1 /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
8 |*===----------------------------------------------------------------------===*|
10 |* This header provides a public inferface to a Clang library for extracting *|
11 |* high-level symbol information from source files without exposing the full *|
14 \*===----------------------------------------------------------------------===*/
16 #ifndef LLVM_CLANG_C_INDEX_H
17 #define LLVM_CLANG_C_INDEX_H
21 #include "clang-c/Platform.h"
22 #include "clang-c/CXErrorCode.h"
23 #include "clang-c/CXString.h"
24 #include "clang-c/BuildSystem.h"
27 * \brief The version constants for the libclang API.
28 * CINDEX_VERSION_MINOR should increase when there are API additions.
29 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
31 * The policy about the libclang API was always to keep it source and ABI
32 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
34 #define CINDEX_VERSION_MAJOR 0
35 #define CINDEX_VERSION_MINOR 38
37 #define CINDEX_VERSION_ENCODE(major, minor) ( \
41 #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
42 CINDEX_VERSION_MAJOR, \
43 CINDEX_VERSION_MINOR )
45 #define CINDEX_VERSION_STRINGIZE_(major, minor) \
47 #define CINDEX_VERSION_STRINGIZE(major, minor) \
48 CINDEX_VERSION_STRINGIZE_(major, minor)
50 #define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
51 CINDEX_VERSION_MAJOR, \
58 /** \defgroup CINDEX libclang: C Interface to Clang
60 * The C Interface to Clang provides a relatively small API that exposes
61 * facilities for parsing source code into an abstract syntax tree (AST),
62 * loading already-parsed ASTs, traversing the AST, associating
63 * physical source locations with elements within the AST, and other
64 * facilities that support Clang-based development tools.
66 * This C interface to Clang will never provide all of the information
67 * representation stored in Clang's C++ AST, nor should it: the intent is to
68 * maintain an API that is relatively stable from one release to the next,
69 * providing only the basic functionality needed to support development tools.
71 * To avoid namespace pollution, data types are prefixed with "CX" and
72 * functions are prefixed with "clang_".
78 * \brief An "index" that consists of a set of translation units that would
79 * typically be linked together into an executable or library.
81 typedef void *CXIndex;
84 * \brief An opaque type representing target information for a given translation
87 typedef struct CXTargetInfoImpl *CXTargetInfo;
90 * \brief A single translation unit, which resides in an index.
92 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
95 * \brief Opaque pointer representing client data that will be passed through
96 * to various callbacks and visitors.
98 typedef void *CXClientData;
101 * \brief Provides the contents of a file that has not yet been saved to disk.
103 * Each CXUnsavedFile instance provides the name of a file on the
104 * system along with the current contents of that file that have not
105 * yet been saved to disk.
107 struct CXUnsavedFile {
109 * \brief The file whose contents have not yet been saved.
111 * This file must already exist in the file system.
113 const char *Filename;
116 * \brief A buffer containing the unsaved contents of this file.
118 const char *Contents;
121 * \brief The length of the unsaved contents of this buffer.
123 unsigned long Length;
127 * \brief Describes the availability of a particular entity, which indicates
128 * whether the use of this entity will result in a warning or error due to
129 * it being deprecated or unavailable.
131 enum CXAvailabilityKind {
133 * \brief The entity is available.
135 CXAvailability_Available,
137 * \brief The entity is available, but has been deprecated (and its use is
140 CXAvailability_Deprecated,
142 * \brief The entity is not available; any use of it will be an error.
144 CXAvailability_NotAvailable,
146 * \brief The entity is available, but not accessible; any use of it will be
149 CXAvailability_NotAccessible
153 * \brief Describes a version number of the form major.minor.subminor.
155 typedef struct CXVersion {
157 * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
158 * value indicates that there is no version number at all.
162 * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
163 * will be negative if no minor version number was provided, e.g., for
168 * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
169 * will be negative if no minor or subminor version number was provided,
170 * e.g., in version '10' or '10.7'.
176 * \brief Provides a shared context for creating translation units.
178 * It provides two options:
180 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
181 * declarations (when loading any new translation units). A "local" declaration
182 * is one that belongs in the translation unit itself and not in a precompiled
183 * header that was used by the translation unit. If zero, all declarations
184 * will be enumerated.
186 * Here is an example:
189 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
190 * Idx = clang_createIndex(1, 1);
192 * // IndexTest.pch was produced with the following command:
193 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
194 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
196 * // This will load all the symbols from 'IndexTest.pch'
197 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
198 * TranslationUnitVisitor, 0);
199 * clang_disposeTranslationUnit(TU);
201 * // This will load all the symbols from 'IndexTest.c', excluding symbols
202 * // from 'IndexTest.pch'.
203 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
204 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
206 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
207 * TranslationUnitVisitor, 0);
208 * clang_disposeTranslationUnit(TU);
211 * This process of creating the 'pch', loading it separately, and using it (via
212 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
213 * (which gives the indexer the same performance benefit as the compiler).
215 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
216 int displayDiagnostics);
219 * \brief Destroy the given index.
221 * The index must not be destroyed until all of the translation units created
222 * within that index have been destroyed.
224 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
228 * \brief Used to indicate that no special CXIndex options are needed.
230 CXGlobalOpt_None = 0x0,
233 * \brief Used to indicate that threads that libclang creates for indexing
234 * purposes should use background priority.
236 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
237 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
239 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
242 * \brief Used to indicate that threads that libclang creates for editing
243 * purposes should use background priority.
245 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
246 * #clang_annotateTokens
248 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
251 * \brief Used to indicate that all threads that libclang creates should use
252 * background priority.
254 CXGlobalOpt_ThreadBackgroundPriorityForAll =
255 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
256 CXGlobalOpt_ThreadBackgroundPriorityForEditing
261 * \brief Sets general options associated with a CXIndex.
266 * clang_CXIndex_setGlobalOptions(idx,
267 * clang_CXIndex_getGlobalOptions(idx) |
268 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
271 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
273 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
276 * \brief Gets the general options associated with a CXIndex.
278 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
279 * are associated with the given CXIndex object.
281 CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
284 * \defgroup CINDEX_FILES File manipulation routines
290 * \brief A particular source file that is part of a translation unit.
292 typedef void *CXFile;
295 * \brief Retrieve the complete file and path name of the given file.
297 CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
300 * \brief Retrieve the last modification time of the given file.
302 CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
305 * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
306 * across an indexing session.
309 unsigned long long data[3];
313 * \brief Retrieve the unique ID for the given \c file.
315 * \param file the file to get the ID for.
316 * \param outID stores the returned CXFileUniqueID.
317 * \returns If there was a failure getting the unique ID, returns non-zero,
318 * otherwise returns 0.
320 CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
323 * \brief Determine whether the given header is guarded against
324 * multiple inclusions, either with the conventional
325 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
327 CINDEX_LINKAGE unsigned
328 clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
331 * \brief Retrieve a file handle within the given translation unit.
333 * \param tu the translation unit
335 * \param file_name the name of the file.
337 * \returns the file handle for the named file in the translation unit \p tu,
338 * or a NULL file handle if the file was not a part of this translation unit.
340 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
341 const char *file_name);
344 * \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
345 * or they are both NULL.
347 CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
354 * \defgroup CINDEX_LOCATIONS Physical source locations
356 * Clang represents physical source locations in its abstract syntax tree in
357 * great detail, with file, line, and column information for the majority of
358 * the tokens parsed in the source code. These data types and functions are
359 * used to represent source location information, either for a particular
360 * point in the program or for a range of points in the program, and extract
361 * specific location information from those data types.
367 * \brief Identifies a specific source location within a translation
370 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
371 * to map a source location to a particular file, line, and column.
374 const void *ptr_data[2];
379 * \brief Identifies a half-open character range in the source code.
381 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
382 * starting and end locations from a source range, respectively.
385 const void *ptr_data[2];
386 unsigned begin_int_data;
387 unsigned end_int_data;
391 * \brief Retrieve a NULL (invalid) source location.
393 CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
396 * \brief Determine whether two source locations, which must refer into
397 * the same translation unit, refer to exactly the same point in the source
400 * \returns non-zero if the source locations refer to the same location, zero
401 * if they refer to different locations.
403 CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
404 CXSourceLocation loc2);
407 * \brief Retrieves the source location associated with a given file/line/column
408 * in a particular translation unit.
410 CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
415 * \brief Retrieves the source location associated with a given character offset
416 * in a particular translation unit.
418 CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
423 * \brief Returns non-zero if the given source location is in a system header.
425 CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
428 * \brief Returns non-zero if the given source location is in the main file of
429 * the corresponding translation unit.
431 CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
434 * \brief Retrieve a NULL (invalid) source range.
436 CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
439 * \brief Retrieve a source range given the beginning and ending source
442 CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
443 CXSourceLocation end);
446 * \brief Determine whether two ranges are equivalent.
448 * \returns non-zero if the ranges are the same, zero if they differ.
450 CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
451 CXSourceRange range2);
454 * \brief Returns non-zero if \p range is null.
456 CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
459 * \brief Retrieve the file, line, column, and offset represented by
460 * the given source location.
462 * If the location refers into a macro expansion, retrieves the
463 * location of the macro expansion.
465 * \param location the location within a source file that will be decomposed
468 * \param file [out] if non-NULL, will be set to the file to which the given
469 * source location points.
471 * \param line [out] if non-NULL, will be set to the line to which the given
472 * source location points.
474 * \param column [out] if non-NULL, will be set to the column to which the given
475 * source location points.
477 * \param offset [out] if non-NULL, will be set to the offset into the
478 * buffer to which the given source location points.
480 CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
487 * \brief Retrieve the file, line and column represented by the given source
488 * location, as specified in a # line directive.
490 * Example: given the following source code in a file somefile.c
495 * static int func(void)
501 * the location information returned by this function would be
503 * File: dummy.c Line: 124 Column: 12
505 * whereas clang_getExpansionLocation would have returned
507 * File: somefile.c Line: 3 Column: 12
509 * \param location the location within a source file that will be decomposed
512 * \param filename [out] if non-NULL, will be set to the filename of the
513 * source location. Note that filenames returned will be for "virtual" files,
514 * which don't necessarily exist on the machine running clang - e.g. when
515 * parsing preprocessed output obtained from a different environment. If
516 * a non-NULL value is passed in, remember to dispose of the returned value
517 * using \c clang_disposeString() once you've finished with it. For an invalid
518 * source location, an empty string is returned.
520 * \param line [out] if non-NULL, will be set to the line number of the
521 * source location. For an invalid source location, zero is returned.
523 * \param column [out] if non-NULL, will be set to the column number of the
524 * source location. For an invalid source location, zero is returned.
526 CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
532 * \brief Legacy API to retrieve the file, line, column, and offset represented
533 * by the given source location.
535 * This interface has been replaced by the newer interface
536 * #clang_getExpansionLocation(). See that interface's documentation for
539 CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
546 * \brief Retrieve the file, line, column, and offset represented by
547 * the given source location.
549 * If the location refers into a macro instantiation, return where the
550 * location was originally spelled in the source file.
552 * \param location the location within a source file that will be decomposed
555 * \param file [out] if non-NULL, will be set to the file to which the given
556 * source location points.
558 * \param line [out] if non-NULL, will be set to the line to which the given
559 * source location points.
561 * \param column [out] if non-NULL, will be set to the column to which the given
562 * source location points.
564 * \param offset [out] if non-NULL, will be set to the offset into the
565 * buffer to which the given source location points.
567 CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
574 * \brief Retrieve the file, line, column, and offset represented by
575 * the given source location.
577 * If the location refers into a macro expansion, return where the macro was
578 * expanded or where the macro argument was written, if the location points at
581 * \param location the location within a source file that will be decomposed
584 * \param file [out] if non-NULL, will be set to the file to which the given
585 * source location points.
587 * \param line [out] if non-NULL, will be set to the line to which the given
588 * source location points.
590 * \param column [out] if non-NULL, will be set to the column to which the given
591 * source location points.
593 * \param offset [out] if non-NULL, will be set to the offset into the
594 * buffer to which the given source location points.
596 CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
603 * \brief Retrieve a source location representing the first character within a
606 CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
609 * \brief Retrieve a source location representing the last character within a
612 CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
615 * \brief Identifies an array of ranges.
618 /** \brief The number of ranges in the \c ranges array. */
621 * \brief An array of \c CXSourceRanges.
623 CXSourceRange *ranges;
627 * \brief Retrieve all ranges that were skipped by the preprocessor.
629 * The preprocessor will skip lines when they are surrounded by an
630 * if/ifdef/ifndef directive whose condition does not evaluate to true.
632 CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
636 * \brief Retrieve all ranges from all files that were skipped by the
639 * The preprocessor will skip lines when they are surrounded by an
640 * if/ifdef/ifndef directive whose condition does not evaluate to true.
642 CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
645 * \brief Destroy the given \c CXSourceRangeList.
647 CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
654 * \defgroup CINDEX_DIAG Diagnostic reporting
660 * \brief Describes the severity of a particular diagnostic.
662 enum CXDiagnosticSeverity {
664 * \brief A diagnostic that has been suppressed, e.g., by a command-line
667 CXDiagnostic_Ignored = 0,
670 * \brief This diagnostic is a note that should be attached to the
671 * previous (non-note) diagnostic.
673 CXDiagnostic_Note = 1,
676 * \brief This diagnostic indicates suspicious code that may not be
679 CXDiagnostic_Warning = 2,
682 * \brief This diagnostic indicates that the code is ill-formed.
684 CXDiagnostic_Error = 3,
687 * \brief This diagnostic indicates that the code is ill-formed such
688 * that future parser recovery is unlikely to produce useful
691 CXDiagnostic_Fatal = 4
695 * \brief A single diagnostic, containing the diagnostic's severity,
696 * location, text, source ranges, and fix-it hints.
698 typedef void *CXDiagnostic;
701 * \brief A group of CXDiagnostics.
703 typedef void *CXDiagnosticSet;
706 * \brief Determine the number of diagnostics in a CXDiagnosticSet.
708 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
711 * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
713 * \param Diags the CXDiagnosticSet to query.
714 * \param Index the zero-based diagnostic number to retrieve.
716 * \returns the requested diagnostic. This diagnostic must be freed
717 * via a call to \c clang_disposeDiagnostic().
719 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
723 * \brief Describes the kind of error that occurred (if any) in a call to
724 * \c clang_loadDiagnostics.
726 enum CXLoadDiag_Error {
728 * \brief Indicates that no error occurred.
733 * \brief Indicates that an unknown error occurred while attempting to
734 * deserialize diagnostics.
736 CXLoadDiag_Unknown = 1,
739 * \brief Indicates that the file containing the serialized diagnostics
740 * could not be opened.
742 CXLoadDiag_CannotLoad = 2,
745 * \brief Indicates that the serialized diagnostics file is invalid or
748 CXLoadDiag_InvalidFile = 3
752 * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
755 * \param file The name of the file to deserialize.
756 * \param error A pointer to a enum value recording if there was a problem
757 * deserializing the diagnostics.
758 * \param errorString A pointer to a CXString for recording the error string
759 * if the file was not successfully loaded.
761 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
762 * diagnostics should be released using clang_disposeDiagnosticSet().
764 CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
765 enum CXLoadDiag_Error *error,
766 CXString *errorString);
769 * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
771 CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
774 * \brief Retrieve the child diagnostics of a CXDiagnostic.
776 * This CXDiagnosticSet does not need to be released by
777 * clang_disposeDiagnosticSet.
779 CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
782 * \brief Determine the number of diagnostics produced for the given
785 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
788 * \brief Retrieve a diagnostic associated with the given translation unit.
790 * \param Unit the translation unit to query.
791 * \param Index the zero-based diagnostic number to retrieve.
793 * \returns the requested diagnostic. This diagnostic must be freed
794 * via a call to \c clang_disposeDiagnostic().
796 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
800 * \brief Retrieve the complete set of diagnostics associated with a
803 * \param Unit the translation unit to query.
805 CINDEX_LINKAGE CXDiagnosticSet
806 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
809 * \brief Destroy a diagnostic.
811 CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
814 * \brief Options to control the display of diagnostics.
816 * The values in this enum are meant to be combined to customize the
817 * behavior of \c clang_formatDiagnostic().
819 enum CXDiagnosticDisplayOptions {
821 * \brief Display the source-location information where the
822 * diagnostic was located.
824 * When set, diagnostics will be prefixed by the file, line, and
825 * (optionally) column to which the diagnostic refers. For example,
828 * test.c:28: warning: extra tokens at end of #endif directive
831 * This option corresponds to the clang flag \c -fshow-source-location.
833 CXDiagnostic_DisplaySourceLocation = 0x01,
836 * \brief If displaying the source-location information of the
837 * diagnostic, also include the column number.
839 * This option corresponds to the clang flag \c -fshow-column.
841 CXDiagnostic_DisplayColumn = 0x02,
844 * \brief If displaying the source-location information of the
845 * diagnostic, also include information about source ranges in a
846 * machine-parsable format.
848 * This option corresponds to the clang flag
849 * \c -fdiagnostics-print-source-range-info.
851 CXDiagnostic_DisplaySourceRanges = 0x04,
854 * \brief Display the option name associated with this diagnostic, if any.
856 * The option name displayed (e.g., -Wconversion) will be placed in brackets
857 * after the diagnostic text. This option corresponds to the clang flag
858 * \c -fdiagnostics-show-option.
860 CXDiagnostic_DisplayOption = 0x08,
863 * \brief Display the category number associated with this diagnostic, if any.
865 * The category number is displayed within brackets after the diagnostic text.
866 * This option corresponds to the clang flag
867 * \c -fdiagnostics-show-category=id.
869 CXDiagnostic_DisplayCategoryId = 0x10,
872 * \brief Display the category name associated with this diagnostic, if any.
874 * The category name is displayed within brackets after the diagnostic text.
875 * This option corresponds to the clang flag
876 * \c -fdiagnostics-show-category=name.
878 CXDiagnostic_DisplayCategoryName = 0x20
882 * \brief Format the given diagnostic in a manner that is suitable for display.
884 * This routine will format the given diagnostic to a string, rendering
885 * the diagnostic according to the various options given. The
886 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
887 * options that most closely mimics the behavior of the clang compiler.
889 * \param Diagnostic The diagnostic to print.
891 * \param Options A set of options that control the diagnostic display,
892 * created by combining \c CXDiagnosticDisplayOptions values.
894 * \returns A new string containing for formatted diagnostic.
896 CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
900 * \brief Retrieve the set of display options most similar to the
901 * default behavior of the clang compiler.
903 * \returns A set of display options suitable for use with \c
904 * clang_formatDiagnostic().
906 CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
909 * \brief Determine the severity of the given diagnostic.
911 CINDEX_LINKAGE enum CXDiagnosticSeverity
912 clang_getDiagnosticSeverity(CXDiagnostic);
915 * \brief Retrieve the source location of the given diagnostic.
917 * This location is where Clang would print the caret ('^') when
918 * displaying the diagnostic on the command line.
920 CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
923 * \brief Retrieve the text of the given diagnostic.
925 CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
928 * \brief Retrieve the name of the command-line option that enabled this
931 * \param Diag The diagnostic to be queried.
933 * \param Disable If non-NULL, will be set to the option that disables this
934 * diagnostic (if any).
936 * \returns A string that contains the command-line option used to enable this
937 * warning, such as "-Wconversion" or "-pedantic".
939 CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
943 * \brief Retrieve the category number for this diagnostic.
945 * Diagnostics can be categorized into groups along with other, related
946 * diagnostics (e.g., diagnostics under the same warning flag). This routine
947 * retrieves the category number for the given diagnostic.
949 * \returns The number of the category that contains this diagnostic, or zero
950 * if this diagnostic is uncategorized.
952 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
955 * \brief Retrieve the name of a particular diagnostic category. This
956 * is now deprecated. Use clang_getDiagnosticCategoryText()
959 * \param Category A diagnostic category number, as returned by
960 * \c clang_getDiagnosticCategory().
962 * \returns The name of the given diagnostic category.
964 CINDEX_DEPRECATED CINDEX_LINKAGE
965 CXString clang_getDiagnosticCategoryName(unsigned Category);
968 * \brief Retrieve the diagnostic category text for a given diagnostic.
970 * \returns The text of the given diagnostic category.
972 CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
975 * \brief Determine the number of source ranges associated with the given
978 CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
981 * \brief Retrieve a source range associated with the diagnostic.
983 * A diagnostic's source ranges highlight important elements in the source
984 * code. On the command line, Clang displays source ranges by
985 * underlining them with '~' characters.
987 * \param Diagnostic the diagnostic whose range is being extracted.
989 * \param Range the zero-based index specifying which range to
991 * \returns the requested source range.
993 CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
997 * \brief Determine the number of fix-it hints associated with the
1000 CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1003 * \brief Retrieve the replacement information for a given fix-it.
1005 * Fix-its are described in terms of a source range whose contents
1006 * should be replaced by a string. This approach generalizes over
1007 * three kinds of operations: removal of source code (the range covers
1008 * the code to be removed and the replacement string is empty),
1009 * replacement of source code (the range covers the code to be
1010 * replaced and the replacement string provides the new code), and
1011 * insertion (both the start and end of the range point at the
1012 * insertion location, and the replacement string provides the text to
1015 * \param Diagnostic The diagnostic whose fix-its are being queried.
1017 * \param FixIt The zero-based index of the fix-it.
1019 * \param ReplacementRange The source range whose contents will be
1020 * replaced with the returned replacement string. Note that source
1021 * ranges are half-open ranges [a, b), so the source code should be
1022 * replaced from a and up to (but not including) b.
1024 * \returns A string containing text that should be replace the source
1025 * code indicated by the \c ReplacementRange.
1027 CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
1029 CXSourceRange *ReplacementRange);
1036 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1038 * The routines in this group provide the ability to create and destroy
1039 * translation units from files, either by parsing the contents of the files or
1040 * by reading in a serialized representation of a translation unit.
1046 * \brief Get the original translation unit source file name.
1048 CINDEX_LINKAGE CXString
1049 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1052 * \brief Return the CXTranslationUnit for a given source file and the provided
1053 * command line arguments one would pass to the compiler.
1055 * Note: The 'source_filename' argument is optional. If the caller provides a
1056 * NULL pointer, the name of the source file is expected to reside in the
1057 * specified command line arguments.
1059 * Note: When encountered in 'clang_command_line_args', the following options
1065 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
1067 * \param CIdx The index object with which the translation unit will be
1070 * \param source_filename The name of the source file to load, or NULL if the
1071 * source file is included in \p clang_command_line_args.
1073 * \param num_clang_command_line_args The number of command-line arguments in
1074 * \p clang_command_line_args.
1076 * \param clang_command_line_args The command-line arguments that would be
1077 * passed to the \c clang executable if it were being invoked out-of-process.
1078 * These command-line options will be parsed and will affect how the translation
1079 * unit is parsed. Note that the following options are ignored: '-c',
1080 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1082 * \param num_unsaved_files the number of unsaved file entries in \p
1085 * \param unsaved_files the files that have not yet been saved to disk
1086 * but may be required for code completion, including the contents of
1087 * those files. The contents and name of these files (as specified by
1088 * CXUnsavedFile) are copied when necessary, so the client only needs to
1089 * guarantee their validity until the call to this function returns.
1091 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1093 const char *source_filename,
1094 int num_clang_command_line_args,
1095 const char * const *clang_command_line_args,
1096 unsigned num_unsaved_files,
1097 struct CXUnsavedFile *unsaved_files);
1100 * \brief Same as \c clang_createTranslationUnit2, but returns
1101 * the \c CXTranslationUnit instead of an error code. In case of an error this
1102 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1105 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1107 const char *ast_filename);
1110 * \brief Create a translation unit from an AST file (\c -emit-ast).
1112 * \param[out] out_TU A non-NULL pointer to store the created
1113 * \c CXTranslationUnit.
1115 * \returns Zero on success, otherwise returns an error code.
1117 CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1119 const char *ast_filename,
1120 CXTranslationUnit *out_TU);
1123 * \brief Flags that control the creation of translation units.
1125 * The enumerators in this enumeration type are meant to be bitwise
1126 * ORed together to specify which options should be used when
1127 * constructing the translation unit.
1129 enum CXTranslationUnit_Flags {
1131 * \brief Used to indicate that no special translation-unit options are
1134 CXTranslationUnit_None = 0x0,
1137 * \brief Used to indicate that the parser should construct a "detailed"
1138 * preprocessing record, including all macro definitions and instantiations.
1140 * Constructing a detailed preprocessing record requires more memory
1141 * and time to parse, since the information contained in the record
1142 * is usually not retained. However, it can be useful for
1143 * applications that require more detailed information about the
1144 * behavior of the preprocessor.
1146 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1149 * \brief Used to indicate that the translation unit is incomplete.
1151 * When a translation unit is considered "incomplete", semantic
1152 * analysis that is typically performed at the end of the
1153 * translation unit will be suppressed. For example, this suppresses
1154 * the completion of tentative declarations in C and of
1155 * instantiation of implicitly-instantiation function templates in
1156 * C++. This option is typically used when parsing a header with the
1157 * intent of producing a precompiled header.
1159 CXTranslationUnit_Incomplete = 0x02,
1162 * \brief Used to indicate that the translation unit should be built with an
1163 * implicit precompiled header for the preamble.
1165 * An implicit precompiled header is used as an optimization when a
1166 * particular translation unit is likely to be reparsed many times
1167 * when the sources aren't changing that often. In this case, an
1168 * implicit precompiled header will be built containing all of the
1169 * initial includes at the top of the main file (what we refer to as
1170 * the "preamble" of the file). In subsequent parses, if the
1171 * preamble or the files in it have not changed, \c
1172 * clang_reparseTranslationUnit() will re-use the implicit
1173 * precompiled header to improve parsing performance.
1175 CXTranslationUnit_PrecompiledPreamble = 0x04,
1178 * \brief Used to indicate that the translation unit should cache some
1179 * code-completion results with each reparse of the source file.
1181 * Caching of code-completion results is a performance optimization that
1182 * introduces some overhead to reparsing but improves the performance of
1183 * code-completion operations.
1185 CXTranslationUnit_CacheCompletionResults = 0x08,
1188 * \brief Used to indicate that the translation unit will be serialized with
1189 * \c clang_saveTranslationUnit.
1191 * This option is typically used when parsing a header with the intent of
1192 * producing a precompiled header.
1194 CXTranslationUnit_ForSerialization = 0x10,
1197 * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
1199 * Note: this is a *temporary* option that is available only while
1200 * we are testing C++ precompiled preamble support. It is deprecated.
1202 CXTranslationUnit_CXXChainedPCH = 0x20,
1205 * \brief Used to indicate that function/method bodies should be skipped while
1208 * This option can be used to search for declarations/definitions while
1209 * ignoring the usages.
1211 CXTranslationUnit_SkipFunctionBodies = 0x40,
1214 * \brief Used to indicate that brief documentation comments should be
1215 * included into the set of code completions returned from this translation
1218 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1221 * \brief Used to indicate that the precompiled preamble should be created on
1222 * the first parse. Otherwise it will be created on the first reparse. This
1223 * trades runtime on the first parse (serializing the preamble takes time) for
1224 * reduced runtime on the second parse (can now reuse the preamble).
1226 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1229 * \brief Do not stop processing when fatal errors are encountered.
1231 * When fatal errors are encountered while parsing a translation unit,
1232 * semantic analysis is typically stopped early when compiling code. A common
1233 * source for fatal errors are unresolvable include files. For the
1234 * purposes of an IDE, this is undesirable behavior and as much information
1235 * as possible should be reported. Use this flag to enable this behavior.
1237 CXTranslationUnit_KeepGoing = 0x200
1241 * \brief Returns the set of flags that is suitable for parsing a translation
1242 * unit that is being edited.
1244 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1245 * to indicate that the translation unit is likely to be reparsed many times,
1246 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1247 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1248 * set contains an unspecified set of optimizations (e.g., the precompiled
1249 * preamble) geared toward improving the performance of these routines. The
1250 * set of optimizations enabled may change from one version to the next.
1252 CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1255 * \brief Same as \c clang_parseTranslationUnit2, but returns
1256 * the \c CXTranslationUnit instead of an error code. In case of an error this
1257 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1260 CINDEX_LINKAGE CXTranslationUnit
1261 clang_parseTranslationUnit(CXIndex CIdx,
1262 const char *source_filename,
1263 const char *const *command_line_args,
1264 int num_command_line_args,
1265 struct CXUnsavedFile *unsaved_files,
1266 unsigned num_unsaved_files,
1270 * \brief Parse the given source file and the translation unit corresponding
1273 * This routine is the main entry point for the Clang C API, providing the
1274 * ability to parse a source file into a translation unit that can then be
1275 * queried by other functions in the API. This routine accepts a set of
1276 * command-line arguments so that the compilation can be configured in the same
1277 * way that the compiler is configured on the command line.
1279 * \param CIdx The index object with which the translation unit will be
1282 * \param source_filename The name of the source file to load, or NULL if the
1283 * source file is included in \c command_line_args.
1285 * \param command_line_args The command-line arguments that would be
1286 * passed to the \c clang executable if it were being invoked out-of-process.
1287 * These command-line options will be parsed and will affect how the translation
1288 * unit is parsed. Note that the following options are ignored: '-c',
1289 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1291 * \param num_command_line_args The number of command-line arguments in
1292 * \c command_line_args.
1294 * \param unsaved_files the files that have not yet been saved to disk
1295 * but may be required for parsing, including the contents of
1296 * those files. The contents and name of these files (as specified by
1297 * CXUnsavedFile) are copied when necessary, so the client only needs to
1298 * guarantee their validity until the call to this function returns.
1300 * \param num_unsaved_files the number of unsaved file entries in \p
1303 * \param options A bitmask of options that affects how the translation unit
1304 * is managed but not its compilation. This should be a bitwise OR of the
1305 * CXTranslationUnit_XXX flags.
1307 * \param[out] out_TU A non-NULL pointer to store the created
1308 * \c CXTranslationUnit, describing the parsed code and containing any
1309 * diagnostics produced by the compiler.
1311 * \returns Zero on success, otherwise returns an error code.
1313 CINDEX_LINKAGE enum CXErrorCode
1314 clang_parseTranslationUnit2(CXIndex CIdx,
1315 const char *source_filename,
1316 const char *const *command_line_args,
1317 int num_command_line_args,
1318 struct CXUnsavedFile *unsaved_files,
1319 unsigned num_unsaved_files,
1321 CXTranslationUnit *out_TU);
1324 * \brief Same as clang_parseTranslationUnit2 but requires a full command line
1325 * for \c command_line_args including argv[0]. This is useful if the standard
1326 * library paths are relative to the binary.
1328 CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1329 CXIndex CIdx, const char *source_filename,
1330 const char *const *command_line_args, int num_command_line_args,
1331 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1332 unsigned options, CXTranslationUnit *out_TU);
1335 * \brief Flags that control how translation units are saved.
1337 * The enumerators in this enumeration type are meant to be bitwise
1338 * ORed together to specify which options should be used when
1339 * saving the translation unit.
1341 enum CXSaveTranslationUnit_Flags {
1343 * \brief Used to indicate that no special saving options are needed.
1345 CXSaveTranslationUnit_None = 0x0
1349 * \brief Returns the set of flags that is suitable for saving a translation
1352 * The set of flags returned provide options for
1353 * \c clang_saveTranslationUnit() by default. The returned flag
1354 * set contains an unspecified set of options that save translation units with
1355 * the most commonly-requested data.
1357 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1360 * \brief Describes the kind of error that occurred (if any) in a call to
1361 * \c clang_saveTranslationUnit().
1365 * \brief Indicates that no error occurred while saving a translation unit.
1367 CXSaveError_None = 0,
1370 * \brief Indicates that an unknown error occurred while attempting to save
1373 * This error typically indicates that file I/O failed when attempting to
1376 CXSaveError_Unknown = 1,
1379 * \brief Indicates that errors during translation prevented this attempt
1380 * to save the translation unit.
1382 * Errors that prevent the translation unit from being saved can be
1383 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1385 CXSaveError_TranslationErrors = 2,
1388 * \brief Indicates that the translation unit to be saved was somehow
1389 * invalid (e.g., NULL).
1391 CXSaveError_InvalidTU = 3
1395 * \brief Saves a translation unit into a serialized representation of
1396 * that translation unit on disk.
1398 * Any translation unit that was parsed without error can be saved
1399 * into a file. The translation unit can then be deserialized into a
1400 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1401 * if it is an incomplete translation unit that corresponds to a
1402 * header, used as a precompiled header when parsing other translation
1405 * \param TU The translation unit to save.
1407 * \param FileName The file to which the translation unit will be saved.
1409 * \param options A bitmask of options that affects how the translation unit
1410 * is saved. This should be a bitwise OR of the
1411 * CXSaveTranslationUnit_XXX flags.
1413 * \returns A value that will match one of the enumerators of the CXSaveError
1414 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1415 * saved successfully, while a non-zero value indicates that a problem occurred.
1417 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1418 const char *FileName,
1422 * \brief Destroy the specified CXTranslationUnit object.
1424 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1427 * \brief Flags that control the reparsing of translation units.
1429 * The enumerators in this enumeration type are meant to be bitwise
1430 * ORed together to specify which options should be used when
1431 * reparsing the translation unit.
1433 enum CXReparse_Flags {
1435 * \brief Used to indicate that no special reparsing options are needed.
1437 CXReparse_None = 0x0
1441 * \brief Returns the set of flags that is suitable for reparsing a translation
1444 * The set of flags returned provide options for
1445 * \c clang_reparseTranslationUnit() by default. The returned flag
1446 * set contains an unspecified set of optimizations geared toward common uses
1447 * of reparsing. The set of optimizations enabled may change from one version
1450 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1453 * \brief Reparse the source files that produced this translation unit.
1455 * This routine can be used to re-parse the source files that originally
1456 * created the given translation unit, for example because those source files
1457 * have changed (either on disk or as passed via \p unsaved_files). The
1458 * source code will be reparsed with the same command-line options as it
1459 * was originally parsed.
1461 * Reparsing a translation unit invalidates all cursors and source locations
1462 * that refer into that translation unit. This makes reparsing a translation
1463 * unit semantically equivalent to destroying the translation unit and then
1464 * creating a new translation unit with the same command-line arguments.
1465 * However, it may be more efficient to reparse a translation
1466 * unit using this routine.
1468 * \param TU The translation unit whose contents will be re-parsed. The
1469 * translation unit must originally have been built with
1470 * \c clang_createTranslationUnitFromSourceFile().
1472 * \param num_unsaved_files The number of unsaved file entries in \p
1475 * \param unsaved_files The files that have not yet been saved to disk
1476 * but may be required for parsing, including the contents of
1477 * those files. The contents and name of these files (as specified by
1478 * CXUnsavedFile) are copied when necessary, so the client only needs to
1479 * guarantee their validity until the call to this function returns.
1481 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1482 * The function \c clang_defaultReparseOptions() produces a default set of
1483 * options recommended for most uses, based on the translation unit.
1485 * \returns 0 if the sources could be reparsed. A non-zero error code will be
1486 * returned if reparsing was impossible, such that the translation unit is
1487 * invalid. In such cases, the only valid call for \c TU is
1488 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1489 * routine are described by the \c CXErrorCode enum.
1491 CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1492 unsigned num_unsaved_files,
1493 struct CXUnsavedFile *unsaved_files,
1497 * \brief Categorizes how memory is being used by a translation unit.
1499 enum CXTUResourceUsageKind {
1500 CXTUResourceUsage_AST = 1,
1501 CXTUResourceUsage_Identifiers = 2,
1502 CXTUResourceUsage_Selectors = 3,
1503 CXTUResourceUsage_GlobalCompletionResults = 4,
1504 CXTUResourceUsage_SourceManagerContentCache = 5,
1505 CXTUResourceUsage_AST_SideTables = 6,
1506 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1507 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1508 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1509 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1510 CXTUResourceUsage_Preprocessor = 11,
1511 CXTUResourceUsage_PreprocessingRecord = 12,
1512 CXTUResourceUsage_SourceManager_DataStructures = 13,
1513 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1514 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1515 CXTUResourceUsage_MEMORY_IN_BYTES_END =
1516 CXTUResourceUsage_Preprocessor_HeaderSearch,
1518 CXTUResourceUsage_First = CXTUResourceUsage_AST,
1519 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1523 * \brief Returns the human-readable null-terminated C string that represents
1524 * the name of the memory category. This string should never be freed.
1527 const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1529 typedef struct CXTUResourceUsageEntry {
1530 /* \brief The memory usage category. */
1531 enum CXTUResourceUsageKind kind;
1532 /* \brief Amount of resources used.
1533 The units will depend on the resource kind. */
1534 unsigned long amount;
1535 } CXTUResourceUsageEntry;
1538 * \brief The memory usage of a CXTranslationUnit, broken into categories.
1540 typedef struct CXTUResourceUsage {
1541 /* \brief Private data member, used for queries. */
1544 /* \brief The number of entries in the 'entries' array. */
1545 unsigned numEntries;
1547 /* \brief An array of key-value pairs, representing the breakdown of memory
1549 CXTUResourceUsageEntry *entries;
1551 } CXTUResourceUsage;
1554 * \brief Return the memory usage of a translation unit. This object
1555 * should be released with clang_disposeCXTUResourceUsage().
1557 CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1559 CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1562 * \brief Get target information for this translation unit.
1564 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1566 CINDEX_LINKAGE CXTargetInfo
1567 clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1570 * \brief Destroy the CXTargetInfo object.
1573 clang_TargetInfo_dispose(CXTargetInfo Info);
1576 * \brief Get the normalized target triple as a string.
1578 * Returns the empty string in case of any error.
1580 CINDEX_LINKAGE CXString
1581 clang_TargetInfo_getTriple(CXTargetInfo Info);
1584 * \brief Get the pointer width of the target in bits.
1586 * Returns -1 in case of error.
1589 clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1596 * \brief Describes the kind of entity that a cursor refers to.
1601 * \brief A declaration whose specific kind is not exposed via this
1604 * Unexposed declarations have the same operations as any other kind
1605 * of declaration; one can extract their location information,
1606 * spelling, find their definitions, etc. However, the specific kind
1607 * of the declaration is not reported.
1609 CXCursor_UnexposedDecl = 1,
1610 /** \brief A C or C++ struct. */
1611 CXCursor_StructDecl = 2,
1612 /** \brief A C or C++ union. */
1613 CXCursor_UnionDecl = 3,
1614 /** \brief A C++ class. */
1615 CXCursor_ClassDecl = 4,
1616 /** \brief An enumeration. */
1617 CXCursor_EnumDecl = 5,
1619 * \brief A field (in C) or non-static data member (in C++) in a
1620 * struct, union, or C++ class.
1622 CXCursor_FieldDecl = 6,
1623 /** \brief An enumerator constant. */
1624 CXCursor_EnumConstantDecl = 7,
1625 /** \brief A function. */
1626 CXCursor_FunctionDecl = 8,
1627 /** \brief A variable. */
1628 CXCursor_VarDecl = 9,
1629 /** \brief A function or method parameter. */
1630 CXCursor_ParmDecl = 10,
1631 /** \brief An Objective-C \@interface. */
1632 CXCursor_ObjCInterfaceDecl = 11,
1633 /** \brief An Objective-C \@interface for a category. */
1634 CXCursor_ObjCCategoryDecl = 12,
1635 /** \brief An Objective-C \@protocol declaration. */
1636 CXCursor_ObjCProtocolDecl = 13,
1637 /** \brief An Objective-C \@property declaration. */
1638 CXCursor_ObjCPropertyDecl = 14,
1639 /** \brief An Objective-C instance variable. */
1640 CXCursor_ObjCIvarDecl = 15,
1641 /** \brief An Objective-C instance method. */
1642 CXCursor_ObjCInstanceMethodDecl = 16,
1643 /** \brief An Objective-C class method. */
1644 CXCursor_ObjCClassMethodDecl = 17,
1645 /** \brief An Objective-C \@implementation. */
1646 CXCursor_ObjCImplementationDecl = 18,
1647 /** \brief An Objective-C \@implementation for a category. */
1648 CXCursor_ObjCCategoryImplDecl = 19,
1649 /** \brief A typedef. */
1650 CXCursor_TypedefDecl = 20,
1651 /** \brief A C++ class method. */
1652 CXCursor_CXXMethod = 21,
1653 /** \brief A C++ namespace. */
1654 CXCursor_Namespace = 22,
1655 /** \brief A linkage specification, e.g. 'extern "C"'. */
1656 CXCursor_LinkageSpec = 23,
1657 /** \brief A C++ constructor. */
1658 CXCursor_Constructor = 24,
1659 /** \brief A C++ destructor. */
1660 CXCursor_Destructor = 25,
1661 /** \brief A C++ conversion function. */
1662 CXCursor_ConversionFunction = 26,
1663 /** \brief A C++ template type parameter. */
1664 CXCursor_TemplateTypeParameter = 27,
1665 /** \brief A C++ non-type template parameter. */
1666 CXCursor_NonTypeTemplateParameter = 28,
1667 /** \brief A C++ template template parameter. */
1668 CXCursor_TemplateTemplateParameter = 29,
1669 /** \brief A C++ function template. */
1670 CXCursor_FunctionTemplate = 30,
1671 /** \brief A C++ class template. */
1672 CXCursor_ClassTemplate = 31,
1673 /** \brief A C++ class template partial specialization. */
1674 CXCursor_ClassTemplatePartialSpecialization = 32,
1675 /** \brief A C++ namespace alias declaration. */
1676 CXCursor_NamespaceAlias = 33,
1677 /** \brief A C++ using directive. */
1678 CXCursor_UsingDirective = 34,
1679 /** \brief A C++ using declaration. */
1680 CXCursor_UsingDeclaration = 35,
1681 /** \brief A C++ alias declaration */
1682 CXCursor_TypeAliasDecl = 36,
1683 /** \brief An Objective-C \@synthesize definition. */
1684 CXCursor_ObjCSynthesizeDecl = 37,
1685 /** \brief An Objective-C \@dynamic definition. */
1686 CXCursor_ObjCDynamicDecl = 38,
1687 /** \brief An access specifier. */
1688 CXCursor_CXXAccessSpecifier = 39,
1690 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1691 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
1694 CXCursor_FirstRef = 40, /* Decl references */
1695 CXCursor_ObjCSuperClassRef = 40,
1696 CXCursor_ObjCProtocolRef = 41,
1697 CXCursor_ObjCClassRef = 42,
1699 * \brief A reference to a type declaration.
1701 * A type reference occurs anywhere where a type is named but not
1702 * declared. For example, given:
1705 * typedef unsigned size_type;
1709 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1710 * while the type of the variable "size" is referenced. The cursor
1711 * referenced by the type of size is the typedef for size_type.
1713 CXCursor_TypeRef = 43,
1714 CXCursor_CXXBaseSpecifier = 44,
1716 * \brief A reference to a class template, function template, template
1717 * template parameter, or class template partial specialization.
1719 CXCursor_TemplateRef = 45,
1721 * \brief A reference to a namespace or namespace alias.
1723 CXCursor_NamespaceRef = 46,
1725 * \brief A reference to a member of a struct, union, or class that occurs in
1726 * some non-expression context, e.g., a designated initializer.
1728 CXCursor_MemberRef = 47,
1730 * \brief A reference to a labeled statement.
1732 * This cursor kind is used to describe the jump to "start_over" in the
1733 * goto statement in the following example:
1742 * A label reference cursor refers to a label statement.
1744 CXCursor_LabelRef = 48,
1747 * \brief A reference to a set of overloaded functions or function templates
1748 * that has not yet been resolved to a specific function or function template.
1750 * An overloaded declaration reference cursor occurs in C++ templates where
1751 * a dependent name refers to a function. For example:
1754 * template<typename T> void swap(T&, T&);
1757 * void swap(X&, X&);
1759 * template<typename T>
1760 * void reverse(T* first, T* last) {
1761 * while (first < last - 1) {
1762 * swap(*first, *--last);
1768 * void swap(Y&, Y&);
1771 * Here, the identifier "swap" is associated with an overloaded declaration
1772 * reference. In the template definition, "swap" refers to either of the two
1773 * "swap" functions declared above, so both results will be available. At
1774 * instantiation time, "swap" may also refer to other functions found via
1775 * argument-dependent lookup (e.g., the "swap" function at the end of the
1778 * The functions \c clang_getNumOverloadedDecls() and
1779 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1780 * referenced by this cursor.
1782 CXCursor_OverloadedDeclRef = 49,
1785 * \brief A reference to a variable that occurs in some non-expression
1786 * context, e.g., a C++ lambda capture list.
1788 CXCursor_VariableRef = 50,
1790 CXCursor_LastRef = CXCursor_VariableRef,
1792 /* Error conditions */
1793 CXCursor_FirstInvalid = 70,
1794 CXCursor_InvalidFile = 70,
1795 CXCursor_NoDeclFound = 71,
1796 CXCursor_NotImplemented = 72,
1797 CXCursor_InvalidCode = 73,
1798 CXCursor_LastInvalid = CXCursor_InvalidCode,
1801 CXCursor_FirstExpr = 100,
1804 * \brief An expression whose specific kind is not exposed via this
1807 * Unexposed expressions have the same operations as any other kind
1808 * of expression; one can extract their location information,
1809 * spelling, children, etc. However, the specific kind of the
1810 * expression is not reported.
1812 CXCursor_UnexposedExpr = 100,
1815 * \brief An expression that refers to some value declaration, such
1816 * as a function, variable, or enumerator.
1818 CXCursor_DeclRefExpr = 101,
1821 * \brief An expression that refers to a member of a struct, union,
1822 * class, Objective-C class, etc.
1824 CXCursor_MemberRefExpr = 102,
1826 /** \brief An expression that calls a function. */
1827 CXCursor_CallExpr = 103,
1829 /** \brief An expression that sends a message to an Objective-C
1831 CXCursor_ObjCMessageExpr = 104,
1833 /** \brief An expression that represents a block literal. */
1834 CXCursor_BlockExpr = 105,
1836 /** \brief An integer literal.
1838 CXCursor_IntegerLiteral = 106,
1840 /** \brief A floating point number literal.
1842 CXCursor_FloatingLiteral = 107,
1844 /** \brief An imaginary number literal.
1846 CXCursor_ImaginaryLiteral = 108,
1848 /** \brief A string literal.
1850 CXCursor_StringLiteral = 109,
1852 /** \brief A character literal.
1854 CXCursor_CharacterLiteral = 110,
1856 /** \brief A parenthesized expression, e.g. "(1)".
1858 * This AST node is only formed if full location information is requested.
1860 CXCursor_ParenExpr = 111,
1862 /** \brief This represents the unary-expression's (except sizeof and
1865 CXCursor_UnaryOperator = 112,
1867 /** \brief [C99 6.5.2.1] Array Subscripting.
1869 CXCursor_ArraySubscriptExpr = 113,
1871 /** \brief A builtin binary operation expression such as "x + y" or
1874 CXCursor_BinaryOperator = 114,
1876 /** \brief Compound assignment such as "+=".
1878 CXCursor_CompoundAssignOperator = 115,
1880 /** \brief The ?: ternary operator.
1882 CXCursor_ConditionalOperator = 116,
1884 /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1885 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1887 * For example: (int)f.
1889 CXCursor_CStyleCastExpr = 117,
1891 /** \brief [C99 6.5.2.5]
1893 CXCursor_CompoundLiteralExpr = 118,
1895 /** \brief Describes an C or C++ initializer list.
1897 CXCursor_InitListExpr = 119,
1899 /** \brief The GNU address of label extension, representing &&label.
1901 CXCursor_AddrLabelExpr = 120,
1903 /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1905 CXCursor_StmtExpr = 121,
1907 /** \brief Represents a C11 generic selection.
1909 CXCursor_GenericSelectionExpr = 122,
1911 /** \brief Implements the GNU __null extension, which is a name for a null
1912 * pointer constant that has integral type (e.g., int or long) and is the same
1913 * size and alignment as a pointer.
1915 * The __null extension is typically only used by system headers, which define
1916 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1917 * match the size of a pointer).
1919 CXCursor_GNUNullExpr = 123,
1921 /** \brief C++'s static_cast<> expression.
1923 CXCursor_CXXStaticCastExpr = 124,
1925 /** \brief C++'s dynamic_cast<> expression.
1927 CXCursor_CXXDynamicCastExpr = 125,
1929 /** \brief C++'s reinterpret_cast<> expression.
1931 CXCursor_CXXReinterpretCastExpr = 126,
1933 /** \brief C++'s const_cast<> expression.
1935 CXCursor_CXXConstCastExpr = 127,
1937 /** \brief Represents an explicit C++ type conversion that uses "functional"
1938 * notion (C++ [expr.type.conv]).
1945 CXCursor_CXXFunctionalCastExpr = 128,
1947 /** \brief A C++ typeid expression (C++ [expr.typeid]).
1949 CXCursor_CXXTypeidExpr = 129,
1951 /** \brief [C++ 2.13.5] C++ Boolean Literal.
1953 CXCursor_CXXBoolLiteralExpr = 130,
1955 /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1957 CXCursor_CXXNullPtrLiteralExpr = 131,
1959 /** \brief Represents the "this" expression in C++
1961 CXCursor_CXXThisExpr = 132,
1963 /** \brief [C++ 15] C++ Throw Expression.
1965 * This handles 'throw' and 'throw' assignment-expression. When
1966 * assignment-expression isn't present, Op will be null.
1968 CXCursor_CXXThrowExpr = 133,
1970 /** \brief A new expression for memory allocation and constructor calls, e.g:
1971 * "new CXXNewExpr(foo)".
1973 CXCursor_CXXNewExpr = 134,
1975 /** \brief A delete expression for memory deallocation and destructor calls,
1976 * e.g. "delete[] pArray".
1978 CXCursor_CXXDeleteExpr = 135,
1980 /** \brief A unary expression. (noexcept, sizeof, or other traits)
1982 CXCursor_UnaryExpr = 136,
1984 /** \brief An Objective-C string literal i.e. @"foo".
1986 CXCursor_ObjCStringLiteral = 137,
1988 /** \brief An Objective-C \@encode expression.
1990 CXCursor_ObjCEncodeExpr = 138,
1992 /** \brief An Objective-C \@selector expression.
1994 CXCursor_ObjCSelectorExpr = 139,
1996 /** \brief An Objective-C \@protocol expression.
1998 CXCursor_ObjCProtocolExpr = 140,
2000 /** \brief An Objective-C "bridged" cast expression, which casts between
2001 * Objective-C pointers and C pointers, transferring ownership in the process.
2004 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2007 CXCursor_ObjCBridgedCastExpr = 141,
2009 /** \brief Represents a C++0x pack expansion that produces a sequence of
2012 * A pack expansion expression contains a pattern (which itself is an
2013 * expression) followed by an ellipsis. For example:
2016 * template<typename F, typename ...Types>
2017 * void forward(F f, Types &&...args) {
2018 * f(static_cast<Types&&>(args)...);
2022 CXCursor_PackExpansionExpr = 142,
2024 /** \brief Represents an expression that computes the length of a parameter
2028 * template<typename ...Types>
2030 * static const unsigned value = sizeof...(Types);
2034 CXCursor_SizeOfPackExpr = 143,
2036 /* \brief Represents a C++ lambda expression that produces a local function
2040 * void abssort(float *x, unsigned N) {
2041 * std::sort(x, x + N,
2042 * [](float a, float b) {
2043 * return std::abs(a) < std::abs(b);
2048 CXCursor_LambdaExpr = 144,
2050 /** \brief Objective-c Boolean Literal.
2052 CXCursor_ObjCBoolLiteralExpr = 145,
2054 /** \brief Represents the "self" expression in an Objective-C method.
2056 CXCursor_ObjCSelfExpr = 146,
2058 /** \brief OpenMP 4.0 [2.4, Array Section].
2060 CXCursor_OMPArraySectionExpr = 147,
2062 /** \brief Represents an @available(...) check.
2064 CXCursor_ObjCAvailabilityCheckExpr = 148,
2066 CXCursor_LastExpr = CXCursor_ObjCAvailabilityCheckExpr,
2069 CXCursor_FirstStmt = 200,
2071 * \brief A statement whose specific kind is not exposed via this
2074 * Unexposed statements have the same operations as any other kind of
2075 * statement; one can extract their location information, spelling,
2076 * children, etc. However, the specific kind of the statement is not
2079 CXCursor_UnexposedStmt = 200,
2081 /** \brief A labelled statement in a function.
2083 * This cursor kind is used to describe the "start_over:" label statement in
2084 * the following example:
2092 CXCursor_LabelStmt = 201,
2094 /** \brief A group of statements like { stmt stmt }.
2096 * This cursor kind is used to describe compound statements, e.g. function
2099 CXCursor_CompoundStmt = 202,
2101 /** \brief A case statement.
2103 CXCursor_CaseStmt = 203,
2105 /** \brief A default statement.
2107 CXCursor_DefaultStmt = 204,
2109 /** \brief An if statement
2111 CXCursor_IfStmt = 205,
2113 /** \brief A switch statement.
2115 CXCursor_SwitchStmt = 206,
2117 /** \brief A while statement.
2119 CXCursor_WhileStmt = 207,
2121 /** \brief A do statement.
2123 CXCursor_DoStmt = 208,
2125 /** \brief A for statement.
2127 CXCursor_ForStmt = 209,
2129 /** \brief A goto statement.
2131 CXCursor_GotoStmt = 210,
2133 /** \brief An indirect goto statement.
2135 CXCursor_IndirectGotoStmt = 211,
2137 /** \brief A continue statement.
2139 CXCursor_ContinueStmt = 212,
2141 /** \brief A break statement.
2143 CXCursor_BreakStmt = 213,
2145 /** \brief A return statement.
2147 CXCursor_ReturnStmt = 214,
2149 /** \brief A GCC inline assembly statement extension.
2151 CXCursor_GCCAsmStmt = 215,
2152 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
2154 /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
2156 CXCursor_ObjCAtTryStmt = 216,
2158 /** \brief Objective-C's \@catch statement.
2160 CXCursor_ObjCAtCatchStmt = 217,
2162 /** \brief Objective-C's \@finally statement.
2164 CXCursor_ObjCAtFinallyStmt = 218,
2166 /** \brief Objective-C's \@throw statement.
2168 CXCursor_ObjCAtThrowStmt = 219,
2170 /** \brief Objective-C's \@synchronized statement.
2172 CXCursor_ObjCAtSynchronizedStmt = 220,
2174 /** \brief Objective-C's autorelease pool statement.
2176 CXCursor_ObjCAutoreleasePoolStmt = 221,
2178 /** \brief Objective-C's collection statement.
2180 CXCursor_ObjCForCollectionStmt = 222,
2182 /** \brief C++'s catch statement.
2184 CXCursor_CXXCatchStmt = 223,
2186 /** \brief C++'s try statement.
2188 CXCursor_CXXTryStmt = 224,
2190 /** \brief C++'s for (* : *) statement.
2192 CXCursor_CXXForRangeStmt = 225,
2194 /** \brief Windows Structured Exception Handling's try statement.
2196 CXCursor_SEHTryStmt = 226,
2198 /** \brief Windows Structured Exception Handling's except statement.
2200 CXCursor_SEHExceptStmt = 227,
2202 /** \brief Windows Structured Exception Handling's finally statement.
2204 CXCursor_SEHFinallyStmt = 228,
2206 /** \brief A MS inline assembly statement extension.
2208 CXCursor_MSAsmStmt = 229,
2210 /** \brief The null statement ";": C99 6.8.3p3.
2212 * This cursor kind is used to describe the null statement.
2214 CXCursor_NullStmt = 230,
2216 /** \brief Adaptor class for mixing declarations with statements and
2219 CXCursor_DeclStmt = 231,
2221 /** \brief OpenMP parallel directive.
2223 CXCursor_OMPParallelDirective = 232,
2225 /** \brief OpenMP SIMD directive.
2227 CXCursor_OMPSimdDirective = 233,
2229 /** \brief OpenMP for directive.
2231 CXCursor_OMPForDirective = 234,
2233 /** \brief OpenMP sections directive.
2235 CXCursor_OMPSectionsDirective = 235,
2237 /** \brief OpenMP section directive.
2239 CXCursor_OMPSectionDirective = 236,
2241 /** \brief OpenMP single directive.
2243 CXCursor_OMPSingleDirective = 237,
2245 /** \brief OpenMP parallel for directive.
2247 CXCursor_OMPParallelForDirective = 238,
2249 /** \brief OpenMP parallel sections directive.
2251 CXCursor_OMPParallelSectionsDirective = 239,
2253 /** \brief OpenMP task directive.
2255 CXCursor_OMPTaskDirective = 240,
2257 /** \brief OpenMP master directive.
2259 CXCursor_OMPMasterDirective = 241,
2261 /** \brief OpenMP critical directive.
2263 CXCursor_OMPCriticalDirective = 242,
2265 /** \brief OpenMP taskyield directive.
2267 CXCursor_OMPTaskyieldDirective = 243,
2269 /** \brief OpenMP barrier directive.
2271 CXCursor_OMPBarrierDirective = 244,
2273 /** \brief OpenMP taskwait directive.
2275 CXCursor_OMPTaskwaitDirective = 245,
2277 /** \brief OpenMP flush directive.
2279 CXCursor_OMPFlushDirective = 246,
2281 /** \brief Windows Structured Exception Handling's leave statement.
2283 CXCursor_SEHLeaveStmt = 247,
2285 /** \brief OpenMP ordered directive.
2287 CXCursor_OMPOrderedDirective = 248,
2289 /** \brief OpenMP atomic directive.
2291 CXCursor_OMPAtomicDirective = 249,
2293 /** \brief OpenMP for SIMD directive.
2295 CXCursor_OMPForSimdDirective = 250,
2297 /** \brief OpenMP parallel for SIMD directive.
2299 CXCursor_OMPParallelForSimdDirective = 251,
2301 /** \brief OpenMP target directive.
2303 CXCursor_OMPTargetDirective = 252,
2305 /** \brief OpenMP teams directive.
2307 CXCursor_OMPTeamsDirective = 253,
2309 /** \brief OpenMP taskgroup directive.
2311 CXCursor_OMPTaskgroupDirective = 254,
2313 /** \brief OpenMP cancellation point directive.
2315 CXCursor_OMPCancellationPointDirective = 255,
2317 /** \brief OpenMP cancel directive.
2319 CXCursor_OMPCancelDirective = 256,
2321 /** \brief OpenMP target data directive.
2323 CXCursor_OMPTargetDataDirective = 257,
2325 /** \brief OpenMP taskloop directive.
2327 CXCursor_OMPTaskLoopDirective = 258,
2329 /** \brief OpenMP taskloop simd directive.
2331 CXCursor_OMPTaskLoopSimdDirective = 259,
2333 /** \brief OpenMP distribute directive.
2335 CXCursor_OMPDistributeDirective = 260,
2337 /** \brief OpenMP target enter data directive.
2339 CXCursor_OMPTargetEnterDataDirective = 261,
2341 /** \brief OpenMP target exit data directive.
2343 CXCursor_OMPTargetExitDataDirective = 262,
2345 /** \brief OpenMP target parallel directive.
2347 CXCursor_OMPTargetParallelDirective = 263,
2349 /** \brief OpenMP target parallel for directive.
2351 CXCursor_OMPTargetParallelForDirective = 264,
2353 /** \brief OpenMP target update directive.
2355 CXCursor_OMPTargetUpdateDirective = 265,
2357 /** \brief OpenMP distribute parallel for directive.
2359 CXCursor_OMPDistributeParallelForDirective = 266,
2361 /** \brief OpenMP distribute parallel for simd directive.
2363 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2365 /** \brief OpenMP distribute simd directive.
2367 CXCursor_OMPDistributeSimdDirective = 268,
2369 /** \brief OpenMP target parallel for simd directive.
2371 CXCursor_OMPTargetParallelForSimdDirective = 269,
2373 /** \brief OpenMP target simd directive.
2375 CXCursor_OMPTargetSimdDirective = 270,
2377 /** \brief OpenMP teams distribute directive.
2379 CXCursor_OMPTeamsDistributeDirective = 271,
2381 /** \brief OpenMP teams distribute simd directive.
2383 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2385 /** \brief OpenMP teams distribute parallel for simd directive.
2387 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2389 /** \brief OpenMP teams distribute parallel for directive.
2391 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2393 /** \brief OpenMP target teams directive.
2395 CXCursor_OMPTargetTeamsDirective = 275,
2397 /** \brief OpenMP target teams distribute directive.
2399 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2401 /** \brief OpenMP target teams distribute parallel for directive.
2403 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2405 /** \brief OpenMP target teams distribute parallel for simd directive.
2407 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2409 /** \brief OpenMP target teams distribute simd directive.
2411 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2413 CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
2416 * \brief Cursor that represents the translation unit itself.
2418 * The translation unit cursor exists primarily to act as the root
2419 * cursor for traversing the contents of a translation unit.
2421 CXCursor_TranslationUnit = 300,
2424 CXCursor_FirstAttr = 400,
2426 * \brief An attribute whose specific kind is not exposed via this
2429 CXCursor_UnexposedAttr = 400,
2431 CXCursor_IBActionAttr = 401,
2432 CXCursor_IBOutletAttr = 402,
2433 CXCursor_IBOutletCollectionAttr = 403,
2434 CXCursor_CXXFinalAttr = 404,
2435 CXCursor_CXXOverrideAttr = 405,
2436 CXCursor_AnnotateAttr = 406,
2437 CXCursor_AsmLabelAttr = 407,
2438 CXCursor_PackedAttr = 408,
2439 CXCursor_PureAttr = 409,
2440 CXCursor_ConstAttr = 410,
2441 CXCursor_NoDuplicateAttr = 411,
2442 CXCursor_CUDAConstantAttr = 412,
2443 CXCursor_CUDADeviceAttr = 413,
2444 CXCursor_CUDAGlobalAttr = 414,
2445 CXCursor_CUDAHostAttr = 415,
2446 CXCursor_CUDASharedAttr = 416,
2447 CXCursor_VisibilityAttr = 417,
2448 CXCursor_DLLExport = 418,
2449 CXCursor_DLLImport = 419,
2450 CXCursor_LastAttr = CXCursor_DLLImport,
2453 CXCursor_PreprocessingDirective = 500,
2454 CXCursor_MacroDefinition = 501,
2455 CXCursor_MacroExpansion = 502,
2456 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2457 CXCursor_InclusionDirective = 503,
2458 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2459 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2461 /* Extra Declarations */
2463 * \brief A module import declaration.
2465 CXCursor_ModuleImportDecl = 600,
2466 CXCursor_TypeAliasTemplateDecl = 601,
2468 * \brief A static_assert or _Static_assert node
2470 CXCursor_StaticAssert = 602,
2472 * \brief a friend declaration.
2474 CXCursor_FriendDecl = 603,
2475 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2476 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
2479 * \brief A code completion overload candidate.
2481 CXCursor_OverloadCandidate = 700
2485 * \brief A cursor representing some element in the abstract syntax tree for
2486 * a translation unit.
2488 * The cursor abstraction unifies the different kinds of entities in a
2489 * program--declaration, statements, expressions, references to declarations,
2490 * etc.--under a single "cursor" abstraction with a common set of operations.
2491 * Common operation for a cursor include: getting the physical location in
2492 * a source file where the cursor points, getting the name associated with a
2493 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2495 * Cursors can be produced in two specific ways.
2496 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2497 * from which one can use clang_visitChildren() to explore the rest of the
2498 * translation unit. clang_getCursor() maps from a physical source location
2499 * to the entity that resides at that location, allowing one to map from the
2500 * source code into the AST.
2503 enum CXCursorKind kind;
2505 const void *data[3];
2509 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2515 * \brief Retrieve the NULL cursor, which represents no entity.
2517 CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2520 * \brief Retrieve the cursor that represents the given translation unit.
2522 * The translation unit cursor can be used to start traversing the
2523 * various declarations within the given translation unit.
2525 CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2528 * \brief Determine whether two cursors are equivalent.
2530 CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2533 * \brief Returns non-zero if \p cursor is null.
2535 CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2538 * \brief Compute a hash value for the given cursor.
2540 CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2543 * \brief Retrieve the kind of the given cursor.
2545 CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2548 * \brief Determine whether the given cursor kind represents a declaration.
2550 CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2553 * \brief Determine whether the given cursor kind represents a simple
2556 * Note that other kinds of cursors (such as expressions) can also refer to
2557 * other cursors. Use clang_getCursorReferenced() to determine whether a
2558 * particular cursor refers to another entity.
2560 CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2563 * \brief Determine whether the given cursor kind represents an expression.
2565 CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2568 * \brief Determine whether the given cursor kind represents a statement.
2570 CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2573 * \brief Determine whether the given cursor kind represents an attribute.
2575 CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2578 * \brief Determine whether the given cursor has any attributes.
2580 CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2583 * \brief Determine whether the given cursor kind represents an invalid
2586 CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2589 * \brief Determine whether the given cursor kind represents a translation
2592 CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2595 * \brief Determine whether the given cursor represents a preprocessing
2596 * element, such as a preprocessor directive or macro instantiation.
2598 CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2601 * \brief Determine whether the given cursor represents a currently
2602 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2604 CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2607 * \brief Describe the linkage of the entity referred to by a cursor.
2609 enum CXLinkageKind {
2610 /** \brief This value indicates that no linkage information is available
2611 * for a provided CXCursor. */
2614 * \brief This is the linkage for variables, parameters, and so on that
2615 * have automatic storage. This covers normal (non-extern) local variables.
2617 CXLinkage_NoLinkage,
2618 /** \brief This is the linkage for static variables and static functions. */
2620 /** \brief This is the linkage for entities with external linkage that live
2621 * in C++ anonymous namespaces.*/
2622 CXLinkage_UniqueExternal,
2623 /** \brief This is the linkage for entities with true, external linkage. */
2628 * \brief Determine the linkage of the entity referred to by a given cursor.
2630 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2632 enum CXVisibilityKind {
2633 /** \brief This value indicates that no visibility information is available
2634 * for a provided CXCursor. */
2635 CXVisibility_Invalid,
2637 /** \brief Symbol not seen by the linker. */
2638 CXVisibility_Hidden,
2639 /** \brief Symbol seen by the linker but resolves to a symbol inside this object. */
2640 CXVisibility_Protected,
2641 /** \brief Symbol seen by the linker and acts like a normal symbol. */
2642 CXVisibility_Default
2646 * \brief Describe the visibility of the entity referred to by a cursor.
2648 * This returns the default visibility if not explicitly specified by
2649 * a visibility attribute. The default visibility may be changed by
2650 * commandline arguments.
2652 * \param cursor The cursor to query.
2654 * \returns The visibility of the cursor.
2656 CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2659 * \brief Determine the availability of the entity that this cursor refers to,
2660 * taking the current target platform into account.
2662 * \param cursor The cursor to query.
2664 * \returns The availability of the cursor.
2666 CINDEX_LINKAGE enum CXAvailabilityKind
2667 clang_getCursorAvailability(CXCursor cursor);
2670 * Describes the availability of a given entity on a particular platform, e.g.,
2671 * a particular class might only be available on Mac OS 10.7 or newer.
2673 typedef struct CXPlatformAvailability {
2675 * \brief A string that describes the platform for which this structure
2676 * provides availability information.
2678 * Possible values are "ios" or "macos".
2682 * \brief The version number in which this entity was introduced.
2684 CXVersion Introduced;
2686 * \brief The version number in which this entity was deprecated (but is
2689 CXVersion Deprecated;
2691 * \brief The version number in which this entity was obsoleted, and therefore
2692 * is no longer available.
2694 CXVersion Obsoleted;
2696 * \brief Whether the entity is unconditionally unavailable on this platform.
2700 * \brief An optional message to provide to a user of this API, e.g., to
2701 * suggest replacement APIs.
2704 } CXPlatformAvailability;
2707 * \brief Determine the availability of the entity that this cursor refers to
2708 * on any platforms for which availability information is known.
2710 * \param cursor The cursor to query.
2712 * \param always_deprecated If non-NULL, will be set to indicate whether the
2713 * entity is deprecated on all platforms.
2715 * \param deprecated_message If non-NULL, will be set to the message text
2716 * provided along with the unconditional deprecation of this entity. The client
2717 * is responsible for deallocating this string.
2719 * \param always_unavailable If non-NULL, will be set to indicate whether the
2720 * entity is unavailable on all platforms.
2722 * \param unavailable_message If non-NULL, will be set to the message text
2723 * provided along with the unconditional unavailability of this entity. The
2724 * client is responsible for deallocating this string.
2726 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2727 * that will be populated with platform availability information, up to either
2728 * the number of platforms for which availability information is available (as
2729 * returned by this function) or \c availability_size, whichever is smaller.
2731 * \param availability_size The number of elements available in the
2732 * \c availability array.
2734 * \returns The number of platforms (N) for which availability information is
2735 * available (which is unrelated to \c availability_size).
2737 * Note that the client is responsible for calling
2738 * \c clang_disposeCXPlatformAvailability to free each of the
2739 * platform-availability structures returned. There are
2740 * \c min(N, availability_size) such structures.
2743 clang_getCursorPlatformAvailability(CXCursor cursor,
2744 int *always_deprecated,
2745 CXString *deprecated_message,
2746 int *always_unavailable,
2747 CXString *unavailable_message,
2748 CXPlatformAvailability *availability,
2749 int availability_size);
2752 * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2755 clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2758 * \brief Describe the "language" of the entity referred to by a cursor.
2760 enum CXLanguageKind {
2761 CXLanguage_Invalid = 0,
2764 CXLanguage_CPlusPlus
2768 * \brief Determine the "language" of the entity referred to by a given cursor.
2770 CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2773 * \brief Returns the translation unit that a cursor originated from.
2775 CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2778 * \brief A fast container representing a set of CXCursors.
2780 typedef struct CXCursorSetImpl *CXCursorSet;
2783 * \brief Creates an empty CXCursorSet.
2785 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2788 * \brief Disposes a CXCursorSet and releases its associated memory.
2790 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2793 * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2795 * \returns non-zero if the set contains the specified cursor.
2797 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2801 * \brief Inserts a CXCursor into a CXCursorSet.
2803 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2805 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2809 * \brief Determine the semantic parent of the given cursor.
2811 * The semantic parent of a cursor is the cursor that semantically contains
2812 * the given \p cursor. For many declarations, the lexical and semantic parents
2813 * are equivalent (the lexical parent is returned by
2814 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2815 * definitions are provided out-of-line. For example:
2825 * In the out-of-line definition of \c C::f, the semantic parent is
2826 * the class \c C, of which this function is a member. The lexical parent is
2827 * the place where the declaration actually occurs in the source code; in this
2828 * case, the definition occurs in the translation unit. In general, the
2829 * lexical parent for a given entity can change without affecting the semantics
2830 * of the program, and the lexical parent of different declarations of the
2831 * same entity may be different. Changing the semantic parent of a declaration,
2832 * on the other hand, can have a major impact on semantics, and redeclarations
2833 * of a particular entity should all have the same semantic context.
2835 * In the example above, both declarations of \c C::f have \c C as their
2836 * semantic context, while the lexical context of the first \c C::f is \c C
2837 * and the lexical context of the second \c C::f is the translation unit.
2839 * For global declarations, the semantic parent is the translation unit.
2841 CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2844 * \brief Determine the lexical parent of the given cursor.
2846 * The lexical parent of a cursor is the cursor in which the given \p cursor
2847 * was actually written. For many declarations, the lexical and semantic parents
2848 * are equivalent (the semantic parent is returned by
2849 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2850 * definitions are provided out-of-line. For example:
2860 * In the out-of-line definition of \c C::f, the semantic parent is
2861 * the class \c C, of which this function is a member. The lexical parent is
2862 * the place where the declaration actually occurs in the source code; in this
2863 * case, the definition occurs in the translation unit. In general, the
2864 * lexical parent for a given entity can change without affecting the semantics
2865 * of the program, and the lexical parent of different declarations of the
2866 * same entity may be different. Changing the semantic parent of a declaration,
2867 * on the other hand, can have a major impact on semantics, and redeclarations
2868 * of a particular entity should all have the same semantic context.
2870 * In the example above, both declarations of \c C::f have \c C as their
2871 * semantic context, while the lexical context of the first \c C::f is \c C
2872 * and the lexical context of the second \c C::f is the translation unit.
2874 * For declarations written in the global scope, the lexical parent is
2875 * the translation unit.
2877 CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2880 * \brief Determine the set of methods that are overridden by the given
2883 * In both Objective-C and C++, a method (aka virtual member function,
2884 * in C++) can override a virtual method in a base class. For
2885 * Objective-C, a method is said to override any method in the class's
2886 * base class, its protocols, or its categories' protocols, that has the same
2887 * selector and is of the same kind (class or instance).
2888 * If no such method exists, the search continues to the class's superclass,
2889 * its protocols, and its categories, and so on. A method from an Objective-C
2890 * implementation is considered to override the same methods as its
2891 * corresponding method in the interface.
2893 * For C++, a virtual member function overrides any virtual member
2894 * function with the same signature that occurs in its base
2895 * classes. With multiple inheritance, a virtual member function can
2896 * override several virtual member functions coming from different
2899 * In all cases, this function determines the immediate overridden
2900 * method, rather than all of the overridden methods. For example, if
2901 * a method is originally declared in a class A, then overridden in B
2902 * (which in inherits from A) and also in C (which inherited from B),
2903 * then the only overridden method returned from this function when
2904 * invoked on C's method will be B's method. The client may then
2905 * invoke this function again, given the previously-found overridden
2906 * methods, to map out the complete method-override set.
2908 * \param cursor A cursor representing an Objective-C or C++
2909 * method. This routine will compute the set of methods that this
2912 * \param overridden A pointer whose pointee will be replaced with a
2913 * pointer to an array of cursors, representing the set of overridden
2914 * methods. If there are no overridden methods, the pointee will be
2915 * set to NULL. The pointee must be freed via a call to
2916 * \c clang_disposeOverriddenCursors().
2918 * \param num_overridden A pointer to the number of overridden
2919 * functions, will be set to the number of overridden functions in the
2920 * array pointed to by \p overridden.
2922 CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2923 CXCursor **overridden,
2924 unsigned *num_overridden);
2927 * \brief Free the set of overridden cursors returned by \c
2928 * clang_getOverriddenCursors().
2930 CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2933 * \brief Retrieve the file that is included by the given inclusion directive
2936 CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2943 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2945 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2946 * routines help map between cursors and the physical locations where the
2947 * described entities occur in the source code. The mapping is provided in
2948 * both directions, so one can map from source code to the AST and back.
2954 * \brief Map a source location to the cursor that describes the entity at that
2955 * location in the source code.
2957 * clang_getCursor() maps an arbitrary source location within a translation
2958 * unit down to the most specific cursor that describes the entity at that
2959 * location. For example, given an expression \c x + y, invoking
2960 * clang_getCursor() with a source location pointing to "x" will return the
2961 * cursor for "x"; similarly for "y". If the cursor points anywhere between
2962 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2963 * will return a cursor referring to the "+" expression.
2965 * \returns a cursor representing the entity at the given source location, or
2966 * a NULL cursor if no such entity can be found.
2968 CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2971 * \brief Retrieve the physical location of the source constructor referenced
2972 * by the given cursor.
2974 * The location of a declaration is typically the location of the name of that
2975 * declaration, where the name of that declaration would occur if it is
2976 * unnamed, or some keyword that introduces that particular declaration.
2977 * The location of a reference is where that reference occurs within the
2980 CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2983 * \brief Retrieve the physical extent of the source construct referenced by
2986 * The extent of a cursor starts with the file/line/column pointing at the
2987 * first character within the source construct that the cursor refers to and
2988 * ends with the last character within that source construct. For a
2989 * declaration, the extent covers the declaration itself. For a reference,
2990 * the extent covers the location of the reference (e.g., where the referenced
2991 * entity was actually used).
2993 CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
3000 * \defgroup CINDEX_TYPES Type information for CXCursors
3006 * \brief Describes the kind of type
3010 * \brief Represents an invalid type (e.g., where no type is available).
3015 * \brief A type whose specific kind is not exposed via this
3018 CXType_Unexposed = 1,
3030 CXType_ULongLong = 11,
3031 CXType_UInt128 = 12,
3038 CXType_LongLong = 19,
3042 CXType_LongDouble = 23,
3043 CXType_NullPtr = 24,
3044 CXType_Overload = 25,
3045 CXType_Dependent = 26,
3047 CXType_ObjCClass = 28,
3048 CXType_ObjCSel = 29,
3049 CXType_Float128 = 30,
3051 CXType_FirstBuiltin = CXType_Void,
3052 CXType_LastBuiltin = CXType_Half,
3054 CXType_Complex = 100,
3055 CXType_Pointer = 101,
3056 CXType_BlockPointer = 102,
3057 CXType_LValueReference = 103,
3058 CXType_RValueReference = 104,
3059 CXType_Record = 105,
3061 CXType_Typedef = 107,
3062 CXType_ObjCInterface = 108,
3063 CXType_ObjCObjectPointer = 109,
3064 CXType_FunctionNoProto = 110,
3065 CXType_FunctionProto = 111,
3066 CXType_ConstantArray = 112,
3067 CXType_Vector = 113,
3068 CXType_IncompleteArray = 114,
3069 CXType_VariableArray = 115,
3070 CXType_DependentSizedArray = 116,
3071 CXType_MemberPointer = 117,
3075 * \brief Represents a type that was referred to using an elaborated type keyword.
3077 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3079 CXType_Elaborated = 119
3083 * \brief Describes the calling convention of a function type
3085 enum CXCallingConv {
3086 CXCallingConv_Default = 0,
3087 CXCallingConv_C = 1,
3088 CXCallingConv_X86StdCall = 2,
3089 CXCallingConv_X86FastCall = 3,
3090 CXCallingConv_X86ThisCall = 4,
3091 CXCallingConv_X86Pascal = 5,
3092 CXCallingConv_AAPCS = 6,
3093 CXCallingConv_AAPCS_VFP = 7,
3094 CXCallingConv_X86RegCall = 8,
3095 CXCallingConv_IntelOclBicc = 9,
3096 CXCallingConv_X86_64Win64 = 10,
3097 CXCallingConv_X86_64SysV = 11,
3098 CXCallingConv_X86VectorCall = 12,
3099 CXCallingConv_Swift = 13,
3100 CXCallingConv_PreserveMost = 14,
3101 CXCallingConv_PreserveAll = 15,
3103 CXCallingConv_Invalid = 100,
3104 CXCallingConv_Unexposed = 200
3108 * \brief The type of an element in the abstract syntax tree.
3112 enum CXTypeKind kind;
3117 * \brief Retrieve the type of a CXCursor (if any).
3119 CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3122 * \brief Pretty-print the underlying type using the rules of the
3123 * language of the translation unit from which it came.
3125 * If the type is invalid, an empty string is returned.
3127 CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3130 * \brief Retrieve the underlying type of a typedef declaration.
3132 * If the cursor does not reference a typedef declaration, an invalid type is
3135 CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3138 * \brief Retrieve the integer type of an enum declaration.
3140 * If the cursor does not reference an enum declaration, an invalid type is
3143 CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3146 * \brief Retrieve the integer value of an enum constant declaration as a signed
3149 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3150 * Since this is also potentially a valid constant value, the kind of the cursor
3151 * must be verified before calling this function.
3153 CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3156 * \brief Retrieve the integer value of an enum constant declaration as an unsigned
3159 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3160 * Since this is also potentially a valid constant value, the kind of the cursor
3161 * must be verified before calling this function.
3163 CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3166 * \brief Retrieve the bit width of a bit field declaration as an integer.
3168 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3170 CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3173 * \brief Retrieve the number of non-variadic arguments associated with a given
3176 * The number of arguments can be determined for calls as well as for
3177 * declarations of functions or methods. For other cursors -1 is returned.
3179 CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3182 * \brief Retrieve the argument cursor of a function or method.
3184 * The argument cursor can be determined for calls as well as for declarations
3185 * of functions or methods. For other cursors and for invalid indices, an
3186 * invalid cursor is returned.
3188 CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3191 * \brief Describes the kind of a template argument.
3193 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3194 * element descriptions.
3196 enum CXTemplateArgumentKind {
3197 CXTemplateArgumentKind_Null,
3198 CXTemplateArgumentKind_Type,
3199 CXTemplateArgumentKind_Declaration,
3200 CXTemplateArgumentKind_NullPtr,
3201 CXTemplateArgumentKind_Integral,
3202 CXTemplateArgumentKind_Template,
3203 CXTemplateArgumentKind_TemplateExpansion,
3204 CXTemplateArgumentKind_Expression,
3205 CXTemplateArgumentKind_Pack,
3206 /* Indicates an error case, preventing the kind from being deduced. */
3207 CXTemplateArgumentKind_Invalid
3211 *\brief Returns the number of template args of a function decl representing a
3212 * template specialization.
3214 * If the argument cursor cannot be converted into a template function
3215 * declaration, -1 is returned.
3217 * For example, for the following declaration and specialization:
3218 * template <typename T, int kInt, bool kBool>
3219 * void foo() { ... }
3222 * void foo<float, -7, true>();
3224 * The value 3 would be returned from this call.
3226 CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3229 * \brief Retrieve the kind of the I'th template argument of the CXCursor C.
3231 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3232 * template argument kind is returned.
3234 * For example, for the following declaration and specialization:
3235 * template <typename T, int kInt, bool kBool>
3236 * void foo() { ... }
3239 * void foo<float, -7, true>();
3241 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3244 CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3245 CXCursor C, unsigned I);
3248 * \brief Retrieve a CXType representing the type of a TemplateArgument of a
3249 * function decl representing a template specialization.
3251 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3252 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3255 * For example, for the following declaration and specialization:
3256 * template <typename T, int kInt, bool kBool>
3257 * void foo() { ... }
3260 * void foo<float, -7, true>();
3262 * If called with I = 0, "float", will be returned.
3263 * Invalid types will be returned for I == 1 or 2.
3265 CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3269 * \brief Retrieve the value of an Integral TemplateArgument (of a function
3270 * decl representing a template specialization) as a signed long long.
3272 * It is undefined to call this function on a CXCursor that does not represent a
3273 * FunctionDecl or whose I'th template argument is not an integral value.
3275 * For example, for the following declaration and specialization:
3276 * template <typename T, int kInt, bool kBool>
3277 * void foo() { ... }
3280 * void foo<float, -7, true>();
3282 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3283 * For I == 0, this function's behavior is undefined.
3285 CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3289 * \brief Retrieve the value of an Integral TemplateArgument (of a function
3290 * decl representing a template specialization) as an unsigned long long.
3292 * It is undefined to call this function on a CXCursor that does not represent a
3293 * FunctionDecl or whose I'th template argument is not an integral value.
3295 * For example, for the following declaration and specialization:
3296 * template <typename T, int kInt, bool kBool>
3297 * void foo() { ... }
3300 * void foo<float, 2147483649, true>();
3302 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3303 * For I == 0, this function's behavior is undefined.
3305 CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3306 CXCursor C, unsigned I);
3309 * \brief Determine whether two CXTypes represent the same type.
3311 * \returns non-zero if the CXTypes represent the same type and
3314 CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3317 * \brief Return the canonical type for a CXType.
3319 * Clang's type system explicitly models typedefs and all the ways
3320 * a specific type can be represented. The canonical type is the underlying
3321 * type with all the "sugar" removed. For example, if 'T' is a typedef
3322 * for 'int', the canonical type for 'T' would be 'int'.
3324 CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3327 * \brief Determine whether a CXType has the "const" qualifier set,
3328 * without looking through typedefs that may have added "const" at a
3331 CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3334 * \brief Determine whether a CXCursor that is a macro, is
3337 CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3340 * \brief Determine whether a CXCursor that is a macro, is a
3343 CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3346 * \brief Determine whether a CXCursor that is a function declaration, is an
3347 * inline declaration.
3349 CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3352 * \brief Determine whether a CXType has the "volatile" qualifier set,
3353 * without looking through typedefs that may have added "volatile" at
3354 * a different level.
3356 CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3359 * \brief Determine whether a CXType has the "restrict" qualifier set,
3360 * without looking through typedefs that may have added "restrict" at a
3363 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3366 * \brief For pointer types, returns the type of the pointee.
3368 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3371 * \brief Return the cursor for the declaration of the given type.
3373 CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3376 * Returns the Objective-C type encoding for the specified declaration.
3378 CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3381 * Returns the Objective-C type encoding for the specified CXType.
3383 CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3386 * \brief Retrieve the spelling of a given CXTypeKind.
3388 CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3391 * \brief Retrieve the calling convention associated with a function type.
3393 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3395 CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3398 * \brief Retrieve the return type associated with a function type.
3400 * If a non-function type is passed in, an invalid type is returned.
3402 CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3405 * \brief Retrieve the number of non-variadic parameters associated with a
3408 * If a non-function type is passed in, -1 is returned.
3410 CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3413 * \brief Retrieve the type of a parameter of a function type.
3415 * If a non-function type is passed in or the function does not have enough
3416 * parameters, an invalid type is returned.
3418 CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3421 * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
3423 CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3426 * \brief Retrieve the return type associated with a given cursor.
3428 * This only returns a valid type if the cursor refers to a function or method.
3430 CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3433 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
3436 CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3439 * \brief Return the element type of an array, complex, or vector type.
3441 * If a type is passed in that is not an array, complex, or vector type,
3442 * an invalid type is returned.
3444 CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3447 * \brief Return the number of elements of an array or vector type.
3449 * If a type is passed in that is not an array or vector type,
3452 CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3455 * \brief Return the element type of an array type.
3457 * If a non-array type is passed in, an invalid type is returned.
3459 CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3462 * \brief Return the array size of a constant array.
3464 * If a non-array type is passed in, -1 is returned.
3466 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3469 * \brief Retrieve the type named by the qualified-id.
3471 * If a non-elaborated type is passed in, an invalid type is returned.
3473 CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3476 * \brief Determine if a typedef is 'transparent' tag.
3478 * A typedef is considered 'transparent' if it shares a name and spelling
3479 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3481 * \returns non-zero if transparent and zero otherwise.
3483 CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3486 * \brief List the possible error codes for \c clang_Type_getSizeOf,
3487 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3488 * \c clang_Cursor_getOffsetOf.
3490 * A value of this enumeration type can be returned if the target type is not
3491 * a valid argument to sizeof, alignof or offsetof.
3493 enum CXTypeLayoutError {
3495 * \brief Type is of kind CXType_Invalid.
3497 CXTypeLayoutError_Invalid = -1,
3499 * \brief The type is an incomplete Type.
3501 CXTypeLayoutError_Incomplete = -2,
3503 * \brief The type is a dependent Type.
3505 CXTypeLayoutError_Dependent = -3,
3507 * \brief The type is not a constant size type.
3509 CXTypeLayoutError_NotConstantSize = -4,
3511 * \brief The Field name is not valid for this record.
3513 CXTypeLayoutError_InvalidFieldName = -5
3517 * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
3520 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3521 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3523 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3525 * If the type declaration is not a constant size type,
3526 * CXTypeLayoutError_NotConstantSize is returned.
3528 CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3531 * \brief Return the class type of an member pointer type.
3533 * If a non-member-pointer type is passed in, an invalid type is returned.
3535 CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3538 * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
3540 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3541 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3543 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3546 CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3549 * \brief Return the offset of a field named S in a record of type T in bits
3550 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3552 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3554 * If the field's type declaration is an incomplete type,
3555 * CXTypeLayoutError_Incomplete is returned.
3556 * If the field's type declaration is a dependent type,
3557 * CXTypeLayoutError_Dependent is returned.
3558 * If the field's name S is not found,
3559 * CXTypeLayoutError_InvalidFieldName is returned.
3561 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3564 * \brief Return the offset of the field represented by the Cursor.
3566 * If the cursor is not a field declaration, -1 is returned.
3567 * If the cursor semantic parent is not a record field declaration,
3568 * CXTypeLayoutError_Invalid is returned.
3569 * If the field's type declaration is an incomplete type,
3570 * CXTypeLayoutError_Incomplete is returned.
3571 * If the field's type declaration is a dependent type,
3572 * CXTypeLayoutError_Dependent is returned.
3573 * If the field's name S is not found,
3574 * CXTypeLayoutError_InvalidFieldName is returned.
3576 CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3579 * \brief Determine whether the given cursor represents an anonymous record
3582 CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3584 enum CXRefQualifierKind {
3585 /** \brief No ref-qualifier was provided. */
3586 CXRefQualifier_None = 0,
3587 /** \brief An lvalue ref-qualifier was provided (\c &). */
3588 CXRefQualifier_LValue,
3589 /** \brief An rvalue ref-qualifier was provided (\c &&). */
3590 CXRefQualifier_RValue
3594 * \brief Returns the number of template arguments for given template
3595 * specialization, or -1 if type \c T is not a template specialization.
3597 CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3600 * \brief Returns the type template argument of a template class specialization
3603 * This function only returns template type arguments and does not handle
3604 * template template arguments or variadic packs.
3606 CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
3609 * \brief Retrieve the ref-qualifier kind of a function or method.
3611 * The ref-qualifier is returned for C++ functions or methods. For other types
3612 * or non-C++ declarations, CXRefQualifier_None is returned.
3614 CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3617 * \brief Returns non-zero if the cursor specifies a Record member that is a
3620 CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3623 * \brief Returns 1 if the base class specified by the cursor with kind
3624 * CX_CXXBaseSpecifier is virtual.
3626 CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3629 * \brief Represents the C++ access control level to a base class for a
3630 * cursor with kind CX_CXXBaseSpecifier.
3632 enum CX_CXXAccessSpecifier {
3633 CX_CXXInvalidAccessSpecifier,
3640 * \brief Returns the access control level for the referenced object.
3642 * If the cursor refers to a C++ declaration, its access control level within its
3643 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3644 * access specifier, the specifier itself is returned.
3646 CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3649 * \brief Represents the storage classes as declared in the source. CX_SC_Invalid
3650 * was added for the case that the passed cursor in not a declaration.
3652 enum CX_StorageClass {
3657 CX_SC_PrivateExtern,
3658 CX_SC_OpenCLWorkGroupLocal,
3664 * \brief Returns the storage class for a function or variable declaration.
3666 * If the passed in Cursor is not a function or variable declaration,
3667 * CX_SC_Invalid is returned else the storage class.
3669 CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
3672 * \brief Determine the number of overloaded declarations referenced by a
3673 * \c CXCursor_OverloadedDeclRef cursor.
3675 * \param cursor The cursor whose overloaded declarations are being queried.
3677 * \returns The number of overloaded declarations referenced by \c cursor. If it
3678 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3680 CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3683 * \brief Retrieve a cursor for one of the overloaded declarations referenced
3684 * by a \c CXCursor_OverloadedDeclRef cursor.
3686 * \param cursor The cursor whose overloaded declarations are being queried.
3688 * \param index The zero-based index into the set of overloaded declarations in
3691 * \returns A cursor representing the declaration referenced by the given
3692 * \c cursor at the specified \c index. If the cursor does not have an
3693 * associated set of overloaded declarations, or if the index is out of bounds,
3694 * returns \c clang_getNullCursor();
3696 CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3704 * \defgroup CINDEX_ATTRIBUTES Information for attributes
3710 * \brief For cursors representing an iboutletcollection attribute,
3711 * this function returns the collection element type.
3714 CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3721 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3723 * These routines provide the ability to traverse the abstract syntax tree
3730 * \brief Describes how the traversal of the children of a particular
3731 * cursor should proceed after visiting a particular child cursor.
3733 * A value of this enumeration type should be returned by each
3734 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3736 enum CXChildVisitResult {
3738 * \brief Terminates the cursor traversal.
3742 * \brief Continues the cursor traversal with the next sibling of
3743 * the cursor just visited, without visiting its children.
3745 CXChildVisit_Continue,
3747 * \brief Recursively traverse the children of this cursor, using
3748 * the same visitor and client data.
3750 CXChildVisit_Recurse
3754 * \brief Visitor invoked for each cursor found by a traversal.
3756 * This visitor function will be invoked for each cursor found by
3757 * clang_visitCursorChildren(). Its first argument is the cursor being
3758 * visited, its second argument is the parent visitor for that cursor,
3759 * and its third argument is the client data provided to
3760 * clang_visitCursorChildren().
3762 * The visitor should return one of the \c CXChildVisitResult values
3763 * to direct clang_visitCursorChildren().
3765 typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3767 CXClientData client_data);
3770 * \brief Visit the children of a particular cursor.
3772 * This function visits all the direct children of the given cursor,
3773 * invoking the given \p visitor function with the cursors of each
3774 * visited child. The traversal may be recursive, if the visitor returns
3775 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3776 * the visitor returns \c CXChildVisit_Break.
3778 * \param parent the cursor whose child may be visited. All kinds of
3779 * cursors can be visited, including invalid cursors (which, by
3780 * definition, have no children).
3782 * \param visitor the visitor function that will be invoked for each
3783 * child of \p parent.
3785 * \param client_data pointer data supplied by the client, which will
3786 * be passed to the visitor each time it is invoked.
3788 * \returns a non-zero value if the traversal was terminated
3789 * prematurely by the visitor returning \c CXChildVisit_Break.
3791 CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
3792 CXCursorVisitor visitor,
3793 CXClientData client_data);
3794 #ifdef __has_feature
3795 # if __has_feature(blocks)
3797 * \brief Visitor invoked for each cursor found by a traversal.
3799 * This visitor block will be invoked for each cursor found by
3800 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3801 * visited, its second argument is the parent visitor for that cursor.
3803 * The visitor should return one of the \c CXChildVisitResult values
3804 * to direct clang_visitChildrenWithBlock().
3806 typedef enum CXChildVisitResult
3807 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3810 * Visits the children of a cursor using the specified block. Behaves
3811 * identically to clang_visitChildren() in all other respects.
3813 CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
3814 CXCursorVisitorBlock block);
3823 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3825 * These routines provide the ability to determine references within and
3826 * across translation units, by providing the names of the entities referenced
3827 * by cursors, follow reference cursors to the declarations they reference,
3828 * and associate declarations with their definitions.
3834 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3835 * by the given cursor.
3837 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3838 * entity (function, class, variable, etc.) within a program. USRs can be
3839 * compared across translation units to determine, e.g., when references in
3840 * one translation refer to an entity defined in another translation unit.
3842 CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3845 * \brief Construct a USR for a specified Objective-C class.
3847 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3850 * \brief Construct a USR for a specified Objective-C category.
3852 CINDEX_LINKAGE CXString
3853 clang_constructUSR_ObjCCategory(const char *class_name,
3854 const char *category_name);
3857 * \brief Construct a USR for a specified Objective-C protocol.
3859 CINDEX_LINKAGE CXString
3860 clang_constructUSR_ObjCProtocol(const char *protocol_name);
3863 * \brief Construct a USR for a specified Objective-C instance variable and
3864 * the USR for its containing class.
3866 CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3870 * \brief Construct a USR for a specified Objective-C method and
3871 * the USR for its containing class.
3873 CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3874 unsigned isInstanceMethod,
3878 * \brief Construct a USR for a specified Objective-C property and the USR
3879 * for its containing class.
3881 CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3885 * \brief Retrieve a name for the entity referenced by this cursor.
3887 CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3890 * \brief Retrieve a range for a piece that forms the cursors spelling name.
3891 * Most of the times there is only one range for the complete spelling but for
3892 * Objective-C methods and Objective-C message expressions, there are multiple
3893 * pieces for each selector identifier.
3895 * \param pieceIndex the index of the spelling name piece. If this is greater
3896 * than the actual number of pieces, it will return a NULL (invalid) range.
3898 * \param options Reserved.
3900 CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
3901 unsigned pieceIndex,
3905 * \brief Retrieve the display name for the entity referenced by this cursor.
3907 * The display name contains extra information that helps identify the cursor,
3908 * such as the parameters of a function or template or the arguments of a
3909 * class template specialization.
3911 CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
3913 /** \brief For a cursor that is a reference, retrieve a cursor representing the
3914 * entity that it references.
3916 * Reference cursors refer to other entities in the AST. For example, an
3917 * Objective-C superclass reference cursor refers to an Objective-C class.
3918 * This function produces the cursor for the Objective-C class from the
3919 * cursor for the superclass reference. If the input cursor is a declaration or
3920 * definition, it returns that declaration or definition unchanged.
3921 * Otherwise, returns the NULL cursor.
3923 CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
3926 * \brief For a cursor that is either a reference to or a declaration
3927 * of some entity, retrieve a cursor that describes the definition of
3930 * Some entities can be declared multiple times within a translation
3931 * unit, but only one of those declarations can also be a
3932 * definition. For example, given:
3936 * int g(int x, int y) { return f(x, y); }
3937 * int f(int a, int b) { return a + b; }
3941 * there are three declarations of the function "f", but only the
3942 * second one is a definition. The clang_getCursorDefinition()
3943 * function will take any cursor pointing to a declaration of "f"
3944 * (the first or fourth lines of the example) or a cursor referenced
3945 * that uses "f" (the call to "f' inside "g") and will return a
3946 * declaration cursor pointing to the definition (the second "f"
3949 * If given a cursor for which there is no corresponding definition,
3950 * e.g., because there is no definition of that entity within this
3951 * translation unit, returns a NULL cursor.
3953 CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
3956 * \brief Determine whether the declaration pointed to by this cursor
3957 * is also a definition of that entity.
3959 CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
3962 * \brief Retrieve the canonical cursor corresponding to the given cursor.
3964 * In the C family of languages, many kinds of entities can be declared several
3965 * times within a single translation unit. For example, a structure type can
3966 * be forward-declared (possibly multiple times) and later defined:
3976 * The declarations and the definition of \c X are represented by three
3977 * different cursors, all of which are declarations of the same underlying
3978 * entity. One of these cursor is considered the "canonical" cursor, which
3979 * is effectively the representative for the underlying entity. One can
3980 * determine if two cursors are declarations of the same underlying entity by
3981 * comparing their canonical cursors.
3983 * \returns The canonical cursor for the entity referred to by the given cursor.
3985 CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
3988 * \brief If the cursor points to a selector identifier in an Objective-C
3989 * method or message expression, this returns the selector index.
3991 * After getting a cursor with #clang_getCursor, this can be called to
3992 * determine if the location points to a selector identifier.
3994 * \returns The selector index if the cursor is an Objective-C method or message
3995 * expression and the cursor is pointing to a selector identifier, or -1
3998 CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4001 * \brief Given a cursor pointing to a C++ method call or an Objective-C
4002 * message, returns non-zero if the method/message is "dynamic", meaning:
4004 * For a C++ method: the call is virtual.
4005 * For an Objective-C message: the receiver is an object instance, not 'super'
4006 * or a specific class.
4008 * If the method/message is "static" or the cursor does not point to a
4009 * method/message, it will return zero.
4011 CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4014 * \brief Given a cursor pointing to an Objective-C message or property
4015 * reference, or C++ method call, returns the CXType of the receiver.
4017 CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4020 * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
4023 CXObjCPropertyAttr_noattr = 0x00,
4024 CXObjCPropertyAttr_readonly = 0x01,
4025 CXObjCPropertyAttr_getter = 0x02,
4026 CXObjCPropertyAttr_assign = 0x04,
4027 CXObjCPropertyAttr_readwrite = 0x08,
4028 CXObjCPropertyAttr_retain = 0x10,
4029 CXObjCPropertyAttr_copy = 0x20,
4030 CXObjCPropertyAttr_nonatomic = 0x40,
4031 CXObjCPropertyAttr_setter = 0x80,
4032 CXObjCPropertyAttr_atomic = 0x100,
4033 CXObjCPropertyAttr_weak = 0x200,
4034 CXObjCPropertyAttr_strong = 0x400,
4035 CXObjCPropertyAttr_unsafe_unretained = 0x800,
4036 CXObjCPropertyAttr_class = 0x1000
4037 } CXObjCPropertyAttrKind;
4040 * \brief Given a cursor that represents a property declaration, return the
4041 * associated property attributes. The bits are formed from
4042 * \c CXObjCPropertyAttrKind.
4044 * \param reserved Reserved for future use, pass 0.
4046 CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4050 * \brief 'Qualifiers' written next to the return and parameter types in
4051 * Objective-C method declarations.
4054 CXObjCDeclQualifier_None = 0x0,
4055 CXObjCDeclQualifier_In = 0x1,
4056 CXObjCDeclQualifier_Inout = 0x2,
4057 CXObjCDeclQualifier_Out = 0x4,
4058 CXObjCDeclQualifier_Bycopy = 0x8,
4059 CXObjCDeclQualifier_Byref = 0x10,
4060 CXObjCDeclQualifier_Oneway = 0x20
4061 } CXObjCDeclQualifierKind;
4064 * \brief Given a cursor that represents an Objective-C method or parameter
4065 * declaration, return the associated Objective-C qualifiers for the return
4066 * type or the parameter respectively. The bits are formed from
4067 * CXObjCDeclQualifierKind.
4069 CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4072 * \brief Given a cursor that represents an Objective-C method or property
4073 * declaration, return non-zero if the declaration was affected by "\@optional".
4074 * Returns zero if the cursor is not such a declaration or it is "\@required".
4076 CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4079 * \brief Returns non-zero if the given cursor is a variadic function or method.
4081 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4084 * \brief Given a cursor that represents a declaration, return the associated
4085 * comment's source range. The range may include multiple consecutive comments
4086 * with whitespace in between.
4088 CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4091 * \brief Given a cursor that represents a declaration, return the associated
4092 * comment text, including comment markers.
4094 CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4097 * \brief Given a cursor that represents a documentable entity (e.g.,
4098 * declaration), return the associated \\brief paragraph; otherwise return the
4101 CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4107 /** \defgroup CINDEX_MANGLE Name Mangling API Functions
4113 * \brief Retrieve the CXString representing the mangled name of the cursor.
4115 CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4118 * \brief Retrieve the CXStrings representing the mangled symbols of the C++
4119 * constructor or destructor at the cursor.
4121 CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4128 * \defgroup CINDEX_MODULE Module introspection
4130 * The functions in this group provide access to information about modules.
4135 typedef void *CXModule;
4138 * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4140 CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4143 * \brief Given a CXFile header file, return the module that contains it, if one
4146 CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4149 * \param Module a module object.
4151 * \returns the module file where the provided module object came from.
4153 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4156 * \param Module a module object.
4158 * \returns the parent of a sub-module or NULL if the given module is top-level,
4159 * e.g. for 'std.vector' it will return the 'std' module.
4161 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4164 * \param Module a module object.
4166 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4167 * will return "vector".
4169 CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4172 * \param Module a module object.
4174 * \returns the full name of the module, e.g. "std.vector".
4176 CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4179 * \param Module a module object.
4181 * \returns non-zero if the module is a system one.
4183 CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4186 * \param Module a module object.
4188 * \returns the number of top level headers associated with this module.
4190 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4194 * \param Module a module object.
4196 * \param Index top level header index (zero-based).
4198 * \returns the specified top level header associated with the module.
4201 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4202 CXModule Module, unsigned Index);
4209 * \defgroup CINDEX_CPP C++ AST introspection
4211 * The routines in this group provide access information in the ASTs specific
4212 * to C++ language features.
4218 * \brief Determine if a C++ constructor is a converting constructor.
4220 CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4223 * \brief Determine if a C++ constructor is a copy constructor.
4225 CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4228 * \brief Determine if a C++ constructor is the default constructor.
4230 CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4233 * \brief Determine if a C++ constructor is a move constructor.
4235 CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4238 * \brief Determine if a C++ field is declared 'mutable'.
4240 CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4243 * \brief Determine if a C++ method is declared '= default'.
4245 CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4248 * \brief Determine if a C++ member function or member function template is
4251 CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4254 * \brief Determine if a C++ member function or member function template is
4255 * declared 'static'.
4257 CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4260 * \brief Determine if a C++ member function or member function template is
4261 * explicitly declared 'virtual' or if it overrides a virtual method from
4262 * one of the base classes.
4264 CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4267 * \brief Determine if a C++ member function or member function template is
4270 CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4273 * \brief Given a cursor that represents a template, determine
4274 * the cursor kind of the specializations would be generated by instantiating
4277 * This routine can be used to determine what flavor of function template,
4278 * class template, or class template partial specialization is stored in the
4279 * cursor. For example, it can describe whether a class template cursor is
4280 * declared with "struct", "class" or "union".
4282 * \param C The cursor to query. This cursor should represent a template
4285 * \returns The cursor kind of the specializations that would be generated
4286 * by instantiating the template \p C. If \p C is not a template, returns
4287 * \c CXCursor_NoDeclFound.
4289 CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4292 * \brief Given a cursor that may represent a specialization or instantiation
4293 * of a template, retrieve the cursor that represents the template that it
4294 * specializes or from which it was instantiated.
4296 * This routine determines the template involved both for explicit
4297 * specializations of templates and for implicit instantiations of the template,
4298 * both of which are referred to as "specializations". For a class template
4299 * specialization (e.g., \c std::vector<bool>), this routine will return
4300 * either the primary template (\c std::vector) or, if the specialization was
4301 * instantiated from a class template partial specialization, the class template
4302 * partial specialization. For a class template partial specialization and a
4303 * function template specialization (including instantiations), this
4304 * this routine will return the specialized template.
4306 * For members of a class template (e.g., member functions, member classes, or
4307 * static data members), returns the specialized or instantiated member.
4308 * Although not strictly "templates" in the C++ language, members of class
4309 * templates have the same notions of specializations and instantiations that
4310 * templates do, so this routine treats them similarly.
4312 * \param C A cursor that may be a specialization of a template or a member
4315 * \returns If the given cursor is a specialization or instantiation of a
4316 * template or a member thereof, the template or member that it specializes or
4317 * from which it was instantiated. Otherwise, returns a NULL cursor.
4319 CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4322 * \brief Given a cursor that references something else, return the source range
4323 * covering that reference.
4325 * \param C A cursor pointing to a member reference, a declaration reference, or
4327 * \param NameFlags A bitset with three independent flags:
4328 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4329 * CXNameRange_WantSinglePiece.
4330 * \param PieceIndex For contiguous names or when passing the flag
4331 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4332 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4333 * non-contiguous names, this index can be used to retrieve the individual
4334 * pieces of the name. See also CXNameRange_WantSinglePiece.
4336 * \returns The piece of the name pointed to by the given cursor. If there is no
4337 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4339 CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4341 unsigned PieceIndex);
4343 enum CXNameRefFlags {
4345 * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4348 CXNameRange_WantQualifier = 0x1,
4351 * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
4354 CXNameRange_WantTemplateArgs = 0x2,
4357 * \brief If the name is non-contiguous, return the full spanning range.
4359 * Non-contiguous names occur in Objective-C when a selector with two or more
4360 * parameters is used, or in C++ when using an operator:
4362 * [object doSomething:here withValue:there]; // Objective-C
4363 * return some_vector[1]; // C++
4366 CXNameRange_WantSinglePiece = 0x4
4374 * \defgroup CINDEX_LEX Token extraction and manipulation
4376 * The routines in this group provide access to the tokens within a
4377 * translation unit, along with a semantic mapping of those tokens to
4378 * their corresponding cursors.
4384 * \brief Describes a kind of token.
4386 typedef enum CXTokenKind {
4388 * \brief A token that contains some kind of punctuation.
4390 CXToken_Punctuation,
4393 * \brief A language keyword.
4398 * \brief An identifier (that is not a keyword).
4403 * \brief A numeric, string, or character literal.
4414 * \brief Describes a single preprocessing token.
4417 unsigned int_data[4];
4422 * \brief Determine the kind of the given token.
4424 CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4427 * \brief Determine the spelling of the given token.
4429 * The spelling of a token is the textual representation of that token, e.g.,
4430 * the text of an identifier or keyword.
4432 CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4435 * \brief Retrieve the source location of the given token.
4437 CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4441 * \brief Retrieve a source range that covers the given token.
4443 CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4446 * \brief Tokenize the source code described by the given range into raw
4449 * \param TU the translation unit whose text is being tokenized.
4451 * \param Range the source range in which text should be tokenized. All of the
4452 * tokens produced by tokenization will fall within this source range,
4454 * \param Tokens this pointer will be set to point to the array of tokens
4455 * that occur within the given source range. The returned pointer must be
4456 * freed with clang_disposeTokens() before the translation unit is destroyed.
4458 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4462 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4463 CXToken **Tokens, unsigned *NumTokens);
4466 * \brief Annotate the given set of tokens by providing cursors for each token
4467 * that can be mapped to a specific entity within the abstract syntax tree.
4469 * This token-annotation routine is equivalent to invoking
4470 * clang_getCursor() for the source locations of each of the
4471 * tokens. The cursors provided are filtered, so that only those
4472 * cursors that have a direct correspondence to the token are
4473 * accepted. For example, given a function call \c f(x),
4474 * clang_getCursor() would provide the following cursors:
4476 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4477 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4478 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4480 * Only the first and last of these cursors will occur within the
4481 * annotate, since the tokens "f" and "x' directly refer to a function
4482 * and a variable, respectively, but the parentheses are just a small
4483 * part of the full syntax of the function call expression, which is
4484 * not provided as an annotation.
4486 * \param TU the translation unit that owns the given tokens.
4488 * \param Tokens the set of tokens to annotate.
4490 * \param NumTokens the number of tokens in \p Tokens.
4492 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4493 * replaced with the cursors corresponding to each token.
4495 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4496 CXToken *Tokens, unsigned NumTokens,
4500 * \brief Free the given set of tokens.
4502 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4503 CXToken *Tokens, unsigned NumTokens);
4510 * \defgroup CINDEX_DEBUG Debugging facilities
4512 * These routines are used for testing and debugging, only, and should not
4518 /* for debug/testing */
4519 CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4520 CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4521 const char **startBuf,
4522 const char **endBuf,
4523 unsigned *startLine,
4524 unsigned *startColumn,
4526 unsigned *endColumn);
4527 CINDEX_LINKAGE void clang_enableStackTraces(void);
4528 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4529 unsigned stack_size);
4536 * \defgroup CINDEX_CODE_COMPLET Code completion
4538 * Code completion involves taking an (incomplete) source file, along with
4539 * knowledge of where the user is actively editing that file, and suggesting
4540 * syntactically- and semantically-valid constructs that the user might want to
4541 * use at that particular point in the source code. These data structures and
4542 * routines provide support for code completion.
4548 * \brief A semantic string that describes a code-completion result.
4550 * A semantic string that describes the formatting of a code-completion
4551 * result as a single "template" of text that should be inserted into the
4552 * source buffer when a particular code-completion result is selected.
4553 * Each semantic string is made up of some number of "chunks", each of which
4554 * contains some text along with a description of what that text means, e.g.,
4555 * the name of the entity being referenced, whether the text chunk is part of
4556 * the template, or whether it is a "placeholder" that the user should replace
4557 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4558 * description of the different kinds of chunks.
4560 typedef void *CXCompletionString;
4563 * \brief A single result of code completion.
4567 * \brief The kind of entity that this completion refers to.
4569 * The cursor kind will be a macro, keyword, or a declaration (one of the
4570 * *Decl cursor kinds), describing the entity that the completion is
4573 * \todo In the future, we would like to provide a full cursor, to allow
4574 * the client to extract additional information from declaration.
4576 enum CXCursorKind CursorKind;
4579 * \brief The code-completion string that describes how to insert this
4580 * code-completion result into the editing buffer.
4582 CXCompletionString CompletionString;
4583 } CXCompletionResult;
4586 * \brief Describes a single piece of text within a code-completion string.
4588 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4589 * either a piece of text with a specific "kind" that describes how that text
4590 * should be interpreted by the client or is another completion string.
4592 enum CXCompletionChunkKind {
4594 * \brief A code-completion string that describes "optional" text that
4595 * could be a part of the template (but is not required).
4597 * The Optional chunk is the only kind of chunk that has a code-completion
4598 * string for its representation, which is accessible via
4599 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4600 * describes an additional part of the template that is completely optional.
4601 * For example, optional chunks can be used to describe the placeholders for
4602 * arguments that match up with defaulted function parameters, e.g. given:
4605 * void f(int x, float y = 3.14, double z = 2.71828);
4608 * The code-completion string for this function would contain:
4609 * - a TypedText chunk for "f".
4610 * - a LeftParen chunk for "(".
4611 * - a Placeholder chunk for "int x"
4612 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4613 * - a Comma chunk for ","
4614 * - a Placeholder chunk for "float y"
4615 * - an Optional chunk containing the last defaulted argument:
4616 * - a Comma chunk for ","
4617 * - a Placeholder chunk for "double z"
4618 * - a RightParen chunk for ")"
4620 * There are many ways to handle Optional chunks. Two simple approaches are:
4621 * - Completely ignore optional chunks, in which case the template for the
4622 * function "f" would only include the first parameter ("int x").
4623 * - Fully expand all optional chunks, in which case the template for the
4624 * function "f" would have all of the parameters.
4626 CXCompletionChunk_Optional,
4628 * \brief Text that a user would be expected to type to get this
4629 * code-completion result.
4631 * There will be exactly one "typed text" chunk in a semantic string, which
4632 * will typically provide the spelling of a keyword or the name of a
4633 * declaration that could be used at the current code point. Clients are
4634 * expected to filter the code-completion results based on the text in this
4637 CXCompletionChunk_TypedText,
4639 * \brief Text that should be inserted as part of a code-completion result.
4641 * A "text" chunk represents text that is part of the template to be
4642 * inserted into user code should this particular code-completion result
4645 CXCompletionChunk_Text,
4647 * \brief Placeholder text that should be replaced by the user.
4649 * A "placeholder" chunk marks a place where the user should insert text
4650 * into the code-completion template. For example, placeholders might mark
4651 * the function parameters for a function declaration, to indicate that the
4652 * user should provide arguments for each of those parameters. The actual
4653 * text in a placeholder is a suggestion for the text to display before
4654 * the user replaces the placeholder with real code.
4656 CXCompletionChunk_Placeholder,
4658 * \brief Informative text that should be displayed but never inserted as
4659 * part of the template.
4661 * An "informative" chunk contains annotations that can be displayed to
4662 * help the user decide whether a particular code-completion result is the
4663 * right option, but which is not part of the actual template to be inserted
4664 * by code completion.
4666 CXCompletionChunk_Informative,
4668 * \brief Text that describes the current parameter when code-completion is
4669 * referring to function call, message send, or template specialization.
4671 * A "current parameter" chunk occurs when code-completion is providing
4672 * information about a parameter corresponding to the argument at the
4673 * code-completion point. For example, given a function
4676 * int add(int x, int y);
4679 * and the source code \c add(, where the code-completion point is after the
4680 * "(", the code-completion string will contain a "current parameter" chunk
4681 * for "int x", indicating that the current argument will initialize that
4682 * parameter. After typing further, to \c add(17, (where the code-completion
4683 * point is after the ","), the code-completion string will contain a
4684 * "current paremeter" chunk to "int y".
4686 CXCompletionChunk_CurrentParameter,
4688 * \brief A left parenthesis ('('), used to initiate a function call or
4689 * signal the beginning of a function parameter list.
4691 CXCompletionChunk_LeftParen,
4693 * \brief A right parenthesis (')'), used to finish a function call or
4694 * signal the end of a function parameter list.
4696 CXCompletionChunk_RightParen,
4698 * \brief A left bracket ('[').
4700 CXCompletionChunk_LeftBracket,
4702 * \brief A right bracket (']').
4704 CXCompletionChunk_RightBracket,
4706 * \brief A left brace ('{').
4708 CXCompletionChunk_LeftBrace,
4710 * \brief A right brace ('}').
4712 CXCompletionChunk_RightBrace,
4714 * \brief A left angle bracket ('<').
4716 CXCompletionChunk_LeftAngle,
4718 * \brief A right angle bracket ('>').
4720 CXCompletionChunk_RightAngle,
4722 * \brief A comma separator (',').
4724 CXCompletionChunk_Comma,
4726 * \brief Text that specifies the result type of a given result.
4728 * This special kind of informative chunk is not meant to be inserted into
4729 * the text buffer. Rather, it is meant to illustrate the type that an
4730 * expression using the given completion string would have.
4732 CXCompletionChunk_ResultType,
4734 * \brief A colon (':').
4736 CXCompletionChunk_Colon,
4738 * \brief A semicolon (';').
4740 CXCompletionChunk_SemiColon,
4742 * \brief An '=' sign.
4744 CXCompletionChunk_Equal,
4746 * Horizontal space (' ').
4748 CXCompletionChunk_HorizontalSpace,
4750 * Vertical space ('\\n'), after which it is generally a good idea to
4751 * perform indentation.
4753 CXCompletionChunk_VerticalSpace
4757 * \brief Determine the kind of a particular chunk within a completion string.
4759 * \param completion_string the completion string to query.
4761 * \param chunk_number the 0-based index of the chunk in the completion string.
4763 * \returns the kind of the chunk at the index \c chunk_number.
4765 CINDEX_LINKAGE enum CXCompletionChunkKind
4766 clang_getCompletionChunkKind(CXCompletionString completion_string,
4767 unsigned chunk_number);
4770 * \brief Retrieve the text associated with a particular chunk within a
4771 * completion string.
4773 * \param completion_string the completion string to query.
4775 * \param chunk_number the 0-based index of the chunk in the completion string.
4777 * \returns the text associated with the chunk at index \c chunk_number.
4779 CINDEX_LINKAGE CXString
4780 clang_getCompletionChunkText(CXCompletionString completion_string,
4781 unsigned chunk_number);
4784 * \brief Retrieve the completion string associated with a particular chunk
4785 * within a completion string.
4787 * \param completion_string the completion string to query.
4789 * \param chunk_number the 0-based index of the chunk in the completion string.
4791 * \returns the completion string associated with the chunk at index
4794 CINDEX_LINKAGE CXCompletionString
4795 clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4796 unsigned chunk_number);
4799 * \brief Retrieve the number of chunks in the given code-completion string.
4801 CINDEX_LINKAGE unsigned
4802 clang_getNumCompletionChunks(CXCompletionString completion_string);
4805 * \brief Determine the priority of this code completion.
4807 * The priority of a code completion indicates how likely it is that this
4808 * particular completion is the completion that the user will select. The
4809 * priority is selected by various internal heuristics.
4811 * \param completion_string The completion string to query.
4813 * \returns The priority of this completion string. Smaller values indicate
4814 * higher-priority (more likely) completions.
4816 CINDEX_LINKAGE unsigned
4817 clang_getCompletionPriority(CXCompletionString completion_string);
4820 * \brief Determine the availability of the entity that this code-completion
4823 * \param completion_string The completion string to query.
4825 * \returns The availability of the completion string.
4827 CINDEX_LINKAGE enum CXAvailabilityKind
4828 clang_getCompletionAvailability(CXCompletionString completion_string);
4831 * \brief Retrieve the number of annotations associated with the given
4832 * completion string.
4834 * \param completion_string the completion string to query.
4836 * \returns the number of annotations associated with the given completion
4839 CINDEX_LINKAGE unsigned
4840 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
4843 * \brief Retrieve the annotation associated with the given completion string.
4845 * \param completion_string the completion string to query.
4847 * \param annotation_number the 0-based index of the annotation of the
4848 * completion string.
4850 * \returns annotation string associated with the completion at index
4851 * \c annotation_number, or a NULL string if that annotation is not available.
4853 CINDEX_LINKAGE CXString
4854 clang_getCompletionAnnotation(CXCompletionString completion_string,
4855 unsigned annotation_number);
4858 * \brief Retrieve the parent context of the given completion string.
4860 * The parent context of a completion string is the semantic parent of
4861 * the declaration (if any) that the code completion represents. For example,
4862 * a code completion for an Objective-C method would have the method's class
4863 * or protocol as its context.
4865 * \param completion_string The code completion string whose parent is
4868 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
4870 * \returns The name of the completion parent, e.g., "NSObject" if
4871 * the completion string represents a method in the NSObject class.
4873 CINDEX_LINKAGE CXString
4874 clang_getCompletionParent(CXCompletionString completion_string,
4875 enum CXCursorKind *kind);
4878 * \brief Retrieve the brief documentation comment attached to the declaration
4879 * that corresponds to the given completion string.
4881 CINDEX_LINKAGE CXString
4882 clang_getCompletionBriefComment(CXCompletionString completion_string);
4885 * \brief Retrieve a completion string for an arbitrary declaration or macro
4886 * definition cursor.
4888 * \param cursor The cursor to query.
4890 * \returns A non-context-sensitive completion string for declaration and macro
4891 * definition cursors, or NULL for other kinds of cursors.
4893 CINDEX_LINKAGE CXCompletionString
4894 clang_getCursorCompletionString(CXCursor cursor);
4897 * \brief Contains the results of code-completion.
4899 * This data structure contains the results of code completion, as
4900 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
4901 * \c clang_disposeCodeCompleteResults.
4905 * \brief The code-completion results.
4907 CXCompletionResult *Results;
4910 * \brief The number of code-completion results stored in the
4913 unsigned NumResults;
4914 } CXCodeCompleteResults;
4917 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
4918 * modify its behavior.
4920 * The enumerators in this enumeration can be bitwise-OR'd together to
4921 * provide multiple options to \c clang_codeCompleteAt().
4923 enum CXCodeComplete_Flags {
4925 * \brief Whether to include macros within the set of code
4926 * completions returned.
4928 CXCodeComplete_IncludeMacros = 0x01,
4931 * \brief Whether to include code patterns for language constructs
4932 * within the set of code completions, e.g., for loops.
4934 CXCodeComplete_IncludeCodePatterns = 0x02,
4937 * \brief Whether to include brief documentation within the set of code
4938 * completions returned.
4940 CXCodeComplete_IncludeBriefComments = 0x04
4944 * \brief Bits that represent the context under which completion is occurring.
4946 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
4947 * contexts are occurring simultaneously.
4949 enum CXCompletionContext {
4951 * \brief The context for completions is unexposed, as only Clang results
4952 * should be included. (This is equivalent to having no context bits set.)
4954 CXCompletionContext_Unexposed = 0,
4957 * \brief Completions for any possible type should be included in the results.
4959 CXCompletionContext_AnyType = 1 << 0,
4962 * \brief Completions for any possible value (variables, function calls, etc.)
4963 * should be included in the results.
4965 CXCompletionContext_AnyValue = 1 << 1,
4967 * \brief Completions for values that resolve to an Objective-C object should
4968 * be included in the results.
4970 CXCompletionContext_ObjCObjectValue = 1 << 2,
4972 * \brief Completions for values that resolve to an Objective-C selector
4973 * should be included in the results.
4975 CXCompletionContext_ObjCSelectorValue = 1 << 3,
4977 * \brief Completions for values that resolve to a C++ class type should be
4978 * included in the results.
4980 CXCompletionContext_CXXClassTypeValue = 1 << 4,
4983 * \brief Completions for fields of the member being accessed using the dot
4984 * operator should be included in the results.
4986 CXCompletionContext_DotMemberAccess = 1 << 5,
4988 * \brief Completions for fields of the member being accessed using the arrow
4989 * operator should be included in the results.
4991 CXCompletionContext_ArrowMemberAccess = 1 << 6,
4993 * \brief Completions for properties of the Objective-C object being accessed
4994 * using the dot operator should be included in the results.
4996 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
4999 * \brief Completions for enum tags should be included in the results.
5001 CXCompletionContext_EnumTag = 1 << 8,
5003 * \brief Completions for union tags should be included in the results.
5005 CXCompletionContext_UnionTag = 1 << 9,
5007 * \brief Completions for struct tags should be included in the results.
5009 CXCompletionContext_StructTag = 1 << 10,
5012 * \brief Completions for C++ class names should be included in the results.
5014 CXCompletionContext_ClassTag = 1 << 11,
5016 * \brief Completions for C++ namespaces and namespace aliases should be
5017 * included in the results.
5019 CXCompletionContext_Namespace = 1 << 12,
5021 * \brief Completions for C++ nested name specifiers should be included in
5024 CXCompletionContext_NestedNameSpecifier = 1 << 13,
5027 * \brief Completions for Objective-C interfaces (classes) should be included
5030 CXCompletionContext_ObjCInterface = 1 << 14,
5032 * \brief Completions for Objective-C protocols should be included in
5035 CXCompletionContext_ObjCProtocol = 1 << 15,
5037 * \brief Completions for Objective-C categories should be included in
5040 CXCompletionContext_ObjCCategory = 1 << 16,
5042 * \brief Completions for Objective-C instance messages should be included
5045 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5047 * \brief Completions for Objective-C class messages should be included in
5050 CXCompletionContext_ObjCClassMessage = 1 << 18,
5052 * \brief Completions for Objective-C selector names should be included in
5055 CXCompletionContext_ObjCSelectorName = 1 << 19,
5058 * \brief Completions for preprocessor macro names should be included in
5061 CXCompletionContext_MacroName = 1 << 20,
5064 * \brief Natural language completions should be included in the results.
5066 CXCompletionContext_NaturalLanguage = 1 << 21,
5069 * \brief The current context is unknown, so set all contexts.
5071 CXCompletionContext_Unknown = ((1 << 22) - 1)
5075 * \brief Returns a default set of code-completion options that can be
5076 * passed to\c clang_codeCompleteAt().
5078 CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5081 * \brief Perform code completion at a given location in a translation unit.
5083 * This function performs code completion at a particular file, line, and
5084 * column within source code, providing results that suggest potential
5085 * code snippets based on the context of the completion. The basic model
5086 * for code completion is that Clang will parse a complete source file,
5087 * performing syntax checking up to the location where code-completion has
5088 * been requested. At that point, a special code-completion token is passed
5089 * to the parser, which recognizes this token and determines, based on the
5090 * current location in the C/Objective-C/C++ grammar and the state of
5091 * semantic analysis, what completions to provide. These completions are
5092 * returned via a new \c CXCodeCompleteResults structure.
5094 * Code completion itself is meant to be triggered by the client when the
5095 * user types punctuation characters or whitespace, at which point the
5096 * code-completion location will coincide with the cursor. For example, if \c p
5097 * is a pointer, code-completion might be triggered after the "-" and then
5098 * after the ">" in \c p->. When the code-completion location is afer the ">",
5099 * the completion results will provide, e.g., the members of the struct that
5100 * "p" points to. The client is responsible for placing the cursor at the
5101 * beginning of the token currently being typed, then filtering the results
5102 * based on the contents of the token. For example, when code-completing for
5103 * the expression \c p->get, the client should provide the location just after
5104 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5105 * client can filter the results based on the current token text ("get"), only
5106 * showing those results that start with "get". The intent of this interface
5107 * is to separate the relatively high-latency acquisition of code-completion
5108 * results from the filtering of results on a per-character basis, which must
5109 * have a lower latency.
5111 * \param TU The translation unit in which code-completion should
5112 * occur. The source files for this translation unit need not be
5113 * completely up-to-date (and the contents of those source files may
5114 * be overridden via \p unsaved_files). Cursors referring into the
5115 * translation unit may be invalidated by this invocation.
5117 * \param complete_filename The name of the source file where code
5118 * completion should be performed. This filename may be any file
5119 * included in the translation unit.
5121 * \param complete_line The line at which code-completion should occur.
5123 * \param complete_column The column at which code-completion should occur.
5124 * Note that the column should point just after the syntactic construct that
5125 * initiated code completion, and not in the middle of a lexical token.
5127 * \param unsaved_files the Files that have not yet been saved to disk
5128 * but may be required for parsing or code completion, including the
5129 * contents of those files. The contents and name of these files (as
5130 * specified by CXUnsavedFile) are copied when necessary, so the
5131 * client only needs to guarantee their validity until the call to
5132 * this function returns.
5134 * \param num_unsaved_files The number of unsaved file entries in \p
5137 * \param options Extra options that control the behavior of code
5138 * completion, expressed as a bitwise OR of the enumerators of the
5139 * CXCodeComplete_Flags enumeration. The
5140 * \c clang_defaultCodeCompleteOptions() function returns a default set
5141 * of code-completion options.
5143 * \returns If successful, a new \c CXCodeCompleteResults structure
5144 * containing code-completion results, which should eventually be
5145 * freed with \c clang_disposeCodeCompleteResults(). If code
5146 * completion fails, returns NULL.
5149 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5150 const char *complete_filename,
5151 unsigned complete_line,
5152 unsigned complete_column,
5153 struct CXUnsavedFile *unsaved_files,
5154 unsigned num_unsaved_files,
5158 * \brief Sort the code-completion results in case-insensitive alphabetical
5161 * \param Results The set of results to sort.
5162 * \param NumResults The number of results in \p Results.
5165 void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5166 unsigned NumResults);
5169 * \brief Free the given set of code-completion results.
5172 void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
5175 * \brief Determine the number of diagnostics produced prior to the
5176 * location where code completion was performed.
5179 unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5182 * \brief Retrieve a diagnostic associated with the given code completion.
5184 * \param Results the code completion results to query.
5185 * \param Index the zero-based diagnostic number to retrieve.
5187 * \returns the requested diagnostic. This diagnostic must be freed
5188 * via a call to \c clang_disposeDiagnostic().
5191 CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5195 * \brief Determines what completions are appropriate for the context
5196 * the given code completion.
5198 * \param Results the code completion results to query
5200 * \returns the kinds of completions that are appropriate for use
5201 * along with the given code completion results.
5204 unsigned long long clang_codeCompleteGetContexts(
5205 CXCodeCompleteResults *Results);
5208 * \brief Returns the cursor kind for the container for the current code
5209 * completion context. The container is only guaranteed to be set for
5210 * contexts where a container exists (i.e. member accesses or Objective-C
5211 * message sends); if there is not a container, this function will return
5212 * CXCursor_InvalidCode.
5214 * \param Results the code completion results to query
5216 * \param IsIncomplete on return, this value will be false if Clang has complete
5217 * information about the container. If Clang does not have complete
5218 * information, this value will be true.
5220 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5224 enum CXCursorKind clang_codeCompleteGetContainerKind(
5225 CXCodeCompleteResults *Results,
5226 unsigned *IsIncomplete);
5229 * \brief Returns the USR for the container for the current code completion
5230 * context. If there is not a container for the current context, this
5231 * function will return the empty string.
5233 * \param Results the code completion results to query
5235 * \returns the USR for the container
5238 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5241 * \brief Returns the currently-entered selector for an Objective-C message
5242 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5243 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5244 * CXCompletionContext_ObjCClassMessage.
5246 * \param Results the code completion results to query
5248 * \returns the selector (or partial selector) that has been entered thus far
5249 * for an Objective-C message send.
5252 CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5259 * \defgroup CINDEX_MISC Miscellaneous utility functions
5265 * \brief Return a version string, suitable for showing to a user, but not
5266 * intended to be parsed (the format is not guaranteed to be stable).
5268 CINDEX_LINKAGE CXString clang_getClangVersion(void);
5271 * \brief Enable/disable crash recovery.
5273 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5274 * value enables crash recovery, while 0 disables it.
5276 CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5279 * \brief Visitor invoked for each file in a translation unit
5280 * (used with clang_getInclusions()).
5282 * This visitor function will be invoked by clang_getInclusions() for each
5283 * file included (either at the top-level or by \#include directives) within
5284 * a translation unit. The first argument is the file being included, and
5285 * the second and third arguments provide the inclusion stack. The
5286 * array is sorted in order of immediate inclusion. For example,
5287 * the first element refers to the location that included 'included_file'.
5289 typedef void (*CXInclusionVisitor)(CXFile included_file,
5290 CXSourceLocation* inclusion_stack,
5291 unsigned include_len,
5292 CXClientData client_data);
5295 * \brief Visit the set of preprocessor inclusions in a translation unit.
5296 * The visitor function is called with the provided data for every included
5297 * file. This does not include headers included by the PCH file (unless one
5298 * is inspecting the inclusions in the PCH file itself).
5300 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5301 CXInclusionVisitor visitor,
5302 CXClientData client_data);
5307 CXEval_ObjCStrLiteral = 3,
5308 CXEval_StrLiteral = 4,
5312 CXEval_UnExposed = 0
5314 } CXEvalResultKind ;
5317 * \brief Evaluation result of a cursor
5319 typedef void * CXEvalResult;
5322 * \brief If cursor is a statement declaration tries to evaluate the
5323 * statement and if its variable, tries to evaluate its initializer,
5324 * into its corresponding type.
5326 CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5329 * \brief Returns the kind of the evaluated result.
5331 CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
5334 * \brief Returns the evaluation result as integer if the
5337 CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5340 * \brief Returns the evaluation result as a long long integer if the
5341 * kind is Int. This prevents overflows that may happen if the result is
5342 * returned with clang_EvalResult_getAsInt.
5344 CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5347 * \brief Returns a non-zero value if the kind is Int and the evaluation
5348 * result resulted in an unsigned integer.
5350 CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5353 * \brief Returns the evaluation result as an unsigned integer if
5354 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5356 CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5359 * \brief Returns the evaluation result as double if the
5362 CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5365 * \brief Returns the evaluation result as a constant string if the
5366 * kind is other than Int or float. User must not free this pointer,
5367 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5368 * by clang_Cursor_Evaluate.
5370 CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
5373 * \brief Disposes the created Eval memory.
5375 CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5380 /** \defgroup CINDEX_REMAPPING Remapping functions
5386 * \brief A remapping of original source files and their translated files.
5388 typedef void *CXRemapping;
5391 * \brief Retrieve a remapping.
5393 * \param path the path that contains metadata about remappings.
5395 * \returns the requested remapping. This remapping must be freed
5396 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5398 CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5401 * \brief Retrieve a remapping.
5403 * \param filePaths pointer to an array of file paths containing remapping info.
5405 * \param numFiles number of file paths.
5407 * \returns the requested remapping. This remapping must be freed
5408 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5411 CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5415 * \brief Determine the number of remappings.
5417 CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5420 * \brief Get the original and the associated filename from the remapping.
5422 * \param original If non-NULL, will be set to the original filename.
5424 * \param transformed If non-NULL, will be set to the filename that the original
5425 * is associated with.
5427 CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5428 CXString *original, CXString *transformed);
5431 * \brief Dispose the remapping.
5433 CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5439 /** \defgroup CINDEX_HIGH Higher level API functions
5444 enum CXVisitorResult {
5449 typedef struct CXCursorAndRangeVisitor {
5451 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5452 } CXCursorAndRangeVisitor;
5456 * \brief Function returned successfully.
5458 CXResult_Success = 0,
5460 * \brief One of the parameters was invalid for the function.
5462 CXResult_Invalid = 1,
5464 * \brief The function was terminated by a callback (e.g. it returned
5467 CXResult_VisitBreak = 2
5472 * \brief Find references of a declaration in a specific file.
5474 * \param cursor pointing to a declaration or a reference of one.
5476 * \param file to search for references.
5478 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5479 * each reference found.
5480 * The CXSourceRange will point inside the file; if the reference is inside
5481 * a macro (and not a macro argument) the CXSourceRange will be invalid.
5483 * \returns one of the CXResult enumerators.
5485 CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5486 CXCursorAndRangeVisitor visitor);
5489 * \brief Find #import/#include directives in a specific file.
5491 * \param TU translation unit containing the file to query.
5493 * \param file to search for #import/#include directives.
5495 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5496 * each directive found.
5498 * \returns one of the CXResult enumerators.
5500 CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5502 CXCursorAndRangeVisitor visitor);
5504 #ifdef __has_feature
5505 # if __has_feature(blocks)
5507 typedef enum CXVisitorResult
5508 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5511 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5512 CXCursorAndRangeVisitorBlock);
5515 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5516 CXCursorAndRangeVisitorBlock);
5522 * \brief The client's data object that is associated with a CXFile.
5524 typedef void *CXIdxClientFile;
5527 * \brief The client's data object that is associated with a semantic entity.
5529 typedef void *CXIdxClientEntity;
5532 * \brief The client's data object that is associated with a semantic container
5535 typedef void *CXIdxClientContainer;
5538 * \brief The client's data object that is associated with an AST file (PCH
5541 typedef void *CXIdxClientASTFile;
5544 * \brief Source location passed to index callbacks.
5552 * \brief Data for ppIncludedFile callback.
5556 * \brief Location of '#' in the \#include/\#import directive.
5560 * \brief Filename as written in the \#include/\#import directive.
5562 const char *filename;
5564 * \brief The actual file that the \#include/\#import directive resolved to.
5570 * \brief Non-zero if the directive was automatically turned into a module
5574 } CXIdxIncludedFileInfo;
5577 * \brief Data for IndexerCallbacks#importedASTFile.
5581 * \brief Top level AST file containing the imported PCH, module or submodule.
5585 * \brief The imported module or NULL if the AST file is a PCH.
5589 * \brief Location where the file is imported. Applicable only for modules.
5593 * \brief Non-zero if an inclusion directive was automatically turned into
5594 * a module import. Applicable only for modules.
5598 } CXIdxImportedASTFileInfo;
5601 CXIdxEntity_Unexposed = 0,
5602 CXIdxEntity_Typedef = 1,
5603 CXIdxEntity_Function = 2,
5604 CXIdxEntity_Variable = 3,
5605 CXIdxEntity_Field = 4,
5606 CXIdxEntity_EnumConstant = 5,
5608 CXIdxEntity_ObjCClass = 6,
5609 CXIdxEntity_ObjCProtocol = 7,
5610 CXIdxEntity_ObjCCategory = 8,
5612 CXIdxEntity_ObjCInstanceMethod = 9,
5613 CXIdxEntity_ObjCClassMethod = 10,
5614 CXIdxEntity_ObjCProperty = 11,
5615 CXIdxEntity_ObjCIvar = 12,
5617 CXIdxEntity_Enum = 13,
5618 CXIdxEntity_Struct = 14,
5619 CXIdxEntity_Union = 15,
5621 CXIdxEntity_CXXClass = 16,
5622 CXIdxEntity_CXXNamespace = 17,
5623 CXIdxEntity_CXXNamespaceAlias = 18,
5624 CXIdxEntity_CXXStaticVariable = 19,
5625 CXIdxEntity_CXXStaticMethod = 20,
5626 CXIdxEntity_CXXInstanceMethod = 21,
5627 CXIdxEntity_CXXConstructor = 22,
5628 CXIdxEntity_CXXDestructor = 23,
5629 CXIdxEntity_CXXConversionFunction = 24,
5630 CXIdxEntity_CXXTypeAlias = 25,
5631 CXIdxEntity_CXXInterface = 26
5636 CXIdxEntityLang_None = 0,
5637 CXIdxEntityLang_C = 1,
5638 CXIdxEntityLang_ObjC = 2,
5639 CXIdxEntityLang_CXX = 3,
5640 CXIdxEntityLang_Swift = 4
5641 } CXIdxEntityLanguage;
5644 * \brief Extra C++ template information for an entity. This can apply to:
5645 * CXIdxEntity_Function
5646 * CXIdxEntity_CXXClass
5647 * CXIdxEntity_CXXStaticMethod
5648 * CXIdxEntity_CXXInstanceMethod
5649 * CXIdxEntity_CXXConstructor
5650 * CXIdxEntity_CXXConversionFunction
5651 * CXIdxEntity_CXXTypeAlias
5654 CXIdxEntity_NonTemplate = 0,
5655 CXIdxEntity_Template = 1,
5656 CXIdxEntity_TemplatePartialSpecialization = 2,
5657 CXIdxEntity_TemplateSpecialization = 3
5658 } CXIdxEntityCXXTemplateKind;
5661 CXIdxAttr_Unexposed = 0,
5662 CXIdxAttr_IBAction = 1,
5663 CXIdxAttr_IBOutlet = 2,
5664 CXIdxAttr_IBOutletCollection = 3
5674 CXIdxEntityKind kind;
5675 CXIdxEntityCXXTemplateKind templateKind;
5676 CXIdxEntityLanguage lang;
5680 const CXIdxAttrInfo *const *attributes;
5681 unsigned numAttributes;
5686 } CXIdxContainerInfo;
5689 const CXIdxAttrInfo *attrInfo;
5690 const CXIdxEntityInfo *objcClass;
5691 CXCursor classCursor;
5693 } CXIdxIBOutletCollectionAttrInfo;
5696 CXIdxDeclFlag_Skipped = 0x1
5697 } CXIdxDeclInfoFlags;
5700 const CXIdxEntityInfo *entityInfo;
5703 const CXIdxContainerInfo *semanticContainer;
5705 * \brief Generally same as #semanticContainer but can be different in
5706 * cases like out-of-line C++ member functions.
5708 const CXIdxContainerInfo *lexicalContainer;
5709 int isRedeclaration;
5712 const CXIdxContainerInfo *declAsContainer;
5714 * \brief Whether the declaration exists in code or was created implicitly
5715 * by the compiler, e.g. implicit Objective-C methods for properties.
5718 const CXIdxAttrInfo *const *attributes;
5719 unsigned numAttributes;
5726 CXIdxObjCContainer_ForwardRef = 0,
5727 CXIdxObjCContainer_Interface = 1,
5728 CXIdxObjCContainer_Implementation = 2
5729 } CXIdxObjCContainerKind;
5732 const CXIdxDeclInfo *declInfo;
5733 CXIdxObjCContainerKind kind;
5734 } CXIdxObjCContainerDeclInfo;
5737 const CXIdxEntityInfo *base;
5740 } CXIdxBaseClassInfo;
5743 const CXIdxEntityInfo *protocol;
5746 } CXIdxObjCProtocolRefInfo;
5749 const CXIdxObjCProtocolRefInfo *const *protocols;
5750 unsigned numProtocols;
5751 } CXIdxObjCProtocolRefListInfo;
5754 const CXIdxObjCContainerDeclInfo *containerInfo;
5755 const CXIdxBaseClassInfo *superInfo;
5756 const CXIdxObjCProtocolRefListInfo *protocols;
5757 } CXIdxObjCInterfaceDeclInfo;
5760 const CXIdxObjCContainerDeclInfo *containerInfo;
5761 const CXIdxEntityInfo *objcClass;
5762 CXCursor classCursor;
5764 const CXIdxObjCProtocolRefListInfo *protocols;
5765 } CXIdxObjCCategoryDeclInfo;
5768 const CXIdxDeclInfo *declInfo;
5769 const CXIdxEntityInfo *getter;
5770 const CXIdxEntityInfo *setter;
5771 } CXIdxObjCPropertyDeclInfo;
5774 const CXIdxDeclInfo *declInfo;
5775 const CXIdxBaseClassInfo *const *bases;
5777 } CXIdxCXXClassDeclInfo;
5780 * \brief Data for IndexerCallbacks#indexEntityReference.
5784 * \brief The entity is referenced directly in user's code.
5786 CXIdxEntityRef_Direct = 1,
5788 * \brief An implicit reference, e.g. a reference of an Objective-C method
5789 * via the dot syntax.
5791 CXIdxEntityRef_Implicit = 2
5792 } CXIdxEntityRefKind;
5795 * \brief Data for IndexerCallbacks#indexEntityReference.
5798 CXIdxEntityRefKind kind;
5800 * \brief Reference cursor.
5805 * \brief The entity that gets referenced.
5807 const CXIdxEntityInfo *referencedEntity;
5809 * \brief Immediate "parent" of the reference. For example:
5815 * The parent of reference of type 'Foo' is the variable 'var'.
5816 * For references inside statement bodies of functions/methods,
5817 * the parentEntity will be the function/method.
5819 const CXIdxEntityInfo *parentEntity;
5821 * \brief Lexical container context of the reference.
5823 const CXIdxContainerInfo *container;
5824 } CXIdxEntityRefInfo;
5827 * \brief A group of callbacks used by #clang_indexSourceFile and
5828 * #clang_indexTranslationUnit.
5832 * \brief Called periodically to check whether indexing should be aborted.
5833 * Should return 0 to continue, and non-zero to abort.
5835 int (*abortQuery)(CXClientData client_data, void *reserved);
5838 * \brief Called at the end of indexing; passes the complete diagnostic set.
5840 void (*diagnostic)(CXClientData client_data,
5841 CXDiagnosticSet, void *reserved);
5843 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
5844 CXFile mainFile, void *reserved);
5847 * \brief Called when a file gets \#included/\#imported.
5849 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
5850 const CXIdxIncludedFileInfo *);
5853 * \brief Called when a AST file (PCH or module) gets imported.
5855 * AST files will not get indexed (there will not be callbacks to index all
5856 * the entities in an AST file). The recommended action is that, if the AST
5857 * file is not already indexed, to initiate a new indexing job specific to
5860 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
5861 const CXIdxImportedASTFileInfo *);
5864 * \brief Called at the beginning of indexing a translation unit.
5866 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
5869 void (*indexDeclaration)(CXClientData client_data,
5870 const CXIdxDeclInfo *);
5873 * \brief Called to index a reference of an entity.
5875 void (*indexEntityReference)(CXClientData client_data,
5876 const CXIdxEntityRefInfo *);
5880 CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
5881 CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
5882 clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
5884 CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
5885 clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
5888 const CXIdxObjCCategoryDeclInfo *
5889 clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
5891 CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
5892 clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
5894 CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
5895 clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
5897 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
5898 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
5900 CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
5901 clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
5904 * \brief For retrieving a custom CXIdxClientContainer attached to a
5907 CINDEX_LINKAGE CXIdxClientContainer
5908 clang_index_getClientContainer(const CXIdxContainerInfo *);
5911 * \brief For setting a custom CXIdxClientContainer attached to a
5915 clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
5918 * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
5920 CINDEX_LINKAGE CXIdxClientEntity
5921 clang_index_getClientEntity(const CXIdxEntityInfo *);
5924 * \brief For setting a custom CXIdxClientEntity attached to an entity.
5927 clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
5930 * \brief An indexing action/session, to be applied to one or multiple
5931 * translation units.
5933 typedef void *CXIndexAction;
5936 * \brief An indexing action/session, to be applied to one or multiple
5937 * translation units.
5939 * \param CIdx The index object with which the index action will be associated.
5941 CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
5944 * \brief Destroy the given index action.
5946 * The index action must not be destroyed until all of the translation units
5947 * created within that index action have been destroyed.
5949 CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
5953 * \brief Used to indicate that no special indexing options are needed.
5955 CXIndexOpt_None = 0x0,
5958 * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
5959 * be invoked for only one reference of an entity per source file that does
5960 * not also include a declaration/definition of the entity.
5962 CXIndexOpt_SuppressRedundantRefs = 0x1,
5965 * \brief Function-local symbols should be indexed. If this is not set
5966 * function-local symbols will be ignored.
5968 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
5971 * \brief Implicit function/class template instantiations should be indexed.
5972 * If this is not set, implicit instantiations will be ignored.
5974 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
5977 * \brief Suppress all compiler warnings when parsing for indexing.
5979 CXIndexOpt_SuppressWarnings = 0x8,
5982 * \brief Skip a function/method body that was already parsed during an
5983 * indexing session associated with a \c CXIndexAction object.
5984 * Bodies in system headers are always skipped.
5986 CXIndexOpt_SkipParsedBodiesInSession = 0x10
5991 * \brief Index the given source file and the translation unit corresponding
5992 * to that file via callbacks implemented through #IndexerCallbacks.
5994 * \param client_data pointer data supplied by the client, which will
5995 * be passed to the invoked callbacks.
5997 * \param index_callbacks Pointer to indexing callbacks that the client
6000 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6001 * passed in index_callbacks.
6003 * \param index_options A bitmask of options that affects how indexing is
6004 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6006 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6007 * reused after indexing is finished. Set to \c NULL if you do not require it.
6009 * \returns 0 on success or if there were errors from which the compiler could
6010 * recover. If there is a failure from which there is no recovery, returns
6011 * a non-zero \c CXErrorCode.
6013 * The rest of the parameters are the same as #clang_parseTranslationUnit.
6015 CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
6016 CXClientData client_data,
6017 IndexerCallbacks *index_callbacks,
6018 unsigned index_callbacks_size,
6019 unsigned index_options,
6020 const char *source_filename,
6021 const char * const *command_line_args,
6022 int num_command_line_args,
6023 struct CXUnsavedFile *unsaved_files,
6024 unsigned num_unsaved_files,
6025 CXTranslationUnit *out_TU,
6026 unsigned TU_options);
6029 * \brief Same as clang_indexSourceFile but requires a full command line
6030 * for \c command_line_args including argv[0]. This is useful if the standard
6031 * library paths are relative to the binary.
6033 CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6034 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6035 unsigned index_callbacks_size, unsigned index_options,
6036 const char *source_filename, const char *const *command_line_args,
6037 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6038 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6041 * \brief Index the given translation unit via callbacks implemented through
6042 * #IndexerCallbacks.
6044 * The order of callback invocations is not guaranteed to be the same as
6045 * when indexing a source file. The high level order will be:
6047 * -Preprocessor callbacks invocations
6048 * -Declaration/reference callbacks invocations
6049 * -Diagnostic callback invocations
6051 * The parameters are the same as #clang_indexSourceFile.
6053 * \returns If there is a failure from which there is no recovery, returns
6054 * non-zero, otherwise returns 0.
6056 CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
6057 CXClientData client_data,
6058 IndexerCallbacks *index_callbacks,
6059 unsigned index_callbacks_size,
6060 unsigned index_options,
6064 * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
6065 * the given CXIdxLoc.
6067 * If the location refers into a macro expansion, retrieves the
6068 * location of the macro expansion and if it refers into a macro argument
6069 * retrieves the location of the argument.
6071 CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6072 CXIdxClientFile *indexFile,
6079 * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6082 CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6085 * \brief Visitor invoked for each field found by a traversal.
6087 * This visitor function will be invoked for each field found by
6088 * \c clang_Type_visitFields. Its first argument is the cursor being
6089 * visited, its second argument is the client data provided to
6090 * \c clang_Type_visitFields.
6092 * The visitor should return one of the \c CXVisitorResult values
6093 * to direct \c clang_Type_visitFields.
6095 typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6096 CXClientData client_data);
6099 * \brief Visit the fields of a particular type.
6101 * This function visits all the direct fields of the given cursor,
6102 * invoking the given \p visitor function with the cursors of each
6103 * visited field. The traversal may be ended prematurely, if
6104 * the visitor returns \c CXFieldVisit_Break.
6106 * \param T the record type whose field may be visited.
6108 * \param visitor the visitor function that will be invoked for each
6111 * \param client_data pointer data supplied by the client, which will
6112 * be passed to the visitor each time it is invoked.
6114 * \returns a non-zero value if the traversal was terminated
6115 * prematurely by the visitor returning \c CXFieldVisit_Break.
6117 CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6118 CXFieldVisitor visitor,
6119 CXClientData client_data);