Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / include / clang-c / Index.h
blob64ab3378957c70230dc4ab4f62d8e6fa6e35ad8f
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 \*===----------------------------------------------------------------------===*/
16 #ifndef LLVM_CLANG_C_INDEX_H
17 #define LLVM_CLANG_C_INDEX_H
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"
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.
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.
36 #define CINDEX_VERSION_MAJOR 0
37 #define CINDEX_VERSION_MINOR 64
39 #define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
41 #define CINDEX_VERSION \
42 CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
44 #define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
45 #define CINDEX_VERSION_STRINGIZE(major, minor) \
46 CINDEX_VERSION_STRINGIZE_(major, minor)
48 #define CINDEX_VERSION_STRING \
49 CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
51 #ifndef __has_feature
52 #define __has_feature(feature) 0
53 #endif
55 LLVM_CLANG_C_EXTERN_C_BEGIN
57 /** \defgroup CINDEX libclang: C Interface to Clang
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.
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.
70 * To avoid namespace pollution, data types are prefixed with "CX" and
71 * functions are prefixed with "clang_".
73 * @{
76 /**
77 * An "index" that consists of a set of translation units that would
78 * typically be linked together into an executable or library.
80 typedef void *CXIndex;
82 /**
83 * An opaque type representing target information for a given translation
84 * unit.
86 typedef struct CXTargetInfoImpl *CXTargetInfo;
88 /**
89 * A single translation unit, which resides in an index.
91 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
93 /**
94 * Opaque pointer representing client data that will be passed through
95 * to various callbacks and visitors.
97 typedef void *CXClientData;
99 /**
100 * Provides the contents of a file that has not yet been saved to disk.
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.
106 struct CXUnsavedFile {
108 * The file whose contents have not yet been saved.
110 * This file must already exist in the file system.
112 const char *Filename;
115 * A buffer containing the unsaved contents of this file.
117 const char *Contents;
120 * The length of the unsaved contents of this buffer.
122 unsigned long Length;
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.
130 enum CXAvailabilityKind {
132 * The entity is available.
134 CXAvailability_Available,
136 * The entity is available, but has been deprecated (and its use is
137 * not recommended).
139 CXAvailability_Deprecated,
141 * The entity is not available; any use of it will be an error.
143 CXAvailability_NotAvailable,
145 * The entity is available, but not accessible; any use of it will be
146 * an error.
148 CXAvailability_NotAccessible
152 * Describes a version number of the form major.minor.subminor.
154 typedef struct CXVersion {
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.
159 int Major;
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'.
165 int Minor;
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'.
171 int Subminor;
172 } CXVersion;
175 * Describes the exception specification of a cursor.
177 * A negative value indicates that the cursor is not a function declaration.
179 enum CXCursor_ExceptionSpecificationKind {
181 * The cursor has no exception specification.
183 CXCursor_ExceptionSpecificationKind_None,
186 * The cursor has exception specification throw()
188 CXCursor_ExceptionSpecificationKind_DynamicNone,
191 * The cursor has exception specification throw(T1, T2)
193 CXCursor_ExceptionSpecificationKind_Dynamic,
196 * The cursor has exception specification throw(...).
198 CXCursor_ExceptionSpecificationKind_MSAny,
201 * The cursor has exception specification basic noexcept.
203 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
206 * The cursor has exception specification computed noexcept.
208 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
211 * The exception specification has not yet been evaluated.
213 CXCursor_ExceptionSpecificationKind_Unevaluated,
216 * The exception specification has not yet been instantiated.
218 CXCursor_ExceptionSpecificationKind_Uninstantiated,
221 * The exception specification has not been parsed yet.
223 CXCursor_ExceptionSpecificationKind_Unparsed,
226 * The cursor has a __declspec(nothrow) exception specification.
228 CXCursor_ExceptionSpecificationKind_NoThrow
232 * Provides a shared context for creating translation units.
234 * It provides two options:
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.
242 * Here is an example:
244 * \code
245 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
246 * Idx = clang_createIndex(1, 1);
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");
252 * // This will load all the symbols from 'IndexTest.pch'
253 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
254 * TranslationUnitVisitor, 0);
255 * clang_disposeTranslationUnit(TU);
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
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).
271 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
272 int displayDiagnostics);
275 * Destroy the given index.
277 * The index must not be destroyed until all of the translation units created
278 * within that index have been destroyed.
280 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
282 typedef enum {
284 * Use the default value of an option that may depend on the process
285 * environment.
287 CXChoice_Default = 0,
289 * Enable the option.
291 CXChoice_Enabled = 1,
293 * Disable the option.
295 CXChoice_Disabled = 2
296 } CXChoice;
298 typedef enum {
300 * Used to indicate that no special CXIndex options are needed.
302 CXGlobalOpt_None = 0x0,
305 * Used to indicate that threads that libclang creates for indexing
306 * purposes should use background priority.
308 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
309 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
311 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
314 * Used to indicate that threads that libclang creates for editing
315 * purposes should use background priority.
317 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
318 * #clang_annotateTokens
320 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
323 * Used to indicate that all threads that libclang creates should use
324 * background priority.
326 CXGlobalOpt_ThreadBackgroundPriorityForAll =
327 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
328 CXGlobalOpt_ThreadBackgroundPriorityForEditing
330 } CXGlobalOptFlags;
333 * Index initialization options.
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
353 typedef struct CXIndexOptions {
355 * The size of struct CXIndexOptions used for option versioning.
357 * Always initialize this member to sizeof(CXIndexOptions), or assign
358 * sizeof(CXIndexOptions) to it right after creating a CXIndexOptions object.
360 unsigned Size;
362 * A CXChoice enumerator that specifies the indexing priority policy.
363 * \sa CXGlobalOpt_ThreadBackgroundPriorityForIndexing
365 unsigned char ThreadBackgroundPriorityForIndexing;
367 * A CXChoice enumerator that specifies the editing priority policy.
368 * \sa CXGlobalOpt_ThreadBackgroundPriorityForEditing
370 unsigned char ThreadBackgroundPriorityForEditing;
372 * \see clang_createIndex()
374 unsigned ExcludeDeclarationsFromPCH : 1;
376 * \see clang_createIndex()
378 unsigned DisplayDiagnostics : 1;
380 * Store PCH in memory. If zero, PCH are stored in temporary files.
382 unsigned StorePreamblesInMemory : 1;
383 unsigned /*Reserved*/ : 13;
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.
390 * This option is ignored if \a StorePreamblesInMemory is non-zero.
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.
395 const char *PreambleStoragePath;
397 * Specifies a path which will contain log files for certain libclang
398 * invocations. A null value implies that libclang invocations are not logged.
400 const char *InvocationEmissionPath;
401 } CXIndexOptions;
404 * Provides a shared context for creating translation units.
406 * Call this function instead of clang_createIndex() if you need to configure
407 * the additional options in CXIndexOptions.
409 * \returns The created index or null in case of error, such as an unsupported
410 * value of options->Size.
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;
442 * \endcode
444 * \sa clang_createIndex()
446 CINDEX_LINKAGE CXIndex
447 clang_createIndexWithOptions(const CXIndexOptions *options);
450 * Sets general options associated with a CXIndex.
452 * This function is DEPRECATED. Set
453 * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
454 * CXIndexOptions::ThreadBackgroundPriorityForEditing and call
455 * clang_createIndexWithOptions() instead.
457 * For example:
458 * \code
459 * CXIndex idx = ...;
460 * clang_CXIndex_setGlobalOptions(idx,
461 * clang_CXIndex_getGlobalOptions(idx) |
462 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
463 * \endcode
465 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
467 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
470 * Gets the general options associated with a CXIndex.
472 * This function allows to obtain the final option values used by libclang after
473 * specifying the option policies via CXChoice enumerators.
475 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
476 * are associated with the given CXIndex object.
478 CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
481 * Sets the invocation emission path option in a CXIndex.
483 * This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and
484 * call clang_createIndexWithOptions() instead.
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..
490 CINDEX_LINKAGE void
491 clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
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.
498 CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,
499 CXFile file);
502 * Retrieve a file handle within the given translation unit.
504 * \param tu the translation unit
506 * \param file_name the name of the file.
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.
511 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
512 const char *file_name);
515 * Retrieve the buffer associated with the given file.
517 * \param tu the translation unit
519 * \param file the file for which to retrieve the buffer.
521 * \param size [out] if non-NULL, will be set to the size of the buffer.
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.
526 CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
527 CXFile file, size_t *size);
530 * Retrieves the source location associated with a given file/line/column
531 * in a particular translation unit.
533 CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
534 CXFile file, unsigned line,
535 unsigned column);
537 * Retrieves the source location associated with a given character offset
538 * in a particular translation unit.
540 CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
541 CXFile file,
542 unsigned offset);
545 * Retrieve all ranges that were skipped by the preprocessor.
547 * The preprocessor will skip lines when they are surrounded by an
548 * if/ifdef/ifndef directive whose condition does not evaluate to true.
550 CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
551 CXFile file);
554 * Retrieve all ranges from all files that were skipped by the
555 * preprocessor.
557 * The preprocessor will skip lines when they are surrounded by an
558 * if/ifdef/ifndef directive whose condition does not evaluate to true.
560 CINDEX_LINKAGE CXSourceRangeList *
561 clang_getAllSkippedRanges(CXTranslationUnit tu);
564 * Determine the number of diagnostics produced for the given
565 * translation unit.
567 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
570 * Retrieve a diagnostic associated with the given translation unit.
572 * \param Unit the translation unit to query.
573 * \param Index the zero-based diagnostic number to retrieve.
575 * \returns the requested diagnostic. This diagnostic must be freed
576 * via a call to \c clang_disposeDiagnostic().
578 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
579 unsigned Index);
582 * Retrieve the complete set of diagnostics associated with a
583 * translation unit.
585 * \param Unit the translation unit to query.
587 CINDEX_LINKAGE CXDiagnosticSet
588 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
591 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
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.
597 * @{
601 * Get the original translation unit source file name.
603 CINDEX_LINKAGE CXString
604 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
607 * Return the CXTranslationUnit for a given source file and the provided
608 * command line arguments one would pass to the compiler.
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.
614 * Note: When encountered in 'clang_command_line_args', the following options
615 * are ignored:
617 * '-c'
618 * '-emit-ast'
619 * '-fsyntax-only'
620 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
622 * \param CIdx The index object with which the translation unit will be
623 * associated.
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.
628 * \param num_clang_command_line_args The number of command-line arguments in
629 * \p clang_command_line_args.
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>'.
637 * \param num_unsaved_files the number of unsaved file entries in \p
638 * unsaved_files.
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.
646 CINDEX_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);
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.
657 CINDEX_LINKAGE CXTranslationUnit
658 clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
661 * Create a translation unit from an AST file (\c -emit-ast).
663 * \param[out] out_TU A non-NULL pointer to store the created
664 * \c CXTranslationUnit.
666 * \returns Zero on success, otherwise returns an error code.
668 CINDEX_LINKAGE enum CXErrorCode
669 clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
670 CXTranslationUnit *out_TU);
673 * Flags that control the creation of translation units.
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.
679 enum CXTranslationUnit_Flags {
681 * Used to indicate that no special translation-unit options are
682 * needed.
684 CXTranslationUnit_None = 0x0,
687 * Used to indicate that the parser should construct a "detailed"
688 * preprocessing record, including all macro definitions and instantiations.
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.
696 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
699 * Used to indicate that the translation unit is incomplete.
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.
709 CXTranslationUnit_Incomplete = 0x02,
712 * Used to indicate that the translation unit should be built with an
713 * implicit precompiled header for the preamble.
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.
725 CXTranslationUnit_PrecompiledPreamble = 0x04,
728 * Used to indicate that the translation unit should cache some
729 * code-completion results with each reparse of the source file.
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.
735 CXTranslationUnit_CacheCompletionResults = 0x08,
738 * Used to indicate that the translation unit will be serialized with
739 * \c clang_saveTranslationUnit.
741 * This option is typically used when parsing a header with the intent of
742 * producing a precompiled header.
744 CXTranslationUnit_ForSerialization = 0x10,
747 * DEPRECATED: Enabled chained precompiled preambles in C++.
749 * Note: this is a *temporary* option that is available only while
750 * we are testing C++ precompiled preamble support. It is deprecated.
752 CXTranslationUnit_CXXChainedPCH = 0x20,
755 * Used to indicate that function/method bodies should be skipped while
756 * parsing.
758 * This option can be used to search for declarations/definitions while
759 * ignoring the usages.
761 CXTranslationUnit_SkipFunctionBodies = 0x40,
764 * Used to indicate that brief documentation comments should be
765 * included into the set of code completions returned from this translation
766 * unit.
768 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
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).
776 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
779 * Do not stop processing when fatal errors are encountered.
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.
787 CXTranslationUnit_KeepGoing = 0x200,
790 * Sets the preprocessor in a mode for parsing a single file only.
792 CXTranslationUnit_SingleFileParse = 0x400,
795 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
796 * constrain the skipping of function bodies to the preamble.
798 * The function bodies of the main file are not skipped.
800 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
803 * Used to indicate that attributed types should be included in CXType.
805 CXTranslationUnit_IncludeAttributedTypes = 0x1000,
808 * Used to indicate that implicit attributes should be visited.
810 CXTranslationUnit_VisitImplicitAttributes = 0x2000,
813 * Used to indicate that non-errors from included files should be ignored.
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.
820 CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
823 * Tells the preprocessor not to skip excluded conditional blocks.
825 CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
829 * Returns the set of flags that is suitable for parsing a translation
830 * unit that is being edited.
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.
840 CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
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.
848 CINDEX_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);
855 * Parse the given source file and the translation unit corresponding
856 * to that file.
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.
864 * \param CIdx The index object with which the translation unit will be
865 * associated.
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.
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>'.
876 * \param num_command_line_args The number of command-line arguments in
877 * \c command_line_args.
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.
885 * \param num_unsaved_files the number of unsaved file entries in \p
886 * unsaved_files.
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.
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.
896 * \returns Zero on success, otherwise returns an error code.
898 CINDEX_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);
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.
909 CINDEX_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);
916 * Flags that control how translation units are saved.
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.
922 enum CXSaveTranslationUnit_Flags {
924 * Used to indicate that no special saving options are needed.
926 CXSaveTranslationUnit_None = 0x0
930 * Returns the set of flags that is suitable for saving a translation
931 * unit.
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.
938 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
941 * Describes the kind of error that occurred (if any) in a call to
942 * \c clang_saveTranslationUnit().
944 enum CXSaveError {
946 * Indicates that no error occurred while saving a translation unit.
948 CXSaveError_None = 0,
951 * Indicates that an unknown error occurred while attempting to save
952 * the file.
954 * This error typically indicates that file I/O failed when attempting to
955 * write the file.
957 CXSaveError_Unknown = 1,
960 * Indicates that errors during translation prevented this attempt
961 * to save the translation unit.
963 * Errors that prevent the translation unit from being saved can be
964 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
966 CXSaveError_TranslationErrors = 2,
969 * Indicates that the translation unit to be saved was somehow
970 * invalid (e.g., NULL).
972 CXSaveError_InvalidTU = 3
976 * Saves a translation unit into a serialized representation of
977 * that translation unit on disk.
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.
986 * \param TU The translation unit to save.
988 * \param FileName The file to which the translation unit will be saved.
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.
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.
998 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
999 const char *FileName,
1000 unsigned options);
1003 * Suspend a translation unit in order to free memory associated with it.
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.
1009 CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1012 * Destroy the specified CXTranslationUnit object.
1014 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1017 * Flags that control the reparsing of translation units.
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.
1023 enum CXReparse_Flags {
1025 * Used to indicate that no special reparsing options are needed.
1027 CXReparse_None = 0x0
1031 * Returns the set of flags that is suitable for reparsing a translation
1032 * unit.
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.
1040 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1043 * Reparse the source files that produced this translation unit.
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.
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.
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().
1062 * \param num_unsaved_files The number of unsaved file entries in \p
1063 * unsaved_files.
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.
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.
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.
1081 CINDEX_LINKAGE int
1082 clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
1083 struct CXUnsavedFile *unsaved_files,
1084 unsigned options);
1087 * Categorizes how memory is being used by a translation unit.
1089 enum 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,
1108 CXTUResourceUsage_First = CXTUResourceUsage_AST,
1109 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1113 * Returns the human-readable null-terminated C string that represents
1114 * the name of the memory category. This string should never be freed.
1116 CINDEX_LINKAGE
1117 const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1119 typedef 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;
1128 * The memory usage of a CXTranslationUnit, broken into categories.
1130 typedef struct CXTUResourceUsage {
1131 /* Private data member, used for queries. */
1132 void *data;
1134 /* The number of entries in the 'entries' array. */
1135 unsigned numEntries;
1137 /* An array of key-value pairs, representing the breakdown of memory
1138 usage. */
1139 CXTUResourceUsageEntry *entries;
1141 } CXTUResourceUsage;
1144 * Return the memory usage of a translation unit. This object
1145 * should be released with clang_disposeCXTUResourceUsage().
1147 CINDEX_LINKAGE CXTUResourceUsage
1148 clang_getCXTUResourceUsage(CXTranslationUnit TU);
1150 CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1153 * Get target information for this translation unit.
1155 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1157 CINDEX_LINKAGE CXTargetInfo
1158 clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1161 * Destroy the CXTargetInfo object.
1163 CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);
1166 * Get the normalized target triple as a string.
1168 * Returns the empty string in case of any error.
1170 CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);
1173 * Get the pointer width of the target in bits.
1175 * Returns -1 in case of error.
1177 CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1180 * @}
1184 * Describes the kind of entity that a cursor refers to.
1186 enum CXCursorKind {
1187 /* Declarations */
1189 * A declaration whose specific kind is not exposed via this
1190 * interface.
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.
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,
1207 * A field (in C) or non-static data member (in C++) in a
1208 * struct, union, or C++ class.
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,
1278 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1279 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
1281 /* References */
1282 CXCursor_FirstRef = 40, /* Decl references */
1283 CXCursor_ObjCSuperClassRef = 40,
1284 CXCursor_ObjCProtocolRef = 41,
1285 CXCursor_ObjCClassRef = 42,
1287 * A reference to a type declaration.
1289 * A type reference occurs anywhere where a type is named but not
1290 * declared. For example, given:
1292 * \code
1293 * typedef unsigned size_type;
1294 * size_type size;
1295 * \endcode
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.
1301 CXCursor_TypeRef = 43,
1302 CXCursor_CXXBaseSpecifier = 44,
1304 * A reference to a class template, function template, template
1305 * template parameter, or class template partial specialization.
1307 CXCursor_TemplateRef = 45,
1309 * A reference to a namespace or namespace alias.
1311 CXCursor_NamespaceRef = 46,
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.
1316 CXCursor_MemberRef = 47,
1318 * A reference to a labeled statement.
1320 * This cursor kind is used to describe the jump to "start_over" in the
1321 * goto statement in the following example:
1323 * \code
1324 * start_over:
1325 * ++counter;
1327 * goto start_over;
1328 * \endcode
1330 * A label reference cursor refers to a label statement.
1332 CXCursor_LabelRef = 48,
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.
1338 * An overloaded declaration reference cursor occurs in C++ templates where
1339 * a dependent name refers to a function. For example:
1341 * \code
1342 * template<typename T> void swap(T&, T&);
1344 * struct X { ... };
1345 * void swap(X&, X&);
1347 * template<typename T>
1348 * void reverse(T* first, T* last) {
1349 * while (first < last - 1) {
1350 * swap(*first, *--last);
1351 * ++first;
1355 * struct Y { };
1356 * void swap(Y&, Y&);
1357 * \endcode
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).
1366 * The functions \c clang_getNumOverloadedDecls() and
1367 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1368 * referenced by this cursor.
1370 CXCursor_OverloadedDeclRef = 49,
1373 * A reference to a variable that occurs in some non-expression
1374 * context, e.g., a C++ lambda capture list.
1376 CXCursor_VariableRef = 50,
1378 CXCursor_LastRef = CXCursor_VariableRef,
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,
1388 /* Expressions */
1389 CXCursor_FirstExpr = 100,
1392 * An expression whose specific kind is not exposed via this
1393 * interface.
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.
1400 CXCursor_UnexposedExpr = 100,
1403 * An expression that refers to some value declaration, such
1404 * as a function, variable, or enumerator.
1406 CXCursor_DeclRefExpr = 101,
1409 * An expression that refers to a member of a struct, union,
1410 * class, Objective-C class, etc.
1412 CXCursor_MemberRefExpr = 102,
1414 /** An expression that calls a function. */
1415 CXCursor_CallExpr = 103,
1417 /** An expression that sends a message to an Objective-C
1418 object or class. */
1419 CXCursor_ObjCMessageExpr = 104,
1421 /** An expression that represents a block literal. */
1422 CXCursor_BlockExpr = 105,
1424 /** An integer literal.
1426 CXCursor_IntegerLiteral = 106,
1428 /** A floating point number literal.
1430 CXCursor_FloatingLiteral = 107,
1432 /** An imaginary number literal.
1434 CXCursor_ImaginaryLiteral = 108,
1436 /** A string literal.
1438 CXCursor_StringLiteral = 109,
1440 /** A character literal.
1442 CXCursor_CharacterLiteral = 110,
1444 /** A parenthesized expression, e.g. "(1)".
1446 * This AST node is only formed if full location information is requested.
1448 CXCursor_ParenExpr = 111,
1450 /** This represents the unary-expression's (except sizeof and
1451 * alignof).
1453 CXCursor_UnaryOperator = 112,
1455 /** [C99 6.5.2.1] Array Subscripting.
1457 CXCursor_ArraySubscriptExpr = 113,
1459 /** A builtin binary operation expression such as "x + y" or
1460 * "x <= y".
1462 CXCursor_BinaryOperator = 114,
1464 /** Compound assignment such as "+=".
1466 CXCursor_CompoundAssignOperator = 115,
1468 /** The ?: ternary operator.
1470 CXCursor_ConditionalOperator = 116,
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.
1475 * For example: (int)f.
1477 CXCursor_CStyleCastExpr = 117,
1479 /** [C99 6.5.2.5]
1481 CXCursor_CompoundLiteralExpr = 118,
1483 /** Describes an C or C++ initializer list.
1485 CXCursor_InitListExpr = 119,
1487 /** The GNU address of label extension, representing &&label.
1489 CXCursor_AddrLabelExpr = 120,
1491 /** This is the GNU Statement Expression extension: ({int X=4; X;})
1493 CXCursor_StmtExpr = 121,
1495 /** Represents a C11 generic selection.
1497 CXCursor_GenericSelectionExpr = 122,
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.
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).
1507 CXCursor_GNUNullExpr = 123,
1509 /** C++'s static_cast<> expression.
1511 CXCursor_CXXStaticCastExpr = 124,
1513 /** C++'s dynamic_cast<> expression.
1515 CXCursor_CXXDynamicCastExpr = 125,
1517 /** C++'s reinterpret_cast<> expression.
1519 CXCursor_CXXReinterpretCastExpr = 126,
1521 /** C++'s const_cast<> expression.
1523 CXCursor_CXXConstCastExpr = 127,
1525 /** Represents an explicit C++ type conversion that uses "functional"
1526 * notion (C++ [expr.type.conv]).
1528 * Example:
1529 * \code
1530 * x = int(0.5);
1531 * \endcode
1533 CXCursor_CXXFunctionalCastExpr = 128,
1535 /** A C++ typeid expression (C++ [expr.typeid]).
1537 CXCursor_CXXTypeidExpr = 129,
1539 /** [C++ 2.13.5] C++ Boolean Literal.
1541 CXCursor_CXXBoolLiteralExpr = 130,
1543 /** [C++0x 2.14.7] C++ Pointer Literal.
1545 CXCursor_CXXNullPtrLiteralExpr = 131,
1547 /** Represents the "this" expression in C++
1549 CXCursor_CXXThisExpr = 132,
1551 /** [C++ 15] C++ Throw Expression.
1553 * This handles 'throw' and 'throw' assignment-expression. When
1554 * assignment-expression isn't present, Op will be null.
1556 CXCursor_CXXThrowExpr = 133,
1558 /** A new expression for memory allocation and constructor calls, e.g:
1559 * "new CXXNewExpr(foo)".
1561 CXCursor_CXXNewExpr = 134,
1563 /** A delete expression for memory deallocation and destructor calls,
1564 * e.g. "delete[] pArray".
1566 CXCursor_CXXDeleteExpr = 135,
1568 /** A unary expression. (noexcept, sizeof, or other traits)
1570 CXCursor_UnaryExpr = 136,
1572 /** An Objective-C string literal i.e. @"foo".
1574 CXCursor_ObjCStringLiteral = 137,
1576 /** An Objective-C \@encode expression.
1578 CXCursor_ObjCEncodeExpr = 138,
1580 /** An Objective-C \@selector expression.
1582 CXCursor_ObjCSelectorExpr = 139,
1584 /** An Objective-C \@protocol expression.
1586 CXCursor_ObjCProtocolExpr = 140,
1588 /** An Objective-C "bridged" cast expression, which casts between
1589 * Objective-C pointers and C pointers, transferring ownership in the process.
1591 * \code
1592 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
1593 * \endcode
1595 CXCursor_ObjCBridgedCastExpr = 141,
1597 /** Represents a C++0x pack expansion that produces a sequence of
1598 * expressions.
1600 * A pack expansion expression contains a pattern (which itself is an
1601 * expression) followed by an ellipsis. For example:
1603 * \code
1604 * template<typename F, typename ...Types>
1605 * void forward(F f, Types &&...args) {
1606 * f(static_cast<Types&&>(args)...);
1608 * \endcode
1610 CXCursor_PackExpansionExpr = 142,
1612 /** Represents an expression that computes the length of a parameter
1613 * pack.
1615 * \code
1616 * template<typename ...Types>
1617 * struct count {
1618 * static const unsigned value = sizeof...(Types);
1619 * };
1620 * \endcode
1622 CXCursor_SizeOfPackExpr = 143,
1624 /* Represents a C++ lambda expression that produces a local function
1625 * object.
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 * });
1634 * \endcode
1636 CXCursor_LambdaExpr = 144,
1638 /** Objective-c Boolean Literal.
1640 CXCursor_ObjCBoolLiteralExpr = 145,
1642 /** Represents the "self" expression in an Objective-C method.
1644 CXCursor_ObjCSelfExpr = 146,
1646 /** OpenMP 5.0 [2.1.5, Array Section].
1648 CXCursor_OMPArraySectionExpr = 147,
1650 /** Represents an @available(...) check.
1652 CXCursor_ObjCAvailabilityCheckExpr = 148,
1655 * Fixed point literal
1657 CXCursor_FixedPointLiteral = 149,
1659 /** OpenMP 5.0 [2.1.4, Array Shaping].
1661 CXCursor_OMPArrayShapingExpr = 150,
1664 * OpenMP 5.0 [2.1.6 Iterators]
1666 CXCursor_OMPIteratorExpr = 151,
1668 /** OpenCL's addrspace_cast<> expression.
1670 CXCursor_CXXAddrspaceCastExpr = 152,
1673 * Expression that references a C++20 concept.
1675 CXCursor_ConceptSpecializationExpr = 153,
1678 * Expression that references a C++20 concept.
1680 CXCursor_RequiresExpr = 154,
1683 * Expression that references a C++20 parenthesized list aggregate
1684 * initializer.
1686 CXCursor_CXXParenListInitExpr = 155,
1688 CXCursor_LastExpr = CXCursor_CXXParenListInitExpr,
1690 /* Statements */
1691 CXCursor_FirstStmt = 200,
1693 * A statement whose specific kind is not exposed via this
1694 * interface.
1696 * Unexposed statements have the same operations as any other kind of
1697 * statement; one can extract their location information, spelling,
1698 * children, etc. However, the specific kind of the statement is not
1699 * reported.
1701 CXCursor_UnexposedStmt = 200,
1703 /** A labelled statement in a function.
1705 * This cursor kind is used to describe the "start_over:" label statement in
1706 * the following example:
1708 * \code
1709 * start_over:
1710 * ++counter;
1711 * \endcode
1714 CXCursor_LabelStmt = 201,
1716 /** A group of statements like { stmt stmt }.
1718 * This cursor kind is used to describe compound statements, e.g. function
1719 * bodies.
1721 CXCursor_CompoundStmt = 202,
1723 /** A case statement.
1725 CXCursor_CaseStmt = 203,
1727 /** A default statement.
1729 CXCursor_DefaultStmt = 204,
1731 /** An if statement
1733 CXCursor_IfStmt = 205,
1735 /** A switch statement.
1737 CXCursor_SwitchStmt = 206,
1739 /** A while statement.
1741 CXCursor_WhileStmt = 207,
1743 /** A do statement.
1745 CXCursor_DoStmt = 208,
1747 /** A for statement.
1749 CXCursor_ForStmt = 209,
1751 /** A goto statement.
1753 CXCursor_GotoStmt = 210,
1755 /** An indirect goto statement.
1757 CXCursor_IndirectGotoStmt = 211,
1759 /** A continue statement.
1761 CXCursor_ContinueStmt = 212,
1763 /** A break statement.
1765 CXCursor_BreakStmt = 213,
1767 /** A return statement.
1769 CXCursor_ReturnStmt = 214,
1771 /** A GCC inline assembly statement extension.
1773 CXCursor_GCCAsmStmt = 215,
1774 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
1776 /** Objective-C's overall \@try-\@catch-\@finally statement.
1778 CXCursor_ObjCAtTryStmt = 216,
1780 /** Objective-C's \@catch statement.
1782 CXCursor_ObjCAtCatchStmt = 217,
1784 /** Objective-C's \@finally statement.
1786 CXCursor_ObjCAtFinallyStmt = 218,
1788 /** Objective-C's \@throw statement.
1790 CXCursor_ObjCAtThrowStmt = 219,
1792 /** Objective-C's \@synchronized statement.
1794 CXCursor_ObjCAtSynchronizedStmt = 220,
1796 /** Objective-C's autorelease pool statement.
1798 CXCursor_ObjCAutoreleasePoolStmt = 221,
1800 /** Objective-C's collection statement.
1802 CXCursor_ObjCForCollectionStmt = 222,
1804 /** C++'s catch statement.
1806 CXCursor_CXXCatchStmt = 223,
1808 /** C++'s try statement.
1810 CXCursor_CXXTryStmt = 224,
1812 /** C++'s for (* : *) statement.
1814 CXCursor_CXXForRangeStmt = 225,
1816 /** Windows Structured Exception Handling's try statement.
1818 CXCursor_SEHTryStmt = 226,
1820 /** Windows Structured Exception Handling's except statement.
1822 CXCursor_SEHExceptStmt = 227,
1824 /** Windows Structured Exception Handling's finally statement.
1826 CXCursor_SEHFinallyStmt = 228,
1828 /** A MS inline assembly statement extension.
1830 CXCursor_MSAsmStmt = 229,
1832 /** The null statement ";": C99 6.8.3p3.
1834 * This cursor kind is used to describe the null statement.
1836 CXCursor_NullStmt = 230,
1838 /** Adaptor class for mixing declarations with statements and
1839 * expressions.
1841 CXCursor_DeclStmt = 231,
1843 /** OpenMP parallel directive.
1845 CXCursor_OMPParallelDirective = 232,
1847 /** OpenMP SIMD directive.
1849 CXCursor_OMPSimdDirective = 233,
1851 /** OpenMP for directive.
1853 CXCursor_OMPForDirective = 234,
1855 /** OpenMP sections directive.
1857 CXCursor_OMPSectionsDirective = 235,
1859 /** OpenMP section directive.
1861 CXCursor_OMPSectionDirective = 236,
1863 /** OpenMP single directive.
1865 CXCursor_OMPSingleDirective = 237,
1867 /** OpenMP parallel for directive.
1869 CXCursor_OMPParallelForDirective = 238,
1871 /** OpenMP parallel sections directive.
1873 CXCursor_OMPParallelSectionsDirective = 239,
1875 /** OpenMP task directive.
1877 CXCursor_OMPTaskDirective = 240,
1879 /** OpenMP master directive.
1881 CXCursor_OMPMasterDirective = 241,
1883 /** OpenMP critical directive.
1885 CXCursor_OMPCriticalDirective = 242,
1887 /** OpenMP taskyield directive.
1889 CXCursor_OMPTaskyieldDirective = 243,
1891 /** OpenMP barrier directive.
1893 CXCursor_OMPBarrierDirective = 244,
1895 /** OpenMP taskwait directive.
1897 CXCursor_OMPTaskwaitDirective = 245,
1899 /** OpenMP flush directive.
1901 CXCursor_OMPFlushDirective = 246,
1903 /** Windows Structured Exception Handling's leave statement.
1905 CXCursor_SEHLeaveStmt = 247,
1907 /** OpenMP ordered directive.
1909 CXCursor_OMPOrderedDirective = 248,
1911 /** OpenMP atomic directive.
1913 CXCursor_OMPAtomicDirective = 249,
1915 /** OpenMP for SIMD directive.
1917 CXCursor_OMPForSimdDirective = 250,
1919 /** OpenMP parallel for SIMD directive.
1921 CXCursor_OMPParallelForSimdDirective = 251,
1923 /** OpenMP target directive.
1925 CXCursor_OMPTargetDirective = 252,
1927 /** OpenMP teams directive.
1929 CXCursor_OMPTeamsDirective = 253,
1931 /** OpenMP taskgroup directive.
1933 CXCursor_OMPTaskgroupDirective = 254,
1935 /** OpenMP cancellation point directive.
1937 CXCursor_OMPCancellationPointDirective = 255,
1939 /** OpenMP cancel directive.
1941 CXCursor_OMPCancelDirective = 256,
1943 /** OpenMP target data directive.
1945 CXCursor_OMPTargetDataDirective = 257,
1947 /** OpenMP taskloop directive.
1949 CXCursor_OMPTaskLoopDirective = 258,
1951 /** OpenMP taskloop simd directive.
1953 CXCursor_OMPTaskLoopSimdDirective = 259,
1955 /** OpenMP distribute directive.
1957 CXCursor_OMPDistributeDirective = 260,
1959 /** OpenMP target enter data directive.
1961 CXCursor_OMPTargetEnterDataDirective = 261,
1963 /** OpenMP target exit data directive.
1965 CXCursor_OMPTargetExitDataDirective = 262,
1967 /** OpenMP target parallel directive.
1969 CXCursor_OMPTargetParallelDirective = 263,
1971 /** OpenMP target parallel for directive.
1973 CXCursor_OMPTargetParallelForDirective = 264,
1975 /** OpenMP target update directive.
1977 CXCursor_OMPTargetUpdateDirective = 265,
1979 /** OpenMP distribute parallel for directive.
1981 CXCursor_OMPDistributeParallelForDirective = 266,
1983 /** OpenMP distribute parallel for simd directive.
1985 CXCursor_OMPDistributeParallelForSimdDirective = 267,
1987 /** OpenMP distribute simd directive.
1989 CXCursor_OMPDistributeSimdDirective = 268,
1991 /** OpenMP target parallel for simd directive.
1993 CXCursor_OMPTargetParallelForSimdDirective = 269,
1995 /** OpenMP target simd directive.
1997 CXCursor_OMPTargetSimdDirective = 270,
1999 /** OpenMP teams distribute directive.
2001 CXCursor_OMPTeamsDistributeDirective = 271,
2003 /** OpenMP teams distribute simd directive.
2005 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2007 /** OpenMP teams distribute parallel for simd directive.
2009 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2011 /** OpenMP teams distribute parallel for directive.
2013 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2015 /** OpenMP target teams directive.
2017 CXCursor_OMPTargetTeamsDirective = 275,
2019 /** OpenMP target teams distribute directive.
2021 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2023 /** OpenMP target teams distribute parallel for directive.
2025 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2027 /** OpenMP target teams distribute parallel for simd directive.
2029 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2031 /** OpenMP target teams distribute simd directive.
2033 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2035 /** C++2a std::bit_cast expression.
2037 CXCursor_BuiltinBitCastExpr = 280,
2039 /** OpenMP master taskloop directive.
2041 CXCursor_OMPMasterTaskLoopDirective = 281,
2043 /** OpenMP parallel master taskloop directive.
2045 CXCursor_OMPParallelMasterTaskLoopDirective = 282,
2047 /** OpenMP master taskloop simd directive.
2049 CXCursor_OMPMasterTaskLoopSimdDirective = 283,
2051 /** OpenMP parallel master taskloop simd directive.
2053 CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
2055 /** OpenMP parallel master directive.
2057 CXCursor_OMPParallelMasterDirective = 285,
2059 /** OpenMP depobj directive.
2061 CXCursor_OMPDepobjDirective = 286,
2063 /** OpenMP scan directive.
2065 CXCursor_OMPScanDirective = 287,
2067 /** OpenMP tile directive.
2069 CXCursor_OMPTileDirective = 288,
2071 /** OpenMP canonical loop.
2073 CXCursor_OMPCanonicalLoop = 289,
2075 /** OpenMP interop directive.
2077 CXCursor_OMPInteropDirective = 290,
2079 /** OpenMP dispatch directive.
2081 CXCursor_OMPDispatchDirective = 291,
2083 /** OpenMP masked directive.
2085 CXCursor_OMPMaskedDirective = 292,
2087 /** OpenMP unroll directive.
2089 CXCursor_OMPUnrollDirective = 293,
2091 /** OpenMP metadirective directive.
2093 CXCursor_OMPMetaDirective = 294,
2095 /** OpenMP loop directive.
2097 CXCursor_OMPGenericLoopDirective = 295,
2099 /** OpenMP teams loop directive.
2101 CXCursor_OMPTeamsGenericLoopDirective = 296,
2103 /** OpenMP target teams loop directive.
2105 CXCursor_OMPTargetTeamsGenericLoopDirective = 297,
2107 /** OpenMP parallel loop directive.
2109 CXCursor_OMPParallelGenericLoopDirective = 298,
2111 /** OpenMP target parallel loop directive.
2113 CXCursor_OMPTargetParallelGenericLoopDirective = 299,
2115 /** OpenMP parallel masked directive.
2117 CXCursor_OMPParallelMaskedDirective = 300,
2119 /** OpenMP masked taskloop directive.
2121 CXCursor_OMPMaskedTaskLoopDirective = 301,
2123 /** OpenMP masked taskloop simd directive.
2125 CXCursor_OMPMaskedTaskLoopSimdDirective = 302,
2127 /** OpenMP parallel masked taskloop directive.
2129 CXCursor_OMPParallelMaskedTaskLoopDirective = 303,
2131 /** OpenMP parallel masked taskloop simd directive.
2133 CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304,
2135 /** OpenMP error directive.
2137 CXCursor_OMPErrorDirective = 305,
2139 /** OpenMP scope directive.
2141 CXCursor_OMPScopeDirective = 306,
2143 CXCursor_LastStmt = CXCursor_OMPScopeDirective,
2146 * Cursor that represents the translation unit itself.
2148 * The translation unit cursor exists primarily to act as the root
2149 * cursor for traversing the contents of a translation unit.
2151 CXCursor_TranslationUnit = 350,
2153 /* Attributes */
2154 CXCursor_FirstAttr = 400,
2156 * An attribute whose specific kind is not exposed via this
2157 * interface.
2159 CXCursor_UnexposedAttr = 400,
2161 CXCursor_IBActionAttr = 401,
2162 CXCursor_IBOutletAttr = 402,
2163 CXCursor_IBOutletCollectionAttr = 403,
2164 CXCursor_CXXFinalAttr = 404,
2165 CXCursor_CXXOverrideAttr = 405,
2166 CXCursor_AnnotateAttr = 406,
2167 CXCursor_AsmLabelAttr = 407,
2168 CXCursor_PackedAttr = 408,
2169 CXCursor_PureAttr = 409,
2170 CXCursor_ConstAttr = 410,
2171 CXCursor_NoDuplicateAttr = 411,
2172 CXCursor_CUDAConstantAttr = 412,
2173 CXCursor_CUDADeviceAttr = 413,
2174 CXCursor_CUDAGlobalAttr = 414,
2175 CXCursor_CUDAHostAttr = 415,
2176 CXCursor_CUDASharedAttr = 416,
2177 CXCursor_VisibilityAttr = 417,
2178 CXCursor_DLLExport = 418,
2179 CXCursor_DLLImport = 419,
2180 CXCursor_NSReturnsRetained = 420,
2181 CXCursor_NSReturnsNotRetained = 421,
2182 CXCursor_NSReturnsAutoreleased = 422,
2183 CXCursor_NSConsumesSelf = 423,
2184 CXCursor_NSConsumed = 424,
2185 CXCursor_ObjCException = 425,
2186 CXCursor_ObjCNSObject = 426,
2187 CXCursor_ObjCIndependentClass = 427,
2188 CXCursor_ObjCPreciseLifetime = 428,
2189 CXCursor_ObjCReturnsInnerPointer = 429,
2190 CXCursor_ObjCRequiresSuper = 430,
2191 CXCursor_ObjCRootClass = 431,
2192 CXCursor_ObjCSubclassingRestricted = 432,
2193 CXCursor_ObjCExplicitProtocolImpl = 433,
2194 CXCursor_ObjCDesignatedInitializer = 434,
2195 CXCursor_ObjCRuntimeVisible = 435,
2196 CXCursor_ObjCBoxable = 436,
2197 CXCursor_FlagEnum = 437,
2198 CXCursor_ConvergentAttr = 438,
2199 CXCursor_WarnUnusedAttr = 439,
2200 CXCursor_WarnUnusedResultAttr = 440,
2201 CXCursor_AlignedAttr = 441,
2202 CXCursor_LastAttr = CXCursor_AlignedAttr,
2204 /* Preprocessing */
2205 CXCursor_PreprocessingDirective = 500,
2206 CXCursor_MacroDefinition = 501,
2207 CXCursor_MacroExpansion = 502,
2208 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2209 CXCursor_InclusionDirective = 503,
2210 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2211 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2213 /* Extra Declarations */
2215 * A module import declaration.
2217 CXCursor_ModuleImportDecl = 600,
2218 CXCursor_TypeAliasTemplateDecl = 601,
2220 * A static_assert or _Static_assert node
2222 CXCursor_StaticAssert = 602,
2224 * a friend declaration.
2226 CXCursor_FriendDecl = 603,
2228 * a concept declaration.
2230 CXCursor_ConceptDecl = 604,
2232 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2233 CXCursor_LastExtraDecl = CXCursor_ConceptDecl,
2236 * A code completion overload candidate.
2238 CXCursor_OverloadCandidate = 700
2242 * A cursor representing some element in the abstract syntax tree for
2243 * a translation unit.
2245 * The cursor abstraction unifies the different kinds of entities in a
2246 * program--declaration, statements, expressions, references to declarations,
2247 * etc.--under a single "cursor" abstraction with a common set of operations.
2248 * Common operation for a cursor include: getting the physical location in
2249 * a source file where the cursor points, getting the name associated with a
2250 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2252 * Cursors can be produced in two specific ways.
2253 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2254 * from which one can use clang_visitChildren() to explore the rest of the
2255 * translation unit. clang_getCursor() maps from a physical source location
2256 * to the entity that resides at that location, allowing one to map from the
2257 * source code into the AST.
2259 typedef struct {
2260 enum CXCursorKind kind;
2261 int xdata;
2262 const void *data[3];
2263 } CXCursor;
2266 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2268 * @{
2272 * Retrieve the NULL cursor, which represents no entity.
2274 CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2277 * Retrieve the cursor that represents the given translation unit.
2279 * The translation unit cursor can be used to start traversing the
2280 * various declarations within the given translation unit.
2282 CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2285 * Determine whether two cursors are equivalent.
2287 CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2290 * Returns non-zero if \p cursor is null.
2292 CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2295 * Compute a hash value for the given cursor.
2297 CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2300 * Retrieve the kind of the given cursor.
2302 CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2305 * Determine whether the given cursor kind represents a declaration.
2307 CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2310 * Determine whether the given declaration is invalid.
2312 * A declaration is invalid if it could not be parsed successfully.
2314 * \returns non-zero if the cursor represents a declaration and it is
2315 * invalid, otherwise NULL.
2317 CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2320 * Determine whether the given cursor kind represents a simple
2321 * reference.
2323 * Note that other kinds of cursors (such as expressions) can also refer to
2324 * other cursors. Use clang_getCursorReferenced() to determine whether a
2325 * particular cursor refers to another entity.
2327 CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2330 * Determine whether the given cursor kind represents an expression.
2332 CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2335 * Determine whether the given cursor kind represents a statement.
2337 CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2340 * Determine whether the given cursor kind represents an attribute.
2342 CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2345 * Determine whether the given cursor has any attributes.
2347 CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2350 * Determine whether the given cursor kind represents an invalid
2351 * cursor.
2353 CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2356 * Determine whether the given cursor kind represents a translation
2357 * unit.
2359 CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2361 /***
2362 * Determine whether the given cursor represents a preprocessing
2363 * element, such as a preprocessor directive or macro instantiation.
2365 CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2367 /***
2368 * Determine whether the given cursor represents a currently
2369 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2371 CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2374 * Describe the linkage of the entity referred to by a cursor.
2376 enum CXLinkageKind {
2377 /** This value indicates that no linkage information is available
2378 * for a provided CXCursor. */
2379 CXLinkage_Invalid,
2381 * This is the linkage for variables, parameters, and so on that
2382 * have automatic storage. This covers normal (non-extern) local variables.
2384 CXLinkage_NoLinkage,
2385 /** This is the linkage for static variables and static functions. */
2386 CXLinkage_Internal,
2387 /** This is the linkage for entities with external linkage that live
2388 * in C++ anonymous namespaces.*/
2389 CXLinkage_UniqueExternal,
2390 /** This is the linkage for entities with true, external linkage. */
2391 CXLinkage_External
2395 * Determine the linkage of the entity referred to by a given cursor.
2397 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2399 enum CXVisibilityKind {
2400 /** This value indicates that no visibility information is available
2401 * for a provided CXCursor. */
2402 CXVisibility_Invalid,
2404 /** Symbol not seen by the linker. */
2405 CXVisibility_Hidden,
2406 /** Symbol seen by the linker but resolves to a symbol inside this object. */
2407 CXVisibility_Protected,
2408 /** Symbol seen by the linker and acts like a normal symbol. */
2409 CXVisibility_Default
2413 * Describe the visibility of the entity referred to by a cursor.
2415 * This returns the default visibility if not explicitly specified by
2416 * a visibility attribute. The default visibility may be changed by
2417 * commandline arguments.
2419 * \param cursor The cursor to query.
2421 * \returns The visibility of the cursor.
2423 CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2426 * Determine the availability of the entity that this cursor refers to,
2427 * taking the current target platform into account.
2429 * \param cursor The cursor to query.
2431 * \returns The availability of the cursor.
2433 CINDEX_LINKAGE enum CXAvailabilityKind
2434 clang_getCursorAvailability(CXCursor cursor);
2437 * Describes the availability of a given entity on a particular platform, e.g.,
2438 * a particular class might only be available on Mac OS 10.7 or newer.
2440 typedef struct CXPlatformAvailability {
2442 * A string that describes the platform for which this structure
2443 * provides availability information.
2445 * Possible values are "ios" or "macos".
2447 CXString Platform;
2449 * The version number in which this entity was introduced.
2451 CXVersion Introduced;
2453 * The version number in which this entity was deprecated (but is
2454 * still available).
2456 CXVersion Deprecated;
2458 * The version number in which this entity was obsoleted, and therefore
2459 * is no longer available.
2461 CXVersion Obsoleted;
2463 * Whether the entity is unconditionally unavailable on this platform.
2465 int Unavailable;
2467 * An optional message to provide to a user of this API, e.g., to
2468 * suggest replacement APIs.
2470 CXString Message;
2471 } CXPlatformAvailability;
2474 * Determine the availability of the entity that this cursor refers to
2475 * on any platforms for which availability information is known.
2477 * \param cursor The cursor to query.
2479 * \param always_deprecated If non-NULL, will be set to indicate whether the
2480 * entity is deprecated on all platforms.
2482 * \param deprecated_message If non-NULL, will be set to the message text
2483 * provided along with the unconditional deprecation of this entity. The client
2484 * is responsible for deallocating this string.
2486 * \param always_unavailable If non-NULL, will be set to indicate whether the
2487 * entity is unavailable on all platforms.
2489 * \param unavailable_message If non-NULL, will be set to the message text
2490 * provided along with the unconditional unavailability of this entity. The
2491 * client is responsible for deallocating this string.
2493 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2494 * that will be populated with platform availability information, up to either
2495 * the number of platforms for which availability information is available (as
2496 * returned by this function) or \c availability_size, whichever is smaller.
2498 * \param availability_size The number of elements available in the
2499 * \c availability array.
2501 * \returns The number of platforms (N) for which availability information is
2502 * available (which is unrelated to \c availability_size).
2504 * Note that the client is responsible for calling
2505 * \c clang_disposeCXPlatformAvailability to free each of the
2506 * platform-availability structures returned. There are
2507 * \c min(N, availability_size) such structures.
2509 CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
2510 CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
2511 int *always_unavailable, CXString *unavailable_message,
2512 CXPlatformAvailability *availability, int availability_size);
2515 * Free the memory associated with a \c CXPlatformAvailability structure.
2517 CINDEX_LINKAGE void
2518 clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2521 * If cursor refers to a variable declaration and it has initializer returns
2522 * cursor referring to the initializer otherwise return null cursor.
2524 CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);
2527 * If cursor refers to a variable declaration that has global storage returns 1.
2528 * If cursor refers to a variable declaration that doesn't have global storage
2529 * returns 0. Otherwise returns -1.
2531 CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);
2534 * If cursor refers to a variable declaration that has external storage
2535 * returns 1. If cursor refers to a variable declaration that doesn't have
2536 * external storage returns 0. Otherwise returns -1.
2538 CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);
2541 * Describe the "language" of the entity referred to by a cursor.
2543 enum CXLanguageKind {
2544 CXLanguage_Invalid = 0,
2545 CXLanguage_C,
2546 CXLanguage_ObjC,
2547 CXLanguage_CPlusPlus
2551 * Determine the "language" of the entity referred to by a given cursor.
2553 CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2556 * Describe the "thread-local storage (TLS) kind" of the declaration
2557 * referred to by a cursor.
2559 enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
2562 * Determine the "thread-local storage (TLS) kind" of the declaration
2563 * referred to by a cursor.
2565 CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2568 * Returns the translation unit that a cursor originated from.
2570 CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2573 * A fast container representing a set of CXCursors.
2575 typedef struct CXCursorSetImpl *CXCursorSet;
2578 * Creates an empty CXCursorSet.
2580 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2583 * Disposes a CXCursorSet and releases its associated memory.
2585 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2588 * Queries a CXCursorSet to see if it contains a specific CXCursor.
2590 * \returns non-zero if the set contains the specified cursor.
2592 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2593 CXCursor cursor);
2596 * Inserts a CXCursor into a CXCursorSet.
2598 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2600 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2601 CXCursor cursor);
2604 * Determine the semantic parent of the given cursor.
2606 * The semantic parent of a cursor is the cursor that semantically contains
2607 * the given \p cursor. For many declarations, the lexical and semantic parents
2608 * are equivalent (the lexical parent is returned by
2609 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2610 * definitions are provided out-of-line. For example:
2612 * \code
2613 * class C {
2614 * void f();
2615 * };
2617 * void C::f() { }
2618 * \endcode
2620 * In the out-of-line definition of \c C::f, the semantic parent is
2621 * the class \c C, of which this function is a member. The lexical parent is
2622 * the place where the declaration actually occurs in the source code; in this
2623 * case, the definition occurs in the translation unit. In general, the
2624 * lexical parent for a given entity can change without affecting the semantics
2625 * of the program, and the lexical parent of different declarations of the
2626 * same entity may be different. Changing the semantic parent of a declaration,
2627 * on the other hand, can have a major impact on semantics, and redeclarations
2628 * of a particular entity should all have the same semantic context.
2630 * In the example above, both declarations of \c C::f have \c C as their
2631 * semantic context, while the lexical context of the first \c C::f is \c C
2632 * and the lexical context of the second \c C::f is the translation unit.
2634 * For global declarations, the semantic parent is the translation unit.
2636 CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2639 * Determine the lexical parent of the given cursor.
2641 * The lexical parent of a cursor is the cursor in which the given \p cursor
2642 * was actually written. For many declarations, the lexical and semantic parents
2643 * are equivalent (the semantic parent is returned by
2644 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2645 * definitions are provided out-of-line. For example:
2647 * \code
2648 * class C {
2649 * void f();
2650 * };
2652 * void C::f() { }
2653 * \endcode
2655 * In the out-of-line definition of \c C::f, the semantic parent is
2656 * the class \c C, of which this function is a member. The lexical parent is
2657 * the place where the declaration actually occurs in the source code; in this
2658 * case, the definition occurs in the translation unit. In general, the
2659 * lexical parent for a given entity can change without affecting the semantics
2660 * of the program, and the lexical parent of different declarations of the
2661 * same entity may be different. Changing the semantic parent of a declaration,
2662 * on the other hand, can have a major impact on semantics, and redeclarations
2663 * of a particular entity should all have the same semantic context.
2665 * In the example above, both declarations of \c C::f have \c C as their
2666 * semantic context, while the lexical context of the first \c C::f is \c C
2667 * and the lexical context of the second \c C::f is the translation unit.
2669 * For declarations written in the global scope, the lexical parent is
2670 * the translation unit.
2672 CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2675 * Determine the set of methods that are overridden by the given
2676 * method.
2678 * In both Objective-C and C++, a method (aka virtual member function,
2679 * in C++) can override a virtual method in a base class. For
2680 * Objective-C, a method is said to override any method in the class's
2681 * base class, its protocols, or its categories' protocols, that has the same
2682 * selector and is of the same kind (class or instance).
2683 * If no such method exists, the search continues to the class's superclass,
2684 * its protocols, and its categories, and so on. A method from an Objective-C
2685 * implementation is considered to override the same methods as its
2686 * corresponding method in the interface.
2688 * For C++, a virtual member function overrides any virtual member
2689 * function with the same signature that occurs in its base
2690 * classes. With multiple inheritance, a virtual member function can
2691 * override several virtual member functions coming from different
2692 * base classes.
2694 * In all cases, this function determines the immediate overridden
2695 * method, rather than all of the overridden methods. For example, if
2696 * a method is originally declared in a class A, then overridden in B
2697 * (which in inherits from A) and also in C (which inherited from B),
2698 * then the only overridden method returned from this function when
2699 * invoked on C's method will be B's method. The client may then
2700 * invoke this function again, given the previously-found overridden
2701 * methods, to map out the complete method-override set.
2703 * \param cursor A cursor representing an Objective-C or C++
2704 * method. This routine will compute the set of methods that this
2705 * method overrides.
2707 * \param overridden A pointer whose pointee will be replaced with a
2708 * pointer to an array of cursors, representing the set of overridden
2709 * methods. If there are no overridden methods, the pointee will be
2710 * set to NULL. The pointee must be freed via a call to
2711 * \c clang_disposeOverriddenCursors().
2713 * \param num_overridden A pointer to the number of overridden
2714 * functions, will be set to the number of overridden functions in the
2715 * array pointed to by \p overridden.
2717 CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2718 CXCursor **overridden,
2719 unsigned *num_overridden);
2722 * Free the set of overridden cursors returned by \c
2723 * clang_getOverriddenCursors().
2725 CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2728 * Retrieve the file that is included by the given inclusion directive
2729 * cursor.
2731 CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2734 * @}
2738 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2740 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2741 * routines help map between cursors and the physical locations where the
2742 * described entities occur in the source code. The mapping is provided in
2743 * both directions, so one can map from source code to the AST and back.
2745 * @{
2749 * Map a source location to the cursor that describes the entity at that
2750 * location in the source code.
2752 * clang_getCursor() maps an arbitrary source location within a translation
2753 * unit down to the most specific cursor that describes the entity at that
2754 * location. For example, given an expression \c x + y, invoking
2755 * clang_getCursor() with a source location pointing to "x" will return the
2756 * cursor for "x"; similarly for "y". If the cursor points anywhere between
2757 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2758 * will return a cursor referring to the "+" expression.
2760 * \returns a cursor representing the entity at the given source location, or
2761 * a NULL cursor if no such entity can be found.
2763 CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2766 * Retrieve the physical location of the source constructor referenced
2767 * by the given cursor.
2769 * The location of a declaration is typically the location of the name of that
2770 * declaration, where the name of that declaration would occur if it is
2771 * unnamed, or some keyword that introduces that particular declaration.
2772 * The location of a reference is where that reference occurs within the
2773 * source code.
2775 CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2778 * Retrieve the physical extent of the source construct referenced by
2779 * the given cursor.
2781 * The extent of a cursor starts with the file/line/column pointing at the
2782 * first character within the source construct that the cursor refers to and
2783 * ends with the last character within that source construct. For a
2784 * declaration, the extent covers the declaration itself. For a reference,
2785 * the extent covers the location of the reference (e.g., where the referenced
2786 * entity was actually used).
2788 CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
2791 * @}
2795 * \defgroup CINDEX_TYPES Type information for CXCursors
2797 * @{
2801 * Describes the kind of type
2803 enum CXTypeKind {
2805 * Represents an invalid type (e.g., where no type is available).
2807 CXType_Invalid = 0,
2810 * A type whose specific kind is not exposed via this
2811 * interface.
2813 CXType_Unexposed = 1,
2815 /* Builtin types */
2816 CXType_Void = 2,
2817 CXType_Bool = 3,
2818 CXType_Char_U = 4,
2819 CXType_UChar = 5,
2820 CXType_Char16 = 6,
2821 CXType_Char32 = 7,
2822 CXType_UShort = 8,
2823 CXType_UInt = 9,
2824 CXType_ULong = 10,
2825 CXType_ULongLong = 11,
2826 CXType_UInt128 = 12,
2827 CXType_Char_S = 13,
2828 CXType_SChar = 14,
2829 CXType_WChar = 15,
2830 CXType_Short = 16,
2831 CXType_Int = 17,
2832 CXType_Long = 18,
2833 CXType_LongLong = 19,
2834 CXType_Int128 = 20,
2835 CXType_Float = 21,
2836 CXType_Double = 22,
2837 CXType_LongDouble = 23,
2838 CXType_NullPtr = 24,
2839 CXType_Overload = 25,
2840 CXType_Dependent = 26,
2841 CXType_ObjCId = 27,
2842 CXType_ObjCClass = 28,
2843 CXType_ObjCSel = 29,
2844 CXType_Float128 = 30,
2845 CXType_Half = 31,
2846 CXType_Float16 = 32,
2847 CXType_ShortAccum = 33,
2848 CXType_Accum = 34,
2849 CXType_LongAccum = 35,
2850 CXType_UShortAccum = 36,
2851 CXType_UAccum = 37,
2852 CXType_ULongAccum = 38,
2853 CXType_BFloat16 = 39,
2854 CXType_Ibm128 = 40,
2855 CXType_FirstBuiltin = CXType_Void,
2856 CXType_LastBuiltin = CXType_Ibm128,
2858 CXType_Complex = 100,
2859 CXType_Pointer = 101,
2860 CXType_BlockPointer = 102,
2861 CXType_LValueReference = 103,
2862 CXType_RValueReference = 104,
2863 CXType_Record = 105,
2864 CXType_Enum = 106,
2865 CXType_Typedef = 107,
2866 CXType_ObjCInterface = 108,
2867 CXType_ObjCObjectPointer = 109,
2868 CXType_FunctionNoProto = 110,
2869 CXType_FunctionProto = 111,
2870 CXType_ConstantArray = 112,
2871 CXType_Vector = 113,
2872 CXType_IncompleteArray = 114,
2873 CXType_VariableArray = 115,
2874 CXType_DependentSizedArray = 116,
2875 CXType_MemberPointer = 117,
2876 CXType_Auto = 118,
2879 * Represents a type that was referred to using an elaborated type keyword.
2881 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
2883 CXType_Elaborated = 119,
2885 /* OpenCL PipeType. */
2886 CXType_Pipe = 120,
2888 /* OpenCL builtin types. */
2889 CXType_OCLImage1dRO = 121,
2890 CXType_OCLImage1dArrayRO = 122,
2891 CXType_OCLImage1dBufferRO = 123,
2892 CXType_OCLImage2dRO = 124,
2893 CXType_OCLImage2dArrayRO = 125,
2894 CXType_OCLImage2dDepthRO = 126,
2895 CXType_OCLImage2dArrayDepthRO = 127,
2896 CXType_OCLImage2dMSAARO = 128,
2897 CXType_OCLImage2dArrayMSAARO = 129,
2898 CXType_OCLImage2dMSAADepthRO = 130,
2899 CXType_OCLImage2dArrayMSAADepthRO = 131,
2900 CXType_OCLImage3dRO = 132,
2901 CXType_OCLImage1dWO = 133,
2902 CXType_OCLImage1dArrayWO = 134,
2903 CXType_OCLImage1dBufferWO = 135,
2904 CXType_OCLImage2dWO = 136,
2905 CXType_OCLImage2dArrayWO = 137,
2906 CXType_OCLImage2dDepthWO = 138,
2907 CXType_OCLImage2dArrayDepthWO = 139,
2908 CXType_OCLImage2dMSAAWO = 140,
2909 CXType_OCLImage2dArrayMSAAWO = 141,
2910 CXType_OCLImage2dMSAADepthWO = 142,
2911 CXType_OCLImage2dArrayMSAADepthWO = 143,
2912 CXType_OCLImage3dWO = 144,
2913 CXType_OCLImage1dRW = 145,
2914 CXType_OCLImage1dArrayRW = 146,
2915 CXType_OCLImage1dBufferRW = 147,
2916 CXType_OCLImage2dRW = 148,
2917 CXType_OCLImage2dArrayRW = 149,
2918 CXType_OCLImage2dDepthRW = 150,
2919 CXType_OCLImage2dArrayDepthRW = 151,
2920 CXType_OCLImage2dMSAARW = 152,
2921 CXType_OCLImage2dArrayMSAARW = 153,
2922 CXType_OCLImage2dMSAADepthRW = 154,
2923 CXType_OCLImage2dArrayMSAADepthRW = 155,
2924 CXType_OCLImage3dRW = 156,
2925 CXType_OCLSampler = 157,
2926 CXType_OCLEvent = 158,
2927 CXType_OCLQueue = 159,
2928 CXType_OCLReserveID = 160,
2930 CXType_ObjCObject = 161,
2931 CXType_ObjCTypeParam = 162,
2932 CXType_Attributed = 163,
2934 CXType_OCLIntelSubgroupAVCMcePayload = 164,
2935 CXType_OCLIntelSubgroupAVCImePayload = 165,
2936 CXType_OCLIntelSubgroupAVCRefPayload = 166,
2937 CXType_OCLIntelSubgroupAVCSicPayload = 167,
2938 CXType_OCLIntelSubgroupAVCMceResult = 168,
2939 CXType_OCLIntelSubgroupAVCImeResult = 169,
2940 CXType_OCLIntelSubgroupAVCRefResult = 170,
2941 CXType_OCLIntelSubgroupAVCSicResult = 171,
2942 CXType_OCLIntelSubgroupAVCImeResultSingleReferenceStreamout = 172,
2943 CXType_OCLIntelSubgroupAVCImeResultDualReferenceStreamout = 173,
2944 CXType_OCLIntelSubgroupAVCImeSingleReferenceStreamin = 174,
2945 CXType_OCLIntelSubgroupAVCImeDualReferenceStreamin = 175,
2947 /* Old aliases for AVC OpenCL extension types. */
2948 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
2949 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
2950 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
2951 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
2953 CXType_ExtVector = 176,
2954 CXType_Atomic = 177,
2955 CXType_BTFTagAttributed = 178
2959 * Describes the calling convention of a function type
2961 enum CXCallingConv {
2962 CXCallingConv_Default = 0,
2963 CXCallingConv_C = 1,
2964 CXCallingConv_X86StdCall = 2,
2965 CXCallingConv_X86FastCall = 3,
2966 CXCallingConv_X86ThisCall = 4,
2967 CXCallingConv_X86Pascal = 5,
2968 CXCallingConv_AAPCS = 6,
2969 CXCallingConv_AAPCS_VFP = 7,
2970 CXCallingConv_X86RegCall = 8,
2971 CXCallingConv_IntelOclBicc = 9,
2972 CXCallingConv_Win64 = 10,
2973 /* Alias for compatibility with older versions of API. */
2974 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
2975 CXCallingConv_X86_64SysV = 11,
2976 CXCallingConv_X86VectorCall = 12,
2977 CXCallingConv_Swift = 13,
2978 CXCallingConv_PreserveMost = 14,
2979 CXCallingConv_PreserveAll = 15,
2980 CXCallingConv_AArch64VectorCall = 16,
2981 CXCallingConv_SwiftAsync = 17,
2982 CXCallingConv_AArch64SVEPCS = 18,
2983 CXCallingConv_M68kRTD = 19,
2985 CXCallingConv_Invalid = 100,
2986 CXCallingConv_Unexposed = 200
2990 * The type of an element in the abstract syntax tree.
2993 typedef struct {
2994 enum CXTypeKind kind;
2995 void *data[2];
2996 } CXType;
2999 * Retrieve the type of a CXCursor (if any).
3001 CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3004 * Pretty-print the underlying type using the rules of the
3005 * language of the translation unit from which it came.
3007 * If the type is invalid, an empty string is returned.
3009 CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3012 * Retrieve the underlying type of a typedef declaration.
3014 * If the cursor does not reference a typedef declaration, an invalid type is
3015 * returned.
3017 CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3020 * Retrieve the integer type of an enum declaration.
3022 * If the cursor does not reference an enum declaration, an invalid type is
3023 * returned.
3025 CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3028 * Retrieve the integer value of an enum constant declaration as a signed
3029 * long long.
3031 * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3032 * returned. Since this is also potentially a valid constant value, the kind of
3033 * the cursor must be verified before calling this function.
3035 CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3038 * Retrieve the integer value of an enum constant declaration as an unsigned
3039 * long long.
3041 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3042 * returned. Since this is also potentially a valid constant value, the kind of
3043 * the cursor must be verified before calling this function.
3045 CINDEX_LINKAGE unsigned long long
3046 clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3049 * Returns non-zero if the cursor specifies a Record member that is a bit-field.
3051 CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3054 * Retrieve the bit width of a bit-field declaration as an integer.
3056 * If the cursor does not reference a bit-field, or if the bit-field's width
3057 * expression cannot be evaluated, -1 is returned.
3059 * For example:
3060 * \code
3061 * if (clang_Cursor_isBitField(Cursor)) {
3062 * int Width = clang_getFieldDeclBitWidth(Cursor);
3063 * if (Width != -1) {
3064 * // The bit-field width is not value-dependent.
3067 * \endcode
3069 CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3072 * Retrieve the number of non-variadic arguments associated with a given
3073 * cursor.
3075 * The number of arguments can be determined for calls as well as for
3076 * declarations of functions or methods. For other cursors -1 is returned.
3078 CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3081 * Retrieve the argument cursor of a function or method.
3083 * The argument cursor can be determined for calls as well as for declarations
3084 * of functions or methods. For other cursors and for invalid indices, an
3085 * invalid cursor is returned.
3087 CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3090 * Describes the kind of a template argument.
3092 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3093 * element descriptions.
3095 enum CXTemplateArgumentKind {
3096 CXTemplateArgumentKind_Null,
3097 CXTemplateArgumentKind_Type,
3098 CXTemplateArgumentKind_Declaration,
3099 CXTemplateArgumentKind_NullPtr,
3100 CXTemplateArgumentKind_Integral,
3101 CXTemplateArgumentKind_Template,
3102 CXTemplateArgumentKind_TemplateExpansion,
3103 CXTemplateArgumentKind_Expression,
3104 CXTemplateArgumentKind_Pack,
3105 /* Indicates an error case, preventing the kind from being deduced. */
3106 CXTemplateArgumentKind_Invalid
3110 * Returns the number of template args of a function, struct, or class decl
3111 * representing a template specialization.
3113 * If the argument cursor cannot be converted into a template function
3114 * declaration, -1 is returned.
3116 * For example, for the following declaration and specialization:
3117 * template <typename T, int kInt, bool kBool>
3118 * void foo() { ... }
3120 * template <>
3121 * void foo<float, -7, true>();
3123 * The value 3 would be returned from this call.
3125 CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3128 * Retrieve the kind of the I'th template argument of the CXCursor C.
3130 * If the argument CXCursor does not represent a FunctionDecl, StructDecl, or
3131 * ClassTemplatePartialSpecialization, an invalid template argument kind is
3132 * returned.
3134 * For example, for the following declaration and specialization:
3135 * template <typename T, int kInt, bool kBool>
3136 * void foo() { ... }
3138 * template <>
3139 * void foo<float, -7, true>();
3141 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3142 * respectively.
3144 CINDEX_LINKAGE enum CXTemplateArgumentKind
3145 clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
3148 * Retrieve a CXType representing the type of a TemplateArgument of a
3149 * function decl representing a template specialization.
3151 * If the argument CXCursor does not represent a FunctionDecl, StructDecl,
3152 * ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument
3153 * has a kind of CXTemplateArgKind_Integral, an invalid type is returned.
3155 * For example, for the following declaration and specialization:
3156 * template <typename T, int kInt, bool kBool>
3157 * void foo() { ... }
3159 * template <>
3160 * void foo<float, -7, true>();
3162 * If called with I = 0, "float", will be returned.
3163 * Invalid types will be returned for I == 1 or 2.
3165 CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3166 unsigned I);
3169 * Retrieve the value of an Integral TemplateArgument (of a function
3170 * decl representing a template specialization) as a signed long long.
3172 * It is undefined to call this function on a CXCursor that does not represent a
3173 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization
3174 * whose I'th template argument is not an integral value.
3176 * For example, for the following declaration and specialization:
3177 * template <typename T, int kInt, bool kBool>
3178 * void foo() { ... }
3180 * template <>
3181 * void foo<float, -7, true>();
3183 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3184 * For I == 0, this function's behavior is undefined.
3186 CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3187 unsigned I);
3190 * Retrieve the value of an Integral TemplateArgument (of a function
3191 * decl representing a template specialization) as an unsigned long long.
3193 * It is undefined to call this function on a CXCursor that does not represent a
3194 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or
3195 * whose I'th template argument is not an integral value.
3197 * For example, for the following declaration and specialization:
3198 * template <typename T, int kInt, bool kBool>
3199 * void foo() { ... }
3201 * template <>
3202 * void foo<float, 2147483649, true>();
3204 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3205 * For I == 0, this function's behavior is undefined.
3207 CINDEX_LINKAGE unsigned long long
3208 clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
3211 * Determine whether two CXTypes represent the same type.
3213 * \returns non-zero if the CXTypes represent the same type and
3214 * zero otherwise.
3216 CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3219 * Return the canonical type for a CXType.
3221 * Clang's type system explicitly models typedefs and all the ways
3222 * a specific type can be represented. The canonical type is the underlying
3223 * type with all the "sugar" removed. For example, if 'T' is a typedef
3224 * for 'int', the canonical type for 'T' would be 'int'.
3226 CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3229 * Determine whether a CXType has the "const" qualifier set,
3230 * without looking through typedefs that may have added "const" at a
3231 * different level.
3233 CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3236 * Determine whether a CXCursor that is a macro, is
3237 * function like.
3239 CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3242 * Determine whether a CXCursor that is a macro, is a
3243 * builtin one.
3245 CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3248 * Determine whether a CXCursor that is a function declaration, is an
3249 * inline declaration.
3251 CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3254 * Determine whether a CXType has the "volatile" qualifier set,
3255 * without looking through typedefs that may have added "volatile" at
3256 * a different level.
3258 CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3261 * Determine whether a CXType has the "restrict" qualifier set,
3262 * without looking through typedefs that may have added "restrict" at a
3263 * different level.
3265 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3268 * Returns the address space of the given type.
3270 CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3273 * Returns the typedef name of the given type.
3275 CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3278 * For pointer types, returns the type of the pointee.
3280 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3283 * Retrieve the unqualified variant of the given type, removing as
3284 * little sugar as possible.
3286 * For example, given the following series of typedefs:
3288 * \code
3289 * typedef int Integer;
3290 * typedef const Integer CInteger;
3291 * typedef CInteger DifferenceType;
3292 * \endcode
3294 * Executing \c clang_getUnqualifiedType() on a \c CXType that
3295 * represents \c DifferenceType, will desugar to a type representing
3296 * \c Integer, that has no qualifiers.
3298 * And, executing \c clang_getUnqualifiedType() on the type of the
3299 * first argument of the following function declaration:
3301 * \code
3302 * void foo(const int);
3303 * \endcode
3305 * Will return a type representing \c int, removing the \c const
3306 * qualifier.
3308 * Sugar over array types is not desugared.
3310 * A type can be checked for qualifiers with \c
3311 * clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType()
3312 * and \c clang_isRestrictQualifiedType().
3314 * A type that resulted from a call to \c clang_getUnqualifiedType
3315 * will return \c false for all of the above calls.
3317 CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);
3320 * For reference types (e.g., "const int&"), returns the type that the
3321 * reference refers to (e.g "const int").
3323 * Otherwise, returns the type itself.
3325 * A type that has kind \c CXType_LValueReference or
3326 * \c CXType_RValueReference is a reference type.
3328 CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);
3331 * Return the cursor for the declaration of the given type.
3333 CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3336 * Returns the Objective-C type encoding for the specified declaration.
3338 CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3341 * Returns the Objective-C type encoding for the specified CXType.
3343 CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3346 * Retrieve the spelling of a given CXTypeKind.
3348 CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3351 * Retrieve the calling convention associated with a function type.
3353 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3355 CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3358 * Retrieve the return type associated with a function type.
3360 * If a non-function type is passed in, an invalid type is returned.
3362 CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3365 * Retrieve the exception specification type associated with a function type.
3366 * This is a value of type CXCursor_ExceptionSpecificationKind.
3368 * If a non-function type is passed in, an error code of -1 is returned.
3370 CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3373 * Retrieve the number of non-variadic parameters associated with a
3374 * function type.
3376 * If a non-function type is passed in, -1 is returned.
3378 CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3381 * Retrieve the type of a parameter of a function type.
3383 * If a non-function type is passed in or the function does not have enough
3384 * parameters, an invalid type is returned.
3386 CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3389 * Retrieves the base type of the ObjCObjectType.
3391 * If the type is not an ObjC object, an invalid type is returned.
3393 CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3396 * Retrieve the number of protocol references associated with an ObjC object/id.
3398 * If the type is not an ObjC object, 0 is returned.
3400 CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3403 * Retrieve the decl for a protocol reference for an ObjC object/id.
3405 * If the type is not an ObjC object or there are not enough protocol
3406 * references, an invalid cursor is returned.
3408 CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3411 * Retrieve the number of type arguments associated with an ObjC object.
3413 * If the type is not an ObjC object, 0 is returned.
3415 CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3418 * Retrieve a type argument associated with an ObjC object.
3420 * If the type is not an ObjC or the index is not valid,
3421 * an invalid type is returned.
3423 CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3426 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3428 CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3431 * Retrieve the return type associated with a given cursor.
3433 * This only returns a valid type if the cursor refers to a function or method.
3435 CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3438 * Retrieve the exception specification type associated with a given cursor.
3439 * This is a value of type CXCursor_ExceptionSpecificationKind.
3441 * This only returns a valid result if the cursor refers to a function or
3442 * method.
3444 CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3447 * Return 1 if the CXType is a POD (plain old data) type, and 0
3448 * otherwise.
3450 CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3453 * Return the element type of an array, complex, or vector type.
3455 * If a type is passed in that is not an array, complex, or vector type,
3456 * an invalid type is returned.
3458 CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3461 * Return the number of elements of an array or vector type.
3463 * If a type is passed in that is not an array or vector type,
3464 * -1 is returned.
3466 CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3469 * Return the element type of an array type.
3471 * If a non-array type is passed in, an invalid type is returned.
3473 CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3476 * Return the array size of a constant array.
3478 * If a non-array type is passed in, -1 is returned.
3480 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3483 * Retrieve the type named by the qualified-id.
3485 * If a non-elaborated type is passed in, an invalid type is returned.
3487 CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3490 * Determine if a typedef is 'transparent' tag.
3492 * A typedef is considered 'transparent' if it shares a name and spelling
3493 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3495 * \returns non-zero if transparent and zero otherwise.
3497 CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3499 enum CXTypeNullabilityKind {
3501 * Values of this type can never be null.
3503 CXTypeNullability_NonNull = 0,
3505 * Values of this type can be null.
3507 CXTypeNullability_Nullable = 1,
3509 * Whether values of this type can be null is (explicitly)
3510 * unspecified. This captures a (fairly rare) case where we
3511 * can't conclude anything about the nullability of the type even
3512 * though it has been considered.
3514 CXTypeNullability_Unspecified = 2,
3516 * Nullability is not applicable to this type.
3518 CXTypeNullability_Invalid = 3,
3521 * Generally behaves like Nullable, except when used in a block parameter that
3522 * was imported into a swift async method. There, swift will assume that the
3523 * parameter can get null even if no error occurred. _Nullable parameters are
3524 * assumed to only get null on error.
3526 CXTypeNullability_NullableResult = 4
3530 * Retrieve the nullability kind of a pointer type.
3532 CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3535 * List the possible error codes for \c clang_Type_getSizeOf,
3536 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3537 * \c clang_Cursor_getOffsetOf.
3539 * A value of this enumeration type can be returned if the target type is not
3540 * a valid argument to sizeof, alignof or offsetof.
3542 enum CXTypeLayoutError {
3544 * Type is of kind CXType_Invalid.
3546 CXTypeLayoutError_Invalid = -1,
3548 * The type is an incomplete Type.
3550 CXTypeLayoutError_Incomplete = -2,
3552 * The type is a dependent Type.
3554 CXTypeLayoutError_Dependent = -3,
3556 * The type is not a constant size type.
3558 CXTypeLayoutError_NotConstantSize = -4,
3560 * The Field name is not valid for this record.
3562 CXTypeLayoutError_InvalidFieldName = -5,
3564 * The type is undeduced.
3566 CXTypeLayoutError_Undeduced = -6
3570 * Return the alignment of a type in bytes as per C++[expr.alignof]
3571 * standard.
3573 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3574 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3575 * is returned.
3576 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3577 * returned.
3578 * If the type declaration is not a constant size type,
3579 * CXTypeLayoutError_NotConstantSize is returned.
3581 CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3584 * Return the class type of an member pointer type.
3586 * If a non-member-pointer type is passed in, an invalid type is returned.
3588 CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3591 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3593 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3594 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3595 * is returned.
3596 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3597 * returned.
3599 CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3602 * Return the offset of a field named S in a record of type T in bits
3603 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3605 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3606 * is returned.
3607 * If the field's type declaration is an incomplete type,
3608 * CXTypeLayoutError_Incomplete is returned.
3609 * If the field's type declaration is a dependent type,
3610 * CXTypeLayoutError_Dependent is returned.
3611 * If the field's name S is not found,
3612 * CXTypeLayoutError_InvalidFieldName is returned.
3614 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3617 * Return the type that was modified by this attributed type.
3619 * If the type is not an attributed type, an invalid type is returned.
3621 CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3624 * Gets the type contained by this atomic type.
3626 * If a non-atomic type is passed in, an invalid type is returned.
3628 CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
3631 * Return the offset of the field represented by the Cursor.
3633 * If the cursor is not a field declaration, -1 is returned.
3634 * If the cursor semantic parent is not a record field declaration,
3635 * CXTypeLayoutError_Invalid is returned.
3636 * If the field's type declaration is an incomplete type,
3637 * CXTypeLayoutError_Incomplete is returned.
3638 * If the field's type declaration is a dependent type,
3639 * CXTypeLayoutError_Dependent is returned.
3640 * If the field's name S is not found,
3641 * CXTypeLayoutError_InvalidFieldName is returned.
3643 CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3646 * Determine whether the given cursor represents an anonymous
3647 * tag or namespace
3649 CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3652 * Determine whether the given cursor represents an anonymous record
3653 * declaration.
3655 CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
3658 * Determine whether the given cursor represents an inline namespace
3659 * declaration.
3661 CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
3663 enum CXRefQualifierKind {
3664 /** No ref-qualifier was provided. */
3665 CXRefQualifier_None = 0,
3666 /** An lvalue ref-qualifier was provided (\c &). */
3667 CXRefQualifier_LValue,
3668 /** An rvalue ref-qualifier was provided (\c &&). */
3669 CXRefQualifier_RValue
3673 * Returns the number of template arguments for given template
3674 * specialization, or -1 if type \c T is not a template specialization.
3676 CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3679 * Returns the type template argument of a template class specialization
3680 * at given index.
3682 * This function only returns template type arguments and does not handle
3683 * template template arguments or variadic packs.
3685 CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
3686 unsigned i);
3689 * Retrieve the ref-qualifier kind of a function or method.
3691 * The ref-qualifier is returned for C++ functions or methods. For other types
3692 * or non-C++ declarations, CXRefQualifier_None is returned.
3694 CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3697 * Returns 1 if the base class specified by the cursor with kind
3698 * CX_CXXBaseSpecifier is virtual.
3700 CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3703 * Represents the C++ access control level to a base class for a
3704 * cursor with kind CX_CXXBaseSpecifier.
3706 enum CX_CXXAccessSpecifier {
3707 CX_CXXInvalidAccessSpecifier,
3708 CX_CXXPublic,
3709 CX_CXXProtected,
3710 CX_CXXPrivate
3714 * Returns the access control level for the referenced object.
3716 * If the cursor refers to a C++ declaration, its access control level within
3717 * its parent scope is returned. Otherwise, if the cursor refers to a base
3718 * specifier or access specifier, the specifier itself is returned.
3720 CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3723 * Represents the storage classes as declared in the source. CX_SC_Invalid
3724 * was added for the case that the passed cursor in not a declaration.
3726 enum CX_StorageClass {
3727 CX_SC_Invalid,
3728 CX_SC_None,
3729 CX_SC_Extern,
3730 CX_SC_Static,
3731 CX_SC_PrivateExtern,
3732 CX_SC_OpenCLWorkGroupLocal,
3733 CX_SC_Auto,
3734 CX_SC_Register
3738 * Returns the storage class for a function or variable declaration.
3740 * If the passed in Cursor is not a function or variable declaration,
3741 * CX_SC_Invalid is returned else the storage class.
3743 CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
3746 * Determine the number of overloaded declarations referenced by a
3747 * \c CXCursor_OverloadedDeclRef cursor.
3749 * \param cursor The cursor whose overloaded declarations are being queried.
3751 * \returns The number of overloaded declarations referenced by \c cursor. If it
3752 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3754 CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3757 * Retrieve a cursor for one of the overloaded declarations referenced
3758 * by a \c CXCursor_OverloadedDeclRef cursor.
3760 * \param cursor The cursor whose overloaded declarations are being queried.
3762 * \param index The zero-based index into the set of overloaded declarations in
3763 * the cursor.
3765 * \returns A cursor representing the declaration referenced by the given
3766 * \c cursor at the specified \c index. If the cursor does not have an
3767 * associated set of overloaded declarations, or if the index is out of bounds,
3768 * returns \c clang_getNullCursor();
3770 CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3771 unsigned index);
3774 * @}
3778 * \defgroup CINDEX_ATTRIBUTES Information for attributes
3780 * @{
3784 * For cursors representing an iboutletcollection attribute,
3785 * this function returns the collection element type.
3788 CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3791 * @}
3795 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3797 * These routines provide the ability to traverse the abstract syntax tree
3798 * using cursors.
3800 * @{
3804 * Describes how the traversal of the children of a particular
3805 * cursor should proceed after visiting a particular child cursor.
3807 * A value of this enumeration type should be returned by each
3808 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3810 enum CXChildVisitResult {
3812 * Terminates the cursor traversal.
3814 CXChildVisit_Break,
3816 * Continues the cursor traversal with the next sibling of
3817 * the cursor just visited, without visiting its children.
3819 CXChildVisit_Continue,
3821 * Recursively traverse the children of this cursor, using
3822 * the same visitor and client data.
3824 CXChildVisit_Recurse
3828 * Visitor invoked for each cursor found by a traversal.
3830 * This visitor function will be invoked for each cursor found by
3831 * clang_visitCursorChildren(). Its first argument is the cursor being
3832 * visited, its second argument is the parent visitor for that cursor,
3833 * and its third argument is the client data provided to
3834 * clang_visitCursorChildren().
3836 * The visitor should return one of the \c CXChildVisitResult values
3837 * to direct clang_visitCursorChildren().
3839 typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3840 CXCursor parent,
3841 CXClientData client_data);
3844 * Visit the children of a particular cursor.
3846 * This function visits all the direct children of the given cursor,
3847 * invoking the given \p visitor function with the cursors of each
3848 * visited child. The traversal may be recursive, if the visitor returns
3849 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3850 * the visitor returns \c CXChildVisit_Break.
3852 * \param parent the cursor whose child may be visited. All kinds of
3853 * cursors can be visited, including invalid cursors (which, by
3854 * definition, have no children).
3856 * \param visitor the visitor function that will be invoked for each
3857 * child of \p parent.
3859 * \param client_data pointer data supplied by the client, which will
3860 * be passed to the visitor each time it is invoked.
3862 * \returns a non-zero value if the traversal was terminated
3863 * prematurely by the visitor returning \c CXChildVisit_Break.
3865 CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
3866 CXCursorVisitor visitor,
3867 CXClientData client_data);
3869 * Visitor invoked for each cursor found by a traversal.
3871 * This visitor block will be invoked for each cursor found by
3872 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3873 * visited, its second argument is the parent visitor for that cursor.
3875 * The visitor should return one of the \c CXChildVisitResult values
3876 * to direct clang_visitChildrenWithBlock().
3878 #if __has_feature(blocks)
3879 typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
3880 CXCursor parent);
3881 #else
3882 typedef struct _CXChildVisitResult *CXCursorVisitorBlock;
3883 #endif
3886 * Visits the children of a cursor using the specified block. Behaves
3887 * identically to clang_visitChildren() in all other respects.
3889 CINDEX_LINKAGE unsigned
3890 clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
3893 * @}
3897 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3899 * These routines provide the ability to determine references within and
3900 * across translation units, by providing the names of the entities referenced
3901 * by cursors, follow reference cursors to the declarations they reference,
3902 * and associate declarations with their definitions.
3904 * @{
3908 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3909 * by the given cursor.
3911 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3912 * entity (function, class, variable, etc.) within a program. USRs can be
3913 * compared across translation units to determine, e.g., when references in
3914 * one translation refer to an entity defined in another translation unit.
3916 CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3919 * Construct a USR for a specified Objective-C class.
3921 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3924 * Construct a USR for a specified Objective-C category.
3926 CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
3927 const char *class_name, const char *category_name);
3930 * Construct a USR for a specified Objective-C protocol.
3932 CINDEX_LINKAGE CXString
3933 clang_constructUSR_ObjCProtocol(const char *protocol_name);
3936 * Construct a USR for a specified Objective-C instance variable and
3937 * the USR for its containing class.
3939 CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3940 CXString classUSR);
3943 * Construct a USR for a specified Objective-C method and
3944 * the USR for its containing class.
3946 CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3947 unsigned isInstanceMethod,
3948 CXString classUSR);
3951 * Construct a USR for a specified Objective-C property and the USR
3952 * for its containing class.
3954 CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3955 CXString classUSR);
3958 * Retrieve a name for the entity referenced by this cursor.
3960 CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3963 * Retrieve a range for a piece that forms the cursors spelling name.
3964 * Most of the times there is only one range for the complete spelling but for
3965 * Objective-C methods and Objective-C message expressions, there are multiple
3966 * pieces for each selector identifier.
3968 * \param pieceIndex the index of the spelling name piece. If this is greater
3969 * than the actual number of pieces, it will return a NULL (invalid) range.
3971 * \param options Reserved.
3973 CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
3974 CXCursor, unsigned pieceIndex, unsigned options);
3977 * Opaque pointer representing a policy that controls pretty printing
3978 * for \c clang_getCursorPrettyPrinted.
3980 typedef void *CXPrintingPolicy;
3983 * Properties for the printing policy.
3985 * See \c clang::PrintingPolicy for more information.
3987 enum CXPrintingPolicyProperty {
3988 CXPrintingPolicy_Indentation,
3989 CXPrintingPolicy_SuppressSpecifiers,
3990 CXPrintingPolicy_SuppressTagKeyword,
3991 CXPrintingPolicy_IncludeTagDefinition,
3992 CXPrintingPolicy_SuppressScope,
3993 CXPrintingPolicy_SuppressUnwrittenScope,
3994 CXPrintingPolicy_SuppressInitializers,
3995 CXPrintingPolicy_ConstantArraySizeAsWritten,
3996 CXPrintingPolicy_AnonymousTagLocations,
3997 CXPrintingPolicy_SuppressStrongLifetime,
3998 CXPrintingPolicy_SuppressLifetimeQualifiers,
3999 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4000 CXPrintingPolicy_Bool,
4001 CXPrintingPolicy_Restrict,
4002 CXPrintingPolicy_Alignof,
4003 CXPrintingPolicy_UnderscoreAlignof,
4004 CXPrintingPolicy_UseVoidForZeroParams,
4005 CXPrintingPolicy_TerseOutput,
4006 CXPrintingPolicy_PolishForDeclaration,
4007 CXPrintingPolicy_Half,
4008 CXPrintingPolicy_MSWChar,
4009 CXPrintingPolicy_IncludeNewlines,
4010 CXPrintingPolicy_MSVCFormatting,
4011 CXPrintingPolicy_ConstantsAsWritten,
4012 CXPrintingPolicy_SuppressImplicitBase,
4013 CXPrintingPolicy_FullyQualifiedName,
4015 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4019 * Get a property value for the given printing policy.
4021 CINDEX_LINKAGE unsigned
4022 clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4023 enum CXPrintingPolicyProperty Property);
4026 * Set a property value for the given printing policy.
4028 CINDEX_LINKAGE void
4029 clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4030 enum CXPrintingPolicyProperty Property,
4031 unsigned Value);
4034 * Retrieve the default policy for the cursor.
4036 * The policy should be released after use with \c
4037 * clang_PrintingPolicy_dispose.
4039 CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4042 * Release a printing policy.
4044 CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4047 * Pretty print declarations.
4049 * \param Cursor The cursor representing a declaration.
4051 * \param Policy The policy to control the entities being printed. If
4052 * NULL, a default policy is used.
4054 * \returns The pretty printed declaration or the empty string for
4055 * other cursors.
4057 CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4058 CXPrintingPolicy Policy);
4061 * Retrieve the display name for the entity referenced by this cursor.
4063 * The display name contains extra information that helps identify the cursor,
4064 * such as the parameters of a function or template or the arguments of a
4065 * class template specialization.
4067 CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
4069 /** For a cursor that is a reference, retrieve a cursor representing the
4070 * entity that it references.
4072 * Reference cursors refer to other entities in the AST. For example, an
4073 * Objective-C superclass reference cursor refers to an Objective-C class.
4074 * This function produces the cursor for the Objective-C class from the
4075 * cursor for the superclass reference. If the input cursor is a declaration or
4076 * definition, it returns that declaration or definition unchanged.
4077 * Otherwise, returns the NULL cursor.
4079 CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
4082 * For a cursor that is either a reference to or a declaration
4083 * of some entity, retrieve a cursor that describes the definition of
4084 * that entity.
4086 * Some entities can be declared multiple times within a translation
4087 * unit, but only one of those declarations can also be a
4088 * definition. For example, given:
4090 * \code
4091 * int f(int, int);
4092 * int g(int x, int y) { return f(x, y); }
4093 * int f(int a, int b) { return a + b; }
4094 * int f(int, int);
4095 * \endcode
4097 * there are three declarations of the function "f", but only the
4098 * second one is a definition. The clang_getCursorDefinition()
4099 * function will take any cursor pointing to a declaration of "f"
4100 * (the first or fourth lines of the example) or a cursor referenced
4101 * that uses "f" (the call to "f' inside "g") and will return a
4102 * declaration cursor pointing to the definition (the second "f"
4103 * declaration).
4105 * If given a cursor for which there is no corresponding definition,
4106 * e.g., because there is no definition of that entity within this
4107 * translation unit, returns a NULL cursor.
4109 CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4112 * Determine whether the declaration pointed to by this cursor
4113 * is also a definition of that entity.
4115 CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4118 * Retrieve the canonical cursor corresponding to the given cursor.
4120 * In the C family of languages, many kinds of entities can be declared several
4121 * times within a single translation unit. For example, a structure type can
4122 * be forward-declared (possibly multiple times) and later defined:
4124 * \code
4125 * struct X;
4126 * struct X;
4127 * struct X {
4128 * int member;
4129 * };
4130 * \endcode
4132 * The declarations and the definition of \c X are represented by three
4133 * different cursors, all of which are declarations of the same underlying
4134 * entity. One of these cursor is considered the "canonical" cursor, which
4135 * is effectively the representative for the underlying entity. One can
4136 * determine if two cursors are declarations of the same underlying entity by
4137 * comparing their canonical cursors.
4139 * \returns The canonical cursor for the entity referred to by the given cursor.
4141 CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4144 * If the cursor points to a selector identifier in an Objective-C
4145 * method or message expression, this returns the selector index.
4147 * After getting a cursor with #clang_getCursor, this can be called to
4148 * determine if the location points to a selector identifier.
4150 * \returns The selector index if the cursor is an Objective-C method or message
4151 * expression and the cursor is pointing to a selector identifier, or -1
4152 * otherwise.
4154 CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4157 * Given a cursor pointing to a C++ method call or an Objective-C
4158 * message, returns non-zero if the method/message is "dynamic", meaning:
4160 * For a C++ method: the call is virtual.
4161 * For an Objective-C message: the receiver is an object instance, not 'super'
4162 * or a specific class.
4164 * If the method/message is "static" or the cursor does not point to a
4165 * method/message, it will return zero.
4167 CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4170 * Given a cursor pointing to an Objective-C message or property
4171 * reference, or C++ method call, returns the CXType of the receiver.
4173 CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4176 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4178 typedef enum {
4179 CXObjCPropertyAttr_noattr = 0x00,
4180 CXObjCPropertyAttr_readonly = 0x01,
4181 CXObjCPropertyAttr_getter = 0x02,
4182 CXObjCPropertyAttr_assign = 0x04,
4183 CXObjCPropertyAttr_readwrite = 0x08,
4184 CXObjCPropertyAttr_retain = 0x10,
4185 CXObjCPropertyAttr_copy = 0x20,
4186 CXObjCPropertyAttr_nonatomic = 0x40,
4187 CXObjCPropertyAttr_setter = 0x80,
4188 CXObjCPropertyAttr_atomic = 0x100,
4189 CXObjCPropertyAttr_weak = 0x200,
4190 CXObjCPropertyAttr_strong = 0x400,
4191 CXObjCPropertyAttr_unsafe_unretained = 0x800,
4192 CXObjCPropertyAttr_class = 0x1000
4193 } CXObjCPropertyAttrKind;
4196 * Given a cursor that represents a property declaration, return the
4197 * associated property attributes. The bits are formed from
4198 * \c CXObjCPropertyAttrKind.
4200 * \param reserved Reserved for future use, pass 0.
4202 CINDEX_LINKAGE unsigned
4203 clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
4206 * Given a cursor that represents a property declaration, return the
4207 * name of the method that implements the getter.
4209 CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4212 * Given a cursor that represents a property declaration, return the
4213 * name of the method that implements the setter, if any.
4215 CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4218 * 'Qualifiers' written next to the return and parameter types in
4219 * Objective-C method declarations.
4221 typedef enum {
4222 CXObjCDeclQualifier_None = 0x0,
4223 CXObjCDeclQualifier_In = 0x1,
4224 CXObjCDeclQualifier_Inout = 0x2,
4225 CXObjCDeclQualifier_Out = 0x4,
4226 CXObjCDeclQualifier_Bycopy = 0x8,
4227 CXObjCDeclQualifier_Byref = 0x10,
4228 CXObjCDeclQualifier_Oneway = 0x20
4229 } CXObjCDeclQualifierKind;
4232 * Given a cursor that represents an Objective-C method or parameter
4233 * declaration, return the associated Objective-C qualifiers for the return
4234 * type or the parameter respectively. The bits are formed from
4235 * CXObjCDeclQualifierKind.
4237 CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4240 * Given a cursor that represents an Objective-C method or property
4241 * declaration, return non-zero if the declaration was affected by "\@optional".
4242 * Returns zero if the cursor is not such a declaration or it is "\@required".
4244 CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4247 * Returns non-zero if the given cursor is a variadic function or method.
4249 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4252 * Returns non-zero if the given cursor points to a symbol marked with
4253 * external_source_symbol attribute.
4255 * \param language If non-NULL, and the attribute is present, will be set to
4256 * the 'language' string from the attribute.
4258 * \param definedIn If non-NULL, and the attribute is present, will be set to
4259 * the 'definedIn' string from the attribute.
4261 * \param isGenerated If non-NULL, and the attribute is present, will be set to
4262 * non-zero if the 'generated_declaration' is set in the attribute.
4264 CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4265 CXString *language,
4266 CXString *definedIn,
4267 unsigned *isGenerated);
4270 * Given a cursor that represents a declaration, return the associated
4271 * comment's source range. The range may include multiple consecutive comments
4272 * with whitespace in between.
4274 CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4277 * Given a cursor that represents a declaration, return the associated
4278 * comment text, including comment markers.
4280 CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4283 * Given a cursor that represents a documentable entity (e.g.,
4284 * declaration), return the associated \paragraph; otherwise return the
4285 * first paragraph.
4287 CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4290 * @}
4293 /** \defgroup CINDEX_MANGLE Name Mangling API Functions
4295 * @{
4299 * Retrieve the CXString representing the mangled name of the cursor.
4301 CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4304 * Retrieve the CXStrings representing the mangled symbols of the C++
4305 * constructor or destructor at the cursor.
4307 CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4310 * Retrieve the CXStrings representing the mangled symbols of the ObjC
4311 * class interface or implementation at the cursor.
4313 CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4316 * @}
4320 * \defgroup CINDEX_MODULE Module introspection
4322 * The functions in this group provide access to information about modules.
4324 * @{
4327 typedef void *CXModule;
4330 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4332 CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4335 * Given a CXFile header file, return the module that contains it, if one
4336 * exists.
4338 CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4341 * \param Module a module object.
4343 * \returns the module file where the provided module object came from.
4345 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4348 * \param Module a module object.
4350 * \returns the parent of a sub-module or NULL if the given module is top-level,
4351 * e.g. for 'std.vector' it will return the 'std' module.
4353 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4356 * \param Module a module object.
4358 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4359 * will return "vector".
4361 CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4364 * \param Module a module object.
4366 * \returns the full name of the module, e.g. "std.vector".
4368 CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4371 * \param Module a module object.
4373 * \returns non-zero if the module is a system one.
4375 CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4378 * \param Module a module object.
4380 * \returns the number of top level headers associated with this module.
4382 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4383 CXModule Module);
4386 * \param Module a module object.
4388 * \param Index top level header index (zero-based).
4390 * \returns the specified top level header associated with the module.
4392 CINDEX_LINKAGE
4393 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
4394 unsigned Index);
4397 * @}
4401 * \defgroup CINDEX_CPP C++ AST introspection
4403 * The routines in this group provide access information in the ASTs specific
4404 * to C++ language features.
4406 * @{
4410 * Determine if a C++ constructor is a converting constructor.
4412 CINDEX_LINKAGE unsigned
4413 clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4416 * Determine if a C++ constructor is a copy constructor.
4418 CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4421 * Determine if a C++ constructor is the default constructor.
4423 CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4426 * Determine if a C++ constructor is a move constructor.
4428 CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4431 * Determine if a C++ field is declared 'mutable'.
4433 CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4436 * Determine if a C++ method is declared '= default'.
4438 CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4441 * Determine if a C++ method is declared '= delete'.
4443 CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C);
4446 * Determine if a C++ member function or member function template is
4447 * pure virtual.
4449 CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4452 * Determine if a C++ member function or member function template is
4453 * declared 'static'.
4455 CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4458 * Determine if a C++ member function or member function template is
4459 * explicitly declared 'virtual' or if it overrides a virtual method from
4460 * one of the base classes.
4462 CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4465 * Determine if a C++ member function is a copy-assignment operator,
4466 * returning 1 if such is the case and 0 otherwise.
4468 * > A copy-assignment operator `X::operator=` is a non-static,
4469 * > non-template member function of _class_ `X` with exactly one
4470 * > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
4471 * > volatile X&`.
4473 * That is, for example, the `operator=` in:
4475 * class Foo {
4476 * bool operator=(const volatile Foo&);
4477 * };
4479 * Is a copy-assignment operator, while the `operator=` in:
4481 * class Bar {
4482 * bool operator=(const int&);
4483 * };
4485 * Is not.
4487 CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C);
4490 * Determine if a C++ member function is a move-assignment operator,
4491 * returning 1 if such is the case and 0 otherwise.
4493 * > A move-assignment operator `X::operator=` is a non-static,
4494 * > non-template member function of _class_ `X` with exactly one
4495 * > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
4496 * > volatile X&&`.
4498 * That is, for example, the `operator=` in:
4500 * class Foo {
4501 * bool operator=(const volatile Foo&&);
4502 * };
4504 * Is a move-assignment operator, while the `operator=` in:
4506 * class Bar {
4507 * bool operator=(const int&&);
4508 * };
4510 * Is not.
4512 CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C);
4515 * Determines if a C++ constructor or conversion function was declared
4516 * explicit, returning 1 if such is the case and 0 otherwise.
4518 * Constructors or conversion functions are declared explicit through
4519 * the use of the explicit specifier.
4521 * For example, the following constructor and conversion function are
4522 * not explicit as they lack the explicit specifier:
4524 * class Foo {
4525 * Foo();
4526 * operator int();
4527 * };
4529 * While the following constructor and conversion function are
4530 * explicit as they are declared with the explicit specifier.
4532 * class Foo {
4533 * explicit Foo();
4534 * explicit operator int();
4535 * };
4537 * This function will return 0 when given a cursor pointing to one of
4538 * the former declarations and it will return 1 for a cursor pointing
4539 * to the latter declarations.
4541 * The explicit specifier allows the user to specify a
4542 * conditional compile-time expression whose value decides
4543 * whether the marked element is explicit or not.
4545 * For example:
4547 * constexpr bool foo(int i) { return i % 2 == 0; }
4549 * class Foo {
4550 * explicit(foo(1)) Foo();
4551 * explicit(foo(2)) operator int();
4554 * This function will return 0 for the constructor and 1 for
4555 * the conversion function.
4557 CINDEX_LINKAGE unsigned clang_CXXMethod_isExplicit(CXCursor C);
4560 * Determine if a C++ record is abstract, i.e. whether a class or struct
4561 * has a pure virtual member function.
4563 CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4566 * Determine if an enum declaration refers to a scoped enum.
4568 CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4571 * Determine if a C++ member function or member function template is
4572 * declared 'const'.
4574 CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4577 * Given a cursor that represents a template, determine
4578 * the cursor kind of the specializations would be generated by instantiating
4579 * the template.
4581 * This routine can be used to determine what flavor of function template,
4582 * class template, or class template partial specialization is stored in the
4583 * cursor. For example, it can describe whether a class template cursor is
4584 * declared with "struct", "class" or "union".
4586 * \param C The cursor to query. This cursor should represent a template
4587 * declaration.
4589 * \returns The cursor kind of the specializations that would be generated
4590 * by instantiating the template \p C. If \p C is not a template, returns
4591 * \c CXCursor_NoDeclFound.
4593 CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4596 * Given a cursor that may represent a specialization or instantiation
4597 * of a template, retrieve the cursor that represents the template that it
4598 * specializes or from which it was instantiated.
4600 * This routine determines the template involved both for explicit
4601 * specializations of templates and for implicit instantiations of the template,
4602 * both of which are referred to as "specializations". For a class template
4603 * specialization (e.g., \c std::vector<bool>), this routine will return
4604 * either the primary template (\c std::vector) or, if the specialization was
4605 * instantiated from a class template partial specialization, the class template
4606 * partial specialization. For a class template partial specialization and a
4607 * function template specialization (including instantiations), this
4608 * this routine will return the specialized template.
4610 * For members of a class template (e.g., member functions, member classes, or
4611 * static data members), returns the specialized or instantiated member.
4612 * Although not strictly "templates" in the C++ language, members of class
4613 * templates have the same notions of specializations and instantiations that
4614 * templates do, so this routine treats them similarly.
4616 * \param C A cursor that may be a specialization of a template or a member
4617 * of a template.
4619 * \returns If the given cursor is a specialization or instantiation of a
4620 * template or a member thereof, the template or member that it specializes or
4621 * from which it was instantiated. Otherwise, returns a NULL cursor.
4623 CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4626 * Given a cursor that references something else, return the source range
4627 * covering that reference.
4629 * \param C A cursor pointing to a member reference, a declaration reference, or
4630 * an operator call.
4631 * \param NameFlags A bitset with three independent flags:
4632 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4633 * CXNameRange_WantSinglePiece.
4634 * \param PieceIndex For contiguous names or when passing the flag
4635 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4636 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4637 * non-contiguous names, this index can be used to retrieve the individual
4638 * pieces of the name. See also CXNameRange_WantSinglePiece.
4640 * \returns The piece of the name pointed to by the given cursor. If there is no
4641 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4643 CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
4644 CXCursor C, unsigned NameFlags, unsigned PieceIndex);
4646 enum CXNameRefFlags {
4648 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4649 * range.
4651 CXNameRange_WantQualifier = 0x1,
4654 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
4655 * in the range.
4657 CXNameRange_WantTemplateArgs = 0x2,
4660 * If the name is non-contiguous, return the full spanning range.
4662 * Non-contiguous names occur in Objective-C when a selector with two or more
4663 * parameters is used, or in C++ when using an operator:
4664 * \code
4665 * [object doSomething:here withValue:there]; // Objective-C
4666 * return some_vector[1]; // C++
4667 * \endcode
4669 CXNameRange_WantSinglePiece = 0x4
4673 * @}
4677 * \defgroup CINDEX_LEX Token extraction and manipulation
4679 * The routines in this group provide access to the tokens within a
4680 * translation unit, along with a semantic mapping of those tokens to
4681 * their corresponding cursors.
4683 * @{
4687 * Describes a kind of token.
4689 typedef enum CXTokenKind {
4691 * A token that contains some kind of punctuation.
4693 CXToken_Punctuation,
4696 * A language keyword.
4698 CXToken_Keyword,
4701 * An identifier (that is not a keyword).
4703 CXToken_Identifier,
4706 * A numeric, string, or character literal.
4708 CXToken_Literal,
4711 * A comment.
4713 CXToken_Comment
4714 } CXTokenKind;
4717 * Describes a single preprocessing token.
4719 typedef struct {
4720 unsigned int_data[4];
4721 void *ptr_data;
4722 } CXToken;
4725 * Get the raw lexical token starting with the given location.
4727 * \param TU the translation unit whose text is being tokenized.
4729 * \param Location the source location with which the token starts.
4731 * \returns The token starting with the given location or NULL if no such token
4732 * exist. The returned pointer must be freed with clang_disposeTokens before the
4733 * translation unit is destroyed.
4735 CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4736 CXSourceLocation Location);
4739 * Determine the kind of the given token.
4741 CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4744 * Determine the spelling of the given token.
4746 * The spelling of a token is the textual representation of that token, e.g.,
4747 * the text of an identifier or keyword.
4749 CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4752 * Retrieve the source location of the given token.
4754 CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4755 CXToken);
4758 * Retrieve a source range that covers the given token.
4760 CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4763 * Tokenize the source code described by the given range into raw
4764 * lexical tokens.
4766 * \param TU the translation unit whose text is being tokenized.
4768 * \param Range the source range in which text should be tokenized. All of the
4769 * tokens produced by tokenization will fall within this source range,
4771 * \param Tokens this pointer will be set to point to the array of tokens
4772 * that occur within the given source range. The returned pointer must be
4773 * freed with clang_disposeTokens() before the translation unit is destroyed.
4775 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4776 * array.
4779 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4780 CXToken **Tokens, unsigned *NumTokens);
4783 * Annotate the given set of tokens by providing cursors for each token
4784 * that can be mapped to a specific entity within the abstract syntax tree.
4786 * This token-annotation routine is equivalent to invoking
4787 * clang_getCursor() for the source locations of each of the
4788 * tokens. The cursors provided are filtered, so that only those
4789 * cursors that have a direct correspondence to the token are
4790 * accepted. For example, given a function call \c f(x),
4791 * clang_getCursor() would provide the following cursors:
4793 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4794 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4795 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4797 * Only the first and last of these cursors will occur within the
4798 * annotate, since the tokens "f" and "x' directly refer to a function
4799 * and a variable, respectively, but the parentheses are just a small
4800 * part of the full syntax of the function call expression, which is
4801 * not provided as an annotation.
4803 * \param TU the translation unit that owns the given tokens.
4805 * \param Tokens the set of tokens to annotate.
4807 * \param NumTokens the number of tokens in \p Tokens.
4809 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4810 * replaced with the cursors corresponding to each token.
4812 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
4813 unsigned NumTokens, CXCursor *Cursors);
4816 * Free the given set of tokens.
4818 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
4819 unsigned NumTokens);
4822 * @}
4826 * \defgroup CINDEX_DEBUG Debugging facilities
4828 * These routines are used for testing and debugging, only, and should not
4829 * be relied upon.
4831 * @{
4834 /* for debug/testing */
4835 CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4836 CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
4837 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
4838 unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
4839 CINDEX_LINKAGE void clang_enableStackTraces(void);
4840 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
4841 unsigned stack_size);
4844 * @}
4848 * \defgroup CINDEX_CODE_COMPLET Code completion
4850 * Code completion involves taking an (incomplete) source file, along with
4851 * knowledge of where the user is actively editing that file, and suggesting
4852 * syntactically- and semantically-valid constructs that the user might want to
4853 * use at that particular point in the source code. These data structures and
4854 * routines provide support for code completion.
4856 * @{
4860 * A semantic string that describes a code-completion result.
4862 * A semantic string that describes the formatting of a code-completion
4863 * result as a single "template" of text that should be inserted into the
4864 * source buffer when a particular code-completion result is selected.
4865 * Each semantic string is made up of some number of "chunks", each of which
4866 * contains some text along with a description of what that text means, e.g.,
4867 * the name of the entity being referenced, whether the text chunk is part of
4868 * the template, or whether it is a "placeholder" that the user should replace
4869 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4870 * description of the different kinds of chunks.
4872 typedef void *CXCompletionString;
4875 * A single result of code completion.
4877 typedef struct {
4879 * The kind of entity that this completion refers to.
4881 * The cursor kind will be a macro, keyword, or a declaration (one of the
4882 * *Decl cursor kinds), describing the entity that the completion is
4883 * referring to.
4885 * \todo In the future, we would like to provide a full cursor, to allow
4886 * the client to extract additional information from declaration.
4888 enum CXCursorKind CursorKind;
4891 * The code-completion string that describes how to insert this
4892 * code-completion result into the editing buffer.
4894 CXCompletionString CompletionString;
4895 } CXCompletionResult;
4898 * Describes a single piece of text within a code-completion string.
4900 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4901 * either a piece of text with a specific "kind" that describes how that text
4902 * should be interpreted by the client or is another completion string.
4904 enum CXCompletionChunkKind {
4906 * A code-completion string that describes "optional" text that
4907 * could be a part of the template (but is not required).
4909 * The Optional chunk is the only kind of chunk that has a code-completion
4910 * string for its representation, which is accessible via
4911 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4912 * describes an additional part of the template that is completely optional.
4913 * For example, optional chunks can be used to describe the placeholders for
4914 * arguments that match up with defaulted function parameters, e.g. given:
4916 * \code
4917 * void f(int x, float y = 3.14, double z = 2.71828);
4918 * \endcode
4920 * The code-completion string for this function would contain:
4921 * - a TypedText chunk for "f".
4922 * - a LeftParen chunk for "(".
4923 * - a Placeholder chunk for "int x"
4924 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4925 * - a Comma chunk for ","
4926 * - a Placeholder chunk for "float y"
4927 * - an Optional chunk containing the last defaulted argument:
4928 * - a Comma chunk for ","
4929 * - a Placeholder chunk for "double z"
4930 * - a RightParen chunk for ")"
4932 * There are many ways to handle Optional chunks. Two simple approaches are:
4933 * - Completely ignore optional chunks, in which case the template for the
4934 * function "f" would only include the first parameter ("int x").
4935 * - Fully expand all optional chunks, in which case the template for the
4936 * function "f" would have all of the parameters.
4938 CXCompletionChunk_Optional,
4940 * Text that a user would be expected to type to get this
4941 * code-completion result.
4943 * There will be exactly one "typed text" chunk in a semantic string, which
4944 * will typically provide the spelling of a keyword or the name of a
4945 * declaration that could be used at the current code point. Clients are
4946 * expected to filter the code-completion results based on the text in this
4947 * chunk.
4949 CXCompletionChunk_TypedText,
4951 * Text that should be inserted as part of a code-completion result.
4953 * A "text" chunk represents text that is part of the template to be
4954 * inserted into user code should this particular code-completion result
4955 * be selected.
4957 CXCompletionChunk_Text,
4959 * Placeholder text that should be replaced by the user.
4961 * A "placeholder" chunk marks a place where the user should insert text
4962 * into the code-completion template. For example, placeholders might mark
4963 * the function parameters for a function declaration, to indicate that the
4964 * user should provide arguments for each of those parameters. The actual
4965 * text in a placeholder is a suggestion for the text to display before
4966 * the user replaces the placeholder with real code.
4968 CXCompletionChunk_Placeholder,
4970 * Informative text that should be displayed but never inserted as
4971 * part of the template.
4973 * An "informative" chunk contains annotations that can be displayed to
4974 * help the user decide whether a particular code-completion result is the
4975 * right option, but which is not part of the actual template to be inserted
4976 * by code completion.
4978 CXCompletionChunk_Informative,
4980 * Text that describes the current parameter when code-completion is
4981 * referring to function call, message send, or template specialization.
4983 * A "current parameter" chunk occurs when code-completion is providing
4984 * information about a parameter corresponding to the argument at the
4985 * code-completion point. For example, given a function
4987 * \code
4988 * int add(int x, int y);
4989 * \endcode
4991 * and the source code \c add(, where the code-completion point is after the
4992 * "(", the code-completion string will contain a "current parameter" chunk
4993 * for "int x", indicating that the current argument will initialize that
4994 * parameter. After typing further, to \c add(17, (where the code-completion
4995 * point is after the ","), the code-completion string will contain a
4996 * "current parameter" chunk to "int y".
4998 CXCompletionChunk_CurrentParameter,
5000 * A left parenthesis ('('), used to initiate a function call or
5001 * signal the beginning of a function parameter list.
5003 CXCompletionChunk_LeftParen,
5005 * A right parenthesis (')'), used to finish a function call or
5006 * signal the end of a function parameter list.
5008 CXCompletionChunk_RightParen,
5010 * A left bracket ('[').
5012 CXCompletionChunk_LeftBracket,
5014 * A right bracket (']').
5016 CXCompletionChunk_RightBracket,
5018 * A left brace ('{').
5020 CXCompletionChunk_LeftBrace,
5022 * A right brace ('}').
5024 CXCompletionChunk_RightBrace,
5026 * A left angle bracket ('<').
5028 CXCompletionChunk_LeftAngle,
5030 * A right angle bracket ('>').
5032 CXCompletionChunk_RightAngle,
5034 * A comma separator (',').
5036 CXCompletionChunk_Comma,
5038 * Text that specifies the result type of a given result.
5040 * This special kind of informative chunk is not meant to be inserted into
5041 * the text buffer. Rather, it is meant to illustrate the type that an
5042 * expression using the given completion string would have.
5044 CXCompletionChunk_ResultType,
5046 * A colon (':').
5048 CXCompletionChunk_Colon,
5050 * A semicolon (';').
5052 CXCompletionChunk_SemiColon,
5054 * An '=' sign.
5056 CXCompletionChunk_Equal,
5058 * Horizontal space (' ').
5060 CXCompletionChunk_HorizontalSpace,
5062 * Vertical space ('\\n'), after which it is generally a good idea to
5063 * perform indentation.
5065 CXCompletionChunk_VerticalSpace
5069 * Determine the kind of a particular chunk within a completion string.
5071 * \param completion_string the completion string to query.
5073 * \param chunk_number the 0-based index of the chunk in the completion string.
5075 * \returns the kind of the chunk at the index \c chunk_number.
5077 CINDEX_LINKAGE enum CXCompletionChunkKind
5078 clang_getCompletionChunkKind(CXCompletionString completion_string,
5079 unsigned chunk_number);
5082 * Retrieve the text associated with a particular chunk within a
5083 * completion string.
5085 * \param completion_string the completion string to query.
5087 * \param chunk_number the 0-based index of the chunk in the completion string.
5089 * \returns the text associated with the chunk at index \c chunk_number.
5091 CINDEX_LINKAGE CXString clang_getCompletionChunkText(
5092 CXCompletionString completion_string, unsigned chunk_number);
5095 * Retrieve the completion string associated with a particular chunk
5096 * within a completion string.
5098 * \param completion_string the completion string to query.
5100 * \param chunk_number the 0-based index of the chunk in the completion string.
5102 * \returns the completion string associated with the chunk at index
5103 * \c chunk_number.
5105 CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
5106 CXCompletionString completion_string, unsigned chunk_number);
5109 * Retrieve the number of chunks in the given code-completion string.
5111 CINDEX_LINKAGE unsigned
5112 clang_getNumCompletionChunks(CXCompletionString completion_string);
5115 * Determine the priority of this code completion.
5117 * The priority of a code completion indicates how likely it is that this
5118 * particular completion is the completion that the user will select. The
5119 * priority is selected by various internal heuristics.
5121 * \param completion_string The completion string to query.
5123 * \returns The priority of this completion string. Smaller values indicate
5124 * higher-priority (more likely) completions.
5126 CINDEX_LINKAGE unsigned
5127 clang_getCompletionPriority(CXCompletionString completion_string);
5130 * Determine the availability of the entity that this code-completion
5131 * string refers to.
5133 * \param completion_string The completion string to query.
5135 * \returns The availability of the completion string.
5137 CINDEX_LINKAGE enum CXAvailabilityKind
5138 clang_getCompletionAvailability(CXCompletionString completion_string);
5141 * Retrieve the number of annotations associated with the given
5142 * completion string.
5144 * \param completion_string the completion string to query.
5146 * \returns the number of annotations associated with the given completion
5147 * string.
5149 CINDEX_LINKAGE unsigned
5150 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5153 * Retrieve the annotation associated with the given completion string.
5155 * \param completion_string the completion string to query.
5157 * \param annotation_number the 0-based index of the annotation of the
5158 * completion string.
5160 * \returns annotation string associated with the completion at index
5161 * \c annotation_number, or a NULL string if that annotation is not available.
5163 CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
5164 CXCompletionString completion_string, unsigned annotation_number);
5167 * Retrieve the parent context of the given completion string.
5169 * The parent context of a completion string is the semantic parent of
5170 * the declaration (if any) that the code completion represents. For example,
5171 * a code completion for an Objective-C method would have the method's class
5172 * or protocol as its context.
5174 * \param completion_string The code completion string whose parent is
5175 * being queried.
5177 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5179 * \returns The name of the completion parent, e.g., "NSObject" if
5180 * the completion string represents a method in the NSObject class.
5182 CINDEX_LINKAGE CXString clang_getCompletionParent(
5183 CXCompletionString completion_string, enum CXCursorKind *kind);
5186 * Retrieve the brief documentation comment attached to the declaration
5187 * that corresponds to the given completion string.
5189 CINDEX_LINKAGE CXString
5190 clang_getCompletionBriefComment(CXCompletionString completion_string);
5193 * Retrieve a completion string for an arbitrary declaration or macro
5194 * definition cursor.
5196 * \param cursor The cursor to query.
5198 * \returns A non-context-sensitive completion string for declaration and macro
5199 * definition cursors, or NULL for other kinds of cursors.
5201 CINDEX_LINKAGE CXCompletionString
5202 clang_getCursorCompletionString(CXCursor cursor);
5205 * Contains the results of code-completion.
5207 * This data structure contains the results of code completion, as
5208 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5209 * \c clang_disposeCodeCompleteResults.
5211 typedef struct {
5213 * The code-completion results.
5215 CXCompletionResult *Results;
5218 * The number of code-completion results stored in the
5219 * \c Results array.
5221 unsigned NumResults;
5222 } CXCodeCompleteResults;
5225 * Retrieve the number of fix-its for the given completion index.
5227 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5228 * option was set.
5230 * \param results The structure keeping all completion results
5232 * \param completion_index The index of the completion
5234 * \return The number of fix-its which must be applied before the completion at
5235 * completion_index can be applied
5237 CINDEX_LINKAGE unsigned
5238 clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5239 unsigned completion_index);
5242 * Fix-its that *must* be applied before inserting the text for the
5243 * corresponding completion.
5245 * By default, clang_codeCompleteAt() only returns completions with empty
5246 * fix-its. Extra completions with non-empty fix-its should be explicitly
5247 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5249 * For the clients to be able to compute position of the cursor after applying
5250 * fix-its, the following conditions are guaranteed to hold for
5251 * replacement_range of the stored fix-its:
5252 * - Ranges in the fix-its are guaranteed to never contain the completion
5253 * point (or identifier under completion point, if any) inside them, except
5254 * at the start or at the end of the range.
5255 * - If a fix-it range starts or ends with completion point (or starts or
5256 * ends after the identifier under completion point), it will contain at
5257 * least one character. It allows to unambiguously recompute completion
5258 * point after applying the fix-it.
5260 * The intuition is that provided fix-its change code around the identifier we
5261 * complete, but are not allowed to touch the identifier itself or the
5262 * completion point. One example of completions with corrections are the ones
5263 * replacing '.' with '->' and vice versa:
5265 * std::unique_ptr<std::vector<int>> vec_ptr;
5266 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5267 * replacing '.' with '->'.
5268 * In 'vec_ptr->^', one of the completions is 'release', it requires
5269 * replacing '->' with '.'.
5271 * \param results The structure keeping all completion results
5273 * \param completion_index The index of the completion
5275 * \param fixit_index The index of the fix-it for the completion at
5276 * completion_index
5278 * \param replacement_range The fix-it range that must be replaced before the
5279 * completion at completion_index can be applied
5281 * \returns The fix-it string that must replace the code at replacement_range
5282 * before the completion at completion_index can be applied
5284 CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5285 CXCodeCompleteResults *results, unsigned completion_index,
5286 unsigned fixit_index, CXSourceRange *replacement_range);
5289 * Flags that can be passed to \c clang_codeCompleteAt() to
5290 * modify its behavior.
5292 * The enumerators in this enumeration can be bitwise-OR'd together to
5293 * provide multiple options to \c clang_codeCompleteAt().
5295 enum CXCodeComplete_Flags {
5297 * Whether to include macros within the set of code
5298 * completions returned.
5300 CXCodeComplete_IncludeMacros = 0x01,
5303 * Whether to include code patterns for language constructs
5304 * within the set of code completions, e.g., for loops.
5306 CXCodeComplete_IncludeCodePatterns = 0x02,
5309 * Whether to include brief documentation within the set of code
5310 * completions returned.
5312 CXCodeComplete_IncludeBriefComments = 0x04,
5315 * Whether to speed up completion by omitting top- or namespace-level entities
5316 * defined in the preamble. There's no guarantee any particular entity is
5317 * omitted. This may be useful if the headers are indexed externally.
5319 CXCodeComplete_SkipPreamble = 0x08,
5322 * Whether to include completions with small
5323 * fix-its, e.g. change '.' to '->' on member access, etc.
5325 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
5329 * Bits that represent the context under which completion is occurring.
5331 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5332 * contexts are occurring simultaneously.
5334 enum CXCompletionContext {
5336 * The context for completions is unexposed, as only Clang results
5337 * should be included. (This is equivalent to having no context bits set.)
5339 CXCompletionContext_Unexposed = 0,
5342 * Completions for any possible type should be included in the results.
5344 CXCompletionContext_AnyType = 1 << 0,
5347 * Completions for any possible value (variables, function calls, etc.)
5348 * should be included in the results.
5350 CXCompletionContext_AnyValue = 1 << 1,
5352 * Completions for values that resolve to an Objective-C object should
5353 * be included in the results.
5355 CXCompletionContext_ObjCObjectValue = 1 << 2,
5357 * Completions for values that resolve to an Objective-C selector
5358 * should be included in the results.
5360 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5362 * Completions for values that resolve to a C++ class type should be
5363 * included in the results.
5365 CXCompletionContext_CXXClassTypeValue = 1 << 4,
5368 * Completions for fields of the member being accessed using the dot
5369 * operator should be included in the results.
5371 CXCompletionContext_DotMemberAccess = 1 << 5,
5373 * Completions for fields of the member being accessed using the arrow
5374 * operator should be included in the results.
5376 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5378 * Completions for properties of the Objective-C object being accessed
5379 * using the dot operator should be included in the results.
5381 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5384 * Completions for enum tags should be included in the results.
5386 CXCompletionContext_EnumTag = 1 << 8,
5388 * Completions for union tags should be included in the results.
5390 CXCompletionContext_UnionTag = 1 << 9,
5392 * Completions for struct tags should be included in the results.
5394 CXCompletionContext_StructTag = 1 << 10,
5397 * Completions for C++ class names should be included in the results.
5399 CXCompletionContext_ClassTag = 1 << 11,
5401 * Completions for C++ namespaces and namespace aliases should be
5402 * included in the results.
5404 CXCompletionContext_Namespace = 1 << 12,
5406 * Completions for C++ nested name specifiers should be included in
5407 * the results.
5409 CXCompletionContext_NestedNameSpecifier = 1 << 13,
5412 * Completions for Objective-C interfaces (classes) should be included
5413 * in the results.
5415 CXCompletionContext_ObjCInterface = 1 << 14,
5417 * Completions for Objective-C protocols should be included in
5418 * the results.
5420 CXCompletionContext_ObjCProtocol = 1 << 15,
5422 * Completions for Objective-C categories should be included in
5423 * the results.
5425 CXCompletionContext_ObjCCategory = 1 << 16,
5427 * Completions for Objective-C instance messages should be included
5428 * in the results.
5430 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5432 * Completions for Objective-C class messages should be included in
5433 * the results.
5435 CXCompletionContext_ObjCClassMessage = 1 << 18,
5437 * Completions for Objective-C selector names should be included in
5438 * the results.
5440 CXCompletionContext_ObjCSelectorName = 1 << 19,
5443 * Completions for preprocessor macro names should be included in
5444 * the results.
5446 CXCompletionContext_MacroName = 1 << 20,
5449 * Natural language completions should be included in the results.
5451 CXCompletionContext_NaturalLanguage = 1 << 21,
5454 * #include file completions should be included in the results.
5456 CXCompletionContext_IncludedFile = 1 << 22,
5459 * The current context is unknown, so set all contexts.
5461 CXCompletionContext_Unknown = ((1 << 23) - 1)
5465 * Returns a default set of code-completion options that can be
5466 * passed to\c clang_codeCompleteAt().
5468 CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5471 * Perform code completion at a given location in a translation unit.
5473 * This function performs code completion at a particular file, line, and
5474 * column within source code, providing results that suggest potential
5475 * code snippets based on the context of the completion. The basic model
5476 * for code completion is that Clang will parse a complete source file,
5477 * performing syntax checking up to the location where code-completion has
5478 * been requested. At that point, a special code-completion token is passed
5479 * to the parser, which recognizes this token and determines, based on the
5480 * current location in the C/Objective-C/C++ grammar and the state of
5481 * semantic analysis, what completions to provide. These completions are
5482 * returned via a new \c CXCodeCompleteResults structure.
5484 * Code completion itself is meant to be triggered by the client when the
5485 * user types punctuation characters or whitespace, at which point the
5486 * code-completion location will coincide with the cursor. For example, if \c p
5487 * is a pointer, code-completion might be triggered after the "-" and then
5488 * after the ">" in \c p->. When the code-completion location is after the ">",
5489 * the completion results will provide, e.g., the members of the struct that
5490 * "p" points to. The client is responsible for placing the cursor at the
5491 * beginning of the token currently being typed, then filtering the results
5492 * based on the contents of the token. For example, when code-completing for
5493 * the expression \c p->get, the client should provide the location just after
5494 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5495 * client can filter the results based on the current token text ("get"), only
5496 * showing those results that start with "get". The intent of this interface
5497 * is to separate the relatively high-latency acquisition of code-completion
5498 * results from the filtering of results on a per-character basis, which must
5499 * have a lower latency.
5501 * \param TU The translation unit in which code-completion should
5502 * occur. The source files for this translation unit need not be
5503 * completely up-to-date (and the contents of those source files may
5504 * be overridden via \p unsaved_files). Cursors referring into the
5505 * translation unit may be invalidated by this invocation.
5507 * \param complete_filename The name of the source file where code
5508 * completion should be performed. This filename may be any file
5509 * included in the translation unit.
5511 * \param complete_line The line at which code-completion should occur.
5513 * \param complete_column The column at which code-completion should occur.
5514 * Note that the column should point just after the syntactic construct that
5515 * initiated code completion, and not in the middle of a lexical token.
5517 * \param unsaved_files the Files that have not yet been saved to disk
5518 * but may be required for parsing or code completion, including the
5519 * contents of those files. The contents and name of these files (as
5520 * specified by CXUnsavedFile) are copied when necessary, so the
5521 * client only needs to guarantee their validity until the call to
5522 * this function returns.
5524 * \param num_unsaved_files The number of unsaved file entries in \p
5525 * unsaved_files.
5527 * \param options Extra options that control the behavior of code
5528 * completion, expressed as a bitwise OR of the enumerators of the
5529 * CXCodeComplete_Flags enumeration. The
5530 * \c clang_defaultCodeCompleteOptions() function returns a default set
5531 * of code-completion options.
5533 * \returns If successful, a new \c CXCodeCompleteResults structure
5534 * containing code-completion results, which should eventually be
5535 * freed with \c clang_disposeCodeCompleteResults(). If code
5536 * completion fails, returns NULL.
5538 CINDEX_LINKAGE
5539 CXCodeCompleteResults *
5540 clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
5541 unsigned complete_line, unsigned complete_column,
5542 struct CXUnsavedFile *unsaved_files,
5543 unsigned num_unsaved_files, unsigned options);
5546 * Sort the code-completion results in case-insensitive alphabetical
5547 * order.
5549 * \param Results The set of results to sort.
5550 * \param NumResults The number of results in \p Results.
5552 CINDEX_LINKAGE
5553 void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5554 unsigned NumResults);
5557 * Free the given set of code-completion results.
5559 CINDEX_LINKAGE
5560 void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
5563 * Determine the number of diagnostics produced prior to the
5564 * location where code completion was performed.
5566 CINDEX_LINKAGE
5567 unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5570 * Retrieve a diagnostic associated with the given code completion.
5572 * \param Results the code completion results to query.
5573 * \param Index the zero-based diagnostic number to retrieve.
5575 * \returns the requested diagnostic. This diagnostic must be freed
5576 * via a call to \c clang_disposeDiagnostic().
5578 CINDEX_LINKAGE
5579 CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5580 unsigned Index);
5583 * Determines what completions are appropriate for the context
5584 * the given code completion.
5586 * \param Results the code completion results to query
5588 * \returns the kinds of completions that are appropriate for use
5589 * along with the given code completion results.
5591 CINDEX_LINKAGE
5592 unsigned long long
5593 clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
5596 * Returns the cursor kind for the container for the current code
5597 * completion context. The container is only guaranteed to be set for
5598 * contexts where a container exists (i.e. member accesses or Objective-C
5599 * message sends); if there is not a container, this function will return
5600 * CXCursor_InvalidCode.
5602 * \param Results the code completion results to query
5604 * \param IsIncomplete on return, this value will be false if Clang has complete
5605 * information about the container. If Clang does not have complete
5606 * information, this value will be true.
5608 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5609 * container
5611 CINDEX_LINKAGE
5612 enum CXCursorKind
5613 clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
5614 unsigned *IsIncomplete);
5617 * Returns the USR for the container for the current code completion
5618 * context. If there is not a container for the current context, this
5619 * function will return the empty string.
5621 * \param Results the code completion results to query
5623 * \returns the USR for the container
5625 CINDEX_LINKAGE
5626 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5629 * Returns the currently-entered selector for an Objective-C message
5630 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5631 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5632 * CXCompletionContext_ObjCClassMessage.
5634 * \param Results the code completion results to query
5636 * \returns the selector (or partial selector) that has been entered thus far
5637 * for an Objective-C message send.
5639 CINDEX_LINKAGE
5640 CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5643 * @}
5647 * \defgroup CINDEX_MISC Miscellaneous utility functions
5649 * @{
5653 * Return a version string, suitable for showing to a user, but not
5654 * intended to be parsed (the format is not guaranteed to be stable).
5656 CINDEX_LINKAGE CXString clang_getClangVersion(void);
5659 * Enable/disable crash recovery.
5661 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5662 * value enables crash recovery, while 0 disables it.
5664 CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5667 * Visitor invoked for each file in a translation unit
5668 * (used with clang_getInclusions()).
5670 * This visitor function will be invoked by clang_getInclusions() for each
5671 * file included (either at the top-level or by \#include directives) within
5672 * a translation unit. The first argument is the file being included, and
5673 * the second and third arguments provide the inclusion stack. The
5674 * array is sorted in order of immediate inclusion. For example,
5675 * the first element refers to the location that included 'included_file'.
5677 typedef void (*CXInclusionVisitor)(CXFile included_file,
5678 CXSourceLocation *inclusion_stack,
5679 unsigned include_len,
5680 CXClientData client_data);
5683 * Visit the set of preprocessor inclusions in a translation unit.
5684 * The visitor function is called with the provided data for every included
5685 * file. This does not include headers included by the PCH file (unless one
5686 * is inspecting the inclusions in the PCH file itself).
5688 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5689 CXInclusionVisitor visitor,
5690 CXClientData client_data);
5692 typedef enum {
5693 CXEval_Int = 1,
5694 CXEval_Float = 2,
5695 CXEval_ObjCStrLiteral = 3,
5696 CXEval_StrLiteral = 4,
5697 CXEval_CFStr = 5,
5698 CXEval_Other = 6,
5700 CXEval_UnExposed = 0
5702 } CXEvalResultKind;
5705 * Evaluation result of a cursor
5707 typedef void *CXEvalResult;
5710 * If cursor is a statement declaration tries to evaluate the
5711 * statement and if its variable, tries to evaluate its initializer,
5712 * into its corresponding type.
5713 * If it's an expression, tries to evaluate the expression.
5715 CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5718 * Returns the kind of the evaluated result.
5720 CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
5723 * Returns the evaluation result as integer if the
5724 * kind is Int.
5726 CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5729 * Returns the evaluation result as a long long integer if the
5730 * kind is Int. This prevents overflows that may happen if the result is
5731 * returned with clang_EvalResult_getAsInt.
5733 CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5736 * Returns a non-zero value if the kind is Int and the evaluation
5737 * result resulted in an unsigned integer.
5739 CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5742 * Returns the evaluation result as an unsigned integer if
5743 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5745 CINDEX_LINKAGE unsigned long long
5746 clang_EvalResult_getAsUnsigned(CXEvalResult E);
5749 * Returns the evaluation result as double if the
5750 * kind is double.
5752 CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5755 * Returns the evaluation result as a constant string if the
5756 * kind is other than Int or float. User must not free this pointer,
5757 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5758 * by clang_Cursor_Evaluate.
5760 CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
5763 * Disposes the created Eval memory.
5765 CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5767 * @}
5770 /** \defgroup CINDEX_REMAPPING Remapping functions
5772 * @{
5776 * A remapping of original source files and their translated files.
5778 typedef void *CXRemapping;
5781 * Retrieve a remapping.
5783 * \param path the path that contains metadata about remappings.
5785 * \returns the requested remapping. This remapping must be freed
5786 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5788 CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5791 * Retrieve a remapping.
5793 * \param filePaths pointer to an array of file paths containing remapping info.
5795 * \param numFiles number of file paths.
5797 * \returns the requested remapping. This remapping must be freed
5798 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5800 CINDEX_LINKAGE
5801 CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5802 unsigned numFiles);
5805 * Determine the number of remappings.
5807 CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5810 * Get the original and the associated filename from the remapping.
5812 * \param original If non-NULL, will be set to the original filename.
5814 * \param transformed If non-NULL, will be set to the filename that the original
5815 * is associated with.
5817 CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5818 CXString *original,
5819 CXString *transformed);
5822 * Dispose the remapping.
5824 CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5827 * @}
5830 /** \defgroup CINDEX_HIGH Higher level API functions
5832 * @{
5835 enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
5837 typedef struct CXCursorAndRangeVisitor {
5838 void *context;
5839 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5840 } CXCursorAndRangeVisitor;
5842 typedef enum {
5844 * Function returned successfully.
5846 CXResult_Success = 0,
5848 * One of the parameters was invalid for the function.
5850 CXResult_Invalid = 1,
5852 * The function was terminated by a callback (e.g. it returned
5853 * CXVisit_Break)
5855 CXResult_VisitBreak = 2
5857 } CXResult;
5860 * Find references of a declaration in a specific file.
5862 * \param cursor pointing to a declaration or a reference of one.
5864 * \param file to search for references.
5866 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5867 * each reference found.
5868 * The CXSourceRange will point inside the file; if the reference is inside
5869 * a macro (and not a macro argument) the CXSourceRange will be invalid.
5871 * \returns one of the CXResult enumerators.
5873 CINDEX_LINKAGE CXResult clang_findReferencesInFile(
5874 CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
5877 * Find #import/#include directives in a specific file.
5879 * \param TU translation unit containing the file to query.
5881 * \param file to search for #import/#include directives.
5883 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5884 * each directive found.
5886 * \returns one of the CXResult enumerators.
5888 CINDEX_LINKAGE CXResult clang_findIncludesInFile(
5889 CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
5891 #if __has_feature(blocks)
5892 typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
5893 CXSourceRange);
5894 #else
5895 typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;
5896 #endif
5898 CINDEX_LINKAGE
5899 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5900 CXCursorAndRangeVisitorBlock);
5902 CINDEX_LINKAGE
5903 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5904 CXCursorAndRangeVisitorBlock);
5907 * The client's data object that is associated with a CXFile.
5909 typedef void *CXIdxClientFile;
5912 * The client's data object that is associated with a semantic entity.
5914 typedef void *CXIdxClientEntity;
5917 * The client's data object that is associated with a semantic container
5918 * of entities.
5920 typedef void *CXIdxClientContainer;
5923 * The client's data object that is associated with an AST file (PCH
5924 * or module).
5926 typedef void *CXIdxClientASTFile;
5929 * Source location passed to index callbacks.
5931 typedef struct {
5932 void *ptr_data[2];
5933 unsigned int_data;
5934 } CXIdxLoc;
5937 * Data for ppIncludedFile callback.
5939 typedef struct {
5941 * Location of '#' in the \#include/\#import directive.
5943 CXIdxLoc hashLoc;
5945 * Filename as written in the \#include/\#import directive.
5947 const char *filename;
5949 * The actual file that the \#include/\#import directive resolved to.
5951 CXFile file;
5952 int isImport;
5953 int isAngled;
5955 * Non-zero if the directive was automatically turned into a module
5956 * import.
5958 int isModuleImport;
5959 } CXIdxIncludedFileInfo;
5962 * Data for IndexerCallbacks#importedASTFile.
5964 typedef struct {
5966 * Top level AST file containing the imported PCH, module or submodule.
5968 CXFile file;
5970 * The imported module or NULL if the AST file is a PCH.
5972 CXModule module;
5974 * Location where the file is imported. Applicable only for modules.
5976 CXIdxLoc loc;
5978 * Non-zero if an inclusion directive was automatically turned into
5979 * a module import. Applicable only for modules.
5981 int isImplicit;
5983 } CXIdxImportedASTFileInfo;
5985 typedef enum {
5986 CXIdxEntity_Unexposed = 0,
5987 CXIdxEntity_Typedef = 1,
5988 CXIdxEntity_Function = 2,
5989 CXIdxEntity_Variable = 3,
5990 CXIdxEntity_Field = 4,
5991 CXIdxEntity_EnumConstant = 5,
5993 CXIdxEntity_ObjCClass = 6,
5994 CXIdxEntity_ObjCProtocol = 7,
5995 CXIdxEntity_ObjCCategory = 8,
5997 CXIdxEntity_ObjCInstanceMethod = 9,
5998 CXIdxEntity_ObjCClassMethod = 10,
5999 CXIdxEntity_ObjCProperty = 11,
6000 CXIdxEntity_ObjCIvar = 12,
6002 CXIdxEntity_Enum = 13,
6003 CXIdxEntity_Struct = 14,
6004 CXIdxEntity_Union = 15,
6006 CXIdxEntity_CXXClass = 16,
6007 CXIdxEntity_CXXNamespace = 17,
6008 CXIdxEntity_CXXNamespaceAlias = 18,
6009 CXIdxEntity_CXXStaticVariable = 19,
6010 CXIdxEntity_CXXStaticMethod = 20,
6011 CXIdxEntity_CXXInstanceMethod = 21,
6012 CXIdxEntity_CXXConstructor = 22,
6013 CXIdxEntity_CXXDestructor = 23,
6014 CXIdxEntity_CXXConversionFunction = 24,
6015 CXIdxEntity_CXXTypeAlias = 25,
6016 CXIdxEntity_CXXInterface = 26,
6017 CXIdxEntity_CXXConcept = 27
6019 } CXIdxEntityKind;
6021 typedef enum {
6022 CXIdxEntityLang_None = 0,
6023 CXIdxEntityLang_C = 1,
6024 CXIdxEntityLang_ObjC = 2,
6025 CXIdxEntityLang_CXX = 3,
6026 CXIdxEntityLang_Swift = 4
6027 } CXIdxEntityLanguage;
6030 * Extra C++ template information for an entity. This can apply to:
6031 * CXIdxEntity_Function
6032 * CXIdxEntity_CXXClass
6033 * CXIdxEntity_CXXStaticMethod
6034 * CXIdxEntity_CXXInstanceMethod
6035 * CXIdxEntity_CXXConstructor
6036 * CXIdxEntity_CXXConversionFunction
6037 * CXIdxEntity_CXXTypeAlias
6039 typedef enum {
6040 CXIdxEntity_NonTemplate = 0,
6041 CXIdxEntity_Template = 1,
6042 CXIdxEntity_TemplatePartialSpecialization = 2,
6043 CXIdxEntity_TemplateSpecialization = 3
6044 } CXIdxEntityCXXTemplateKind;
6046 typedef enum {
6047 CXIdxAttr_Unexposed = 0,
6048 CXIdxAttr_IBAction = 1,
6049 CXIdxAttr_IBOutlet = 2,
6050 CXIdxAttr_IBOutletCollection = 3
6051 } CXIdxAttrKind;
6053 typedef struct {
6054 CXIdxAttrKind kind;
6055 CXCursor cursor;
6056 CXIdxLoc loc;
6057 } CXIdxAttrInfo;
6059 typedef struct {
6060 CXIdxEntityKind kind;
6061 CXIdxEntityCXXTemplateKind templateKind;
6062 CXIdxEntityLanguage lang;
6063 const char *name;
6064 const char *USR;
6065 CXCursor cursor;
6066 const CXIdxAttrInfo *const *attributes;
6067 unsigned numAttributes;
6068 } CXIdxEntityInfo;
6070 typedef struct {
6071 CXCursor cursor;
6072 } CXIdxContainerInfo;
6074 typedef struct {
6075 const CXIdxAttrInfo *attrInfo;
6076 const CXIdxEntityInfo *objcClass;
6077 CXCursor classCursor;
6078 CXIdxLoc classLoc;
6079 } CXIdxIBOutletCollectionAttrInfo;
6081 typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
6083 typedef struct {
6084 const CXIdxEntityInfo *entityInfo;
6085 CXCursor cursor;
6086 CXIdxLoc loc;
6087 const CXIdxContainerInfo *semanticContainer;
6089 * Generally same as #semanticContainer but can be different in
6090 * cases like out-of-line C++ member functions.
6092 const CXIdxContainerInfo *lexicalContainer;
6093 int isRedeclaration;
6094 int isDefinition;
6095 int isContainer;
6096 const CXIdxContainerInfo *declAsContainer;
6098 * Whether the declaration exists in code or was created implicitly
6099 * by the compiler, e.g. implicit Objective-C methods for properties.
6101 int isImplicit;
6102 const CXIdxAttrInfo *const *attributes;
6103 unsigned numAttributes;
6105 unsigned flags;
6107 } CXIdxDeclInfo;
6109 typedef enum {
6110 CXIdxObjCContainer_ForwardRef = 0,
6111 CXIdxObjCContainer_Interface = 1,
6112 CXIdxObjCContainer_Implementation = 2
6113 } CXIdxObjCContainerKind;
6115 typedef struct {
6116 const CXIdxDeclInfo *declInfo;
6117 CXIdxObjCContainerKind kind;
6118 } CXIdxObjCContainerDeclInfo;
6120 typedef struct {
6121 const CXIdxEntityInfo *base;
6122 CXCursor cursor;
6123 CXIdxLoc loc;
6124 } CXIdxBaseClassInfo;
6126 typedef struct {
6127 const CXIdxEntityInfo *protocol;
6128 CXCursor cursor;
6129 CXIdxLoc loc;
6130 } CXIdxObjCProtocolRefInfo;
6132 typedef struct {
6133 const CXIdxObjCProtocolRefInfo *const *protocols;
6134 unsigned numProtocols;
6135 } CXIdxObjCProtocolRefListInfo;
6137 typedef struct {
6138 const CXIdxObjCContainerDeclInfo *containerInfo;
6139 const CXIdxBaseClassInfo *superInfo;
6140 const CXIdxObjCProtocolRefListInfo *protocols;
6141 } CXIdxObjCInterfaceDeclInfo;
6143 typedef struct {
6144 const CXIdxObjCContainerDeclInfo *containerInfo;
6145 const CXIdxEntityInfo *objcClass;
6146 CXCursor classCursor;
6147 CXIdxLoc classLoc;
6148 const CXIdxObjCProtocolRefListInfo *protocols;
6149 } CXIdxObjCCategoryDeclInfo;
6151 typedef struct {
6152 const CXIdxDeclInfo *declInfo;
6153 const CXIdxEntityInfo *getter;
6154 const CXIdxEntityInfo *setter;
6155 } CXIdxObjCPropertyDeclInfo;
6157 typedef struct {
6158 const CXIdxDeclInfo *declInfo;
6159 const CXIdxBaseClassInfo *const *bases;
6160 unsigned numBases;
6161 } CXIdxCXXClassDeclInfo;
6164 * Data for IndexerCallbacks#indexEntityReference.
6166 * This may be deprecated in a future version as this duplicates
6167 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6169 typedef enum {
6171 * The entity is referenced directly in user's code.
6173 CXIdxEntityRef_Direct = 1,
6175 * An implicit reference, e.g. a reference of an Objective-C method
6176 * via the dot syntax.
6178 CXIdxEntityRef_Implicit = 2
6179 } CXIdxEntityRefKind;
6182 * Roles that are attributed to symbol occurrences.
6184 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6185 * higher bits zeroed. These high bits may be exposed in the future.
6187 typedef enum {
6188 CXSymbolRole_None = 0,
6189 CXSymbolRole_Declaration = 1 << 0,
6190 CXSymbolRole_Definition = 1 << 1,
6191 CXSymbolRole_Reference = 1 << 2,
6192 CXSymbolRole_Read = 1 << 3,
6193 CXSymbolRole_Write = 1 << 4,
6194 CXSymbolRole_Call = 1 << 5,
6195 CXSymbolRole_Dynamic = 1 << 6,
6196 CXSymbolRole_AddressOf = 1 << 7,
6197 CXSymbolRole_Implicit = 1 << 8
6198 } CXSymbolRole;
6201 * Data for IndexerCallbacks#indexEntityReference.
6203 typedef struct {
6204 CXIdxEntityRefKind kind;
6206 * Reference cursor.
6208 CXCursor cursor;
6209 CXIdxLoc loc;
6211 * The entity that gets referenced.
6213 const CXIdxEntityInfo *referencedEntity;
6215 * Immediate "parent" of the reference. For example:
6217 * \code
6218 * Foo *var;
6219 * \endcode
6221 * The parent of reference of type 'Foo' is the variable 'var'.
6222 * For references inside statement bodies of functions/methods,
6223 * the parentEntity will be the function/method.
6225 const CXIdxEntityInfo *parentEntity;
6227 * Lexical container context of the reference.
6229 const CXIdxContainerInfo *container;
6231 * Sets of symbol roles of the reference.
6233 CXSymbolRole role;
6234 } CXIdxEntityRefInfo;
6237 * A group of callbacks used by #clang_indexSourceFile and
6238 * #clang_indexTranslationUnit.
6240 typedef struct {
6242 * Called periodically to check whether indexing should be aborted.
6243 * Should return 0 to continue, and non-zero to abort.
6245 int (*abortQuery)(CXClientData client_data, void *reserved);
6248 * Called at the end of indexing; passes the complete diagnostic set.
6250 void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
6252 CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
6253 void *reserved);
6256 * Called when a file gets \#included/\#imported.
6258 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
6259 const CXIdxIncludedFileInfo *);
6262 * Called when a AST file (PCH or module) gets imported.
6264 * AST files will not get indexed (there will not be callbacks to index all
6265 * the entities in an AST file). The recommended action is that, if the AST
6266 * file is not already indexed, to initiate a new indexing job specific to
6267 * the AST file.
6269 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
6270 const CXIdxImportedASTFileInfo *);
6273 * Called at the beginning of indexing a translation unit.
6275 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
6276 void *reserved);
6278 void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
6281 * Called to index a reference of an entity.
6283 void (*indexEntityReference)(CXClientData client_data,
6284 const CXIdxEntityRefInfo *);
6286 } IndexerCallbacks;
6288 CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6289 CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6290 clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
6292 CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6293 clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6295 CINDEX_LINKAGE
6296 const CXIdxObjCCategoryDeclInfo *
6297 clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6299 CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6300 clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
6302 CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6303 clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6305 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6306 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6308 CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6309 clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6312 * For retrieving a custom CXIdxClientContainer attached to a
6313 * container.
6315 CINDEX_LINKAGE CXIdxClientContainer
6316 clang_index_getClientContainer(const CXIdxContainerInfo *);
6319 * For setting a custom CXIdxClientContainer attached to a
6320 * container.
6322 CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
6323 CXIdxClientContainer);
6326 * For retrieving a custom CXIdxClientEntity attached to an entity.
6328 CINDEX_LINKAGE CXIdxClientEntity
6329 clang_index_getClientEntity(const CXIdxEntityInfo *);
6332 * For setting a custom CXIdxClientEntity attached to an entity.
6334 CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
6335 CXIdxClientEntity);
6338 * An indexing action/session, to be applied to one or multiple
6339 * translation units.
6341 typedef void *CXIndexAction;
6344 * An indexing action/session, to be applied to one or multiple
6345 * translation units.
6347 * \param CIdx The index object with which the index action will be associated.
6349 CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6352 * Destroy the given index action.
6354 * The index action must not be destroyed until all of the translation units
6355 * created within that index action have been destroyed.
6357 CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6359 typedef enum {
6361 * Used to indicate that no special indexing options are needed.
6363 CXIndexOpt_None = 0x0,
6366 * Used to indicate that IndexerCallbacks#indexEntityReference should
6367 * be invoked for only one reference of an entity per source file that does
6368 * not also include a declaration/definition of the entity.
6370 CXIndexOpt_SuppressRedundantRefs = 0x1,
6373 * Function-local symbols should be indexed. If this is not set
6374 * function-local symbols will be ignored.
6376 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6379 * Implicit function/class template instantiations should be indexed.
6380 * If this is not set, implicit instantiations will be ignored.
6382 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6385 * Suppress all compiler warnings when parsing for indexing.
6387 CXIndexOpt_SuppressWarnings = 0x8,
6390 * Skip a function/method body that was already parsed during an
6391 * indexing session associated with a \c CXIndexAction object.
6392 * Bodies in system headers are always skipped.
6394 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6396 } CXIndexOptFlags;
6399 * Index the given source file and the translation unit corresponding
6400 * to that file via callbacks implemented through #IndexerCallbacks.
6402 * \param client_data pointer data supplied by the client, which will
6403 * be passed to the invoked callbacks.
6405 * \param index_callbacks Pointer to indexing callbacks that the client
6406 * implements.
6408 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6409 * passed in index_callbacks.
6411 * \param index_options A bitmask of options that affects how indexing is
6412 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6414 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6415 * reused after indexing is finished. Set to \c NULL if you do not require it.
6417 * \returns 0 on success or if there were errors from which the compiler could
6418 * recover. If there is a failure from which there is no recovery, returns
6419 * a non-zero \c CXErrorCode.
6421 * The rest of the parameters are the same as #clang_parseTranslationUnit.
6423 CINDEX_LINKAGE int clang_indexSourceFile(
6424 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6425 unsigned index_callbacks_size, unsigned index_options,
6426 const char *source_filename, const char *const *command_line_args,
6427 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6428 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6431 * Same as clang_indexSourceFile but requires a full command line
6432 * for \c command_line_args including argv[0]. This is useful if the standard
6433 * library paths are relative to the binary.
6435 CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6436 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6437 unsigned index_callbacks_size, unsigned index_options,
6438 const char *source_filename, const char *const *command_line_args,
6439 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6440 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6443 * Index the given translation unit via callbacks implemented through
6444 * #IndexerCallbacks.
6446 * The order of callback invocations is not guaranteed to be the same as
6447 * when indexing a source file. The high level order will be:
6449 * -Preprocessor callbacks invocations
6450 * -Declaration/reference callbacks invocations
6451 * -Diagnostic callback invocations
6453 * The parameters are the same as #clang_indexSourceFile.
6455 * \returns If there is a failure from which there is no recovery, returns
6456 * non-zero, otherwise returns 0.
6458 CINDEX_LINKAGE int clang_indexTranslationUnit(
6459 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6460 unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
6463 * Retrieve the CXIdxFile, file, line, column, and offset represented by
6464 * the given CXIdxLoc.
6466 * If the location refers into a macro expansion, retrieves the
6467 * location of the macro expansion and if it refers into a macro argument
6468 * retrieves the location of the argument.
6470 CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6471 CXIdxClientFile *indexFile,
6472 CXFile *file, unsigned *line,
6473 unsigned *column,
6474 unsigned *offset);
6477 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6479 CINDEX_LINKAGE
6480 CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6483 * Visitor invoked for each field found by a traversal.
6485 * This visitor function will be invoked for each field found by
6486 * \c clang_Type_visitFields. Its first argument is the cursor being
6487 * visited, its second argument is the client data provided to
6488 * \c clang_Type_visitFields.
6490 * The visitor should return one of the \c CXVisitorResult values
6491 * to direct \c clang_Type_visitFields.
6493 typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6494 CXClientData client_data);
6497 * Visit the fields of a particular type.
6499 * This function visits all the direct fields of the given cursor,
6500 * invoking the given \p visitor function with the cursors of each
6501 * visited field. The traversal may be ended prematurely, if
6502 * the visitor returns \c CXFieldVisit_Break.
6504 * \param T the record type whose field may be visited.
6506 * \param visitor the visitor function that will be invoked for each
6507 * field of \p T.
6509 * \param client_data pointer data supplied by the client, which will
6510 * be passed to the visitor each time it is invoked.
6512 * \returns a non-zero value if the traversal was terminated
6513 * prematurely by the visitor returning \c CXFieldVisit_Break.
6515 CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
6516 CXClientData client_data);
6519 * Describes the kind of binary operators.
6521 enum CXBinaryOperatorKind {
6522 /** This value describes cursors which are not binary operators. */
6523 CXBinaryOperator_Invalid,
6524 /** C++ Pointer - to - member operator. */
6525 CXBinaryOperator_PtrMemD,
6526 /** C++ Pointer - to - member operator. */
6527 CXBinaryOperator_PtrMemI,
6528 /** Multiplication operator. */
6529 CXBinaryOperator_Mul,
6530 /** Division operator. */
6531 CXBinaryOperator_Div,
6532 /** Remainder operator. */
6533 CXBinaryOperator_Rem,
6534 /** Addition operator. */
6535 CXBinaryOperator_Add,
6536 /** Subtraction operator. */
6537 CXBinaryOperator_Sub,
6538 /** Bitwise shift left operator. */
6539 CXBinaryOperator_Shl,
6540 /** Bitwise shift right operator. */
6541 CXBinaryOperator_Shr,
6542 /** C++ three-way comparison (spaceship) operator. */
6543 CXBinaryOperator_Cmp,
6544 /** Less than operator. */
6545 CXBinaryOperator_LT,
6546 /** Greater than operator. */
6547 CXBinaryOperator_GT,
6548 /** Less or equal operator. */
6549 CXBinaryOperator_LE,
6550 /** Greater or equal operator. */
6551 CXBinaryOperator_GE,
6552 /** Equal operator. */
6553 CXBinaryOperator_EQ,
6554 /** Not equal operator. */
6555 CXBinaryOperator_NE,
6556 /** Bitwise AND operator. */
6557 CXBinaryOperator_And,
6558 /** Bitwise XOR operator. */
6559 CXBinaryOperator_Xor,
6560 /** Bitwise OR operator. */
6561 CXBinaryOperator_Or,
6562 /** Logical AND operator. */
6563 CXBinaryOperator_LAnd,
6564 /** Logical OR operator. */
6565 CXBinaryOperator_LOr,
6566 /** Assignment operator. */
6567 CXBinaryOperator_Assign,
6568 /** Multiplication assignment operator. */
6569 CXBinaryOperator_MulAssign,
6570 /** Division assignment operator. */
6571 CXBinaryOperator_DivAssign,
6572 /** Remainder assignment operator. */
6573 CXBinaryOperator_RemAssign,
6574 /** Addition assignment operator. */
6575 CXBinaryOperator_AddAssign,
6576 /** Subtraction assignment operator. */
6577 CXBinaryOperator_SubAssign,
6578 /** Bitwise shift left assignment operator. */
6579 CXBinaryOperator_ShlAssign,
6580 /** Bitwise shift right assignment operator. */
6581 CXBinaryOperator_ShrAssign,
6582 /** Bitwise AND assignment operator. */
6583 CXBinaryOperator_AndAssign,
6584 /** Bitwise XOR assignment operator. */
6585 CXBinaryOperator_XorAssign,
6586 /** Bitwise OR assignment operator. */
6587 CXBinaryOperator_OrAssign,
6588 /** Comma operator. */
6589 CXBinaryOperator_Comma
6593 * Retrieve the spelling of a given CXBinaryOperatorKind.
6595 CINDEX_LINKAGE CXString
6596 clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind);
6599 * Retrieve the binary operator kind of this cursor.
6601 * If this cursor is not a binary operator then returns Invalid.
6603 CINDEX_LINKAGE enum CXBinaryOperatorKind
6604 clang_getCursorBinaryOperatorKind(CXCursor cursor);
6607 * Describes the kind of unary operators.
6609 enum CXUnaryOperatorKind {
6610 /** This value describes cursors which are not unary operators. */
6611 CXUnaryOperator_Invalid,
6612 /** Postfix increment operator. */
6613 CXUnaryOperator_PostInc,
6614 /** Postfix decrement operator. */
6615 CXUnaryOperator_PostDec,
6616 /** Prefix increment operator. */
6617 CXUnaryOperator_PreInc,
6618 /** Prefix decrement operator. */
6619 CXUnaryOperator_PreDec,
6620 /** Address of operator. */
6621 CXUnaryOperator_AddrOf,
6622 /** Dereference operator. */
6623 CXUnaryOperator_Deref,
6624 /** Plus operator. */
6625 CXUnaryOperator_Plus,
6626 /** Minus operator. */
6627 CXUnaryOperator_Minus,
6628 /** Not operator. */
6629 CXUnaryOperator_Not,
6630 /** LNot operator. */
6631 CXUnaryOperator_LNot,
6632 /** "__real expr" operator. */
6633 CXUnaryOperator_Real,
6634 /** "__imag expr" operator. */
6635 CXUnaryOperator_Imag,
6636 /** __extension__ marker operator. */
6637 CXUnaryOperator_Extension,
6638 /** C++ co_await operator. */
6639 CXUnaryOperator_Coawait
6643 * Retrieve the spelling of a given CXUnaryOperatorKind.
6645 CINDEX_LINKAGE CXString
6646 clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind);
6649 * Retrieve the unary operator kind of this cursor.
6651 * If this cursor is not a unary operator then returns Invalid.
6653 CINDEX_LINKAGE enum CXUnaryOperatorKind
6654 clang_getCursorUnaryOperatorKind(CXCursor cursor);
6657 * @}
6661 * @}
6664 LLVM_CLANG_C_EXTERN_C_END
6666 #endif