[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / include / clang-c / Index.h
blobb897910624de86d6a1f1f4ee5348b85ce3e62f49
1 /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2 |* *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4 |* Exceptions. *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* This header provides a public interface to a Clang library for extracting *|
11 |* high-level symbol information from source files without exposing the full *|
12 |* Clang C++ API. *|
13 |* *|
14 \*===----------------------------------------------------------------------===*/
16 #ifndef LLVM_CLANG_C_INDEX_H
17 #define LLVM_CLANG_C_INDEX_H
19 #include <time.h>
21 #include "clang-c/BuildSystem.h"
22 #include "clang-c/CXErrorCode.h"
23 #include "clang-c/CXString.h"
24 #include "clang-c/ExternC.h"
25 #include "clang-c/Platform.h"
27 /**
28 * The version constants for the libclang API.
29 * CINDEX_VERSION_MINOR should increase when there are API additions.
30 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
32 * The policy about the libclang API was always to keep it source and ABI
33 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
35 #define CINDEX_VERSION_MAJOR 0
36 #define CINDEX_VERSION_MINOR 62
38 #define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
40 #define CINDEX_VERSION \
41 CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
43 #define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
44 #define CINDEX_VERSION_STRINGIZE(major, minor) \
45 CINDEX_VERSION_STRINGIZE_(major, minor)
47 #define CINDEX_VERSION_STRING \
48 CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
50 LLVM_CLANG_C_EXTERN_C_BEGIN
52 /** \defgroup CINDEX libclang: C Interface to Clang
54 * The C Interface to Clang provides a relatively small API that exposes
55 * facilities for parsing source code into an abstract syntax tree (AST),
56 * loading already-parsed ASTs, traversing the AST, associating
57 * physical source locations with elements within the AST, and other
58 * facilities that support Clang-based development tools.
60 * This C interface to Clang will never provide all of the information
61 * representation stored in Clang's C++ AST, nor should it: the intent is to
62 * maintain an API that is relatively stable from one release to the next,
63 * providing only the basic functionality needed to support development tools.
65 * To avoid namespace pollution, data types are prefixed with "CX" and
66 * functions are prefixed with "clang_".
68 * @{
71 /**
72 * An "index" that consists of a set of translation units that would
73 * typically be linked together into an executable or library.
75 typedef void *CXIndex;
77 /**
78 * An opaque type representing target information for a given translation
79 * unit.
81 typedef struct CXTargetInfoImpl *CXTargetInfo;
83 /**
84 * A single translation unit, which resides in an index.
86 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
88 /**
89 * Opaque pointer representing client data that will be passed through
90 * to various callbacks and visitors.
92 typedef void *CXClientData;
94 /**
95 * 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 * The file whose contents have not yet been saved.
105 * This file must already exist in the file system.
107 const char *Filename;
110 * A buffer containing the unsaved contents of this file.
112 const char *Contents;
115 * The length of the unsaved contents of this buffer.
117 unsigned long Length;
121 * 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 * The entity is available.
129 CXAvailability_Available,
131 * The entity is available, but has been deprecated (and its use is
132 * not recommended).
134 CXAvailability_Deprecated,
136 * The entity is not available; any use of it will be an error.
138 CXAvailability_NotAvailable,
140 * The entity is available, but not accessible; any use of it will be
141 * an error.
143 CXAvailability_NotAccessible
147 * Describes a version number of the form major.minor.subminor.
149 typedef struct CXVersion {
151 * 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.
154 int Major;
156 * 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
158 * version '10'.
160 int Minor;
162 * 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'.
166 int Subminor;
167 } CXVersion;
170 * Describes the exception specification of a cursor.
172 * A negative value indicates that the cursor is not a function declaration.
174 enum CXCursor_ExceptionSpecificationKind {
176 * The cursor has no exception specification.
178 CXCursor_ExceptionSpecificationKind_None,
181 * The cursor has exception specification throw()
183 CXCursor_ExceptionSpecificationKind_DynamicNone,
186 * The cursor has exception specification throw(T1, T2)
188 CXCursor_ExceptionSpecificationKind_Dynamic,
191 * The cursor has exception specification throw(...).
193 CXCursor_ExceptionSpecificationKind_MSAny,
196 * The cursor has exception specification basic noexcept.
198 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
201 * The cursor has exception specification computed noexcept.
203 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
206 * The exception specification has not yet been evaluated.
208 CXCursor_ExceptionSpecificationKind_Unevaluated,
211 * The exception specification has not yet been instantiated.
213 CXCursor_ExceptionSpecificationKind_Uninstantiated,
216 * The exception specification has not been parsed yet.
218 CXCursor_ExceptionSpecificationKind_Unparsed,
221 * The cursor has a __declspec(nothrow) exception specification.
223 CXCursor_ExceptionSpecificationKind_NoThrow
227 * Provides a shared context for creating translation units.
229 * It provides two options:
231 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
232 * declarations (when loading any new translation units). A "local" declaration
233 * is one that belongs in the translation unit itself and not in a precompiled
234 * header that was used by the translation unit. If zero, all declarations
235 * will be enumerated.
237 * Here is an example:
239 * \code
240 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
241 * Idx = clang_createIndex(1, 1);
243 * // IndexTest.pch was produced with the following command:
244 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
245 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
247 * // This will load all the symbols from 'IndexTest.pch'
248 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
249 * TranslationUnitVisitor, 0);
250 * clang_disposeTranslationUnit(TU);
252 * // This will load all the symbols from 'IndexTest.c', excluding symbols
253 * // from 'IndexTest.pch'.
254 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
255 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
256 * 0, 0);
257 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
258 * TranslationUnitVisitor, 0);
259 * clang_disposeTranslationUnit(TU);
260 * \endcode
262 * This process of creating the 'pch', loading it separately, and using it (via
263 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
264 * (which gives the indexer the same performance benefit as the compiler).
266 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
267 int displayDiagnostics);
270 * Destroy the given index.
272 * The index must not be destroyed until all of the translation units created
273 * within that index have been destroyed.
275 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
277 typedef enum {
279 * Used to indicate that no special CXIndex options are needed.
281 CXGlobalOpt_None = 0x0,
284 * Used to indicate that threads that libclang creates for indexing
285 * purposes should use background priority.
287 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
288 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
290 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
293 * Used to indicate that threads that libclang creates for editing
294 * purposes should use background priority.
296 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
297 * #clang_annotateTokens
299 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
302 * Used to indicate that all threads that libclang creates should use
303 * background priority.
305 CXGlobalOpt_ThreadBackgroundPriorityForAll =
306 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
307 CXGlobalOpt_ThreadBackgroundPriorityForEditing
309 } CXGlobalOptFlags;
312 * Sets general options associated with a CXIndex.
314 * For example:
315 * \code
316 * CXIndex idx = ...;
317 * clang_CXIndex_setGlobalOptions(idx,
318 * clang_CXIndex_getGlobalOptions(idx) |
319 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
320 * \endcode
322 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
324 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
327 * Gets the general options associated with a CXIndex.
329 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
330 * are associated with the given CXIndex object.
332 CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
335 * Sets the invocation emission path option in a CXIndex.
337 * The invocation emission path specifies a path which will contain log
338 * files for certain libclang invocations. A null value (default) implies that
339 * libclang invocations are not logged..
341 CINDEX_LINKAGE void
342 clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
345 * \defgroup CINDEX_FILES File manipulation routines
347 * @{
351 * A particular source file that is part of a translation unit.
353 typedef void *CXFile;
356 * Retrieve the complete file and path name of the given file.
358 CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
361 * Retrieve the last modification time of the given file.
363 CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
366 * Uniquely identifies a CXFile, that refers to the same underlying file,
367 * across an indexing session.
369 typedef struct {
370 unsigned long long data[3];
371 } CXFileUniqueID;
374 * Retrieve the unique ID for the given \c file.
376 * \param file the file to get the ID for.
377 * \param outID stores the returned CXFileUniqueID.
378 * \returns If there was a failure getting the unique ID, returns non-zero,
379 * otherwise returns 0.
381 CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
384 * Determine whether the given header is guarded against
385 * multiple inclusions, either with the conventional
386 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
388 CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,
389 CXFile file);
392 * Retrieve a file handle within the given translation unit.
394 * \param tu the translation unit
396 * \param file_name the name of the file.
398 * \returns the file handle for the named file in the translation unit \p tu,
399 * or a NULL file handle if the file was not a part of this translation unit.
401 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
402 const char *file_name);
405 * Retrieve the buffer associated with the given file.
407 * \param tu the translation unit
409 * \param file the file for which to retrieve the buffer.
411 * \param size [out] if non-NULL, will be set to the size of the buffer.
413 * \returns a pointer to the buffer in memory that holds the contents of
414 * \p file, or a NULL pointer when the file is not loaded.
416 CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
417 CXFile file, size_t *size);
420 * Returns non-zero if the \c file1 and \c file2 point to the same file,
421 * or they are both NULL.
423 CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
426 * Returns the real path name of \c file.
428 * An empty string may be returned. Use \c clang_getFileName() in that case.
430 CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
433 * @}
437 * \defgroup CINDEX_LOCATIONS Physical source locations
439 * Clang represents physical source locations in its abstract syntax tree in
440 * great detail, with file, line, and column information for the majority of
441 * the tokens parsed in the source code. These data types and functions are
442 * used to represent source location information, either for a particular
443 * point in the program or for a range of points in the program, and extract
444 * specific location information from those data types.
446 * @{
450 * Identifies a specific source location within a translation
451 * unit.
453 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
454 * to map a source location to a particular file, line, and column.
456 typedef struct {
457 const void *ptr_data[2];
458 unsigned int_data;
459 } CXSourceLocation;
462 * Identifies a half-open character range in the source code.
464 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
465 * starting and end locations from a source range, respectively.
467 typedef struct {
468 const void *ptr_data[2];
469 unsigned begin_int_data;
470 unsigned end_int_data;
471 } CXSourceRange;
474 * Retrieve a NULL (invalid) source location.
476 CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
479 * Determine whether two source locations, which must refer into
480 * the same translation unit, refer to exactly the same point in the source
481 * code.
483 * \returns non-zero if the source locations refer to the same location, zero
484 * if they refer to different locations.
486 CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
487 CXSourceLocation loc2);
490 * Retrieves the source location associated with a given file/line/column
491 * in a particular translation unit.
493 CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
494 CXFile file, unsigned line,
495 unsigned column);
497 * Retrieves the source location associated with a given character offset
498 * in a particular translation unit.
500 CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
501 CXFile file,
502 unsigned offset);
505 * Returns non-zero if the given source location is in a system header.
507 CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
510 * Returns non-zero if the given source location is in the main file of
511 * the corresponding translation unit.
513 CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
516 * Retrieve a NULL (invalid) source range.
518 CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
521 * Retrieve a source range given the beginning and ending source
522 * locations.
524 CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
525 CXSourceLocation end);
528 * Determine whether two ranges are equivalent.
530 * \returns non-zero if the ranges are the same, zero if they differ.
532 CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
533 CXSourceRange range2);
536 * Returns non-zero if \p range is null.
538 CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
541 * Retrieve the file, line, column, and offset represented by
542 * the given source location.
544 * If the location refers into a macro expansion, retrieves the
545 * location of the macro expansion.
547 * \param location the location within a source file that will be decomposed
548 * into its parts.
550 * \param file [out] if non-NULL, will be set to the file to which the given
551 * source location points.
553 * \param line [out] if non-NULL, will be set to the line to which the given
554 * source location points.
556 * \param column [out] if non-NULL, will be set to the column to which the given
557 * source location points.
559 * \param offset [out] if non-NULL, will be set to the offset into the
560 * buffer to which the given source location points.
562 CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
563 CXFile *file, unsigned *line,
564 unsigned *column,
565 unsigned *offset);
568 * Retrieve the file, line and column represented by the given source
569 * location, as specified in a # line directive.
571 * Example: given the following source code in a file somefile.c
573 * \code
574 * #123 "dummy.c" 1
576 * static int func(void)
578 * return 0;
580 * \endcode
582 * the location information returned by this function would be
584 * File: dummy.c Line: 124 Column: 12
586 * whereas clang_getExpansionLocation would have returned
588 * File: somefile.c Line: 3 Column: 12
590 * \param location the location within a source file that will be decomposed
591 * into its parts.
593 * \param filename [out] if non-NULL, will be set to the filename of the
594 * source location. Note that filenames returned will be for "virtual" files,
595 * which don't necessarily exist on the machine running clang - e.g. when
596 * parsing preprocessed output obtained from a different environment. If
597 * a non-NULL value is passed in, remember to dispose of the returned value
598 * using \c clang_disposeString() once you've finished with it. For an invalid
599 * source location, an empty string is returned.
601 * \param line [out] if non-NULL, will be set to the line number of the
602 * source location. For an invalid source location, zero is returned.
604 * \param column [out] if non-NULL, will be set to the column number of the
605 * source location. For an invalid source location, zero is returned.
607 CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
608 CXString *filename,
609 unsigned *line, unsigned *column);
612 * Legacy API to retrieve the file, line, column, and offset represented
613 * by the given source location.
615 * This interface has been replaced by the newer interface
616 * #clang_getExpansionLocation(). See that interface's documentation for
617 * details.
619 CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
620 CXFile *file, unsigned *line,
621 unsigned *column,
622 unsigned *offset);
625 * Retrieve the file, line, column, and offset represented by
626 * the given source location.
628 * If the location refers into a macro instantiation, return where the
629 * location was originally spelled in the source file.
631 * \param location the location within a source file that will be decomposed
632 * into its parts.
634 * \param file [out] if non-NULL, will be set to the file to which the given
635 * source location points.
637 * \param line [out] if non-NULL, will be set to the line to which the given
638 * source location points.
640 * \param column [out] if non-NULL, will be set to the column to which the given
641 * source location points.
643 * \param offset [out] if non-NULL, will be set to the offset into the
644 * buffer to which the given source location points.
646 CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
647 CXFile *file, unsigned *line,
648 unsigned *column,
649 unsigned *offset);
652 * Retrieve the file, line, column, and offset represented by
653 * the given source location.
655 * If the location refers into a macro expansion, return where the macro was
656 * expanded or where the macro argument was written, if the location points at
657 * a macro argument.
659 * \param location the location within a source file that will be decomposed
660 * into its parts.
662 * \param file [out] if non-NULL, will be set to the file to which the given
663 * source location points.
665 * \param line [out] if non-NULL, will be set to the line to which the given
666 * source location points.
668 * \param column [out] if non-NULL, will be set to the column to which the given
669 * source location points.
671 * \param offset [out] if non-NULL, will be set to the offset into the
672 * buffer to which the given source location points.
674 CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
675 CXFile *file, unsigned *line,
676 unsigned *column, unsigned *offset);
679 * Retrieve a source location representing the first character within a
680 * source range.
682 CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
685 * Retrieve a source location representing the last character within a
686 * source range.
688 CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
691 * Identifies an array of ranges.
693 typedef struct {
694 /** The number of ranges in the \c ranges array. */
695 unsigned count;
697 * An array of \c CXSourceRanges.
699 CXSourceRange *ranges;
700 } CXSourceRangeList;
703 * Retrieve all ranges that were skipped by the preprocessor.
705 * The preprocessor will skip lines when they are surrounded by an
706 * if/ifdef/ifndef directive whose condition does not evaluate to true.
708 CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
709 CXFile file);
712 * Retrieve all ranges from all files that were skipped by the
713 * preprocessor.
715 * The preprocessor will skip lines when they are surrounded by an
716 * if/ifdef/ifndef directive whose condition does not evaluate to true.
718 CINDEX_LINKAGE CXSourceRangeList *
719 clang_getAllSkippedRanges(CXTranslationUnit tu);
722 * Destroy the given \c CXSourceRangeList.
724 CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
727 * @}
731 * \defgroup CINDEX_DIAG Diagnostic reporting
733 * @{
737 * Describes the severity of a particular diagnostic.
739 enum CXDiagnosticSeverity {
741 * A diagnostic that has been suppressed, e.g., by a command-line
742 * option.
744 CXDiagnostic_Ignored = 0,
747 * This diagnostic is a note that should be attached to the
748 * previous (non-note) diagnostic.
750 CXDiagnostic_Note = 1,
753 * This diagnostic indicates suspicious code that may not be
754 * wrong.
756 CXDiagnostic_Warning = 2,
759 * This diagnostic indicates that the code is ill-formed.
761 CXDiagnostic_Error = 3,
764 * This diagnostic indicates that the code is ill-formed such
765 * that future parser recovery is unlikely to produce useful
766 * results.
768 CXDiagnostic_Fatal = 4
772 * A single diagnostic, containing the diagnostic's severity,
773 * location, text, source ranges, and fix-it hints.
775 typedef void *CXDiagnostic;
778 * A group of CXDiagnostics.
780 typedef void *CXDiagnosticSet;
783 * Determine the number of diagnostics in a CXDiagnosticSet.
785 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
788 * Retrieve a diagnostic associated with the given CXDiagnosticSet.
790 * \param Diags the CXDiagnosticSet to query.
791 * \param Index the zero-based diagnostic number to retrieve.
793 * \returns the requested diagnostic. This diagnostic must be freed
794 * via a call to \c clang_disposeDiagnostic().
796 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
797 unsigned Index);
800 * Describes the kind of error that occurred (if any) in a call to
801 * \c clang_loadDiagnostics.
803 enum CXLoadDiag_Error {
805 * Indicates that no error occurred.
807 CXLoadDiag_None = 0,
810 * Indicates that an unknown error occurred while attempting to
811 * deserialize diagnostics.
813 CXLoadDiag_Unknown = 1,
816 * Indicates that the file containing the serialized diagnostics
817 * could not be opened.
819 CXLoadDiag_CannotLoad = 2,
822 * Indicates that the serialized diagnostics file is invalid or
823 * corrupt.
825 CXLoadDiag_InvalidFile = 3
829 * Deserialize a set of diagnostics from a Clang diagnostics bitcode
830 * file.
832 * \param file The name of the file to deserialize.
833 * \param error A pointer to a enum value recording if there was a problem
834 * deserializing the diagnostics.
835 * \param errorString A pointer to a CXString for recording the error string
836 * if the file was not successfully loaded.
838 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
839 * diagnostics should be released using clang_disposeDiagnosticSet().
841 CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(
842 const char *file, enum CXLoadDiag_Error *error, CXString *errorString);
845 * Release a CXDiagnosticSet and all of its contained diagnostics.
847 CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
850 * Retrieve the child diagnostics of a CXDiagnostic.
852 * This CXDiagnosticSet does not need to be released by
853 * clang_disposeDiagnosticSet.
855 CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
858 * Determine the number of diagnostics produced for the given
859 * translation unit.
861 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
864 * Retrieve a diagnostic associated with the given translation unit.
866 * \param Unit the translation unit to query.
867 * \param Index the zero-based diagnostic number to retrieve.
869 * \returns the requested diagnostic. This diagnostic must be freed
870 * via a call to \c clang_disposeDiagnostic().
872 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
873 unsigned Index);
876 * Retrieve the complete set of diagnostics associated with a
877 * translation unit.
879 * \param Unit the translation unit to query.
881 CINDEX_LINKAGE CXDiagnosticSet
882 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
885 * Destroy a diagnostic.
887 CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
890 * Options to control the display of diagnostics.
892 * The values in this enum are meant to be combined to customize the
893 * behavior of \c clang_formatDiagnostic().
895 enum CXDiagnosticDisplayOptions {
897 * Display the source-location information where the
898 * diagnostic was located.
900 * When set, diagnostics will be prefixed by the file, line, and
901 * (optionally) column to which the diagnostic refers. For example,
903 * \code
904 * test.c:28: warning: extra tokens at end of #endif directive
905 * \endcode
907 * This option corresponds to the clang flag \c -fshow-source-location.
909 CXDiagnostic_DisplaySourceLocation = 0x01,
912 * If displaying the source-location information of the
913 * diagnostic, also include the column number.
915 * This option corresponds to the clang flag \c -fshow-column.
917 CXDiagnostic_DisplayColumn = 0x02,
920 * If displaying the source-location information of the
921 * diagnostic, also include information about source ranges in a
922 * machine-parsable format.
924 * This option corresponds to the clang flag
925 * \c -fdiagnostics-print-source-range-info.
927 CXDiagnostic_DisplaySourceRanges = 0x04,
930 * Display the option name associated with this diagnostic, if any.
932 * The option name displayed (e.g., -Wconversion) will be placed in brackets
933 * after the diagnostic text. This option corresponds to the clang flag
934 * \c -fdiagnostics-show-option.
936 CXDiagnostic_DisplayOption = 0x08,
939 * Display the category number associated with this diagnostic, if any.
941 * The category number is displayed within brackets after the diagnostic text.
942 * This option corresponds to the clang flag
943 * \c -fdiagnostics-show-category=id.
945 CXDiagnostic_DisplayCategoryId = 0x10,
948 * Display the category name associated with this diagnostic, if any.
950 * The category name is displayed within brackets after the diagnostic text.
951 * This option corresponds to the clang flag
952 * \c -fdiagnostics-show-category=name.
954 CXDiagnostic_DisplayCategoryName = 0x20
958 * Format the given diagnostic in a manner that is suitable for display.
960 * This routine will format the given diagnostic to a string, rendering
961 * the diagnostic according to the various options given. The
962 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
963 * options that most closely mimics the behavior of the clang compiler.
965 * \param Diagnostic The diagnostic to print.
967 * \param Options A set of options that control the diagnostic display,
968 * created by combining \c CXDiagnosticDisplayOptions values.
970 * \returns A new string containing for formatted diagnostic.
972 CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
973 unsigned Options);
976 * Retrieve the set of display options most similar to the
977 * default behavior of the clang compiler.
979 * \returns A set of display options suitable for use with \c
980 * clang_formatDiagnostic().
982 CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
985 * Determine the severity of the given diagnostic.
987 CINDEX_LINKAGE enum CXDiagnosticSeverity
988 clang_getDiagnosticSeverity(CXDiagnostic);
991 * Retrieve the source location of the given diagnostic.
993 * This location is where Clang would print the caret ('^') when
994 * displaying the diagnostic on the command line.
996 CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
999 * Retrieve the text of the given diagnostic.
1001 CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
1004 * Retrieve the name of the command-line option that enabled this
1005 * diagnostic.
1007 * \param Diag The diagnostic to be queried.
1009 * \param Disable If non-NULL, will be set to the option that disables this
1010 * diagnostic (if any).
1012 * \returns A string that contains the command-line option used to enable this
1013 * warning, such as "-Wconversion" or "-pedantic".
1015 CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1016 CXString *Disable);
1019 * Retrieve the category number for this diagnostic.
1021 * Diagnostics can be categorized into groups along with other, related
1022 * diagnostics (e.g., diagnostics under the same warning flag). This routine
1023 * retrieves the category number for the given diagnostic.
1025 * \returns The number of the category that contains this diagnostic, or zero
1026 * if this diagnostic is uncategorized.
1028 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1031 * Retrieve the name of a particular diagnostic category. This
1032 * is now deprecated. Use clang_getDiagnosticCategoryText()
1033 * instead.
1035 * \param Category A diagnostic category number, as returned by
1036 * \c clang_getDiagnosticCategory().
1038 * \returns The name of the given diagnostic category.
1040 CINDEX_DEPRECATED CINDEX_LINKAGE CXString
1041 clang_getDiagnosticCategoryName(unsigned Category);
1044 * Retrieve the diagnostic category text for a given diagnostic.
1046 * \returns The text of the given diagnostic category.
1048 CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
1051 * Determine the number of source ranges associated with the given
1052 * diagnostic.
1054 CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
1057 * Retrieve a source range associated with the diagnostic.
1059 * A diagnostic's source ranges highlight important elements in the source
1060 * code. On the command line, Clang displays source ranges by
1061 * underlining them with '~' characters.
1063 * \param Diagnostic the diagnostic whose range is being extracted.
1065 * \param Range the zero-based index specifying which range to
1067 * \returns the requested source range.
1069 CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
1070 unsigned Range);
1073 * Determine the number of fix-it hints associated with the
1074 * given diagnostic.
1076 CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1079 * Retrieve the replacement information for a given fix-it.
1081 * Fix-its are described in terms of a source range whose contents
1082 * should be replaced by a string. This approach generalizes over
1083 * three kinds of operations: removal of source code (the range covers
1084 * the code to be removed and the replacement string is empty),
1085 * replacement of source code (the range covers the code to be
1086 * replaced and the replacement string provides the new code), and
1087 * insertion (both the start and end of the range point at the
1088 * insertion location, and the replacement string provides the text to
1089 * insert).
1091 * \param Diagnostic The diagnostic whose fix-its are being queried.
1093 * \param FixIt The zero-based index of the fix-it.
1095 * \param ReplacementRange The source range whose contents will be
1096 * replaced with the returned replacement string. Note that source
1097 * ranges are half-open ranges [a, b), so the source code should be
1098 * replaced from a and up to (but not including) b.
1100 * \returns A string containing text that should be replace the source
1101 * code indicated by the \c ReplacementRange.
1103 CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(
1104 CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange *ReplacementRange);
1107 * @}
1111 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1113 * The routines in this group provide the ability to create and destroy
1114 * translation units from files, either by parsing the contents of the files or
1115 * by reading in a serialized representation of a translation unit.
1117 * @{
1121 * Get the original translation unit source file name.
1123 CINDEX_LINKAGE CXString
1124 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1127 * Return the CXTranslationUnit for a given source file and the provided
1128 * command line arguments one would pass to the compiler.
1130 * Note: The 'source_filename' argument is optional. If the caller provides a
1131 * NULL pointer, the name of the source file is expected to reside in the
1132 * specified command line arguments.
1134 * Note: When encountered in 'clang_command_line_args', the following options
1135 * are ignored:
1137 * '-c'
1138 * '-emit-ast'
1139 * '-fsyntax-only'
1140 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
1142 * \param CIdx The index object with which the translation unit will be
1143 * associated.
1145 * \param source_filename The name of the source file to load, or NULL if the
1146 * source file is included in \p clang_command_line_args.
1148 * \param num_clang_command_line_args The number of command-line arguments in
1149 * \p clang_command_line_args.
1151 * \param clang_command_line_args The command-line arguments that would be
1152 * passed to the \c clang executable if it were being invoked out-of-process.
1153 * These command-line options will be parsed and will affect how the translation
1154 * unit is parsed. Note that the following options are ignored: '-c',
1155 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1157 * \param num_unsaved_files the number of unsaved file entries in \p
1158 * unsaved_files.
1160 * \param unsaved_files the files that have not yet been saved to disk
1161 * but may be required for code completion, including the contents of
1162 * those files. The contents and name of these files (as specified by
1163 * CXUnsavedFile) are copied when necessary, so the client only needs to
1164 * guarantee their validity until the call to this function returns.
1166 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1167 CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
1168 const char *const *clang_command_line_args, unsigned num_unsaved_files,
1169 struct CXUnsavedFile *unsaved_files);
1172 * Same as \c clang_createTranslationUnit2, but returns
1173 * the \c CXTranslationUnit instead of an error code. In case of an error this
1174 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1175 * error codes.
1177 CINDEX_LINKAGE CXTranslationUnit
1178 clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
1181 * Create a translation unit from an AST file (\c -emit-ast).
1183 * \param[out] out_TU A non-NULL pointer to store the created
1184 * \c CXTranslationUnit.
1186 * \returns Zero on success, otherwise returns an error code.
1188 CINDEX_LINKAGE enum CXErrorCode
1189 clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
1190 CXTranslationUnit *out_TU);
1193 * Flags that control the creation of translation units.
1195 * The enumerators in this enumeration type are meant to be bitwise
1196 * ORed together to specify which options should be used when
1197 * constructing the translation unit.
1199 enum CXTranslationUnit_Flags {
1201 * Used to indicate that no special translation-unit options are
1202 * needed.
1204 CXTranslationUnit_None = 0x0,
1207 * Used to indicate that the parser should construct a "detailed"
1208 * preprocessing record, including all macro definitions and instantiations.
1210 * Constructing a detailed preprocessing record requires more memory
1211 * and time to parse, since the information contained in the record
1212 * is usually not retained. However, it can be useful for
1213 * applications that require more detailed information about the
1214 * behavior of the preprocessor.
1216 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1219 * Used to indicate that the translation unit is incomplete.
1221 * When a translation unit is considered "incomplete", semantic
1222 * analysis that is typically performed at the end of the
1223 * translation unit will be suppressed. For example, this suppresses
1224 * the completion of tentative declarations in C and of
1225 * instantiation of implicitly-instantiation function templates in
1226 * C++. This option is typically used when parsing a header with the
1227 * intent of producing a precompiled header.
1229 CXTranslationUnit_Incomplete = 0x02,
1232 * Used to indicate that the translation unit should be built with an
1233 * implicit precompiled header for the preamble.
1235 * An implicit precompiled header is used as an optimization when a
1236 * particular translation unit is likely to be reparsed many times
1237 * when the sources aren't changing that often. In this case, an
1238 * implicit precompiled header will be built containing all of the
1239 * initial includes at the top of the main file (what we refer to as
1240 * the "preamble" of the file). In subsequent parses, if the
1241 * preamble or the files in it have not changed, \c
1242 * clang_reparseTranslationUnit() will re-use the implicit
1243 * precompiled header to improve parsing performance.
1245 CXTranslationUnit_PrecompiledPreamble = 0x04,
1248 * Used to indicate that the translation unit should cache some
1249 * code-completion results with each reparse of the source file.
1251 * Caching of code-completion results is a performance optimization that
1252 * introduces some overhead to reparsing but improves the performance of
1253 * code-completion operations.
1255 CXTranslationUnit_CacheCompletionResults = 0x08,
1258 * Used to indicate that the translation unit will be serialized with
1259 * \c clang_saveTranslationUnit.
1261 * This option is typically used when parsing a header with the intent of
1262 * producing a precompiled header.
1264 CXTranslationUnit_ForSerialization = 0x10,
1267 * DEPRECATED: Enabled chained precompiled preambles in C++.
1269 * Note: this is a *temporary* option that is available only while
1270 * we are testing C++ precompiled preamble support. It is deprecated.
1272 CXTranslationUnit_CXXChainedPCH = 0x20,
1275 * Used to indicate that function/method bodies should be skipped while
1276 * parsing.
1278 * This option can be used to search for declarations/definitions while
1279 * ignoring the usages.
1281 CXTranslationUnit_SkipFunctionBodies = 0x40,
1284 * Used to indicate that brief documentation comments should be
1285 * included into the set of code completions returned from this translation
1286 * unit.
1288 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1291 * Used to indicate that the precompiled preamble should be created on
1292 * the first parse. Otherwise it will be created on the first reparse. This
1293 * trades runtime on the first parse (serializing the preamble takes time) for
1294 * reduced runtime on the second parse (can now reuse the preamble).
1296 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1299 * Do not stop processing when fatal errors are encountered.
1301 * When fatal errors are encountered while parsing a translation unit,
1302 * semantic analysis is typically stopped early when compiling code. A common
1303 * source for fatal errors are unresolvable include files. For the
1304 * purposes of an IDE, this is undesirable behavior and as much information
1305 * as possible should be reported. Use this flag to enable this behavior.
1307 CXTranslationUnit_KeepGoing = 0x200,
1310 * Sets the preprocessor in a mode for parsing a single file only.
1312 CXTranslationUnit_SingleFileParse = 0x400,
1315 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
1316 * constrain the skipping of function bodies to the preamble.
1318 * The function bodies of the main file are not skipped.
1320 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
1323 * Used to indicate that attributed types should be included in CXType.
1325 CXTranslationUnit_IncludeAttributedTypes = 0x1000,
1328 * Used to indicate that implicit attributes should be visited.
1330 CXTranslationUnit_VisitImplicitAttributes = 0x2000,
1333 * Used to indicate that non-errors from included files should be ignored.
1335 * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
1336 * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
1337 * the case where these warnings are not of interest, as for an IDE for
1338 * example, which typically shows only the diagnostics in the main file.
1340 CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
1343 * Tells the preprocessor not to skip excluded conditional blocks.
1345 CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
1349 * Returns the set of flags that is suitable for parsing a translation
1350 * unit that is being edited.
1352 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1353 * to indicate that the translation unit is likely to be reparsed many times,
1354 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1355 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1356 * set contains an unspecified set of optimizations (e.g., the precompiled
1357 * preamble) geared toward improving the performance of these routines. The
1358 * set of optimizations enabled may change from one version to the next.
1360 CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1363 * Same as \c clang_parseTranslationUnit2, but returns
1364 * the \c CXTranslationUnit instead of an error code. In case of an error this
1365 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1366 * error codes.
1368 CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(
1369 CXIndex CIdx, const char *source_filename,
1370 const char *const *command_line_args, int num_command_line_args,
1371 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1372 unsigned options);
1375 * Parse the given source file and the translation unit corresponding
1376 * to that file.
1378 * This routine is the main entry point for the Clang C API, providing the
1379 * ability to parse a source file into a translation unit that can then be
1380 * queried by other functions in the API. This routine accepts a set of
1381 * command-line arguments so that the compilation can be configured in the same
1382 * way that the compiler is configured on the command line.
1384 * \param CIdx The index object with which the translation unit will be
1385 * associated.
1387 * \param source_filename The name of the source file to load, or NULL if the
1388 * source file is included in \c command_line_args.
1390 * \param command_line_args The command-line arguments that would be
1391 * passed to the \c clang executable if it were being invoked out-of-process.
1392 * These command-line options will be parsed and will affect how the translation
1393 * unit is parsed. Note that the following options are ignored: '-c',
1394 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1396 * \param num_command_line_args The number of command-line arguments in
1397 * \c command_line_args.
1399 * \param unsaved_files the files that have not yet been saved to disk
1400 * but may be required for parsing, including the contents of
1401 * those files. The contents and name of these files (as specified by
1402 * CXUnsavedFile) are copied when necessary, so the client only needs to
1403 * guarantee their validity until the call to this function returns.
1405 * \param num_unsaved_files the number of unsaved file entries in \p
1406 * unsaved_files.
1408 * \param options A bitmask of options that affects how the translation unit
1409 * is managed but not its compilation. This should be a bitwise OR of the
1410 * CXTranslationUnit_XXX flags.
1412 * \param[out] out_TU A non-NULL pointer to store the created
1413 * \c CXTranslationUnit, describing the parsed code and containing any
1414 * diagnostics produced by the compiler.
1416 * \returns Zero on success, otherwise returns an error code.
1418 CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2(
1419 CXIndex CIdx, const char *source_filename,
1420 const char *const *command_line_args, int num_command_line_args,
1421 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1422 unsigned options, CXTranslationUnit *out_TU);
1425 * Same as clang_parseTranslationUnit2 but requires a full command line
1426 * for \c command_line_args including argv[0]. This is useful if the standard
1427 * library paths are relative to the binary.
1429 CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1430 CXIndex CIdx, const char *source_filename,
1431 const char *const *command_line_args, int num_command_line_args,
1432 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1433 unsigned options, CXTranslationUnit *out_TU);
1436 * Flags that control how translation units are saved.
1438 * The enumerators in this enumeration type are meant to be bitwise
1439 * ORed together to specify which options should be used when
1440 * saving the translation unit.
1442 enum CXSaveTranslationUnit_Flags {
1444 * Used to indicate that no special saving options are needed.
1446 CXSaveTranslationUnit_None = 0x0
1450 * Returns the set of flags that is suitable for saving a translation
1451 * unit.
1453 * The set of flags returned provide options for
1454 * \c clang_saveTranslationUnit() by default. The returned flag
1455 * set contains an unspecified set of options that save translation units with
1456 * the most commonly-requested data.
1458 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1461 * Describes the kind of error that occurred (if any) in a call to
1462 * \c clang_saveTranslationUnit().
1464 enum CXSaveError {
1466 * Indicates that no error occurred while saving a translation unit.
1468 CXSaveError_None = 0,
1471 * Indicates that an unknown error occurred while attempting to save
1472 * the file.
1474 * This error typically indicates that file I/O failed when attempting to
1475 * write the file.
1477 CXSaveError_Unknown = 1,
1480 * Indicates that errors during translation prevented this attempt
1481 * to save the translation unit.
1483 * Errors that prevent the translation unit from being saved can be
1484 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1486 CXSaveError_TranslationErrors = 2,
1489 * Indicates that the translation unit to be saved was somehow
1490 * invalid (e.g., NULL).
1492 CXSaveError_InvalidTU = 3
1496 * Saves a translation unit into a serialized representation of
1497 * that translation unit on disk.
1499 * Any translation unit that was parsed without error can be saved
1500 * into a file. The translation unit can then be deserialized into a
1501 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1502 * if it is an incomplete translation unit that corresponds to a
1503 * header, used as a precompiled header when parsing other translation
1504 * units.
1506 * \param TU The translation unit to save.
1508 * \param FileName The file to which the translation unit will be saved.
1510 * \param options A bitmask of options that affects how the translation unit
1511 * is saved. This should be a bitwise OR of the
1512 * CXSaveTranslationUnit_XXX flags.
1514 * \returns A value that will match one of the enumerators of the CXSaveError
1515 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1516 * saved successfully, while a non-zero value indicates that a problem occurred.
1518 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1519 const char *FileName,
1520 unsigned options);
1523 * Suspend a translation unit in order to free memory associated with it.
1525 * A suspended translation unit uses significantly less memory but on the other
1526 * side does not support any other calls than \c clang_reparseTranslationUnit
1527 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1529 CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1532 * Destroy the specified CXTranslationUnit object.
1534 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1537 * Flags that control the reparsing of translation units.
1539 * The enumerators in this enumeration type are meant to be bitwise
1540 * ORed together to specify which options should be used when
1541 * reparsing the translation unit.
1543 enum CXReparse_Flags {
1545 * Used to indicate that no special reparsing options are needed.
1547 CXReparse_None = 0x0
1551 * Returns the set of flags that is suitable for reparsing a translation
1552 * unit.
1554 * The set of flags returned provide options for
1555 * \c clang_reparseTranslationUnit() by default. The returned flag
1556 * set contains an unspecified set of optimizations geared toward common uses
1557 * of reparsing. The set of optimizations enabled may change from one version
1558 * to the next.
1560 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1563 * Reparse the source files that produced this translation unit.
1565 * This routine can be used to re-parse the source files that originally
1566 * created the given translation unit, for example because those source files
1567 * have changed (either on disk or as passed via \p unsaved_files). The
1568 * source code will be reparsed with the same command-line options as it
1569 * was originally parsed.
1571 * Reparsing a translation unit invalidates all cursors and source locations
1572 * that refer into that translation unit. This makes reparsing a translation
1573 * unit semantically equivalent to destroying the translation unit and then
1574 * creating a new translation unit with the same command-line arguments.
1575 * However, it may be more efficient to reparse a translation
1576 * unit using this routine.
1578 * \param TU The translation unit whose contents will be re-parsed. The
1579 * translation unit must originally have been built with
1580 * \c clang_createTranslationUnitFromSourceFile().
1582 * \param num_unsaved_files The number of unsaved file entries in \p
1583 * unsaved_files.
1585 * \param unsaved_files The files that have not yet been saved to disk
1586 * but may be required for parsing, including the contents of
1587 * those files. The contents and name of these files (as specified by
1588 * CXUnsavedFile) are copied when necessary, so the client only needs to
1589 * guarantee their validity until the call to this function returns.
1591 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1592 * The function \c clang_defaultReparseOptions() produces a default set of
1593 * options recommended for most uses, based on the translation unit.
1595 * \returns 0 if the sources could be reparsed. A non-zero error code will be
1596 * returned if reparsing was impossible, such that the translation unit is
1597 * invalid. In such cases, the only valid call for \c TU is
1598 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1599 * routine are described by the \c CXErrorCode enum.
1601 CINDEX_LINKAGE int
1602 clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
1603 struct CXUnsavedFile *unsaved_files,
1604 unsigned options);
1607 * Categorizes how memory is being used by a translation unit.
1609 enum CXTUResourceUsageKind {
1610 CXTUResourceUsage_AST = 1,
1611 CXTUResourceUsage_Identifiers = 2,
1612 CXTUResourceUsage_Selectors = 3,
1613 CXTUResourceUsage_GlobalCompletionResults = 4,
1614 CXTUResourceUsage_SourceManagerContentCache = 5,
1615 CXTUResourceUsage_AST_SideTables = 6,
1616 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1617 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1618 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1619 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1620 CXTUResourceUsage_Preprocessor = 11,
1621 CXTUResourceUsage_PreprocessingRecord = 12,
1622 CXTUResourceUsage_SourceManager_DataStructures = 13,
1623 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1624 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1625 CXTUResourceUsage_MEMORY_IN_BYTES_END =
1626 CXTUResourceUsage_Preprocessor_HeaderSearch,
1628 CXTUResourceUsage_First = CXTUResourceUsage_AST,
1629 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1633 * Returns the human-readable null-terminated C string that represents
1634 * the name of the memory category. This string should never be freed.
1636 CINDEX_LINKAGE
1637 const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1639 typedef struct CXTUResourceUsageEntry {
1640 /* The memory usage category. */
1641 enum CXTUResourceUsageKind kind;
1642 /* Amount of resources used.
1643 The units will depend on the resource kind. */
1644 unsigned long amount;
1645 } CXTUResourceUsageEntry;
1648 * The memory usage of a CXTranslationUnit, broken into categories.
1650 typedef struct CXTUResourceUsage {
1651 /* Private data member, used for queries. */
1652 void *data;
1654 /* The number of entries in the 'entries' array. */
1655 unsigned numEntries;
1657 /* An array of key-value pairs, representing the breakdown of memory
1658 usage. */
1659 CXTUResourceUsageEntry *entries;
1661 } CXTUResourceUsage;
1664 * Return the memory usage of a translation unit. This object
1665 * should be released with clang_disposeCXTUResourceUsage().
1667 CINDEX_LINKAGE CXTUResourceUsage
1668 clang_getCXTUResourceUsage(CXTranslationUnit TU);
1670 CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1673 * Get target information for this translation unit.
1675 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1677 CINDEX_LINKAGE CXTargetInfo
1678 clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1681 * Destroy the CXTargetInfo object.
1683 CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);
1686 * Get the normalized target triple as a string.
1688 * Returns the empty string in case of any error.
1690 CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);
1693 * Get the pointer width of the target in bits.
1695 * Returns -1 in case of error.
1697 CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1700 * @}
1704 * Describes the kind of entity that a cursor refers to.
1706 enum CXCursorKind {
1707 /* Declarations */
1709 * A declaration whose specific kind is not exposed via this
1710 * interface.
1712 * Unexposed declarations have the same operations as any other kind
1713 * of declaration; one can extract their location information,
1714 * spelling, find their definitions, etc. However, the specific kind
1715 * of the declaration is not reported.
1717 CXCursor_UnexposedDecl = 1,
1718 /** A C or C++ struct. */
1719 CXCursor_StructDecl = 2,
1720 /** A C or C++ union. */
1721 CXCursor_UnionDecl = 3,
1722 /** A C++ class. */
1723 CXCursor_ClassDecl = 4,
1724 /** An enumeration. */
1725 CXCursor_EnumDecl = 5,
1727 * A field (in C) or non-static data member (in C++) in a
1728 * struct, union, or C++ class.
1730 CXCursor_FieldDecl = 6,
1731 /** An enumerator constant. */
1732 CXCursor_EnumConstantDecl = 7,
1733 /** A function. */
1734 CXCursor_FunctionDecl = 8,
1735 /** A variable. */
1736 CXCursor_VarDecl = 9,
1737 /** A function or method parameter. */
1738 CXCursor_ParmDecl = 10,
1739 /** An Objective-C \@interface. */
1740 CXCursor_ObjCInterfaceDecl = 11,
1741 /** An Objective-C \@interface for a category. */
1742 CXCursor_ObjCCategoryDecl = 12,
1743 /** An Objective-C \@protocol declaration. */
1744 CXCursor_ObjCProtocolDecl = 13,
1745 /** An Objective-C \@property declaration. */
1746 CXCursor_ObjCPropertyDecl = 14,
1747 /** An Objective-C instance variable. */
1748 CXCursor_ObjCIvarDecl = 15,
1749 /** An Objective-C instance method. */
1750 CXCursor_ObjCInstanceMethodDecl = 16,
1751 /** An Objective-C class method. */
1752 CXCursor_ObjCClassMethodDecl = 17,
1753 /** An Objective-C \@implementation. */
1754 CXCursor_ObjCImplementationDecl = 18,
1755 /** An Objective-C \@implementation for a category. */
1756 CXCursor_ObjCCategoryImplDecl = 19,
1757 /** A typedef. */
1758 CXCursor_TypedefDecl = 20,
1759 /** A C++ class method. */
1760 CXCursor_CXXMethod = 21,
1761 /** A C++ namespace. */
1762 CXCursor_Namespace = 22,
1763 /** A linkage specification, e.g. 'extern "C"'. */
1764 CXCursor_LinkageSpec = 23,
1765 /** A C++ constructor. */
1766 CXCursor_Constructor = 24,
1767 /** A C++ destructor. */
1768 CXCursor_Destructor = 25,
1769 /** A C++ conversion function. */
1770 CXCursor_ConversionFunction = 26,
1771 /** A C++ template type parameter. */
1772 CXCursor_TemplateTypeParameter = 27,
1773 /** A C++ non-type template parameter. */
1774 CXCursor_NonTypeTemplateParameter = 28,
1775 /** A C++ template template parameter. */
1776 CXCursor_TemplateTemplateParameter = 29,
1777 /** A C++ function template. */
1778 CXCursor_FunctionTemplate = 30,
1779 /** A C++ class template. */
1780 CXCursor_ClassTemplate = 31,
1781 /** A C++ class template partial specialization. */
1782 CXCursor_ClassTemplatePartialSpecialization = 32,
1783 /** A C++ namespace alias declaration. */
1784 CXCursor_NamespaceAlias = 33,
1785 /** A C++ using directive. */
1786 CXCursor_UsingDirective = 34,
1787 /** A C++ using declaration. */
1788 CXCursor_UsingDeclaration = 35,
1789 /** A C++ alias declaration */
1790 CXCursor_TypeAliasDecl = 36,
1791 /** An Objective-C \@synthesize definition. */
1792 CXCursor_ObjCSynthesizeDecl = 37,
1793 /** An Objective-C \@dynamic definition. */
1794 CXCursor_ObjCDynamicDecl = 38,
1795 /** An access specifier. */
1796 CXCursor_CXXAccessSpecifier = 39,
1798 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
1799 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
1801 /* References */
1802 CXCursor_FirstRef = 40, /* Decl references */
1803 CXCursor_ObjCSuperClassRef = 40,
1804 CXCursor_ObjCProtocolRef = 41,
1805 CXCursor_ObjCClassRef = 42,
1807 * A reference to a type declaration.
1809 * A type reference occurs anywhere where a type is named but not
1810 * declared. For example, given:
1812 * \code
1813 * typedef unsigned size_type;
1814 * size_type size;
1815 * \endcode
1817 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1818 * while the type of the variable "size" is referenced. The cursor
1819 * referenced by the type of size is the typedef for size_type.
1821 CXCursor_TypeRef = 43,
1822 CXCursor_CXXBaseSpecifier = 44,
1824 * A reference to a class template, function template, template
1825 * template parameter, or class template partial specialization.
1827 CXCursor_TemplateRef = 45,
1829 * A reference to a namespace or namespace alias.
1831 CXCursor_NamespaceRef = 46,
1833 * A reference to a member of a struct, union, or class that occurs in
1834 * some non-expression context, e.g., a designated initializer.
1836 CXCursor_MemberRef = 47,
1838 * A reference to a labeled statement.
1840 * This cursor kind is used to describe the jump to "start_over" in the
1841 * goto statement in the following example:
1843 * \code
1844 * start_over:
1845 * ++counter;
1847 * goto start_over;
1848 * \endcode
1850 * A label reference cursor refers to a label statement.
1852 CXCursor_LabelRef = 48,
1855 * A reference to a set of overloaded functions or function templates
1856 * that has not yet been resolved to a specific function or function template.
1858 * An overloaded declaration reference cursor occurs in C++ templates where
1859 * a dependent name refers to a function. For example:
1861 * \code
1862 * template<typename T> void swap(T&, T&);
1864 * struct X { ... };
1865 * void swap(X&, X&);
1867 * template<typename T>
1868 * void reverse(T* first, T* last) {
1869 * while (first < last - 1) {
1870 * swap(*first, *--last);
1871 * ++first;
1875 * struct Y { };
1876 * void swap(Y&, Y&);
1877 * \endcode
1879 * Here, the identifier "swap" is associated with an overloaded declaration
1880 * reference. In the template definition, "swap" refers to either of the two
1881 * "swap" functions declared above, so both results will be available. At
1882 * instantiation time, "swap" may also refer to other functions found via
1883 * argument-dependent lookup (e.g., the "swap" function at the end of the
1884 * example).
1886 * The functions \c clang_getNumOverloadedDecls() and
1887 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1888 * referenced by this cursor.
1890 CXCursor_OverloadedDeclRef = 49,
1893 * A reference to a variable that occurs in some non-expression
1894 * context, e.g., a C++ lambda capture list.
1896 CXCursor_VariableRef = 50,
1898 CXCursor_LastRef = CXCursor_VariableRef,
1900 /* Error conditions */
1901 CXCursor_FirstInvalid = 70,
1902 CXCursor_InvalidFile = 70,
1903 CXCursor_NoDeclFound = 71,
1904 CXCursor_NotImplemented = 72,
1905 CXCursor_InvalidCode = 73,
1906 CXCursor_LastInvalid = CXCursor_InvalidCode,
1908 /* Expressions */
1909 CXCursor_FirstExpr = 100,
1912 * An expression whose specific kind is not exposed via this
1913 * interface.
1915 * Unexposed expressions have the same operations as any other kind
1916 * of expression; one can extract their location information,
1917 * spelling, children, etc. However, the specific kind of the
1918 * expression is not reported.
1920 CXCursor_UnexposedExpr = 100,
1923 * An expression that refers to some value declaration, such
1924 * as a function, variable, or enumerator.
1926 CXCursor_DeclRefExpr = 101,
1929 * An expression that refers to a member of a struct, union,
1930 * class, Objective-C class, etc.
1932 CXCursor_MemberRefExpr = 102,
1934 /** An expression that calls a function. */
1935 CXCursor_CallExpr = 103,
1937 /** An expression that sends a message to an Objective-C
1938 object or class. */
1939 CXCursor_ObjCMessageExpr = 104,
1941 /** An expression that represents a block literal. */
1942 CXCursor_BlockExpr = 105,
1944 /** An integer literal.
1946 CXCursor_IntegerLiteral = 106,
1948 /** A floating point number literal.
1950 CXCursor_FloatingLiteral = 107,
1952 /** An imaginary number literal.
1954 CXCursor_ImaginaryLiteral = 108,
1956 /** A string literal.
1958 CXCursor_StringLiteral = 109,
1960 /** A character literal.
1962 CXCursor_CharacterLiteral = 110,
1964 /** A parenthesized expression, e.g. "(1)".
1966 * This AST node is only formed if full location information is requested.
1968 CXCursor_ParenExpr = 111,
1970 /** This represents the unary-expression's (except sizeof and
1971 * alignof).
1973 CXCursor_UnaryOperator = 112,
1975 /** [C99 6.5.2.1] Array Subscripting.
1977 CXCursor_ArraySubscriptExpr = 113,
1979 /** A builtin binary operation expression such as "x + y" or
1980 * "x <= y".
1982 CXCursor_BinaryOperator = 114,
1984 /** Compound assignment such as "+=".
1986 CXCursor_CompoundAssignOperator = 115,
1988 /** The ?: ternary operator.
1990 CXCursor_ConditionalOperator = 116,
1992 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1993 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1995 * For example: (int)f.
1997 CXCursor_CStyleCastExpr = 117,
1999 /** [C99 6.5.2.5]
2001 CXCursor_CompoundLiteralExpr = 118,
2003 /** Describes an C or C++ initializer list.
2005 CXCursor_InitListExpr = 119,
2007 /** The GNU address of label extension, representing &&label.
2009 CXCursor_AddrLabelExpr = 120,
2011 /** This is the GNU Statement Expression extension: ({int X=4; X;})
2013 CXCursor_StmtExpr = 121,
2015 /** Represents a C11 generic selection.
2017 CXCursor_GenericSelectionExpr = 122,
2019 /** Implements the GNU __null extension, which is a name for a null
2020 * pointer constant that has integral type (e.g., int or long) and is the same
2021 * size and alignment as a pointer.
2023 * The __null extension is typically only used by system headers, which define
2024 * NULL as __null in C++ rather than using 0 (which is an integer that may not
2025 * match the size of a pointer).
2027 CXCursor_GNUNullExpr = 123,
2029 /** C++'s static_cast<> expression.
2031 CXCursor_CXXStaticCastExpr = 124,
2033 /** C++'s dynamic_cast<> expression.
2035 CXCursor_CXXDynamicCastExpr = 125,
2037 /** C++'s reinterpret_cast<> expression.
2039 CXCursor_CXXReinterpretCastExpr = 126,
2041 /** C++'s const_cast<> expression.
2043 CXCursor_CXXConstCastExpr = 127,
2045 /** Represents an explicit C++ type conversion that uses "functional"
2046 * notion (C++ [expr.type.conv]).
2048 * Example:
2049 * \code
2050 * x = int(0.5);
2051 * \endcode
2053 CXCursor_CXXFunctionalCastExpr = 128,
2055 /** A C++ typeid expression (C++ [expr.typeid]).
2057 CXCursor_CXXTypeidExpr = 129,
2059 /** [C++ 2.13.5] C++ Boolean Literal.
2061 CXCursor_CXXBoolLiteralExpr = 130,
2063 /** [C++0x 2.14.7] C++ Pointer Literal.
2065 CXCursor_CXXNullPtrLiteralExpr = 131,
2067 /** Represents the "this" expression in C++
2069 CXCursor_CXXThisExpr = 132,
2071 /** [C++ 15] C++ Throw Expression.
2073 * This handles 'throw' and 'throw' assignment-expression. When
2074 * assignment-expression isn't present, Op will be null.
2076 CXCursor_CXXThrowExpr = 133,
2078 /** A new expression for memory allocation and constructor calls, e.g:
2079 * "new CXXNewExpr(foo)".
2081 CXCursor_CXXNewExpr = 134,
2083 /** A delete expression for memory deallocation and destructor calls,
2084 * e.g. "delete[] pArray".
2086 CXCursor_CXXDeleteExpr = 135,
2088 /** A unary expression. (noexcept, sizeof, or other traits)
2090 CXCursor_UnaryExpr = 136,
2092 /** An Objective-C string literal i.e. @"foo".
2094 CXCursor_ObjCStringLiteral = 137,
2096 /** An Objective-C \@encode expression.
2098 CXCursor_ObjCEncodeExpr = 138,
2100 /** An Objective-C \@selector expression.
2102 CXCursor_ObjCSelectorExpr = 139,
2104 /** An Objective-C \@protocol expression.
2106 CXCursor_ObjCProtocolExpr = 140,
2108 /** An Objective-C "bridged" cast expression, which casts between
2109 * Objective-C pointers and C pointers, transferring ownership in the process.
2111 * \code
2112 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2113 * \endcode
2115 CXCursor_ObjCBridgedCastExpr = 141,
2117 /** Represents a C++0x pack expansion that produces a sequence of
2118 * expressions.
2120 * A pack expansion expression contains a pattern (which itself is an
2121 * expression) followed by an ellipsis. For example:
2123 * \code
2124 * template<typename F, typename ...Types>
2125 * void forward(F f, Types &&...args) {
2126 * f(static_cast<Types&&>(args)...);
2128 * \endcode
2130 CXCursor_PackExpansionExpr = 142,
2132 /** Represents an expression that computes the length of a parameter
2133 * pack.
2135 * \code
2136 * template<typename ...Types>
2137 * struct count {
2138 * static const unsigned value = sizeof...(Types);
2139 * };
2140 * \endcode
2142 CXCursor_SizeOfPackExpr = 143,
2144 /* Represents a C++ lambda expression that produces a local function
2145 * object.
2147 * \code
2148 * void abssort(float *x, unsigned N) {
2149 * std::sort(x, x + N,
2150 * [](float a, float b) {
2151 * return std::abs(a) < std::abs(b);
2152 * });
2154 * \endcode
2156 CXCursor_LambdaExpr = 144,
2158 /** Objective-c Boolean Literal.
2160 CXCursor_ObjCBoolLiteralExpr = 145,
2162 /** Represents the "self" expression in an Objective-C method.
2164 CXCursor_ObjCSelfExpr = 146,
2166 /** OpenMP 5.0 [2.1.5, Array Section].
2168 CXCursor_OMPArraySectionExpr = 147,
2170 /** Represents an @available(...) check.
2172 CXCursor_ObjCAvailabilityCheckExpr = 148,
2175 * Fixed point literal
2177 CXCursor_FixedPointLiteral = 149,
2179 /** OpenMP 5.0 [2.1.4, Array Shaping].
2181 CXCursor_OMPArrayShapingExpr = 150,
2184 * OpenMP 5.0 [2.1.6 Iterators]
2186 CXCursor_OMPIteratorExpr = 151,
2188 /** OpenCL's addrspace_cast<> expression.
2190 CXCursor_CXXAddrspaceCastExpr = 152,
2193 * Expression that references a C++20 concept.
2195 CXCursor_ConceptSpecializationExpr = 153,
2198 * Expression that references a C++20 concept.
2200 CXCursor_RequiresExpr = 154,
2202 CXCursor_LastExpr = CXCursor_RequiresExpr,
2204 /* Statements */
2205 CXCursor_FirstStmt = 200,
2207 * A statement whose specific kind is not exposed via this
2208 * interface.
2210 * Unexposed statements have the same operations as any other kind of
2211 * statement; one can extract their location information, spelling,
2212 * children, etc. However, the specific kind of the statement is not
2213 * reported.
2215 CXCursor_UnexposedStmt = 200,
2217 /** A labelled statement in a function.
2219 * This cursor kind is used to describe the "start_over:" label statement in
2220 * the following example:
2222 * \code
2223 * start_over:
2224 * ++counter;
2225 * \endcode
2228 CXCursor_LabelStmt = 201,
2230 /** A group of statements like { stmt stmt }.
2232 * This cursor kind is used to describe compound statements, e.g. function
2233 * bodies.
2235 CXCursor_CompoundStmt = 202,
2237 /** A case statement.
2239 CXCursor_CaseStmt = 203,
2241 /** A default statement.
2243 CXCursor_DefaultStmt = 204,
2245 /** An if statement
2247 CXCursor_IfStmt = 205,
2249 /** A switch statement.
2251 CXCursor_SwitchStmt = 206,
2253 /** A while statement.
2255 CXCursor_WhileStmt = 207,
2257 /** A do statement.
2259 CXCursor_DoStmt = 208,
2261 /** A for statement.
2263 CXCursor_ForStmt = 209,
2265 /** A goto statement.
2267 CXCursor_GotoStmt = 210,
2269 /** An indirect goto statement.
2271 CXCursor_IndirectGotoStmt = 211,
2273 /** A continue statement.
2275 CXCursor_ContinueStmt = 212,
2277 /** A break statement.
2279 CXCursor_BreakStmt = 213,
2281 /** A return statement.
2283 CXCursor_ReturnStmt = 214,
2285 /** A GCC inline assembly statement extension.
2287 CXCursor_GCCAsmStmt = 215,
2288 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
2290 /** Objective-C's overall \@try-\@catch-\@finally statement.
2292 CXCursor_ObjCAtTryStmt = 216,
2294 /** Objective-C's \@catch statement.
2296 CXCursor_ObjCAtCatchStmt = 217,
2298 /** Objective-C's \@finally statement.
2300 CXCursor_ObjCAtFinallyStmt = 218,
2302 /** Objective-C's \@throw statement.
2304 CXCursor_ObjCAtThrowStmt = 219,
2306 /** Objective-C's \@synchronized statement.
2308 CXCursor_ObjCAtSynchronizedStmt = 220,
2310 /** Objective-C's autorelease pool statement.
2312 CXCursor_ObjCAutoreleasePoolStmt = 221,
2314 /** Objective-C's collection statement.
2316 CXCursor_ObjCForCollectionStmt = 222,
2318 /** C++'s catch statement.
2320 CXCursor_CXXCatchStmt = 223,
2322 /** C++'s try statement.
2324 CXCursor_CXXTryStmt = 224,
2326 /** C++'s for (* : *) statement.
2328 CXCursor_CXXForRangeStmt = 225,
2330 /** Windows Structured Exception Handling's try statement.
2332 CXCursor_SEHTryStmt = 226,
2334 /** Windows Structured Exception Handling's except statement.
2336 CXCursor_SEHExceptStmt = 227,
2338 /** Windows Structured Exception Handling's finally statement.
2340 CXCursor_SEHFinallyStmt = 228,
2342 /** A MS inline assembly statement extension.
2344 CXCursor_MSAsmStmt = 229,
2346 /** The null statement ";": C99 6.8.3p3.
2348 * This cursor kind is used to describe the null statement.
2350 CXCursor_NullStmt = 230,
2352 /** Adaptor class for mixing declarations with statements and
2353 * expressions.
2355 CXCursor_DeclStmt = 231,
2357 /** OpenMP parallel directive.
2359 CXCursor_OMPParallelDirective = 232,
2361 /** OpenMP SIMD directive.
2363 CXCursor_OMPSimdDirective = 233,
2365 /** OpenMP for directive.
2367 CXCursor_OMPForDirective = 234,
2369 /** OpenMP sections directive.
2371 CXCursor_OMPSectionsDirective = 235,
2373 /** OpenMP section directive.
2375 CXCursor_OMPSectionDirective = 236,
2377 /** OpenMP single directive.
2379 CXCursor_OMPSingleDirective = 237,
2381 /** OpenMP parallel for directive.
2383 CXCursor_OMPParallelForDirective = 238,
2385 /** OpenMP parallel sections directive.
2387 CXCursor_OMPParallelSectionsDirective = 239,
2389 /** OpenMP task directive.
2391 CXCursor_OMPTaskDirective = 240,
2393 /** OpenMP master directive.
2395 CXCursor_OMPMasterDirective = 241,
2397 /** OpenMP critical directive.
2399 CXCursor_OMPCriticalDirective = 242,
2401 /** OpenMP taskyield directive.
2403 CXCursor_OMPTaskyieldDirective = 243,
2405 /** OpenMP barrier directive.
2407 CXCursor_OMPBarrierDirective = 244,
2409 /** OpenMP taskwait directive.
2411 CXCursor_OMPTaskwaitDirective = 245,
2413 /** OpenMP flush directive.
2415 CXCursor_OMPFlushDirective = 246,
2417 /** Windows Structured Exception Handling's leave statement.
2419 CXCursor_SEHLeaveStmt = 247,
2421 /** OpenMP ordered directive.
2423 CXCursor_OMPOrderedDirective = 248,
2425 /** OpenMP atomic directive.
2427 CXCursor_OMPAtomicDirective = 249,
2429 /** OpenMP for SIMD directive.
2431 CXCursor_OMPForSimdDirective = 250,
2433 /** OpenMP parallel for SIMD directive.
2435 CXCursor_OMPParallelForSimdDirective = 251,
2437 /** OpenMP target directive.
2439 CXCursor_OMPTargetDirective = 252,
2441 /** OpenMP teams directive.
2443 CXCursor_OMPTeamsDirective = 253,
2445 /** OpenMP taskgroup directive.
2447 CXCursor_OMPTaskgroupDirective = 254,
2449 /** OpenMP cancellation point directive.
2451 CXCursor_OMPCancellationPointDirective = 255,
2453 /** OpenMP cancel directive.
2455 CXCursor_OMPCancelDirective = 256,
2457 /** OpenMP target data directive.
2459 CXCursor_OMPTargetDataDirective = 257,
2461 /** OpenMP taskloop directive.
2463 CXCursor_OMPTaskLoopDirective = 258,
2465 /** OpenMP taskloop simd directive.
2467 CXCursor_OMPTaskLoopSimdDirective = 259,
2469 /** OpenMP distribute directive.
2471 CXCursor_OMPDistributeDirective = 260,
2473 /** OpenMP target enter data directive.
2475 CXCursor_OMPTargetEnterDataDirective = 261,
2477 /** OpenMP target exit data directive.
2479 CXCursor_OMPTargetExitDataDirective = 262,
2481 /** OpenMP target parallel directive.
2483 CXCursor_OMPTargetParallelDirective = 263,
2485 /** OpenMP target parallel for directive.
2487 CXCursor_OMPTargetParallelForDirective = 264,
2489 /** OpenMP target update directive.
2491 CXCursor_OMPTargetUpdateDirective = 265,
2493 /** OpenMP distribute parallel for directive.
2495 CXCursor_OMPDistributeParallelForDirective = 266,
2497 /** OpenMP distribute parallel for simd directive.
2499 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2501 /** OpenMP distribute simd directive.
2503 CXCursor_OMPDistributeSimdDirective = 268,
2505 /** OpenMP target parallel for simd directive.
2507 CXCursor_OMPTargetParallelForSimdDirective = 269,
2509 /** OpenMP target simd directive.
2511 CXCursor_OMPTargetSimdDirective = 270,
2513 /** OpenMP teams distribute directive.
2515 CXCursor_OMPTeamsDistributeDirective = 271,
2517 /** OpenMP teams distribute simd directive.
2519 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2521 /** OpenMP teams distribute parallel for simd directive.
2523 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2525 /** OpenMP teams distribute parallel for directive.
2527 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2529 /** OpenMP target teams directive.
2531 CXCursor_OMPTargetTeamsDirective = 275,
2533 /** OpenMP target teams distribute directive.
2535 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2537 /** OpenMP target teams distribute parallel for directive.
2539 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2541 /** OpenMP target teams distribute parallel for simd directive.
2543 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2545 /** OpenMP target teams distribute simd directive.
2547 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2549 /** C++2a std::bit_cast expression.
2551 CXCursor_BuiltinBitCastExpr = 280,
2553 /** OpenMP master taskloop directive.
2555 CXCursor_OMPMasterTaskLoopDirective = 281,
2557 /** OpenMP parallel master taskloop directive.
2559 CXCursor_OMPParallelMasterTaskLoopDirective = 282,
2561 /** OpenMP master taskloop simd directive.
2563 CXCursor_OMPMasterTaskLoopSimdDirective = 283,
2565 /** OpenMP parallel master taskloop simd directive.
2567 CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
2569 /** OpenMP parallel master directive.
2571 CXCursor_OMPParallelMasterDirective = 285,
2573 /** OpenMP depobj directive.
2575 CXCursor_OMPDepobjDirective = 286,
2577 /** OpenMP scan directive.
2579 CXCursor_OMPScanDirective = 287,
2581 /** OpenMP tile directive.
2583 CXCursor_OMPTileDirective = 288,
2585 /** OpenMP canonical loop.
2587 CXCursor_OMPCanonicalLoop = 289,
2589 /** OpenMP interop directive.
2591 CXCursor_OMPInteropDirective = 290,
2593 /** OpenMP dispatch directive.
2595 CXCursor_OMPDispatchDirective = 291,
2597 /** OpenMP masked directive.
2599 CXCursor_OMPMaskedDirective = 292,
2601 /** OpenMP unroll directive.
2603 CXCursor_OMPUnrollDirective = 293,
2605 /** OpenMP metadirective directive.
2607 CXCursor_OMPMetaDirective = 294,
2609 /** OpenMP loop directive.
2611 CXCursor_OMPGenericLoopDirective = 295,
2613 /** OpenMP teams loop directive.
2615 CXCursor_OMPTeamsGenericLoopDirective = 296,
2617 /** OpenMP target teams loop directive.
2619 CXCursor_OMPTargetTeamsGenericLoopDirective = 297,
2621 /** OpenMP parallel loop directive.
2623 CXCursor_OMPParallelGenericLoopDirective = 298,
2625 /** OpenMP target parallel loop directive.
2627 CXCursor_OMPTargetParallelGenericLoopDirective = 299,
2629 /** OpenMP parallel masked directive.
2631 CXCursor_OMPParallelMaskedDirective = 300,
2633 /** OpenMP masked taskloop directive.
2635 CXCursor_OMPMaskedTaskLoopDirective = 301,
2637 /** OpenMP masked taskloop simd directive.
2639 CXCursor_OMPMaskedTaskLoopSimdDirective = 302,
2641 /** OpenMP parallel masked taskloop directive.
2643 CXCursor_OMPParallelMaskedTaskLoopDirective = 303,
2645 /** OpenMP parallel masked taskloop simd directive.
2647 CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304,
2649 CXCursor_LastStmt = CXCursor_OMPParallelMaskedTaskLoopSimdDirective,
2652 * Cursor that represents the translation unit itself.
2654 * The translation unit cursor exists primarily to act as the root
2655 * cursor for traversing the contents of a translation unit.
2657 CXCursor_TranslationUnit = 350,
2659 /* Attributes */
2660 CXCursor_FirstAttr = 400,
2662 * An attribute whose specific kind is not exposed via this
2663 * interface.
2665 CXCursor_UnexposedAttr = 400,
2667 CXCursor_IBActionAttr = 401,
2668 CXCursor_IBOutletAttr = 402,
2669 CXCursor_IBOutletCollectionAttr = 403,
2670 CXCursor_CXXFinalAttr = 404,
2671 CXCursor_CXXOverrideAttr = 405,
2672 CXCursor_AnnotateAttr = 406,
2673 CXCursor_AsmLabelAttr = 407,
2674 CXCursor_PackedAttr = 408,
2675 CXCursor_PureAttr = 409,
2676 CXCursor_ConstAttr = 410,
2677 CXCursor_NoDuplicateAttr = 411,
2678 CXCursor_CUDAConstantAttr = 412,
2679 CXCursor_CUDADeviceAttr = 413,
2680 CXCursor_CUDAGlobalAttr = 414,
2681 CXCursor_CUDAHostAttr = 415,
2682 CXCursor_CUDASharedAttr = 416,
2683 CXCursor_VisibilityAttr = 417,
2684 CXCursor_DLLExport = 418,
2685 CXCursor_DLLImport = 419,
2686 CXCursor_NSReturnsRetained = 420,
2687 CXCursor_NSReturnsNotRetained = 421,
2688 CXCursor_NSReturnsAutoreleased = 422,
2689 CXCursor_NSConsumesSelf = 423,
2690 CXCursor_NSConsumed = 424,
2691 CXCursor_ObjCException = 425,
2692 CXCursor_ObjCNSObject = 426,
2693 CXCursor_ObjCIndependentClass = 427,
2694 CXCursor_ObjCPreciseLifetime = 428,
2695 CXCursor_ObjCReturnsInnerPointer = 429,
2696 CXCursor_ObjCRequiresSuper = 430,
2697 CXCursor_ObjCRootClass = 431,
2698 CXCursor_ObjCSubclassingRestricted = 432,
2699 CXCursor_ObjCExplicitProtocolImpl = 433,
2700 CXCursor_ObjCDesignatedInitializer = 434,
2701 CXCursor_ObjCRuntimeVisible = 435,
2702 CXCursor_ObjCBoxable = 436,
2703 CXCursor_FlagEnum = 437,
2704 CXCursor_ConvergentAttr = 438,
2705 CXCursor_WarnUnusedAttr = 439,
2706 CXCursor_WarnUnusedResultAttr = 440,
2707 CXCursor_AlignedAttr = 441,
2708 CXCursor_LastAttr = CXCursor_AlignedAttr,
2710 /* Preprocessing */
2711 CXCursor_PreprocessingDirective = 500,
2712 CXCursor_MacroDefinition = 501,
2713 CXCursor_MacroExpansion = 502,
2714 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2715 CXCursor_InclusionDirective = 503,
2716 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2717 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2719 /* Extra Declarations */
2721 * A module import declaration.
2723 CXCursor_ModuleImportDecl = 600,
2724 CXCursor_TypeAliasTemplateDecl = 601,
2726 * A static_assert or _Static_assert node
2728 CXCursor_StaticAssert = 602,
2730 * a friend declaration.
2732 CXCursor_FriendDecl = 603,
2734 * a concept declaration.
2736 CXCursor_ConceptDecl = 604,
2738 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2739 CXCursor_LastExtraDecl = CXCursor_ConceptDecl,
2742 * A code completion overload candidate.
2744 CXCursor_OverloadCandidate = 700
2748 * A cursor representing some element in the abstract syntax tree for
2749 * a translation unit.
2751 * The cursor abstraction unifies the different kinds of entities in a
2752 * program--declaration, statements, expressions, references to declarations,
2753 * etc.--under a single "cursor" abstraction with a common set of operations.
2754 * Common operation for a cursor include: getting the physical location in
2755 * a source file where the cursor points, getting the name associated with a
2756 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2758 * Cursors can be produced in two specific ways.
2759 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2760 * from which one can use clang_visitChildren() to explore the rest of the
2761 * translation unit. clang_getCursor() maps from a physical source location
2762 * to the entity that resides at that location, allowing one to map from the
2763 * source code into the AST.
2765 typedef struct {
2766 enum CXCursorKind kind;
2767 int xdata;
2768 const void *data[3];
2769 } CXCursor;
2772 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2774 * @{
2778 * Retrieve the NULL cursor, which represents no entity.
2780 CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2783 * Retrieve the cursor that represents the given translation unit.
2785 * The translation unit cursor can be used to start traversing the
2786 * various declarations within the given translation unit.
2788 CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2791 * Determine whether two cursors are equivalent.
2793 CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2796 * Returns non-zero if \p cursor is null.
2798 CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2801 * Compute a hash value for the given cursor.
2803 CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2806 * Retrieve the kind of the given cursor.
2808 CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2811 * Determine whether the given cursor kind represents a declaration.
2813 CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2816 * Determine whether the given declaration is invalid.
2818 * A declaration is invalid if it could not be parsed successfully.
2820 * \returns non-zero if the cursor represents a declaration and it is
2821 * invalid, otherwise NULL.
2823 CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2826 * Determine whether the given cursor kind represents a simple
2827 * reference.
2829 * Note that other kinds of cursors (such as expressions) can also refer to
2830 * other cursors. Use clang_getCursorReferenced() to determine whether a
2831 * particular cursor refers to another entity.
2833 CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2836 * Determine whether the given cursor kind represents an expression.
2838 CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2841 * Determine whether the given cursor kind represents a statement.
2843 CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2846 * Determine whether the given cursor kind represents an attribute.
2848 CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2851 * Determine whether the given cursor has any attributes.
2853 CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2856 * Determine whether the given cursor kind represents an invalid
2857 * cursor.
2859 CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2862 * Determine whether the given cursor kind represents a translation
2863 * unit.
2865 CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2867 /***
2868 * Determine whether the given cursor represents a preprocessing
2869 * element, such as a preprocessor directive or macro instantiation.
2871 CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2873 /***
2874 * Determine whether the given cursor represents a currently
2875 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2877 CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2880 * Describe the linkage of the entity referred to by a cursor.
2882 enum CXLinkageKind {
2883 /** This value indicates that no linkage information is available
2884 * for a provided CXCursor. */
2885 CXLinkage_Invalid,
2887 * This is the linkage for variables, parameters, and so on that
2888 * have automatic storage. This covers normal (non-extern) local variables.
2890 CXLinkage_NoLinkage,
2891 /** This is the linkage for static variables and static functions. */
2892 CXLinkage_Internal,
2893 /** This is the linkage for entities with external linkage that live
2894 * in C++ anonymous namespaces.*/
2895 CXLinkage_UniqueExternal,
2896 /** This is the linkage for entities with true, external linkage. */
2897 CXLinkage_External
2901 * Determine the linkage of the entity referred to by a given cursor.
2903 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2905 enum CXVisibilityKind {
2906 /** This value indicates that no visibility information is available
2907 * for a provided CXCursor. */
2908 CXVisibility_Invalid,
2910 /** Symbol not seen by the linker. */
2911 CXVisibility_Hidden,
2912 /** Symbol seen by the linker but resolves to a symbol inside this object. */
2913 CXVisibility_Protected,
2914 /** Symbol seen by the linker and acts like a normal symbol. */
2915 CXVisibility_Default
2919 * Describe the visibility of the entity referred to by a cursor.
2921 * This returns the default visibility if not explicitly specified by
2922 * a visibility attribute. The default visibility may be changed by
2923 * commandline arguments.
2925 * \param cursor The cursor to query.
2927 * \returns The visibility of the cursor.
2929 CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2932 * Determine the availability of the entity that this cursor refers to,
2933 * taking the current target platform into account.
2935 * \param cursor The cursor to query.
2937 * \returns The availability of the cursor.
2939 CINDEX_LINKAGE enum CXAvailabilityKind
2940 clang_getCursorAvailability(CXCursor cursor);
2943 * Describes the availability of a given entity on a particular platform, e.g.,
2944 * a particular class might only be available on Mac OS 10.7 or newer.
2946 typedef struct CXPlatformAvailability {
2948 * A string that describes the platform for which this structure
2949 * provides availability information.
2951 * Possible values are "ios" or "macos".
2953 CXString Platform;
2955 * The version number in which this entity was introduced.
2957 CXVersion Introduced;
2959 * The version number in which this entity was deprecated (but is
2960 * still available).
2962 CXVersion Deprecated;
2964 * The version number in which this entity was obsoleted, and therefore
2965 * is no longer available.
2967 CXVersion Obsoleted;
2969 * Whether the entity is unconditionally unavailable on this platform.
2971 int Unavailable;
2973 * An optional message to provide to a user of this API, e.g., to
2974 * suggest replacement APIs.
2976 CXString Message;
2977 } CXPlatformAvailability;
2980 * Determine the availability of the entity that this cursor refers to
2981 * on any platforms for which availability information is known.
2983 * \param cursor The cursor to query.
2985 * \param always_deprecated If non-NULL, will be set to indicate whether the
2986 * entity is deprecated on all platforms.
2988 * \param deprecated_message If non-NULL, will be set to the message text
2989 * provided along with the unconditional deprecation of this entity. The client
2990 * is responsible for deallocating this string.
2992 * \param always_unavailable If non-NULL, will be set to indicate whether the
2993 * entity is unavailable on all platforms.
2995 * \param unavailable_message If non-NULL, will be set to the message text
2996 * provided along with the unconditional unavailability of this entity. The
2997 * client is responsible for deallocating this string.
2999 * \param availability If non-NULL, an array of CXPlatformAvailability instances
3000 * that will be populated with platform availability information, up to either
3001 * the number of platforms for which availability information is available (as
3002 * returned by this function) or \c availability_size, whichever is smaller.
3004 * \param availability_size The number of elements available in the
3005 * \c availability array.
3007 * \returns The number of platforms (N) for which availability information is
3008 * available (which is unrelated to \c availability_size).
3010 * Note that the client is responsible for calling
3011 * \c clang_disposeCXPlatformAvailability to free each of the
3012 * platform-availability structures returned. There are
3013 * \c min(N, availability_size) such structures.
3015 CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
3016 CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
3017 int *always_unavailable, CXString *unavailable_message,
3018 CXPlatformAvailability *availability, int availability_size);
3021 * Free the memory associated with a \c CXPlatformAvailability structure.
3023 CINDEX_LINKAGE void
3024 clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
3027 * If cursor refers to a variable declaration and it has initializer returns
3028 * cursor referring to the initializer otherwise return null cursor.
3030 CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);
3033 * If cursor refers to a variable declaration that has global storage returns 1.
3034 * If cursor refers to a variable declaration that doesn't have global storage
3035 * returns 0. Otherwise returns -1.
3037 CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);
3040 * If cursor refers to a variable declaration that has external storage
3041 * returns 1. If cursor refers to a variable declaration that doesn't have
3042 * external storage returns 0. Otherwise returns -1.
3044 CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);
3047 * Describe the "language" of the entity referred to by a cursor.
3049 enum CXLanguageKind {
3050 CXLanguage_Invalid = 0,
3051 CXLanguage_C,
3052 CXLanguage_ObjC,
3053 CXLanguage_CPlusPlus
3057 * Determine the "language" of the entity referred to by a given cursor.
3059 CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
3062 * Describe the "thread-local storage (TLS) kind" of the declaration
3063 * referred to by a cursor.
3065 enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
3068 * Determine the "thread-local storage (TLS) kind" of the declaration
3069 * referred to by a cursor.
3071 CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
3074 * Returns the translation unit that a cursor originated from.
3076 CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
3079 * A fast container representing a set of CXCursors.
3081 typedef struct CXCursorSetImpl *CXCursorSet;
3084 * Creates an empty CXCursorSet.
3086 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
3089 * Disposes a CXCursorSet and releases its associated memory.
3091 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
3094 * Queries a CXCursorSet to see if it contains a specific CXCursor.
3096 * \returns non-zero if the set contains the specified cursor.
3098 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
3099 CXCursor cursor);
3102 * Inserts a CXCursor into a CXCursorSet.
3104 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
3106 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
3107 CXCursor cursor);
3110 * Determine the semantic parent of the given cursor.
3112 * The semantic parent of a cursor is the cursor that semantically contains
3113 * the given \p cursor. For many declarations, the lexical and semantic parents
3114 * are equivalent (the lexical parent is returned by
3115 * \c clang_getCursorLexicalParent()). They diverge when declarations or
3116 * definitions are provided out-of-line. For example:
3118 * \code
3119 * class C {
3120 * void f();
3121 * };
3123 * void C::f() { }
3124 * \endcode
3126 * In the out-of-line definition of \c C::f, the semantic parent is
3127 * the class \c C, of which this function is a member. The lexical parent is
3128 * the place where the declaration actually occurs in the source code; in this
3129 * case, the definition occurs in the translation unit. In general, the
3130 * lexical parent for a given entity can change without affecting the semantics
3131 * of the program, and the lexical parent of different declarations of the
3132 * same entity may be different. Changing the semantic parent of a declaration,
3133 * on the other hand, can have a major impact on semantics, and redeclarations
3134 * of a particular entity should all have the same semantic context.
3136 * In the example above, both declarations of \c C::f have \c C as their
3137 * semantic context, while the lexical context of the first \c C::f is \c C
3138 * and the lexical context of the second \c C::f is the translation unit.
3140 * For global declarations, the semantic parent is the translation unit.
3142 CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3145 * Determine the lexical parent of the given cursor.
3147 * The lexical parent of a cursor is the cursor in which the given \p cursor
3148 * was actually written. For many declarations, the lexical and semantic parents
3149 * are equivalent (the semantic parent is returned by
3150 * \c clang_getCursorSemanticParent()). They diverge when declarations or
3151 * definitions are provided out-of-line. For example:
3153 * \code
3154 * class C {
3155 * void f();
3156 * };
3158 * void C::f() { }
3159 * \endcode
3161 * In the out-of-line definition of \c C::f, the semantic parent is
3162 * the class \c C, of which this function is a member. The lexical parent is
3163 * the place where the declaration actually occurs in the source code; in this
3164 * case, the definition occurs in the translation unit. In general, the
3165 * lexical parent for a given entity can change without affecting the semantics
3166 * of the program, and the lexical parent of different declarations of the
3167 * same entity may be different. Changing the semantic parent of a declaration,
3168 * on the other hand, can have a major impact on semantics, and redeclarations
3169 * of a particular entity should all have the same semantic context.
3171 * In the example above, both declarations of \c C::f have \c C as their
3172 * semantic context, while the lexical context of the first \c C::f is \c C
3173 * and the lexical context of the second \c C::f is the translation unit.
3175 * For declarations written in the global scope, the lexical parent is
3176 * the translation unit.
3178 CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
3181 * Determine the set of methods that are overridden by the given
3182 * method.
3184 * In both Objective-C and C++, a method (aka virtual member function,
3185 * in C++) can override a virtual method in a base class. For
3186 * Objective-C, a method is said to override any method in the class's
3187 * base class, its protocols, or its categories' protocols, that has the same
3188 * selector and is of the same kind (class or instance).
3189 * If no such method exists, the search continues to the class's superclass,
3190 * its protocols, and its categories, and so on. A method from an Objective-C
3191 * implementation is considered to override the same methods as its
3192 * corresponding method in the interface.
3194 * For C++, a virtual member function overrides any virtual member
3195 * function with the same signature that occurs in its base
3196 * classes. With multiple inheritance, a virtual member function can
3197 * override several virtual member functions coming from different
3198 * base classes.
3200 * In all cases, this function determines the immediate overridden
3201 * method, rather than all of the overridden methods. For example, if
3202 * a method is originally declared in a class A, then overridden in B
3203 * (which in inherits from A) and also in C (which inherited from B),
3204 * then the only overridden method returned from this function when
3205 * invoked on C's method will be B's method. The client may then
3206 * invoke this function again, given the previously-found overridden
3207 * methods, to map out the complete method-override set.
3209 * \param cursor A cursor representing an Objective-C or C++
3210 * method. This routine will compute the set of methods that this
3211 * method overrides.
3213 * \param overridden A pointer whose pointee will be replaced with a
3214 * pointer to an array of cursors, representing the set of overridden
3215 * methods. If there are no overridden methods, the pointee will be
3216 * set to NULL. The pointee must be freed via a call to
3217 * \c clang_disposeOverriddenCursors().
3219 * \param num_overridden A pointer to the number of overridden
3220 * functions, will be set to the number of overridden functions in the
3221 * array pointed to by \p overridden.
3223 CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
3224 CXCursor **overridden,
3225 unsigned *num_overridden);
3228 * Free the set of overridden cursors returned by \c
3229 * clang_getOverriddenCursors().
3231 CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3234 * Retrieve the file that is included by the given inclusion directive
3235 * cursor.
3237 CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
3240 * @}
3244 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3246 * Cursors represent a location within the Abstract Syntax Tree (AST). These
3247 * routines help map between cursors and the physical locations where the
3248 * described entities occur in the source code. The mapping is provided in
3249 * both directions, so one can map from source code to the AST and back.
3251 * @{
3255 * Map a source location to the cursor that describes the entity at that
3256 * location in the source code.
3258 * clang_getCursor() maps an arbitrary source location within a translation
3259 * unit down to the most specific cursor that describes the entity at that
3260 * location. For example, given an expression \c x + y, invoking
3261 * clang_getCursor() with a source location pointing to "x" will return the
3262 * cursor for "x"; similarly for "y". If the cursor points anywhere between
3263 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3264 * will return a cursor referring to the "+" expression.
3266 * \returns a cursor representing the entity at the given source location, or
3267 * a NULL cursor if no such entity can be found.
3269 CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
3272 * Retrieve the physical location of the source constructor referenced
3273 * by the given cursor.
3275 * The location of a declaration is typically the location of the name of that
3276 * declaration, where the name of that declaration would occur if it is
3277 * unnamed, or some keyword that introduces that particular declaration.
3278 * The location of a reference is where that reference occurs within the
3279 * source code.
3281 CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
3284 * Retrieve the physical extent of the source construct referenced by
3285 * the given cursor.
3287 * The extent of a cursor starts with the file/line/column pointing at the
3288 * first character within the source construct that the cursor refers to and
3289 * ends with the last character within that source construct. For a
3290 * declaration, the extent covers the declaration itself. For a reference,
3291 * the extent covers the location of the reference (e.g., where the referenced
3292 * entity was actually used).
3294 CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
3297 * @}
3301 * \defgroup CINDEX_TYPES Type information for CXCursors
3303 * @{
3307 * Describes the kind of type
3309 enum CXTypeKind {
3311 * Represents an invalid type (e.g., where no type is available).
3313 CXType_Invalid = 0,
3316 * A type whose specific kind is not exposed via this
3317 * interface.
3319 CXType_Unexposed = 1,
3321 /* Builtin types */
3322 CXType_Void = 2,
3323 CXType_Bool = 3,
3324 CXType_Char_U = 4,
3325 CXType_UChar = 5,
3326 CXType_Char16 = 6,
3327 CXType_Char32 = 7,
3328 CXType_UShort = 8,
3329 CXType_UInt = 9,
3330 CXType_ULong = 10,
3331 CXType_ULongLong = 11,
3332 CXType_UInt128 = 12,
3333 CXType_Char_S = 13,
3334 CXType_SChar = 14,
3335 CXType_WChar = 15,
3336 CXType_Short = 16,
3337 CXType_Int = 17,
3338 CXType_Long = 18,
3339 CXType_LongLong = 19,
3340 CXType_Int128 = 20,
3341 CXType_Float = 21,
3342 CXType_Double = 22,
3343 CXType_LongDouble = 23,
3344 CXType_NullPtr = 24,
3345 CXType_Overload = 25,
3346 CXType_Dependent = 26,
3347 CXType_ObjCId = 27,
3348 CXType_ObjCClass = 28,
3349 CXType_ObjCSel = 29,
3350 CXType_Float128 = 30,
3351 CXType_Half = 31,
3352 CXType_Float16 = 32,
3353 CXType_ShortAccum = 33,
3354 CXType_Accum = 34,
3355 CXType_LongAccum = 35,
3356 CXType_UShortAccum = 36,
3357 CXType_UAccum = 37,
3358 CXType_ULongAccum = 38,
3359 CXType_BFloat16 = 39,
3360 CXType_Ibm128 = 40,
3361 CXType_FirstBuiltin = CXType_Void,
3362 CXType_LastBuiltin = CXType_Ibm128,
3364 CXType_Complex = 100,
3365 CXType_Pointer = 101,
3366 CXType_BlockPointer = 102,
3367 CXType_LValueReference = 103,
3368 CXType_RValueReference = 104,
3369 CXType_Record = 105,
3370 CXType_Enum = 106,
3371 CXType_Typedef = 107,
3372 CXType_ObjCInterface = 108,
3373 CXType_ObjCObjectPointer = 109,
3374 CXType_FunctionNoProto = 110,
3375 CXType_FunctionProto = 111,
3376 CXType_ConstantArray = 112,
3377 CXType_Vector = 113,
3378 CXType_IncompleteArray = 114,
3379 CXType_VariableArray = 115,
3380 CXType_DependentSizedArray = 116,
3381 CXType_MemberPointer = 117,
3382 CXType_Auto = 118,
3385 * Represents a type that was referred to using an elaborated type keyword.
3387 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3389 CXType_Elaborated = 119,
3391 /* OpenCL PipeType. */
3392 CXType_Pipe = 120,
3394 /* OpenCL builtin types. */
3395 CXType_OCLImage1dRO = 121,
3396 CXType_OCLImage1dArrayRO = 122,
3397 CXType_OCLImage1dBufferRO = 123,
3398 CXType_OCLImage2dRO = 124,
3399 CXType_OCLImage2dArrayRO = 125,
3400 CXType_OCLImage2dDepthRO = 126,
3401 CXType_OCLImage2dArrayDepthRO = 127,
3402 CXType_OCLImage2dMSAARO = 128,
3403 CXType_OCLImage2dArrayMSAARO = 129,
3404 CXType_OCLImage2dMSAADepthRO = 130,
3405 CXType_OCLImage2dArrayMSAADepthRO = 131,
3406 CXType_OCLImage3dRO = 132,
3407 CXType_OCLImage1dWO = 133,
3408 CXType_OCLImage1dArrayWO = 134,
3409 CXType_OCLImage1dBufferWO = 135,
3410 CXType_OCLImage2dWO = 136,
3411 CXType_OCLImage2dArrayWO = 137,
3412 CXType_OCLImage2dDepthWO = 138,
3413 CXType_OCLImage2dArrayDepthWO = 139,
3414 CXType_OCLImage2dMSAAWO = 140,
3415 CXType_OCLImage2dArrayMSAAWO = 141,
3416 CXType_OCLImage2dMSAADepthWO = 142,
3417 CXType_OCLImage2dArrayMSAADepthWO = 143,
3418 CXType_OCLImage3dWO = 144,
3419 CXType_OCLImage1dRW = 145,
3420 CXType_OCLImage1dArrayRW = 146,
3421 CXType_OCLImage1dBufferRW = 147,
3422 CXType_OCLImage2dRW = 148,
3423 CXType_OCLImage2dArrayRW = 149,
3424 CXType_OCLImage2dDepthRW = 150,
3425 CXType_OCLImage2dArrayDepthRW = 151,
3426 CXType_OCLImage2dMSAARW = 152,
3427 CXType_OCLImage2dArrayMSAARW = 153,
3428 CXType_OCLImage2dMSAADepthRW = 154,
3429 CXType_OCLImage2dArrayMSAADepthRW = 155,
3430 CXType_OCLImage3dRW = 156,
3431 CXType_OCLSampler = 157,
3432 CXType_OCLEvent = 158,
3433 CXType_OCLQueue = 159,
3434 CXType_OCLReserveID = 160,
3436 CXType_ObjCObject = 161,
3437 CXType_ObjCTypeParam = 162,
3438 CXType_Attributed = 163,
3440 CXType_OCLIntelSubgroupAVCMcePayload = 164,
3441 CXType_OCLIntelSubgroupAVCImePayload = 165,
3442 CXType_OCLIntelSubgroupAVCRefPayload = 166,
3443 CXType_OCLIntelSubgroupAVCSicPayload = 167,
3444 CXType_OCLIntelSubgroupAVCMceResult = 168,
3445 CXType_OCLIntelSubgroupAVCImeResult = 169,
3446 CXType_OCLIntelSubgroupAVCRefResult = 170,
3447 CXType_OCLIntelSubgroupAVCSicResult = 171,
3448 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3449 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3450 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3452 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
3454 CXType_ExtVector = 176,
3455 CXType_Atomic = 177,
3456 CXType_BTFTagAttributed = 178
3460 * Describes the calling convention of a function type
3462 enum CXCallingConv {
3463 CXCallingConv_Default = 0,
3464 CXCallingConv_C = 1,
3465 CXCallingConv_X86StdCall = 2,
3466 CXCallingConv_X86FastCall = 3,
3467 CXCallingConv_X86ThisCall = 4,
3468 CXCallingConv_X86Pascal = 5,
3469 CXCallingConv_AAPCS = 6,
3470 CXCallingConv_AAPCS_VFP = 7,
3471 CXCallingConv_X86RegCall = 8,
3472 CXCallingConv_IntelOclBicc = 9,
3473 CXCallingConv_Win64 = 10,
3474 /* Alias for compatibility with older versions of API. */
3475 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
3476 CXCallingConv_X86_64SysV = 11,
3477 CXCallingConv_X86VectorCall = 12,
3478 CXCallingConv_Swift = 13,
3479 CXCallingConv_PreserveMost = 14,
3480 CXCallingConv_PreserveAll = 15,
3481 CXCallingConv_AArch64VectorCall = 16,
3482 CXCallingConv_SwiftAsync = 17,
3483 CXCallingConv_AArch64SVEPCS = 18,
3485 CXCallingConv_Invalid = 100,
3486 CXCallingConv_Unexposed = 200
3490 * The type of an element in the abstract syntax tree.
3493 typedef struct {
3494 enum CXTypeKind kind;
3495 void *data[2];
3496 } CXType;
3499 * Retrieve the type of a CXCursor (if any).
3501 CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3504 * Pretty-print the underlying type using the rules of the
3505 * language of the translation unit from which it came.
3507 * If the type is invalid, an empty string is returned.
3509 CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3512 * Retrieve the underlying type of a typedef declaration.
3514 * If the cursor does not reference a typedef declaration, an invalid type is
3515 * returned.
3517 CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3520 * Retrieve the integer type of an enum declaration.
3522 * If the cursor does not reference an enum declaration, an invalid type is
3523 * returned.
3525 CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3528 * Retrieve the integer value of an enum constant declaration as a signed
3529 * long long.
3531 * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3532 * returned. Since this is also potentially a valid constant value, the kind of
3533 * the cursor must be verified before calling this function.
3535 CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3538 * Retrieve the integer value of an enum constant declaration as an unsigned
3539 * long long.
3541 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3542 * returned. Since this is also potentially a valid constant value, the kind of
3543 * the cursor must be verified before calling this function.
3545 CINDEX_LINKAGE unsigned long long
3546 clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3549 * Retrieve the bit width of a bit field declaration as an integer.
3551 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3553 CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3556 * Retrieve the number of non-variadic arguments associated with a given
3557 * cursor.
3559 * The number of arguments can be determined for calls as well as for
3560 * declarations of functions or methods. For other cursors -1 is returned.
3562 CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3565 * Retrieve the argument cursor of a function or method.
3567 * The argument cursor can be determined for calls as well as for declarations
3568 * of functions or methods. For other cursors and for invalid indices, an
3569 * invalid cursor is returned.
3571 CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3574 * Describes the kind of a template argument.
3576 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3577 * element descriptions.
3579 enum CXTemplateArgumentKind {
3580 CXTemplateArgumentKind_Null,
3581 CXTemplateArgumentKind_Type,
3582 CXTemplateArgumentKind_Declaration,
3583 CXTemplateArgumentKind_NullPtr,
3584 CXTemplateArgumentKind_Integral,
3585 CXTemplateArgumentKind_Template,
3586 CXTemplateArgumentKind_TemplateExpansion,
3587 CXTemplateArgumentKind_Expression,
3588 CXTemplateArgumentKind_Pack,
3589 /* Indicates an error case, preventing the kind from being deduced. */
3590 CXTemplateArgumentKind_Invalid
3594 *Returns the number of template args of a function decl representing a
3595 * template specialization.
3597 * If the argument cursor cannot be converted into a template function
3598 * declaration, -1 is returned.
3600 * For example, for the following declaration and specialization:
3601 * template <typename T, int kInt, bool kBool>
3602 * void foo() { ... }
3604 * template <>
3605 * void foo<float, -7, true>();
3607 * The value 3 would be returned from this call.
3609 CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3612 * Retrieve the kind of the I'th template argument of the CXCursor C.
3614 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3615 * template argument kind is returned.
3617 * For example, for the following declaration and specialization:
3618 * template <typename T, int kInt, bool kBool>
3619 * void foo() { ... }
3621 * template <>
3622 * void foo<float, -7, true>();
3624 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3625 * respectively.
3627 CINDEX_LINKAGE enum CXTemplateArgumentKind
3628 clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
3631 * Retrieve a CXType representing the type of a TemplateArgument of a
3632 * function decl representing a template specialization.
3634 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3635 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3636 * is returned.
3638 * For example, for the following declaration and specialization:
3639 * template <typename T, int kInt, bool kBool>
3640 * void foo() { ... }
3642 * template <>
3643 * void foo<float, -7, true>();
3645 * If called with I = 0, "float", will be returned.
3646 * Invalid types will be returned for I == 1 or 2.
3648 CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3649 unsigned I);
3652 * Retrieve the value of an Integral TemplateArgument (of a function
3653 * decl representing a template specialization) as a signed long long.
3655 * It is undefined to call this function on a CXCursor that does not represent a
3656 * FunctionDecl or whose I'th template argument is not an integral value.
3658 * For example, for the following declaration and specialization:
3659 * template <typename T, int kInt, bool kBool>
3660 * void foo() { ... }
3662 * template <>
3663 * void foo<float, -7, true>();
3665 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3666 * For I == 0, this function's behavior is undefined.
3668 CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3669 unsigned I);
3672 * Retrieve the value of an Integral TemplateArgument (of a function
3673 * decl representing a template specialization) as an unsigned long long.
3675 * It is undefined to call this function on a CXCursor that does not represent a
3676 * FunctionDecl or whose I'th template argument is not an integral value.
3678 * For example, for the following declaration and specialization:
3679 * template <typename T, int kInt, bool kBool>
3680 * void foo() { ... }
3682 * template <>
3683 * void foo<float, 2147483649, true>();
3685 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3686 * For I == 0, this function's behavior is undefined.
3688 CINDEX_LINKAGE unsigned long long
3689 clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
3692 * Determine whether two CXTypes represent the same type.
3694 * \returns non-zero if the CXTypes represent the same type and
3695 * zero otherwise.
3697 CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3700 * Return the canonical type for a CXType.
3702 * Clang's type system explicitly models typedefs and all the ways
3703 * a specific type can be represented. The canonical type is the underlying
3704 * type with all the "sugar" removed. For example, if 'T' is a typedef
3705 * for 'int', the canonical type for 'T' would be 'int'.
3707 CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3710 * Determine whether a CXType has the "const" qualifier set,
3711 * without looking through typedefs that may have added "const" at a
3712 * different level.
3714 CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3717 * Determine whether a CXCursor that is a macro, is
3718 * function like.
3720 CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3723 * Determine whether a CXCursor that is a macro, is a
3724 * builtin one.
3726 CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3729 * Determine whether a CXCursor that is a function declaration, is an
3730 * inline declaration.
3732 CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3735 * Determine whether a CXType has the "volatile" qualifier set,
3736 * without looking through typedefs that may have added "volatile" at
3737 * a different level.
3739 CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3742 * Determine whether a CXType has the "restrict" qualifier set,
3743 * without looking through typedefs that may have added "restrict" at a
3744 * different level.
3746 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3749 * Returns the address space of the given type.
3751 CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3754 * Returns the typedef name of the given type.
3756 CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3759 * For pointer types, returns the type of the pointee.
3761 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3764 * Return the cursor for the declaration of the given type.
3766 CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3769 * Returns the Objective-C type encoding for the specified declaration.
3771 CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3774 * Returns the Objective-C type encoding for the specified CXType.
3776 CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3779 * Retrieve the spelling of a given CXTypeKind.
3781 CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3784 * Retrieve the calling convention associated with a function type.
3786 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3788 CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3791 * Retrieve the return type associated with a function type.
3793 * If a non-function type is passed in, an invalid type is returned.
3795 CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3798 * Retrieve the exception specification type associated with a function type.
3799 * This is a value of type CXCursor_ExceptionSpecificationKind.
3801 * If a non-function type is passed in, an error code of -1 is returned.
3803 CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3806 * Retrieve the number of non-variadic parameters associated with a
3807 * function type.
3809 * If a non-function type is passed in, -1 is returned.
3811 CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3814 * Retrieve the type of a parameter of a function type.
3816 * If a non-function type is passed in or the function does not have enough
3817 * parameters, an invalid type is returned.
3819 CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3822 * Retrieves the base type of the ObjCObjectType.
3824 * If the type is not an ObjC object, an invalid type is returned.
3826 CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3829 * Retrieve the number of protocol references associated with an ObjC object/id.
3831 * If the type is not an ObjC object, 0 is returned.
3833 CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3836 * Retrieve the decl for a protocol reference for an ObjC object/id.
3838 * If the type is not an ObjC object or there are not enough protocol
3839 * references, an invalid cursor is returned.
3841 CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3844 * Retrieve the number of type arguments associated with an ObjC object.
3846 * If the type is not an ObjC object, 0 is returned.
3848 CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3851 * Retrieve a type argument associated with an ObjC object.
3853 * If the type is not an ObjC or the index is not valid,
3854 * an invalid type is returned.
3856 CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3859 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3861 CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3864 * Retrieve the return type associated with a given cursor.
3866 * This only returns a valid type if the cursor refers to a function or method.
3868 CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3871 * Retrieve the exception specification type associated with a given cursor.
3872 * This is a value of type CXCursor_ExceptionSpecificationKind.
3874 * This only returns a valid result if the cursor refers to a function or
3875 * method.
3877 CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3880 * Return 1 if the CXType is a POD (plain old data) type, and 0
3881 * otherwise.
3883 CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3886 * Return the element type of an array, complex, or vector type.
3888 * If a type is passed in that is not an array, complex, or vector type,
3889 * an invalid type is returned.
3891 CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3894 * Return the number of elements of an array or vector type.
3896 * If a type is passed in that is not an array or vector type,
3897 * -1 is returned.
3899 CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3902 * Return the element type of an array type.
3904 * If a non-array type is passed in, an invalid type is returned.
3906 CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3909 * Return the array size of a constant array.
3911 * If a non-array type is passed in, -1 is returned.
3913 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3916 * Retrieve the type named by the qualified-id.
3918 * If a non-elaborated type is passed in, an invalid type is returned.
3920 CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3923 * Determine if a typedef is 'transparent' tag.
3925 * A typedef is considered 'transparent' if it shares a name and spelling
3926 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3928 * \returns non-zero if transparent and zero otherwise.
3930 CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3932 enum CXTypeNullabilityKind {
3934 * Values of this type can never be null.
3936 CXTypeNullability_NonNull = 0,
3938 * Values of this type can be null.
3940 CXTypeNullability_Nullable = 1,
3942 * Whether values of this type can be null is (explicitly)
3943 * unspecified. This captures a (fairly rare) case where we
3944 * can't conclude anything about the nullability of the type even
3945 * though it has been considered.
3947 CXTypeNullability_Unspecified = 2,
3949 * Nullability is not applicable to this type.
3951 CXTypeNullability_Invalid = 3,
3954 * Generally behaves like Nullable, except when used in a block parameter that
3955 * was imported into a swift async method. There, swift will assume that the
3956 * parameter can get null even if no error occurred. _Nullable parameters are
3957 * assumed to only get null on error.
3959 CXTypeNullability_NullableResult = 4
3963 * Retrieve the nullability kind of a pointer type.
3965 CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3968 * List the possible error codes for \c clang_Type_getSizeOf,
3969 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3970 * \c clang_Cursor_getOffsetOf.
3972 * A value of this enumeration type can be returned if the target type is not
3973 * a valid argument to sizeof, alignof or offsetof.
3975 enum CXTypeLayoutError {
3977 * Type is of kind CXType_Invalid.
3979 CXTypeLayoutError_Invalid = -1,
3981 * The type is an incomplete Type.
3983 CXTypeLayoutError_Incomplete = -2,
3985 * The type is a dependent Type.
3987 CXTypeLayoutError_Dependent = -3,
3989 * The type is not a constant size type.
3991 CXTypeLayoutError_NotConstantSize = -4,
3993 * The Field name is not valid for this record.
3995 CXTypeLayoutError_InvalidFieldName = -5,
3997 * The type is undeduced.
3999 CXTypeLayoutError_Undeduced = -6
4003 * Return the alignment of a type in bytes as per C++[expr.alignof]
4004 * standard.
4006 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
4007 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
4008 * is returned.
4009 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
4010 * returned.
4011 * If the type declaration is not a constant size type,
4012 * CXTypeLayoutError_NotConstantSize is returned.
4014 CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
4017 * Return the class type of an member pointer type.
4019 * If a non-member-pointer type is passed in, an invalid type is returned.
4021 CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
4024 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
4026 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
4027 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
4028 * is returned.
4029 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
4030 * returned.
4032 CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
4035 * Return the offset of a field named S in a record of type T in bits
4036 * as it would be returned by __offsetof__ as per C++11[18.2p4]
4038 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
4039 * is returned.
4040 * If the field's type declaration is an incomplete type,
4041 * CXTypeLayoutError_Incomplete is returned.
4042 * If the field's type declaration is a dependent type,
4043 * CXTypeLayoutError_Dependent is returned.
4044 * If the field's name S is not found,
4045 * CXTypeLayoutError_InvalidFieldName is returned.
4047 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
4050 * Return the type that was modified by this attributed type.
4052 * If the type is not an attributed type, an invalid type is returned.
4054 CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
4057 * Gets the type contained by this atomic type.
4059 * If a non-atomic type is passed in, an invalid type is returned.
4061 CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
4064 * Return the offset of the field represented by the Cursor.
4066 * If the cursor is not a field declaration, -1 is returned.
4067 * If the cursor semantic parent is not a record field declaration,
4068 * CXTypeLayoutError_Invalid is returned.
4069 * If the field's type declaration is an incomplete type,
4070 * CXTypeLayoutError_Incomplete is returned.
4071 * If the field's type declaration is a dependent type,
4072 * CXTypeLayoutError_Dependent is returned.
4073 * If the field's name S is not found,
4074 * CXTypeLayoutError_InvalidFieldName is returned.
4076 CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
4079 * Determine whether the given cursor represents an anonymous
4080 * tag or namespace
4082 CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
4085 * Determine whether the given cursor represents an anonymous record
4086 * declaration.
4088 CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
4091 * Determine whether the given cursor represents an inline namespace
4092 * declaration.
4094 CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
4096 enum CXRefQualifierKind {
4097 /** No ref-qualifier was provided. */
4098 CXRefQualifier_None = 0,
4099 /** An lvalue ref-qualifier was provided (\c &). */
4100 CXRefQualifier_LValue,
4101 /** An rvalue ref-qualifier was provided (\c &&). */
4102 CXRefQualifier_RValue
4106 * Returns the number of template arguments for given template
4107 * specialization, or -1 if type \c T is not a template specialization.
4109 CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
4112 * Returns the type template argument of a template class specialization
4113 * at given index.
4115 * This function only returns template type arguments and does not handle
4116 * template template arguments or variadic packs.
4118 CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
4119 unsigned i);
4122 * Retrieve the ref-qualifier kind of a function or method.
4124 * The ref-qualifier is returned for C++ functions or methods. For other types
4125 * or non-C++ declarations, CXRefQualifier_None is returned.
4127 CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
4130 * Returns non-zero if the cursor specifies a Record member that is a
4131 * bitfield.
4133 CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
4136 * Returns 1 if the base class specified by the cursor with kind
4137 * CX_CXXBaseSpecifier is virtual.
4139 CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
4142 * Represents the C++ access control level to a base class for a
4143 * cursor with kind CX_CXXBaseSpecifier.
4145 enum CX_CXXAccessSpecifier {
4146 CX_CXXInvalidAccessSpecifier,
4147 CX_CXXPublic,
4148 CX_CXXProtected,
4149 CX_CXXPrivate
4153 * Returns the access control level for the referenced object.
4155 * If the cursor refers to a C++ declaration, its access control level within
4156 * its parent scope is returned. Otherwise, if the cursor refers to a base
4157 * specifier or access specifier, the specifier itself is returned.
4159 CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
4162 * Represents the storage classes as declared in the source. CX_SC_Invalid
4163 * was added for the case that the passed cursor in not a declaration.
4165 enum CX_StorageClass {
4166 CX_SC_Invalid,
4167 CX_SC_None,
4168 CX_SC_Extern,
4169 CX_SC_Static,
4170 CX_SC_PrivateExtern,
4171 CX_SC_OpenCLWorkGroupLocal,
4172 CX_SC_Auto,
4173 CX_SC_Register
4177 * Returns the storage class for a function or variable declaration.
4179 * If the passed in Cursor is not a function or variable declaration,
4180 * CX_SC_Invalid is returned else the storage class.
4182 CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4185 * Determine the number of overloaded declarations referenced by a
4186 * \c CXCursor_OverloadedDeclRef cursor.
4188 * \param cursor The cursor whose overloaded declarations are being queried.
4190 * \returns The number of overloaded declarations referenced by \c cursor. If it
4191 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4193 CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
4196 * Retrieve a cursor for one of the overloaded declarations referenced
4197 * by a \c CXCursor_OverloadedDeclRef cursor.
4199 * \param cursor The cursor whose overloaded declarations are being queried.
4201 * \param index The zero-based index into the set of overloaded declarations in
4202 * the cursor.
4204 * \returns A cursor representing the declaration referenced by the given
4205 * \c cursor at the specified \c index. If the cursor does not have an
4206 * associated set of overloaded declarations, or if the index is out of bounds,
4207 * returns \c clang_getNullCursor();
4209 CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
4210 unsigned index);
4213 * @}
4217 * \defgroup CINDEX_ATTRIBUTES Information for attributes
4219 * @{
4223 * For cursors representing an iboutletcollection attribute,
4224 * this function returns the collection element type.
4227 CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
4230 * @}
4234 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4236 * These routines provide the ability to traverse the abstract syntax tree
4237 * using cursors.
4239 * @{
4243 * Describes how the traversal of the children of a particular
4244 * cursor should proceed after visiting a particular child cursor.
4246 * A value of this enumeration type should be returned by each
4247 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4249 enum CXChildVisitResult {
4251 * Terminates the cursor traversal.
4253 CXChildVisit_Break,
4255 * Continues the cursor traversal with the next sibling of
4256 * the cursor just visited, without visiting its children.
4258 CXChildVisit_Continue,
4260 * Recursively traverse the children of this cursor, using
4261 * the same visitor and client data.
4263 CXChildVisit_Recurse
4267 * Visitor invoked for each cursor found by a traversal.
4269 * This visitor function will be invoked for each cursor found by
4270 * clang_visitCursorChildren(). Its first argument is the cursor being
4271 * visited, its second argument is the parent visitor for that cursor,
4272 * and its third argument is the client data provided to
4273 * clang_visitCursorChildren().
4275 * The visitor should return one of the \c CXChildVisitResult values
4276 * to direct clang_visitCursorChildren().
4278 typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4279 CXCursor parent,
4280 CXClientData client_data);
4283 * Visit the children of a particular cursor.
4285 * This function visits all the direct children of the given cursor,
4286 * invoking the given \p visitor function with the cursors of each
4287 * visited child. The traversal may be recursive, if the visitor returns
4288 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4289 * the visitor returns \c CXChildVisit_Break.
4291 * \param parent the cursor whose child may be visited. All kinds of
4292 * cursors can be visited, including invalid cursors (which, by
4293 * definition, have no children).
4295 * \param visitor the visitor function that will be invoked for each
4296 * child of \p parent.
4298 * \param client_data pointer data supplied by the client, which will
4299 * be passed to the visitor each time it is invoked.
4301 * \returns a non-zero value if the traversal was terminated
4302 * prematurely by the visitor returning \c CXChildVisit_Break.
4304 CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
4305 CXCursorVisitor visitor,
4306 CXClientData client_data);
4307 #ifdef __has_feature
4308 #if __has_feature(blocks)
4310 * Visitor invoked for each cursor found by a traversal.
4312 * This visitor block will be invoked for each cursor found by
4313 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4314 * visited, its second argument is the parent visitor for that cursor.
4316 * The visitor should return one of the \c CXChildVisitResult values
4317 * to direct clang_visitChildrenWithBlock().
4319 typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
4320 CXCursor parent);
4323 * Visits the children of a cursor using the specified block. Behaves
4324 * identically to clang_visitChildren() in all other respects.
4326 CINDEX_LINKAGE unsigned
4327 clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
4328 #endif
4329 #endif
4332 * @}
4336 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4338 * These routines provide the ability to determine references within and
4339 * across translation units, by providing the names of the entities referenced
4340 * by cursors, follow reference cursors to the declarations they reference,
4341 * and associate declarations with their definitions.
4343 * @{
4347 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4348 * by the given cursor.
4350 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4351 * entity (function, class, variable, etc.) within a program. USRs can be
4352 * compared across translation units to determine, e.g., when references in
4353 * one translation refer to an entity defined in another translation unit.
4355 CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4358 * Construct a USR for a specified Objective-C class.
4360 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4363 * Construct a USR for a specified Objective-C category.
4365 CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
4366 const char *class_name, const char *category_name);
4369 * Construct a USR for a specified Objective-C protocol.
4371 CINDEX_LINKAGE CXString
4372 clang_constructUSR_ObjCProtocol(const char *protocol_name);
4375 * Construct a USR for a specified Objective-C instance variable and
4376 * the USR for its containing class.
4378 CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4379 CXString classUSR);
4382 * Construct a USR for a specified Objective-C method and
4383 * the USR for its containing class.
4385 CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4386 unsigned isInstanceMethod,
4387 CXString classUSR);
4390 * Construct a USR for a specified Objective-C property and the USR
4391 * for its containing class.
4393 CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4394 CXString classUSR);
4397 * Retrieve a name for the entity referenced by this cursor.
4399 CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4402 * Retrieve a range for a piece that forms the cursors spelling name.
4403 * Most of the times there is only one range for the complete spelling but for
4404 * Objective-C methods and Objective-C message expressions, there are multiple
4405 * pieces for each selector identifier.
4407 * \param pieceIndex the index of the spelling name piece. If this is greater
4408 * than the actual number of pieces, it will return a NULL (invalid) range.
4410 * \param options Reserved.
4412 CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
4413 CXCursor, unsigned pieceIndex, unsigned options);
4416 * Opaque pointer representing a policy that controls pretty printing
4417 * for \c clang_getCursorPrettyPrinted.
4419 typedef void *CXPrintingPolicy;
4422 * Properties for the printing policy.
4424 * See \c clang::PrintingPolicy for more information.
4426 enum CXPrintingPolicyProperty {
4427 CXPrintingPolicy_Indentation,
4428 CXPrintingPolicy_SuppressSpecifiers,
4429 CXPrintingPolicy_SuppressTagKeyword,
4430 CXPrintingPolicy_IncludeTagDefinition,
4431 CXPrintingPolicy_SuppressScope,
4432 CXPrintingPolicy_SuppressUnwrittenScope,
4433 CXPrintingPolicy_SuppressInitializers,
4434 CXPrintingPolicy_ConstantArraySizeAsWritten,
4435 CXPrintingPolicy_AnonymousTagLocations,
4436 CXPrintingPolicy_SuppressStrongLifetime,
4437 CXPrintingPolicy_SuppressLifetimeQualifiers,
4438 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4439 CXPrintingPolicy_Bool,
4440 CXPrintingPolicy_Restrict,
4441 CXPrintingPolicy_Alignof,
4442 CXPrintingPolicy_UnderscoreAlignof,
4443 CXPrintingPolicy_UseVoidForZeroParams,
4444 CXPrintingPolicy_TerseOutput,
4445 CXPrintingPolicy_PolishForDeclaration,
4446 CXPrintingPolicy_Half,
4447 CXPrintingPolicy_MSWChar,
4448 CXPrintingPolicy_IncludeNewlines,
4449 CXPrintingPolicy_MSVCFormatting,
4450 CXPrintingPolicy_ConstantsAsWritten,
4451 CXPrintingPolicy_SuppressImplicitBase,
4452 CXPrintingPolicy_FullyQualifiedName,
4454 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4458 * Get a property value for the given printing policy.
4460 CINDEX_LINKAGE unsigned
4461 clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4462 enum CXPrintingPolicyProperty Property);
4465 * Set a property value for the given printing policy.
4467 CINDEX_LINKAGE void
4468 clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4469 enum CXPrintingPolicyProperty Property,
4470 unsigned Value);
4473 * Retrieve the default policy for the cursor.
4475 * The policy should be released after use with \c
4476 * clang_PrintingPolicy_dispose.
4478 CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4481 * Release a printing policy.
4483 CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4486 * Pretty print declarations.
4488 * \param Cursor The cursor representing a declaration.
4490 * \param Policy The policy to control the entities being printed. If
4491 * NULL, a default policy is used.
4493 * \returns The pretty printed declaration or the empty string for
4494 * other cursors.
4496 CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4497 CXPrintingPolicy Policy);
4500 * Retrieve the display name for the entity referenced by this cursor.
4502 * The display name contains extra information that helps identify the cursor,
4503 * such as the parameters of a function or template or the arguments of a
4504 * class template specialization.
4506 CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
4508 /** For a cursor that is a reference, retrieve a cursor representing the
4509 * entity that it references.
4511 * Reference cursors refer to other entities in the AST. For example, an
4512 * Objective-C superclass reference cursor refers to an Objective-C class.
4513 * This function produces the cursor for the Objective-C class from the
4514 * cursor for the superclass reference. If the input cursor is a declaration or
4515 * definition, it returns that declaration or definition unchanged.
4516 * Otherwise, returns the NULL cursor.
4518 CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
4521 * For a cursor that is either a reference to or a declaration
4522 * of some entity, retrieve a cursor that describes the definition of
4523 * that entity.
4525 * Some entities can be declared multiple times within a translation
4526 * unit, but only one of those declarations can also be a
4527 * definition. For example, given:
4529 * \code
4530 * int f(int, int);
4531 * int g(int x, int y) { return f(x, y); }
4532 * int f(int a, int b) { return a + b; }
4533 * int f(int, int);
4534 * \endcode
4536 * there are three declarations of the function "f", but only the
4537 * second one is a definition. The clang_getCursorDefinition()
4538 * function will take any cursor pointing to a declaration of "f"
4539 * (the first or fourth lines of the example) or a cursor referenced
4540 * that uses "f" (the call to "f' inside "g") and will return a
4541 * declaration cursor pointing to the definition (the second "f"
4542 * declaration).
4544 * If given a cursor for which there is no corresponding definition,
4545 * e.g., because there is no definition of that entity within this
4546 * translation unit, returns a NULL cursor.
4548 CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4551 * Determine whether the declaration pointed to by this cursor
4552 * is also a definition of that entity.
4554 CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4557 * Retrieve the canonical cursor corresponding to the given cursor.
4559 * In the C family of languages, many kinds of entities can be declared several
4560 * times within a single translation unit. For example, a structure type can
4561 * be forward-declared (possibly multiple times) and later defined:
4563 * \code
4564 * struct X;
4565 * struct X;
4566 * struct X {
4567 * int member;
4568 * };
4569 * \endcode
4571 * The declarations and the definition of \c X are represented by three
4572 * different cursors, all of which are declarations of the same underlying
4573 * entity. One of these cursor is considered the "canonical" cursor, which
4574 * is effectively the representative for the underlying entity. One can
4575 * determine if two cursors are declarations of the same underlying entity by
4576 * comparing their canonical cursors.
4578 * \returns The canonical cursor for the entity referred to by the given cursor.
4580 CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4583 * If the cursor points to a selector identifier in an Objective-C
4584 * method or message expression, this returns the selector index.
4586 * After getting a cursor with #clang_getCursor, this can be called to
4587 * determine if the location points to a selector identifier.
4589 * \returns The selector index if the cursor is an Objective-C method or message
4590 * expression and the cursor is pointing to a selector identifier, or -1
4591 * otherwise.
4593 CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4596 * Given a cursor pointing to a C++ method call or an Objective-C
4597 * message, returns non-zero if the method/message is "dynamic", meaning:
4599 * For a C++ method: the call is virtual.
4600 * For an Objective-C message: the receiver is an object instance, not 'super'
4601 * or a specific class.
4603 * If the method/message is "static" or the cursor does not point to a
4604 * method/message, it will return zero.
4606 CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4609 * Given a cursor pointing to an Objective-C message or property
4610 * reference, or C++ method call, returns the CXType of the receiver.
4612 CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4615 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4617 typedef enum {
4618 CXObjCPropertyAttr_noattr = 0x00,
4619 CXObjCPropertyAttr_readonly = 0x01,
4620 CXObjCPropertyAttr_getter = 0x02,
4621 CXObjCPropertyAttr_assign = 0x04,
4622 CXObjCPropertyAttr_readwrite = 0x08,
4623 CXObjCPropertyAttr_retain = 0x10,
4624 CXObjCPropertyAttr_copy = 0x20,
4625 CXObjCPropertyAttr_nonatomic = 0x40,
4626 CXObjCPropertyAttr_setter = 0x80,
4627 CXObjCPropertyAttr_atomic = 0x100,
4628 CXObjCPropertyAttr_weak = 0x200,
4629 CXObjCPropertyAttr_strong = 0x400,
4630 CXObjCPropertyAttr_unsafe_unretained = 0x800,
4631 CXObjCPropertyAttr_class = 0x1000
4632 } CXObjCPropertyAttrKind;
4635 * Given a cursor that represents a property declaration, return the
4636 * associated property attributes. The bits are formed from
4637 * \c CXObjCPropertyAttrKind.
4639 * \param reserved Reserved for future use, pass 0.
4641 CINDEX_LINKAGE unsigned
4642 clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
4645 * Given a cursor that represents a property declaration, return the
4646 * name of the method that implements the getter.
4648 CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4651 * Given a cursor that represents a property declaration, return the
4652 * name of the method that implements the setter, if any.
4654 CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4657 * 'Qualifiers' written next to the return and parameter types in
4658 * Objective-C method declarations.
4660 typedef enum {
4661 CXObjCDeclQualifier_None = 0x0,
4662 CXObjCDeclQualifier_In = 0x1,
4663 CXObjCDeclQualifier_Inout = 0x2,
4664 CXObjCDeclQualifier_Out = 0x4,
4665 CXObjCDeclQualifier_Bycopy = 0x8,
4666 CXObjCDeclQualifier_Byref = 0x10,
4667 CXObjCDeclQualifier_Oneway = 0x20
4668 } CXObjCDeclQualifierKind;
4671 * Given a cursor that represents an Objective-C method or parameter
4672 * declaration, return the associated Objective-C qualifiers for the return
4673 * type or the parameter respectively. The bits are formed from
4674 * CXObjCDeclQualifierKind.
4676 CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4679 * Given a cursor that represents an Objective-C method or property
4680 * declaration, return non-zero if the declaration was affected by "\@optional".
4681 * Returns zero if the cursor is not such a declaration or it is "\@required".
4683 CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4686 * Returns non-zero if the given cursor is a variadic function or method.
4688 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4691 * Returns non-zero if the given cursor points to a symbol marked with
4692 * external_source_symbol attribute.
4694 * \param language If non-NULL, and the attribute is present, will be set to
4695 * the 'language' string from the attribute.
4697 * \param definedIn If non-NULL, and the attribute is present, will be set to
4698 * the 'definedIn' string from the attribute.
4700 * \param isGenerated If non-NULL, and the attribute is present, will be set to
4701 * non-zero if the 'generated_declaration' is set in the attribute.
4703 CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4704 CXString *language,
4705 CXString *definedIn,
4706 unsigned *isGenerated);
4709 * Given a cursor that represents a declaration, return the associated
4710 * comment's source range. The range may include multiple consecutive comments
4711 * with whitespace in between.
4713 CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4716 * Given a cursor that represents a declaration, return the associated
4717 * comment text, including comment markers.
4719 CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4722 * Given a cursor that represents a documentable entity (e.g.,
4723 * declaration), return the associated \paragraph; otherwise return the
4724 * first paragraph.
4726 CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4729 * @}
4732 /** \defgroup CINDEX_MANGLE Name Mangling API Functions
4734 * @{
4738 * Retrieve the CXString representing the mangled name of the cursor.
4740 CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4743 * Retrieve the CXStrings representing the mangled symbols of the C++
4744 * constructor or destructor at the cursor.
4746 CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4749 * Retrieve the CXStrings representing the mangled symbols of the ObjC
4750 * class interface or implementation at the cursor.
4752 CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4755 * @}
4759 * \defgroup CINDEX_MODULE Module introspection
4761 * The functions in this group provide access to information about modules.
4763 * @{
4766 typedef void *CXModule;
4769 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4771 CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4774 * Given a CXFile header file, return the module that contains it, if one
4775 * exists.
4777 CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4780 * \param Module a module object.
4782 * \returns the module file where the provided module object came from.
4784 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4787 * \param Module a module object.
4789 * \returns the parent of a sub-module or NULL if the given module is top-level,
4790 * e.g. for 'std.vector' it will return the 'std' module.
4792 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4795 * \param Module a module object.
4797 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4798 * will return "vector".
4800 CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4803 * \param Module a module object.
4805 * \returns the full name of the module, e.g. "std.vector".
4807 CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4810 * \param Module a module object.
4812 * \returns non-zero if the module is a system one.
4814 CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4817 * \param Module a module object.
4819 * \returns the number of top level headers associated with this module.
4821 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4822 CXModule Module);
4825 * \param Module a module object.
4827 * \param Index top level header index (zero-based).
4829 * \returns the specified top level header associated with the module.
4831 CINDEX_LINKAGE
4832 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
4833 unsigned Index);
4836 * @}
4840 * \defgroup CINDEX_CPP C++ AST introspection
4842 * The routines in this group provide access information in the ASTs specific
4843 * to C++ language features.
4845 * @{
4849 * Determine if a C++ constructor is a converting constructor.
4851 CINDEX_LINKAGE unsigned
4852 clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4855 * Determine if a C++ constructor is a copy constructor.
4857 CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4860 * Determine if a C++ constructor is the default constructor.
4862 CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4865 * Determine if a C++ constructor is a move constructor.
4867 CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4870 * Determine if a C++ field is declared 'mutable'.
4872 CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4875 * Determine if a C++ method is declared '= default'.
4877 CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4880 * Determine if a C++ member function or member function template is
4881 * pure virtual.
4883 CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4886 * Determine if a C++ member function or member function template is
4887 * declared 'static'.
4889 CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4892 * Determine if a C++ member function or member function template is
4893 * explicitly declared 'virtual' or if it overrides a virtual method from
4894 * one of the base classes.
4896 CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4899 * Determine if a C++ record is abstract, i.e. whether a class or struct
4900 * has a pure virtual member function.
4902 CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4905 * Determine if an enum declaration refers to a scoped enum.
4907 CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4910 * Determine if a C++ member function or member function template is
4911 * declared 'const'.
4913 CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4916 * Given a cursor that represents a template, determine
4917 * the cursor kind of the specializations would be generated by instantiating
4918 * the template.
4920 * This routine can be used to determine what flavor of function template,
4921 * class template, or class template partial specialization is stored in the
4922 * cursor. For example, it can describe whether a class template cursor is
4923 * declared with "struct", "class" or "union".
4925 * \param C The cursor to query. This cursor should represent a template
4926 * declaration.
4928 * \returns The cursor kind of the specializations that would be generated
4929 * by instantiating the template \p C. If \p C is not a template, returns
4930 * \c CXCursor_NoDeclFound.
4932 CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4935 * Given a cursor that may represent a specialization or instantiation
4936 * of a template, retrieve the cursor that represents the template that it
4937 * specializes or from which it was instantiated.
4939 * This routine determines the template involved both for explicit
4940 * specializations of templates and for implicit instantiations of the template,
4941 * both of which are referred to as "specializations". For a class template
4942 * specialization (e.g., \c std::vector<bool>), this routine will return
4943 * either the primary template (\c std::vector) or, if the specialization was
4944 * instantiated from a class template partial specialization, the class template
4945 * partial specialization. For a class template partial specialization and a
4946 * function template specialization (including instantiations), this
4947 * this routine will return the specialized template.
4949 * For members of a class template (e.g., member functions, member classes, or
4950 * static data members), returns the specialized or instantiated member.
4951 * Although not strictly "templates" in the C++ language, members of class
4952 * templates have the same notions of specializations and instantiations that
4953 * templates do, so this routine treats them similarly.
4955 * \param C A cursor that may be a specialization of a template or a member
4956 * of a template.
4958 * \returns If the given cursor is a specialization or instantiation of a
4959 * template or a member thereof, the template or member that it specializes or
4960 * from which it was instantiated. Otherwise, returns a NULL cursor.
4962 CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4965 * Given a cursor that references something else, return the source range
4966 * covering that reference.
4968 * \param C A cursor pointing to a member reference, a declaration reference, or
4969 * an operator call.
4970 * \param NameFlags A bitset with three independent flags:
4971 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4972 * CXNameRange_WantSinglePiece.
4973 * \param PieceIndex For contiguous names or when passing the flag
4974 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4975 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4976 * non-contiguous names, this index can be used to retrieve the individual
4977 * pieces of the name. See also CXNameRange_WantSinglePiece.
4979 * \returns The piece of the name pointed to by the given cursor. If there is no
4980 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4982 CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
4983 CXCursor C, unsigned NameFlags, unsigned PieceIndex);
4985 enum CXNameRefFlags {
4987 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4988 * range.
4990 CXNameRange_WantQualifier = 0x1,
4993 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
4994 * in the range.
4996 CXNameRange_WantTemplateArgs = 0x2,
4999 * If the name is non-contiguous, return the full spanning range.
5001 * Non-contiguous names occur in Objective-C when a selector with two or more
5002 * parameters is used, or in C++ when using an operator:
5003 * \code
5004 * [object doSomething:here withValue:there]; // Objective-C
5005 * return some_vector[1]; // C++
5006 * \endcode
5008 CXNameRange_WantSinglePiece = 0x4
5012 * @}
5016 * \defgroup CINDEX_LEX Token extraction and manipulation
5018 * The routines in this group provide access to the tokens within a
5019 * translation unit, along with a semantic mapping of those tokens to
5020 * their corresponding cursors.
5022 * @{
5026 * Describes a kind of token.
5028 typedef enum CXTokenKind {
5030 * A token that contains some kind of punctuation.
5032 CXToken_Punctuation,
5035 * A language keyword.
5037 CXToken_Keyword,
5040 * An identifier (that is not a keyword).
5042 CXToken_Identifier,
5045 * A numeric, string, or character literal.
5047 CXToken_Literal,
5050 * A comment.
5052 CXToken_Comment
5053 } CXTokenKind;
5056 * Describes a single preprocessing token.
5058 typedef struct {
5059 unsigned int_data[4];
5060 void *ptr_data;
5061 } CXToken;
5064 * Get the raw lexical token starting with the given location.
5066 * \param TU the translation unit whose text is being tokenized.
5068 * \param Location the source location with which the token starts.
5070 * \returns The token starting with the given location or NULL if no such token
5071 * exist. The returned pointer must be freed with clang_disposeTokens before the
5072 * translation unit is destroyed.
5074 CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
5075 CXSourceLocation Location);
5078 * Determine the kind of the given token.
5080 CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
5083 * Determine the spelling of the given token.
5085 * The spelling of a token is the textual representation of that token, e.g.,
5086 * the text of an identifier or keyword.
5088 CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
5091 * Retrieve the source location of the given token.
5093 CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
5094 CXToken);
5097 * Retrieve a source range that covers the given token.
5099 CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
5102 * Tokenize the source code described by the given range into raw
5103 * lexical tokens.
5105 * \param TU the translation unit whose text is being tokenized.
5107 * \param Range the source range in which text should be tokenized. All of the
5108 * tokens produced by tokenization will fall within this source range,
5110 * \param Tokens this pointer will be set to point to the array of tokens
5111 * that occur within the given source range. The returned pointer must be
5112 * freed with clang_disposeTokens() before the translation unit is destroyed.
5114 * \param NumTokens will be set to the number of tokens in the \c *Tokens
5115 * array.
5118 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
5119 CXToken **Tokens, unsigned *NumTokens);
5122 * Annotate the given set of tokens by providing cursors for each token
5123 * that can be mapped to a specific entity within the abstract syntax tree.
5125 * This token-annotation routine is equivalent to invoking
5126 * clang_getCursor() for the source locations of each of the
5127 * tokens. The cursors provided are filtered, so that only those
5128 * cursors that have a direct correspondence to the token are
5129 * accepted. For example, given a function call \c f(x),
5130 * clang_getCursor() would provide the following cursors:
5132 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
5133 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
5134 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
5136 * Only the first and last of these cursors will occur within the
5137 * annotate, since the tokens "f" and "x' directly refer to a function
5138 * and a variable, respectively, but the parentheses are just a small
5139 * part of the full syntax of the function call expression, which is
5140 * not provided as an annotation.
5142 * \param TU the translation unit that owns the given tokens.
5144 * \param Tokens the set of tokens to annotate.
5146 * \param NumTokens the number of tokens in \p Tokens.
5148 * \param Cursors an array of \p NumTokens cursors, whose contents will be
5149 * replaced with the cursors corresponding to each token.
5151 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
5152 unsigned NumTokens, CXCursor *Cursors);
5155 * Free the given set of tokens.
5157 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
5158 unsigned NumTokens);
5161 * @}
5165 * \defgroup CINDEX_DEBUG Debugging facilities
5167 * These routines are used for testing and debugging, only, and should not
5168 * be relied upon.
5170 * @{
5173 /* for debug/testing */
5174 CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
5175 CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
5176 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
5177 unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
5178 CINDEX_LINKAGE void clang_enableStackTraces(void);
5179 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
5180 unsigned stack_size);
5183 * @}
5187 * \defgroup CINDEX_CODE_COMPLET Code completion
5189 * Code completion involves taking an (incomplete) source file, along with
5190 * knowledge of where the user is actively editing that file, and suggesting
5191 * syntactically- and semantically-valid constructs that the user might want to
5192 * use at that particular point in the source code. These data structures and
5193 * routines provide support for code completion.
5195 * @{
5199 * A semantic string that describes a code-completion result.
5201 * A semantic string that describes the formatting of a code-completion
5202 * result as a single "template" of text that should be inserted into the
5203 * source buffer when a particular code-completion result is selected.
5204 * Each semantic string is made up of some number of "chunks", each of which
5205 * contains some text along with a description of what that text means, e.g.,
5206 * the name of the entity being referenced, whether the text chunk is part of
5207 * the template, or whether it is a "placeholder" that the user should replace
5208 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
5209 * description of the different kinds of chunks.
5211 typedef void *CXCompletionString;
5214 * A single result of code completion.
5216 typedef struct {
5218 * The kind of entity that this completion refers to.
5220 * The cursor kind will be a macro, keyword, or a declaration (one of the
5221 * *Decl cursor kinds), describing the entity that the completion is
5222 * referring to.
5224 * \todo In the future, we would like to provide a full cursor, to allow
5225 * the client to extract additional information from declaration.
5227 enum CXCursorKind CursorKind;
5230 * The code-completion string that describes how to insert this
5231 * code-completion result into the editing buffer.
5233 CXCompletionString CompletionString;
5234 } CXCompletionResult;
5237 * Describes a single piece of text within a code-completion string.
5239 * Each "chunk" within a code-completion string (\c CXCompletionString) is
5240 * either a piece of text with a specific "kind" that describes how that text
5241 * should be interpreted by the client or is another completion string.
5243 enum CXCompletionChunkKind {
5245 * A code-completion string that describes "optional" text that
5246 * could be a part of the template (but is not required).
5248 * The Optional chunk is the only kind of chunk that has a code-completion
5249 * string for its representation, which is accessible via
5250 * \c clang_getCompletionChunkCompletionString(). The code-completion string
5251 * describes an additional part of the template that is completely optional.
5252 * For example, optional chunks can be used to describe the placeholders for
5253 * arguments that match up with defaulted function parameters, e.g. given:
5255 * \code
5256 * void f(int x, float y = 3.14, double z = 2.71828);
5257 * \endcode
5259 * The code-completion string for this function would contain:
5260 * - a TypedText chunk for "f".
5261 * - a LeftParen chunk for "(".
5262 * - a Placeholder chunk for "int x"
5263 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
5264 * - a Comma chunk for ","
5265 * - a Placeholder chunk for "float y"
5266 * - an Optional chunk containing the last defaulted argument:
5267 * - a Comma chunk for ","
5268 * - a Placeholder chunk for "double z"
5269 * - a RightParen chunk for ")"
5271 * There are many ways to handle Optional chunks. Two simple approaches are:
5272 * - Completely ignore optional chunks, in which case the template for the
5273 * function "f" would only include the first parameter ("int x").
5274 * - Fully expand all optional chunks, in which case the template for the
5275 * function "f" would have all of the parameters.
5277 CXCompletionChunk_Optional,
5279 * Text that a user would be expected to type to get this
5280 * code-completion result.
5282 * There will be exactly one "typed text" chunk in a semantic string, which
5283 * will typically provide the spelling of a keyword or the name of a
5284 * declaration that could be used at the current code point. Clients are
5285 * expected to filter the code-completion results based on the text in this
5286 * chunk.
5288 CXCompletionChunk_TypedText,
5290 * Text that should be inserted as part of a code-completion result.
5292 * A "text" chunk represents text that is part of the template to be
5293 * inserted into user code should this particular code-completion result
5294 * be selected.
5296 CXCompletionChunk_Text,
5298 * Placeholder text that should be replaced by the user.
5300 * A "placeholder" chunk marks a place where the user should insert text
5301 * into the code-completion template. For example, placeholders might mark
5302 * the function parameters for a function declaration, to indicate that the
5303 * user should provide arguments for each of those parameters. The actual
5304 * text in a placeholder is a suggestion for the text to display before
5305 * the user replaces the placeholder with real code.
5307 CXCompletionChunk_Placeholder,
5309 * Informative text that should be displayed but never inserted as
5310 * part of the template.
5312 * An "informative" chunk contains annotations that can be displayed to
5313 * help the user decide whether a particular code-completion result is the
5314 * right option, but which is not part of the actual template to be inserted
5315 * by code completion.
5317 CXCompletionChunk_Informative,
5319 * Text that describes the current parameter when code-completion is
5320 * referring to function call, message send, or template specialization.
5322 * A "current parameter" chunk occurs when code-completion is providing
5323 * information about a parameter corresponding to the argument at the
5324 * code-completion point. For example, given a function
5326 * \code
5327 * int add(int x, int y);
5328 * \endcode
5330 * and the source code \c add(, where the code-completion point is after the
5331 * "(", the code-completion string will contain a "current parameter" chunk
5332 * for "int x", indicating that the current argument will initialize that
5333 * parameter. After typing further, to \c add(17, (where the code-completion
5334 * point is after the ","), the code-completion string will contain a
5335 * "current parameter" chunk to "int y".
5337 CXCompletionChunk_CurrentParameter,
5339 * A left parenthesis ('('), used to initiate a function call or
5340 * signal the beginning of a function parameter list.
5342 CXCompletionChunk_LeftParen,
5344 * A right parenthesis (')'), used to finish a function call or
5345 * signal the end of a function parameter list.
5347 CXCompletionChunk_RightParen,
5349 * A left bracket ('[').
5351 CXCompletionChunk_LeftBracket,
5353 * A right bracket (']').
5355 CXCompletionChunk_RightBracket,
5357 * A left brace ('{').
5359 CXCompletionChunk_LeftBrace,
5361 * A right brace ('}').
5363 CXCompletionChunk_RightBrace,
5365 * A left angle bracket ('<').
5367 CXCompletionChunk_LeftAngle,
5369 * A right angle bracket ('>').
5371 CXCompletionChunk_RightAngle,
5373 * A comma separator (',').
5375 CXCompletionChunk_Comma,
5377 * Text that specifies the result type of a given result.
5379 * This special kind of informative chunk is not meant to be inserted into
5380 * the text buffer. Rather, it is meant to illustrate the type that an
5381 * expression using the given completion string would have.
5383 CXCompletionChunk_ResultType,
5385 * A colon (':').
5387 CXCompletionChunk_Colon,
5389 * A semicolon (';').
5391 CXCompletionChunk_SemiColon,
5393 * An '=' sign.
5395 CXCompletionChunk_Equal,
5397 * Horizontal space (' ').
5399 CXCompletionChunk_HorizontalSpace,
5401 * Vertical space ('\\n'), after which it is generally a good idea to
5402 * perform indentation.
5404 CXCompletionChunk_VerticalSpace
5408 * Determine the kind of a particular chunk within a completion string.
5410 * \param completion_string the completion string to query.
5412 * \param chunk_number the 0-based index of the chunk in the completion string.
5414 * \returns the kind of the chunk at the index \c chunk_number.
5416 CINDEX_LINKAGE enum CXCompletionChunkKind
5417 clang_getCompletionChunkKind(CXCompletionString completion_string,
5418 unsigned chunk_number);
5421 * Retrieve the text associated with a particular chunk within a
5422 * completion string.
5424 * \param completion_string the completion string to query.
5426 * \param chunk_number the 0-based index of the chunk in the completion string.
5428 * \returns the text associated with the chunk at index \c chunk_number.
5430 CINDEX_LINKAGE CXString clang_getCompletionChunkText(
5431 CXCompletionString completion_string, unsigned chunk_number);
5434 * Retrieve the completion string associated with a particular chunk
5435 * within a completion string.
5437 * \param completion_string the completion string to query.
5439 * \param chunk_number the 0-based index of the chunk in the completion string.
5441 * \returns the completion string associated with the chunk at index
5442 * \c chunk_number.
5444 CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
5445 CXCompletionString completion_string, unsigned chunk_number);
5448 * Retrieve the number of chunks in the given code-completion string.
5450 CINDEX_LINKAGE unsigned
5451 clang_getNumCompletionChunks(CXCompletionString completion_string);
5454 * Determine the priority of this code completion.
5456 * The priority of a code completion indicates how likely it is that this
5457 * particular completion is the completion that the user will select. The
5458 * priority is selected by various internal heuristics.
5460 * \param completion_string The completion string to query.
5462 * \returns The priority of this completion string. Smaller values indicate
5463 * higher-priority (more likely) completions.
5465 CINDEX_LINKAGE unsigned
5466 clang_getCompletionPriority(CXCompletionString completion_string);
5469 * Determine the availability of the entity that this code-completion
5470 * string refers to.
5472 * \param completion_string The completion string to query.
5474 * \returns The availability of the completion string.
5476 CINDEX_LINKAGE enum CXAvailabilityKind
5477 clang_getCompletionAvailability(CXCompletionString completion_string);
5480 * Retrieve the number of annotations associated with the given
5481 * completion string.
5483 * \param completion_string the completion string to query.
5485 * \returns the number of annotations associated with the given completion
5486 * string.
5488 CINDEX_LINKAGE unsigned
5489 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5492 * Retrieve the annotation associated with the given completion string.
5494 * \param completion_string the completion string to query.
5496 * \param annotation_number the 0-based index of the annotation of the
5497 * completion string.
5499 * \returns annotation string associated with the completion at index
5500 * \c annotation_number, or a NULL string if that annotation is not available.
5502 CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
5503 CXCompletionString completion_string, unsigned annotation_number);
5506 * Retrieve the parent context of the given completion string.
5508 * The parent context of a completion string is the semantic parent of
5509 * the declaration (if any) that the code completion represents. For example,
5510 * a code completion for an Objective-C method would have the method's class
5511 * or protocol as its context.
5513 * \param completion_string The code completion string whose parent is
5514 * being queried.
5516 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5518 * \returns The name of the completion parent, e.g., "NSObject" if
5519 * the completion string represents a method in the NSObject class.
5521 CINDEX_LINKAGE CXString clang_getCompletionParent(
5522 CXCompletionString completion_string, enum CXCursorKind *kind);
5525 * Retrieve the brief documentation comment attached to the declaration
5526 * that corresponds to the given completion string.
5528 CINDEX_LINKAGE CXString
5529 clang_getCompletionBriefComment(CXCompletionString completion_string);
5532 * Retrieve a completion string for an arbitrary declaration or macro
5533 * definition cursor.
5535 * \param cursor The cursor to query.
5537 * \returns A non-context-sensitive completion string for declaration and macro
5538 * definition cursors, or NULL for other kinds of cursors.
5540 CINDEX_LINKAGE CXCompletionString
5541 clang_getCursorCompletionString(CXCursor cursor);
5544 * Contains the results of code-completion.
5546 * This data structure contains the results of code completion, as
5547 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5548 * \c clang_disposeCodeCompleteResults.
5550 typedef struct {
5552 * The code-completion results.
5554 CXCompletionResult *Results;
5557 * The number of code-completion results stored in the
5558 * \c Results array.
5560 unsigned NumResults;
5561 } CXCodeCompleteResults;
5564 * Retrieve the number of fix-its for the given completion index.
5566 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5567 * option was set.
5569 * \param results The structure keeping all completion results
5571 * \param completion_index The index of the completion
5573 * \return The number of fix-its which must be applied before the completion at
5574 * completion_index can be applied
5576 CINDEX_LINKAGE unsigned
5577 clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5578 unsigned completion_index);
5581 * Fix-its that *must* be applied before inserting the text for the
5582 * corresponding completion.
5584 * By default, clang_codeCompleteAt() only returns completions with empty
5585 * fix-its. Extra completions with non-empty fix-its should be explicitly
5586 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5588 * For the clients to be able to compute position of the cursor after applying
5589 * fix-its, the following conditions are guaranteed to hold for
5590 * replacement_range of the stored fix-its:
5591 * - Ranges in the fix-its are guaranteed to never contain the completion
5592 * point (or identifier under completion point, if any) inside them, except
5593 * at the start or at the end of the range.
5594 * - If a fix-it range starts or ends with completion point (or starts or
5595 * ends after the identifier under completion point), it will contain at
5596 * least one character. It allows to unambiguously recompute completion
5597 * point after applying the fix-it.
5599 * The intuition is that provided fix-its change code around the identifier we
5600 * complete, but are not allowed to touch the identifier itself or the
5601 * completion point. One example of completions with corrections are the ones
5602 * replacing '.' with '->' and vice versa:
5604 * std::unique_ptr<std::vector<int>> vec_ptr;
5605 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5606 * replacing '.' with '->'.
5607 * In 'vec_ptr->^', one of the completions is 'release', it requires
5608 * replacing '->' with '.'.
5610 * \param results The structure keeping all completion results
5612 * \param completion_index The index of the completion
5614 * \param fixit_index The index of the fix-it for the completion at
5615 * completion_index
5617 * \param replacement_range The fix-it range that must be replaced before the
5618 * completion at completion_index can be applied
5620 * \returns The fix-it string that must replace the code at replacement_range
5621 * before the completion at completion_index can be applied
5623 CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5624 CXCodeCompleteResults *results, unsigned completion_index,
5625 unsigned fixit_index, CXSourceRange *replacement_range);
5628 * Flags that can be passed to \c clang_codeCompleteAt() to
5629 * modify its behavior.
5631 * The enumerators in this enumeration can be bitwise-OR'd together to
5632 * provide multiple options to \c clang_codeCompleteAt().
5634 enum CXCodeComplete_Flags {
5636 * Whether to include macros within the set of code
5637 * completions returned.
5639 CXCodeComplete_IncludeMacros = 0x01,
5642 * Whether to include code patterns for language constructs
5643 * within the set of code completions, e.g., for loops.
5645 CXCodeComplete_IncludeCodePatterns = 0x02,
5648 * Whether to include brief documentation within the set of code
5649 * completions returned.
5651 CXCodeComplete_IncludeBriefComments = 0x04,
5654 * Whether to speed up completion by omitting top- or namespace-level entities
5655 * defined in the preamble. There's no guarantee any particular entity is
5656 * omitted. This may be useful if the headers are indexed externally.
5658 CXCodeComplete_SkipPreamble = 0x08,
5661 * Whether to include completions with small
5662 * fix-its, e.g. change '.' to '->' on member access, etc.
5664 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
5668 * Bits that represent the context under which completion is occurring.
5670 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5671 * contexts are occurring simultaneously.
5673 enum CXCompletionContext {
5675 * The context for completions is unexposed, as only Clang results
5676 * should be included. (This is equivalent to having no context bits set.)
5678 CXCompletionContext_Unexposed = 0,
5681 * Completions for any possible type should be included in the results.
5683 CXCompletionContext_AnyType = 1 << 0,
5686 * Completions for any possible value (variables, function calls, etc.)
5687 * should be included in the results.
5689 CXCompletionContext_AnyValue = 1 << 1,
5691 * Completions for values that resolve to an Objective-C object should
5692 * be included in the results.
5694 CXCompletionContext_ObjCObjectValue = 1 << 2,
5696 * Completions for values that resolve to an Objective-C selector
5697 * should be included in the results.
5699 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5701 * Completions for values that resolve to a C++ class type should be
5702 * included in the results.
5704 CXCompletionContext_CXXClassTypeValue = 1 << 4,
5707 * Completions for fields of the member being accessed using the dot
5708 * operator should be included in the results.
5710 CXCompletionContext_DotMemberAccess = 1 << 5,
5712 * Completions for fields of the member being accessed using the arrow
5713 * operator should be included in the results.
5715 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5717 * Completions for properties of the Objective-C object being accessed
5718 * using the dot operator should be included in the results.
5720 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5723 * Completions for enum tags should be included in the results.
5725 CXCompletionContext_EnumTag = 1 << 8,
5727 * Completions for union tags should be included in the results.
5729 CXCompletionContext_UnionTag = 1 << 9,
5731 * Completions for struct tags should be included in the results.
5733 CXCompletionContext_StructTag = 1 << 10,
5736 * Completions for C++ class names should be included in the results.
5738 CXCompletionContext_ClassTag = 1 << 11,
5740 * Completions for C++ namespaces and namespace aliases should be
5741 * included in the results.
5743 CXCompletionContext_Namespace = 1 << 12,
5745 * Completions for C++ nested name specifiers should be included in
5746 * the results.
5748 CXCompletionContext_NestedNameSpecifier = 1 << 13,
5751 * Completions for Objective-C interfaces (classes) should be included
5752 * in the results.
5754 CXCompletionContext_ObjCInterface = 1 << 14,
5756 * Completions for Objective-C protocols should be included in
5757 * the results.
5759 CXCompletionContext_ObjCProtocol = 1 << 15,
5761 * Completions for Objective-C categories should be included in
5762 * the results.
5764 CXCompletionContext_ObjCCategory = 1 << 16,
5766 * Completions for Objective-C instance messages should be included
5767 * in the results.
5769 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5771 * Completions for Objective-C class messages should be included in
5772 * the results.
5774 CXCompletionContext_ObjCClassMessage = 1 << 18,
5776 * Completions for Objective-C selector names should be included in
5777 * the results.
5779 CXCompletionContext_ObjCSelectorName = 1 << 19,
5782 * Completions for preprocessor macro names should be included in
5783 * the results.
5785 CXCompletionContext_MacroName = 1 << 20,
5788 * Natural language completions should be included in the results.
5790 CXCompletionContext_NaturalLanguage = 1 << 21,
5793 * #include file completions should be included in the results.
5795 CXCompletionContext_IncludedFile = 1 << 22,
5798 * The current context is unknown, so set all contexts.
5800 CXCompletionContext_Unknown = ((1 << 23) - 1)
5804 * Returns a default set of code-completion options that can be
5805 * passed to\c clang_codeCompleteAt().
5807 CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5810 * Perform code completion at a given location in a translation unit.
5812 * This function performs code completion at a particular file, line, and
5813 * column within source code, providing results that suggest potential
5814 * code snippets based on the context of the completion. The basic model
5815 * for code completion is that Clang will parse a complete source file,
5816 * performing syntax checking up to the location where code-completion has
5817 * been requested. At that point, a special code-completion token is passed
5818 * to the parser, which recognizes this token and determines, based on the
5819 * current location in the C/Objective-C/C++ grammar and the state of
5820 * semantic analysis, what completions to provide. These completions are
5821 * returned via a new \c CXCodeCompleteResults structure.
5823 * Code completion itself is meant to be triggered by the client when the
5824 * user types punctuation characters or whitespace, at which point the
5825 * code-completion location will coincide with the cursor. For example, if \c p
5826 * is a pointer, code-completion might be triggered after the "-" and then
5827 * after the ">" in \c p->. When the code-completion location is after the ">",
5828 * the completion results will provide, e.g., the members of the struct that
5829 * "p" points to. The client is responsible for placing the cursor at the
5830 * beginning of the token currently being typed, then filtering the results
5831 * based on the contents of the token. For example, when code-completing for
5832 * the expression \c p->get, the client should provide the location just after
5833 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5834 * client can filter the results based on the current token text ("get"), only
5835 * showing those results that start with "get". The intent of this interface
5836 * is to separate the relatively high-latency acquisition of code-completion
5837 * results from the filtering of results on a per-character basis, which must
5838 * have a lower latency.
5840 * \param TU The translation unit in which code-completion should
5841 * occur. The source files for this translation unit need not be
5842 * completely up-to-date (and the contents of those source files may
5843 * be overridden via \p unsaved_files). Cursors referring into the
5844 * translation unit may be invalidated by this invocation.
5846 * \param complete_filename The name of the source file where code
5847 * completion should be performed. This filename may be any file
5848 * included in the translation unit.
5850 * \param complete_line The line at which code-completion should occur.
5852 * \param complete_column The column at which code-completion should occur.
5853 * Note that the column should point just after the syntactic construct that
5854 * initiated code completion, and not in the middle of a lexical token.
5856 * \param unsaved_files the Files that have not yet been saved to disk
5857 * but may be required for parsing or code completion, including the
5858 * contents of those files. The contents and name of these files (as
5859 * specified by CXUnsavedFile) are copied when necessary, so the
5860 * client only needs to guarantee their validity until the call to
5861 * this function returns.
5863 * \param num_unsaved_files The number of unsaved file entries in \p
5864 * unsaved_files.
5866 * \param options Extra options that control the behavior of code
5867 * completion, expressed as a bitwise OR of the enumerators of the
5868 * CXCodeComplete_Flags enumeration. The
5869 * \c clang_defaultCodeCompleteOptions() function returns a default set
5870 * of code-completion options.
5872 * \returns If successful, a new \c CXCodeCompleteResults structure
5873 * containing code-completion results, which should eventually be
5874 * freed with \c clang_disposeCodeCompleteResults(). If code
5875 * completion fails, returns NULL.
5877 CINDEX_LINKAGE
5878 CXCodeCompleteResults *
5879 clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
5880 unsigned complete_line, unsigned complete_column,
5881 struct CXUnsavedFile *unsaved_files,
5882 unsigned num_unsaved_files, unsigned options);
5885 * Sort the code-completion results in case-insensitive alphabetical
5886 * order.
5888 * \param Results The set of results to sort.
5889 * \param NumResults The number of results in \p Results.
5891 CINDEX_LINKAGE
5892 void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5893 unsigned NumResults);
5896 * Free the given set of code-completion results.
5898 CINDEX_LINKAGE
5899 void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
5902 * Determine the number of diagnostics produced prior to the
5903 * location where code completion was performed.
5905 CINDEX_LINKAGE
5906 unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5909 * Retrieve a diagnostic associated with the given code completion.
5911 * \param Results the code completion results to query.
5912 * \param Index the zero-based diagnostic number to retrieve.
5914 * \returns the requested diagnostic. This diagnostic must be freed
5915 * via a call to \c clang_disposeDiagnostic().
5917 CINDEX_LINKAGE
5918 CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5919 unsigned Index);
5922 * Determines what completions are appropriate for the context
5923 * the given code completion.
5925 * \param Results the code completion results to query
5927 * \returns the kinds of completions that are appropriate for use
5928 * along with the given code completion results.
5930 CINDEX_LINKAGE
5931 unsigned long long
5932 clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
5935 * Returns the cursor kind for the container for the current code
5936 * completion context. The container is only guaranteed to be set for
5937 * contexts where a container exists (i.e. member accesses or Objective-C
5938 * message sends); if there is not a container, this function will return
5939 * CXCursor_InvalidCode.
5941 * \param Results the code completion results to query
5943 * \param IsIncomplete on return, this value will be false if Clang has complete
5944 * information about the container. If Clang does not have complete
5945 * information, this value will be true.
5947 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5948 * container
5950 CINDEX_LINKAGE
5951 enum CXCursorKind
5952 clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
5953 unsigned *IsIncomplete);
5956 * Returns the USR for the container for the current code completion
5957 * context. If there is not a container for the current context, this
5958 * function will return the empty string.
5960 * \param Results the code completion results to query
5962 * \returns the USR for the container
5964 CINDEX_LINKAGE
5965 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5968 * Returns the currently-entered selector for an Objective-C message
5969 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5970 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5971 * CXCompletionContext_ObjCClassMessage.
5973 * \param Results the code completion results to query
5975 * \returns the selector (or partial selector) that has been entered thus far
5976 * for an Objective-C message send.
5978 CINDEX_LINKAGE
5979 CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5982 * @}
5986 * \defgroup CINDEX_MISC Miscellaneous utility functions
5988 * @{
5992 * Return a version string, suitable for showing to a user, but not
5993 * intended to be parsed (the format is not guaranteed to be stable).
5995 CINDEX_LINKAGE CXString clang_getClangVersion(void);
5998 * Enable/disable crash recovery.
6000 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
6001 * value enables crash recovery, while 0 disables it.
6003 CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
6006 * Visitor invoked for each file in a translation unit
6007 * (used with clang_getInclusions()).
6009 * This visitor function will be invoked by clang_getInclusions() for each
6010 * file included (either at the top-level or by \#include directives) within
6011 * a translation unit. The first argument is the file being included, and
6012 * the second and third arguments provide the inclusion stack. The
6013 * array is sorted in order of immediate inclusion. For example,
6014 * the first element refers to the location that included 'included_file'.
6016 typedef void (*CXInclusionVisitor)(CXFile included_file,
6017 CXSourceLocation *inclusion_stack,
6018 unsigned include_len,
6019 CXClientData client_data);
6022 * Visit the set of preprocessor inclusions in a translation unit.
6023 * The visitor function is called with the provided data for every included
6024 * file. This does not include headers included by the PCH file (unless one
6025 * is inspecting the inclusions in the PCH file itself).
6027 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
6028 CXInclusionVisitor visitor,
6029 CXClientData client_data);
6031 typedef enum {
6032 CXEval_Int = 1,
6033 CXEval_Float = 2,
6034 CXEval_ObjCStrLiteral = 3,
6035 CXEval_StrLiteral = 4,
6036 CXEval_CFStr = 5,
6037 CXEval_Other = 6,
6039 CXEval_UnExposed = 0
6041 } CXEvalResultKind;
6044 * Evaluation result of a cursor
6046 typedef void *CXEvalResult;
6049 * If cursor is a statement declaration tries to evaluate the
6050 * statement and if its variable, tries to evaluate its initializer,
6051 * into its corresponding type.
6052 * If it's an expression, tries to evaluate the expression.
6054 CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
6057 * Returns the kind of the evaluated result.
6059 CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
6062 * Returns the evaluation result as integer if the
6063 * kind is Int.
6065 CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
6068 * Returns the evaluation result as a long long integer if the
6069 * kind is Int. This prevents overflows that may happen if the result is
6070 * returned with clang_EvalResult_getAsInt.
6072 CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
6075 * Returns a non-zero value if the kind is Int and the evaluation
6076 * result resulted in an unsigned integer.
6078 CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
6081 * Returns the evaluation result as an unsigned integer if
6082 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
6084 CINDEX_LINKAGE unsigned long long
6085 clang_EvalResult_getAsUnsigned(CXEvalResult E);
6088 * Returns the evaluation result as double if the
6089 * kind is double.
6091 CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
6094 * Returns the evaluation result as a constant string if the
6095 * kind is other than Int or float. User must not free this pointer,
6096 * instead call clang_EvalResult_dispose on the CXEvalResult returned
6097 * by clang_Cursor_Evaluate.
6099 CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
6102 * Disposes the created Eval memory.
6104 CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
6106 * @}
6109 /** \defgroup CINDEX_REMAPPING Remapping functions
6111 * @{
6115 * A remapping of original source files and their translated files.
6117 typedef void *CXRemapping;
6120 * Retrieve a remapping.
6122 * \param path the path that contains metadata about remappings.
6124 * \returns the requested remapping. This remapping must be freed
6125 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6127 CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
6130 * Retrieve a remapping.
6132 * \param filePaths pointer to an array of file paths containing remapping info.
6134 * \param numFiles number of file paths.
6136 * \returns the requested remapping. This remapping must be freed
6137 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6139 CINDEX_LINKAGE
6140 CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
6141 unsigned numFiles);
6144 * Determine the number of remappings.
6146 CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
6149 * Get the original and the associated filename from the remapping.
6151 * \param original If non-NULL, will be set to the original filename.
6153 * \param transformed If non-NULL, will be set to the filename that the original
6154 * is associated with.
6156 CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
6157 CXString *original,
6158 CXString *transformed);
6161 * Dispose the remapping.
6163 CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
6166 * @}
6169 /** \defgroup CINDEX_HIGH Higher level API functions
6171 * @{
6174 enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
6176 typedef struct CXCursorAndRangeVisitor {
6177 void *context;
6178 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
6179 } CXCursorAndRangeVisitor;
6181 typedef enum {
6183 * Function returned successfully.
6185 CXResult_Success = 0,
6187 * One of the parameters was invalid for the function.
6189 CXResult_Invalid = 1,
6191 * The function was terminated by a callback (e.g. it returned
6192 * CXVisit_Break)
6194 CXResult_VisitBreak = 2
6196 } CXResult;
6199 * Find references of a declaration in a specific file.
6201 * \param cursor pointing to a declaration or a reference of one.
6203 * \param file to search for references.
6205 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6206 * each reference found.
6207 * The CXSourceRange will point inside the file; if the reference is inside
6208 * a macro (and not a macro argument) the CXSourceRange will be invalid.
6210 * \returns one of the CXResult enumerators.
6212 CINDEX_LINKAGE CXResult clang_findReferencesInFile(
6213 CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
6216 * Find #import/#include directives in a specific file.
6218 * \param TU translation unit containing the file to query.
6220 * \param file to search for #import/#include directives.
6222 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6223 * each directive found.
6225 * \returns one of the CXResult enumerators.
6227 CINDEX_LINKAGE CXResult clang_findIncludesInFile(
6228 CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
6230 #ifdef __has_feature
6231 #if __has_feature(blocks)
6233 typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
6234 CXSourceRange);
6236 CINDEX_LINKAGE
6237 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6238 CXCursorAndRangeVisitorBlock);
6240 CINDEX_LINKAGE
6241 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6242 CXCursorAndRangeVisitorBlock);
6244 #endif
6245 #endif
6248 * The client's data object that is associated with a CXFile.
6250 typedef void *CXIdxClientFile;
6253 * The client's data object that is associated with a semantic entity.
6255 typedef void *CXIdxClientEntity;
6258 * The client's data object that is associated with a semantic container
6259 * of entities.
6261 typedef void *CXIdxClientContainer;
6264 * The client's data object that is associated with an AST file (PCH
6265 * or module).
6267 typedef void *CXIdxClientASTFile;
6270 * Source location passed to index callbacks.
6272 typedef struct {
6273 void *ptr_data[2];
6274 unsigned int_data;
6275 } CXIdxLoc;
6278 * Data for ppIncludedFile callback.
6280 typedef struct {
6282 * Location of '#' in the \#include/\#import directive.
6284 CXIdxLoc hashLoc;
6286 * Filename as written in the \#include/\#import directive.
6288 const char *filename;
6290 * The actual file that the \#include/\#import directive resolved to.
6292 CXFile file;
6293 int isImport;
6294 int isAngled;
6296 * Non-zero if the directive was automatically turned into a module
6297 * import.
6299 int isModuleImport;
6300 } CXIdxIncludedFileInfo;
6303 * Data for IndexerCallbacks#importedASTFile.
6305 typedef struct {
6307 * Top level AST file containing the imported PCH, module or submodule.
6309 CXFile file;
6311 * The imported module or NULL if the AST file is a PCH.
6313 CXModule module;
6315 * Location where the file is imported. Applicable only for modules.
6317 CXIdxLoc loc;
6319 * Non-zero if an inclusion directive was automatically turned into
6320 * a module import. Applicable only for modules.
6322 int isImplicit;
6324 } CXIdxImportedASTFileInfo;
6326 typedef enum {
6327 CXIdxEntity_Unexposed = 0,
6328 CXIdxEntity_Typedef = 1,
6329 CXIdxEntity_Function = 2,
6330 CXIdxEntity_Variable = 3,
6331 CXIdxEntity_Field = 4,
6332 CXIdxEntity_EnumConstant = 5,
6334 CXIdxEntity_ObjCClass = 6,
6335 CXIdxEntity_ObjCProtocol = 7,
6336 CXIdxEntity_ObjCCategory = 8,
6338 CXIdxEntity_ObjCInstanceMethod = 9,
6339 CXIdxEntity_ObjCClassMethod = 10,
6340 CXIdxEntity_ObjCProperty = 11,
6341 CXIdxEntity_ObjCIvar = 12,
6343 CXIdxEntity_Enum = 13,
6344 CXIdxEntity_Struct = 14,
6345 CXIdxEntity_Union = 15,
6347 CXIdxEntity_CXXClass = 16,
6348 CXIdxEntity_CXXNamespace = 17,
6349 CXIdxEntity_CXXNamespaceAlias = 18,
6350 CXIdxEntity_CXXStaticVariable = 19,
6351 CXIdxEntity_CXXStaticMethod = 20,
6352 CXIdxEntity_CXXInstanceMethod = 21,
6353 CXIdxEntity_CXXConstructor = 22,
6354 CXIdxEntity_CXXDestructor = 23,
6355 CXIdxEntity_CXXConversionFunction = 24,
6356 CXIdxEntity_CXXTypeAlias = 25,
6357 CXIdxEntity_CXXInterface = 26,
6358 CXIdxEntity_CXXConcept = 27
6360 } CXIdxEntityKind;
6362 typedef enum {
6363 CXIdxEntityLang_None = 0,
6364 CXIdxEntityLang_C = 1,
6365 CXIdxEntityLang_ObjC = 2,
6366 CXIdxEntityLang_CXX = 3,
6367 CXIdxEntityLang_Swift = 4
6368 } CXIdxEntityLanguage;
6371 * Extra C++ template information for an entity. This can apply to:
6372 * CXIdxEntity_Function
6373 * CXIdxEntity_CXXClass
6374 * CXIdxEntity_CXXStaticMethod
6375 * CXIdxEntity_CXXInstanceMethod
6376 * CXIdxEntity_CXXConstructor
6377 * CXIdxEntity_CXXConversionFunction
6378 * CXIdxEntity_CXXTypeAlias
6380 typedef enum {
6381 CXIdxEntity_NonTemplate = 0,
6382 CXIdxEntity_Template = 1,
6383 CXIdxEntity_TemplatePartialSpecialization = 2,
6384 CXIdxEntity_TemplateSpecialization = 3
6385 } CXIdxEntityCXXTemplateKind;
6387 typedef enum {
6388 CXIdxAttr_Unexposed = 0,
6389 CXIdxAttr_IBAction = 1,
6390 CXIdxAttr_IBOutlet = 2,
6391 CXIdxAttr_IBOutletCollection = 3
6392 } CXIdxAttrKind;
6394 typedef struct {
6395 CXIdxAttrKind kind;
6396 CXCursor cursor;
6397 CXIdxLoc loc;
6398 } CXIdxAttrInfo;
6400 typedef struct {
6401 CXIdxEntityKind kind;
6402 CXIdxEntityCXXTemplateKind templateKind;
6403 CXIdxEntityLanguage lang;
6404 const char *name;
6405 const char *USR;
6406 CXCursor cursor;
6407 const CXIdxAttrInfo *const *attributes;
6408 unsigned numAttributes;
6409 } CXIdxEntityInfo;
6411 typedef struct {
6412 CXCursor cursor;
6413 } CXIdxContainerInfo;
6415 typedef struct {
6416 const CXIdxAttrInfo *attrInfo;
6417 const CXIdxEntityInfo *objcClass;
6418 CXCursor classCursor;
6419 CXIdxLoc classLoc;
6420 } CXIdxIBOutletCollectionAttrInfo;
6422 typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
6424 typedef struct {
6425 const CXIdxEntityInfo *entityInfo;
6426 CXCursor cursor;
6427 CXIdxLoc loc;
6428 const CXIdxContainerInfo *semanticContainer;
6430 * Generally same as #semanticContainer but can be different in
6431 * cases like out-of-line C++ member functions.
6433 const CXIdxContainerInfo *lexicalContainer;
6434 int isRedeclaration;
6435 int isDefinition;
6436 int isContainer;
6437 const CXIdxContainerInfo *declAsContainer;
6439 * Whether the declaration exists in code or was created implicitly
6440 * by the compiler, e.g. implicit Objective-C methods for properties.
6442 int isImplicit;
6443 const CXIdxAttrInfo *const *attributes;
6444 unsigned numAttributes;
6446 unsigned flags;
6448 } CXIdxDeclInfo;
6450 typedef enum {
6451 CXIdxObjCContainer_ForwardRef = 0,
6452 CXIdxObjCContainer_Interface = 1,
6453 CXIdxObjCContainer_Implementation = 2
6454 } CXIdxObjCContainerKind;
6456 typedef struct {
6457 const CXIdxDeclInfo *declInfo;
6458 CXIdxObjCContainerKind kind;
6459 } CXIdxObjCContainerDeclInfo;
6461 typedef struct {
6462 const CXIdxEntityInfo *base;
6463 CXCursor cursor;
6464 CXIdxLoc loc;
6465 } CXIdxBaseClassInfo;
6467 typedef struct {
6468 const CXIdxEntityInfo *protocol;
6469 CXCursor cursor;
6470 CXIdxLoc loc;
6471 } CXIdxObjCProtocolRefInfo;
6473 typedef struct {
6474 const CXIdxObjCProtocolRefInfo *const *protocols;
6475 unsigned numProtocols;
6476 } CXIdxObjCProtocolRefListInfo;
6478 typedef struct {
6479 const CXIdxObjCContainerDeclInfo *containerInfo;
6480 const CXIdxBaseClassInfo *superInfo;
6481 const CXIdxObjCProtocolRefListInfo *protocols;
6482 } CXIdxObjCInterfaceDeclInfo;
6484 typedef struct {
6485 const CXIdxObjCContainerDeclInfo *containerInfo;
6486 const CXIdxEntityInfo *objcClass;
6487 CXCursor classCursor;
6488 CXIdxLoc classLoc;
6489 const CXIdxObjCProtocolRefListInfo *protocols;
6490 } CXIdxObjCCategoryDeclInfo;
6492 typedef struct {
6493 const CXIdxDeclInfo *declInfo;
6494 const CXIdxEntityInfo *getter;
6495 const CXIdxEntityInfo *setter;
6496 } CXIdxObjCPropertyDeclInfo;
6498 typedef struct {
6499 const CXIdxDeclInfo *declInfo;
6500 const CXIdxBaseClassInfo *const *bases;
6501 unsigned numBases;
6502 } CXIdxCXXClassDeclInfo;
6505 * Data for IndexerCallbacks#indexEntityReference.
6507 * This may be deprecated in a future version as this duplicates
6508 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6510 typedef enum {
6512 * The entity is referenced directly in user's code.
6514 CXIdxEntityRef_Direct = 1,
6516 * An implicit reference, e.g. a reference of an Objective-C method
6517 * via the dot syntax.
6519 CXIdxEntityRef_Implicit = 2
6520 } CXIdxEntityRefKind;
6523 * Roles that are attributed to symbol occurrences.
6525 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6526 * higher bits zeroed. These high bits may be exposed in the future.
6528 typedef enum {
6529 CXSymbolRole_None = 0,
6530 CXSymbolRole_Declaration = 1 << 0,
6531 CXSymbolRole_Definition = 1 << 1,
6532 CXSymbolRole_Reference = 1 << 2,
6533 CXSymbolRole_Read = 1 << 3,
6534 CXSymbolRole_Write = 1 << 4,
6535 CXSymbolRole_Call = 1 << 5,
6536 CXSymbolRole_Dynamic = 1 << 6,
6537 CXSymbolRole_AddressOf = 1 << 7,
6538 CXSymbolRole_Implicit = 1 << 8
6539 } CXSymbolRole;
6542 * Data for IndexerCallbacks#indexEntityReference.
6544 typedef struct {
6545 CXIdxEntityRefKind kind;
6547 * Reference cursor.
6549 CXCursor cursor;
6550 CXIdxLoc loc;
6552 * The entity that gets referenced.
6554 const CXIdxEntityInfo *referencedEntity;
6556 * Immediate "parent" of the reference. For example:
6558 * \code
6559 * Foo *var;
6560 * \endcode
6562 * The parent of reference of type 'Foo' is the variable 'var'.
6563 * For references inside statement bodies of functions/methods,
6564 * the parentEntity will be the function/method.
6566 const CXIdxEntityInfo *parentEntity;
6568 * Lexical container context of the reference.
6570 const CXIdxContainerInfo *container;
6572 * Sets of symbol roles of the reference.
6574 CXSymbolRole role;
6575 } CXIdxEntityRefInfo;
6578 * A group of callbacks used by #clang_indexSourceFile and
6579 * #clang_indexTranslationUnit.
6581 typedef struct {
6583 * Called periodically to check whether indexing should be aborted.
6584 * Should return 0 to continue, and non-zero to abort.
6586 int (*abortQuery)(CXClientData client_data, void *reserved);
6589 * Called at the end of indexing; passes the complete diagnostic set.
6591 void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
6593 CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
6594 void *reserved);
6597 * Called when a file gets \#included/\#imported.
6599 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
6600 const CXIdxIncludedFileInfo *);
6603 * Called when a AST file (PCH or module) gets imported.
6605 * AST files will not get indexed (there will not be callbacks to index all
6606 * the entities in an AST file). The recommended action is that, if the AST
6607 * file is not already indexed, to initiate a new indexing job specific to
6608 * the AST file.
6610 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
6611 const CXIdxImportedASTFileInfo *);
6614 * Called at the beginning of indexing a translation unit.
6616 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
6617 void *reserved);
6619 void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
6622 * Called to index a reference of an entity.
6624 void (*indexEntityReference)(CXClientData client_data,
6625 const CXIdxEntityRefInfo *);
6627 } IndexerCallbacks;
6629 CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6630 CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6631 clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
6633 CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6634 clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6636 CINDEX_LINKAGE
6637 const CXIdxObjCCategoryDeclInfo *
6638 clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6640 CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6641 clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
6643 CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6644 clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6646 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6647 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6649 CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6650 clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6653 * For retrieving a custom CXIdxClientContainer attached to a
6654 * container.
6656 CINDEX_LINKAGE CXIdxClientContainer
6657 clang_index_getClientContainer(const CXIdxContainerInfo *);
6660 * For setting a custom CXIdxClientContainer attached to a
6661 * container.
6663 CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
6664 CXIdxClientContainer);
6667 * For retrieving a custom CXIdxClientEntity attached to an entity.
6669 CINDEX_LINKAGE CXIdxClientEntity
6670 clang_index_getClientEntity(const CXIdxEntityInfo *);
6673 * For setting a custom CXIdxClientEntity attached to an entity.
6675 CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
6676 CXIdxClientEntity);
6679 * An indexing action/session, to be applied to one or multiple
6680 * translation units.
6682 typedef void *CXIndexAction;
6685 * An indexing action/session, to be applied to one or multiple
6686 * translation units.
6688 * \param CIdx The index object with which the index action will be associated.
6690 CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6693 * Destroy the given index action.
6695 * The index action must not be destroyed until all of the translation units
6696 * created within that index action have been destroyed.
6698 CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6700 typedef enum {
6702 * Used to indicate that no special indexing options are needed.
6704 CXIndexOpt_None = 0x0,
6707 * Used to indicate that IndexerCallbacks#indexEntityReference should
6708 * be invoked for only one reference of an entity per source file that does
6709 * not also include a declaration/definition of the entity.
6711 CXIndexOpt_SuppressRedundantRefs = 0x1,
6714 * Function-local symbols should be indexed. If this is not set
6715 * function-local symbols will be ignored.
6717 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6720 * Implicit function/class template instantiations should be indexed.
6721 * If this is not set, implicit instantiations will be ignored.
6723 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6726 * Suppress all compiler warnings when parsing for indexing.
6728 CXIndexOpt_SuppressWarnings = 0x8,
6731 * Skip a function/method body that was already parsed during an
6732 * indexing session associated with a \c CXIndexAction object.
6733 * Bodies in system headers are always skipped.
6735 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6737 } CXIndexOptFlags;
6740 * Index the given source file and the translation unit corresponding
6741 * to that file via callbacks implemented through #IndexerCallbacks.
6743 * \param client_data pointer data supplied by the client, which will
6744 * be passed to the invoked callbacks.
6746 * \param index_callbacks Pointer to indexing callbacks that the client
6747 * implements.
6749 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6750 * passed in index_callbacks.
6752 * \param index_options A bitmask of options that affects how indexing is
6753 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6755 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6756 * reused after indexing is finished. Set to \c NULL if you do not require it.
6758 * \returns 0 on success or if there were errors from which the compiler could
6759 * recover. If there is a failure from which there is no recovery, returns
6760 * a non-zero \c CXErrorCode.
6762 * The rest of the parameters are the same as #clang_parseTranslationUnit.
6764 CINDEX_LINKAGE int clang_indexSourceFile(
6765 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6766 unsigned index_callbacks_size, unsigned index_options,
6767 const char *source_filename, const char *const *command_line_args,
6768 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6769 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6772 * Same as clang_indexSourceFile but requires a full command line
6773 * for \c command_line_args including argv[0]. This is useful if the standard
6774 * library paths are relative to the binary.
6776 CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6777 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6778 unsigned index_callbacks_size, unsigned index_options,
6779 const char *source_filename, const char *const *command_line_args,
6780 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6781 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6784 * Index the given translation unit via callbacks implemented through
6785 * #IndexerCallbacks.
6787 * The order of callback invocations is not guaranteed to be the same as
6788 * when indexing a source file. The high level order will be:
6790 * -Preprocessor callbacks invocations
6791 * -Declaration/reference callbacks invocations
6792 * -Diagnostic callback invocations
6794 * The parameters are the same as #clang_indexSourceFile.
6796 * \returns If there is a failure from which there is no recovery, returns
6797 * non-zero, otherwise returns 0.
6799 CINDEX_LINKAGE int clang_indexTranslationUnit(
6800 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6801 unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
6804 * Retrieve the CXIdxFile, file, line, column, and offset represented by
6805 * the given CXIdxLoc.
6807 * If the location refers into a macro expansion, retrieves the
6808 * location of the macro expansion and if it refers into a macro argument
6809 * retrieves the location of the argument.
6811 CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6812 CXIdxClientFile *indexFile,
6813 CXFile *file, unsigned *line,
6814 unsigned *column,
6815 unsigned *offset);
6818 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6820 CINDEX_LINKAGE
6821 CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6824 * Visitor invoked for each field found by a traversal.
6826 * This visitor function will be invoked for each field found by
6827 * \c clang_Type_visitFields. Its first argument is the cursor being
6828 * visited, its second argument is the client data provided to
6829 * \c clang_Type_visitFields.
6831 * The visitor should return one of the \c CXVisitorResult values
6832 * to direct \c clang_Type_visitFields.
6834 typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6835 CXClientData client_data);
6838 * Visit the fields of a particular type.
6840 * This function visits all the direct fields of the given cursor,
6841 * invoking the given \p visitor function with the cursors of each
6842 * visited field. The traversal may be ended prematurely, if
6843 * the visitor returns \c CXFieldVisit_Break.
6845 * \param T the record type whose field may be visited.
6847 * \param visitor the visitor function that will be invoked for each
6848 * field of \p T.
6850 * \param client_data pointer data supplied by the client, which will
6851 * be passed to the visitor each time it is invoked.
6853 * \returns a non-zero value if the traversal was terminated
6854 * prematurely by the visitor returning \c CXFieldVisit_Break.
6856 CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
6857 CXClientData client_data);
6860 * @}
6864 * @}
6867 LLVM_CLANG_C_EXTERN_C_END
6869 #endif