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
23 #include "clang-c/Platform.h"
24 #include "clang-c/CXString.h"
27 * \brief The version constants for the libclang API.
28 * CINDEX_VERSION_MINOR should increase when there are API additions.
29 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
31 * The policy about the libclang API was always to keep it source and ABI
32 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
34 #define CINDEX_VERSION_MAJOR 0
35 #define CINDEX_VERSION_MINOR 19
37 #define CINDEX_VERSION_ENCODE(major, minor) ( \
41 #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
42 CINDEX_VERSION_MAJOR, \
43 CINDEX_VERSION_MINOR )
45 #define CINDEX_VERSION_STRINGIZE_(major, minor) \
47 #define CINDEX_VERSION_STRINGIZE(major, minor) \
48 CINDEX_VERSION_STRINGIZE_(major, minor)
50 #define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
51 CINDEX_VERSION_MAJOR, \
58 /** \defgroup CINDEX libclang: C Interface to Clang
60 * The C Interface to Clang provides a relatively small API that exposes
61 * facilities for parsing source code into an abstract syntax tree (AST),
62 * loading already-parsed ASTs, traversing the AST, associating
63 * physical source locations with elements within the AST, and other
64 * facilities that support Clang-based development tools.
66 * This C interface to Clang will never provide all of the information
67 * representation stored in Clang's C++ AST, nor should it: the intent is to
68 * maintain an API that is relatively stable from one release to the next,
69 * providing only the basic functionality needed to support development tools.
71 * To avoid namespace pollution, data types are prefixed with "CX" and
72 * functions are prefixed with "clang_".
78 * \brief An "index" that consists of a set of translation units that would
79 * typically be linked together into an executable or library.
81 typedef void *CXIndex;
84 * \brief A single translation unit, which resides in an index.
86 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
89 * \brief Opaque pointer representing client data that will be passed through
90 * to various callbacks and visitors.
92 typedef void *CXClientData;
95 * \brief Provides the contents of a file that has not yet been saved to disk.
97 * Each CXUnsavedFile instance provides the name of a file on the
98 * system along with the current contents of that file that have not
99 * yet been saved to disk.
101 struct CXUnsavedFile {
103 * \brief The file whose contents have not yet been saved.
105 * This file must already exist in the file system.
107 const char *Filename;
110 * \brief A buffer containing the unsaved contents of this file.
112 const char *Contents;
115 * \brief The length of the unsaved contents of this buffer.
117 unsigned long Length;
121 * \brief Describes the availability of a particular entity, which indicates
122 * whether the use of this entity will result in a warning or error due to
123 * it being deprecated or unavailable.
125 enum CXAvailabilityKind {
127 * \brief The entity is available.
129 CXAvailability_Available,
131 * \brief The entity is available, but has been deprecated (and its use is
134 CXAvailability_Deprecated,
136 * \brief The entity is not available; any use of it will be an error.
138 CXAvailability_NotAvailable,
140 * \brief The entity is available, but not accessible; any use of it will be
143 CXAvailability_NotAccessible
147 * \brief Describes a version number of the form major.minor.subminor.
149 typedef struct CXVersion {
151 * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
152 * value indicates that there is no version number at all.
156 * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
157 * will be negative if no minor version number was provided, e.g., for
162 * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
163 * will be negative if no minor or subminor version number was provided,
164 * e.g., in version '10' or '10.7'.
170 * \brief Provides a shared context for creating translation units.
172 * It provides two options:
174 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
175 * declarations (when loading any new translation units). A "local" declaration
176 * is one that belongs in the translation unit itself and not in a precompiled
177 * header that was used by the translation unit. If zero, all declarations
178 * will be enumerated.
180 * Here is an example:
183 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
184 * Idx = clang_createIndex(1, 1);
186 * // IndexTest.pch was produced with the following command:
187 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
188 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
190 * // This will load all the symbols from 'IndexTest.pch'
191 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
192 * TranslationUnitVisitor, 0);
193 * clang_disposeTranslationUnit(TU);
195 * // This will load all the symbols from 'IndexTest.c', excluding symbols
196 * // from 'IndexTest.pch'.
197 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
198 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
200 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
201 * TranslationUnitVisitor, 0);
202 * clang_disposeTranslationUnit(TU);
205 * This process of creating the 'pch', loading it separately, and using it (via
206 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
207 * (which gives the indexer the same performance benefit as the compiler).
209 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
210 int displayDiagnostics);
213 * \brief Destroy the given index.
215 * The index must not be destroyed until all of the translation units created
216 * within that index have been destroyed.
218 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
222 * \brief Used to indicate that no special CXIndex options are needed.
224 CXGlobalOpt_None = 0x0,
227 * \brief Used to indicate that threads that libclang creates for indexing
228 * purposes should use background priority.
230 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
231 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
233 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
236 * \brief Used to indicate that threads that libclang creates for editing
237 * purposes should use background priority.
239 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
240 * #clang_annotateTokens
242 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
245 * \brief Used to indicate that all threads that libclang creates should use
246 * background priority.
248 CXGlobalOpt_ThreadBackgroundPriorityForAll =
249 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
250 CXGlobalOpt_ThreadBackgroundPriorityForEditing
255 * \brief Sets general options associated with a CXIndex.
260 * clang_CXIndex_setGlobalOptions(idx,
261 * clang_CXIndex_getGlobalOptions(idx) |
262 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
265 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
267 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
270 * \brief Gets the general options associated with a CXIndex.
272 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
273 * are associated with the given CXIndex object.
275 CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
278 * \defgroup CINDEX_FILES File manipulation routines
284 * \brief A particular source file that is part of a translation unit.
286 typedef void *CXFile;
290 * \brief Retrieve the complete file and path name of the given file.
292 CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
295 * \brief Retrieve the last modification time of the given file.
297 CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
300 * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
301 * across an indexing session.
304 unsigned long long data[3];
308 * \brief Retrieve the unique ID for the given \c file.
310 * \param file the file to get the ID for.
311 * \param outID stores the returned CXFileUniqueID.
312 * \returns If there was a failure getting the unique ID, returns non-zero,
313 * otherwise returns 0.
315 CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
318 * \brief Determine whether the given header is guarded against
319 * multiple inclusions, either with the conventional
320 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
322 CINDEX_LINKAGE unsigned
323 clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
326 * \brief Retrieve a file handle within the given translation unit.
328 * \param tu the translation unit
330 * \param file_name the name of the file.
332 * \returns the file handle for the named file in the translation unit \p tu,
333 * or a NULL file handle if the file was not a part of this translation unit.
335 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
336 const char *file_name);
343 * \defgroup CINDEX_LOCATIONS Physical source locations
345 * Clang represents physical source locations in its abstract syntax tree in
346 * great detail, with file, line, and column information for the majority of
347 * the tokens parsed in the source code. These data types and functions are
348 * used to represent source location information, either for a particular
349 * point in the program or for a range of points in the program, and extract
350 * specific location information from those data types.
356 * \brief Identifies a specific source location within a translation
359 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
360 * to map a source location to a particular file, line, and column.
363 const void *ptr_data[2];
368 * \brief Identifies a half-open character range in the source code.
370 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
371 * starting and end locations from a source range, respectively.
374 const void *ptr_data[2];
375 unsigned begin_int_data;
376 unsigned end_int_data;
380 * \brief Retrieve a NULL (invalid) source location.
382 CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
385 * \brief Determine whether two source locations, which must refer into
386 * the same translation unit, refer to exactly the same point in the source
389 * \returns non-zero if the source locations refer to the same location, zero
390 * if they refer to different locations.
392 CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
393 CXSourceLocation loc2);
396 * \brief Retrieves the source location associated with a given file/line/column
397 * in a particular translation unit.
399 CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
404 * \brief Retrieves the source location associated with a given character offset
405 * in a particular translation unit.
407 CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
412 * \brief Returns non-zero if the given source location is in a system header.
414 CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
417 * \brief Retrieve a NULL (invalid) source range.
419 CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
422 * \brief Retrieve a source range given the beginning and ending source
425 CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
426 CXSourceLocation end);
429 * \brief Determine whether two ranges are equivalent.
431 * \returns non-zero if the ranges are the same, zero if they differ.
433 CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
434 CXSourceRange range2);
437 * \brief Returns non-zero if \p range is null.
439 CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
442 * \brief Retrieve the file, line, column, and offset represented by
443 * the given source location.
445 * If the location refers into a macro expansion, retrieves the
446 * location of the macro expansion.
448 * \param location the location within a source file that will be decomposed
451 * \param file [out] if non-NULL, will be set to the file to which the given
452 * source location points.
454 * \param line [out] if non-NULL, will be set to the line to which the given
455 * source location points.
457 * \param column [out] if non-NULL, will be set to the column to which the given
458 * source location points.
460 * \param offset [out] if non-NULL, will be set to the offset into the
461 * buffer to which the given source location points.
463 CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
470 * \brief Retrieve the file, line, column, and offset represented by
471 * the given source location, as specified in a # line directive.
473 * Example: given the following source code in a file somefile.c
478 * static int func(void)
484 * the location information returned by this function would be
486 * File: dummy.c Line: 124 Column: 12
488 * whereas clang_getExpansionLocation would have returned
490 * File: somefile.c Line: 3 Column: 12
492 * \param location the location within a source file that will be decomposed
495 * \param filename [out] if non-NULL, will be set to the filename of the
496 * source location. Note that filenames returned will be for "virtual" files,
497 * which don't necessarily exist on the machine running clang - e.g. when
498 * parsing preprocessed output obtained from a different environment. If
499 * a non-NULL value is passed in, remember to dispose of the returned value
500 * using \c clang_disposeString() once you've finished with it. For an invalid
501 * source location, an empty string is returned.
503 * \param line [out] if non-NULL, will be set to the line number of the
504 * source location. For an invalid source location, zero is returned.
506 * \param column [out] if non-NULL, will be set to the column number of the
507 * source location. For an invalid source location, zero is returned.
509 CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
515 * \brief Legacy API to retrieve the file, line, column, and offset represented
516 * by the given source location.
518 * This interface has been replaced by the newer interface
519 * #clang_getExpansionLocation(). See that interface's documentation for
522 CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
529 * \brief Retrieve the file, line, column, and offset represented by
530 * the given source location.
532 * If the location refers into a macro instantiation, return where the
533 * location was originally spelled in the source file.
535 * \param location the location within a source file that will be decomposed
538 * \param file [out] if non-NULL, will be set to the file to which the given
539 * source location points.
541 * \param line [out] if non-NULL, will be set to the line to which the given
542 * source location points.
544 * \param column [out] if non-NULL, will be set to the column to which the given
545 * source location points.
547 * \param offset [out] if non-NULL, will be set to the offset into the
548 * buffer to which the given source location points.
550 CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
557 * \brief Retrieve the file, line, column, and offset represented by
558 * the given source location.
560 * If the location refers into a macro expansion, return where the macro was
561 * expanded or where the macro argument was written, if the location points at
564 * \param location the location within a source file that will be decomposed
567 * \param file [out] if non-NULL, will be set to the file to which the given
568 * source location points.
570 * \param line [out] if non-NULL, will be set to the line to which the given
571 * source location points.
573 * \param column [out] if non-NULL, will be set to the column to which the given
574 * source location points.
576 * \param offset [out] if non-NULL, will be set to the offset into the
577 * buffer to which the given source location points.
579 CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
586 * \brief Retrieve a source location representing the first character within a
589 CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
592 * \brief Retrieve a source location representing the last character within a
595 CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
602 * \defgroup CINDEX_DIAG Diagnostic reporting
608 * \brief Describes the severity of a particular diagnostic.
610 enum CXDiagnosticSeverity {
612 * \brief A diagnostic that has been suppressed, e.g., by a command-line
615 CXDiagnostic_Ignored = 0,
618 * \brief This diagnostic is a note that should be attached to the
619 * previous (non-note) diagnostic.
621 CXDiagnostic_Note = 1,
624 * \brief This diagnostic indicates suspicious code that may not be
627 CXDiagnostic_Warning = 2,
630 * \brief This diagnostic indicates that the code is ill-formed.
632 CXDiagnostic_Error = 3,
635 * \brief This diagnostic indicates that the code is ill-formed such
636 * that future parser recovery is unlikely to produce useful
639 CXDiagnostic_Fatal = 4
643 * \brief A single diagnostic, containing the diagnostic's severity,
644 * location, text, source ranges, and fix-it hints.
646 typedef void *CXDiagnostic;
649 * \brief A group of CXDiagnostics.
651 typedef void *CXDiagnosticSet;
654 * \brief Determine the number of diagnostics in a CXDiagnosticSet.
656 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
659 * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
661 * \param Diags the CXDiagnosticSet to query.
662 * \param Index the zero-based diagnostic number to retrieve.
664 * \returns the requested diagnostic. This diagnostic must be freed
665 * via a call to \c clang_disposeDiagnostic().
667 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
672 * \brief Describes the kind of error that occurred (if any) in a call to
673 * \c clang_loadDiagnostics.
675 enum CXLoadDiag_Error {
677 * \brief Indicates that no error occurred.
682 * \brief Indicates that an unknown error occurred while attempting to
683 * deserialize diagnostics.
685 CXLoadDiag_Unknown = 1,
688 * \brief Indicates that the file containing the serialized diagnostics
689 * could not be opened.
691 CXLoadDiag_CannotLoad = 2,
694 * \brief Indicates that the serialized diagnostics file is invalid or
697 CXLoadDiag_InvalidFile = 3
701 * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
704 * \param file The name of the file to deserialize.
705 * \param error A pointer to a enum value recording if there was a problem
706 * deserializing the diagnostics.
707 * \param errorString A pointer to a CXString for recording the error string
708 * if the file was not successfully loaded.
710 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
711 * diagnostics should be released using clang_disposeDiagnosticSet().
713 CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
714 enum CXLoadDiag_Error *error,
715 CXString *errorString);
718 * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
720 CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
723 * \brief Retrieve the child diagnostics of a CXDiagnostic.
725 * This CXDiagnosticSet does not need to be released by
726 * clang_diposeDiagnosticSet.
728 CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
731 * \brief Determine the number of diagnostics produced for the given
734 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
737 * \brief Retrieve a diagnostic associated with the given translation unit.
739 * \param Unit the translation unit to query.
740 * \param Index the zero-based diagnostic number to retrieve.
742 * \returns the requested diagnostic. This diagnostic must be freed
743 * via a call to \c clang_disposeDiagnostic().
745 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
749 * \brief Retrieve the complete set of diagnostics associated with a
752 * \param Unit the translation unit to query.
754 CINDEX_LINKAGE CXDiagnosticSet
755 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
758 * \brief Destroy a diagnostic.
760 CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
763 * \brief Options to control the display of diagnostics.
765 * The values in this enum are meant to be combined to customize the
766 * behavior of \c clang_displayDiagnostic().
768 enum CXDiagnosticDisplayOptions {
770 * \brief Display the source-location information where the
771 * diagnostic was located.
773 * When set, diagnostics will be prefixed by the file, line, and
774 * (optionally) column to which the diagnostic refers. For example,
777 * test.c:28: warning: extra tokens at end of #endif directive
780 * This option corresponds to the clang flag \c -fshow-source-location.
782 CXDiagnostic_DisplaySourceLocation = 0x01,
785 * \brief If displaying the source-location information of the
786 * diagnostic, also include the column number.
788 * This option corresponds to the clang flag \c -fshow-column.
790 CXDiagnostic_DisplayColumn = 0x02,
793 * \brief If displaying the source-location information of the
794 * diagnostic, also include information about source ranges in a
795 * machine-parsable format.
797 * This option corresponds to the clang flag
798 * \c -fdiagnostics-print-source-range-info.
800 CXDiagnostic_DisplaySourceRanges = 0x04,
803 * \brief Display the option name associated with this diagnostic, if any.
805 * The option name displayed (e.g., -Wconversion) will be placed in brackets
806 * after the diagnostic text. This option corresponds to the clang flag
807 * \c -fdiagnostics-show-option.
809 CXDiagnostic_DisplayOption = 0x08,
812 * \brief Display the category number associated with this diagnostic, if any.
814 * The category number is displayed within brackets after the diagnostic text.
815 * This option corresponds to the clang flag
816 * \c -fdiagnostics-show-category=id.
818 CXDiagnostic_DisplayCategoryId = 0x10,
821 * \brief Display the category name associated with this diagnostic, if any.
823 * The category name is displayed within brackets after the diagnostic text.
824 * This option corresponds to the clang flag
825 * \c -fdiagnostics-show-category=name.
827 CXDiagnostic_DisplayCategoryName = 0x20
831 * \brief Format the given diagnostic in a manner that is suitable for display.
833 * This routine will format the given diagnostic to a string, rendering
834 * the diagnostic according to the various options given. The
835 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
836 * options that most closely mimics the behavior of the clang compiler.
838 * \param Diagnostic The diagnostic to print.
840 * \param Options A set of options that control the diagnostic display,
841 * created by combining \c CXDiagnosticDisplayOptions values.
843 * \returns A new string containing for formatted diagnostic.
845 CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
849 * \brief Retrieve the set of display options most similar to the
850 * default behavior of the clang compiler.
852 * \returns A set of display options suitable for use with \c
853 * clang_displayDiagnostic().
855 CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
858 * \brief Determine the severity of the given diagnostic.
860 CINDEX_LINKAGE enum CXDiagnosticSeverity
861 clang_getDiagnosticSeverity(CXDiagnostic);
864 * \brief Retrieve the source location of the given diagnostic.
866 * This location is where Clang would print the caret ('^') when
867 * displaying the diagnostic on the command line.
869 CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
872 * \brief Retrieve the text of the given diagnostic.
874 CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
877 * \brief Retrieve the name of the command-line option that enabled this
880 * \param Diag The diagnostic to be queried.
882 * \param Disable If non-NULL, will be set to the option that disables this
883 * diagnostic (if any).
885 * \returns A string that contains the command-line option used to enable this
886 * warning, such as "-Wconversion" or "-pedantic".
888 CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
892 * \brief Retrieve the category number for this diagnostic.
894 * Diagnostics can be categorized into groups along with other, related
895 * diagnostics (e.g., diagnostics under the same warning flag). This routine
896 * retrieves the category number for the given diagnostic.
898 * \returns The number of the category that contains this diagnostic, or zero
899 * if this diagnostic is uncategorized.
901 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
904 * \brief Retrieve the name of a particular diagnostic category. This
905 * is now deprecated. Use clang_getDiagnosticCategoryText()
908 * \param Category A diagnostic category number, as returned by
909 * \c clang_getDiagnosticCategory().
911 * \returns The name of the given diagnostic category.
913 CINDEX_DEPRECATED CINDEX_LINKAGE
914 CXString clang_getDiagnosticCategoryName(unsigned Category);
917 * \brief Retrieve the diagnostic category text for a given diagnostic.
919 * \returns The text of the given diagnostic category.
921 CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
924 * \brief Determine the number of source ranges associated with the given
927 CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
930 * \brief Retrieve a source range associated with the diagnostic.
932 * A diagnostic's source ranges highlight important elements in the source
933 * code. On the command line, Clang displays source ranges by
934 * underlining them with '~' characters.
936 * \param Diagnostic the diagnostic whose range is being extracted.
938 * \param Range the zero-based index specifying which range to
940 * \returns the requested source range.
942 CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
946 * \brief Determine the number of fix-it hints associated with the
949 CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
952 * \brief Retrieve the replacement information for a given fix-it.
954 * Fix-its are described in terms of a source range whose contents
955 * should be replaced by a string. This approach generalizes over
956 * three kinds of operations: removal of source code (the range covers
957 * the code to be removed and the replacement string is empty),
958 * replacement of source code (the range covers the code to be
959 * replaced and the replacement string provides the new code), and
960 * insertion (both the start and end of the range point at the
961 * insertion location, and the replacement string provides the text to
964 * \param Diagnostic The diagnostic whose fix-its are being queried.
966 * \param FixIt The zero-based index of the fix-it.
968 * \param ReplacementRange The source range whose contents will be
969 * replaced with the returned replacement string. Note that source
970 * ranges are half-open ranges [a, b), so the source code should be
971 * replaced from a and up to (but not including) b.
973 * \returns A string containing text that should be replace the source
974 * code indicated by the \c ReplacementRange.
976 CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
978 CXSourceRange *ReplacementRange);
985 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
987 * The routines in this group provide the ability to create and destroy
988 * translation units from files, either by parsing the contents of the files or
989 * by reading in a serialized representation of a translation unit.
995 * \brief Get the original translation unit source file name.
997 CINDEX_LINKAGE CXString
998 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1001 * \brief Return the CXTranslationUnit for a given source file and the provided
1002 * command line arguments one would pass to the compiler.
1004 * Note: The 'source_filename' argument is optional. If the caller provides a
1005 * NULL pointer, the name of the source file is expected to reside in the
1006 * specified command line arguments.
1008 * Note: When encountered in 'clang_command_line_args', the following options
1014 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
1016 * \param CIdx The index object with which the translation unit will be
1019 * \param source_filename The name of the source file to load, or NULL if the
1020 * source file is included in \p clang_command_line_args.
1022 * \param num_clang_command_line_args The number of command-line arguments in
1023 * \p clang_command_line_args.
1025 * \param clang_command_line_args The command-line arguments that would be
1026 * passed to the \c clang executable if it were being invoked out-of-process.
1027 * These command-line options will be parsed and will affect how the translation
1028 * unit is parsed. Note that the following options are ignored: '-c',
1029 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1031 * \param num_unsaved_files the number of unsaved file entries in \p
1034 * \param unsaved_files the files that have not yet been saved to disk
1035 * but may be required for code completion, including the contents of
1036 * those files. The contents and name of these files (as specified by
1037 * CXUnsavedFile) are copied when necessary, so the client only needs to
1038 * guarantee their validity until the call to this function returns.
1040 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1042 const char *source_filename,
1043 int num_clang_command_line_args,
1044 const char * const *clang_command_line_args,
1045 unsigned num_unsaved_files,
1046 struct CXUnsavedFile *unsaved_files);
1049 * \brief Create a translation unit from an AST file (-emit-ast).
1051 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
1052 const char *ast_filename);
1055 * \brief Flags that control the creation of translation units.
1057 * The enumerators in this enumeration type are meant to be bitwise
1058 * ORed together to specify which options should be used when
1059 * constructing the translation unit.
1061 enum CXTranslationUnit_Flags {
1063 * \brief Used to indicate that no special translation-unit options are
1066 CXTranslationUnit_None = 0x0,
1069 * \brief Used to indicate that the parser should construct a "detailed"
1070 * preprocessing record, including all macro definitions and instantiations.
1072 * Constructing a detailed preprocessing record requires more memory
1073 * and time to parse, since the information contained in the record
1074 * is usually not retained. However, it can be useful for
1075 * applications that require more detailed information about the
1076 * behavior of the preprocessor.
1078 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1081 * \brief Used to indicate that the translation unit is incomplete.
1083 * When a translation unit is considered "incomplete", semantic
1084 * analysis that is typically performed at the end of the
1085 * translation unit will be suppressed. For example, this suppresses
1086 * the completion of tentative declarations in C and of
1087 * instantiation of implicitly-instantiation function templates in
1088 * C++. This option is typically used when parsing a header with the
1089 * intent of producing a precompiled header.
1091 CXTranslationUnit_Incomplete = 0x02,
1094 * \brief Used to indicate that the translation unit should be built with an
1095 * implicit precompiled header for the preamble.
1097 * An implicit precompiled header is used as an optimization when a
1098 * particular translation unit is likely to be reparsed many times
1099 * when the sources aren't changing that often. In this case, an
1100 * implicit precompiled header will be built containing all of the
1101 * initial includes at the top of the main file (what we refer to as
1102 * the "preamble" of the file). In subsequent parses, if the
1103 * preamble or the files in it have not changed, \c
1104 * clang_reparseTranslationUnit() will re-use the implicit
1105 * precompiled header to improve parsing performance.
1107 CXTranslationUnit_PrecompiledPreamble = 0x04,
1110 * \brief Used to indicate that the translation unit should cache some
1111 * code-completion results with each reparse of the source file.
1113 * Caching of code-completion results is a performance optimization that
1114 * introduces some overhead to reparsing but improves the performance of
1115 * code-completion operations.
1117 CXTranslationUnit_CacheCompletionResults = 0x08,
1120 * \brief Used to indicate that the translation unit will be serialized with
1121 * \c clang_saveTranslationUnit.
1123 * This option is typically used when parsing a header with the intent of
1124 * producing a precompiled header.
1126 CXTranslationUnit_ForSerialization = 0x10,
1129 * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
1131 * Note: this is a *temporary* option that is available only while
1132 * we are testing C++ precompiled preamble support. It is deprecated.
1134 CXTranslationUnit_CXXChainedPCH = 0x20,
1137 * \brief Used to indicate that function/method bodies should be skipped while
1140 * This option can be used to search for declarations/definitions while
1141 * ignoring the usages.
1143 CXTranslationUnit_SkipFunctionBodies = 0x40,
1146 * \brief Used to indicate that brief documentation comments should be
1147 * included into the set of code completions returned from this translation
1150 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
1154 * \brief Returns the set of flags that is suitable for parsing a translation
1155 * unit that is being edited.
1157 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1158 * to indicate that the translation unit is likely to be reparsed many times,
1159 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1160 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1161 * set contains an unspecified set of optimizations (e.g., the precompiled
1162 * preamble) geared toward improving the performance of these routines. The
1163 * set of optimizations enabled may change from one version to the next.
1165 CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1168 * \brief Parse the given source file and the translation unit corresponding
1171 * This routine is the main entry point for the Clang C API, providing the
1172 * ability to parse a source file into a translation unit that can then be
1173 * queried by other functions in the API. This routine accepts a set of
1174 * command-line arguments so that the compilation can be configured in the same
1175 * way that the compiler is configured on the command line.
1177 * \param CIdx The index object with which the translation unit will be
1180 * \param source_filename The name of the source file to load, or NULL if the
1181 * source file is included in \p command_line_args.
1183 * \param command_line_args The command-line arguments that would be
1184 * passed to the \c clang executable if it were being invoked out-of-process.
1185 * These command-line options will be parsed and will affect how the translation
1186 * unit is parsed. Note that the following options are ignored: '-c',
1187 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1189 * \param num_command_line_args The number of command-line arguments in
1190 * \p command_line_args.
1192 * \param unsaved_files the files that have not yet been saved to disk
1193 * but may be required for parsing, including the contents of
1194 * those files. The contents and name of these files (as specified by
1195 * CXUnsavedFile) are copied when necessary, so the client only needs to
1196 * guarantee their validity until the call to this function returns.
1198 * \param num_unsaved_files the number of unsaved file entries in \p
1201 * \param options A bitmask of options that affects how the translation unit
1202 * is managed but not its compilation. This should be a bitwise OR of the
1203 * CXTranslationUnit_XXX flags.
1205 * \returns A new translation unit describing the parsed code and containing
1206 * any diagnostics produced by the compiler. If there is a failure from which
1207 * the compiler cannot recover, returns NULL.
1209 CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
1210 const char *source_filename,
1211 const char * const *command_line_args,
1212 int num_command_line_args,
1213 struct CXUnsavedFile *unsaved_files,
1214 unsigned num_unsaved_files,
1218 * \brief Flags that control how translation units are saved.
1220 * The enumerators in this enumeration type are meant to be bitwise
1221 * ORed together to specify which options should be used when
1222 * saving the translation unit.
1224 enum CXSaveTranslationUnit_Flags {
1226 * \brief Used to indicate that no special saving options are needed.
1228 CXSaveTranslationUnit_None = 0x0
1232 * \brief Returns the set of flags that is suitable for saving a translation
1235 * The set of flags returned provide options for
1236 * \c clang_saveTranslationUnit() by default. The returned flag
1237 * set contains an unspecified set of options that save translation units with
1238 * the most commonly-requested data.
1240 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1243 * \brief Describes the kind of error that occurred (if any) in a call to
1244 * \c clang_saveTranslationUnit().
1248 * \brief Indicates that no error occurred while saving a translation unit.
1250 CXSaveError_None = 0,
1253 * \brief Indicates that an unknown error occurred while attempting to save
1256 * This error typically indicates that file I/O failed when attempting to
1259 CXSaveError_Unknown = 1,
1262 * \brief Indicates that errors during translation prevented this attempt
1263 * to save the translation unit.
1265 * Errors that prevent the translation unit from being saved can be
1266 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1268 CXSaveError_TranslationErrors = 2,
1271 * \brief Indicates that the translation unit to be saved was somehow
1272 * invalid (e.g., NULL).
1274 CXSaveError_InvalidTU = 3
1278 * \brief Saves a translation unit into a serialized representation of
1279 * that translation unit on disk.
1281 * Any translation unit that was parsed without error can be saved
1282 * into a file. The translation unit can then be deserialized into a
1283 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1284 * if it is an incomplete translation unit that corresponds to a
1285 * header, used as a precompiled header when parsing other translation
1288 * \param TU The translation unit to save.
1290 * \param FileName The file to which the translation unit will be saved.
1292 * \param options A bitmask of options that affects how the translation unit
1293 * is saved. This should be a bitwise OR of the
1294 * CXSaveTranslationUnit_XXX flags.
1296 * \returns A value that will match one of the enumerators of the CXSaveError
1297 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1298 * saved successfully, while a non-zero value indicates that a problem occurred.
1300 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1301 const char *FileName,
1305 * \brief Destroy the specified CXTranslationUnit object.
1307 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1310 * \brief Flags that control the reparsing of translation units.
1312 * The enumerators in this enumeration type are meant to be bitwise
1313 * ORed together to specify which options should be used when
1314 * reparsing the translation unit.
1316 enum CXReparse_Flags {
1318 * \brief Used to indicate that no special reparsing options are needed.
1320 CXReparse_None = 0x0
1324 * \brief Returns the set of flags that is suitable for reparsing a translation
1327 * The set of flags returned provide options for
1328 * \c clang_reparseTranslationUnit() by default. The returned flag
1329 * set contains an unspecified set of optimizations geared toward common uses
1330 * of reparsing. The set of optimizations enabled may change from one version
1333 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1336 * \brief Reparse the source files that produced this translation unit.
1338 * This routine can be used to re-parse the source files that originally
1339 * created the given translation unit, for example because those source files
1340 * have changed (either on disk or as passed via \p unsaved_files). The
1341 * source code will be reparsed with the same command-line options as it
1342 * was originally parsed.
1344 * Reparsing a translation unit invalidates all cursors and source locations
1345 * that refer into that translation unit. This makes reparsing a translation
1346 * unit semantically equivalent to destroying the translation unit and then
1347 * creating a new translation unit with the same command-line arguments.
1348 * However, it may be more efficient to reparse a translation
1349 * unit using this routine.
1351 * \param TU The translation unit whose contents will be re-parsed. The
1352 * translation unit must originally have been built with
1353 * \c clang_createTranslationUnitFromSourceFile().
1355 * \param num_unsaved_files The number of unsaved file entries in \p
1358 * \param unsaved_files The files that have not yet been saved to disk
1359 * but may be required for parsing, including the contents of
1360 * those files. The contents and name of these files (as specified by
1361 * CXUnsavedFile) are copied when necessary, so the client only needs to
1362 * guarantee their validity until the call to this function returns.
1364 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1365 * The function \c clang_defaultReparseOptions() produces a default set of
1366 * options recommended for most uses, based on the translation unit.
1368 * \returns 0 if the sources could be reparsed. A non-zero value will be
1369 * returned if reparsing was impossible, such that the translation unit is
1370 * invalid. In such cases, the only valid call for \p TU is
1371 * \c clang_disposeTranslationUnit(TU).
1373 CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1374 unsigned num_unsaved_files,
1375 struct CXUnsavedFile *unsaved_files,
1379 * \brief Categorizes how memory is being used by a translation unit.
1381 enum CXTUResourceUsageKind {
1382 CXTUResourceUsage_AST = 1,
1383 CXTUResourceUsage_Identifiers = 2,
1384 CXTUResourceUsage_Selectors = 3,
1385 CXTUResourceUsage_GlobalCompletionResults = 4,
1386 CXTUResourceUsage_SourceManagerContentCache = 5,
1387 CXTUResourceUsage_AST_SideTables = 6,
1388 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1389 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1390 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1391 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1392 CXTUResourceUsage_Preprocessor = 11,
1393 CXTUResourceUsage_PreprocessingRecord = 12,
1394 CXTUResourceUsage_SourceManager_DataStructures = 13,
1395 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1396 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1397 CXTUResourceUsage_MEMORY_IN_BYTES_END =
1398 CXTUResourceUsage_Preprocessor_HeaderSearch,
1400 CXTUResourceUsage_First = CXTUResourceUsage_AST,
1401 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1405 * \brief Returns the human-readable null-terminated C string that represents
1406 * the name of the memory category. This string should never be freed.
1409 const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1411 typedef struct CXTUResourceUsageEntry {
1412 /* \brief The memory usage category. */
1413 enum CXTUResourceUsageKind kind;
1414 /* \brief Amount of resources used.
1415 The units will depend on the resource kind. */
1416 unsigned long amount;
1417 } CXTUResourceUsageEntry;
1420 * \brief The memory usage of a CXTranslationUnit, broken into categories.
1422 typedef struct CXTUResourceUsage {
1423 /* \brief Private data member, used for queries. */
1426 /* \brief The number of entries in the 'entries' array. */
1427 unsigned numEntries;
1429 /* \brief An array of key-value pairs, representing the breakdown of memory
1431 CXTUResourceUsageEntry *entries;
1433 } CXTUResourceUsage;
1436 * \brief Return the memory usage of a translation unit. This object
1437 * should be released with clang_disposeCXTUResourceUsage().
1439 CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1441 CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1448 * \brief Describes the kind of entity that a cursor refers to.
1453 * \brief A declaration whose specific kind is not exposed via this
1456 * Unexposed declarations have the same operations as any other kind
1457 * of declaration; one can extract their location information,
1458 * spelling, find their definitions, etc. However, the specific kind
1459 * of the declaration is not reported.
1461 CXCursor_UnexposedDecl = 1,
1462 /** \brief A C or C++ struct. */
1463 CXCursor_StructDecl = 2,
1464 /** \brief A C or C++ union. */
1465 CXCursor_UnionDecl = 3,
1466 /** \brief A C++ class. */
1467 CXCursor_ClassDecl = 4,
1468 /** \brief An enumeration. */
1469 CXCursor_EnumDecl = 5,
1471 * \brief A field (in C) or non-static data member (in C++) in a
1472 * struct, union, or C++ class.
1474 CXCursor_FieldDecl = 6,
1475 /** \brief An enumerator constant. */
1476 CXCursor_EnumConstantDecl = 7,
1477 /** \brief A function. */
1478 CXCursor_FunctionDecl = 8,
1479 /** \brief A variable. */
1480 CXCursor_VarDecl = 9,
1481 /** \brief A function or method parameter. */
1482 CXCursor_ParmDecl = 10,
1483 /** \brief An Objective-C \@interface. */
1484 CXCursor_ObjCInterfaceDecl = 11,
1485 /** \brief An Objective-C \@interface for a category. */
1486 CXCursor_ObjCCategoryDecl = 12,
1487 /** \brief An Objective-C \@protocol declaration. */
1488 CXCursor_ObjCProtocolDecl = 13,
1489 /** \brief An Objective-C \@property declaration. */
1490 CXCursor_ObjCPropertyDecl = 14,
1491 /** \brief An Objective-C instance variable. */
1492 CXCursor_ObjCIvarDecl = 15,
1493 /** \brief An Objective-C instance method. */
1494 CXCursor_ObjCInstanceMethodDecl = 16,
1495 /** \brief An Objective-C class method. */
1496 CXCursor_ObjCClassMethodDecl = 17,
1497 /** \brief An Objective-C \@implementation. */
1498 CXCursor_ObjCImplementationDecl = 18,
1499 /** \brief An Objective-C \@implementation for a category. */
1500 CXCursor_ObjCCategoryImplDecl = 19,
1501 /** \brief A typedef */
1502 CXCursor_TypedefDecl = 20,
1503 /** \brief A C++ class method. */
1504 CXCursor_CXXMethod = 21,
1505 /** \brief A C++ namespace. */
1506 CXCursor_Namespace = 22,
1507 /** \brief A linkage specification, e.g. 'extern "C"'. */
1508 CXCursor_LinkageSpec = 23,
1509 /** \brief A C++ constructor. */
1510 CXCursor_Constructor = 24,
1511 /** \brief A C++ destructor. */
1512 CXCursor_Destructor = 25,
1513 /** \brief A C++ conversion function. */
1514 CXCursor_ConversionFunction = 26,
1515 /** \brief A C++ template type parameter. */
1516 CXCursor_TemplateTypeParameter = 27,
1517 /** \brief A C++ non-type template parameter. */
1518 CXCursor_NonTypeTemplateParameter = 28,
1519 /** \brief A C++ template template parameter. */
1520 CXCursor_TemplateTemplateParameter = 29,
1521 /** \brief A C++ function template. */
1522 CXCursor_FunctionTemplate = 30,
1523 /** \brief A C++ class template. */
1524 CXCursor_ClassTemplate = 31,
1525 /** \brief A C++ class template partial specialization. */
1526 CXCursor_ClassTemplatePartialSpecialization = 32,
1527 /** \brief A C++ namespace alias declaration. */
1528 CXCursor_NamespaceAlias = 33,
1529 /** \brief A C++ using directive. */
1530 CXCursor_UsingDirective = 34,
1531 /** \brief A C++ using declaration. */
1532 CXCursor_UsingDeclaration = 35,
1533 /** \brief A C++ alias declaration */
1534 CXCursor_TypeAliasDecl = 36,
1535 /** \brief An Objective-C \@synthesize definition. */
1536 CXCursor_ObjCSynthesizeDecl = 37,
1537 /** \brief An Objective-C \@dynamic definition. */
1538 CXCursor_ObjCDynamicDecl = 38,
1539 /** \brief An access specifier. */
1540 CXCursor_CXXAccessSpecifier = 39,
1542 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1543 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
1546 CXCursor_FirstRef = 40, /* Decl references */
1547 CXCursor_ObjCSuperClassRef = 40,
1548 CXCursor_ObjCProtocolRef = 41,
1549 CXCursor_ObjCClassRef = 42,
1551 * \brief A reference to a type declaration.
1553 * A type reference occurs anywhere where a type is named but not
1554 * declared. For example, given:
1557 * typedef unsigned size_type;
1561 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1562 * while the type of the variable "size" is referenced. The cursor
1563 * referenced by the type of size is the typedef for size_type.
1565 CXCursor_TypeRef = 43,
1566 CXCursor_CXXBaseSpecifier = 44,
1568 * \brief A reference to a class template, function template, template
1569 * template parameter, or class template partial specialization.
1571 CXCursor_TemplateRef = 45,
1573 * \brief A reference to a namespace or namespace alias.
1575 CXCursor_NamespaceRef = 46,
1577 * \brief A reference to a member of a struct, union, or class that occurs in
1578 * some non-expression context, e.g., a designated initializer.
1580 CXCursor_MemberRef = 47,
1582 * \brief A reference to a labeled statement.
1584 * This cursor kind is used to describe the jump to "start_over" in the
1585 * goto statement in the following example:
1594 * A label reference cursor refers to a label statement.
1596 CXCursor_LabelRef = 48,
1599 * \brief A reference to a set of overloaded functions or function templates
1600 * that has not yet been resolved to a specific function or function template.
1602 * An overloaded declaration reference cursor occurs in C++ templates where
1603 * a dependent name refers to a function. For example:
1606 * template<typename T> void swap(T&, T&);
1609 * void swap(X&, X&);
1611 * template<typename T>
1612 * void reverse(T* first, T* last) {
1613 * while (first < last - 1) {
1614 * swap(*first, *--last);
1620 * void swap(Y&, Y&);
1623 * Here, the identifier "swap" is associated with an overloaded declaration
1624 * reference. In the template definition, "swap" refers to either of the two
1625 * "swap" functions declared above, so both results will be available. At
1626 * instantiation time, "swap" may also refer to other functions found via
1627 * argument-dependent lookup (e.g., the "swap" function at the end of the
1630 * The functions \c clang_getNumOverloadedDecls() and
1631 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1632 * referenced by this cursor.
1634 CXCursor_OverloadedDeclRef = 49,
1637 * \brief A reference to a variable that occurs in some non-expression
1638 * context, e.g., a C++ lambda capture list.
1640 CXCursor_VariableRef = 50,
1642 CXCursor_LastRef = CXCursor_VariableRef,
1644 /* Error conditions */
1645 CXCursor_FirstInvalid = 70,
1646 CXCursor_InvalidFile = 70,
1647 CXCursor_NoDeclFound = 71,
1648 CXCursor_NotImplemented = 72,
1649 CXCursor_InvalidCode = 73,
1650 CXCursor_LastInvalid = CXCursor_InvalidCode,
1653 CXCursor_FirstExpr = 100,
1656 * \brief An expression whose specific kind is not exposed via this
1659 * Unexposed expressions have the same operations as any other kind
1660 * of expression; one can extract their location information,
1661 * spelling, children, etc. However, the specific kind of the
1662 * expression is not reported.
1664 CXCursor_UnexposedExpr = 100,
1667 * \brief An expression that refers to some value declaration, such
1668 * as a function, varible, or enumerator.
1670 CXCursor_DeclRefExpr = 101,
1673 * \brief An expression that refers to a member of a struct, union,
1674 * class, Objective-C class, etc.
1676 CXCursor_MemberRefExpr = 102,
1678 /** \brief An expression that calls a function. */
1679 CXCursor_CallExpr = 103,
1681 /** \brief An expression that sends a message to an Objective-C
1683 CXCursor_ObjCMessageExpr = 104,
1685 /** \brief An expression that represents a block literal. */
1686 CXCursor_BlockExpr = 105,
1688 /** \brief An integer literal.
1690 CXCursor_IntegerLiteral = 106,
1692 /** \brief A floating point number literal.
1694 CXCursor_FloatingLiteral = 107,
1696 /** \brief An imaginary number literal.
1698 CXCursor_ImaginaryLiteral = 108,
1700 /** \brief A string literal.
1702 CXCursor_StringLiteral = 109,
1704 /** \brief A character literal.
1706 CXCursor_CharacterLiteral = 110,
1708 /** \brief A parenthesized expression, e.g. "(1)".
1710 * This AST node is only formed if full location information is requested.
1712 CXCursor_ParenExpr = 111,
1714 /** \brief This represents the unary-expression's (except sizeof and
1717 CXCursor_UnaryOperator = 112,
1719 /** \brief [C99 6.5.2.1] Array Subscripting.
1721 CXCursor_ArraySubscriptExpr = 113,
1723 /** \brief A builtin binary operation expression such as "x + y" or
1726 CXCursor_BinaryOperator = 114,
1728 /** \brief Compound assignment such as "+=".
1730 CXCursor_CompoundAssignOperator = 115,
1732 /** \brief The ?: ternary operator.
1734 CXCursor_ConditionalOperator = 116,
1736 /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1737 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1739 * For example: (int)f.
1741 CXCursor_CStyleCastExpr = 117,
1743 /** \brief [C99 6.5.2.5]
1745 CXCursor_CompoundLiteralExpr = 118,
1747 /** \brief Describes an C or C++ initializer list.
1749 CXCursor_InitListExpr = 119,
1751 /** \brief The GNU address of label extension, representing &&label.
1753 CXCursor_AddrLabelExpr = 120,
1755 /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1757 CXCursor_StmtExpr = 121,
1759 /** \brief Represents a C11 generic selection.
1761 CXCursor_GenericSelectionExpr = 122,
1763 /** \brief Implements the GNU __null extension, which is a name for a null
1764 * pointer constant that has integral type (e.g., int or long) and is the same
1765 * size and alignment as a pointer.
1767 * The __null extension is typically only used by system headers, which define
1768 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1769 * match the size of a pointer).
1771 CXCursor_GNUNullExpr = 123,
1773 /** \brief C++'s static_cast<> expression.
1775 CXCursor_CXXStaticCastExpr = 124,
1777 /** \brief C++'s dynamic_cast<> expression.
1779 CXCursor_CXXDynamicCastExpr = 125,
1781 /** \brief C++'s reinterpret_cast<> expression.
1783 CXCursor_CXXReinterpretCastExpr = 126,
1785 /** \brief C++'s const_cast<> expression.
1787 CXCursor_CXXConstCastExpr = 127,
1789 /** \brief Represents an explicit C++ type conversion that uses "functional"
1790 * notion (C++ [expr.type.conv]).
1797 CXCursor_CXXFunctionalCastExpr = 128,
1799 /** \brief A C++ typeid expression (C++ [expr.typeid]).
1801 CXCursor_CXXTypeidExpr = 129,
1803 /** \brief [C++ 2.13.5] C++ Boolean Literal.
1805 CXCursor_CXXBoolLiteralExpr = 130,
1807 /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1809 CXCursor_CXXNullPtrLiteralExpr = 131,
1811 /** \brief Represents the "this" expression in C++
1813 CXCursor_CXXThisExpr = 132,
1815 /** \brief [C++ 15] C++ Throw Expression.
1817 * This handles 'throw' and 'throw' assignment-expression. When
1818 * assignment-expression isn't present, Op will be null.
1820 CXCursor_CXXThrowExpr = 133,
1822 /** \brief A new expression for memory allocation and constructor calls, e.g:
1823 * "new CXXNewExpr(foo)".
1825 CXCursor_CXXNewExpr = 134,
1827 /** \brief A delete expression for memory deallocation and destructor calls,
1828 * e.g. "delete[] pArray".
1830 CXCursor_CXXDeleteExpr = 135,
1832 /** \brief A unary expression.
1834 CXCursor_UnaryExpr = 136,
1836 /** \brief An Objective-C string literal i.e. @"foo".
1838 CXCursor_ObjCStringLiteral = 137,
1840 /** \brief An Objective-C \@encode expression.
1842 CXCursor_ObjCEncodeExpr = 138,
1844 /** \brief An Objective-C \@selector expression.
1846 CXCursor_ObjCSelectorExpr = 139,
1848 /** \brief An Objective-C \@protocol expression.
1850 CXCursor_ObjCProtocolExpr = 140,
1852 /** \brief An Objective-C "bridged" cast expression, which casts between
1853 * Objective-C pointers and C pointers, transferring ownership in the process.
1856 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
1859 CXCursor_ObjCBridgedCastExpr = 141,
1861 /** \brief Represents a C++0x pack expansion that produces a sequence of
1864 * A pack expansion expression contains a pattern (which itself is an
1865 * expression) followed by an ellipsis. For example:
1868 * template<typename F, typename ...Types>
1869 * void forward(F f, Types &&...args) {
1870 * f(static_cast<Types&&>(args)...);
1874 CXCursor_PackExpansionExpr = 142,
1876 /** \brief Represents an expression that computes the length of a parameter
1880 * template<typename ...Types>
1882 * static const unsigned value = sizeof...(Types);
1886 CXCursor_SizeOfPackExpr = 143,
1888 /* \brief Represents a C++ lambda expression that produces a local function
1892 * void abssort(float *x, unsigned N) {
1893 * std::sort(x, x + N,
1894 * [](float a, float b) {
1895 * return std::abs(a) < std::abs(b);
1900 CXCursor_LambdaExpr = 144,
1902 /** \brief Objective-c Boolean Literal.
1904 CXCursor_ObjCBoolLiteralExpr = 145,
1906 /** \brief Represents the "self" expression in a ObjC method.
1908 CXCursor_ObjCSelfExpr = 146,
1910 CXCursor_LastExpr = CXCursor_ObjCSelfExpr,
1913 CXCursor_FirstStmt = 200,
1915 * \brief A statement whose specific kind is not exposed via this
1918 * Unexposed statements have the same operations as any other kind of
1919 * statement; one can extract their location information, spelling,
1920 * children, etc. However, the specific kind of the statement is not
1923 CXCursor_UnexposedStmt = 200,
1925 /** \brief A labelled statement in a function.
1927 * This cursor kind is used to describe the "start_over:" label statement in
1928 * the following example:
1936 CXCursor_LabelStmt = 201,
1938 /** \brief A group of statements like { stmt stmt }.
1940 * This cursor kind is used to describe compound statements, e.g. function
1943 CXCursor_CompoundStmt = 202,
1945 /** \brief A case statment.
1947 CXCursor_CaseStmt = 203,
1949 /** \brief A default statement.
1951 CXCursor_DefaultStmt = 204,
1953 /** \brief An if statement
1955 CXCursor_IfStmt = 205,
1957 /** \brief A switch statement.
1959 CXCursor_SwitchStmt = 206,
1961 /** \brief A while statement.
1963 CXCursor_WhileStmt = 207,
1965 /** \brief A do statement.
1967 CXCursor_DoStmt = 208,
1969 /** \brief A for statement.
1971 CXCursor_ForStmt = 209,
1973 /** \brief A goto statement.
1975 CXCursor_GotoStmt = 210,
1977 /** \brief An indirect goto statement.
1979 CXCursor_IndirectGotoStmt = 211,
1981 /** \brief A continue statement.
1983 CXCursor_ContinueStmt = 212,
1985 /** \brief A break statement.
1987 CXCursor_BreakStmt = 213,
1989 /** \brief A return statement.
1991 CXCursor_ReturnStmt = 214,
1993 /** \brief A GCC inline assembly statement extension.
1995 CXCursor_GCCAsmStmt = 215,
1996 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
1998 /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
2000 CXCursor_ObjCAtTryStmt = 216,
2002 /** \brief Objective-C's \@catch statement.
2004 CXCursor_ObjCAtCatchStmt = 217,
2006 /** \brief Objective-C's \@finally statement.
2008 CXCursor_ObjCAtFinallyStmt = 218,
2010 /** \brief Objective-C's \@throw statement.
2012 CXCursor_ObjCAtThrowStmt = 219,
2014 /** \brief Objective-C's \@synchronized statement.
2016 CXCursor_ObjCAtSynchronizedStmt = 220,
2018 /** \brief Objective-C's autorelease pool statement.
2020 CXCursor_ObjCAutoreleasePoolStmt = 221,
2022 /** \brief Objective-C's collection statement.
2024 CXCursor_ObjCForCollectionStmt = 222,
2026 /** \brief C++'s catch statement.
2028 CXCursor_CXXCatchStmt = 223,
2030 /** \brief C++'s try statement.
2032 CXCursor_CXXTryStmt = 224,
2034 /** \brief C++'s for (* : *) statement.
2036 CXCursor_CXXForRangeStmt = 225,
2038 /** \brief Windows Structured Exception Handling's try statement.
2040 CXCursor_SEHTryStmt = 226,
2042 /** \brief Windows Structured Exception Handling's except statement.
2044 CXCursor_SEHExceptStmt = 227,
2046 /** \brief Windows Structured Exception Handling's finally statement.
2048 CXCursor_SEHFinallyStmt = 228,
2050 /** \brief A MS inline assembly statement extension.
2052 CXCursor_MSAsmStmt = 229,
2054 /** \brief The null satement ";": C99 6.8.3p3.
2056 * This cursor kind is used to describe the null statement.
2058 CXCursor_NullStmt = 230,
2060 /** \brief Adaptor class for mixing declarations with statements and
2063 CXCursor_DeclStmt = 231,
2065 CXCursor_LastStmt = CXCursor_DeclStmt,
2068 * \brief Cursor that represents the translation unit itself.
2070 * The translation unit cursor exists primarily to act as the root
2071 * cursor for traversing the contents of a translation unit.
2073 CXCursor_TranslationUnit = 300,
2076 CXCursor_FirstAttr = 400,
2078 * \brief An attribute whose specific kind is not exposed via this
2081 CXCursor_UnexposedAttr = 400,
2083 CXCursor_IBActionAttr = 401,
2084 CXCursor_IBOutletAttr = 402,
2085 CXCursor_IBOutletCollectionAttr = 403,
2086 CXCursor_CXXFinalAttr = 404,
2087 CXCursor_CXXOverrideAttr = 405,
2088 CXCursor_AnnotateAttr = 406,
2089 CXCursor_AsmLabelAttr = 407,
2090 CXCursor_LastAttr = CXCursor_AsmLabelAttr,
2093 CXCursor_PreprocessingDirective = 500,
2094 CXCursor_MacroDefinition = 501,
2095 CXCursor_MacroExpansion = 502,
2096 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2097 CXCursor_InclusionDirective = 503,
2098 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2099 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2101 /* Extra Declarations */
2103 * \brief A module import declaration.
2105 CXCursor_ModuleImportDecl = 600,
2106 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2107 CXCursor_LastExtraDecl = CXCursor_ModuleImportDecl
2111 * \brief A cursor representing some element in the abstract syntax tree for
2112 * a translation unit.
2114 * The cursor abstraction unifies the different kinds of entities in a
2115 * program--declaration, statements, expressions, references to declarations,
2116 * etc.--under a single "cursor" abstraction with a common set of operations.
2117 * Common operation for a cursor include: getting the physical location in
2118 * a source file where the cursor points, getting the name associated with a
2119 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2121 * Cursors can be produced in two specific ways.
2122 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2123 * from which one can use clang_visitChildren() to explore the rest of the
2124 * translation unit. clang_getCursor() maps from a physical source location
2125 * to the entity that resides at that location, allowing one to map from the
2126 * source code into the AST.
2129 enum CXCursorKind kind;
2131 const void *data[3];
2135 * \brief A comment AST node.
2138 const void *ASTNode;
2139 CXTranslationUnit TranslationUnit;
2143 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2149 * \brief Retrieve the NULL cursor, which represents no entity.
2151 CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2154 * \brief Retrieve the cursor that represents the given translation unit.
2156 * The translation unit cursor can be used to start traversing the
2157 * various declarations within the given translation unit.
2159 CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2162 * \brief Determine whether two cursors are equivalent.
2164 CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2167 * \brief Returns non-zero if \p cursor is null.
2169 CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2172 * \brief Compute a hash value for the given cursor.
2174 CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2177 * \brief Retrieve the kind of the given cursor.
2179 CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2182 * \brief Determine whether the given cursor kind represents a declaration.
2184 CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2187 * \brief Determine whether the given cursor kind represents a simple
2190 * Note that other kinds of cursors (such as expressions) can also refer to
2191 * other cursors. Use clang_getCursorReferenced() to determine whether a
2192 * particular cursor refers to another entity.
2194 CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2197 * \brief Determine whether the given cursor kind represents an expression.
2199 CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2202 * \brief Determine whether the given cursor kind represents a statement.
2204 CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2207 * \brief Determine whether the given cursor kind represents an attribute.
2209 CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2212 * \brief Determine whether the given cursor kind represents an invalid
2215 CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2218 * \brief Determine whether the given cursor kind represents a translation
2221 CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2224 * \brief Determine whether the given cursor represents a preprocessing
2225 * element, such as a preprocessor directive or macro instantiation.
2227 CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2230 * \brief Determine whether the given cursor represents a currently
2231 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2233 CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2236 * \brief Describe the linkage of the entity referred to by a cursor.
2238 enum CXLinkageKind {
2239 /** \brief This value indicates that no linkage information is available
2240 * for a provided CXCursor. */
2243 * \brief This is the linkage for variables, parameters, and so on that
2244 * have automatic storage. This covers normal (non-extern) local variables.
2246 CXLinkage_NoLinkage,
2247 /** \brief This is the linkage for static variables and static functions. */
2249 /** \brief This is the linkage for entities with external linkage that live
2250 * in C++ anonymous namespaces.*/
2251 CXLinkage_UniqueExternal,
2252 /** \brief This is the linkage for entities with true, external linkage. */
2257 * \brief Determine the linkage of the entity referred to by a given cursor.
2259 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2262 * \brief Determine the availability of the entity that this cursor refers to,
2263 * taking the current target platform into account.
2265 * \param cursor The cursor to query.
2267 * \returns The availability of the cursor.
2269 CINDEX_LINKAGE enum CXAvailabilityKind
2270 clang_getCursorAvailability(CXCursor cursor);
2273 * Describes the availability of a given entity on a particular platform, e.g.,
2274 * a particular class might only be available on Mac OS 10.7 or newer.
2276 typedef struct CXPlatformAvailability {
2278 * \brief A string that describes the platform for which this structure
2279 * provides availability information.
2281 * Possible values are "ios" or "macosx".
2285 * \brief The version number in which this entity was introduced.
2287 CXVersion Introduced;
2289 * \brief The version number in which this entity was deprecated (but is
2292 CXVersion Deprecated;
2294 * \brief The version number in which this entity was obsoleted, and therefore
2295 * is no longer available.
2297 CXVersion Obsoleted;
2299 * \brief Whether the entity is unconditionally unavailable on this platform.
2303 * \brief An optional message to provide to a user of this API, e.g., to
2304 * suggest replacement APIs.
2307 } CXPlatformAvailability;
2310 * \brief Determine the availability of the entity that this cursor refers to
2311 * on any platforms for which availability information is known.
2313 * \param cursor The cursor to query.
2315 * \param always_deprecated If non-NULL, will be set to indicate whether the
2316 * entity is deprecated on all platforms.
2318 * \param deprecated_message If non-NULL, will be set to the message text
2319 * provided along with the unconditional deprecation of this entity. The client
2320 * is responsible for deallocating this string.
2322 * \param always_unavailable If non-NULL, will be set to indicate whether the
2323 * entity is unavailable on all platforms.
2325 * \param unavailable_message If non-NULL, will be set to the message text
2326 * provided along with the unconditional unavailability of this entity. The
2327 * client is responsible for deallocating this string.
2329 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2330 * that will be populated with platform availability information, up to either
2331 * the number of platforms for which availability information is available (as
2332 * returned by this function) or \c availability_size, whichever is smaller.
2334 * \param availability_size The number of elements available in the
2335 * \c availability array.
2337 * \returns The number of platforms (N) for which availability information is
2338 * available (which is unrelated to \c availability_size).
2340 * Note that the client is responsible for calling
2341 * \c clang_disposeCXPlatformAvailability to free each of the
2342 * platform-availability structures returned. There are
2343 * \c min(N, availability_size) such structures.
2346 clang_getCursorPlatformAvailability(CXCursor cursor,
2347 int *always_deprecated,
2348 CXString *deprecated_message,
2349 int *always_unavailable,
2350 CXString *unavailable_message,
2351 CXPlatformAvailability *availability,
2352 int availability_size);
2355 * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2358 clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2361 * \brief Describe the "language" of the entity referred to by a cursor.
2363 CINDEX_LINKAGE enum CXLanguageKind {
2364 CXLanguage_Invalid = 0,
2367 CXLanguage_CPlusPlus
2371 * \brief Determine the "language" of the entity referred to by a given cursor.
2373 CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2376 * \brief Returns the translation unit that a cursor originated from.
2378 CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2382 * \brief A fast container representing a set of CXCursors.
2384 typedef struct CXCursorSetImpl *CXCursorSet;
2387 * \brief Creates an empty CXCursorSet.
2389 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2392 * \brief Disposes a CXCursorSet and releases its associated memory.
2394 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2397 * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2399 * \returns non-zero if the set contains the specified cursor.
2401 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2405 * \brief Inserts a CXCursor into a CXCursorSet.
2407 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2409 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2413 * \brief Determine the semantic parent of the given cursor.
2415 * The semantic parent of a cursor is the cursor that semantically contains
2416 * the given \p cursor. For many declarations, the lexical and semantic parents
2417 * are equivalent (the lexical parent is returned by
2418 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2419 * definitions are provided out-of-line. For example:
2429 * In the out-of-line definition of \c C::f, the semantic parent is the
2430 * the class \c C, of which this function is a member. The lexical parent is
2431 * the place where the declaration actually occurs in the source code; in this
2432 * case, the definition occurs in the translation unit. In general, the
2433 * lexical parent for a given entity can change without affecting the semantics
2434 * of the program, and the lexical parent of different declarations of the
2435 * same entity may be different. Changing the semantic parent of a declaration,
2436 * on the other hand, can have a major impact on semantics, and redeclarations
2437 * of a particular entity should all have the same semantic context.
2439 * In the example above, both declarations of \c C::f have \c C as their
2440 * semantic context, while the lexical context of the first \c C::f is \c C
2441 * and the lexical context of the second \c C::f is the translation unit.
2443 * For global declarations, the semantic parent is the translation unit.
2445 CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2448 * \brief Determine the lexical parent of the given cursor.
2450 * The lexical parent of a cursor is the cursor in which the given \p cursor
2451 * was actually written. For many declarations, the lexical and semantic parents
2452 * are equivalent (the semantic parent is returned by
2453 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2454 * definitions are provided out-of-line. For example:
2464 * In the out-of-line definition of \c C::f, the semantic parent is the
2465 * the class \c C, of which this function is a member. The lexical parent is
2466 * the place where the declaration actually occurs in the source code; in this
2467 * case, the definition occurs in the translation unit. In general, the
2468 * lexical parent for a given entity can change without affecting the semantics
2469 * of the program, and the lexical parent of different declarations of the
2470 * same entity may be different. Changing the semantic parent of a declaration,
2471 * on the other hand, can have a major impact on semantics, and redeclarations
2472 * of a particular entity should all have the same semantic context.
2474 * In the example above, both declarations of \c C::f have \c C as their
2475 * semantic context, while the lexical context of the first \c C::f is \c C
2476 * and the lexical context of the second \c C::f is the translation unit.
2478 * For declarations written in the global scope, the lexical parent is
2479 * the translation unit.
2481 CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2484 * \brief Determine the set of methods that are overridden by the given
2487 * In both Objective-C and C++, a method (aka virtual member function,
2488 * in C++) can override a virtual method in a base class. For
2489 * Objective-C, a method is said to override any method in the class's
2490 * base class, its protocols, or its categories' protocols, that has the same
2491 * selector and is of the same kind (class or instance).
2492 * If no such method exists, the search continues to the class's superclass,
2493 * its protocols, and its categories, and so on. A method from an Objective-C
2494 * implementation is considered to override the same methods as its
2495 * corresponding method in the interface.
2497 * For C++, a virtual member function overrides any virtual member
2498 * function with the same signature that occurs in its base
2499 * classes. With multiple inheritance, a virtual member function can
2500 * override several virtual member functions coming from different
2503 * In all cases, this function determines the immediate overridden
2504 * method, rather than all of the overridden methods. For example, if
2505 * a method is originally declared in a class A, then overridden in B
2506 * (which in inherits from A) and also in C (which inherited from B),
2507 * then the only overridden method returned from this function when
2508 * invoked on C's method will be B's method. The client may then
2509 * invoke this function again, given the previously-found overridden
2510 * methods, to map out the complete method-override set.
2512 * \param cursor A cursor representing an Objective-C or C++
2513 * method. This routine will compute the set of methods that this
2516 * \param overridden A pointer whose pointee will be replaced with a
2517 * pointer to an array of cursors, representing the set of overridden
2518 * methods. If there are no overridden methods, the pointee will be
2519 * set to NULL. The pointee must be freed via a call to
2520 * \c clang_disposeOverriddenCursors().
2522 * \param num_overridden A pointer to the number of overridden
2523 * functions, will be set to the number of overridden functions in the
2524 * array pointed to by \p overridden.
2526 CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2527 CXCursor **overridden,
2528 unsigned *num_overridden);
2531 * \brief Free the set of overridden cursors returned by \c
2532 * clang_getOverriddenCursors().
2534 CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2537 * \brief Retrieve the file that is included by the given inclusion directive
2540 CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2547 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2549 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2550 * routines help map between cursors and the physical locations where the
2551 * described entities occur in the source code. The mapping is provided in
2552 * both directions, so one can map from source code to the AST and back.
2558 * \brief Map a source location to the cursor that describes the entity at that
2559 * location in the source code.
2561 * clang_getCursor() maps an arbitrary source location within a translation
2562 * unit down to the most specific cursor that describes the entity at that
2563 * location. For example, given an expression \c x + y, invoking
2564 * clang_getCursor() with a source location pointing to "x" will return the
2565 * cursor for "x"; similarly for "y". If the cursor points anywhere between
2566 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2567 * will return a cursor referring to the "+" expression.
2569 * \returns a cursor representing the entity at the given source location, or
2570 * a NULL cursor if no such entity can be found.
2572 CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2575 * \brief Retrieve the physical location of the source constructor referenced
2576 * by the given cursor.
2578 * The location of a declaration is typically the location of the name of that
2579 * declaration, where the name of that declaration would occur if it is
2580 * unnamed, or some keyword that introduces that particular declaration.
2581 * The location of a reference is where that reference occurs within the
2584 CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2587 * \brief Retrieve the physical extent of the source construct referenced by
2590 * The extent of a cursor starts with the file/line/column pointing at the
2591 * first character within the source construct that the cursor refers to and
2592 * ends with the last character withinin that source construct. For a
2593 * declaration, the extent covers the declaration itself. For a reference,
2594 * the extent covers the location of the reference (e.g., where the referenced
2595 * entity was actually used).
2597 CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
2604 * \defgroup CINDEX_TYPES Type information for CXCursors
2610 * \brief Describes the kind of type
2614 * \brief Reprents an invalid type (e.g., where no type is available).
2619 * \brief A type whose specific kind is not exposed via this
2622 CXType_Unexposed = 1,
2634 CXType_ULongLong = 11,
2635 CXType_UInt128 = 12,
2642 CXType_LongLong = 19,
2646 CXType_LongDouble = 23,
2647 CXType_NullPtr = 24,
2648 CXType_Overload = 25,
2649 CXType_Dependent = 26,
2651 CXType_ObjCClass = 28,
2652 CXType_ObjCSel = 29,
2653 CXType_FirstBuiltin = CXType_Void,
2654 CXType_LastBuiltin = CXType_ObjCSel,
2656 CXType_Complex = 100,
2657 CXType_Pointer = 101,
2658 CXType_BlockPointer = 102,
2659 CXType_LValueReference = 103,
2660 CXType_RValueReference = 104,
2661 CXType_Record = 105,
2663 CXType_Typedef = 107,
2664 CXType_ObjCInterface = 108,
2665 CXType_ObjCObjectPointer = 109,
2666 CXType_FunctionNoProto = 110,
2667 CXType_FunctionProto = 111,
2668 CXType_ConstantArray = 112,
2673 * \brief Describes the calling convention of a function type
2675 enum CXCallingConv {
2676 CXCallingConv_Default = 0,
2677 CXCallingConv_C = 1,
2678 CXCallingConv_X86StdCall = 2,
2679 CXCallingConv_X86FastCall = 3,
2680 CXCallingConv_X86ThisCall = 4,
2681 CXCallingConv_X86Pascal = 5,
2682 CXCallingConv_AAPCS = 6,
2683 CXCallingConv_AAPCS_VFP = 7,
2684 CXCallingConv_PnaclCall = 8,
2685 CXCallingConv_IntelOclBicc = 9,
2686 CXCallingConv_X86_64Win64 = 10,
2687 CXCallingConv_X86_64SysV = 11,
2689 CXCallingConv_Invalid = 100,
2690 CXCallingConv_Unexposed = 200
2695 * \brief The type of an element in the abstract syntax tree.
2699 enum CXTypeKind kind;
2704 * \brief Retrieve the type of a CXCursor (if any).
2706 CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
2709 * \brief Pretty-print the underlying type using the rules of the
2710 * language of the translation unit from which it came.
2712 * If the type is invalid, an empty string is returned.
2714 CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
2717 * \brief Retrieve the underlying type of a typedef declaration.
2719 * If the cursor does not reference a typedef declaration, an invalid type is
2722 CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
2725 * \brief Retrieve the integer type of an enum declaration.
2727 * If the cursor does not reference an enum declaration, an invalid type is
2730 CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
2733 * \brief Retrieve the integer value of an enum constant declaration as a signed
2736 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
2737 * Since this is also potentially a valid constant value, the kind of the cursor
2738 * must be verified before calling this function.
2740 CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
2743 * \brief Retrieve the integer value of an enum constant declaration as an unsigned
2746 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
2747 * Since this is also potentially a valid constant value, the kind of the cursor
2748 * must be verified before calling this function.
2750 CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
2753 * \brief Retrieve the bit width of a bit field declaration as an integer.
2755 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
2757 CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
2760 * \brief Retrieve the number of non-variadic arguments associated with a given
2763 * The number of arguments can be determined for calls as well as for
2764 * declarations of functions or methods. For other cursors -1 is returned.
2766 CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
2769 * \brief Retrieve the argument cursor of a function or method.
2771 * The argument cursor can be determined for calls as well as for declarations
2772 * of functions or methods. For other cursors and for invalid indices, an
2773 * invalid cursor is returned.
2775 CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
2778 * \brief Determine whether two CXTypes represent the same type.
2780 * \returns non-zero if the CXTypes represent the same type and
2783 CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
2786 * \brief Return the canonical type for a CXType.
2788 * Clang's type system explicitly models typedefs and all the ways
2789 * a specific type can be represented. The canonical type is the underlying
2790 * type with all the "sugar" removed. For example, if 'T' is a typedef
2791 * for 'int', the canonical type for 'T' would be 'int'.
2793 CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
2796 * \brief Determine whether a CXType has the "const" qualifier set,
2797 * without looking through typedefs that may have added "const" at a
2800 CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
2803 * \brief Determine whether a CXType has the "volatile" qualifier set,
2804 * without looking through typedefs that may have added "volatile" at
2805 * a different level.
2807 CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
2810 * \brief Determine whether a CXType has the "restrict" qualifier set,
2811 * without looking through typedefs that may have added "restrict" at a
2814 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
2817 * \brief For pointer types, returns the type of the pointee.
2819 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
2822 * \brief Return the cursor for the declaration of the given type.
2824 CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
2827 * Returns the Objective-C type encoding for the specified declaration.
2829 CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
2832 * \brief Retrieve the spelling of a given CXTypeKind.
2834 CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
2837 * \brief Retrieve the calling convention associated with a function type.
2839 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
2841 CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
2844 * \brief Retrieve the result type associated with a function type.
2846 * If a non-function type is passed in, an invalid type is returned.
2848 CINDEX_LINKAGE CXType clang_getResultType(CXType T);
2851 * \brief Retrieve the number of non-variadic arguments associated with a
2854 * If a non-function type is passed in, -1 is returned.
2856 CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
2859 * \brief Retrieve the type of an argument of a function type.
2861 * If a non-function type is passed in or the function does not have enough
2862 * parameters, an invalid type is returned.
2864 CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
2867 * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
2869 CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
2872 * \brief Retrieve the result type associated with a given cursor.
2874 * This only returns a valid type if the cursor refers to a function or method.
2876 CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
2879 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
2882 CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
2885 * \brief Return the element type of an array, complex, or vector type.
2887 * If a type is passed in that is not an array, complex, or vector type,
2888 * an invalid type is returned.
2890 CINDEX_LINKAGE CXType clang_getElementType(CXType T);
2893 * \brief Return the number of elements of an array or vector type.
2895 * If a type is passed in that is not an array or vector type,
2898 CINDEX_LINKAGE long long clang_getNumElements(CXType T);
2901 * \brief Return the element type of an array type.
2903 * If a non-array type is passed in, an invalid type is returned.
2905 CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
2908 * \brief Return the array size of a constant array.
2910 * If a non-array type is passed in, -1 is returned.
2912 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
2915 * \brief List the possible error codes for \c clang_Type_getSizeOf,
2916 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
2917 * \c clang_Cursor_getOffsetOf.
2919 * A value of this enumeration type can be returned if the target type is not
2920 * a valid argument to sizeof, alignof or offsetof.
2922 enum CXTypeLayoutError {
2924 * \brief Type is of kind CXType_Invalid.
2926 CXTypeLayoutError_Invalid = -1,
2928 * \brief The type is an incomplete Type.
2930 CXTypeLayoutError_Incomplete = -2,
2932 * \brief The type is a dependent Type.
2934 CXTypeLayoutError_Dependent = -3,
2936 * \brief The type is not a constant size type.
2938 CXTypeLayoutError_NotConstantSize = -4,
2940 * \brief The Field name is not valid for this record.
2942 CXTypeLayoutError_InvalidFieldName = -5
2946 * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
2949 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
2950 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
2952 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
2954 * If the type declaration is not a constant size type,
2955 * CXTypeLayoutError_NotConstantSize is returned.
2957 CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
2960 * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
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
2968 CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
2971 * \brief Return the offset of a field named S in a record of type T in bits
2972 * as it would be returned by __offsetof__ as per C++11[18.2p4]
2974 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
2976 * If the field's type declaration is an incomplete type,
2977 * CXTypeLayoutError_Incomplete is returned.
2978 * If the field's type declaration is a dependent type,
2979 * CXTypeLayoutError_Dependent is returned.
2980 * If the field's name S is not found,
2981 * CXTypeLayoutError_InvalidFieldName is returned.
2983 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
2986 * \brief Returns non-zero if the cursor specifies a Record member that is a
2989 CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
2992 * \brief Returns 1 if the base class specified by the cursor with kind
2993 * CX_CXXBaseSpecifier is virtual.
2995 CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
2998 * \brief Represents the C++ access control level to a base class for a
2999 * cursor with kind CX_CXXBaseSpecifier.
3001 enum CX_CXXAccessSpecifier {
3002 CX_CXXInvalidAccessSpecifier,
3009 * \brief Returns the access control level for the referenced object.
3011 * If the cursor refers to a C++ declaration, its access control level within its
3012 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3013 * access specifier, the specifier itself is returned.
3015 CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3018 * \brief Determine the number of overloaded declarations referenced by a
3019 * \c CXCursor_OverloadedDeclRef cursor.
3021 * \param cursor The cursor whose overloaded declarations are being queried.
3023 * \returns The number of overloaded declarations referenced by \c cursor. If it
3024 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3026 CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3029 * \brief Retrieve a cursor for one of the overloaded declarations referenced
3030 * by a \c CXCursor_OverloadedDeclRef cursor.
3032 * \param cursor The cursor whose overloaded declarations are being queried.
3034 * \param index The zero-based index into the set of overloaded declarations in
3037 * \returns A cursor representing the declaration referenced by the given
3038 * \c cursor at the specified \c index. If the cursor does not have an
3039 * associated set of overloaded declarations, or if the index is out of bounds,
3040 * returns \c clang_getNullCursor();
3042 CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3050 * \defgroup CINDEX_ATTRIBUTES Information for attributes
3057 * \brief For cursors representing an iboutletcollection attribute,
3058 * this function returns the collection element type.
3061 CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3068 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3070 * These routines provide the ability to traverse the abstract syntax tree
3077 * \brief Describes how the traversal of the children of a particular
3078 * cursor should proceed after visiting a particular child cursor.
3080 * A value of this enumeration type should be returned by each
3081 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3083 enum CXChildVisitResult {
3085 * \brief Terminates the cursor traversal.
3089 * \brief Continues the cursor traversal with the next sibling of
3090 * the cursor just visited, without visiting its children.
3092 CXChildVisit_Continue,
3094 * \brief Recursively traverse the children of this cursor, using
3095 * the same visitor and client data.
3097 CXChildVisit_Recurse
3101 * \brief Visitor invoked for each cursor found by a traversal.
3103 * This visitor function will be invoked for each cursor found by
3104 * clang_visitCursorChildren(). Its first argument is the cursor being
3105 * visited, its second argument is the parent visitor for that cursor,
3106 * and its third argument is the client data provided to
3107 * clang_visitCursorChildren().
3109 * The visitor should return one of the \c CXChildVisitResult values
3110 * to direct clang_visitCursorChildren().
3112 typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3114 CXClientData client_data);
3117 * \brief Visit the children of a particular cursor.
3119 * This function visits all the direct children of the given cursor,
3120 * invoking the given \p visitor function with the cursors of each
3121 * visited child. The traversal may be recursive, if the visitor returns
3122 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3123 * the visitor returns \c CXChildVisit_Break.
3125 * \param parent the cursor whose child may be visited. All kinds of
3126 * cursors can be visited, including invalid cursors (which, by
3127 * definition, have no children).
3129 * \param visitor the visitor function that will be invoked for each
3130 * child of \p parent.
3132 * \param client_data pointer data supplied by the client, which will
3133 * be passed to the visitor each time it is invoked.
3135 * \returns a non-zero value if the traversal was terminated
3136 * prematurely by the visitor returning \c CXChildVisit_Break.
3138 CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
3139 CXCursorVisitor visitor,
3140 CXClientData client_data);
3141 #ifdef __has_feature
3142 # if __has_feature(blocks)
3144 * \brief Visitor invoked for each cursor found by a traversal.
3146 * This visitor block will be invoked for each cursor found by
3147 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3148 * visited, its second argument is the parent visitor for that cursor.
3150 * The visitor should return one of the \c CXChildVisitResult values
3151 * to direct clang_visitChildrenWithBlock().
3153 typedef enum CXChildVisitResult
3154 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3157 * Visits the children of a cursor using the specified block. Behaves
3158 * identically to clang_visitChildren() in all other respects.
3160 unsigned clang_visitChildrenWithBlock(CXCursor parent,
3161 CXCursorVisitorBlock block);
3170 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3172 * These routines provide the ability to determine references within and
3173 * across translation units, by providing the names of the entities referenced
3174 * by cursors, follow reference cursors to the declarations they reference,
3175 * and associate declarations with their definitions.
3181 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3182 * by the given cursor.
3184 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3185 * entity (function, class, variable, etc.) within a program. USRs can be
3186 * compared across translation units to determine, e.g., when references in
3187 * one translation refer to an entity defined in another translation unit.
3189 CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3192 * \brief Construct a USR for a specified Objective-C class.
3194 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3197 * \brief Construct a USR for a specified Objective-C category.
3199 CINDEX_LINKAGE CXString
3200 clang_constructUSR_ObjCCategory(const char *class_name,
3201 const char *category_name);
3204 * \brief Construct a USR for a specified Objective-C protocol.
3206 CINDEX_LINKAGE CXString
3207 clang_constructUSR_ObjCProtocol(const char *protocol_name);
3211 * \brief Construct a USR for a specified Objective-C instance variable and
3212 * the USR for its containing class.
3214 CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3218 * \brief Construct a USR for a specified Objective-C method and
3219 * the USR for its containing class.
3221 CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3222 unsigned isInstanceMethod,
3226 * \brief Construct a USR for a specified Objective-C property and the USR
3227 * for its containing class.
3229 CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3233 * \brief Retrieve a name for the entity referenced by this cursor.
3235 CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3238 * \brief Retrieve a range for a piece that forms the cursors spelling name.
3239 * Most of the times there is only one range for the complete spelling but for
3240 * objc methods and objc message expressions, there are multiple pieces for each
3241 * selector identifier.
3243 * \param pieceIndex the index of the spelling name piece. If this is greater
3244 * than the actual number of pieces, it will return a NULL (invalid) range.
3246 * \param options Reserved.
3248 CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
3249 unsigned pieceIndex,
3253 * \brief Retrieve the display name for the entity referenced by this cursor.
3255 * The display name contains extra information that helps identify the cursor,
3256 * such as the parameters of a function or template or the arguments of a
3257 * class template specialization.
3259 CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
3261 /** \brief For a cursor that is a reference, retrieve a cursor representing the
3262 * entity that it references.
3264 * Reference cursors refer to other entities in the AST. For example, an
3265 * Objective-C superclass reference cursor refers to an Objective-C class.
3266 * This function produces the cursor for the Objective-C class from the
3267 * cursor for the superclass reference. If the input cursor is a declaration or
3268 * definition, it returns that declaration or definition unchanged.
3269 * Otherwise, returns the NULL cursor.
3271 CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
3274 * \brief For a cursor that is either a reference to or a declaration
3275 * of some entity, retrieve a cursor that describes the definition of
3278 * Some entities can be declared multiple times within a translation
3279 * unit, but only one of those declarations can also be a
3280 * definition. For example, given:
3284 * int g(int x, int y) { return f(x, y); }
3285 * int f(int a, int b) { return a + b; }
3289 * there are three declarations of the function "f", but only the
3290 * second one is a definition. The clang_getCursorDefinition()
3291 * function will take any cursor pointing to a declaration of "f"
3292 * (the first or fourth lines of the example) or a cursor referenced
3293 * that uses "f" (the call to "f' inside "g") and will return a
3294 * declaration cursor pointing to the definition (the second "f"
3297 * If given a cursor for which there is no corresponding definition,
3298 * e.g., because there is no definition of that entity within this
3299 * translation unit, returns a NULL cursor.
3301 CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
3304 * \brief Determine whether the declaration pointed to by this cursor
3305 * is also a definition of that entity.
3307 CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
3310 * \brief Retrieve the canonical cursor corresponding to the given cursor.
3312 * In the C family of languages, many kinds of entities can be declared several
3313 * times within a single translation unit. For example, a structure type can
3314 * be forward-declared (possibly multiple times) and later defined:
3324 * The declarations and the definition of \c X are represented by three
3325 * different cursors, all of which are declarations of the same underlying
3326 * entity. One of these cursor is considered the "canonical" cursor, which
3327 * is effectively the representative for the underlying entity. One can
3328 * determine if two cursors are declarations of the same underlying entity by
3329 * comparing their canonical cursors.
3331 * \returns The canonical cursor for the entity referred to by the given cursor.
3333 CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
3337 * \brief If the cursor points to a selector identifier in a objc method or
3338 * message expression, this returns the selector index.
3340 * After getting a cursor with #clang_getCursor, this can be called to
3341 * determine if the location points to a selector identifier.
3343 * \returns The selector index if the cursor is an objc method or message
3344 * expression and the cursor is pointing to a selector identifier, or -1
3347 CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
3350 * \brief Given a cursor pointing to a C++ method call or an ObjC message,
3351 * returns non-zero if the method/message is "dynamic", meaning:
3353 * For a C++ method: the call is virtual.
3354 * For an ObjC message: the receiver is an object instance, not 'super' or a
3357 * If the method/message is "static" or the cursor does not point to a
3358 * method/message, it will return zero.
3360 CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
3363 * \brief Given a cursor pointing to an ObjC message, returns the CXType of the
3366 CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
3369 * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
3372 CXObjCPropertyAttr_noattr = 0x00,
3373 CXObjCPropertyAttr_readonly = 0x01,
3374 CXObjCPropertyAttr_getter = 0x02,
3375 CXObjCPropertyAttr_assign = 0x04,
3376 CXObjCPropertyAttr_readwrite = 0x08,
3377 CXObjCPropertyAttr_retain = 0x10,
3378 CXObjCPropertyAttr_copy = 0x20,
3379 CXObjCPropertyAttr_nonatomic = 0x40,
3380 CXObjCPropertyAttr_setter = 0x80,
3381 CXObjCPropertyAttr_atomic = 0x100,
3382 CXObjCPropertyAttr_weak = 0x200,
3383 CXObjCPropertyAttr_strong = 0x400,
3384 CXObjCPropertyAttr_unsafe_unretained = 0x800
3385 } CXObjCPropertyAttrKind;
3388 * \brief Given a cursor that represents a property declaration, return the
3389 * associated property attributes. The bits are formed from
3390 * \c CXObjCPropertyAttrKind.
3392 * \param reserved Reserved for future use, pass 0.
3394 CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
3398 * \brief 'Qualifiers' written next to the return and parameter types in
3399 * ObjC method declarations.
3402 CXObjCDeclQualifier_None = 0x0,
3403 CXObjCDeclQualifier_In = 0x1,
3404 CXObjCDeclQualifier_Inout = 0x2,
3405 CXObjCDeclQualifier_Out = 0x4,
3406 CXObjCDeclQualifier_Bycopy = 0x8,
3407 CXObjCDeclQualifier_Byref = 0x10,
3408 CXObjCDeclQualifier_Oneway = 0x20
3409 } CXObjCDeclQualifierKind;
3412 * \brief Given a cursor that represents an ObjC method or parameter
3413 * declaration, return the associated ObjC qualifiers for the return type or the
3414 * parameter respectively. The bits are formed from CXObjCDeclQualifierKind.
3416 CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
3419 * \brief Returns non-zero if the given cursor is a variadic function or method.
3421 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
3424 * \brief Given a cursor that represents a declaration, return the associated
3425 * comment's source range. The range may include multiple consecutive comments
3426 * with whitespace in between.
3428 CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
3431 * \brief Given a cursor that represents a declaration, return the associated
3432 * comment text, including comment markers.
3434 CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
3437 * \brief Given a cursor that represents a documentable entity (e.g.,
3438 * declaration), return the associated \\brief paragraph; otherwise return the
3441 CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
3444 * \brief Given a cursor that represents a documentable entity (e.g.,
3445 * declaration), return the associated parsed comment as a
3446 * \c CXComment_FullComment AST node.
3448 CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C);
3455 * \defgroup CINDEX_MODULE Module introspection
3457 * The functions in this group provide access to information about modules.
3462 typedef void *CXModule;
3465 * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
3467 CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
3470 * \param Module a module object.
3472 * \returns the module file where the provided module object came from.
3474 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
3477 * \param Module a module object.
3479 * \returns the parent of a sub-module or NULL if the given module is top-level,
3480 * e.g. for 'std.vector' it will return the 'std' module.
3482 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
3485 * \param Module a module object.
3487 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
3488 * will return "vector".
3490 CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
3493 * \param Module a module object.
3495 * \returns the full name of the module, e.g. "std.vector".
3497 CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
3500 * \param Module a module object.
3502 * \returns the number of top level headers associated with this module.
3504 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
3508 * \param Module a module object.
3510 * \param Index top level header index (zero-based).
3512 * \returns the specified top level header associated with the module.
3515 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
3516 CXModule Module, unsigned Index);
3523 * \defgroup CINDEX_COMMENT Comment AST introspection
3525 * The routines in this group provide access to information in the
3526 * documentation comment ASTs.
3532 * \brief Describes the type of the comment AST node (\c CXComment). A comment
3533 * node can be considered block content (e. g., paragraph), inline content
3534 * (plain text) or neither (the root AST node).
3536 enum CXCommentKind {
3538 * \brief Null comment. No AST node is constructed at the requested location
3539 * because there is no text or a syntax error.
3544 * \brief Plain text. Inline content.
3549 * \brief A command with word-like arguments that is considered inline content.
3551 * For example: \\c command.
3553 CXComment_InlineCommand = 2,
3556 * \brief HTML start tag with attributes (name-value pairs). Considered
3561 * <br> <br /> <a href="http://example.org/">
3564 CXComment_HTMLStartTag = 3,
3567 * \brief HTML end tag. Considered inline content.
3574 CXComment_HTMLEndTag = 4,
3577 * \brief A paragraph, contains inline comment. The paragraph itself is
3580 CXComment_Paragraph = 5,
3583 * \brief A command that has zero or more word-like arguments (number of
3584 * word-like arguments depends on command name) and a paragraph as an
3585 * argument. Block command is block content.
3587 * Paragraph argument is also a child of the block command.
3589 * For example: \\brief has 0 word-like arguments and a paragraph argument.
3591 * AST nodes of special kinds that parser knows about (e. g., \\param
3592 * command) have their own node kinds.
3594 CXComment_BlockCommand = 6,
3597 * \brief A \\param or \\arg command that describes the function parameter
3598 * (name, passing direction, description).
3600 * For example: \\param [in] ParamName description.
3602 CXComment_ParamCommand = 7,
3605 * \brief A \\tparam command that describes a template parameter (name and
3608 * For example: \\tparam T description.
3610 CXComment_TParamCommand = 8,
3613 * \brief A verbatim block command (e. g., preformatted code). Verbatim
3614 * block has an opening and a closing command and contains multiple lines of
3615 * text (\c CXComment_VerbatimBlockLine child nodes).
3622 CXComment_VerbatimBlockCommand = 9,
3625 * \brief A line of text that is contained within a
3626 * CXComment_VerbatimBlockCommand node.
3628 CXComment_VerbatimBlockLine = 10,
3631 * \brief A verbatim line command. Verbatim line has an opening command,
3632 * a single line of text (up to the newline after the opening command) and
3633 * has no closing command.
3635 CXComment_VerbatimLine = 11,
3638 * \brief A full comment attached to a declaration, contains block content.
3640 CXComment_FullComment = 12
3644 * \brief The most appropriate rendering mode for an inline command, chosen on
3645 * command semantics in Doxygen.
3647 enum CXCommentInlineCommandRenderKind {
3649 * \brief Command argument should be rendered in a normal font.
3651 CXCommentInlineCommandRenderKind_Normal,
3654 * \brief Command argument should be rendered in a bold font.
3656 CXCommentInlineCommandRenderKind_Bold,
3659 * \brief Command argument should be rendered in a monospaced font.
3661 CXCommentInlineCommandRenderKind_Monospaced,
3664 * \brief Command argument should be rendered emphasized (typically italic
3667 CXCommentInlineCommandRenderKind_Emphasized
3671 * \brief Describes parameter passing direction for \\param or \\arg command.
3673 enum CXCommentParamPassDirection {
3675 * \brief The parameter is an input parameter.
3677 CXCommentParamPassDirection_In,
3680 * \brief The parameter is an output parameter.
3682 CXCommentParamPassDirection_Out,
3685 * \brief The parameter is an input and output parameter.
3687 CXCommentParamPassDirection_InOut
3691 * \param Comment AST node of any kind.
3693 * \returns the type of the AST node.
3695 CINDEX_LINKAGE enum CXCommentKind clang_Comment_getKind(CXComment Comment);
3698 * \param Comment AST node of any kind.
3700 * \returns number of children of the AST node.
3702 CINDEX_LINKAGE unsigned clang_Comment_getNumChildren(CXComment Comment);
3705 * \param Comment AST node of any kind.
3707 * \param ChildIdx child index (zero-based).
3709 * \returns the specified child of the AST node.
3712 CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx);
3715 * \brief A \c CXComment_Paragraph node is considered whitespace if it contains
3716 * only \c CXComment_Text nodes that are empty or whitespace.
3718 * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are
3719 * never considered whitespace.
3721 * \returns non-zero if \c Comment is whitespace.
3723 CINDEX_LINKAGE unsigned clang_Comment_isWhitespace(CXComment Comment);
3726 * \returns non-zero if \c Comment is inline content and has a newline
3727 * immediately following it in the comment text. Newlines between paragraphs
3731 unsigned clang_InlineContentComment_hasTrailingNewline(CXComment Comment);
3734 * \param Comment a \c CXComment_Text AST node.
3736 * \returns text contained in the AST node.
3738 CINDEX_LINKAGE CXString clang_TextComment_getText(CXComment Comment);
3741 * \param Comment a \c CXComment_InlineCommand AST node.
3743 * \returns name of the inline command.
3746 CXString clang_InlineCommandComment_getCommandName(CXComment Comment);
3749 * \param Comment a \c CXComment_InlineCommand AST node.
3751 * \returns the most appropriate rendering mode, chosen on command
3752 * semantics in Doxygen.
3754 CINDEX_LINKAGE enum CXCommentInlineCommandRenderKind
3755 clang_InlineCommandComment_getRenderKind(CXComment Comment);
3758 * \param Comment a \c CXComment_InlineCommand AST node.
3760 * \returns number of command arguments.
3763 unsigned clang_InlineCommandComment_getNumArgs(CXComment Comment);
3766 * \param Comment a \c CXComment_InlineCommand AST node.
3768 * \param ArgIdx argument index (zero-based).
3770 * \returns text of the specified argument.
3773 CXString clang_InlineCommandComment_getArgText(CXComment Comment,
3777 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
3780 * \returns HTML tag name.
3782 CINDEX_LINKAGE CXString clang_HTMLTagComment_getTagName(CXComment Comment);
3785 * \param Comment a \c CXComment_HTMLStartTag AST node.
3787 * \returns non-zero if tag is self-closing (for example, <br />).
3790 unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment Comment);
3793 * \param Comment a \c CXComment_HTMLStartTag AST node.
3795 * \returns number of attributes (name-value pairs) attached to the start tag.
3797 CINDEX_LINKAGE unsigned clang_HTMLStartTag_getNumAttrs(CXComment Comment);
3800 * \param Comment a \c CXComment_HTMLStartTag AST node.
3802 * \param AttrIdx attribute index (zero-based).
3804 * \returns name of the specified attribute.
3807 CXString clang_HTMLStartTag_getAttrName(CXComment Comment, unsigned AttrIdx);
3810 * \param Comment a \c CXComment_HTMLStartTag AST node.
3812 * \param AttrIdx attribute index (zero-based).
3814 * \returns value of the specified attribute.
3817 CXString clang_HTMLStartTag_getAttrValue(CXComment Comment, unsigned AttrIdx);
3820 * \param Comment a \c CXComment_BlockCommand AST node.
3822 * \returns name of the block command.
3825 CXString clang_BlockCommandComment_getCommandName(CXComment Comment);
3828 * \param Comment a \c CXComment_BlockCommand AST node.
3830 * \returns number of word-like arguments.
3833 unsigned clang_BlockCommandComment_getNumArgs(CXComment Comment);
3836 * \param Comment a \c CXComment_BlockCommand AST node.
3838 * \param ArgIdx argument index (zero-based).
3840 * \returns text of the specified word-like argument.
3843 CXString clang_BlockCommandComment_getArgText(CXComment Comment,
3847 * \param Comment a \c CXComment_BlockCommand or
3848 * \c CXComment_VerbatimBlockCommand AST node.
3850 * \returns paragraph argument of the block command.
3853 CXComment clang_BlockCommandComment_getParagraph(CXComment Comment);
3856 * \param Comment a \c CXComment_ParamCommand AST node.
3858 * \returns parameter name.
3861 CXString clang_ParamCommandComment_getParamName(CXComment Comment);
3864 * \param Comment a \c CXComment_ParamCommand AST node.
3866 * \returns non-zero if the parameter that this AST node represents was found
3867 * in the function prototype and \c clang_ParamCommandComment_getParamIndex
3868 * function will return a meaningful value.
3871 unsigned clang_ParamCommandComment_isParamIndexValid(CXComment Comment);
3874 * \param Comment a \c CXComment_ParamCommand AST node.
3876 * \returns zero-based parameter index in function prototype.
3879 unsigned clang_ParamCommandComment_getParamIndex(CXComment Comment);
3882 * \param Comment a \c CXComment_ParamCommand AST node.
3884 * \returns non-zero if parameter passing direction was specified explicitly in
3888 unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment Comment);
3891 * \param Comment a \c CXComment_ParamCommand AST node.
3893 * \returns parameter passing direction.
3896 enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection(
3900 * \param Comment a \c CXComment_TParamCommand AST node.
3902 * \returns template parameter name.
3905 CXString clang_TParamCommandComment_getParamName(CXComment Comment);
3908 * \param Comment a \c CXComment_TParamCommand AST node.
3910 * \returns non-zero if the parameter that this AST node represents was found
3911 * in the template parameter list and
3912 * \c clang_TParamCommandComment_getDepth and
3913 * \c clang_TParamCommandComment_getIndex functions will return a meaningful
3917 unsigned clang_TParamCommandComment_isParamPositionValid(CXComment Comment);
3920 * \param Comment a \c CXComment_TParamCommand AST node.
3922 * \returns zero-based nesting depth of this parameter in the template parameter list.
3926 * template<typename C, template<typename T> class TT>
3927 * void test(TT<int> aaa);
3929 * for C and TT nesting depth is 0,
3930 * for T nesting depth is 1.
3933 unsigned clang_TParamCommandComment_getDepth(CXComment Comment);
3936 * \param Comment a \c CXComment_TParamCommand AST node.
3938 * \returns zero-based parameter index in the template parameter list at a
3939 * given nesting depth.
3943 * template<typename C, template<typename T> class TT>
3944 * void test(TT<int> aaa);
3946 * for C and TT nesting depth is 0, so we can ask for index at depth 0:
3947 * at depth 0 C's index is 0, TT's index is 1.
3949 * For T nesting depth is 1, so we can ask for index at depth 0 and 1:
3950 * at depth 0 T's index is 1 (same as TT's),
3951 * at depth 1 T's index is 0.
3954 unsigned clang_TParamCommandComment_getIndex(CXComment Comment, unsigned Depth);
3957 * \param Comment a \c CXComment_VerbatimBlockLine AST node.
3959 * \returns text contained in the AST node.
3962 CXString clang_VerbatimBlockLineComment_getText(CXComment Comment);
3965 * \param Comment a \c CXComment_VerbatimLine AST node.
3967 * \returns text contained in the AST node.
3969 CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment);
3972 * \brief Convert an HTML tag AST node to string.
3974 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
3977 * \returns string containing an HTML tag.
3979 CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment);
3982 * \brief Convert a given full parsed comment to an HTML fragment.
3984 * Specific details of HTML layout are subject to change. Don't try to parse
3985 * this HTML back into an AST, use other APIs instead.
3987 * Currently the following CSS classes are used:
3988 * \li "para-brief" for \\brief paragraph and equivalent commands;
3989 * \li "para-returns" for \\returns paragraph and equivalent commands;
3990 * \li "word-returns" for the "Returns" word in \\returns paragraph.
3992 * Function argument documentation is rendered as a \<dl\> list with arguments
3993 * sorted in function prototype order. CSS classes used:
3994 * \li "param-name-index-NUMBER" for parameter name (\<dt\>);
3995 * \li "param-descr-index-NUMBER" for parameter description (\<dd\>);
3996 * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if
3997 * parameter index is invalid.
3999 * Template parameter documentation is rendered as a \<dl\> list with
4000 * parameters sorted in template parameter list order. CSS classes used:
4001 * \li "tparam-name-index-NUMBER" for parameter name (\<dt\>);
4002 * \li "tparam-descr-index-NUMBER" for parameter description (\<dd\>);
4003 * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for
4004 * names inside template template parameters;
4005 * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if
4006 * parameter position is invalid.
4008 * \param Comment a \c CXComment_FullComment AST node.
4010 * \returns string containing an HTML fragment.
4012 CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment);
4015 * \brief Convert a given full parsed comment to an XML document.
4017 * A Relax NG schema for the XML can be found in comment-xml-schema.rng file
4018 * inside clang source tree.
4020 * \param Comment a \c CXComment_FullComment AST node.
4022 * \returns string containing an XML document.
4024 CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment);
4031 * \defgroup CINDEX_CPP C++ AST introspection
4033 * The routines in this group provide access information in the ASTs specific
4034 * to C++ language features.
4040 * \brief Determine if a C++ member function or member function template is
4041 * declared 'static'.
4043 CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4046 * \brief Determine if a C++ member function or member function template is
4047 * explicitly declared 'virtual' or if it overrides a virtual method from
4048 * one of the base classes.
4050 CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4053 * \brief Given a cursor that represents a template, determine
4054 * the cursor kind of the specializations would be generated by instantiating
4057 * This routine can be used to determine what flavor of function template,
4058 * class template, or class template partial specialization is stored in the
4059 * cursor. For example, it can describe whether a class template cursor is
4060 * declared with "struct", "class" or "union".
4062 * \param C The cursor to query. This cursor should represent a template
4065 * \returns The cursor kind of the specializations that would be generated
4066 * by instantiating the template \p C. If \p C is not a template, returns
4067 * \c CXCursor_NoDeclFound.
4069 CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4072 * \brief Given a cursor that may represent a specialization or instantiation
4073 * of a template, retrieve the cursor that represents the template that it
4074 * specializes or from which it was instantiated.
4076 * This routine determines the template involved both for explicit
4077 * specializations of templates and for implicit instantiations of the template,
4078 * both of which are referred to as "specializations". For a class template
4079 * specialization (e.g., \c std::vector<bool>), this routine will return
4080 * either the primary template (\c std::vector) or, if the specialization was
4081 * instantiated from a class template partial specialization, the class template
4082 * partial specialization. For a class template partial specialization and a
4083 * function template specialization (including instantiations), this
4084 * this routine will return the specialized template.
4086 * For members of a class template (e.g., member functions, member classes, or
4087 * static data members), returns the specialized or instantiated member.
4088 * Although not strictly "templates" in the C++ language, members of class
4089 * templates have the same notions of specializations and instantiations that
4090 * templates do, so this routine treats them similarly.
4092 * \param C A cursor that may be a specialization of a template or a member
4095 * \returns If the given cursor is a specialization or instantiation of a
4096 * template or a member thereof, the template or member that it specializes or
4097 * from which it was instantiated. Otherwise, returns a NULL cursor.
4099 CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4102 * \brief Given a cursor that references something else, return the source range
4103 * covering that reference.
4105 * \param C A cursor pointing to a member reference, a declaration reference, or
4107 * \param NameFlags A bitset with three independent flags:
4108 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4109 * CXNameRange_WantSinglePiece.
4110 * \param PieceIndex For contiguous names or when passing the flag
4111 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4112 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4113 * non-contiguous names, this index can be used to retrieve the individual
4114 * pieces of the name. See also CXNameRange_WantSinglePiece.
4116 * \returns The piece of the name pointed to by the given cursor. If there is no
4117 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4119 CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4121 unsigned PieceIndex);
4123 enum CXNameRefFlags {
4125 * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4128 CXNameRange_WantQualifier = 0x1,
4131 * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
4134 CXNameRange_WantTemplateArgs = 0x2,
4137 * \brief If the name is non-contiguous, return the full spanning range.
4139 * Non-contiguous names occur in Objective-C when a selector with two or more
4140 * parameters is used, or in C++ when using an operator:
4142 * [object doSomething:here withValue:there]; // ObjC
4143 * return some_vector[1]; // C++
4146 CXNameRange_WantSinglePiece = 0x4
4154 * \defgroup CINDEX_LEX Token extraction and manipulation
4156 * The routines in this group provide access to the tokens within a
4157 * translation unit, along with a semantic mapping of those tokens to
4158 * their corresponding cursors.
4164 * \brief Describes a kind of token.
4166 typedef enum CXTokenKind {
4168 * \brief A token that contains some kind of punctuation.
4170 CXToken_Punctuation,
4173 * \brief A language keyword.
4178 * \brief An identifier (that is not a keyword).
4183 * \brief A numeric, string, or character literal.
4194 * \brief Describes a single preprocessing token.
4197 unsigned int_data[4];
4202 * \brief Determine the kind of the given token.
4204 CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4207 * \brief Determine the spelling of the given token.
4209 * The spelling of a token is the textual representation of that token, e.g.,
4210 * the text of an identifier or keyword.
4212 CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4215 * \brief Retrieve the source location of the given token.
4217 CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4221 * \brief Retrieve a source range that covers the given token.
4223 CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4226 * \brief Tokenize the source code described by the given range into raw
4229 * \param TU the translation unit whose text is being tokenized.
4231 * \param Range the source range in which text should be tokenized. All of the
4232 * tokens produced by tokenization will fall within this source range,
4234 * \param Tokens this pointer will be set to point to the array of tokens
4235 * that occur within the given source range. The returned pointer must be
4236 * freed with clang_disposeTokens() before the translation unit is destroyed.
4238 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4242 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4243 CXToken **Tokens, unsigned *NumTokens);
4246 * \brief Annotate the given set of tokens by providing cursors for each token
4247 * that can be mapped to a specific entity within the abstract syntax tree.
4249 * This token-annotation routine is equivalent to invoking
4250 * clang_getCursor() for the source locations of each of the
4251 * tokens. The cursors provided are filtered, so that only those
4252 * cursors that have a direct correspondence to the token are
4253 * accepted. For example, given a function call \c f(x),
4254 * clang_getCursor() would provide the following cursors:
4256 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4257 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4258 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4260 * Only the first and last of these cursors will occur within the
4261 * annotate, since the tokens "f" and "x' directly refer to a function
4262 * and a variable, respectively, but the parentheses are just a small
4263 * part of the full syntax of the function call expression, which is
4264 * not provided as an annotation.
4266 * \param TU the translation unit that owns the given tokens.
4268 * \param Tokens the set of tokens to annotate.
4270 * \param NumTokens the number of tokens in \p Tokens.
4272 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4273 * replaced with the cursors corresponding to each token.
4275 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4276 CXToken *Tokens, unsigned NumTokens,
4280 * \brief Free the given set of tokens.
4282 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4283 CXToken *Tokens, unsigned NumTokens);
4290 * \defgroup CINDEX_DEBUG Debugging facilities
4292 * These routines are used for testing and debugging, only, and should not
4298 /* for debug/testing */
4299 CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4300 CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4301 const char **startBuf,
4302 const char **endBuf,
4303 unsigned *startLine,
4304 unsigned *startColumn,
4306 unsigned *endColumn);
4307 CINDEX_LINKAGE void clang_enableStackTraces(void);
4308 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4309 unsigned stack_size);
4316 * \defgroup CINDEX_CODE_COMPLET Code completion
4318 * Code completion involves taking an (incomplete) source file, along with
4319 * knowledge of where the user is actively editing that file, and suggesting
4320 * syntactically- and semantically-valid constructs that the user might want to
4321 * use at that particular point in the source code. These data structures and
4322 * routines provide support for code completion.
4328 * \brief A semantic string that describes a code-completion result.
4330 * A semantic string that describes the formatting of a code-completion
4331 * result as a single "template" of text that should be inserted into the
4332 * source buffer when a particular code-completion result is selected.
4333 * Each semantic string is made up of some number of "chunks", each of which
4334 * contains some text along with a description of what that text means, e.g.,
4335 * the name of the entity being referenced, whether the text chunk is part of
4336 * the template, or whether it is a "placeholder" that the user should replace
4337 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4338 * description of the different kinds of chunks.
4340 typedef void *CXCompletionString;
4343 * \brief A single result of code completion.
4347 * \brief The kind of entity that this completion refers to.
4349 * The cursor kind will be a macro, keyword, or a declaration (one of the
4350 * *Decl cursor kinds), describing the entity that the completion is
4353 * \todo In the future, we would like to provide a full cursor, to allow
4354 * the client to extract additional information from declaration.
4356 enum CXCursorKind CursorKind;
4359 * \brief The code-completion string that describes how to insert this
4360 * code-completion result into the editing buffer.
4362 CXCompletionString CompletionString;
4363 } CXCompletionResult;
4366 * \brief Describes a single piece of text within a code-completion string.
4368 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4369 * either a piece of text with a specific "kind" that describes how that text
4370 * should be interpreted by the client or is another completion string.
4372 enum CXCompletionChunkKind {
4374 * \brief A code-completion string that describes "optional" text that
4375 * could be a part of the template (but is not required).
4377 * The Optional chunk is the only kind of chunk that has a code-completion
4378 * string for its representation, which is accessible via
4379 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4380 * describes an additional part of the template that is completely optional.
4381 * For example, optional chunks can be used to describe the placeholders for
4382 * arguments that match up with defaulted function parameters, e.g. given:
4385 * void f(int x, float y = 3.14, double z = 2.71828);
4388 * The code-completion string for this function would contain:
4389 * - a TypedText chunk for "f".
4390 * - a LeftParen chunk for "(".
4391 * - a Placeholder chunk for "int x"
4392 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4393 * - a Comma chunk for ","
4394 * - a Placeholder chunk for "float y"
4395 * - an Optional chunk containing the last defaulted argument:
4396 * - a Comma chunk for ","
4397 * - a Placeholder chunk for "double z"
4398 * - a RightParen chunk for ")"
4400 * There are many ways to handle Optional chunks. Two simple approaches are:
4401 * - Completely ignore optional chunks, in which case the template for the
4402 * function "f" would only include the first parameter ("int x").
4403 * - Fully expand all optional chunks, in which case the template for the
4404 * function "f" would have all of the parameters.
4406 CXCompletionChunk_Optional,
4408 * \brief Text that a user would be expected to type to get this
4409 * code-completion result.
4411 * There will be exactly one "typed text" chunk in a semantic string, which
4412 * will typically provide the spelling of a keyword or the name of a
4413 * declaration that could be used at the current code point. Clients are
4414 * expected to filter the code-completion results based on the text in this
4417 CXCompletionChunk_TypedText,
4419 * \brief Text that should be inserted as part of a code-completion result.
4421 * A "text" chunk represents text that is part of the template to be
4422 * inserted into user code should this particular code-completion result
4425 CXCompletionChunk_Text,
4427 * \brief Placeholder text that should be replaced by the user.
4429 * A "placeholder" chunk marks a place where the user should insert text
4430 * into the code-completion template. For example, placeholders might mark
4431 * the function parameters for a function declaration, to indicate that the
4432 * user should provide arguments for each of those parameters. The actual
4433 * text in a placeholder is a suggestion for the text to display before
4434 * the user replaces the placeholder with real code.
4436 CXCompletionChunk_Placeholder,
4438 * \brief Informative text that should be displayed but never inserted as
4439 * part of the template.
4441 * An "informative" chunk contains annotations that can be displayed to
4442 * help the user decide whether a particular code-completion result is the
4443 * right option, but which is not part of the actual template to be inserted
4444 * by code completion.
4446 CXCompletionChunk_Informative,
4448 * \brief Text that describes the current parameter when code-completion is
4449 * referring to function call, message send, or template specialization.
4451 * A "current parameter" chunk occurs when code-completion is providing
4452 * information about a parameter corresponding to the argument at the
4453 * code-completion point. For example, given a function
4456 * int add(int x, int y);
4459 * and the source code \c add(, where the code-completion point is after the
4460 * "(", the code-completion string will contain a "current parameter" chunk
4461 * for "int x", indicating that the current argument will initialize that
4462 * parameter. After typing further, to \c add(17, (where the code-completion
4463 * point is after the ","), the code-completion string will contain a
4464 * "current paremeter" chunk to "int y".
4466 CXCompletionChunk_CurrentParameter,
4468 * \brief A left parenthesis ('('), used to initiate a function call or
4469 * signal the beginning of a function parameter list.
4471 CXCompletionChunk_LeftParen,
4473 * \brief A right parenthesis (')'), used to finish a function call or
4474 * signal the end of a function parameter list.
4476 CXCompletionChunk_RightParen,
4478 * \brief A left bracket ('[').
4480 CXCompletionChunk_LeftBracket,
4482 * \brief A right bracket (']').
4484 CXCompletionChunk_RightBracket,
4486 * \brief A left brace ('{').
4488 CXCompletionChunk_LeftBrace,
4490 * \brief A right brace ('}').
4492 CXCompletionChunk_RightBrace,
4494 * \brief A left angle bracket ('<').
4496 CXCompletionChunk_LeftAngle,
4498 * \brief A right angle bracket ('>').
4500 CXCompletionChunk_RightAngle,
4502 * \brief A comma separator (',').
4504 CXCompletionChunk_Comma,
4506 * \brief Text that specifies the result type of a given result.
4508 * This special kind of informative chunk is not meant to be inserted into
4509 * the text buffer. Rather, it is meant to illustrate the type that an
4510 * expression using the given completion string would have.
4512 CXCompletionChunk_ResultType,
4514 * \brief A colon (':').
4516 CXCompletionChunk_Colon,
4518 * \brief A semicolon (';').
4520 CXCompletionChunk_SemiColon,
4522 * \brief An '=' sign.
4524 CXCompletionChunk_Equal,
4526 * Horizontal space (' ').
4528 CXCompletionChunk_HorizontalSpace,
4530 * Vertical space ('\n'), after which it is generally a good idea to
4531 * perform indentation.
4533 CXCompletionChunk_VerticalSpace
4537 * \brief Determine the kind of a particular chunk within a completion string.
4539 * \param completion_string the completion string to query.
4541 * \param chunk_number the 0-based index of the chunk in the completion string.
4543 * \returns the kind of the chunk at the index \c chunk_number.
4545 CINDEX_LINKAGE enum CXCompletionChunkKind
4546 clang_getCompletionChunkKind(CXCompletionString completion_string,
4547 unsigned chunk_number);
4550 * \brief Retrieve the text associated with a particular chunk within a
4551 * completion string.
4553 * \param completion_string the completion string to query.
4555 * \param chunk_number the 0-based index of the chunk in the completion string.
4557 * \returns the text associated with the chunk at index \c chunk_number.
4559 CINDEX_LINKAGE CXString
4560 clang_getCompletionChunkText(CXCompletionString completion_string,
4561 unsigned chunk_number);
4564 * \brief Retrieve the completion string associated with a particular chunk
4565 * within a completion string.
4567 * \param completion_string the completion string to query.
4569 * \param chunk_number the 0-based index of the chunk in the completion string.
4571 * \returns the completion string associated with the chunk at index
4574 CINDEX_LINKAGE CXCompletionString
4575 clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4576 unsigned chunk_number);
4579 * \brief Retrieve the number of chunks in the given code-completion string.
4581 CINDEX_LINKAGE unsigned
4582 clang_getNumCompletionChunks(CXCompletionString completion_string);
4585 * \brief Determine the priority of this code completion.
4587 * The priority of a code completion indicates how likely it is that this
4588 * particular completion is the completion that the user will select. The
4589 * priority is selected by various internal heuristics.
4591 * \param completion_string The completion string to query.
4593 * \returns The priority of this completion string. Smaller values indicate
4594 * higher-priority (more likely) completions.
4596 CINDEX_LINKAGE unsigned
4597 clang_getCompletionPriority(CXCompletionString completion_string);
4600 * \brief Determine the availability of the entity that this code-completion
4603 * \param completion_string The completion string to query.
4605 * \returns The availability of the completion string.
4607 CINDEX_LINKAGE enum CXAvailabilityKind
4608 clang_getCompletionAvailability(CXCompletionString completion_string);
4611 * \brief Retrieve the number of annotations associated with the given
4612 * completion string.
4614 * \param completion_string the completion string to query.
4616 * \returns the number of annotations associated with the given completion
4619 CINDEX_LINKAGE unsigned
4620 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
4623 * \brief Retrieve the annotation associated with the given completion string.
4625 * \param completion_string the completion string to query.
4627 * \param annotation_number the 0-based index of the annotation of the
4628 * completion string.
4630 * \returns annotation string associated with the completion at index
4631 * \c annotation_number, or a NULL string if that annotation is not available.
4633 CINDEX_LINKAGE CXString
4634 clang_getCompletionAnnotation(CXCompletionString completion_string,
4635 unsigned annotation_number);
4638 * \brief Retrieve the parent context of the given completion string.
4640 * The parent context of a completion string is the semantic parent of
4641 * the declaration (if any) that the code completion represents. For example,
4642 * a code completion for an Objective-C method would have the method's class
4643 * or protocol as its context.
4645 * \param completion_string The code completion string whose parent is
4648 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
4650 * \returns The name of the completion parent, e.g., "NSObject" if
4651 * the completion string represents a method in the NSObject class.
4653 CINDEX_LINKAGE CXString
4654 clang_getCompletionParent(CXCompletionString completion_string,
4655 enum CXCursorKind *kind);
4658 * \brief Retrieve the brief documentation comment attached to the declaration
4659 * that corresponds to the given completion string.
4661 CINDEX_LINKAGE CXString
4662 clang_getCompletionBriefComment(CXCompletionString completion_string);
4665 * \brief Retrieve a completion string for an arbitrary declaration or macro
4666 * definition cursor.
4668 * \param cursor The cursor to query.
4670 * \returns A non-context-sensitive completion string for declaration and macro
4671 * definition cursors, or NULL for other kinds of cursors.
4673 CINDEX_LINKAGE CXCompletionString
4674 clang_getCursorCompletionString(CXCursor cursor);
4677 * \brief Contains the results of code-completion.
4679 * This data structure contains the results of code completion, as
4680 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
4681 * \c clang_disposeCodeCompleteResults.
4685 * \brief The code-completion results.
4687 CXCompletionResult *Results;
4690 * \brief The number of code-completion results stored in the
4693 unsigned NumResults;
4694 } CXCodeCompleteResults;
4697 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
4698 * modify its behavior.
4700 * The enumerators in this enumeration can be bitwise-OR'd together to
4701 * provide multiple options to \c clang_codeCompleteAt().
4703 enum CXCodeComplete_Flags {
4705 * \brief Whether to include macros within the set of code
4706 * completions returned.
4708 CXCodeComplete_IncludeMacros = 0x01,
4711 * \brief Whether to include code patterns for language constructs
4712 * within the set of code completions, e.g., for loops.
4714 CXCodeComplete_IncludeCodePatterns = 0x02,
4717 * \brief Whether to include brief documentation within the set of code
4718 * completions returned.
4720 CXCodeComplete_IncludeBriefComments = 0x04
4724 * \brief Bits that represent the context under which completion is occurring.
4726 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
4727 * contexts are occurring simultaneously.
4729 enum CXCompletionContext {
4731 * \brief The context for completions is unexposed, as only Clang results
4732 * should be included. (This is equivalent to having no context bits set.)
4734 CXCompletionContext_Unexposed = 0,
4737 * \brief Completions for any possible type should be included in the results.
4739 CXCompletionContext_AnyType = 1 << 0,
4742 * \brief Completions for any possible value (variables, function calls, etc.)
4743 * should be included in the results.
4745 CXCompletionContext_AnyValue = 1 << 1,
4747 * \brief Completions for values that resolve to an Objective-C object should
4748 * be included in the results.
4750 CXCompletionContext_ObjCObjectValue = 1 << 2,
4752 * \brief Completions for values that resolve to an Objective-C selector
4753 * should be included in the results.
4755 CXCompletionContext_ObjCSelectorValue = 1 << 3,
4757 * \brief Completions for values that resolve to a C++ class type should be
4758 * included in the results.
4760 CXCompletionContext_CXXClassTypeValue = 1 << 4,
4763 * \brief Completions for fields of the member being accessed using the dot
4764 * operator should be included in the results.
4766 CXCompletionContext_DotMemberAccess = 1 << 5,
4768 * \brief Completions for fields of the member being accessed using the arrow
4769 * operator should be included in the results.
4771 CXCompletionContext_ArrowMemberAccess = 1 << 6,
4773 * \brief Completions for properties of the Objective-C object being accessed
4774 * using the dot operator should be included in the results.
4776 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
4779 * \brief Completions for enum tags should be included in the results.
4781 CXCompletionContext_EnumTag = 1 << 8,
4783 * \brief Completions for union tags should be included in the results.
4785 CXCompletionContext_UnionTag = 1 << 9,
4787 * \brief Completions for struct tags should be included in the results.
4789 CXCompletionContext_StructTag = 1 << 10,
4792 * \brief Completions for C++ class names should be included in the results.
4794 CXCompletionContext_ClassTag = 1 << 11,
4796 * \brief Completions for C++ namespaces and namespace aliases should be
4797 * included in the results.
4799 CXCompletionContext_Namespace = 1 << 12,
4801 * \brief Completions for C++ nested name specifiers should be included in
4804 CXCompletionContext_NestedNameSpecifier = 1 << 13,
4807 * \brief Completions for Objective-C interfaces (classes) should be included
4810 CXCompletionContext_ObjCInterface = 1 << 14,
4812 * \brief Completions for Objective-C protocols should be included in
4815 CXCompletionContext_ObjCProtocol = 1 << 15,
4817 * \brief Completions for Objective-C categories should be included in
4820 CXCompletionContext_ObjCCategory = 1 << 16,
4822 * \brief Completions for Objective-C instance messages should be included
4825 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
4827 * \brief Completions for Objective-C class messages should be included in
4830 CXCompletionContext_ObjCClassMessage = 1 << 18,
4832 * \brief Completions for Objective-C selector names should be included in
4835 CXCompletionContext_ObjCSelectorName = 1 << 19,
4838 * \brief Completions for preprocessor macro names should be included in
4841 CXCompletionContext_MacroName = 1 << 20,
4844 * \brief Natural language completions should be included in the results.
4846 CXCompletionContext_NaturalLanguage = 1 << 21,
4849 * \brief The current context is unknown, so set all contexts.
4851 CXCompletionContext_Unknown = ((1 << 22) - 1)
4855 * \brief Returns a default set of code-completion options that can be
4856 * passed to\c clang_codeCompleteAt().
4858 CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
4861 * \brief Perform code completion at a given location in a translation unit.
4863 * This function performs code completion at a particular file, line, and
4864 * column within source code, providing results that suggest potential
4865 * code snippets based on the context of the completion. The basic model
4866 * for code completion is that Clang will parse a complete source file,
4867 * performing syntax checking up to the location where code-completion has
4868 * been requested. At that point, a special code-completion token is passed
4869 * to the parser, which recognizes this token and determines, based on the
4870 * current location in the C/Objective-C/C++ grammar and the state of
4871 * semantic analysis, what completions to provide. These completions are
4872 * returned via a new \c CXCodeCompleteResults structure.
4874 * Code completion itself is meant to be triggered by the client when the
4875 * user types punctuation characters or whitespace, at which point the
4876 * code-completion location will coincide with the cursor. For example, if \c p
4877 * is a pointer, code-completion might be triggered after the "-" and then
4878 * after the ">" in \c p->. When the code-completion location is afer the ">",
4879 * the completion results will provide, e.g., the members of the struct that
4880 * "p" points to. The client is responsible for placing the cursor at the
4881 * beginning of the token currently being typed, then filtering the results
4882 * based on the contents of the token. For example, when code-completing for
4883 * the expression \c p->get, the client should provide the location just after
4884 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
4885 * client can filter the results based on the current token text ("get"), only
4886 * showing those results that start with "get". The intent of this interface
4887 * is to separate the relatively high-latency acquisition of code-completion
4888 * results from the filtering of results on a per-character basis, which must
4889 * have a lower latency.
4891 * \param TU The translation unit in which code-completion should
4892 * occur. The source files for this translation unit need not be
4893 * completely up-to-date (and the contents of those source files may
4894 * be overridden via \p unsaved_files). Cursors referring into the
4895 * translation unit may be invalidated by this invocation.
4897 * \param complete_filename The name of the source file where code
4898 * completion should be performed. This filename may be any file
4899 * included in the translation unit.
4901 * \param complete_line The line at which code-completion should occur.
4903 * \param complete_column The column at which code-completion should occur.
4904 * Note that the column should point just after the syntactic construct that
4905 * initiated code completion, and not in the middle of a lexical token.
4907 * \param unsaved_files the Tiles that have not yet been saved to disk
4908 * but may be required for parsing or code completion, including the
4909 * contents of those files. The contents and name of these files (as
4910 * specified by CXUnsavedFile) are copied when necessary, so the
4911 * client only needs to guarantee their validity until the call to
4912 * this function returns.
4914 * \param num_unsaved_files The number of unsaved file entries in \p
4917 * \param options Extra options that control the behavior of code
4918 * completion, expressed as a bitwise OR of the enumerators of the
4919 * CXCodeComplete_Flags enumeration. The
4920 * \c clang_defaultCodeCompleteOptions() function returns a default set
4921 * of code-completion options.
4923 * \returns If successful, a new \c CXCodeCompleteResults structure
4924 * containing code-completion results, which should eventually be
4925 * freed with \c clang_disposeCodeCompleteResults(). If code
4926 * completion fails, returns NULL.
4929 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
4930 const char *complete_filename,
4931 unsigned complete_line,
4932 unsigned complete_column,
4933 struct CXUnsavedFile *unsaved_files,
4934 unsigned num_unsaved_files,
4938 * \brief Sort the code-completion results in case-insensitive alphabetical
4941 * \param Results The set of results to sort.
4942 * \param NumResults The number of results in \p Results.
4945 void clang_sortCodeCompletionResults(CXCompletionResult *Results,
4946 unsigned NumResults);
4949 * \brief Free the given set of code-completion results.
4952 void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
4955 * \brief Determine the number of diagnostics produced prior to the
4956 * location where code completion was performed.
4959 unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
4962 * \brief Retrieve a diagnostic associated with the given code completion.
4964 * \param Results the code completion results to query.
4965 * \param Index the zero-based diagnostic number to retrieve.
4967 * \returns the requested diagnostic. This diagnostic must be freed
4968 * via a call to \c clang_disposeDiagnostic().
4971 CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
4975 * \brief Determines what compeltions are appropriate for the context
4976 * the given code completion.
4978 * \param Results the code completion results to query
4980 * \returns the kinds of completions that are appropriate for use
4981 * along with the given code completion results.
4984 unsigned long long clang_codeCompleteGetContexts(
4985 CXCodeCompleteResults *Results);
4988 * \brief Returns the cursor kind for the container for the current code
4989 * completion context. The container is only guaranteed to be set for
4990 * contexts where a container exists (i.e. member accesses or Objective-C
4991 * message sends); if there is not a container, this function will return
4992 * CXCursor_InvalidCode.
4994 * \param Results the code completion results to query
4996 * \param IsIncomplete on return, this value will be false if Clang has complete
4997 * information about the container. If Clang does not have complete
4998 * information, this value will be true.
5000 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5004 enum CXCursorKind clang_codeCompleteGetContainerKind(
5005 CXCodeCompleteResults *Results,
5006 unsigned *IsIncomplete);
5009 * \brief Returns the USR for the container for the current code completion
5010 * context. If there is not a container for the current context, this
5011 * function will return the empty string.
5013 * \param Results the code completion results to query
5015 * \returns the USR for the container
5018 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5022 * \brief Returns the currently-entered selector for an Objective-C message
5023 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5024 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5025 * CXCompletionContext_ObjCClassMessage.
5027 * \param Results the code completion results to query
5029 * \returns the selector (or partial selector) that has been entered thus far
5030 * for an Objective-C message send.
5033 CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5041 * \defgroup CINDEX_MISC Miscellaneous utility functions
5047 * \brief Return a version string, suitable for showing to a user, but not
5048 * intended to be parsed (the format is not guaranteed to be stable).
5050 CINDEX_LINKAGE CXString clang_getClangVersion(void);
5054 * \brief Enable/disable crash recovery.
5056 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5057 * value enables crash recovery, while 0 disables it.
5059 CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5062 * \brief Visitor invoked for each file in a translation unit
5063 * (used with clang_getInclusions()).
5065 * This visitor function will be invoked by clang_getInclusions() for each
5066 * file included (either at the top-level or by \#include directives) within
5067 * a translation unit. The first argument is the file being included, and
5068 * the second and third arguments provide the inclusion stack. The
5069 * array is sorted in order of immediate inclusion. For example,
5070 * the first element refers to the location that included 'included_file'.
5072 typedef void (*CXInclusionVisitor)(CXFile included_file,
5073 CXSourceLocation* inclusion_stack,
5074 unsigned include_len,
5075 CXClientData client_data);
5078 * \brief Visit the set of preprocessor inclusions in a translation unit.
5079 * The visitor function is called with the provided data for every included
5080 * file. This does not include headers included by the PCH file (unless one
5081 * is inspecting the inclusions in the PCH file itself).
5083 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5084 CXInclusionVisitor visitor,
5085 CXClientData client_data);
5091 /** \defgroup CINDEX_REMAPPING Remapping functions
5097 * \brief A remapping of original source files and their translated files.
5099 typedef void *CXRemapping;
5102 * \brief Retrieve a remapping.
5104 * \param path the path that contains metadata about remappings.
5106 * \returns the requested remapping. This remapping must be freed
5107 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5109 CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5112 * \brief Retrieve a remapping.
5114 * \param filePaths pointer to an array of file paths containing remapping info.
5116 * \param numFiles number of file paths.
5118 * \returns the requested remapping. This remapping must be freed
5119 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5122 CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5126 * \brief Determine the number of remappings.
5128 CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5131 * \brief Get the original and the associated filename from the remapping.
5133 * \param original If non-NULL, will be set to the original filename.
5135 * \param transformed If non-NULL, will be set to the filename that the original
5136 * is associated with.
5138 CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5139 CXString *original, CXString *transformed);
5142 * \brief Dispose the remapping.
5144 CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5150 /** \defgroup CINDEX_HIGH Higher level API functions
5155 enum CXVisitorResult {
5162 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5163 } CXCursorAndRangeVisitor;
5167 * \brief Function returned successfully.
5169 CXResult_Success = 0,
5171 * \brief One of the parameters was invalid for the function.
5173 CXResult_Invalid = 1,
5175 * \brief The function was terminated by a callback (e.g. it returned
5178 CXResult_VisitBreak = 2
5183 * \brief Find references of a declaration in a specific file.
5185 * \param cursor pointing to a declaration or a reference of one.
5187 * \param file to search for references.
5189 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5190 * each reference found.
5191 * The CXSourceRange will point inside the file; if the reference is inside
5192 * a macro (and not a macro argument) the CXSourceRange will be invalid.
5194 * \returns one of the CXResult enumerators.
5196 CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5197 CXCursorAndRangeVisitor visitor);
5200 * \brief Find #import/#include directives in a specific file.
5202 * \param TU translation unit containing the file to query.
5204 * \param file to search for #import/#include directives.
5206 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5207 * each directive found.
5209 * \returns one of the CXResult enumerators.
5211 CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5213 CXCursorAndRangeVisitor visitor);
5215 #ifdef __has_feature
5216 # if __has_feature(blocks)
5218 typedef enum CXVisitorResult
5219 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5222 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5223 CXCursorAndRangeVisitorBlock);
5226 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5227 CXCursorAndRangeVisitorBlock);
5233 * \brief The client's data object that is associated with a CXFile.
5235 typedef void *CXIdxClientFile;
5238 * \brief The client's data object that is associated with a semantic entity.
5240 typedef void *CXIdxClientEntity;
5243 * \brief The client's data object that is associated with a semantic container
5246 typedef void *CXIdxClientContainer;
5249 * \brief The client's data object that is associated with an AST file (PCH
5252 typedef void *CXIdxClientASTFile;
5255 * \brief Source location passed to index callbacks.
5263 * \brief Data for ppIncludedFile callback.
5267 * \brief Location of '#' in the \#include/\#import directive.
5271 * \brief Filename as written in the \#include/\#import directive.
5273 const char *filename;
5275 * \brief The actual file that the \#include/\#import directive resolved to.
5281 * \brief Non-zero if the directive was automatically turned into a module
5285 } CXIdxIncludedFileInfo;
5288 * \brief Data for IndexerCallbacks#importedASTFile.
5292 * \brief Top level AST file containing the imported PCH, module or submodule.
5296 * \brief The imported module or NULL if the AST file is a PCH.
5300 * \brief Location where the file is imported. Applicable only for modules.
5304 * \brief Non-zero if an inclusion directive was automatically turned into
5305 * a module import. Applicable only for modules.
5309 } CXIdxImportedASTFileInfo;
5312 CXIdxEntity_Unexposed = 0,
5313 CXIdxEntity_Typedef = 1,
5314 CXIdxEntity_Function = 2,
5315 CXIdxEntity_Variable = 3,
5316 CXIdxEntity_Field = 4,
5317 CXIdxEntity_EnumConstant = 5,
5319 CXIdxEntity_ObjCClass = 6,
5320 CXIdxEntity_ObjCProtocol = 7,
5321 CXIdxEntity_ObjCCategory = 8,
5323 CXIdxEntity_ObjCInstanceMethod = 9,
5324 CXIdxEntity_ObjCClassMethod = 10,
5325 CXIdxEntity_ObjCProperty = 11,
5326 CXIdxEntity_ObjCIvar = 12,
5328 CXIdxEntity_Enum = 13,
5329 CXIdxEntity_Struct = 14,
5330 CXIdxEntity_Union = 15,
5332 CXIdxEntity_CXXClass = 16,
5333 CXIdxEntity_CXXNamespace = 17,
5334 CXIdxEntity_CXXNamespaceAlias = 18,
5335 CXIdxEntity_CXXStaticVariable = 19,
5336 CXIdxEntity_CXXStaticMethod = 20,
5337 CXIdxEntity_CXXInstanceMethod = 21,
5338 CXIdxEntity_CXXConstructor = 22,
5339 CXIdxEntity_CXXDestructor = 23,
5340 CXIdxEntity_CXXConversionFunction = 24,
5341 CXIdxEntity_CXXTypeAlias = 25,
5342 CXIdxEntity_CXXInterface = 26
5347 CXIdxEntityLang_None = 0,
5348 CXIdxEntityLang_C = 1,
5349 CXIdxEntityLang_ObjC = 2,
5350 CXIdxEntityLang_CXX = 3
5351 } CXIdxEntityLanguage;
5354 * \brief Extra C++ template information for an entity. This can apply to:
5355 * CXIdxEntity_Function
5356 * CXIdxEntity_CXXClass
5357 * CXIdxEntity_CXXStaticMethod
5358 * CXIdxEntity_CXXInstanceMethod
5359 * CXIdxEntity_CXXConstructor
5360 * CXIdxEntity_CXXConversionFunction
5361 * CXIdxEntity_CXXTypeAlias
5364 CXIdxEntity_NonTemplate = 0,
5365 CXIdxEntity_Template = 1,
5366 CXIdxEntity_TemplatePartialSpecialization = 2,
5367 CXIdxEntity_TemplateSpecialization = 3
5368 } CXIdxEntityCXXTemplateKind;
5371 CXIdxAttr_Unexposed = 0,
5372 CXIdxAttr_IBAction = 1,
5373 CXIdxAttr_IBOutlet = 2,
5374 CXIdxAttr_IBOutletCollection = 3
5384 CXIdxEntityKind kind;
5385 CXIdxEntityCXXTemplateKind templateKind;
5386 CXIdxEntityLanguage lang;
5390 const CXIdxAttrInfo *const *attributes;
5391 unsigned numAttributes;
5396 } CXIdxContainerInfo;
5399 const CXIdxAttrInfo *attrInfo;
5400 const CXIdxEntityInfo *objcClass;
5401 CXCursor classCursor;
5403 } CXIdxIBOutletCollectionAttrInfo;
5406 CXIdxDeclFlag_Skipped = 0x1
5407 } CXIdxDeclInfoFlags;
5410 const CXIdxEntityInfo *entityInfo;
5413 const CXIdxContainerInfo *semanticContainer;
5415 * \brief Generally same as #semanticContainer but can be different in
5416 * cases like out-of-line C++ member functions.
5418 const CXIdxContainerInfo *lexicalContainer;
5419 int isRedeclaration;
5422 const CXIdxContainerInfo *declAsContainer;
5424 * \brief Whether the declaration exists in code or was created implicitly
5425 * by the compiler, e.g. implicit objc methods for properties.
5428 const CXIdxAttrInfo *const *attributes;
5429 unsigned numAttributes;
5436 CXIdxObjCContainer_ForwardRef = 0,
5437 CXIdxObjCContainer_Interface = 1,
5438 CXIdxObjCContainer_Implementation = 2
5439 } CXIdxObjCContainerKind;
5442 const CXIdxDeclInfo *declInfo;
5443 CXIdxObjCContainerKind kind;
5444 } CXIdxObjCContainerDeclInfo;
5447 const CXIdxEntityInfo *base;
5450 } CXIdxBaseClassInfo;
5453 const CXIdxEntityInfo *protocol;
5456 } CXIdxObjCProtocolRefInfo;
5459 const CXIdxObjCProtocolRefInfo *const *protocols;
5460 unsigned numProtocols;
5461 } CXIdxObjCProtocolRefListInfo;
5464 const CXIdxObjCContainerDeclInfo *containerInfo;
5465 const CXIdxBaseClassInfo *superInfo;
5466 const CXIdxObjCProtocolRefListInfo *protocols;
5467 } CXIdxObjCInterfaceDeclInfo;
5470 const CXIdxObjCContainerDeclInfo *containerInfo;
5471 const CXIdxEntityInfo *objcClass;
5472 CXCursor classCursor;
5474 const CXIdxObjCProtocolRefListInfo *protocols;
5475 } CXIdxObjCCategoryDeclInfo;
5478 const CXIdxDeclInfo *declInfo;
5479 const CXIdxEntityInfo *getter;
5480 const CXIdxEntityInfo *setter;
5481 } CXIdxObjCPropertyDeclInfo;
5484 const CXIdxDeclInfo *declInfo;
5485 const CXIdxBaseClassInfo *const *bases;
5487 } CXIdxCXXClassDeclInfo;
5490 * \brief Data for IndexerCallbacks#indexEntityReference.
5494 * \brief The entity is referenced directly in user's code.
5496 CXIdxEntityRef_Direct = 1,
5498 * \brief An implicit reference, e.g. a reference of an ObjC method via the
5501 CXIdxEntityRef_Implicit = 2
5502 } CXIdxEntityRefKind;
5505 * \brief Data for IndexerCallbacks#indexEntityReference.
5508 CXIdxEntityRefKind kind;
5510 * \brief Reference cursor.
5515 * \brief The entity that gets referenced.
5517 const CXIdxEntityInfo *referencedEntity;
5519 * \brief Immediate "parent" of the reference. For example:
5525 * The parent of reference of type 'Foo' is the variable 'var'.
5526 * For references inside statement bodies of functions/methods,
5527 * the parentEntity will be the function/method.
5529 const CXIdxEntityInfo *parentEntity;
5531 * \brief Lexical container context of the reference.
5533 const CXIdxContainerInfo *container;
5534 } CXIdxEntityRefInfo;
5537 * \brief A group of callbacks used by #clang_indexSourceFile and
5538 * #clang_indexTranslationUnit.
5542 * \brief Called periodically to check whether indexing should be aborted.
5543 * Should return 0 to continue, and non-zero to abort.
5545 int (*abortQuery)(CXClientData client_data, void *reserved);
5548 * \brief Called at the end of indexing; passes the complete diagnostic set.
5550 void (*diagnostic)(CXClientData client_data,
5551 CXDiagnosticSet, void *reserved);
5553 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
5554 CXFile mainFile, void *reserved);
5557 * \brief Called when a file gets \#included/\#imported.
5559 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
5560 const CXIdxIncludedFileInfo *);
5563 * \brief Called when a AST file (PCH or module) gets imported.
5565 * AST files will not get indexed (there will not be callbacks to index all
5566 * the entities in an AST file). The recommended action is that, if the AST
5567 * file is not already indexed, to initiate a new indexing job specific to
5570 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
5571 const CXIdxImportedASTFileInfo *);
5574 * \brief Called at the beginning of indexing a translation unit.
5576 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
5579 void (*indexDeclaration)(CXClientData client_data,
5580 const CXIdxDeclInfo *);
5583 * \brief Called to index a reference of an entity.
5585 void (*indexEntityReference)(CXClientData client_data,
5586 const CXIdxEntityRefInfo *);
5590 CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
5591 CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
5592 clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
5594 CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
5595 clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
5598 const CXIdxObjCCategoryDeclInfo *
5599 clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
5601 CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
5602 clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
5604 CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
5605 clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
5607 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
5608 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
5610 CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
5611 clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
5614 * \brief For retrieving a custom CXIdxClientContainer attached to a
5617 CINDEX_LINKAGE CXIdxClientContainer
5618 clang_index_getClientContainer(const CXIdxContainerInfo *);
5621 * \brief For setting a custom CXIdxClientContainer attached to a
5625 clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
5628 * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
5630 CINDEX_LINKAGE CXIdxClientEntity
5631 clang_index_getClientEntity(const CXIdxEntityInfo *);
5634 * \brief For setting a custom CXIdxClientEntity attached to an entity.
5637 clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
5640 * \brief An indexing action/session, to be applied to one or multiple
5641 * translation units.
5643 typedef void *CXIndexAction;
5646 * \brief An indexing action/session, to be applied to one or multiple
5647 * translation units.
5649 * \param CIdx The index object with which the index action will be associated.
5651 CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
5654 * \brief Destroy the given index action.
5656 * The index action must not be destroyed until all of the translation units
5657 * created within that index action have been destroyed.
5659 CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
5663 * \brief Used to indicate that no special indexing options are needed.
5665 CXIndexOpt_None = 0x0,
5668 * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
5669 * be invoked for only one reference of an entity per source file that does
5670 * not also include a declaration/definition of the entity.
5672 CXIndexOpt_SuppressRedundantRefs = 0x1,
5675 * \brief Function-local symbols should be indexed. If this is not set
5676 * function-local symbols will be ignored.
5678 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
5681 * \brief Implicit function/class template instantiations should be indexed.
5682 * If this is not set, implicit instantiations will be ignored.
5684 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
5687 * \brief Suppress all compiler warnings when parsing for indexing.
5689 CXIndexOpt_SuppressWarnings = 0x8,
5692 * \brief Skip a function/method body that was already parsed during an
5693 * indexing session assosiated with a \c CXIndexAction object.
5694 * Bodies in system headers are always skipped.
5696 CXIndexOpt_SkipParsedBodiesInSession = 0x10
5701 * \brief Index the given source file and the translation unit corresponding
5702 * to that file via callbacks implemented through #IndexerCallbacks.
5704 * \param client_data pointer data supplied by the client, which will
5705 * be passed to the invoked callbacks.
5707 * \param index_callbacks Pointer to indexing callbacks that the client
5710 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
5711 * passed in index_callbacks.
5713 * \param index_options A bitmask of options that affects how indexing is
5714 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
5716 * \param out_TU [out] pointer to store a CXTranslationUnit that can be reused
5717 * after indexing is finished. Set to NULL if you do not require it.
5719 * \returns If there is a failure from which the there is no recovery, returns
5720 * non-zero, otherwise returns 0.
5722 * The rest of the parameters are the same as #clang_parseTranslationUnit.
5724 CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
5725 CXClientData client_data,
5726 IndexerCallbacks *index_callbacks,
5727 unsigned index_callbacks_size,
5728 unsigned index_options,
5729 const char *source_filename,
5730 const char * const *command_line_args,
5731 int num_command_line_args,
5732 struct CXUnsavedFile *unsaved_files,
5733 unsigned num_unsaved_files,
5734 CXTranslationUnit *out_TU,
5735 unsigned TU_options);
5738 * \brief Index the given translation unit via callbacks implemented through
5739 * #IndexerCallbacks.
5741 * The order of callback invocations is not guaranteed to be the same as
5742 * when indexing a source file. The high level order will be:
5744 * -Preprocessor callbacks invocations
5745 * -Declaration/reference callbacks invocations
5746 * -Diagnostic callback invocations
5748 * The parameters are the same as #clang_indexSourceFile.
5750 * \returns If there is a failure from which the there is no recovery, returns
5751 * non-zero, otherwise returns 0.
5753 CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
5754 CXClientData client_data,
5755 IndexerCallbacks *index_callbacks,
5756 unsigned index_callbacks_size,
5757 unsigned index_options,
5761 * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
5762 * the given CXIdxLoc.
5764 * If the location refers into a macro expansion, retrieves the
5765 * location of the macro expansion and if it refers into a macro argument
5766 * retrieves the location of the argument.
5768 CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
5769 CXIdxClientFile *indexFile,
5776 * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
5779 CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);