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 CLANG_C_INDEX_H
17 #define CLANG_C_INDEX_H
21 #include "clang-c/Platform.h"
22 #include "clang-c/CXString.h"
25 * \brief The version constants for the libclang API.
26 * CINDEX_VERSION_MINOR should increase when there are API additions.
27 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
29 * The policy about the libclang API was always to keep it source and ABI
30 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
32 #define CINDEX_VERSION_MAJOR 0
33 #define CINDEX_VERSION_MINOR 20
35 #define CINDEX_VERSION_ENCODE(major, minor) ( \
39 #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
40 CINDEX_VERSION_MAJOR, \
41 CINDEX_VERSION_MINOR )
43 #define CINDEX_VERSION_STRINGIZE_(major, minor) \
45 #define CINDEX_VERSION_STRINGIZE(major, minor) \
46 CINDEX_VERSION_STRINGIZE_(major, minor)
48 #define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
49 CINDEX_VERSION_MAJOR, \
56 /** \defgroup CINDEX libclang: C Interface to Clang
58 * The C Interface to Clang provides a relatively small API that exposes
59 * facilities for parsing source code into an abstract syntax tree (AST),
60 * loading already-parsed ASTs, traversing the AST, associating
61 * physical source locations with elements within the AST, and other
62 * facilities that support Clang-based development tools.
64 * This C interface to Clang will never provide all of the information
65 * representation stored in Clang's C++ AST, nor should it: the intent is to
66 * maintain an API that is relatively stable from one release to the next,
67 * providing only the basic functionality needed to support development tools.
69 * To avoid namespace pollution, data types are prefixed with "CX" and
70 * functions are prefixed with "clang_".
76 * \brief An "index" that consists of a set of translation units that would
77 * typically be linked together into an executable or library.
79 typedef void *CXIndex;
82 * \brief A single translation unit, which resides in an index.
84 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
87 * \brief Opaque pointer representing client data that will be passed through
88 * to various callbacks and visitors.
90 typedef void *CXClientData;
93 * \brief Provides the contents of a file that has not yet been saved to disk.
95 * Each CXUnsavedFile instance provides the name of a file on the
96 * system along with the current contents of that file that have not
97 * yet been saved to disk.
99 struct CXUnsavedFile {
101 * \brief The file whose contents have not yet been saved.
103 * This file must already exist in the file system.
105 const char *Filename;
108 * \brief A buffer containing the unsaved contents of this file.
110 const char *Contents;
113 * \brief The length of the unsaved contents of this buffer.
115 unsigned long Length;
119 * \brief Describes the availability of a particular entity, which indicates
120 * whether the use of this entity will result in a warning or error due to
121 * it being deprecated or unavailable.
123 enum CXAvailabilityKind {
125 * \brief The entity is available.
127 CXAvailability_Available,
129 * \brief The entity is available, but has been deprecated (and its use is
132 CXAvailability_Deprecated,
134 * \brief The entity is not available; any use of it will be an error.
136 CXAvailability_NotAvailable,
138 * \brief The entity is available, but not accessible; any use of it will be
141 CXAvailability_NotAccessible
145 * \brief Describes a version number of the form major.minor.subminor.
147 typedef struct CXVersion {
149 * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
150 * value indicates that there is no version number at all.
154 * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
155 * will be negative if no minor version number was provided, e.g., for
160 * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
161 * will be negative if no minor or subminor version number was provided,
162 * e.g., in version '10' or '10.7'.
168 * \brief Provides a shared context for creating translation units.
170 * It provides two options:
172 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
173 * declarations (when loading any new translation units). A "local" declaration
174 * is one that belongs in the translation unit itself and not in a precompiled
175 * header that was used by the translation unit. If zero, all declarations
176 * will be enumerated.
178 * Here is an example:
181 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
182 * Idx = clang_createIndex(1, 1);
184 * // IndexTest.pch was produced with the following command:
185 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
186 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
188 * // This will load all the symbols from 'IndexTest.pch'
189 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
190 * TranslationUnitVisitor, 0);
191 * clang_disposeTranslationUnit(TU);
193 * // This will load all the symbols from 'IndexTest.c', excluding symbols
194 * // from 'IndexTest.pch'.
195 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
196 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
198 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
199 * TranslationUnitVisitor, 0);
200 * clang_disposeTranslationUnit(TU);
203 * This process of creating the 'pch', loading it separately, and using it (via
204 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
205 * (which gives the indexer the same performance benefit as the compiler).
207 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
208 int displayDiagnostics);
211 * \brief Destroy the given index.
213 * The index must not be destroyed until all of the translation units created
214 * within that index have been destroyed.
216 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
220 * \brief Used to indicate that no special CXIndex options are needed.
222 CXGlobalOpt_None = 0x0,
225 * \brief Used to indicate that threads that libclang creates for indexing
226 * purposes should use background priority.
228 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
229 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
231 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
234 * \brief Used to indicate that threads that libclang creates for editing
235 * purposes should use background priority.
237 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
238 * #clang_annotateTokens
240 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
243 * \brief Used to indicate that all threads that libclang creates should use
244 * background priority.
246 CXGlobalOpt_ThreadBackgroundPriorityForAll =
247 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
248 CXGlobalOpt_ThreadBackgroundPriorityForEditing
253 * \brief Sets general options associated with a CXIndex.
258 * clang_CXIndex_setGlobalOptions(idx,
259 * clang_CXIndex_getGlobalOptions(idx) |
260 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
263 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
265 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
268 * \brief Gets the general options associated with a CXIndex.
270 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
271 * are associated with the given CXIndex object.
273 CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
276 * \defgroup CINDEX_FILES File manipulation routines
282 * \brief A particular source file that is part of a translation unit.
284 typedef void *CXFile;
288 * \brief Retrieve the complete file and path name of the given file.
290 CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
293 * \brief Retrieve the last modification time of the given file.
295 CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
298 * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
299 * across an indexing session.
302 unsigned long long data[3];
306 * \brief Retrieve the unique ID for the given \c file.
308 * \param file the file to get the ID for.
309 * \param outID stores the returned CXFileUniqueID.
310 * \returns If there was a failure getting the unique ID, returns non-zero,
311 * otherwise returns 0.
313 CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
316 * \brief Determine whether the given header is guarded against
317 * multiple inclusions, either with the conventional
318 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
320 CINDEX_LINKAGE unsigned
321 clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
324 * \brief Retrieve a file handle within the given translation unit.
326 * \param tu the translation unit
328 * \param file_name the name of the file.
330 * \returns the file handle for the named file in the translation unit \p tu,
331 * or a NULL file handle if the file was not a part of this translation unit.
333 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
334 const char *file_name);
341 * \defgroup CINDEX_LOCATIONS Physical source locations
343 * Clang represents physical source locations in its abstract syntax tree in
344 * great detail, with file, line, and column information for the majority of
345 * the tokens parsed in the source code. These data types and functions are
346 * used to represent source location information, either for a particular
347 * point in the program or for a range of points in the program, and extract
348 * specific location information from those data types.
354 * \brief Identifies a specific source location within a translation
357 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
358 * to map a source location to a particular file, line, and column.
361 const void *ptr_data[2];
366 * \brief Identifies a half-open character range in the source code.
368 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
369 * starting and end locations from a source range, respectively.
372 const void *ptr_data[2];
373 unsigned begin_int_data;
374 unsigned end_int_data;
378 * \brief Retrieve a NULL (invalid) source location.
380 CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
383 * \brief Determine whether two source locations, which must refer into
384 * the same translation unit, refer to exactly the same point in the source
387 * \returns non-zero if the source locations refer to the same location, zero
388 * if they refer to different locations.
390 CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
391 CXSourceLocation loc2);
394 * \brief Retrieves the source location associated with a given file/line/column
395 * in a particular translation unit.
397 CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
402 * \brief Retrieves the source location associated with a given character offset
403 * in a particular translation unit.
405 CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
410 * \brief Returns non-zero if the given source location is in a system header.
412 CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
415 * \brief Returns non-zero if the given source location is in the main file of
416 * the corresponding translation unit.
418 CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
421 * \brief Retrieve a NULL (invalid) source range.
423 CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
426 * \brief Retrieve a source range given the beginning and ending source
429 CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
430 CXSourceLocation end);
433 * \brief Determine whether two ranges are equivalent.
435 * \returns non-zero if the ranges are the same, zero if they differ.
437 CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
438 CXSourceRange range2);
441 * \brief Returns non-zero if \p range is null.
443 CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
446 * \brief Retrieve the file, line, column, and offset represented by
447 * the given source location.
449 * If the location refers into a macro expansion, retrieves the
450 * location of the macro expansion.
452 * \param location the location within a source file that will be decomposed
455 * \param file [out] if non-NULL, will be set to the file to which the given
456 * source location points.
458 * \param line [out] if non-NULL, will be set to the line to which the given
459 * source location points.
461 * \param column [out] if non-NULL, will be set to the column to which the given
462 * source location points.
464 * \param offset [out] if non-NULL, will be set to the offset into the
465 * buffer to which the given source location points.
467 CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
474 * \brief Retrieve the file, line, column, and offset represented by
475 * the given source location, as specified in a # line directive.
477 * Example: given the following source code in a file somefile.c
482 * static int func(void)
488 * the location information returned by this function would be
490 * File: dummy.c Line: 124 Column: 12
492 * whereas clang_getExpansionLocation would have returned
494 * File: somefile.c Line: 3 Column: 12
496 * \param location the location within a source file that will be decomposed
499 * \param filename [out] if non-NULL, will be set to the filename of the
500 * source location. Note that filenames returned will be for "virtual" files,
501 * which don't necessarily exist on the machine running clang - e.g. when
502 * parsing preprocessed output obtained from a different environment. If
503 * a non-NULL value is passed in, remember to dispose of the returned value
504 * using \c clang_disposeString() once you've finished with it. For an invalid
505 * source location, an empty string is returned.
507 * \param line [out] if non-NULL, will be set to the line number of the
508 * source location. For an invalid source location, zero is returned.
510 * \param column [out] if non-NULL, will be set to the column number of the
511 * source location. For an invalid source location, zero is returned.
513 CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
519 * \brief Legacy API to retrieve the file, line, column, and offset represented
520 * by the given source location.
522 * This interface has been replaced by the newer interface
523 * #clang_getExpansionLocation(). See that interface's documentation for
526 CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
533 * \brief Retrieve the file, line, column, and offset represented by
534 * the given source location.
536 * If the location refers into a macro instantiation, return where the
537 * location was originally spelled in the source file.
539 * \param location the location within a source file that will be decomposed
542 * \param file [out] if non-NULL, will be set to the file to which the given
543 * source location points.
545 * \param line [out] if non-NULL, will be set to the line to which the given
546 * source location points.
548 * \param column [out] if non-NULL, will be set to the column to which the given
549 * source location points.
551 * \param offset [out] if non-NULL, will be set to the offset into the
552 * buffer to which the given source location points.
554 CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
561 * \brief Retrieve the file, line, column, and offset represented by
562 * the given source location.
564 * If the location refers into a macro expansion, return where the macro was
565 * expanded or where the macro argument was written, if the location points at
568 * \param location the location within a source file that will be decomposed
571 * \param file [out] if non-NULL, will be set to the file to which the given
572 * source location points.
574 * \param line [out] if non-NULL, will be set to the line to which the given
575 * source location points.
577 * \param column [out] if non-NULL, will be set to the column to which the given
578 * source location points.
580 * \param offset [out] if non-NULL, will be set to the offset into the
581 * buffer to which the given source location points.
583 CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
590 * \brief Retrieve a source location representing the first character within a
593 CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
596 * \brief Retrieve a source location representing the last character within a
599 CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
606 * \defgroup CINDEX_DIAG Diagnostic reporting
612 * \brief Describes the severity of a particular diagnostic.
614 enum CXDiagnosticSeverity {
616 * \brief A diagnostic that has been suppressed, e.g., by a command-line
619 CXDiagnostic_Ignored = 0,
622 * \brief This diagnostic is a note that should be attached to the
623 * previous (non-note) diagnostic.
625 CXDiagnostic_Note = 1,
628 * \brief This diagnostic indicates suspicious code that may not be
631 CXDiagnostic_Warning = 2,
634 * \brief This diagnostic indicates that the code is ill-formed.
636 CXDiagnostic_Error = 3,
639 * \brief This diagnostic indicates that the code is ill-formed such
640 * that future parser recovery is unlikely to produce useful
643 CXDiagnostic_Fatal = 4
647 * \brief A single diagnostic, containing the diagnostic's severity,
648 * location, text, source ranges, and fix-it hints.
650 typedef void *CXDiagnostic;
653 * \brief A group of CXDiagnostics.
655 typedef void *CXDiagnosticSet;
658 * \brief Determine the number of diagnostics in a CXDiagnosticSet.
660 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
663 * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
665 * \param Diags the CXDiagnosticSet to query.
666 * \param Index the zero-based diagnostic number to retrieve.
668 * \returns the requested diagnostic. This diagnostic must be freed
669 * via a call to \c clang_disposeDiagnostic().
671 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
676 * \brief Describes the kind of error that occurred (if any) in a call to
677 * \c clang_loadDiagnostics.
679 enum CXLoadDiag_Error {
681 * \brief Indicates that no error occurred.
686 * \brief Indicates that an unknown error occurred while attempting to
687 * deserialize diagnostics.
689 CXLoadDiag_Unknown = 1,
692 * \brief Indicates that the file containing the serialized diagnostics
693 * could not be opened.
695 CXLoadDiag_CannotLoad = 2,
698 * \brief Indicates that the serialized diagnostics file is invalid or
701 CXLoadDiag_InvalidFile = 3
705 * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
708 * \param file The name of the file to deserialize.
709 * \param error A pointer to a enum value recording if there was a problem
710 * deserializing the diagnostics.
711 * \param errorString A pointer to a CXString for recording the error string
712 * if the file was not successfully loaded.
714 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
715 * diagnostics should be released using clang_disposeDiagnosticSet().
717 CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
718 enum CXLoadDiag_Error *error,
719 CXString *errorString);
722 * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
724 CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
727 * \brief Retrieve the child diagnostics of a CXDiagnostic.
729 * This CXDiagnosticSet does not need to be released by
730 * clang_disposeDiagnosticSet.
732 CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
735 * \brief Determine the number of diagnostics produced for the given
738 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
741 * \brief Retrieve a diagnostic associated with the given translation unit.
743 * \param Unit the translation unit to query.
744 * \param Index the zero-based diagnostic number to retrieve.
746 * \returns the requested diagnostic. This diagnostic must be freed
747 * via a call to \c clang_disposeDiagnostic().
749 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
753 * \brief Retrieve the complete set of diagnostics associated with a
756 * \param Unit the translation unit to query.
758 CINDEX_LINKAGE CXDiagnosticSet
759 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
762 * \brief Destroy a diagnostic.
764 CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
767 * \brief Options to control the display of diagnostics.
769 * The values in this enum are meant to be combined to customize the
770 * behavior of \c clang_formatDiagnostic().
772 enum CXDiagnosticDisplayOptions {
774 * \brief Display the source-location information where the
775 * diagnostic was located.
777 * When set, diagnostics will be prefixed by the file, line, and
778 * (optionally) column to which the diagnostic refers. For example,
781 * test.c:28: warning: extra tokens at end of #endif directive
784 * This option corresponds to the clang flag \c -fshow-source-location.
786 CXDiagnostic_DisplaySourceLocation = 0x01,
789 * \brief If displaying the source-location information of the
790 * diagnostic, also include the column number.
792 * This option corresponds to the clang flag \c -fshow-column.
794 CXDiagnostic_DisplayColumn = 0x02,
797 * \brief If displaying the source-location information of the
798 * diagnostic, also include information about source ranges in a
799 * machine-parsable format.
801 * This option corresponds to the clang flag
802 * \c -fdiagnostics-print-source-range-info.
804 CXDiagnostic_DisplaySourceRanges = 0x04,
807 * \brief Display the option name associated with this diagnostic, if any.
809 * The option name displayed (e.g., -Wconversion) will be placed in brackets
810 * after the diagnostic text. This option corresponds to the clang flag
811 * \c -fdiagnostics-show-option.
813 CXDiagnostic_DisplayOption = 0x08,
816 * \brief Display the category number associated with this diagnostic, if any.
818 * The category number is displayed within brackets after the diagnostic text.
819 * This option corresponds to the clang flag
820 * \c -fdiagnostics-show-category=id.
822 CXDiagnostic_DisplayCategoryId = 0x10,
825 * \brief Display the category name associated with this diagnostic, if any.
827 * The category name is displayed within brackets after the diagnostic text.
828 * This option corresponds to the clang flag
829 * \c -fdiagnostics-show-category=name.
831 CXDiagnostic_DisplayCategoryName = 0x20
835 * \brief Format the given diagnostic in a manner that is suitable for display.
837 * This routine will format the given diagnostic to a string, rendering
838 * the diagnostic according to the various options given. The
839 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
840 * options that most closely mimics the behavior of the clang compiler.
842 * \param Diagnostic The diagnostic to print.
844 * \param Options A set of options that control the diagnostic display,
845 * created by combining \c CXDiagnosticDisplayOptions values.
847 * \returns A new string containing for formatted diagnostic.
849 CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
853 * \brief Retrieve the set of display options most similar to the
854 * default behavior of the clang compiler.
856 * \returns A set of display options suitable for use with \c
857 * clang_formatDiagnostic().
859 CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
862 * \brief Determine the severity of the given diagnostic.
864 CINDEX_LINKAGE enum CXDiagnosticSeverity
865 clang_getDiagnosticSeverity(CXDiagnostic);
868 * \brief Retrieve the source location of the given diagnostic.
870 * This location is where Clang would print the caret ('^') when
871 * displaying the diagnostic on the command line.
873 CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
876 * \brief Retrieve the text of the given diagnostic.
878 CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
881 * \brief Retrieve the name of the command-line option that enabled this
884 * \param Diag The diagnostic to be queried.
886 * \param Disable If non-NULL, will be set to the option that disables this
887 * diagnostic (if any).
889 * \returns A string that contains the command-line option used to enable this
890 * warning, such as "-Wconversion" or "-pedantic".
892 CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
896 * \brief Retrieve the category number for this diagnostic.
898 * Diagnostics can be categorized into groups along with other, related
899 * diagnostics (e.g., diagnostics under the same warning flag). This routine
900 * retrieves the category number for the given diagnostic.
902 * \returns The number of the category that contains this diagnostic, or zero
903 * if this diagnostic is uncategorized.
905 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
908 * \brief Retrieve the name of a particular diagnostic category. This
909 * is now deprecated. Use clang_getDiagnosticCategoryText()
912 * \param Category A diagnostic category number, as returned by
913 * \c clang_getDiagnosticCategory().
915 * \returns The name of the given diagnostic category.
917 CINDEX_DEPRECATED CINDEX_LINKAGE
918 CXString clang_getDiagnosticCategoryName(unsigned Category);
921 * \brief Retrieve the diagnostic category text for a given diagnostic.
923 * \returns The text of the given diagnostic category.
925 CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
928 * \brief Determine the number of source ranges associated with the given
931 CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
934 * \brief Retrieve a source range associated with the diagnostic.
936 * A diagnostic's source ranges highlight important elements in the source
937 * code. On the command line, Clang displays source ranges by
938 * underlining them with '~' characters.
940 * \param Diagnostic the diagnostic whose range is being extracted.
942 * \param Range the zero-based index specifying which range to
944 * \returns the requested source range.
946 CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
950 * \brief Determine the number of fix-it hints associated with the
953 CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
956 * \brief Retrieve the replacement information for a given fix-it.
958 * Fix-its are described in terms of a source range whose contents
959 * should be replaced by a string. This approach generalizes over
960 * three kinds of operations: removal of source code (the range covers
961 * the code to be removed and the replacement string is empty),
962 * replacement of source code (the range covers the code to be
963 * replaced and the replacement string provides the new code), and
964 * insertion (both the start and end of the range point at the
965 * insertion location, and the replacement string provides the text to
968 * \param Diagnostic The diagnostic whose fix-its are being queried.
970 * \param FixIt The zero-based index of the fix-it.
972 * \param ReplacementRange The source range whose contents will be
973 * replaced with the returned replacement string. Note that source
974 * ranges are half-open ranges [a, b), so the source code should be
975 * replaced from a and up to (but not including) b.
977 * \returns A string containing text that should be replace the source
978 * code indicated by the \c ReplacementRange.
980 CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
982 CXSourceRange *ReplacementRange);
989 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
991 * The routines in this group provide the ability to create and destroy
992 * translation units from files, either by parsing the contents of the files or
993 * by reading in a serialized representation of a translation unit.
999 * \brief Get the original translation unit source file name.
1001 CINDEX_LINKAGE CXString
1002 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1005 * \brief Return the CXTranslationUnit for a given source file and the provided
1006 * command line arguments one would pass to the compiler.
1008 * Note: The 'source_filename' argument is optional. If the caller provides a
1009 * NULL pointer, the name of the source file is expected to reside in the
1010 * specified command line arguments.
1012 * Note: When encountered in 'clang_command_line_args', the following options
1018 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
1020 * \param CIdx The index object with which the translation unit will be
1023 * \param source_filename The name of the source file to load, or NULL if the
1024 * source file is included in \p clang_command_line_args.
1026 * \param num_clang_command_line_args The number of command-line arguments in
1027 * \p clang_command_line_args.
1029 * \param clang_command_line_args The command-line arguments that would be
1030 * passed to the \c clang executable if it were being invoked out-of-process.
1031 * These command-line options will be parsed and will affect how the translation
1032 * unit is parsed. Note that the following options are ignored: '-c',
1033 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1035 * \param num_unsaved_files the number of unsaved file entries in \p
1038 * \param unsaved_files the files that have not yet been saved to disk
1039 * but may be required for code completion, including the contents of
1040 * those files. The contents and name of these files (as specified by
1041 * CXUnsavedFile) are copied when necessary, so the client only needs to
1042 * guarantee their validity until the call to this function returns.
1044 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1046 const char *source_filename,
1047 int num_clang_command_line_args,
1048 const char * const *clang_command_line_args,
1049 unsigned num_unsaved_files,
1050 struct CXUnsavedFile *unsaved_files);
1053 * \brief Create a translation unit from an AST file (-emit-ast).
1055 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
1056 const char *ast_filename);
1059 * \brief Flags that control the creation of translation units.
1061 * The enumerators in this enumeration type are meant to be bitwise
1062 * ORed together to specify which options should be used when
1063 * constructing the translation unit.
1065 enum CXTranslationUnit_Flags {
1067 * \brief Used to indicate that no special translation-unit options are
1070 CXTranslationUnit_None = 0x0,
1073 * \brief Used to indicate that the parser should construct a "detailed"
1074 * preprocessing record, including all macro definitions and instantiations.
1076 * Constructing a detailed preprocessing record requires more memory
1077 * and time to parse, since the information contained in the record
1078 * is usually not retained. However, it can be useful for
1079 * applications that require more detailed information about the
1080 * behavior of the preprocessor.
1082 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1085 * \brief Used to indicate that the translation unit is incomplete.
1087 * When a translation unit is considered "incomplete", semantic
1088 * analysis that is typically performed at the end of the
1089 * translation unit will be suppressed. For example, this suppresses
1090 * the completion of tentative declarations in C and of
1091 * instantiation of implicitly-instantiation function templates in
1092 * C++. This option is typically used when parsing a header with the
1093 * intent of producing a precompiled header.
1095 CXTranslationUnit_Incomplete = 0x02,
1098 * \brief Used to indicate that the translation unit should be built with an
1099 * implicit precompiled header for the preamble.
1101 * An implicit precompiled header is used as an optimization when a
1102 * particular translation unit is likely to be reparsed many times
1103 * when the sources aren't changing that often. In this case, an
1104 * implicit precompiled header will be built containing all of the
1105 * initial includes at the top of the main file (what we refer to as
1106 * the "preamble" of the file). In subsequent parses, if the
1107 * preamble or the files in it have not changed, \c
1108 * clang_reparseTranslationUnit() will re-use the implicit
1109 * precompiled header to improve parsing performance.
1111 CXTranslationUnit_PrecompiledPreamble = 0x04,
1114 * \brief Used to indicate that the translation unit should cache some
1115 * code-completion results with each reparse of the source file.
1117 * Caching of code-completion results is a performance optimization that
1118 * introduces some overhead to reparsing but improves the performance of
1119 * code-completion operations.
1121 CXTranslationUnit_CacheCompletionResults = 0x08,
1124 * \brief Used to indicate that the translation unit will be serialized with
1125 * \c clang_saveTranslationUnit.
1127 * This option is typically used when parsing a header with the intent of
1128 * producing a precompiled header.
1130 CXTranslationUnit_ForSerialization = 0x10,
1133 * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
1135 * Note: this is a *temporary* option that is available only while
1136 * we are testing C++ precompiled preamble support. It is deprecated.
1138 CXTranslationUnit_CXXChainedPCH = 0x20,
1141 * \brief Used to indicate that function/method bodies should be skipped while
1144 * This option can be used to search for declarations/definitions while
1145 * ignoring the usages.
1147 CXTranslationUnit_SkipFunctionBodies = 0x40,
1150 * \brief Used to indicate that brief documentation comments should be
1151 * included into the set of code completions returned from this translation
1154 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
1158 * \brief Returns the set of flags that is suitable for parsing a translation
1159 * unit that is being edited.
1161 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1162 * to indicate that the translation unit is likely to be reparsed many times,
1163 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1164 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1165 * set contains an unspecified set of optimizations (e.g., the precompiled
1166 * preamble) geared toward improving the performance of these routines. The
1167 * set of optimizations enabled may change from one version to the next.
1169 CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1172 * \brief Parse the given source file and the translation unit corresponding
1175 * This routine is the main entry point for the Clang C API, providing the
1176 * ability to parse a source file into a translation unit that can then be
1177 * queried by other functions in the API. This routine accepts a set of
1178 * command-line arguments so that the compilation can be configured in the same
1179 * way that the compiler is configured on the command line.
1181 * \param CIdx The index object with which the translation unit will be
1184 * \param source_filename The name of the source file to load, or NULL if the
1185 * source file is included in \p command_line_args.
1187 * \param command_line_args The command-line arguments that would be
1188 * passed to the \c clang executable if it were being invoked out-of-process.
1189 * These command-line options will be parsed and will affect how the translation
1190 * unit is parsed. Note that the following options are ignored: '-c',
1191 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1193 * \param num_command_line_args The number of command-line arguments in
1194 * \p command_line_args.
1196 * \param unsaved_files the files that have not yet been saved to disk
1197 * but may be required for parsing, including the contents of
1198 * those files. The contents and name of these files (as specified by
1199 * CXUnsavedFile) are copied when necessary, so the client only needs to
1200 * guarantee their validity until the call to this function returns.
1202 * \param num_unsaved_files the number of unsaved file entries in \p
1205 * \param options A bitmask of options that affects how the translation unit
1206 * is managed but not its compilation. This should be a bitwise OR of the
1207 * CXTranslationUnit_XXX flags.
1209 * \returns A new translation unit describing the parsed code and containing
1210 * any diagnostics produced by the compiler. If there is a failure from which
1211 * the compiler cannot recover, returns NULL.
1213 CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
1214 const char *source_filename,
1215 const char * const *command_line_args,
1216 int num_command_line_args,
1217 struct CXUnsavedFile *unsaved_files,
1218 unsigned num_unsaved_files,
1222 * \brief Flags that control how translation units are saved.
1224 * The enumerators in this enumeration type are meant to be bitwise
1225 * ORed together to specify which options should be used when
1226 * saving the translation unit.
1228 enum CXSaveTranslationUnit_Flags {
1230 * \brief Used to indicate that no special saving options are needed.
1232 CXSaveTranslationUnit_None = 0x0
1236 * \brief Returns the set of flags that is suitable for saving a translation
1239 * The set of flags returned provide options for
1240 * \c clang_saveTranslationUnit() by default. The returned flag
1241 * set contains an unspecified set of options that save translation units with
1242 * the most commonly-requested data.
1244 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1247 * \brief Describes the kind of error that occurred (if any) in a call to
1248 * \c clang_saveTranslationUnit().
1252 * \brief Indicates that no error occurred while saving a translation unit.
1254 CXSaveError_None = 0,
1257 * \brief Indicates that an unknown error occurred while attempting to save
1260 * This error typically indicates that file I/O failed when attempting to
1263 CXSaveError_Unknown = 1,
1266 * \brief Indicates that errors during translation prevented this attempt
1267 * to save the translation unit.
1269 * Errors that prevent the translation unit from being saved can be
1270 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1272 CXSaveError_TranslationErrors = 2,
1275 * \brief Indicates that the translation unit to be saved was somehow
1276 * invalid (e.g., NULL).
1278 CXSaveError_InvalidTU = 3
1282 * \brief Saves a translation unit into a serialized representation of
1283 * that translation unit on disk.
1285 * Any translation unit that was parsed without error can be saved
1286 * into a file. The translation unit can then be deserialized into a
1287 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1288 * if it is an incomplete translation unit that corresponds to a
1289 * header, used as a precompiled header when parsing other translation
1292 * \param TU The translation unit to save.
1294 * \param FileName The file to which the translation unit will be saved.
1296 * \param options A bitmask of options that affects how the translation unit
1297 * is saved. This should be a bitwise OR of the
1298 * CXSaveTranslationUnit_XXX flags.
1300 * \returns A value that will match one of the enumerators of the CXSaveError
1301 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1302 * saved successfully, while a non-zero value indicates that a problem occurred.
1304 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1305 const char *FileName,
1309 * \brief Destroy the specified CXTranslationUnit object.
1311 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1314 * \brief Flags that control the reparsing of translation units.
1316 * The enumerators in this enumeration type are meant to be bitwise
1317 * ORed together to specify which options should be used when
1318 * reparsing the translation unit.
1320 enum CXReparse_Flags {
1322 * \brief Used to indicate that no special reparsing options are needed.
1324 CXReparse_None = 0x0
1328 * \brief Returns the set of flags that is suitable for reparsing a translation
1331 * The set of flags returned provide options for
1332 * \c clang_reparseTranslationUnit() by default. The returned flag
1333 * set contains an unspecified set of optimizations geared toward common uses
1334 * of reparsing. The set of optimizations enabled may change from one version
1337 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1340 * \brief Reparse the source files that produced this translation unit.
1342 * This routine can be used to re-parse the source files that originally
1343 * created the given translation unit, for example because those source files
1344 * have changed (either on disk or as passed via \p unsaved_files). The
1345 * source code will be reparsed with the same command-line options as it
1346 * was originally parsed.
1348 * Reparsing a translation unit invalidates all cursors and source locations
1349 * that refer into that translation unit. This makes reparsing a translation
1350 * unit semantically equivalent to destroying the translation unit and then
1351 * creating a new translation unit with the same command-line arguments.
1352 * However, it may be more efficient to reparse a translation
1353 * unit using this routine.
1355 * \param TU The translation unit whose contents will be re-parsed. The
1356 * translation unit must originally have been built with
1357 * \c clang_createTranslationUnitFromSourceFile().
1359 * \param num_unsaved_files The number of unsaved file entries in \p
1362 * \param unsaved_files The files that have not yet been saved to disk
1363 * but may be required for parsing, including the contents of
1364 * those files. The contents and name of these files (as specified by
1365 * CXUnsavedFile) are copied when necessary, so the client only needs to
1366 * guarantee their validity until the call to this function returns.
1368 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1369 * The function \c clang_defaultReparseOptions() produces a default set of
1370 * options recommended for most uses, based on the translation unit.
1372 * \returns 0 if the sources could be reparsed. A non-zero value will be
1373 * returned if reparsing was impossible, such that the translation unit is
1374 * invalid. In such cases, the only valid call for \p TU is
1375 * \c clang_disposeTranslationUnit(TU).
1377 CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1378 unsigned num_unsaved_files,
1379 struct CXUnsavedFile *unsaved_files,
1383 * \brief Categorizes how memory is being used by a translation unit.
1385 enum CXTUResourceUsageKind {
1386 CXTUResourceUsage_AST = 1,
1387 CXTUResourceUsage_Identifiers = 2,
1388 CXTUResourceUsage_Selectors = 3,
1389 CXTUResourceUsage_GlobalCompletionResults = 4,
1390 CXTUResourceUsage_SourceManagerContentCache = 5,
1391 CXTUResourceUsage_AST_SideTables = 6,
1392 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1393 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1394 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1395 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1396 CXTUResourceUsage_Preprocessor = 11,
1397 CXTUResourceUsage_PreprocessingRecord = 12,
1398 CXTUResourceUsage_SourceManager_DataStructures = 13,
1399 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1400 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1401 CXTUResourceUsage_MEMORY_IN_BYTES_END =
1402 CXTUResourceUsage_Preprocessor_HeaderSearch,
1404 CXTUResourceUsage_First = CXTUResourceUsage_AST,
1405 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1409 * \brief Returns the human-readable null-terminated C string that represents
1410 * the name of the memory category. This string should never be freed.
1413 const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1415 typedef struct CXTUResourceUsageEntry {
1416 /* \brief The memory usage category. */
1417 enum CXTUResourceUsageKind kind;
1418 /* \brief Amount of resources used.
1419 The units will depend on the resource kind. */
1420 unsigned long amount;
1421 } CXTUResourceUsageEntry;
1424 * \brief The memory usage of a CXTranslationUnit, broken into categories.
1426 typedef struct CXTUResourceUsage {
1427 /* \brief Private data member, used for queries. */
1430 /* \brief The number of entries in the 'entries' array. */
1431 unsigned numEntries;
1433 /* \brief An array of key-value pairs, representing the breakdown of memory
1435 CXTUResourceUsageEntry *entries;
1437 } CXTUResourceUsage;
1440 * \brief Return the memory usage of a translation unit. This object
1441 * should be released with clang_disposeCXTUResourceUsage().
1443 CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1445 CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1452 * \brief Describes the kind of entity that a cursor refers to.
1457 * \brief A declaration whose specific kind is not exposed via this
1460 * Unexposed declarations have the same operations as any other kind
1461 * of declaration; one can extract their location information,
1462 * spelling, find their definitions, etc. However, the specific kind
1463 * of the declaration is not reported.
1465 CXCursor_UnexposedDecl = 1,
1466 /** \brief A C or C++ struct. */
1467 CXCursor_StructDecl = 2,
1468 /** \brief A C or C++ union. */
1469 CXCursor_UnionDecl = 3,
1470 /** \brief A C++ class. */
1471 CXCursor_ClassDecl = 4,
1472 /** \brief An enumeration. */
1473 CXCursor_EnumDecl = 5,
1475 * \brief A field (in C) or non-static data member (in C++) in a
1476 * struct, union, or C++ class.
1478 CXCursor_FieldDecl = 6,
1479 /** \brief An enumerator constant. */
1480 CXCursor_EnumConstantDecl = 7,
1481 /** \brief A function. */
1482 CXCursor_FunctionDecl = 8,
1483 /** \brief A variable. */
1484 CXCursor_VarDecl = 9,
1485 /** \brief A function or method parameter. */
1486 CXCursor_ParmDecl = 10,
1487 /** \brief An Objective-C \@interface. */
1488 CXCursor_ObjCInterfaceDecl = 11,
1489 /** \brief An Objective-C \@interface for a category. */
1490 CXCursor_ObjCCategoryDecl = 12,
1491 /** \brief An Objective-C \@protocol declaration. */
1492 CXCursor_ObjCProtocolDecl = 13,
1493 /** \brief An Objective-C \@property declaration. */
1494 CXCursor_ObjCPropertyDecl = 14,
1495 /** \brief An Objective-C instance variable. */
1496 CXCursor_ObjCIvarDecl = 15,
1497 /** \brief An Objective-C instance method. */
1498 CXCursor_ObjCInstanceMethodDecl = 16,
1499 /** \brief An Objective-C class method. */
1500 CXCursor_ObjCClassMethodDecl = 17,
1501 /** \brief An Objective-C \@implementation. */
1502 CXCursor_ObjCImplementationDecl = 18,
1503 /** \brief An Objective-C \@implementation for a category. */
1504 CXCursor_ObjCCategoryImplDecl = 19,
1505 /** \brief A typedef */
1506 CXCursor_TypedefDecl = 20,
1507 /** \brief A C++ class method. */
1508 CXCursor_CXXMethod = 21,
1509 /** \brief A C++ namespace. */
1510 CXCursor_Namespace = 22,
1511 /** \brief A linkage specification, e.g. 'extern "C"'. */
1512 CXCursor_LinkageSpec = 23,
1513 /** \brief A C++ constructor. */
1514 CXCursor_Constructor = 24,
1515 /** \brief A C++ destructor. */
1516 CXCursor_Destructor = 25,
1517 /** \brief A C++ conversion function. */
1518 CXCursor_ConversionFunction = 26,
1519 /** \brief A C++ template type parameter. */
1520 CXCursor_TemplateTypeParameter = 27,
1521 /** \brief A C++ non-type template parameter. */
1522 CXCursor_NonTypeTemplateParameter = 28,
1523 /** \brief A C++ template template parameter. */
1524 CXCursor_TemplateTemplateParameter = 29,
1525 /** \brief A C++ function template. */
1526 CXCursor_FunctionTemplate = 30,
1527 /** \brief A C++ class template. */
1528 CXCursor_ClassTemplate = 31,
1529 /** \brief A C++ class template partial specialization. */
1530 CXCursor_ClassTemplatePartialSpecialization = 32,
1531 /** \brief A C++ namespace alias declaration. */
1532 CXCursor_NamespaceAlias = 33,
1533 /** \brief A C++ using directive. */
1534 CXCursor_UsingDirective = 34,
1535 /** \brief A C++ using declaration. */
1536 CXCursor_UsingDeclaration = 35,
1537 /** \brief A C++ alias declaration */
1538 CXCursor_TypeAliasDecl = 36,
1539 /** \brief An Objective-C \@synthesize definition. */
1540 CXCursor_ObjCSynthesizeDecl = 37,
1541 /** \brief An Objective-C \@dynamic definition. */
1542 CXCursor_ObjCDynamicDecl = 38,
1543 /** \brief An access specifier. */
1544 CXCursor_CXXAccessSpecifier = 39,
1546 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1547 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
1550 CXCursor_FirstRef = 40, /* Decl references */
1551 CXCursor_ObjCSuperClassRef = 40,
1552 CXCursor_ObjCProtocolRef = 41,
1553 CXCursor_ObjCClassRef = 42,
1555 * \brief A reference to a type declaration.
1557 * A type reference occurs anywhere where a type is named but not
1558 * declared. For example, given:
1561 * typedef unsigned size_type;
1565 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1566 * while the type of the variable "size" is referenced. The cursor
1567 * referenced by the type of size is the typedef for size_type.
1569 CXCursor_TypeRef = 43,
1570 CXCursor_CXXBaseSpecifier = 44,
1572 * \brief A reference to a class template, function template, template
1573 * template parameter, or class template partial specialization.
1575 CXCursor_TemplateRef = 45,
1577 * \brief A reference to a namespace or namespace alias.
1579 CXCursor_NamespaceRef = 46,
1581 * \brief A reference to a member of a struct, union, or class that occurs in
1582 * some non-expression context, e.g., a designated initializer.
1584 CXCursor_MemberRef = 47,
1586 * \brief A reference to a labeled statement.
1588 * This cursor kind is used to describe the jump to "start_over" in the
1589 * goto statement in the following example:
1598 * A label reference cursor refers to a label statement.
1600 CXCursor_LabelRef = 48,
1603 * \brief A reference to a set of overloaded functions or function templates
1604 * that has not yet been resolved to a specific function or function template.
1606 * An overloaded declaration reference cursor occurs in C++ templates where
1607 * a dependent name refers to a function. For example:
1610 * template<typename T> void swap(T&, T&);
1613 * void swap(X&, X&);
1615 * template<typename T>
1616 * void reverse(T* first, T* last) {
1617 * while (first < last - 1) {
1618 * swap(*first, *--last);
1624 * void swap(Y&, Y&);
1627 * Here, the identifier "swap" is associated with an overloaded declaration
1628 * reference. In the template definition, "swap" refers to either of the two
1629 * "swap" functions declared above, so both results will be available. At
1630 * instantiation time, "swap" may also refer to other functions found via
1631 * argument-dependent lookup (e.g., the "swap" function at the end of the
1634 * The functions \c clang_getNumOverloadedDecls() and
1635 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1636 * referenced by this cursor.
1638 CXCursor_OverloadedDeclRef = 49,
1641 * \brief A reference to a variable that occurs in some non-expression
1642 * context, e.g., a C++ lambda capture list.
1644 CXCursor_VariableRef = 50,
1646 CXCursor_LastRef = CXCursor_VariableRef,
1648 /* Error conditions */
1649 CXCursor_FirstInvalid = 70,
1650 CXCursor_InvalidFile = 70,
1651 CXCursor_NoDeclFound = 71,
1652 CXCursor_NotImplemented = 72,
1653 CXCursor_InvalidCode = 73,
1654 CXCursor_LastInvalid = CXCursor_InvalidCode,
1657 CXCursor_FirstExpr = 100,
1660 * \brief An expression whose specific kind is not exposed via this
1663 * Unexposed expressions have the same operations as any other kind
1664 * of expression; one can extract their location information,
1665 * spelling, children, etc. However, the specific kind of the
1666 * expression is not reported.
1668 CXCursor_UnexposedExpr = 100,
1671 * \brief An expression that refers to some value declaration, such
1672 * as a function, varible, or enumerator.
1674 CXCursor_DeclRefExpr = 101,
1677 * \brief An expression that refers to a member of a struct, union,
1678 * class, Objective-C class, etc.
1680 CXCursor_MemberRefExpr = 102,
1682 /** \brief An expression that calls a function. */
1683 CXCursor_CallExpr = 103,
1685 /** \brief An expression that sends a message to an Objective-C
1687 CXCursor_ObjCMessageExpr = 104,
1689 /** \brief An expression that represents a block literal. */
1690 CXCursor_BlockExpr = 105,
1692 /** \brief An integer literal.
1694 CXCursor_IntegerLiteral = 106,
1696 /** \brief A floating point number literal.
1698 CXCursor_FloatingLiteral = 107,
1700 /** \brief An imaginary number literal.
1702 CXCursor_ImaginaryLiteral = 108,
1704 /** \brief A string literal.
1706 CXCursor_StringLiteral = 109,
1708 /** \brief A character literal.
1710 CXCursor_CharacterLiteral = 110,
1712 /** \brief A parenthesized expression, e.g. "(1)".
1714 * This AST node is only formed if full location information is requested.
1716 CXCursor_ParenExpr = 111,
1718 /** \brief This represents the unary-expression's (except sizeof and
1721 CXCursor_UnaryOperator = 112,
1723 /** \brief [C99 6.5.2.1] Array Subscripting.
1725 CXCursor_ArraySubscriptExpr = 113,
1727 /** \brief A builtin binary operation expression such as "x + y" or
1730 CXCursor_BinaryOperator = 114,
1732 /** \brief Compound assignment such as "+=".
1734 CXCursor_CompoundAssignOperator = 115,
1736 /** \brief The ?: ternary operator.
1738 CXCursor_ConditionalOperator = 116,
1740 /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1741 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1743 * For example: (int)f.
1745 CXCursor_CStyleCastExpr = 117,
1747 /** \brief [C99 6.5.2.5]
1749 CXCursor_CompoundLiteralExpr = 118,
1751 /** \brief Describes an C or C++ initializer list.
1753 CXCursor_InitListExpr = 119,
1755 /** \brief The GNU address of label extension, representing &&label.
1757 CXCursor_AddrLabelExpr = 120,
1759 /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1761 CXCursor_StmtExpr = 121,
1763 /** \brief Represents a C11 generic selection.
1765 CXCursor_GenericSelectionExpr = 122,
1767 /** \brief Implements the GNU __null extension, which is a name for a null
1768 * pointer constant that has integral type (e.g., int or long) and is the same
1769 * size and alignment as a pointer.
1771 * The __null extension is typically only used by system headers, which define
1772 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1773 * match the size of a pointer).
1775 CXCursor_GNUNullExpr = 123,
1777 /** \brief C++'s static_cast<> expression.
1779 CXCursor_CXXStaticCastExpr = 124,
1781 /** \brief C++'s dynamic_cast<> expression.
1783 CXCursor_CXXDynamicCastExpr = 125,
1785 /** \brief C++'s reinterpret_cast<> expression.
1787 CXCursor_CXXReinterpretCastExpr = 126,
1789 /** \brief C++'s const_cast<> expression.
1791 CXCursor_CXXConstCastExpr = 127,
1793 /** \brief Represents an explicit C++ type conversion that uses "functional"
1794 * notion (C++ [expr.type.conv]).
1801 CXCursor_CXXFunctionalCastExpr = 128,
1803 /** \brief A C++ typeid expression (C++ [expr.typeid]).
1805 CXCursor_CXXTypeidExpr = 129,
1807 /** \brief [C++ 2.13.5] C++ Boolean Literal.
1809 CXCursor_CXXBoolLiteralExpr = 130,
1811 /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1813 CXCursor_CXXNullPtrLiteralExpr = 131,
1815 /** \brief Represents the "this" expression in C++
1817 CXCursor_CXXThisExpr = 132,
1819 /** \brief [C++ 15] C++ Throw Expression.
1821 * This handles 'throw' and 'throw' assignment-expression. When
1822 * assignment-expression isn't present, Op will be null.
1824 CXCursor_CXXThrowExpr = 133,
1826 /** \brief A new expression for memory allocation and constructor calls, e.g:
1827 * "new CXXNewExpr(foo)".
1829 CXCursor_CXXNewExpr = 134,
1831 /** \brief A delete expression for memory deallocation and destructor calls,
1832 * e.g. "delete[] pArray".
1834 CXCursor_CXXDeleteExpr = 135,
1836 /** \brief A unary expression.
1838 CXCursor_UnaryExpr = 136,
1840 /** \brief An Objective-C string literal i.e. @"foo".
1842 CXCursor_ObjCStringLiteral = 137,
1844 /** \brief An Objective-C \@encode expression.
1846 CXCursor_ObjCEncodeExpr = 138,
1848 /** \brief An Objective-C \@selector expression.
1850 CXCursor_ObjCSelectorExpr = 139,
1852 /** \brief An Objective-C \@protocol expression.
1854 CXCursor_ObjCProtocolExpr = 140,
1856 /** \brief An Objective-C "bridged" cast expression, which casts between
1857 * Objective-C pointers and C pointers, transferring ownership in the process.
1860 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
1863 CXCursor_ObjCBridgedCastExpr = 141,
1865 /** \brief Represents a C++0x pack expansion that produces a sequence of
1868 * A pack expansion expression contains a pattern (which itself is an
1869 * expression) followed by an ellipsis. For example:
1872 * template<typename F, typename ...Types>
1873 * void forward(F f, Types &&...args) {
1874 * f(static_cast<Types&&>(args)...);
1878 CXCursor_PackExpansionExpr = 142,
1880 /** \brief Represents an expression that computes the length of a parameter
1884 * template<typename ...Types>
1886 * static const unsigned value = sizeof...(Types);
1890 CXCursor_SizeOfPackExpr = 143,
1892 /* \brief Represents a C++ lambda expression that produces a local function
1896 * void abssort(float *x, unsigned N) {
1897 * std::sort(x, x + N,
1898 * [](float a, float b) {
1899 * return std::abs(a) < std::abs(b);
1904 CXCursor_LambdaExpr = 144,
1906 /** \brief Objective-c Boolean Literal.
1908 CXCursor_ObjCBoolLiteralExpr = 145,
1910 /** \brief Represents the "self" expression in a ObjC method.
1912 CXCursor_ObjCSelfExpr = 146,
1914 CXCursor_LastExpr = CXCursor_ObjCSelfExpr,
1917 CXCursor_FirstStmt = 200,
1919 * \brief A statement whose specific kind is not exposed via this
1922 * Unexposed statements have the same operations as any other kind of
1923 * statement; one can extract their location information, spelling,
1924 * children, etc. However, the specific kind of the statement is not
1927 CXCursor_UnexposedStmt = 200,
1929 /** \brief A labelled statement in a function.
1931 * This cursor kind is used to describe the "start_over:" label statement in
1932 * the following example:
1940 CXCursor_LabelStmt = 201,
1942 /** \brief A group of statements like { stmt stmt }.
1944 * This cursor kind is used to describe compound statements, e.g. function
1947 CXCursor_CompoundStmt = 202,
1949 /** \brief A case statement.
1951 CXCursor_CaseStmt = 203,
1953 /** \brief A default statement.
1955 CXCursor_DefaultStmt = 204,
1957 /** \brief An if statement
1959 CXCursor_IfStmt = 205,
1961 /** \brief A switch statement.
1963 CXCursor_SwitchStmt = 206,
1965 /** \brief A while statement.
1967 CXCursor_WhileStmt = 207,
1969 /** \brief A do statement.
1971 CXCursor_DoStmt = 208,
1973 /** \brief A for statement.
1975 CXCursor_ForStmt = 209,
1977 /** \brief A goto statement.
1979 CXCursor_GotoStmt = 210,
1981 /** \brief An indirect goto statement.
1983 CXCursor_IndirectGotoStmt = 211,
1985 /** \brief A continue statement.
1987 CXCursor_ContinueStmt = 212,
1989 /** \brief A break statement.
1991 CXCursor_BreakStmt = 213,
1993 /** \brief A return statement.
1995 CXCursor_ReturnStmt = 214,
1997 /** \brief A GCC inline assembly statement extension.
1999 CXCursor_GCCAsmStmt = 215,
2000 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
2002 /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
2004 CXCursor_ObjCAtTryStmt = 216,
2006 /** \brief Objective-C's \@catch statement.
2008 CXCursor_ObjCAtCatchStmt = 217,
2010 /** \brief Objective-C's \@finally statement.
2012 CXCursor_ObjCAtFinallyStmt = 218,
2014 /** \brief Objective-C's \@throw statement.
2016 CXCursor_ObjCAtThrowStmt = 219,
2018 /** \brief Objective-C's \@synchronized statement.
2020 CXCursor_ObjCAtSynchronizedStmt = 220,
2022 /** \brief Objective-C's autorelease pool statement.
2024 CXCursor_ObjCAutoreleasePoolStmt = 221,
2026 /** \brief Objective-C's collection statement.
2028 CXCursor_ObjCForCollectionStmt = 222,
2030 /** \brief C++'s catch statement.
2032 CXCursor_CXXCatchStmt = 223,
2034 /** \brief C++'s try statement.
2036 CXCursor_CXXTryStmt = 224,
2038 /** \brief C++'s for (* : *) statement.
2040 CXCursor_CXXForRangeStmt = 225,
2042 /** \brief Windows Structured Exception Handling's try statement.
2044 CXCursor_SEHTryStmt = 226,
2046 /** \brief Windows Structured Exception Handling's except statement.
2048 CXCursor_SEHExceptStmt = 227,
2050 /** \brief Windows Structured Exception Handling's finally statement.
2052 CXCursor_SEHFinallyStmt = 228,
2054 /** \brief A MS inline assembly statement extension.
2056 CXCursor_MSAsmStmt = 229,
2058 /** \brief The null satement ";": C99 6.8.3p3.
2060 * This cursor kind is used to describe the null statement.
2062 CXCursor_NullStmt = 230,
2064 /** \brief Adaptor class for mixing declarations with statements and
2067 CXCursor_DeclStmt = 231,
2069 /** \brief OpenMP parallel directive.
2071 CXCursor_OMPParallelDirective = 232,
2073 CXCursor_LastStmt = CXCursor_OMPParallelDirective,
2076 * \brief Cursor that represents the translation unit itself.
2078 * The translation unit cursor exists primarily to act as the root
2079 * cursor for traversing the contents of a translation unit.
2081 CXCursor_TranslationUnit = 300,
2084 CXCursor_FirstAttr = 400,
2086 * \brief An attribute whose specific kind is not exposed via this
2089 CXCursor_UnexposedAttr = 400,
2091 CXCursor_IBActionAttr = 401,
2092 CXCursor_IBOutletAttr = 402,
2093 CXCursor_IBOutletCollectionAttr = 403,
2094 CXCursor_CXXFinalAttr = 404,
2095 CXCursor_CXXOverrideAttr = 405,
2096 CXCursor_AnnotateAttr = 406,
2097 CXCursor_AsmLabelAttr = 407,
2098 CXCursor_PackedAttr = 408,
2099 CXCursor_LastAttr = CXCursor_PackedAttr,
2102 CXCursor_PreprocessingDirective = 500,
2103 CXCursor_MacroDefinition = 501,
2104 CXCursor_MacroExpansion = 502,
2105 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2106 CXCursor_InclusionDirective = 503,
2107 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2108 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2110 /* Extra Declarations */
2112 * \brief A module import declaration.
2114 CXCursor_ModuleImportDecl = 600,
2115 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2116 CXCursor_LastExtraDecl = CXCursor_ModuleImportDecl
2120 * \brief A cursor representing some element in the abstract syntax tree for
2121 * a translation unit.
2123 * The cursor abstraction unifies the different kinds of entities in a
2124 * program--declaration, statements, expressions, references to declarations,
2125 * etc.--under a single "cursor" abstraction with a common set of operations.
2126 * Common operation for a cursor include: getting the physical location in
2127 * a source file where the cursor points, getting the name associated with a
2128 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2130 * Cursors can be produced in two specific ways.
2131 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2132 * from which one can use clang_visitChildren() to explore the rest of the
2133 * translation unit. clang_getCursor() maps from a physical source location
2134 * to the entity that resides at that location, allowing one to map from the
2135 * source code into the AST.
2138 enum CXCursorKind kind;
2140 const void *data[3];
2144 * \brief A comment AST node.
2147 const void *ASTNode;
2148 CXTranslationUnit TranslationUnit;
2152 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2158 * \brief Retrieve the NULL cursor, which represents no entity.
2160 CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2163 * \brief Retrieve the cursor that represents the given translation unit.
2165 * The translation unit cursor can be used to start traversing the
2166 * various declarations within the given translation unit.
2168 CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2171 * \brief Determine whether two cursors are equivalent.
2173 CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2176 * \brief Returns non-zero if \p cursor is null.
2178 CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2181 * \brief Compute a hash value for the given cursor.
2183 CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2186 * \brief Retrieve the kind of the given cursor.
2188 CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2191 * \brief Determine whether the given cursor kind represents a declaration.
2193 CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2196 * \brief Determine whether the given cursor kind represents a simple
2199 * Note that other kinds of cursors (such as expressions) can also refer to
2200 * other cursors. Use clang_getCursorReferenced() to determine whether a
2201 * particular cursor refers to another entity.
2203 CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2206 * \brief Determine whether the given cursor kind represents an expression.
2208 CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2211 * \brief Determine whether the given cursor kind represents a statement.
2213 CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2216 * \brief Determine whether the given cursor kind represents an attribute.
2218 CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2221 * \brief Determine whether the given cursor kind represents an invalid
2224 CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2227 * \brief Determine whether the given cursor kind represents a translation
2230 CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2233 * \brief Determine whether the given cursor represents a preprocessing
2234 * element, such as a preprocessor directive or macro instantiation.
2236 CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2239 * \brief Determine whether the given cursor represents a currently
2240 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2242 CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2245 * \brief Describe the linkage of the entity referred to by a cursor.
2247 enum CXLinkageKind {
2248 /** \brief This value indicates that no linkage information is available
2249 * for a provided CXCursor. */
2252 * \brief This is the linkage for variables, parameters, and so on that
2253 * have automatic storage. This covers normal (non-extern) local variables.
2255 CXLinkage_NoLinkage,
2256 /** \brief This is the linkage for static variables and static functions. */
2258 /** \brief This is the linkage for entities with external linkage that live
2259 * in C++ anonymous namespaces.*/
2260 CXLinkage_UniqueExternal,
2261 /** \brief This is the linkage for entities with true, external linkage. */
2266 * \brief Determine the linkage of the entity referred to by a given cursor.
2268 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2271 * \brief Determine the availability of the entity that this cursor refers to,
2272 * taking the current target platform into account.
2274 * \param cursor The cursor to query.
2276 * \returns The availability of the cursor.
2278 CINDEX_LINKAGE enum CXAvailabilityKind
2279 clang_getCursorAvailability(CXCursor cursor);
2282 * Describes the availability of a given entity on a particular platform, e.g.,
2283 * a particular class might only be available on Mac OS 10.7 or newer.
2285 typedef struct CXPlatformAvailability {
2287 * \brief A string that describes the platform for which this structure
2288 * provides availability information.
2290 * Possible values are "ios" or "macosx".
2294 * \brief The version number in which this entity was introduced.
2296 CXVersion Introduced;
2298 * \brief The version number in which this entity was deprecated (but is
2301 CXVersion Deprecated;
2303 * \brief The version number in which this entity was obsoleted, and therefore
2304 * is no longer available.
2306 CXVersion Obsoleted;
2308 * \brief Whether the entity is unconditionally unavailable on this platform.
2312 * \brief An optional message to provide to a user of this API, e.g., to
2313 * suggest replacement APIs.
2316 } CXPlatformAvailability;
2319 * \brief Determine the availability of the entity that this cursor refers to
2320 * on any platforms for which availability information is known.
2322 * \param cursor The cursor to query.
2324 * \param always_deprecated If non-NULL, will be set to indicate whether the
2325 * entity is deprecated on all platforms.
2327 * \param deprecated_message If non-NULL, will be set to the message text
2328 * provided along with the unconditional deprecation of this entity. The client
2329 * is responsible for deallocating this string.
2331 * \param always_unavailable If non-NULL, will be set to indicate whether the
2332 * entity is unavailable on all platforms.
2334 * \param unavailable_message If non-NULL, will be set to the message text
2335 * provided along with the unconditional unavailability of this entity. The
2336 * client is responsible for deallocating this string.
2338 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2339 * that will be populated with platform availability information, up to either
2340 * the number of platforms for which availability information is available (as
2341 * returned by this function) or \c availability_size, whichever is smaller.
2343 * \param availability_size The number of elements available in the
2344 * \c availability array.
2346 * \returns The number of platforms (N) for which availability information is
2347 * available (which is unrelated to \c availability_size).
2349 * Note that the client is responsible for calling
2350 * \c clang_disposeCXPlatformAvailability to free each of the
2351 * platform-availability structures returned. There are
2352 * \c min(N, availability_size) such structures.
2355 clang_getCursorPlatformAvailability(CXCursor cursor,
2356 int *always_deprecated,
2357 CXString *deprecated_message,
2358 int *always_unavailable,
2359 CXString *unavailable_message,
2360 CXPlatformAvailability *availability,
2361 int availability_size);
2364 * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2367 clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2370 * \brief Describe the "language" of the entity referred to by a cursor.
2372 CINDEX_LINKAGE enum CXLanguageKind {
2373 CXLanguage_Invalid = 0,
2376 CXLanguage_CPlusPlus
2380 * \brief Determine the "language" of the entity referred to by a given cursor.
2382 CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2385 * \brief Returns the translation unit that a cursor originated from.
2387 CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2391 * \brief A fast container representing a set of CXCursors.
2393 typedef struct CXCursorSetImpl *CXCursorSet;
2396 * \brief Creates an empty CXCursorSet.
2398 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2401 * \brief Disposes a CXCursorSet and releases its associated memory.
2403 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2406 * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2408 * \returns non-zero if the set contains the specified cursor.
2410 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2414 * \brief Inserts a CXCursor into a CXCursorSet.
2416 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2418 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2422 * \brief Determine the semantic parent of the given cursor.
2424 * The semantic parent of a cursor is the cursor that semantically contains
2425 * the given \p cursor. For many declarations, the lexical and semantic parents
2426 * are equivalent (the lexical parent is returned by
2427 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2428 * definitions are provided out-of-line. For example:
2438 * In the out-of-line definition of \c C::f, the semantic parent is the
2439 * the class \c C, of which this function is a member. The lexical parent is
2440 * the place where the declaration actually occurs in the source code; in this
2441 * case, the definition occurs in the translation unit. In general, the
2442 * lexical parent for a given entity can change without affecting the semantics
2443 * of the program, and the lexical parent of different declarations of the
2444 * same entity may be different. Changing the semantic parent of a declaration,
2445 * on the other hand, can have a major impact on semantics, and redeclarations
2446 * of a particular entity should all have the same semantic context.
2448 * In the example above, both declarations of \c C::f have \c C as their
2449 * semantic context, while the lexical context of the first \c C::f is \c C
2450 * and the lexical context of the second \c C::f is the translation unit.
2452 * For global declarations, the semantic parent is the translation unit.
2454 CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2457 * \brief Determine the lexical parent of the given cursor.
2459 * The lexical parent of a cursor is the cursor in which the given \p cursor
2460 * was actually written. For many declarations, the lexical and semantic parents
2461 * are equivalent (the semantic parent is returned by
2462 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2463 * definitions are provided out-of-line. For example:
2473 * In the out-of-line definition of \c C::f, the semantic parent is the
2474 * the class \c C, of which this function is a member. The lexical parent is
2475 * the place where the declaration actually occurs in the source code; in this
2476 * case, the definition occurs in the translation unit. In general, the
2477 * lexical parent for a given entity can change without affecting the semantics
2478 * of the program, and the lexical parent of different declarations of the
2479 * same entity may be different. Changing the semantic parent of a declaration,
2480 * on the other hand, can have a major impact on semantics, and redeclarations
2481 * of a particular entity should all have the same semantic context.
2483 * In the example above, both declarations of \c C::f have \c C as their
2484 * semantic context, while the lexical context of the first \c C::f is \c C
2485 * and the lexical context of the second \c C::f is the translation unit.
2487 * For declarations written in the global scope, the lexical parent is
2488 * the translation unit.
2490 CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2493 * \brief Determine the set of methods that are overridden by the given
2496 * In both Objective-C and C++, a method (aka virtual member function,
2497 * in C++) can override a virtual method in a base class. For
2498 * Objective-C, a method is said to override any method in the class's
2499 * base class, its protocols, or its categories' protocols, that has the same
2500 * selector and is of the same kind (class or instance).
2501 * If no such method exists, the search continues to the class's superclass,
2502 * its protocols, and its categories, and so on. A method from an Objective-C
2503 * implementation is considered to override the same methods as its
2504 * corresponding method in the interface.
2506 * For C++, a virtual member function overrides any virtual member
2507 * function with the same signature that occurs in its base
2508 * classes. With multiple inheritance, a virtual member function can
2509 * override several virtual member functions coming from different
2512 * In all cases, this function determines the immediate overridden
2513 * method, rather than all of the overridden methods. For example, if
2514 * a method is originally declared in a class A, then overridden in B
2515 * (which in inherits from A) and also in C (which inherited from B),
2516 * then the only overridden method returned from this function when
2517 * invoked on C's method will be B's method. The client may then
2518 * invoke this function again, given the previously-found overridden
2519 * methods, to map out the complete method-override set.
2521 * \param cursor A cursor representing an Objective-C or C++
2522 * method. This routine will compute the set of methods that this
2525 * \param overridden A pointer whose pointee will be replaced with a
2526 * pointer to an array of cursors, representing the set of overridden
2527 * methods. If there are no overridden methods, the pointee will be
2528 * set to NULL. The pointee must be freed via a call to
2529 * \c clang_disposeOverriddenCursors().
2531 * \param num_overridden A pointer to the number of overridden
2532 * functions, will be set to the number of overridden functions in the
2533 * array pointed to by \p overridden.
2535 CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2536 CXCursor **overridden,
2537 unsigned *num_overridden);
2540 * \brief Free the set of overridden cursors returned by \c
2541 * clang_getOverriddenCursors().
2543 CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2546 * \brief Retrieve the file that is included by the given inclusion directive
2549 CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2556 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2558 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2559 * routines help map between cursors and the physical locations where the
2560 * described entities occur in the source code. The mapping is provided in
2561 * both directions, so one can map from source code to the AST and back.
2567 * \brief Map a source location to the cursor that describes the entity at that
2568 * location in the source code.
2570 * clang_getCursor() maps an arbitrary source location within a translation
2571 * unit down to the most specific cursor that describes the entity at that
2572 * location. For example, given an expression \c x + y, invoking
2573 * clang_getCursor() with a source location pointing to "x" will return the
2574 * cursor for "x"; similarly for "y". If the cursor points anywhere between
2575 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2576 * will return a cursor referring to the "+" expression.
2578 * \returns a cursor representing the entity at the given source location, or
2579 * a NULL cursor if no such entity can be found.
2581 CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2584 * \brief Retrieve the physical location of the source constructor referenced
2585 * by the given cursor.
2587 * The location of a declaration is typically the location of the name of that
2588 * declaration, where the name of that declaration would occur if it is
2589 * unnamed, or some keyword that introduces that particular declaration.
2590 * The location of a reference is where that reference occurs within the
2593 CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2596 * \brief Retrieve the physical extent of the source construct referenced by
2599 * The extent of a cursor starts with the file/line/column pointing at the
2600 * first character within the source construct that the cursor refers to and
2601 * ends with the last character withinin that source construct. For a
2602 * declaration, the extent covers the declaration itself. For a reference,
2603 * the extent covers the location of the reference (e.g., where the referenced
2604 * entity was actually used).
2606 CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
2613 * \defgroup CINDEX_TYPES Type information for CXCursors
2619 * \brief Describes the kind of type
2623 * \brief Reprents an invalid type (e.g., where no type is available).
2628 * \brief A type whose specific kind is not exposed via this
2631 CXType_Unexposed = 1,
2643 CXType_ULongLong = 11,
2644 CXType_UInt128 = 12,
2651 CXType_LongLong = 19,
2655 CXType_LongDouble = 23,
2656 CXType_NullPtr = 24,
2657 CXType_Overload = 25,
2658 CXType_Dependent = 26,
2660 CXType_ObjCClass = 28,
2661 CXType_ObjCSel = 29,
2662 CXType_FirstBuiltin = CXType_Void,
2663 CXType_LastBuiltin = CXType_ObjCSel,
2665 CXType_Complex = 100,
2666 CXType_Pointer = 101,
2667 CXType_BlockPointer = 102,
2668 CXType_LValueReference = 103,
2669 CXType_RValueReference = 104,
2670 CXType_Record = 105,
2672 CXType_Typedef = 107,
2673 CXType_ObjCInterface = 108,
2674 CXType_ObjCObjectPointer = 109,
2675 CXType_FunctionNoProto = 110,
2676 CXType_FunctionProto = 111,
2677 CXType_ConstantArray = 112,
2678 CXType_Vector = 113,
2679 CXType_IncompleteArray = 114,
2680 CXType_VariableArray = 115,
2681 CXType_DependentSizedArray = 116,
2682 CXType_MemberPointer = 117
2686 * \brief Describes the calling convention of a function type
2688 enum CXCallingConv {
2689 CXCallingConv_Default = 0,
2690 CXCallingConv_C = 1,
2691 CXCallingConv_X86StdCall = 2,
2692 CXCallingConv_X86FastCall = 3,
2693 CXCallingConv_X86ThisCall = 4,
2694 CXCallingConv_X86Pascal = 5,
2695 CXCallingConv_AAPCS = 6,
2696 CXCallingConv_AAPCS_VFP = 7,
2697 CXCallingConv_PnaclCall = 8,
2698 CXCallingConv_IntelOclBicc = 9,
2699 CXCallingConv_X86_64Win64 = 10,
2700 CXCallingConv_X86_64SysV = 11,
2702 CXCallingConv_Invalid = 100,
2703 CXCallingConv_Unexposed = 200
2708 * \brief The type of an element in the abstract syntax tree.
2712 enum CXTypeKind kind;
2717 * \brief Retrieve the type of a CXCursor (if any).
2719 CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
2722 * \brief Pretty-print the underlying type using the rules of the
2723 * language of the translation unit from which it came.
2725 * If the type is invalid, an empty string is returned.
2727 CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
2730 * \brief Retrieve the underlying type of a typedef declaration.
2732 * If the cursor does not reference a typedef declaration, an invalid type is
2735 CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
2738 * \brief Retrieve the integer type of an enum declaration.
2740 * If the cursor does not reference an enum declaration, an invalid type is
2743 CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
2746 * \brief Retrieve the integer value of an enum constant declaration as a signed
2749 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
2750 * Since this is also potentially a valid constant value, the kind of the cursor
2751 * must be verified before calling this function.
2753 CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
2756 * \brief Retrieve the integer value of an enum constant declaration as an unsigned
2759 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
2760 * Since this is also potentially a valid constant value, the kind of the cursor
2761 * must be verified before calling this function.
2763 CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
2766 * \brief Retrieve the bit width of a bit field declaration as an integer.
2768 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
2770 CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
2773 * \brief Retrieve the number of non-variadic arguments associated with a given
2776 * The number of arguments can be determined for calls as well as for
2777 * declarations of functions or methods. For other cursors -1 is returned.
2779 CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
2782 * \brief Retrieve the argument cursor of a function or method.
2784 * The argument cursor can be determined for calls as well as for declarations
2785 * of functions or methods. For other cursors and for invalid indices, an
2786 * invalid cursor is returned.
2788 CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
2791 * \brief Determine whether two CXTypes represent the same type.
2793 * \returns non-zero if the CXTypes represent the same type and
2796 CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
2799 * \brief Return the canonical type for a CXType.
2801 * Clang's type system explicitly models typedefs and all the ways
2802 * a specific type can be represented. The canonical type is the underlying
2803 * type with all the "sugar" removed. For example, if 'T' is a typedef
2804 * for 'int', the canonical type for 'T' would be 'int'.
2806 CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
2809 * \brief Determine whether a CXType has the "const" qualifier set,
2810 * without looking through typedefs that may have added "const" at a
2813 CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
2816 * \brief Determine whether a CXType has the "volatile" qualifier set,
2817 * without looking through typedefs that may have added "volatile" at
2818 * a different level.
2820 CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
2823 * \brief Determine whether a CXType has the "restrict" qualifier set,
2824 * without looking through typedefs that may have added "restrict" at a
2827 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
2830 * \brief For pointer types, returns the type of the pointee.
2832 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
2835 * \brief Return the cursor for the declaration of the given type.
2837 CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
2840 * Returns the Objective-C type encoding for the specified declaration.
2842 CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
2845 * \brief Retrieve the spelling of a given CXTypeKind.
2847 CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
2850 * \brief Retrieve the calling convention associated with a function type.
2852 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
2854 CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
2857 * \brief Retrieve the result type associated with a function type.
2859 * If a non-function type is passed in, an invalid type is returned.
2861 CINDEX_LINKAGE CXType clang_getResultType(CXType T);
2864 * \brief Retrieve the number of non-variadic arguments associated with a
2867 * If a non-function type is passed in, -1 is returned.
2869 CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
2872 * \brief Retrieve the type of an argument of a function type.
2874 * If a non-function type is passed in or the function does not have enough
2875 * parameters, an invalid type is returned.
2877 CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
2880 * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
2882 CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
2885 * \brief Retrieve the result type associated with a given cursor.
2887 * This only returns a valid type if the cursor refers to a function or method.
2889 CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
2892 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
2895 CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
2898 * \brief Return the element type of an array, complex, or vector type.
2900 * If a type is passed in that is not an array, complex, or vector type,
2901 * an invalid type is returned.
2903 CINDEX_LINKAGE CXType clang_getElementType(CXType T);
2906 * \brief Return the number of elements of an array or vector type.
2908 * If a type is passed in that is not an array or vector type,
2911 CINDEX_LINKAGE long long clang_getNumElements(CXType T);
2914 * \brief Return the element type of an array type.
2916 * If a non-array type is passed in, an invalid type is returned.
2918 CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
2921 * \brief Return the array size of a constant array.
2923 * If a non-array type is passed in, -1 is returned.
2925 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
2928 * \brief List the possible error codes for \c clang_Type_getSizeOf,
2929 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
2930 * \c clang_Cursor_getOffsetOf.
2932 * A value of this enumeration type can be returned if the target type is not
2933 * a valid argument to sizeof, alignof or offsetof.
2935 enum CXTypeLayoutError {
2937 * \brief Type is of kind CXType_Invalid.
2939 CXTypeLayoutError_Invalid = -1,
2941 * \brief The type is an incomplete Type.
2943 CXTypeLayoutError_Incomplete = -2,
2945 * \brief The type is a dependent Type.
2947 CXTypeLayoutError_Dependent = -3,
2949 * \brief The type is not a constant size type.
2951 CXTypeLayoutError_NotConstantSize = -4,
2953 * \brief The Field name is not valid for this record.
2955 CXTypeLayoutError_InvalidFieldName = -5
2959 * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
2962 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
2963 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
2965 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
2967 * If the type declaration is not a constant size type,
2968 * CXTypeLayoutError_NotConstantSize is returned.
2970 CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
2973 * \brief Return the class type of an member pointer type.
2975 * If a non-member-pointer type is passed in, an invalid type is returned.
2977 CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
2980 * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
2982 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
2983 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
2985 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
2988 CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
2991 * \brief Return the offset of a field named S in a record of type T in bits
2992 * as it would be returned by __offsetof__ as per C++11[18.2p4]
2994 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
2996 * If the field's type declaration is an incomplete type,
2997 * CXTypeLayoutError_Incomplete is returned.
2998 * If the field's type declaration is a dependent type,
2999 * CXTypeLayoutError_Dependent is returned.
3000 * If the field's name S is not found,
3001 * CXTypeLayoutError_InvalidFieldName is returned.
3003 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3005 enum CXRefQualifierKind {
3006 /** \brief No ref-qualifier was provided. */
3007 CXRefQualifier_None = 0,
3008 /** \brief An lvalue ref-qualifier was provided (\c &). */
3009 CXRefQualifier_LValue,
3010 /** \brief An rvalue ref-qualifier was provided (\c &&). */
3011 CXRefQualifier_RValue
3015 * \brief Retrieve the ref-qualifier kind of a function or method.
3017 * The ref-qualifier is returned for C++ functions or methods. For other types
3018 * or non-C++ declarations, CXRefQualifier_None is returned.
3020 CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3023 * \brief Returns non-zero if the cursor specifies a Record member that is a
3026 CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3029 * \brief Returns 1 if the base class specified by the cursor with kind
3030 * CX_CXXBaseSpecifier is virtual.
3032 CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3035 * \brief Represents the C++ access control level to a base class for a
3036 * cursor with kind CX_CXXBaseSpecifier.
3038 enum CX_CXXAccessSpecifier {
3039 CX_CXXInvalidAccessSpecifier,
3046 * \brief Returns the access control level for the referenced object.
3048 * If the cursor refers to a C++ declaration, its access control level within its
3049 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3050 * access specifier, the specifier itself is returned.
3052 CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3055 * \brief Determine the number of overloaded declarations referenced by a
3056 * \c CXCursor_OverloadedDeclRef cursor.
3058 * \param cursor The cursor whose overloaded declarations are being queried.
3060 * \returns The number of overloaded declarations referenced by \c cursor. If it
3061 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3063 CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3066 * \brief Retrieve a cursor for one of the overloaded declarations referenced
3067 * by a \c CXCursor_OverloadedDeclRef cursor.
3069 * \param cursor The cursor whose overloaded declarations are being queried.
3071 * \param index The zero-based index into the set of overloaded declarations in
3074 * \returns A cursor representing the declaration referenced by the given
3075 * \c cursor at the specified \c index. If the cursor does not have an
3076 * associated set of overloaded declarations, or if the index is out of bounds,
3077 * returns \c clang_getNullCursor();
3079 CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3087 * \defgroup CINDEX_ATTRIBUTES Information for attributes
3094 * \brief For cursors representing an iboutletcollection attribute,
3095 * this function returns the collection element type.
3098 CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3105 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3107 * These routines provide the ability to traverse the abstract syntax tree
3114 * \brief Describes how the traversal of the children of a particular
3115 * cursor should proceed after visiting a particular child cursor.
3117 * A value of this enumeration type should be returned by each
3118 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3120 enum CXChildVisitResult {
3122 * \brief Terminates the cursor traversal.
3126 * \brief Continues the cursor traversal with the next sibling of
3127 * the cursor just visited, without visiting its children.
3129 CXChildVisit_Continue,
3131 * \brief Recursively traverse the children of this cursor, using
3132 * the same visitor and client data.
3134 CXChildVisit_Recurse
3138 * \brief Visitor invoked for each cursor found by a traversal.
3140 * This visitor function will be invoked for each cursor found by
3141 * clang_visitCursorChildren(). Its first argument is the cursor being
3142 * visited, its second argument is the parent visitor for that cursor,
3143 * and its third argument is the client data provided to
3144 * clang_visitCursorChildren().
3146 * The visitor should return one of the \c CXChildVisitResult values
3147 * to direct clang_visitCursorChildren().
3149 typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3151 CXClientData client_data);
3154 * \brief Visit the children of a particular cursor.
3156 * This function visits all the direct children of the given cursor,
3157 * invoking the given \p visitor function with the cursors of each
3158 * visited child. The traversal may be recursive, if the visitor returns
3159 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3160 * the visitor returns \c CXChildVisit_Break.
3162 * \param parent the cursor whose child may be visited. All kinds of
3163 * cursors can be visited, including invalid cursors (which, by
3164 * definition, have no children).
3166 * \param visitor the visitor function that will be invoked for each
3167 * child of \p parent.
3169 * \param client_data pointer data supplied by the client, which will
3170 * be passed to the visitor each time it is invoked.
3172 * \returns a non-zero value if the traversal was terminated
3173 * prematurely by the visitor returning \c CXChildVisit_Break.
3175 CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
3176 CXCursorVisitor visitor,
3177 CXClientData client_data);
3178 #ifdef __has_feature
3179 # if __has_feature(blocks)
3181 * \brief Visitor invoked for each cursor found by a traversal.
3183 * This visitor block will be invoked for each cursor found by
3184 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3185 * visited, its second argument is the parent visitor for that cursor.
3187 * The visitor should return one of the \c CXChildVisitResult values
3188 * to direct clang_visitChildrenWithBlock().
3190 typedef enum CXChildVisitResult
3191 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3194 * Visits the children of a cursor using the specified block. Behaves
3195 * identically to clang_visitChildren() in all other respects.
3197 unsigned clang_visitChildrenWithBlock(CXCursor parent,
3198 CXCursorVisitorBlock block);
3207 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3209 * These routines provide the ability to determine references within and
3210 * across translation units, by providing the names of the entities referenced
3211 * by cursors, follow reference cursors to the declarations they reference,
3212 * and associate declarations with their definitions.
3218 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3219 * by the given cursor.
3221 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3222 * entity (function, class, variable, etc.) within a program. USRs can be
3223 * compared across translation units to determine, e.g., when references in
3224 * one translation refer to an entity defined in another translation unit.
3226 CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3229 * \brief Construct a USR for a specified Objective-C class.
3231 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3234 * \brief Construct a USR for a specified Objective-C category.
3236 CINDEX_LINKAGE CXString
3237 clang_constructUSR_ObjCCategory(const char *class_name,
3238 const char *category_name);
3241 * \brief Construct a USR for a specified Objective-C protocol.
3243 CINDEX_LINKAGE CXString
3244 clang_constructUSR_ObjCProtocol(const char *protocol_name);
3248 * \brief Construct a USR for a specified Objective-C instance variable and
3249 * the USR for its containing class.
3251 CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3255 * \brief Construct a USR for a specified Objective-C method and
3256 * the USR for its containing class.
3258 CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3259 unsigned isInstanceMethod,
3263 * \brief Construct a USR for a specified Objective-C property and the USR
3264 * for its containing class.
3266 CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3270 * \brief Retrieve a name for the entity referenced by this cursor.
3272 CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3275 * \brief Retrieve a range for a piece that forms the cursors spelling name.
3276 * Most of the times there is only one range for the complete spelling but for
3277 * objc methods and objc message expressions, there are multiple pieces for each
3278 * selector identifier.
3280 * \param pieceIndex the index of the spelling name piece. If this is greater
3281 * than the actual number of pieces, it will return a NULL (invalid) range.
3283 * \param options Reserved.
3285 CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
3286 unsigned pieceIndex,
3290 * \brief Retrieve the display name for the entity referenced by this cursor.
3292 * The display name contains extra information that helps identify the cursor,
3293 * such as the parameters of a function or template or the arguments of a
3294 * class template specialization.
3296 CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
3298 /** \brief For a cursor that is a reference, retrieve a cursor representing the
3299 * entity that it references.
3301 * Reference cursors refer to other entities in the AST. For example, an
3302 * Objective-C superclass reference cursor refers to an Objective-C class.
3303 * This function produces the cursor for the Objective-C class from the
3304 * cursor for the superclass reference. If the input cursor is a declaration or
3305 * definition, it returns that declaration or definition unchanged.
3306 * Otherwise, returns the NULL cursor.
3308 CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
3311 * \brief For a cursor that is either a reference to or a declaration
3312 * of some entity, retrieve a cursor that describes the definition of
3315 * Some entities can be declared multiple times within a translation
3316 * unit, but only one of those declarations can also be a
3317 * definition. For example, given:
3321 * int g(int x, int y) { return f(x, y); }
3322 * int f(int a, int b) { return a + b; }
3326 * there are three declarations of the function "f", but only the
3327 * second one is a definition. The clang_getCursorDefinition()
3328 * function will take any cursor pointing to a declaration of "f"
3329 * (the first or fourth lines of the example) or a cursor referenced
3330 * that uses "f" (the call to "f' inside "g") and will return a
3331 * declaration cursor pointing to the definition (the second "f"
3334 * If given a cursor for which there is no corresponding definition,
3335 * e.g., because there is no definition of that entity within this
3336 * translation unit, returns a NULL cursor.
3338 CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
3341 * \brief Determine whether the declaration pointed to by this cursor
3342 * is also a definition of that entity.
3344 CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
3347 * \brief Retrieve the canonical cursor corresponding to the given cursor.
3349 * In the C family of languages, many kinds of entities can be declared several
3350 * times within a single translation unit. For example, a structure type can
3351 * be forward-declared (possibly multiple times) and later defined:
3361 * The declarations and the definition of \c X are represented by three
3362 * different cursors, all of which are declarations of the same underlying
3363 * entity. One of these cursor is considered the "canonical" cursor, which
3364 * is effectively the representative for the underlying entity. One can
3365 * determine if two cursors are declarations of the same underlying entity by
3366 * comparing their canonical cursors.
3368 * \returns The canonical cursor for the entity referred to by the given cursor.
3370 CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
3374 * \brief If the cursor points to a selector identifier in a objc method or
3375 * message expression, this returns the selector index.
3377 * After getting a cursor with #clang_getCursor, this can be called to
3378 * determine if the location points to a selector identifier.
3380 * \returns The selector index if the cursor is an objc method or message
3381 * expression and the cursor is pointing to a selector identifier, or -1
3384 CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
3387 * \brief Given a cursor pointing to a C++ method call or an ObjC message,
3388 * returns non-zero if the method/message is "dynamic", meaning:
3390 * For a C++ method: the call is virtual.
3391 * For an ObjC message: the receiver is an object instance, not 'super' or a
3394 * If the method/message is "static" or the cursor does not point to a
3395 * method/message, it will return zero.
3397 CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
3400 * \brief Given a cursor pointing to an ObjC message, returns the CXType of the
3403 CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
3406 * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
3409 CXObjCPropertyAttr_noattr = 0x00,
3410 CXObjCPropertyAttr_readonly = 0x01,
3411 CXObjCPropertyAttr_getter = 0x02,
3412 CXObjCPropertyAttr_assign = 0x04,
3413 CXObjCPropertyAttr_readwrite = 0x08,
3414 CXObjCPropertyAttr_retain = 0x10,
3415 CXObjCPropertyAttr_copy = 0x20,
3416 CXObjCPropertyAttr_nonatomic = 0x40,
3417 CXObjCPropertyAttr_setter = 0x80,
3418 CXObjCPropertyAttr_atomic = 0x100,
3419 CXObjCPropertyAttr_weak = 0x200,
3420 CXObjCPropertyAttr_strong = 0x400,
3421 CXObjCPropertyAttr_unsafe_unretained = 0x800
3422 } CXObjCPropertyAttrKind;
3425 * \brief Given a cursor that represents a property declaration, return the
3426 * associated property attributes. The bits are formed from
3427 * \c CXObjCPropertyAttrKind.
3429 * \param reserved Reserved for future use, pass 0.
3431 CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
3435 * \brief 'Qualifiers' written next to the return and parameter types in
3436 * ObjC method declarations.
3439 CXObjCDeclQualifier_None = 0x0,
3440 CXObjCDeclQualifier_In = 0x1,
3441 CXObjCDeclQualifier_Inout = 0x2,
3442 CXObjCDeclQualifier_Out = 0x4,
3443 CXObjCDeclQualifier_Bycopy = 0x8,
3444 CXObjCDeclQualifier_Byref = 0x10,
3445 CXObjCDeclQualifier_Oneway = 0x20
3446 } CXObjCDeclQualifierKind;
3449 * \brief Given a cursor that represents an ObjC method or parameter
3450 * declaration, return the associated ObjC qualifiers for the return type or the
3451 * parameter respectively. The bits are formed from CXObjCDeclQualifierKind.
3453 CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
3456 * \brief Given a cursor that represents an ObjC method or property declaration,
3457 * return non-zero if the declaration was affected by "@optional".
3458 * Returns zero if the cursor is not such a declaration or it is "@required".
3460 CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
3463 * \brief Returns non-zero if the given cursor is a variadic function or method.
3465 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
3468 * \brief Given a cursor that represents a declaration, return the associated
3469 * comment's source range. The range may include multiple consecutive comments
3470 * with whitespace in between.
3472 CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
3475 * \brief Given a cursor that represents a declaration, return the associated
3476 * comment text, including comment markers.
3478 CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
3481 * \brief Given a cursor that represents a documentable entity (e.g.,
3482 * declaration), return the associated \\brief paragraph; otherwise return the
3485 CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
3488 * \brief Given a cursor that represents a documentable entity (e.g.,
3489 * declaration), return the associated parsed comment as a
3490 * \c CXComment_FullComment AST node.
3492 CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C);
3499 * \defgroup CINDEX_MODULE Module introspection
3501 * The functions in this group provide access to information about modules.
3506 typedef void *CXModule;
3509 * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
3511 CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
3514 * \param Module a module object.
3516 * \returns the module file where the provided module object came from.
3518 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
3521 * \param Module a module object.
3523 * \returns the parent of a sub-module or NULL if the given module is top-level,
3524 * e.g. for 'std.vector' it will return the 'std' module.
3526 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
3529 * \param Module a module object.
3531 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
3532 * will return "vector".
3534 CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
3537 * \param Module a module object.
3539 * \returns the full name of the module, e.g. "std.vector".
3541 CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
3544 * \param Module a module object.
3546 * \returns the number of top level headers associated with this module.
3548 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
3552 * \param Module a module object.
3554 * \param Index top level header index (zero-based).
3556 * \returns the specified top level header associated with the module.
3559 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
3560 CXModule Module, unsigned Index);
3567 * \defgroup CINDEX_COMMENT Comment AST introspection
3569 * The routines in this group provide access to information in the
3570 * documentation comment ASTs.
3576 * \brief Describes the type of the comment AST node (\c CXComment). A comment
3577 * node can be considered block content (e. g., paragraph), inline content
3578 * (plain text) or neither (the root AST node).
3580 enum CXCommentKind {
3582 * \brief Null comment. No AST node is constructed at the requested location
3583 * because there is no text or a syntax error.
3588 * \brief Plain text. Inline content.
3593 * \brief A command with word-like arguments that is considered inline content.
3595 * For example: \\c command.
3597 CXComment_InlineCommand = 2,
3600 * \brief HTML start tag with attributes (name-value pairs). Considered
3605 * <br> <br /> <a href="http://example.org/">
3608 CXComment_HTMLStartTag = 3,
3611 * \brief HTML end tag. Considered inline content.
3618 CXComment_HTMLEndTag = 4,
3621 * \brief A paragraph, contains inline comment. The paragraph itself is
3624 CXComment_Paragraph = 5,
3627 * \brief A command that has zero or more word-like arguments (number of
3628 * word-like arguments depends on command name) and a paragraph as an
3629 * argument. Block command is block content.
3631 * Paragraph argument is also a child of the block command.
3633 * For example: \\brief has 0 word-like arguments and a paragraph argument.
3635 * AST nodes of special kinds that parser knows about (e. g., \\param
3636 * command) have their own node kinds.
3638 CXComment_BlockCommand = 6,
3641 * \brief A \\param or \\arg command that describes the function parameter
3642 * (name, passing direction, description).
3644 * For example: \\param [in] ParamName description.
3646 CXComment_ParamCommand = 7,
3649 * \brief A \\tparam command that describes a template parameter (name and
3652 * For example: \\tparam T description.
3654 CXComment_TParamCommand = 8,
3657 * \brief A verbatim block command (e. g., preformatted code). Verbatim
3658 * block has an opening and a closing command and contains multiple lines of
3659 * text (\c CXComment_VerbatimBlockLine child nodes).
3666 CXComment_VerbatimBlockCommand = 9,
3669 * \brief A line of text that is contained within a
3670 * CXComment_VerbatimBlockCommand node.
3672 CXComment_VerbatimBlockLine = 10,
3675 * \brief A verbatim line command. Verbatim line has an opening command,
3676 * a single line of text (up to the newline after the opening command) and
3677 * has no closing command.
3679 CXComment_VerbatimLine = 11,
3682 * \brief A full comment attached to a declaration, contains block content.
3684 CXComment_FullComment = 12
3688 * \brief The most appropriate rendering mode for an inline command, chosen on
3689 * command semantics in Doxygen.
3691 enum CXCommentInlineCommandRenderKind {
3693 * \brief Command argument should be rendered in a normal font.
3695 CXCommentInlineCommandRenderKind_Normal,
3698 * \brief Command argument should be rendered in a bold font.
3700 CXCommentInlineCommandRenderKind_Bold,
3703 * \brief Command argument should be rendered in a monospaced font.
3705 CXCommentInlineCommandRenderKind_Monospaced,
3708 * \brief Command argument should be rendered emphasized (typically italic
3711 CXCommentInlineCommandRenderKind_Emphasized
3715 * \brief Describes parameter passing direction for \\param or \\arg command.
3717 enum CXCommentParamPassDirection {
3719 * \brief The parameter is an input parameter.
3721 CXCommentParamPassDirection_In,
3724 * \brief The parameter is an output parameter.
3726 CXCommentParamPassDirection_Out,
3729 * \brief The parameter is an input and output parameter.
3731 CXCommentParamPassDirection_InOut
3735 * \param Comment AST node of any kind.
3737 * \returns the type of the AST node.
3739 CINDEX_LINKAGE enum CXCommentKind clang_Comment_getKind(CXComment Comment);
3742 * \param Comment AST node of any kind.
3744 * \returns number of children of the AST node.
3746 CINDEX_LINKAGE unsigned clang_Comment_getNumChildren(CXComment Comment);
3749 * \param Comment AST node of any kind.
3751 * \param ChildIdx child index (zero-based).
3753 * \returns the specified child of the AST node.
3756 CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx);
3759 * \brief A \c CXComment_Paragraph node is considered whitespace if it contains
3760 * only \c CXComment_Text nodes that are empty or whitespace.
3762 * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are
3763 * never considered whitespace.
3765 * \returns non-zero if \c Comment is whitespace.
3767 CINDEX_LINKAGE unsigned clang_Comment_isWhitespace(CXComment Comment);
3770 * \returns non-zero if \c Comment is inline content and has a newline
3771 * immediately following it in the comment text. Newlines between paragraphs
3775 unsigned clang_InlineContentComment_hasTrailingNewline(CXComment Comment);
3778 * \param Comment a \c CXComment_Text AST node.
3780 * \returns text contained in the AST node.
3782 CINDEX_LINKAGE CXString clang_TextComment_getText(CXComment Comment);
3785 * \param Comment a \c CXComment_InlineCommand AST node.
3787 * \returns name of the inline command.
3790 CXString clang_InlineCommandComment_getCommandName(CXComment Comment);
3793 * \param Comment a \c CXComment_InlineCommand AST node.
3795 * \returns the most appropriate rendering mode, chosen on command
3796 * semantics in Doxygen.
3798 CINDEX_LINKAGE enum CXCommentInlineCommandRenderKind
3799 clang_InlineCommandComment_getRenderKind(CXComment Comment);
3802 * \param Comment a \c CXComment_InlineCommand AST node.
3804 * \returns number of command arguments.
3807 unsigned clang_InlineCommandComment_getNumArgs(CXComment Comment);
3810 * \param Comment a \c CXComment_InlineCommand AST node.
3812 * \param ArgIdx argument index (zero-based).
3814 * \returns text of the specified argument.
3817 CXString clang_InlineCommandComment_getArgText(CXComment Comment,
3821 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
3824 * \returns HTML tag name.
3826 CINDEX_LINKAGE CXString clang_HTMLTagComment_getTagName(CXComment Comment);
3829 * \param Comment a \c CXComment_HTMLStartTag AST node.
3831 * \returns non-zero if tag is self-closing (for example, <br />).
3834 unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment Comment);
3837 * \param Comment a \c CXComment_HTMLStartTag AST node.
3839 * \returns number of attributes (name-value pairs) attached to the start tag.
3841 CINDEX_LINKAGE unsigned clang_HTMLStartTag_getNumAttrs(CXComment Comment);
3844 * \param Comment a \c CXComment_HTMLStartTag AST node.
3846 * \param AttrIdx attribute index (zero-based).
3848 * \returns name of the specified attribute.
3851 CXString clang_HTMLStartTag_getAttrName(CXComment Comment, unsigned AttrIdx);
3854 * \param Comment a \c CXComment_HTMLStartTag AST node.
3856 * \param AttrIdx attribute index (zero-based).
3858 * \returns value of the specified attribute.
3861 CXString clang_HTMLStartTag_getAttrValue(CXComment Comment, unsigned AttrIdx);
3864 * \param Comment a \c CXComment_BlockCommand AST node.
3866 * \returns name of the block command.
3869 CXString clang_BlockCommandComment_getCommandName(CXComment Comment);
3872 * \param Comment a \c CXComment_BlockCommand AST node.
3874 * \returns number of word-like arguments.
3877 unsigned clang_BlockCommandComment_getNumArgs(CXComment Comment);
3880 * \param Comment a \c CXComment_BlockCommand AST node.
3882 * \param ArgIdx argument index (zero-based).
3884 * \returns text of the specified word-like argument.
3887 CXString clang_BlockCommandComment_getArgText(CXComment Comment,
3891 * \param Comment a \c CXComment_BlockCommand or
3892 * \c CXComment_VerbatimBlockCommand AST node.
3894 * \returns paragraph argument of the block command.
3897 CXComment clang_BlockCommandComment_getParagraph(CXComment Comment);
3900 * \param Comment a \c CXComment_ParamCommand AST node.
3902 * \returns parameter name.
3905 CXString clang_ParamCommandComment_getParamName(CXComment Comment);
3908 * \param Comment a \c CXComment_ParamCommand AST node.
3910 * \returns non-zero if the parameter that this AST node represents was found
3911 * in the function prototype and \c clang_ParamCommandComment_getParamIndex
3912 * function will return a meaningful value.
3915 unsigned clang_ParamCommandComment_isParamIndexValid(CXComment Comment);
3918 * \param Comment a \c CXComment_ParamCommand AST node.
3920 * \returns zero-based parameter index in function prototype.
3923 unsigned clang_ParamCommandComment_getParamIndex(CXComment Comment);
3926 * \param Comment a \c CXComment_ParamCommand AST node.
3928 * \returns non-zero if parameter passing direction was specified explicitly in
3932 unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment Comment);
3935 * \param Comment a \c CXComment_ParamCommand AST node.
3937 * \returns parameter passing direction.
3940 enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection(
3944 * \param Comment a \c CXComment_TParamCommand AST node.
3946 * \returns template parameter name.
3949 CXString clang_TParamCommandComment_getParamName(CXComment Comment);
3952 * \param Comment a \c CXComment_TParamCommand AST node.
3954 * \returns non-zero if the parameter that this AST node represents was found
3955 * in the template parameter list and
3956 * \c clang_TParamCommandComment_getDepth and
3957 * \c clang_TParamCommandComment_getIndex functions will return a meaningful
3961 unsigned clang_TParamCommandComment_isParamPositionValid(CXComment Comment);
3964 * \param Comment a \c CXComment_TParamCommand AST node.
3966 * \returns zero-based nesting depth of this parameter in the template parameter list.
3970 * template<typename C, template<typename T> class TT>
3971 * void test(TT<int> aaa);
3973 * for C and TT nesting depth is 0,
3974 * for T nesting depth is 1.
3977 unsigned clang_TParamCommandComment_getDepth(CXComment Comment);
3980 * \param Comment a \c CXComment_TParamCommand AST node.
3982 * \returns zero-based parameter index in the template parameter list at a
3983 * given nesting depth.
3987 * template<typename C, template<typename T> class TT>
3988 * void test(TT<int> aaa);
3990 * for C and TT nesting depth is 0, so we can ask for index at depth 0:
3991 * at depth 0 C's index is 0, TT's index is 1.
3993 * For T nesting depth is 1, so we can ask for index at depth 0 and 1:
3994 * at depth 0 T's index is 1 (same as TT's),
3995 * at depth 1 T's index is 0.
3998 unsigned clang_TParamCommandComment_getIndex(CXComment Comment, unsigned Depth);
4001 * \param Comment a \c CXComment_VerbatimBlockLine AST node.
4003 * \returns text contained in the AST node.
4006 CXString clang_VerbatimBlockLineComment_getText(CXComment Comment);
4009 * \param Comment a \c CXComment_VerbatimLine AST node.
4011 * \returns text contained in the AST node.
4013 CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment);
4016 * \brief Convert an HTML tag AST node to string.
4018 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
4021 * \returns string containing an HTML tag.
4023 CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment);
4026 * \brief Convert a given full parsed comment to an HTML fragment.
4028 * Specific details of HTML layout are subject to change. Don't try to parse
4029 * this HTML back into an AST, use other APIs instead.
4031 * Currently the following CSS classes are used:
4032 * \li "para-brief" for \\brief paragraph and equivalent commands;
4033 * \li "para-returns" for \\returns paragraph and equivalent commands;
4034 * \li "word-returns" for the "Returns" word in \\returns paragraph.
4036 * Function argument documentation is rendered as a \<dl\> list with arguments
4037 * sorted in function prototype order. CSS classes used:
4038 * \li "param-name-index-NUMBER" for parameter name (\<dt\>);
4039 * \li "param-descr-index-NUMBER" for parameter description (\<dd\>);
4040 * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if
4041 * parameter index is invalid.
4043 * Template parameter documentation is rendered as a \<dl\> list with
4044 * parameters sorted in template parameter list order. CSS classes used:
4045 * \li "tparam-name-index-NUMBER" for parameter name (\<dt\>);
4046 * \li "tparam-descr-index-NUMBER" for parameter description (\<dd\>);
4047 * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for
4048 * names inside template template parameters;
4049 * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if
4050 * parameter position is invalid.
4052 * \param Comment a \c CXComment_FullComment AST node.
4054 * \returns string containing an HTML fragment.
4056 CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment);
4059 * \brief Convert a given full parsed comment to an XML document.
4061 * A Relax NG schema for the XML can be found in comment-xml-schema.rng file
4062 * inside clang source tree.
4064 * \param Comment a \c CXComment_FullComment AST node.
4066 * \returns string containing an XML document.
4068 CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment);
4075 * \defgroup CINDEX_CPP C++ AST introspection
4077 * The routines in this group provide access information in the ASTs specific
4078 * to C++ language features.
4084 * \brief Determine if a C++ member function or member function template is
4087 CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4090 * \brief Determine if a C++ member function or member function template is
4091 * declared 'static'.
4093 CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4096 * \brief Determine if a C++ member function or member function template is
4097 * explicitly declared 'virtual' or if it overrides a virtual method from
4098 * one of the base classes.
4100 CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4103 * \brief Given a cursor that represents a template, determine
4104 * the cursor kind of the specializations would be generated by instantiating
4107 * This routine can be used to determine what flavor of function template,
4108 * class template, or class template partial specialization is stored in the
4109 * cursor. For example, it can describe whether a class template cursor is
4110 * declared with "struct", "class" or "union".
4112 * \param C The cursor to query. This cursor should represent a template
4115 * \returns The cursor kind of the specializations that would be generated
4116 * by instantiating the template \p C. If \p C is not a template, returns
4117 * \c CXCursor_NoDeclFound.
4119 CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4122 * \brief Given a cursor that may represent a specialization or instantiation
4123 * of a template, retrieve the cursor that represents the template that it
4124 * specializes or from which it was instantiated.
4126 * This routine determines the template involved both for explicit
4127 * specializations of templates and for implicit instantiations of the template,
4128 * both of which are referred to as "specializations". For a class template
4129 * specialization (e.g., \c std::vector<bool>), this routine will return
4130 * either the primary template (\c std::vector) or, if the specialization was
4131 * instantiated from a class template partial specialization, the class template
4132 * partial specialization. For a class template partial specialization and a
4133 * function template specialization (including instantiations), this
4134 * this routine will return the specialized template.
4136 * For members of a class template (e.g., member functions, member classes, or
4137 * static data members), returns the specialized or instantiated member.
4138 * Although not strictly "templates" in the C++ language, members of class
4139 * templates have the same notions of specializations and instantiations that
4140 * templates do, so this routine treats them similarly.
4142 * \param C A cursor that may be a specialization of a template or a member
4145 * \returns If the given cursor is a specialization or instantiation of a
4146 * template or a member thereof, the template or member that it specializes or
4147 * from which it was instantiated. Otherwise, returns a NULL cursor.
4149 CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4152 * \brief Given a cursor that references something else, return the source range
4153 * covering that reference.
4155 * \param C A cursor pointing to a member reference, a declaration reference, or
4157 * \param NameFlags A bitset with three independent flags:
4158 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4159 * CXNameRange_WantSinglePiece.
4160 * \param PieceIndex For contiguous names or when passing the flag
4161 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4162 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4163 * non-contiguous names, this index can be used to retrieve the individual
4164 * pieces of the name. See also CXNameRange_WantSinglePiece.
4166 * \returns The piece of the name pointed to by the given cursor. If there is no
4167 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4169 CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4171 unsigned PieceIndex);
4173 enum CXNameRefFlags {
4175 * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4178 CXNameRange_WantQualifier = 0x1,
4181 * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
4184 CXNameRange_WantTemplateArgs = 0x2,
4187 * \brief If the name is non-contiguous, return the full spanning range.
4189 * Non-contiguous names occur in Objective-C when a selector with two or more
4190 * parameters is used, or in C++ when using an operator:
4192 * [object doSomething:here withValue:there]; // ObjC
4193 * return some_vector[1]; // C++
4196 CXNameRange_WantSinglePiece = 0x4
4204 * \defgroup CINDEX_LEX Token extraction and manipulation
4206 * The routines in this group provide access to the tokens within a
4207 * translation unit, along with a semantic mapping of those tokens to
4208 * their corresponding cursors.
4214 * \brief Describes a kind of token.
4216 typedef enum CXTokenKind {
4218 * \brief A token that contains some kind of punctuation.
4220 CXToken_Punctuation,
4223 * \brief A language keyword.
4228 * \brief An identifier (that is not a keyword).
4233 * \brief A numeric, string, or character literal.
4244 * \brief Describes a single preprocessing token.
4247 unsigned int_data[4];
4252 * \brief Determine the kind of the given token.
4254 CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4257 * \brief Determine the spelling of the given token.
4259 * The spelling of a token is the textual representation of that token, e.g.,
4260 * the text of an identifier or keyword.
4262 CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4265 * \brief Retrieve the source location of the given token.
4267 CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4271 * \brief Retrieve a source range that covers the given token.
4273 CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4276 * \brief Tokenize the source code described by the given range into raw
4279 * \param TU the translation unit whose text is being tokenized.
4281 * \param Range the source range in which text should be tokenized. All of the
4282 * tokens produced by tokenization will fall within this source range,
4284 * \param Tokens this pointer will be set to point to the array of tokens
4285 * that occur within the given source range. The returned pointer must be
4286 * freed with clang_disposeTokens() before the translation unit is destroyed.
4288 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4292 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4293 CXToken **Tokens, unsigned *NumTokens);
4296 * \brief Annotate the given set of tokens by providing cursors for each token
4297 * that can be mapped to a specific entity within the abstract syntax tree.
4299 * This token-annotation routine is equivalent to invoking
4300 * clang_getCursor() for the source locations of each of the
4301 * tokens. The cursors provided are filtered, so that only those
4302 * cursors that have a direct correspondence to the token are
4303 * accepted. For example, given a function call \c f(x),
4304 * clang_getCursor() would provide the following cursors:
4306 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4307 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4308 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4310 * Only the first and last of these cursors will occur within the
4311 * annotate, since the tokens "f" and "x' directly refer to a function
4312 * and a variable, respectively, but the parentheses are just a small
4313 * part of the full syntax of the function call expression, which is
4314 * not provided as an annotation.
4316 * \param TU the translation unit that owns the given tokens.
4318 * \param Tokens the set of tokens to annotate.
4320 * \param NumTokens the number of tokens in \p Tokens.
4322 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4323 * replaced with the cursors corresponding to each token.
4325 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4326 CXToken *Tokens, unsigned NumTokens,
4330 * \brief Free the given set of tokens.
4332 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4333 CXToken *Tokens, unsigned NumTokens);
4340 * \defgroup CINDEX_DEBUG Debugging facilities
4342 * These routines are used for testing and debugging, only, and should not
4348 /* for debug/testing */
4349 CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4350 CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4351 const char **startBuf,
4352 const char **endBuf,
4353 unsigned *startLine,
4354 unsigned *startColumn,
4356 unsigned *endColumn);
4357 CINDEX_LINKAGE void clang_enableStackTraces(void);
4358 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4359 unsigned stack_size);
4366 * \defgroup CINDEX_CODE_COMPLET Code completion
4368 * Code completion involves taking an (incomplete) source file, along with
4369 * knowledge of where the user is actively editing that file, and suggesting
4370 * syntactically- and semantically-valid constructs that the user might want to
4371 * use at that particular point in the source code. These data structures and
4372 * routines provide support for code completion.
4378 * \brief A semantic string that describes a code-completion result.
4380 * A semantic string that describes the formatting of a code-completion
4381 * result as a single "template" of text that should be inserted into the
4382 * source buffer when a particular code-completion result is selected.
4383 * Each semantic string is made up of some number of "chunks", each of which
4384 * contains some text along with a description of what that text means, e.g.,
4385 * the name of the entity being referenced, whether the text chunk is part of
4386 * the template, or whether it is a "placeholder" that the user should replace
4387 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4388 * description of the different kinds of chunks.
4390 typedef void *CXCompletionString;
4393 * \brief A single result of code completion.
4397 * \brief The kind of entity that this completion refers to.
4399 * The cursor kind will be a macro, keyword, or a declaration (one of the
4400 * *Decl cursor kinds), describing the entity that the completion is
4403 * \todo In the future, we would like to provide a full cursor, to allow
4404 * the client to extract additional information from declaration.
4406 enum CXCursorKind CursorKind;
4409 * \brief The code-completion string that describes how to insert this
4410 * code-completion result into the editing buffer.
4412 CXCompletionString CompletionString;
4413 } CXCompletionResult;
4416 * \brief Describes a single piece of text within a code-completion string.
4418 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4419 * either a piece of text with a specific "kind" that describes how that text
4420 * should be interpreted by the client or is another completion string.
4422 enum CXCompletionChunkKind {
4424 * \brief A code-completion string that describes "optional" text that
4425 * could be a part of the template (but is not required).
4427 * The Optional chunk is the only kind of chunk that has a code-completion
4428 * string for its representation, which is accessible via
4429 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4430 * describes an additional part of the template that is completely optional.
4431 * For example, optional chunks can be used to describe the placeholders for
4432 * arguments that match up with defaulted function parameters, e.g. given:
4435 * void f(int x, float y = 3.14, double z = 2.71828);
4438 * The code-completion string for this function would contain:
4439 * - a TypedText chunk for "f".
4440 * - a LeftParen chunk for "(".
4441 * - a Placeholder chunk for "int x"
4442 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4443 * - a Comma chunk for ","
4444 * - a Placeholder chunk for "float y"
4445 * - an Optional chunk containing the last defaulted argument:
4446 * - a Comma chunk for ","
4447 * - a Placeholder chunk for "double z"
4448 * - a RightParen chunk for ")"
4450 * There are many ways to handle Optional chunks. Two simple approaches are:
4451 * - Completely ignore optional chunks, in which case the template for the
4452 * function "f" would only include the first parameter ("int x").
4453 * - Fully expand all optional chunks, in which case the template for the
4454 * function "f" would have all of the parameters.
4456 CXCompletionChunk_Optional,
4458 * \brief Text that a user would be expected to type to get this
4459 * code-completion result.
4461 * There will be exactly one "typed text" chunk in a semantic string, which
4462 * will typically provide the spelling of a keyword or the name of a
4463 * declaration that could be used at the current code point. Clients are
4464 * expected to filter the code-completion results based on the text in this
4467 CXCompletionChunk_TypedText,
4469 * \brief Text that should be inserted as part of a code-completion result.
4471 * A "text" chunk represents text that is part of the template to be
4472 * inserted into user code should this particular code-completion result
4475 CXCompletionChunk_Text,
4477 * \brief Placeholder text that should be replaced by the user.
4479 * A "placeholder" chunk marks a place where the user should insert text
4480 * into the code-completion template. For example, placeholders might mark
4481 * the function parameters for a function declaration, to indicate that the
4482 * user should provide arguments for each of those parameters. The actual
4483 * text in a placeholder is a suggestion for the text to display before
4484 * the user replaces the placeholder with real code.
4486 CXCompletionChunk_Placeholder,
4488 * \brief Informative text that should be displayed but never inserted as
4489 * part of the template.
4491 * An "informative" chunk contains annotations that can be displayed to
4492 * help the user decide whether a particular code-completion result is the
4493 * right option, but which is not part of the actual template to be inserted
4494 * by code completion.
4496 CXCompletionChunk_Informative,
4498 * \brief Text that describes the current parameter when code-completion is
4499 * referring to function call, message send, or template specialization.
4501 * A "current parameter" chunk occurs when code-completion is providing
4502 * information about a parameter corresponding to the argument at the
4503 * code-completion point. For example, given a function
4506 * int add(int x, int y);
4509 * and the source code \c add(, where the code-completion point is after the
4510 * "(", the code-completion string will contain a "current parameter" chunk
4511 * for "int x", indicating that the current argument will initialize that
4512 * parameter. After typing further, to \c add(17, (where the code-completion
4513 * point is after the ","), the code-completion string will contain a
4514 * "current paremeter" chunk to "int y".
4516 CXCompletionChunk_CurrentParameter,
4518 * \brief A left parenthesis ('('), used to initiate a function call or
4519 * signal the beginning of a function parameter list.
4521 CXCompletionChunk_LeftParen,
4523 * \brief A right parenthesis (')'), used to finish a function call or
4524 * signal the end of a function parameter list.
4526 CXCompletionChunk_RightParen,
4528 * \brief A left bracket ('[').
4530 CXCompletionChunk_LeftBracket,
4532 * \brief A right bracket (']').
4534 CXCompletionChunk_RightBracket,
4536 * \brief A left brace ('{').
4538 CXCompletionChunk_LeftBrace,
4540 * \brief A right brace ('}').
4542 CXCompletionChunk_RightBrace,
4544 * \brief A left angle bracket ('<').
4546 CXCompletionChunk_LeftAngle,
4548 * \brief A right angle bracket ('>').
4550 CXCompletionChunk_RightAngle,
4552 * \brief A comma separator (',').
4554 CXCompletionChunk_Comma,
4556 * \brief Text that specifies the result type of a given result.
4558 * This special kind of informative chunk is not meant to be inserted into
4559 * the text buffer. Rather, it is meant to illustrate the type that an
4560 * expression using the given completion string would have.
4562 CXCompletionChunk_ResultType,
4564 * \brief A colon (':').
4566 CXCompletionChunk_Colon,
4568 * \brief A semicolon (';').
4570 CXCompletionChunk_SemiColon,
4572 * \brief An '=' sign.
4574 CXCompletionChunk_Equal,
4576 * Horizontal space (' ').
4578 CXCompletionChunk_HorizontalSpace,
4580 * Vertical space ('\n'), after which it is generally a good idea to
4581 * perform indentation.
4583 CXCompletionChunk_VerticalSpace
4587 * \brief Determine the kind of a particular chunk within a completion string.
4589 * \param completion_string the completion string to query.
4591 * \param chunk_number the 0-based index of the chunk in the completion string.
4593 * \returns the kind of the chunk at the index \c chunk_number.
4595 CINDEX_LINKAGE enum CXCompletionChunkKind
4596 clang_getCompletionChunkKind(CXCompletionString completion_string,
4597 unsigned chunk_number);
4600 * \brief Retrieve the text associated with a particular chunk within a
4601 * completion string.
4603 * \param completion_string the completion string to query.
4605 * \param chunk_number the 0-based index of the chunk in the completion string.
4607 * \returns the text associated with the chunk at index \c chunk_number.
4609 CINDEX_LINKAGE CXString
4610 clang_getCompletionChunkText(CXCompletionString completion_string,
4611 unsigned chunk_number);
4614 * \brief Retrieve the completion string associated with a particular chunk
4615 * within a completion string.
4617 * \param completion_string the completion string to query.
4619 * \param chunk_number the 0-based index of the chunk in the completion string.
4621 * \returns the completion string associated with the chunk at index
4624 CINDEX_LINKAGE CXCompletionString
4625 clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4626 unsigned chunk_number);
4629 * \brief Retrieve the number of chunks in the given code-completion string.
4631 CINDEX_LINKAGE unsigned
4632 clang_getNumCompletionChunks(CXCompletionString completion_string);
4635 * \brief Determine the priority of this code completion.
4637 * The priority of a code completion indicates how likely it is that this
4638 * particular completion is the completion that the user will select. The
4639 * priority is selected by various internal heuristics.
4641 * \param completion_string The completion string to query.
4643 * \returns The priority of this completion string. Smaller values indicate
4644 * higher-priority (more likely) completions.
4646 CINDEX_LINKAGE unsigned
4647 clang_getCompletionPriority(CXCompletionString completion_string);
4650 * \brief Determine the availability of the entity that this code-completion
4653 * \param completion_string The completion string to query.
4655 * \returns The availability of the completion string.
4657 CINDEX_LINKAGE enum CXAvailabilityKind
4658 clang_getCompletionAvailability(CXCompletionString completion_string);
4661 * \brief Retrieve the number of annotations associated with the given
4662 * completion string.
4664 * \param completion_string the completion string to query.
4666 * \returns the number of annotations associated with the given completion
4669 CINDEX_LINKAGE unsigned
4670 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
4673 * \brief Retrieve the annotation associated with the given completion string.
4675 * \param completion_string the completion string to query.
4677 * \param annotation_number the 0-based index of the annotation of the
4678 * completion string.
4680 * \returns annotation string associated with the completion at index
4681 * \c annotation_number, or a NULL string if that annotation is not available.
4683 CINDEX_LINKAGE CXString
4684 clang_getCompletionAnnotation(CXCompletionString completion_string,
4685 unsigned annotation_number);
4688 * \brief Retrieve the parent context of the given completion string.
4690 * The parent context of a completion string is the semantic parent of
4691 * the declaration (if any) that the code completion represents. For example,
4692 * a code completion for an Objective-C method would have the method's class
4693 * or protocol as its context.
4695 * \param completion_string The code completion string whose parent is
4698 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
4700 * \returns The name of the completion parent, e.g., "NSObject" if
4701 * the completion string represents a method in the NSObject class.
4703 CINDEX_LINKAGE CXString
4704 clang_getCompletionParent(CXCompletionString completion_string,
4705 enum CXCursorKind *kind);
4708 * \brief Retrieve the brief documentation comment attached to the declaration
4709 * that corresponds to the given completion string.
4711 CINDEX_LINKAGE CXString
4712 clang_getCompletionBriefComment(CXCompletionString completion_string);
4715 * \brief Retrieve a completion string for an arbitrary declaration or macro
4716 * definition cursor.
4718 * \param cursor The cursor to query.
4720 * \returns A non-context-sensitive completion string for declaration and macro
4721 * definition cursors, or NULL for other kinds of cursors.
4723 CINDEX_LINKAGE CXCompletionString
4724 clang_getCursorCompletionString(CXCursor cursor);
4727 * \brief Contains the results of code-completion.
4729 * This data structure contains the results of code completion, as
4730 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
4731 * \c clang_disposeCodeCompleteResults.
4735 * \brief The code-completion results.
4737 CXCompletionResult *Results;
4740 * \brief The number of code-completion results stored in the
4743 unsigned NumResults;
4744 } CXCodeCompleteResults;
4747 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
4748 * modify its behavior.
4750 * The enumerators in this enumeration can be bitwise-OR'd together to
4751 * provide multiple options to \c clang_codeCompleteAt().
4753 enum CXCodeComplete_Flags {
4755 * \brief Whether to include macros within the set of code
4756 * completions returned.
4758 CXCodeComplete_IncludeMacros = 0x01,
4761 * \brief Whether to include code patterns for language constructs
4762 * within the set of code completions, e.g., for loops.
4764 CXCodeComplete_IncludeCodePatterns = 0x02,
4767 * \brief Whether to include brief documentation within the set of code
4768 * completions returned.
4770 CXCodeComplete_IncludeBriefComments = 0x04
4774 * \brief Bits that represent the context under which completion is occurring.
4776 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
4777 * contexts are occurring simultaneously.
4779 enum CXCompletionContext {
4781 * \brief The context for completions is unexposed, as only Clang results
4782 * should be included. (This is equivalent to having no context bits set.)
4784 CXCompletionContext_Unexposed = 0,
4787 * \brief Completions for any possible type should be included in the results.
4789 CXCompletionContext_AnyType = 1 << 0,
4792 * \brief Completions for any possible value (variables, function calls, etc.)
4793 * should be included in the results.
4795 CXCompletionContext_AnyValue = 1 << 1,
4797 * \brief Completions for values that resolve to an Objective-C object should
4798 * be included in the results.
4800 CXCompletionContext_ObjCObjectValue = 1 << 2,
4802 * \brief Completions for values that resolve to an Objective-C selector
4803 * should be included in the results.
4805 CXCompletionContext_ObjCSelectorValue = 1 << 3,
4807 * \brief Completions for values that resolve to a C++ class type should be
4808 * included in the results.
4810 CXCompletionContext_CXXClassTypeValue = 1 << 4,
4813 * \brief Completions for fields of the member being accessed using the dot
4814 * operator should be included in the results.
4816 CXCompletionContext_DotMemberAccess = 1 << 5,
4818 * \brief Completions for fields of the member being accessed using the arrow
4819 * operator should be included in the results.
4821 CXCompletionContext_ArrowMemberAccess = 1 << 6,
4823 * \brief Completions for properties of the Objective-C object being accessed
4824 * using the dot operator should be included in the results.
4826 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
4829 * \brief Completions for enum tags should be included in the results.
4831 CXCompletionContext_EnumTag = 1 << 8,
4833 * \brief Completions for union tags should be included in the results.
4835 CXCompletionContext_UnionTag = 1 << 9,
4837 * \brief Completions for struct tags should be included in the results.
4839 CXCompletionContext_StructTag = 1 << 10,
4842 * \brief Completions for C++ class names should be included in the results.
4844 CXCompletionContext_ClassTag = 1 << 11,
4846 * \brief Completions for C++ namespaces and namespace aliases should be
4847 * included in the results.
4849 CXCompletionContext_Namespace = 1 << 12,
4851 * \brief Completions for C++ nested name specifiers should be included in
4854 CXCompletionContext_NestedNameSpecifier = 1 << 13,
4857 * \brief Completions for Objective-C interfaces (classes) should be included
4860 CXCompletionContext_ObjCInterface = 1 << 14,
4862 * \brief Completions for Objective-C protocols should be included in
4865 CXCompletionContext_ObjCProtocol = 1 << 15,
4867 * \brief Completions for Objective-C categories should be included in
4870 CXCompletionContext_ObjCCategory = 1 << 16,
4872 * \brief Completions for Objective-C instance messages should be included
4875 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
4877 * \brief Completions for Objective-C class messages should be included in
4880 CXCompletionContext_ObjCClassMessage = 1 << 18,
4882 * \brief Completions for Objective-C selector names should be included in
4885 CXCompletionContext_ObjCSelectorName = 1 << 19,
4888 * \brief Completions for preprocessor macro names should be included in
4891 CXCompletionContext_MacroName = 1 << 20,
4894 * \brief Natural language completions should be included in the results.
4896 CXCompletionContext_NaturalLanguage = 1 << 21,
4899 * \brief The current context is unknown, so set all contexts.
4901 CXCompletionContext_Unknown = ((1 << 22) - 1)
4905 * \brief Returns a default set of code-completion options that can be
4906 * passed to\c clang_codeCompleteAt().
4908 CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
4911 * \brief Perform code completion at a given location in a translation unit.
4913 * This function performs code completion at a particular file, line, and
4914 * column within source code, providing results that suggest potential
4915 * code snippets based on the context of the completion. The basic model
4916 * for code completion is that Clang will parse a complete source file,
4917 * performing syntax checking up to the location where code-completion has
4918 * been requested. At that point, a special code-completion token is passed
4919 * to the parser, which recognizes this token and determines, based on the
4920 * current location in the C/Objective-C/C++ grammar and the state of
4921 * semantic analysis, what completions to provide. These completions are
4922 * returned via a new \c CXCodeCompleteResults structure.
4924 * Code completion itself is meant to be triggered by the client when the
4925 * user types punctuation characters or whitespace, at which point the
4926 * code-completion location will coincide with the cursor. For example, if \c p
4927 * is a pointer, code-completion might be triggered after the "-" and then
4928 * after the ">" in \c p->. When the code-completion location is afer the ">",
4929 * the completion results will provide, e.g., the members of the struct that
4930 * "p" points to. The client is responsible for placing the cursor at the
4931 * beginning of the token currently being typed, then filtering the results
4932 * based on the contents of the token. For example, when code-completing for
4933 * the expression \c p->get, the client should provide the location just after
4934 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
4935 * client can filter the results based on the current token text ("get"), only
4936 * showing those results that start with "get". The intent of this interface
4937 * is to separate the relatively high-latency acquisition of code-completion
4938 * results from the filtering of results on a per-character basis, which must
4939 * have a lower latency.
4941 * \param TU The translation unit in which code-completion should
4942 * occur. The source files for this translation unit need not be
4943 * completely up-to-date (and the contents of those source files may
4944 * be overridden via \p unsaved_files). Cursors referring into the
4945 * translation unit may be invalidated by this invocation.
4947 * \param complete_filename The name of the source file where code
4948 * completion should be performed. This filename may be any file
4949 * included in the translation unit.
4951 * \param complete_line The line at which code-completion should occur.
4953 * \param complete_column The column at which code-completion should occur.
4954 * Note that the column should point just after the syntactic construct that
4955 * initiated code completion, and not in the middle of a lexical token.
4957 * \param unsaved_files the Tiles that have not yet been saved to disk
4958 * but may be required for parsing or code completion, including the
4959 * contents of those files. The contents and name of these files (as
4960 * specified by CXUnsavedFile) are copied when necessary, so the
4961 * client only needs to guarantee their validity until the call to
4962 * this function returns.
4964 * \param num_unsaved_files The number of unsaved file entries in \p
4967 * \param options Extra options that control the behavior of code
4968 * completion, expressed as a bitwise OR of the enumerators of the
4969 * CXCodeComplete_Flags enumeration. The
4970 * \c clang_defaultCodeCompleteOptions() function returns a default set
4971 * of code-completion options.
4973 * \returns If successful, a new \c CXCodeCompleteResults structure
4974 * containing code-completion results, which should eventually be
4975 * freed with \c clang_disposeCodeCompleteResults(). If code
4976 * completion fails, returns NULL.
4979 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
4980 const char *complete_filename,
4981 unsigned complete_line,
4982 unsigned complete_column,
4983 struct CXUnsavedFile *unsaved_files,
4984 unsigned num_unsaved_files,
4988 * \brief Sort the code-completion results in case-insensitive alphabetical
4991 * \param Results The set of results to sort.
4992 * \param NumResults The number of results in \p Results.
4995 void clang_sortCodeCompletionResults(CXCompletionResult *Results,
4996 unsigned NumResults);
4999 * \brief Free the given set of code-completion results.
5002 void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
5005 * \brief Determine the number of diagnostics produced prior to the
5006 * location where code completion was performed.
5009 unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5012 * \brief Retrieve a diagnostic associated with the given code completion.
5014 * \param Results the code completion results to query.
5015 * \param Index the zero-based diagnostic number to retrieve.
5017 * \returns the requested diagnostic. This diagnostic must be freed
5018 * via a call to \c clang_disposeDiagnostic().
5021 CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5025 * \brief Determines what compeltions are appropriate for the context
5026 * the given code completion.
5028 * \param Results the code completion results to query
5030 * \returns the kinds of completions that are appropriate for use
5031 * along with the given code completion results.
5034 unsigned long long clang_codeCompleteGetContexts(
5035 CXCodeCompleteResults *Results);
5038 * \brief Returns the cursor kind for the container for the current code
5039 * completion context. The container is only guaranteed to be set for
5040 * contexts where a container exists (i.e. member accesses or Objective-C
5041 * message sends); if there is not a container, this function will return
5042 * CXCursor_InvalidCode.
5044 * \param Results the code completion results to query
5046 * \param IsIncomplete on return, this value will be false if Clang has complete
5047 * information about the container. If Clang does not have complete
5048 * information, this value will be true.
5050 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5054 enum CXCursorKind clang_codeCompleteGetContainerKind(
5055 CXCodeCompleteResults *Results,
5056 unsigned *IsIncomplete);
5059 * \brief Returns the USR for the container for the current code completion
5060 * context. If there is not a container for the current context, this
5061 * function will return the empty string.
5063 * \param Results the code completion results to query
5065 * \returns the USR for the container
5068 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5072 * \brief Returns the currently-entered selector for an Objective-C message
5073 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5074 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5075 * CXCompletionContext_ObjCClassMessage.
5077 * \param Results the code completion results to query
5079 * \returns the selector (or partial selector) that has been entered thus far
5080 * for an Objective-C message send.
5083 CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5091 * \defgroup CINDEX_MISC Miscellaneous utility functions
5097 * \brief Return a version string, suitable for showing to a user, but not
5098 * intended to be parsed (the format is not guaranteed to be stable).
5100 CINDEX_LINKAGE CXString clang_getClangVersion(void);
5104 * \brief Enable/disable crash recovery.
5106 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5107 * value enables crash recovery, while 0 disables it.
5109 CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5112 * \brief Visitor invoked for each file in a translation unit
5113 * (used with clang_getInclusions()).
5115 * This visitor function will be invoked by clang_getInclusions() for each
5116 * file included (either at the top-level or by \#include directives) within
5117 * a translation unit. The first argument is the file being included, and
5118 * the second and third arguments provide the inclusion stack. The
5119 * array is sorted in order of immediate inclusion. For example,
5120 * the first element refers to the location that included 'included_file'.
5122 typedef void (*CXInclusionVisitor)(CXFile included_file,
5123 CXSourceLocation* inclusion_stack,
5124 unsigned include_len,
5125 CXClientData client_data);
5128 * \brief Visit the set of preprocessor inclusions in a translation unit.
5129 * The visitor function is called with the provided data for every included
5130 * file. This does not include headers included by the PCH file (unless one
5131 * is inspecting the inclusions in the PCH file itself).
5133 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5134 CXInclusionVisitor visitor,
5135 CXClientData client_data);
5141 /** \defgroup CINDEX_REMAPPING Remapping functions
5147 * \brief A remapping of original source files and their translated files.
5149 typedef void *CXRemapping;
5152 * \brief Retrieve a remapping.
5154 * \param path the path that contains metadata about remappings.
5156 * \returns the requested remapping. This remapping must be freed
5157 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5159 CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5162 * \brief Retrieve a remapping.
5164 * \param filePaths pointer to an array of file paths containing remapping info.
5166 * \param numFiles number of file paths.
5168 * \returns the requested remapping. This remapping must be freed
5169 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5172 CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5176 * \brief Determine the number of remappings.
5178 CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5181 * \brief Get the original and the associated filename from the remapping.
5183 * \param original If non-NULL, will be set to the original filename.
5185 * \param transformed If non-NULL, will be set to the filename that the original
5186 * is associated with.
5188 CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5189 CXString *original, CXString *transformed);
5192 * \brief Dispose the remapping.
5194 CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5200 /** \defgroup CINDEX_HIGH Higher level API functions
5205 enum CXVisitorResult {
5212 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5213 } CXCursorAndRangeVisitor;
5217 * \brief Function returned successfully.
5219 CXResult_Success = 0,
5221 * \brief One of the parameters was invalid for the function.
5223 CXResult_Invalid = 1,
5225 * \brief The function was terminated by a callback (e.g. it returned
5228 CXResult_VisitBreak = 2
5233 * \brief Find references of a declaration in a specific file.
5235 * \param cursor pointing to a declaration or a reference of one.
5237 * \param file to search for references.
5239 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5240 * each reference found.
5241 * The CXSourceRange will point inside the file; if the reference is inside
5242 * a macro (and not a macro argument) the CXSourceRange will be invalid.
5244 * \returns one of the CXResult enumerators.
5246 CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5247 CXCursorAndRangeVisitor visitor);
5250 * \brief Find #import/#include directives in a specific file.
5252 * \param TU translation unit containing the file to query.
5254 * \param file to search for #import/#include directives.
5256 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5257 * each directive found.
5259 * \returns one of the CXResult enumerators.
5261 CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5263 CXCursorAndRangeVisitor visitor);
5265 #ifdef __has_feature
5266 # if __has_feature(blocks)
5268 typedef enum CXVisitorResult
5269 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5272 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5273 CXCursorAndRangeVisitorBlock);
5276 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5277 CXCursorAndRangeVisitorBlock);
5283 * \brief The client's data object that is associated with a CXFile.
5285 typedef void *CXIdxClientFile;
5288 * \brief The client's data object that is associated with a semantic entity.
5290 typedef void *CXIdxClientEntity;
5293 * \brief The client's data object that is associated with a semantic container
5296 typedef void *CXIdxClientContainer;
5299 * \brief The client's data object that is associated with an AST file (PCH
5302 typedef void *CXIdxClientASTFile;
5305 * \brief Source location passed to index callbacks.
5313 * \brief Data for ppIncludedFile callback.
5317 * \brief Location of '#' in the \#include/\#import directive.
5321 * \brief Filename as written in the \#include/\#import directive.
5323 const char *filename;
5325 * \brief The actual file that the \#include/\#import directive resolved to.
5331 * \brief Non-zero if the directive was automatically turned into a module
5335 } CXIdxIncludedFileInfo;
5338 * \brief Data for IndexerCallbacks#importedASTFile.
5342 * \brief Top level AST file containing the imported PCH, module or submodule.
5346 * \brief The imported module or NULL if the AST file is a PCH.
5350 * \brief Location where the file is imported. Applicable only for modules.
5354 * \brief Non-zero if an inclusion directive was automatically turned into
5355 * a module import. Applicable only for modules.
5359 } CXIdxImportedASTFileInfo;
5362 CXIdxEntity_Unexposed = 0,
5363 CXIdxEntity_Typedef = 1,
5364 CXIdxEntity_Function = 2,
5365 CXIdxEntity_Variable = 3,
5366 CXIdxEntity_Field = 4,
5367 CXIdxEntity_EnumConstant = 5,
5369 CXIdxEntity_ObjCClass = 6,
5370 CXIdxEntity_ObjCProtocol = 7,
5371 CXIdxEntity_ObjCCategory = 8,
5373 CXIdxEntity_ObjCInstanceMethod = 9,
5374 CXIdxEntity_ObjCClassMethod = 10,
5375 CXIdxEntity_ObjCProperty = 11,
5376 CXIdxEntity_ObjCIvar = 12,
5378 CXIdxEntity_Enum = 13,
5379 CXIdxEntity_Struct = 14,
5380 CXIdxEntity_Union = 15,
5382 CXIdxEntity_CXXClass = 16,
5383 CXIdxEntity_CXXNamespace = 17,
5384 CXIdxEntity_CXXNamespaceAlias = 18,
5385 CXIdxEntity_CXXStaticVariable = 19,
5386 CXIdxEntity_CXXStaticMethod = 20,
5387 CXIdxEntity_CXXInstanceMethod = 21,
5388 CXIdxEntity_CXXConstructor = 22,
5389 CXIdxEntity_CXXDestructor = 23,
5390 CXIdxEntity_CXXConversionFunction = 24,
5391 CXIdxEntity_CXXTypeAlias = 25,
5392 CXIdxEntity_CXXInterface = 26
5397 CXIdxEntityLang_None = 0,
5398 CXIdxEntityLang_C = 1,
5399 CXIdxEntityLang_ObjC = 2,
5400 CXIdxEntityLang_CXX = 3
5401 } CXIdxEntityLanguage;
5404 * \brief Extra C++ template information for an entity. This can apply to:
5405 * CXIdxEntity_Function
5406 * CXIdxEntity_CXXClass
5407 * CXIdxEntity_CXXStaticMethod
5408 * CXIdxEntity_CXXInstanceMethod
5409 * CXIdxEntity_CXXConstructor
5410 * CXIdxEntity_CXXConversionFunction
5411 * CXIdxEntity_CXXTypeAlias
5414 CXIdxEntity_NonTemplate = 0,
5415 CXIdxEntity_Template = 1,
5416 CXIdxEntity_TemplatePartialSpecialization = 2,
5417 CXIdxEntity_TemplateSpecialization = 3
5418 } CXIdxEntityCXXTemplateKind;
5421 CXIdxAttr_Unexposed = 0,
5422 CXIdxAttr_IBAction = 1,
5423 CXIdxAttr_IBOutlet = 2,
5424 CXIdxAttr_IBOutletCollection = 3
5434 CXIdxEntityKind kind;
5435 CXIdxEntityCXXTemplateKind templateKind;
5436 CXIdxEntityLanguage lang;
5440 const CXIdxAttrInfo *const *attributes;
5441 unsigned numAttributes;
5446 } CXIdxContainerInfo;
5449 const CXIdxAttrInfo *attrInfo;
5450 const CXIdxEntityInfo *objcClass;
5451 CXCursor classCursor;
5453 } CXIdxIBOutletCollectionAttrInfo;
5456 CXIdxDeclFlag_Skipped = 0x1
5457 } CXIdxDeclInfoFlags;
5460 const CXIdxEntityInfo *entityInfo;
5463 const CXIdxContainerInfo *semanticContainer;
5465 * \brief Generally same as #semanticContainer but can be different in
5466 * cases like out-of-line C++ member functions.
5468 const CXIdxContainerInfo *lexicalContainer;
5469 int isRedeclaration;
5472 const CXIdxContainerInfo *declAsContainer;
5474 * \brief Whether the declaration exists in code or was created implicitly
5475 * by the compiler, e.g. implicit objc methods for properties.
5478 const CXIdxAttrInfo *const *attributes;
5479 unsigned numAttributes;
5486 CXIdxObjCContainer_ForwardRef = 0,
5487 CXIdxObjCContainer_Interface = 1,
5488 CXIdxObjCContainer_Implementation = 2
5489 } CXIdxObjCContainerKind;
5492 const CXIdxDeclInfo *declInfo;
5493 CXIdxObjCContainerKind kind;
5494 } CXIdxObjCContainerDeclInfo;
5497 const CXIdxEntityInfo *base;
5500 } CXIdxBaseClassInfo;
5503 const CXIdxEntityInfo *protocol;
5506 } CXIdxObjCProtocolRefInfo;
5509 const CXIdxObjCProtocolRefInfo *const *protocols;
5510 unsigned numProtocols;
5511 } CXIdxObjCProtocolRefListInfo;
5514 const CXIdxObjCContainerDeclInfo *containerInfo;
5515 const CXIdxBaseClassInfo *superInfo;
5516 const CXIdxObjCProtocolRefListInfo *protocols;
5517 } CXIdxObjCInterfaceDeclInfo;
5520 const CXIdxObjCContainerDeclInfo *containerInfo;
5521 const CXIdxEntityInfo *objcClass;
5522 CXCursor classCursor;
5524 const CXIdxObjCProtocolRefListInfo *protocols;
5525 } CXIdxObjCCategoryDeclInfo;
5528 const CXIdxDeclInfo *declInfo;
5529 const CXIdxEntityInfo *getter;
5530 const CXIdxEntityInfo *setter;
5531 } CXIdxObjCPropertyDeclInfo;
5534 const CXIdxDeclInfo *declInfo;
5535 const CXIdxBaseClassInfo *const *bases;
5537 } CXIdxCXXClassDeclInfo;
5540 * \brief Data for IndexerCallbacks#indexEntityReference.
5544 * \brief The entity is referenced directly in user's code.
5546 CXIdxEntityRef_Direct = 1,
5548 * \brief An implicit reference, e.g. a reference of an ObjC method via the
5551 CXIdxEntityRef_Implicit = 2
5552 } CXIdxEntityRefKind;
5555 * \brief Data for IndexerCallbacks#indexEntityReference.
5558 CXIdxEntityRefKind kind;
5560 * \brief Reference cursor.
5565 * \brief The entity that gets referenced.
5567 const CXIdxEntityInfo *referencedEntity;
5569 * \brief Immediate "parent" of the reference. For example:
5575 * The parent of reference of type 'Foo' is the variable 'var'.
5576 * For references inside statement bodies of functions/methods,
5577 * the parentEntity will be the function/method.
5579 const CXIdxEntityInfo *parentEntity;
5581 * \brief Lexical container context of the reference.
5583 const CXIdxContainerInfo *container;
5584 } CXIdxEntityRefInfo;
5587 * \brief A group of callbacks used by #clang_indexSourceFile and
5588 * #clang_indexTranslationUnit.
5592 * \brief Called periodically to check whether indexing should be aborted.
5593 * Should return 0 to continue, and non-zero to abort.
5595 int (*abortQuery)(CXClientData client_data, void *reserved);
5598 * \brief Called at the end of indexing; passes the complete diagnostic set.
5600 void (*diagnostic)(CXClientData client_data,
5601 CXDiagnosticSet, void *reserved);
5603 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
5604 CXFile mainFile, void *reserved);
5607 * \brief Called when a file gets \#included/\#imported.
5609 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
5610 const CXIdxIncludedFileInfo *);
5613 * \brief Called when a AST file (PCH or module) gets imported.
5615 * AST files will not get indexed (there will not be callbacks to index all
5616 * the entities in an AST file). The recommended action is that, if the AST
5617 * file is not already indexed, to initiate a new indexing job specific to
5620 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
5621 const CXIdxImportedASTFileInfo *);
5624 * \brief Called at the beginning of indexing a translation unit.
5626 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
5629 void (*indexDeclaration)(CXClientData client_data,
5630 const CXIdxDeclInfo *);
5633 * \brief Called to index a reference of an entity.
5635 void (*indexEntityReference)(CXClientData client_data,
5636 const CXIdxEntityRefInfo *);
5640 CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
5641 CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
5642 clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
5644 CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
5645 clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
5648 const CXIdxObjCCategoryDeclInfo *
5649 clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
5651 CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
5652 clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
5654 CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
5655 clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
5657 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
5658 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
5660 CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
5661 clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
5664 * \brief For retrieving a custom CXIdxClientContainer attached to a
5667 CINDEX_LINKAGE CXIdxClientContainer
5668 clang_index_getClientContainer(const CXIdxContainerInfo *);
5671 * \brief For setting a custom CXIdxClientContainer attached to a
5675 clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
5678 * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
5680 CINDEX_LINKAGE CXIdxClientEntity
5681 clang_index_getClientEntity(const CXIdxEntityInfo *);
5684 * \brief For setting a custom CXIdxClientEntity attached to an entity.
5687 clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
5690 * \brief An indexing action/session, to be applied to one or multiple
5691 * translation units.
5693 typedef void *CXIndexAction;
5696 * \brief An indexing action/session, to be applied to one or multiple
5697 * translation units.
5699 * \param CIdx The index object with which the index action will be associated.
5701 CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
5704 * \brief Destroy the given index action.
5706 * The index action must not be destroyed until all of the translation units
5707 * created within that index action have been destroyed.
5709 CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
5713 * \brief Used to indicate that no special indexing options are needed.
5715 CXIndexOpt_None = 0x0,
5718 * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
5719 * be invoked for only one reference of an entity per source file that does
5720 * not also include a declaration/definition of the entity.
5722 CXIndexOpt_SuppressRedundantRefs = 0x1,
5725 * \brief Function-local symbols should be indexed. If this is not set
5726 * function-local symbols will be ignored.
5728 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
5731 * \brief Implicit function/class template instantiations should be indexed.
5732 * If this is not set, implicit instantiations will be ignored.
5734 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
5737 * \brief Suppress all compiler warnings when parsing for indexing.
5739 CXIndexOpt_SuppressWarnings = 0x8,
5742 * \brief Skip a function/method body that was already parsed during an
5743 * indexing session assosiated with a \c CXIndexAction object.
5744 * Bodies in system headers are always skipped.
5746 CXIndexOpt_SkipParsedBodiesInSession = 0x10
5751 * \brief Index the given source file and the translation unit corresponding
5752 * to that file via callbacks implemented through #IndexerCallbacks.
5754 * \param client_data pointer data supplied by the client, which will
5755 * be passed to the invoked callbacks.
5757 * \param index_callbacks Pointer to indexing callbacks that the client
5760 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
5761 * passed in index_callbacks.
5763 * \param index_options A bitmask of options that affects how indexing is
5764 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
5766 * \param out_TU [out] pointer to store a CXTranslationUnit that can be reused
5767 * after indexing is finished. Set to NULL if you do not require it.
5769 * \returns If there is a failure from which the there is no recovery, returns
5770 * non-zero, otherwise returns 0.
5772 * The rest of the parameters are the same as #clang_parseTranslationUnit.
5774 CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
5775 CXClientData client_data,
5776 IndexerCallbacks *index_callbacks,
5777 unsigned index_callbacks_size,
5778 unsigned index_options,
5779 const char *source_filename,
5780 const char * const *command_line_args,
5781 int num_command_line_args,
5782 struct CXUnsavedFile *unsaved_files,
5783 unsigned num_unsaved_files,
5784 CXTranslationUnit *out_TU,
5785 unsigned TU_options);
5788 * \brief Index the given translation unit via callbacks implemented through
5789 * #IndexerCallbacks.
5791 * The order of callback invocations is not guaranteed to be the same as
5792 * when indexing a source file. The high level order will be:
5794 * -Preprocessor callbacks invocations
5795 * -Declaration/reference callbacks invocations
5796 * -Diagnostic callback invocations
5798 * The parameters are the same as #clang_indexSourceFile.
5800 * \returns If there is a failure from which the there is no recovery, returns
5801 * non-zero, otherwise returns 0.
5803 CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
5804 CXClientData client_data,
5805 IndexerCallbacks *index_callbacks,
5806 unsigned index_callbacks_size,
5807 unsigned index_options,
5811 * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
5812 * the given CXIdxLoc.
5814 * If the location refers into a macro expansion, retrieves the
5815 * location of the macro expansion and if it refers into a macro argument
5816 * retrieves the location of the argument.
5818 CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
5819 CXIdxClientFile *indexFile,
5826 * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
5829 CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);