6978 lines · c
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\*===----------------------------------------------------------------------===*/15 16#ifndef LLVM_CLANG_C_INDEX_H17#define LLVM_CLANG_C_INDEX_H18 19#include "clang-c/BuildSystem.h"20#include "clang-c/CXDiagnostic.h"21#include "clang-c/CXErrorCode.h"22#include "clang-c/CXFile.h"23#include "clang-c/CXSourceLocation.h"24#include "clang-c/CXString.h"25#include "clang-c/ExternC.h"26#include "clang-c/Platform.h"27 28/**29 * The version constants for the libclang API.30 * CINDEX_VERSION_MINOR should increase when there are API additions.31 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.32 *33 * The policy about the libclang API was always to keep it source and ABI34 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.35 */36#define CINDEX_VERSION_MAJOR 037#define CINDEX_VERSION_MINOR 6438 39#define CINDEX_VERSION_ENCODE(major, minor) (((major) * 10000) + ((minor) * 1))40 41#define CINDEX_VERSION \42 CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)43 44#define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor45#define CINDEX_VERSION_STRINGIZE(major, minor) \46 CINDEX_VERSION_STRINGIZE_(major, minor)47 48#define CINDEX_VERSION_STRING \49 CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)50 51#ifndef __has_feature52#define __has_feature(feature) 053#endif54 55LLVM_CLANG_C_EXTERN_C_BEGIN56 57/** \defgroup CINDEX libclang: C Interface to Clang58 *59 * The C Interface to Clang provides a relatively small API that exposes60 * facilities for parsing source code into an abstract syntax tree (AST),61 * loading already-parsed ASTs, traversing the AST, associating62 * physical source locations with elements within the AST, and other63 * facilities that support Clang-based development tools.64 *65 * This C interface to Clang will never provide all of the information66 * representation stored in Clang's C++ AST, nor should it: the intent is to67 * maintain an API that is relatively stable from one release to the next,68 * providing only the basic functionality needed to support development tools.69 *70 * To avoid namespace pollution, data types are prefixed with "CX" and71 * functions are prefixed with "clang_".72 *73 * @{74 */75 76/**77 * An "index" that consists of a set of translation units that would78 * typically be linked together into an executable or library.79 */80typedef void *CXIndex;81 82/**83 * An opaque type representing target information for a given translation84 * unit.85 */86typedef struct CXTargetInfoImpl *CXTargetInfo;87 88/**89 * A single translation unit, which resides in an index.90 */91typedef struct CXTranslationUnitImpl *CXTranslationUnit;92 93/**94 * Opaque pointer representing client data that will be passed through95 * to various callbacks and visitors.96 */97typedef void *CXClientData;98 99/**100 * Provides the contents of a file that has not yet been saved to disk.101 *102 * Each CXUnsavedFile instance provides the name of a file on the103 * system along with the current contents of that file that have not104 * yet been saved to disk.105 */106struct CXUnsavedFile {107 /**108 * The file whose contents have not yet been saved.109 *110 * This file must already exist in the file system.111 */112 const char *Filename;113 114 /**115 * A buffer containing the unsaved contents of this file.116 */117 const char *Contents;118 119 /**120 * The length of the unsaved contents of this buffer.121 */122 unsigned long Length;123};124 125/**126 * Describes the availability of a particular entity, which indicates127 * whether the use of this entity will result in a warning or error due to128 * it being deprecated or unavailable.129 */130enum CXAvailabilityKind {131 /**132 * The entity is available.133 */134 CXAvailability_Available,135 /**136 * The entity is available, but has been deprecated (and its use is137 * not recommended).138 */139 CXAvailability_Deprecated,140 /**141 * The entity is not available; any use of it will be an error.142 */143 CXAvailability_NotAvailable,144 /**145 * The entity is available, but not accessible; any use of it will be146 * an error.147 */148 CXAvailability_NotAccessible149};150 151/**152 * Describes a version number of the form major.minor.subminor.153 */154typedef struct CXVersion {155 /**156 * The major version number, e.g., the '10' in '10.7.3'. A negative157 * value indicates that there is no version number at all.158 */159 int Major;160 /**161 * The minor version number, e.g., the '7' in '10.7.3'. This value162 * will be negative if no minor version number was provided, e.g., for163 * version '10'.164 */165 int Minor;166 /**167 * The subminor version number, e.g., the '3' in '10.7.3'. This value168 * will be negative if no minor or subminor version number was provided,169 * e.g., in version '10' or '10.7'.170 */171 int Subminor;172} CXVersion;173 174/**175 * Describes the exception specification of a cursor.176 *177 * A negative value indicates that the cursor is not a function declaration.178 */179enum CXCursor_ExceptionSpecificationKind {180 /**181 * The cursor has no exception specification.182 */183 CXCursor_ExceptionSpecificationKind_None,184 185 /**186 * The cursor has exception specification throw()187 */188 CXCursor_ExceptionSpecificationKind_DynamicNone,189 190 /**191 * The cursor has exception specification throw(T1, T2)192 */193 CXCursor_ExceptionSpecificationKind_Dynamic,194 195 /**196 * The cursor has exception specification throw(...).197 */198 CXCursor_ExceptionSpecificationKind_MSAny,199 200 /**201 * The cursor has exception specification basic noexcept.202 */203 CXCursor_ExceptionSpecificationKind_BasicNoexcept,204 205 /**206 * The cursor has exception specification computed noexcept.207 */208 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,209 210 /**211 * The exception specification has not yet been evaluated.212 */213 CXCursor_ExceptionSpecificationKind_Unevaluated,214 215 /**216 * The exception specification has not yet been instantiated.217 */218 CXCursor_ExceptionSpecificationKind_Uninstantiated,219 220 /**221 * The exception specification has not been parsed yet.222 */223 CXCursor_ExceptionSpecificationKind_Unparsed,224 225 /**226 * The cursor has a __declspec(nothrow) exception specification.227 */228 CXCursor_ExceptionSpecificationKind_NoThrow229};230 231/**232 * Provides a shared context for creating translation units.233 *234 * It provides two options:235 *236 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"237 * declarations (when loading any new translation units). A "local" declaration238 * is one that belongs in the translation unit itself and not in a precompiled239 * header that was used by the translation unit. If zero, all declarations240 * will be enumerated.241 *242 * Here is an example:243 *244 * \code245 * // excludeDeclsFromPCH = 1, displayDiagnostics=1246 * Idx = clang_createIndex(1, 1);247 *248 * // IndexTest.pch was produced with the following command:249 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"250 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");251 *252 * // This will load all the symbols from 'IndexTest.pch'253 * clang_visitChildren(clang_getTranslationUnitCursor(TU),254 * TranslationUnitVisitor, 0);255 * clang_disposeTranslationUnit(TU);256 *257 * // This will load all the symbols from 'IndexTest.c', excluding symbols258 * // from 'IndexTest.pch'.259 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };260 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,261 * 0, 0);262 * clang_visitChildren(clang_getTranslationUnitCursor(TU),263 * TranslationUnitVisitor, 0);264 * clang_disposeTranslationUnit(TU);265 * \endcode266 *267 * This process of creating the 'pch', loading it separately, and using it (via268 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks269 * (which gives the indexer the same performance benefit as the compiler).270 */271CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,272 int displayDiagnostics);273 274/**275 * Destroy the given index.276 *277 * The index must not be destroyed until all of the translation units created278 * within that index have been destroyed.279 */280CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);281 282typedef enum {283 /**284 * Use the default value of an option that may depend on the process285 * environment.286 */287 CXChoice_Default = 0,288 /**289 * Enable the option.290 */291 CXChoice_Enabled = 1,292 /**293 * Disable the option.294 */295 CXChoice_Disabled = 2296} CXChoice;297 298typedef enum {299 /**300 * Used to indicate that no special CXIndex options are needed.301 */302 CXGlobalOpt_None = 0x0,303 304 /**305 * Used to indicate that threads that libclang creates for indexing306 * purposes should use background priority.307 *308 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,309 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.310 */311 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,312 313 /**314 * Used to indicate that threads that libclang creates for editing315 * purposes should use background priority.316 *317 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,318 * #clang_annotateTokens319 */320 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,321 322 /**323 * Used to indicate that all threads that libclang creates should use324 * background priority.325 */326 CXGlobalOpt_ThreadBackgroundPriorityForAll =327 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |328 CXGlobalOpt_ThreadBackgroundPriorityForEditing329 330} CXGlobalOptFlags;331 332/**333 * Index initialization options.334 *335 * 0 is the default value of each member of this struct except for Size.336 * Initialize the struct in one of the following three ways to avoid adapting337 * code each time a new member is added to it:338 * \code339 * CXIndexOptions Opts;340 * memset(&Opts, 0, sizeof(Opts));341 * Opts.Size = sizeof(CXIndexOptions);342 * \endcode343 * or explicitly initialize the first data member and zero-initialize the rest:344 * \code345 * CXIndexOptions Opts = { sizeof(CXIndexOptions) };346 * \endcode347 * or to prevent the -Wmissing-field-initializers warning for the above version:348 * \code349 * CXIndexOptions Opts{};350 * Opts.Size = sizeof(CXIndexOptions);351 * \endcode352 */353typedef struct CXIndexOptions {354 /**355 * The size of struct CXIndexOptions used for option versioning.356 *357 * Always initialize this member to sizeof(CXIndexOptions), or assign358 * sizeof(CXIndexOptions) to it right after creating a CXIndexOptions object.359 */360 unsigned Size;361 /**362 * A CXChoice enumerator that specifies the indexing priority policy.363 * \sa CXGlobalOpt_ThreadBackgroundPriorityForIndexing364 */365 unsigned char ThreadBackgroundPriorityForIndexing;366 /**367 * A CXChoice enumerator that specifies the editing priority policy.368 * \sa CXGlobalOpt_ThreadBackgroundPriorityForEditing369 */370 unsigned char ThreadBackgroundPriorityForEditing;371 /**372 * \see clang_createIndex()373 */374 unsigned ExcludeDeclarationsFromPCH : 1;375 /**376 * \see clang_createIndex()377 */378 unsigned DisplayDiagnostics : 1;379 /**380 * Store PCH in memory. If zero, PCH are stored in temporary files.381 */382 unsigned StorePreamblesInMemory : 1;383 unsigned /*Reserved*/ : 13;384 385 /**386 * The path to a directory, in which to store temporary PCH files. If null or387 * empty, the default system temporary directory is used. These PCH files are388 * deleted on clean exit but stay on disk if the program crashes or is killed.389 *390 * This option is ignored if \a StorePreamblesInMemory is non-zero.391 *392 * Libclang does not create the directory at the specified path in the file393 * system. Therefore it must exist, or storing PCH files will fail.394 */395 const char *PreambleStoragePath;396 /**397 * Specifies a path which will contain log files for certain libclang398 * invocations. A null value implies that libclang invocations are not logged.399 */400 const char *InvocationEmissionPath;401} CXIndexOptions;402 403/**404 * Provides a shared context for creating translation units.405 *406 * Call this function instead of clang_createIndex() if you need to configure407 * the additional options in CXIndexOptions.408 *409 * \returns The created index or null in case of error, such as an unsupported410 * value of options->Size.411 *412 * For example:413 * \code414 * CXIndex createIndex(const char *ApplicationTemporaryPath) {415 * const int ExcludeDeclarationsFromPCH = 1;416 * const int DisplayDiagnostics = 1;417 * CXIndex Idx;418 * #if CINDEX_VERSION_MINOR >= 64419 * CXIndexOptions Opts;420 * memset(&Opts, 0, sizeof(Opts));421 * Opts.Size = sizeof(CXIndexOptions);422 * Opts.ThreadBackgroundPriorityForIndexing = 1;423 * Opts.ExcludeDeclarationsFromPCH = ExcludeDeclarationsFromPCH;424 * Opts.DisplayDiagnostics = DisplayDiagnostics;425 * Opts.PreambleStoragePath = ApplicationTemporaryPath;426 * Idx = clang_createIndexWithOptions(&Opts);427 * if (Idx)428 * return Idx;429 * fprintf(stderr,430 * "clang_createIndexWithOptions() failed. "431 * "CINDEX_VERSION_MINOR = %d, sizeof(CXIndexOptions) = %u\n",432 * CINDEX_VERSION_MINOR, Opts.Size);433 * #else434 * (void)ApplicationTemporaryPath;435 * #endif436 * Idx = clang_createIndex(ExcludeDeclarationsFromPCH, DisplayDiagnostics);437 * clang_CXIndex_setGlobalOptions(438 * Idx, clang_CXIndex_getGlobalOptions(Idx) |439 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);440 * return Idx;441 * }442 * \endcode443 *444 * \sa clang_createIndex()445 */446CINDEX_LINKAGE CXIndex447clang_createIndexWithOptions(const CXIndexOptions *options);448 449/**450 * Sets general options associated with a CXIndex.451 *452 * This function is DEPRECATED. Set453 * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or454 * CXIndexOptions::ThreadBackgroundPriorityForEditing and call455 * clang_createIndexWithOptions() instead.456 *457 * For example:458 * \code459 * CXIndex idx = ...;460 * clang_CXIndex_setGlobalOptions(idx,461 * clang_CXIndex_getGlobalOptions(idx) |462 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);463 * \endcode464 *465 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.466 */467CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);468 469/**470 * Gets the general options associated with a CXIndex.471 *472 * This function allows to obtain the final option values used by libclang after473 * specifying the option policies via CXChoice enumerators.474 *475 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that476 * are associated with the given CXIndex object.477 */478CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);479 480/**481 * Sets the invocation emission path option in a CXIndex.482 *483 * This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and484 * call clang_createIndexWithOptions() instead.485 *486 * The invocation emission path specifies a path which will contain log487 * files for certain libclang invocations. A null value (default) implies that488 * libclang invocations are not logged..489 */490CINDEX_LINKAGE void491clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);492 493/**494 * Determine whether the given header is guarded against495 * multiple inclusions, either with the conventional496 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.497 */498CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,499 CXFile file);500 501/**502 * Retrieve a file handle within the given translation unit.503 *504 * \param tu the translation unit505 *506 * \param file_name the name of the file.507 *508 * \returns the file handle for the named file in the translation unit \p tu,509 * or a NULL file handle if the file was not a part of this translation unit.510 */511CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,512 const char *file_name);513 514/**515 * Retrieve the buffer associated with the given file.516 *517 * \param tu the translation unit518 *519 * \param file the file for which to retrieve the buffer.520 *521 * \param size [out] if non-NULL, will be set to the size of the buffer.522 *523 * \returns a pointer to the buffer in memory that holds the contents of524 * \p file, or a NULL pointer when the file is not loaded.525 */526CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,527 CXFile file, size_t *size);528 529/**530 * Retrieves the source location associated with a given file/line/column531 * in a particular translation unit.532 */533CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,534 CXFile file, unsigned line,535 unsigned column);536/**537 * Retrieves the source location associated with a given character offset538 * in a particular translation unit.539 */540CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,541 CXFile file,542 unsigned offset);543 544/**545 * Retrieve all ranges that were skipped by the preprocessor.546 *547 * The preprocessor will skip lines when they are surrounded by an548 * if/ifdef/ifndef directive whose condition does not evaluate to true.549 */550CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,551 CXFile file);552 553/**554 * Retrieve all ranges from all files that were skipped by the555 * preprocessor.556 *557 * The preprocessor will skip lines when they are surrounded by an558 * if/ifdef/ifndef directive whose condition does not evaluate to true.559 */560CINDEX_LINKAGE CXSourceRangeList *561clang_getAllSkippedRanges(CXTranslationUnit tu);562 563/**564 * Determine the number of diagnostics produced for the given565 * translation unit.566 */567CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);568 569/**570 * Retrieve a diagnostic associated with the given translation unit.571 *572 * \param Unit the translation unit to query.573 * \param Index the zero-based diagnostic number to retrieve.574 *575 * \returns the requested diagnostic. This diagnostic must be freed576 * via a call to \c clang_disposeDiagnostic().577 */578CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,579 unsigned Index);580 581/**582 * Retrieve the complete set of diagnostics associated with a583 * translation unit.584 *585 * \param Unit the translation unit to query.586 */587CINDEX_LINKAGE CXDiagnosticSet588clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);589 590/**591 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation592 *593 * The routines in this group provide the ability to create and destroy594 * translation units from files, either by parsing the contents of the files or595 * by reading in a serialized representation of a translation unit.596 *597 * @{598 */599 600/**601 * Get the original translation unit source file name.602 */603CINDEX_LINKAGE CXString604clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);605 606/**607 * Return the CXTranslationUnit for a given source file and the provided608 * command line arguments one would pass to the compiler.609 *610 * Note: The 'source_filename' argument is optional. If the caller provides a611 * NULL pointer, the name of the source file is expected to reside in the612 * specified command line arguments.613 *614 * Note: When encountered in 'clang_command_line_args', the following options615 * are ignored:616 *617 * '-c'618 * '-emit-ast'619 * '-fsyntax-only'620 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)621 *622 * \param CIdx The index object with which the translation unit will be623 * associated.624 *625 * \param source_filename The name of the source file to load, or NULL if the626 * source file is included in \p clang_command_line_args.627 *628 * \param num_clang_command_line_args The number of command-line arguments in629 * \p clang_command_line_args.630 *631 * \param clang_command_line_args The command-line arguments that would be632 * passed to the \c clang executable if it were being invoked out-of-process.633 * These command-line options will be parsed and will affect how the translation634 * unit is parsed. Note that the following options are ignored: '-c',635 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.636 *637 * \param num_unsaved_files the number of unsaved file entries in \p638 * unsaved_files.639 *640 * \param unsaved_files the files that have not yet been saved to disk641 * but may be required for code completion, including the contents of642 * those files. The contents and name of these files (as specified by643 * CXUnsavedFile) are copied when necessary, so the client only needs to644 * guarantee their validity until the call to this function returns.645 */646CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(647 CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,648 const char *const *clang_command_line_args, unsigned num_unsaved_files,649 struct CXUnsavedFile *unsaved_files);650 651/**652 * Same as \c clang_createTranslationUnit2, but returns653 * the \c CXTranslationUnit instead of an error code. In case of an error this654 * routine returns a \c NULL \c CXTranslationUnit, without further detailed655 * error codes.656 */657CINDEX_LINKAGE CXTranslationUnit658clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);659 660/**661 * Create a translation unit from an AST file (\c -emit-ast).662 *663 * \param[out] out_TU A non-NULL pointer to store the created664 * \c CXTranslationUnit.665 *666 * \returns Zero on success, otherwise returns an error code.667 */668CINDEX_LINKAGE enum CXErrorCode669clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,670 CXTranslationUnit *out_TU);671 672/**673 * Flags that control the creation of translation units.674 *675 * The enumerators in this enumeration type are meant to be bitwise676 * ORed together to specify which options should be used when677 * constructing the translation unit.678 */679enum CXTranslationUnit_Flags {680 /**681 * Used to indicate that no special translation-unit options are682 * needed.683 */684 CXTranslationUnit_None = 0x0,685 686 /**687 * Used to indicate that the parser should construct a "detailed"688 * preprocessing record, including all macro definitions and instantiations.689 *690 * Constructing a detailed preprocessing record requires more memory691 * and time to parse, since the information contained in the record692 * is usually not retained. However, it can be useful for693 * applications that require more detailed information about the694 * behavior of the preprocessor.695 */696 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,697 698 /**699 * Used to indicate that the translation unit is incomplete.700 *701 * When a translation unit is considered "incomplete", semantic702 * analysis that is typically performed at the end of the703 * translation unit will be suppressed. For example, this suppresses704 * the completion of tentative declarations in C and of705 * instantiation of implicitly-instantiation function templates in706 * C++. This option is typically used when parsing a header with the707 * intent of producing a precompiled header.708 */709 CXTranslationUnit_Incomplete = 0x02,710 711 /**712 * Used to indicate that the translation unit should be built with an713 * implicit precompiled header for the preamble.714 *715 * An implicit precompiled header is used as an optimization when a716 * particular translation unit is likely to be reparsed many times717 * when the sources aren't changing that often. In this case, an718 * implicit precompiled header will be built containing all of the719 * initial includes at the top of the main file (what we refer to as720 * the "preamble" of the file). In subsequent parses, if the721 * preamble or the files in it have not changed, \c722 * clang_reparseTranslationUnit() will re-use the implicit723 * precompiled header to improve parsing performance.724 */725 CXTranslationUnit_PrecompiledPreamble = 0x04,726 727 /**728 * Used to indicate that the translation unit should cache some729 * code-completion results with each reparse of the source file.730 *731 * Caching of code-completion results is a performance optimization that732 * introduces some overhead to reparsing but improves the performance of733 * code-completion operations.734 */735 CXTranslationUnit_CacheCompletionResults = 0x08,736 737 /**738 * Used to indicate that the translation unit will be serialized with739 * \c clang_saveTranslationUnit.740 *741 * This option is typically used when parsing a header with the intent of742 * producing a precompiled header.743 */744 CXTranslationUnit_ForSerialization = 0x10,745 746 /**747 * DEPRECATED: Enabled chained precompiled preambles in C++.748 *749 * Note: this is a *temporary* option that is available only while750 * we are testing C++ precompiled preamble support. It is deprecated.751 */752 CXTranslationUnit_CXXChainedPCH = 0x20,753 754 /**755 * Used to indicate that function/method bodies should be skipped while756 * parsing.757 *758 * This option can be used to search for declarations/definitions while759 * ignoring the usages.760 */761 CXTranslationUnit_SkipFunctionBodies = 0x40,762 763 /**764 * Used to indicate that brief documentation comments should be765 * included into the set of code completions returned from this translation766 * unit.767 */768 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,769 770 /**771 * Used to indicate that the precompiled preamble should be created on772 * the first parse. Otherwise it will be created on the first reparse. This773 * trades runtime on the first parse (serializing the preamble takes time) for774 * reduced runtime on the second parse (can now reuse the preamble).775 */776 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,777 778 /**779 * Do not stop processing when fatal errors are encountered.780 *781 * When fatal errors are encountered while parsing a translation unit,782 * semantic analysis is typically stopped early when compiling code. A common783 * source for fatal errors are unresolvable include files. For the784 * purposes of an IDE, this is undesirable behavior and as much information785 * as possible should be reported. Use this flag to enable this behavior.786 */787 CXTranslationUnit_KeepGoing = 0x200,788 789 /**790 * Sets the preprocessor in a mode for parsing a single file only.791 */792 CXTranslationUnit_SingleFileParse = 0x400,793 794 /**795 * Used in combination with CXTranslationUnit_SkipFunctionBodies to796 * constrain the skipping of function bodies to the preamble.797 *798 * The function bodies of the main file are not skipped.799 */800 CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,801 802 /**803 * Used to indicate that attributed types should be included in CXType.804 */805 CXTranslationUnit_IncludeAttributedTypes = 0x1000,806 807 /**808 * Used to indicate that implicit attributes should be visited.809 */810 CXTranslationUnit_VisitImplicitAttributes = 0x2000,811 812 /**813 * Used to indicate that non-errors from included files should be ignored.814 *815 * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from816 * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for817 * the case where these warnings are not of interest, as for an IDE for818 * example, which typically shows only the diagnostics in the main file.819 */820 CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,821 822 /**823 * Tells the preprocessor not to skip excluded conditional blocks.824 */825 CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000826};827 828/**829 * Returns the set of flags that is suitable for parsing a translation830 * unit that is being edited.831 *832 * The set of flags returned provide options for \c clang_parseTranslationUnit()833 * to indicate that the translation unit is likely to be reparsed many times,834 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly835 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag836 * set contains an unspecified set of optimizations (e.g., the precompiled837 * preamble) geared toward improving the performance of these routines. The838 * set of optimizations enabled may change from one version to the next.839 */840CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);841 842/**843 * Same as \c clang_parseTranslationUnit2, but returns844 * the \c CXTranslationUnit instead of an error code. In case of an error this845 * routine returns a \c NULL \c CXTranslationUnit, without further detailed846 * error codes.847 */848CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(849 CXIndex CIdx, const char *source_filename,850 const char *const *command_line_args, int num_command_line_args,851 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,852 unsigned options);853 854/**855 * Parse the given source file and the translation unit corresponding856 * to that file.857 *858 * This routine is the main entry point for the Clang C API, providing the859 * ability to parse a source file into a translation unit that can then be860 * queried by other functions in the API. This routine accepts a set of861 * command-line arguments so that the compilation can be configured in the same862 * way that the compiler is configured on the command line.863 *864 * \param CIdx The index object with which the translation unit will be865 * associated.866 *867 * \param source_filename The name of the source file to load, or NULL if the868 * source file is included in \c command_line_args.869 *870 * \param command_line_args The command-line arguments that would be871 * passed to the \c clang executable if it were being invoked out-of-process.872 * These command-line options will be parsed and will affect how the translation873 * unit is parsed. Note that the following options are ignored: '-c',874 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.875 *876 * \param num_command_line_args The number of command-line arguments in877 * \c command_line_args.878 *879 * \param unsaved_files the files that have not yet been saved to disk880 * but may be required for parsing, including the contents of881 * those files. The contents and name of these files (as specified by882 * CXUnsavedFile) are copied when necessary, so the client only needs to883 * guarantee their validity until the call to this function returns.884 *885 * \param num_unsaved_files the number of unsaved file entries in \p886 * unsaved_files.887 *888 * \param options A bitmask of options that affects how the translation unit889 * is managed but not its compilation. This should be a bitwise OR of the890 * CXTranslationUnit_XXX flags.891 *892 * \param[out] out_TU A non-NULL pointer to store the created893 * \c CXTranslationUnit, describing the parsed code and containing any894 * diagnostics produced by the compiler.895 *896 * \returns Zero on success, otherwise returns an error code.897 */898CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2(899 CXIndex CIdx, const char *source_filename,900 const char *const *command_line_args, int num_command_line_args,901 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,902 unsigned options, CXTranslationUnit *out_TU);903 904/**905 * Same as clang_parseTranslationUnit2 but requires a full command line906 * for \c command_line_args including argv[0]. This is useful if the standard907 * library paths are relative to the binary.908 */909CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(910 CXIndex CIdx, const char *source_filename,911 const char *const *command_line_args, int num_command_line_args,912 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,913 unsigned options, CXTranslationUnit *out_TU);914 915/**916 * Flags that control how translation units are saved.917 *918 * The enumerators in this enumeration type are meant to be bitwise919 * ORed together to specify which options should be used when920 * saving the translation unit.921 */922enum CXSaveTranslationUnit_Flags {923 /**924 * Used to indicate that no special saving options are needed.925 */926 CXSaveTranslationUnit_None = 0x0927};928 929/**930 * Returns the set of flags that is suitable for saving a translation931 * unit.932 *933 * The set of flags returned provide options for934 * \c clang_saveTranslationUnit() by default. The returned flag935 * set contains an unspecified set of options that save translation units with936 * the most commonly-requested data.937 */938CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);939 940/**941 * Describes the kind of error that occurred (if any) in a call to942 * \c clang_saveTranslationUnit().943 */944enum CXSaveError {945 /**946 * Indicates that no error occurred while saving a translation unit.947 */948 CXSaveError_None = 0,949 950 /**951 * Indicates that an unknown error occurred while attempting to save952 * the file.953 *954 * This error typically indicates that file I/O failed when attempting to955 * write the file.956 */957 CXSaveError_Unknown = 1,958 959 /**960 * Indicates that errors during translation prevented this attempt961 * to save the translation unit.962 *963 * Errors that prevent the translation unit from being saved can be964 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().965 */966 CXSaveError_TranslationErrors = 2,967 968 /**969 * Indicates that the translation unit to be saved was somehow970 * invalid (e.g., NULL).971 */972 CXSaveError_InvalidTU = 3973};974 975/**976 * Saves a translation unit into a serialized representation of977 * that translation unit on disk.978 *979 * Any translation unit that was parsed without error can be saved980 * into a file. The translation unit can then be deserialized into a981 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,982 * if it is an incomplete translation unit that corresponds to a983 * header, used as a precompiled header when parsing other translation984 * units.985 *986 * \param TU The translation unit to save.987 *988 * \param FileName The file to which the translation unit will be saved.989 *990 * \param options A bitmask of options that affects how the translation unit991 * is saved. This should be a bitwise OR of the992 * CXSaveTranslationUnit_XXX flags.993 *994 * \returns A value that will match one of the enumerators of the CXSaveError995 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was996 * saved successfully, while a non-zero value indicates that a problem occurred.997 */998CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,999 const char *FileName,1000 unsigned options);1001 1002/**1003 * Suspend a translation unit in order to free memory associated with it.1004 *1005 * A suspended translation unit uses significantly less memory but on the other1006 * side does not support any other calls than \c clang_reparseTranslationUnit1007 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.1008 */1009CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);1010 1011/**1012 * Destroy the specified CXTranslationUnit object.1013 */1014CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);1015 1016/**1017 * Flags that control the reparsing of translation units.1018 *1019 * The enumerators in this enumeration type are meant to be bitwise1020 * ORed together to specify which options should be used when1021 * reparsing the translation unit.1022 */1023enum CXReparse_Flags {1024 /**1025 * Used to indicate that no special reparsing options are needed.1026 */1027 CXReparse_None = 0x01028};1029 1030/**1031 * Returns the set of flags that is suitable for reparsing a translation1032 * unit.1033 *1034 * The set of flags returned provide options for1035 * \c clang_reparseTranslationUnit() by default. The returned flag1036 * set contains an unspecified set of optimizations geared toward common uses1037 * of reparsing. The set of optimizations enabled may change from one version1038 * to the next.1039 */1040CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);1041 1042/**1043 * Reparse the source files that produced this translation unit.1044 *1045 * This routine can be used to re-parse the source files that originally1046 * created the given translation unit, for example because those source files1047 * have changed (either on disk or as passed via \p unsaved_files). The1048 * source code will be reparsed with the same command-line options as it1049 * was originally parsed.1050 *1051 * Reparsing a translation unit invalidates all cursors and source locations1052 * that refer into that translation unit. This makes reparsing a translation1053 * unit semantically equivalent to destroying the translation unit and then1054 * creating a new translation unit with the same command-line arguments.1055 * However, it may be more efficient to reparse a translation1056 * unit using this routine.1057 *1058 * \param TU The translation unit whose contents will be re-parsed. The1059 * translation unit must originally have been built with1060 * \c clang_createTranslationUnitFromSourceFile().1061 *1062 * \param num_unsaved_files The number of unsaved file entries in \p1063 * unsaved_files.1064 *1065 * \param unsaved_files The files that have not yet been saved to disk1066 * but may be required for parsing, including the contents of1067 * those files. The contents and name of these files (as specified by1068 * CXUnsavedFile) are copied when necessary, so the client only needs to1069 * guarantee their validity until the call to this function returns.1070 *1071 * \param options A bitset of options composed of the flags in CXReparse_Flags.1072 * The function \c clang_defaultReparseOptions() produces a default set of1073 * options recommended for most uses, based on the translation unit.1074 *1075 * \returns 0 if the sources could be reparsed. A non-zero error code will be1076 * returned if reparsing was impossible, such that the translation unit is1077 * invalid. In such cases, the only valid call for \c TU is1078 * \c clang_disposeTranslationUnit(TU). The error codes returned by this1079 * routine are described by the \c CXErrorCode enum.1080 */1081CINDEX_LINKAGE int1082clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,1083 struct CXUnsavedFile *unsaved_files,1084 unsigned options);1085 1086/**1087 * Categorizes how memory is being used by a translation unit.1088 */1089enum CXTUResourceUsageKind {1090 CXTUResourceUsage_AST = 1,1091 CXTUResourceUsage_Identifiers = 2,1092 CXTUResourceUsage_Selectors = 3,1093 CXTUResourceUsage_GlobalCompletionResults = 4,1094 CXTUResourceUsage_SourceManagerContentCache = 5,1095 CXTUResourceUsage_AST_SideTables = 6,1096 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,1097 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,1098 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,1099 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,1100 CXTUResourceUsage_Preprocessor = 11,1101 CXTUResourceUsage_PreprocessingRecord = 12,1102 CXTUResourceUsage_SourceManager_DataStructures = 13,1103 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,1104 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,1105 CXTUResourceUsage_MEMORY_IN_BYTES_END =1106 CXTUResourceUsage_Preprocessor_HeaderSearch,1107 1108 CXTUResourceUsage_First = CXTUResourceUsage_AST,1109 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch1110};1111 1112/**1113 * Returns the human-readable null-terminated C string that represents1114 * the name of the memory category. This string should never be freed.1115 */1116CINDEX_LINKAGE1117const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);1118 1119typedef struct CXTUResourceUsageEntry {1120 /* The memory usage category. */1121 enum CXTUResourceUsageKind kind;1122 /* Amount of resources used.1123 The units will depend on the resource kind. */1124 unsigned long amount;1125} CXTUResourceUsageEntry;1126 1127/**1128 * The memory usage of a CXTranslationUnit, broken into categories.1129 */1130typedef struct CXTUResourceUsage {1131 /* Private data member, used for queries. */1132 void *data;1133 1134 /* The number of entries in the 'entries' array. */1135 unsigned numEntries;1136 1137 /* An array of key-value pairs, representing the breakdown of memory1138 usage. */1139 CXTUResourceUsageEntry *entries;1140 1141} CXTUResourceUsage;1142 1143/**1144 * Return the memory usage of a translation unit. This object1145 * should be released with clang_disposeCXTUResourceUsage().1146 */1147CINDEX_LINKAGE CXTUResourceUsage1148clang_getCXTUResourceUsage(CXTranslationUnit TU);1149 1150CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);1151 1152/**1153 * Get target information for this translation unit.1154 *1155 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.1156 */1157CINDEX_LINKAGE CXTargetInfo1158clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);1159 1160/**1161 * Destroy the CXTargetInfo object.1162 */1163CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);1164 1165/**1166 * Get the normalized target triple as a string.1167 *1168 * Returns the empty string in case of any error.1169 */1170CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);1171 1172/**1173 * Get the pointer width of the target in bits.1174 *1175 * Returns -1 in case of error.1176 */1177CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);1178 1179/**1180 * @}1181 */1182 1183/**1184 * Describes the kind of entity that a cursor refers to.1185 */1186enum CXCursorKind {1187 /* Declarations */1188 /**1189 * A declaration whose specific kind is not exposed via this1190 * interface.1191 *1192 * Unexposed declarations have the same operations as any other kind1193 * of declaration; one can extract their location information,1194 * spelling, find their definitions, etc. However, the specific kind1195 * of the declaration is not reported.1196 */1197 CXCursor_UnexposedDecl = 1,1198 /** A C or C++ struct. */1199 CXCursor_StructDecl = 2,1200 /** A C or C++ union. */1201 CXCursor_UnionDecl = 3,1202 /** A C++ class. */1203 CXCursor_ClassDecl = 4,1204 /** An enumeration. */1205 CXCursor_EnumDecl = 5,1206 /**1207 * A field (in C) or non-static data member (in C++) in a1208 * struct, union, or C++ class.1209 */1210 CXCursor_FieldDecl = 6,1211 /** An enumerator constant. */1212 CXCursor_EnumConstantDecl = 7,1213 /** A function. */1214 CXCursor_FunctionDecl = 8,1215 /** A variable. */1216 CXCursor_VarDecl = 9,1217 /** A function or method parameter. */1218 CXCursor_ParmDecl = 10,1219 /** An Objective-C \@interface. */1220 CXCursor_ObjCInterfaceDecl = 11,1221 /** An Objective-C \@interface for a category. */1222 CXCursor_ObjCCategoryDecl = 12,1223 /** An Objective-C \@protocol declaration. */1224 CXCursor_ObjCProtocolDecl = 13,1225 /** An Objective-C \@property declaration. */1226 CXCursor_ObjCPropertyDecl = 14,1227 /** An Objective-C instance variable. */1228 CXCursor_ObjCIvarDecl = 15,1229 /** An Objective-C instance method. */1230 CXCursor_ObjCInstanceMethodDecl = 16,1231 /** An Objective-C class method. */1232 CXCursor_ObjCClassMethodDecl = 17,1233 /** An Objective-C \@implementation. */1234 CXCursor_ObjCImplementationDecl = 18,1235 /** An Objective-C \@implementation for a category. */1236 CXCursor_ObjCCategoryImplDecl = 19,1237 /** A typedef. */1238 CXCursor_TypedefDecl = 20,1239 /** A C++ class method. */1240 CXCursor_CXXMethod = 21,1241 /** A C++ namespace. */1242 CXCursor_Namespace = 22,1243 /** A linkage specification, e.g. 'extern "C"'. */1244 CXCursor_LinkageSpec = 23,1245 /** A C++ constructor. */1246 CXCursor_Constructor = 24,1247 /** A C++ destructor. */1248 CXCursor_Destructor = 25,1249 /** A C++ conversion function. */1250 CXCursor_ConversionFunction = 26,1251 /** A C++ template type parameter. */1252 CXCursor_TemplateTypeParameter = 27,1253 /** A C++ non-type template parameter. */1254 CXCursor_NonTypeTemplateParameter = 28,1255 /** A C++ template template parameter. */1256 CXCursor_TemplateTemplateParameter = 29,1257 /** A C++ function template. */1258 CXCursor_FunctionTemplate = 30,1259 /** A C++ class template. */1260 CXCursor_ClassTemplate = 31,1261 /** A C++ class template partial specialization. */1262 CXCursor_ClassTemplatePartialSpecialization = 32,1263 /** A C++ namespace alias declaration. */1264 CXCursor_NamespaceAlias = 33,1265 /** A C++ using directive. */1266 CXCursor_UsingDirective = 34,1267 /** A C++ using declaration. */1268 CXCursor_UsingDeclaration = 35,1269 /** A C++ alias declaration */1270 CXCursor_TypeAliasDecl = 36,1271 /** An Objective-C \@synthesize definition. */1272 CXCursor_ObjCSynthesizeDecl = 37,1273 /** An Objective-C \@dynamic definition. */1274 CXCursor_ObjCDynamicDecl = 38,1275 /** An access specifier. */1276 CXCursor_CXXAccessSpecifier = 39,1277 1278 CXCursor_FirstDecl = CXCursor_UnexposedDecl,1279 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,1280 1281 /* References */1282 CXCursor_FirstRef = 40, /* Decl references */1283 CXCursor_ObjCSuperClassRef = 40,1284 CXCursor_ObjCProtocolRef = 41,1285 CXCursor_ObjCClassRef = 42,1286 /**1287 * A reference to a type declaration.1288 *1289 * A type reference occurs anywhere where a type is named but not1290 * declared. For example, given:1291 *1292 * \code1293 * typedef unsigned size_type;1294 * size_type size;1295 * \endcode1296 *1297 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),1298 * while the type of the variable "size" is referenced. The cursor1299 * referenced by the type of size is the typedef for size_type.1300 */1301 CXCursor_TypeRef = 43,1302 CXCursor_CXXBaseSpecifier = 44,1303 /**1304 * A reference to a class template, function template, template1305 * template parameter, or class template partial specialization.1306 */1307 CXCursor_TemplateRef = 45,1308 /**1309 * A reference to a namespace or namespace alias.1310 */1311 CXCursor_NamespaceRef = 46,1312 /**1313 * A reference to a member of a struct, union, or class that occurs in1314 * some non-expression context, e.g., a designated initializer.1315 */1316 CXCursor_MemberRef = 47,1317 /**1318 * A reference to a labeled statement.1319 *1320 * This cursor kind is used to describe the jump to "start_over" in the1321 * goto statement in the following example:1322 *1323 * \code1324 * start_over:1325 * ++counter;1326 *1327 * goto start_over;1328 * \endcode1329 *1330 * A label reference cursor refers to a label statement.1331 */1332 CXCursor_LabelRef = 48,1333 1334 /**1335 * A reference to a set of overloaded functions or function templates1336 * that has not yet been resolved to a specific function or function template.1337 *1338 * An overloaded declaration reference cursor occurs in C++ templates where1339 * a dependent name refers to a function. For example:1340 *1341 * \code1342 * template<typename T> void swap(T&, T&);1343 *1344 * struct X { ... };1345 * void swap(X&, X&);1346 *1347 * template<typename T>1348 * void reverse(T* first, T* last) {1349 * while (first < last - 1) {1350 * swap(*first, *--last);1351 * ++first;1352 * }1353 * }1354 *1355 * struct Y { };1356 * void swap(Y&, Y&);1357 * \endcode1358 *1359 * Here, the identifier "swap" is associated with an overloaded declaration1360 * reference. In the template definition, "swap" refers to either of the two1361 * "swap" functions declared above, so both results will be available. At1362 * instantiation time, "swap" may also refer to other functions found via1363 * argument-dependent lookup (e.g., the "swap" function at the end of the1364 * example).1365 *1366 * The functions \c clang_getNumOverloadedDecls() and1367 * \c clang_getOverloadedDecl() can be used to retrieve the definitions1368 * referenced by this cursor.1369 */1370 CXCursor_OverloadedDeclRef = 49,1371 1372 /**1373 * A reference to a variable that occurs in some non-expression1374 * context, e.g., a C++ lambda capture list.1375 */1376 CXCursor_VariableRef = 50,1377 1378 CXCursor_LastRef = CXCursor_VariableRef,1379 1380 /* Error conditions */1381 CXCursor_FirstInvalid = 70,1382 CXCursor_InvalidFile = 70,1383 CXCursor_NoDeclFound = 71,1384 CXCursor_NotImplemented = 72,1385 CXCursor_InvalidCode = 73,1386 CXCursor_LastInvalid = CXCursor_InvalidCode,1387 1388 /* Expressions */1389 CXCursor_FirstExpr = 100,1390 1391 /**1392 * An expression whose specific kind is not exposed via this1393 * interface.1394 *1395 * Unexposed expressions have the same operations as any other kind1396 * of expression; one can extract their location information,1397 * spelling, children, etc. However, the specific kind of the1398 * expression is not reported.1399 */1400 CXCursor_UnexposedExpr = 100,1401 1402 /**1403 * An expression that refers to some value declaration, such1404 * as a function, variable, or enumerator.1405 */1406 CXCursor_DeclRefExpr = 101,1407 1408 /**1409 * An expression that refers to a member of a struct, union,1410 * class, Objective-C class, etc.1411 */1412 CXCursor_MemberRefExpr = 102,1413 1414 /** An expression that calls a function. */1415 CXCursor_CallExpr = 103,1416 1417 /** An expression that sends a message to an Objective-C1418 object or class. */1419 CXCursor_ObjCMessageExpr = 104,1420 1421 /** An expression that represents a block literal. */1422 CXCursor_BlockExpr = 105,1423 1424 /** An integer literal.1425 */1426 CXCursor_IntegerLiteral = 106,1427 1428 /** A floating point number literal.1429 */1430 CXCursor_FloatingLiteral = 107,1431 1432 /** An imaginary number literal.1433 */1434 CXCursor_ImaginaryLiteral = 108,1435 1436 /** A string literal.1437 */1438 CXCursor_StringLiteral = 109,1439 1440 /** A character literal.1441 */1442 CXCursor_CharacterLiteral = 110,1443 1444 /** A parenthesized expression, e.g. "(1)".1445 *1446 * This AST node is only formed if full location information is requested.1447 */1448 CXCursor_ParenExpr = 111,1449 1450 /** This represents the unary-expression's (except sizeof and1451 * alignof).1452 */1453 CXCursor_UnaryOperator = 112,1454 1455 /** [C99 6.5.2.1] Array Subscripting.1456 */1457 CXCursor_ArraySubscriptExpr = 113,1458 1459 /** A builtin binary operation expression such as "x + y" or1460 * "x <= y".1461 */1462 CXCursor_BinaryOperator = 114,1463 1464 /** Compound assignment such as "+=".1465 */1466 CXCursor_CompoundAssignOperator = 115,1467 1468 /** The ?: ternary operator.1469 */1470 CXCursor_ConditionalOperator = 116,1471 1472 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++1473 * (C++ [expr.cast]), which uses the syntax (Type)expr.1474 *1475 * For example: (int)f.1476 */1477 CXCursor_CStyleCastExpr = 117,1478 1479 /** [C99 6.5.2.5]1480 */1481 CXCursor_CompoundLiteralExpr = 118,1482 1483 /** Describes an C or C++ initializer list.1484 */1485 CXCursor_InitListExpr = 119,1486 1487 /** The GNU address of label extension, representing &&label.1488 */1489 CXCursor_AddrLabelExpr = 120,1490 1491 /** This is the GNU Statement Expression extension: ({int X=4; X;})1492 */1493 CXCursor_StmtExpr = 121,1494 1495 /** Represents a C11 generic selection.1496 */1497 CXCursor_GenericSelectionExpr = 122,1498 1499 /** Implements the GNU __null extension, which is a name for a null1500 * pointer constant that has integral type (e.g., int or long) and is the same1501 * size and alignment as a pointer.1502 *1503 * The __null extension is typically only used by system headers, which define1504 * NULL as __null in C++ rather than using 0 (which is an integer that may not1505 * match the size of a pointer).1506 */1507 CXCursor_GNUNullExpr = 123,1508 1509 /** C++'s static_cast<> expression.1510 */1511 CXCursor_CXXStaticCastExpr = 124,1512 1513 /** C++'s dynamic_cast<> expression.1514 */1515 CXCursor_CXXDynamicCastExpr = 125,1516 1517 /** C++'s reinterpret_cast<> expression.1518 */1519 CXCursor_CXXReinterpretCastExpr = 126,1520 1521 /** C++'s const_cast<> expression.1522 */1523 CXCursor_CXXConstCastExpr = 127,1524 1525 /** Represents an explicit C++ type conversion that uses "functional"1526 * notion (C++ [expr.type.conv]).1527 *1528 * Example:1529 * \code1530 * x = int(0.5);1531 * \endcode1532 */1533 CXCursor_CXXFunctionalCastExpr = 128,1534 1535 /** A C++ typeid expression (C++ [expr.typeid]).1536 */1537 CXCursor_CXXTypeidExpr = 129,1538 1539 /** [C++ 2.13.5] C++ Boolean Literal.1540 */1541 CXCursor_CXXBoolLiteralExpr = 130,1542 1543 /** [C++0x 2.14.7] C++ Pointer Literal.1544 */1545 CXCursor_CXXNullPtrLiteralExpr = 131,1546 1547 /** Represents the "this" expression in C++1548 */1549 CXCursor_CXXThisExpr = 132,1550 1551 /** [C++ 15] C++ Throw Expression.1552 *1553 * This handles 'throw' and 'throw' assignment-expression. When1554 * assignment-expression isn't present, Op will be null.1555 */1556 CXCursor_CXXThrowExpr = 133,1557 1558 /** A new expression for memory allocation and constructor calls, e.g:1559 * "new CXXNewExpr(foo)".1560 */1561 CXCursor_CXXNewExpr = 134,1562 1563 /** A delete expression for memory deallocation and destructor calls,1564 * e.g. "delete[] pArray".1565 */1566 CXCursor_CXXDeleteExpr = 135,1567 1568 /** A unary expression. (noexcept, sizeof, or other traits)1569 */1570 CXCursor_UnaryExpr = 136,1571 1572 /** An Objective-C string literal i.e. @"foo".1573 */1574 CXCursor_ObjCStringLiteral = 137,1575 1576 /** An Objective-C \@encode expression.1577 */1578 CXCursor_ObjCEncodeExpr = 138,1579 1580 /** An Objective-C \@selector expression.1581 */1582 CXCursor_ObjCSelectorExpr = 139,1583 1584 /** An Objective-C \@protocol expression.1585 */1586 CXCursor_ObjCProtocolExpr = 140,1587 1588 /** An Objective-C "bridged" cast expression, which casts between1589 * Objective-C pointers and C pointers, transferring ownership in the process.1590 *1591 * \code1592 * NSString *str = (__bridge_transfer NSString *)CFCreateString();1593 * \endcode1594 */1595 CXCursor_ObjCBridgedCastExpr = 141,1596 1597 /** Represents a C++0x pack expansion that produces a sequence of1598 * expressions.1599 *1600 * A pack expansion expression contains a pattern (which itself is an1601 * expression) followed by an ellipsis. For example:1602 *1603 * \code1604 * template<typename F, typename ...Types>1605 * void forward(F f, Types &&...args) {1606 * f(static_cast<Types&&>(args)...);1607 * }1608 * \endcode1609 */1610 CXCursor_PackExpansionExpr = 142,1611 1612 /** Represents an expression that computes the length of a parameter1613 * pack.1614 *1615 * \code1616 * template<typename ...Types>1617 * struct count {1618 * static const unsigned value = sizeof...(Types);1619 * };1620 * \endcode1621 */1622 CXCursor_SizeOfPackExpr = 143,1623 1624 /* Represents a C++ lambda expression that produces a local function1625 * object.1626 *1627 * \code1628 * void abssort(float *x, unsigned N) {1629 * std::sort(x, x + N,1630 * [](float a, float b) {1631 * return std::abs(a) < std::abs(b);1632 * });1633 * }1634 * \endcode1635 */1636 CXCursor_LambdaExpr = 144,1637 1638 /** Objective-c Boolean Literal.1639 */1640 CXCursor_ObjCBoolLiteralExpr = 145,1641 1642 /** Represents the "self" expression in an Objective-C method.1643 */1644 CXCursor_ObjCSelfExpr = 146,1645 1646 /** OpenMP 5.0 [2.1.5, Array Section].1647 * OpenACC 3.3 [2.7.1, Data Specification for Data Clauses (Sub Arrays)]1648 */1649 CXCursor_ArraySectionExpr = 147,1650 1651 /** Represents an @available(...) check.1652 */1653 CXCursor_ObjCAvailabilityCheckExpr = 148,1654 1655 /**1656 * Fixed point literal1657 */1658 CXCursor_FixedPointLiteral = 149,1659 1660 /** OpenMP 5.0 [2.1.4, Array Shaping].1661 */1662 CXCursor_OMPArrayShapingExpr = 150,1663 1664 /**1665 * OpenMP 5.0 [2.1.6 Iterators]1666 */1667 CXCursor_OMPIteratorExpr = 151,1668 1669 /** OpenCL's addrspace_cast<> expression.1670 */1671 CXCursor_CXXAddrspaceCastExpr = 152,1672 1673 /**1674 * Expression that references a C++20 concept.1675 */1676 CXCursor_ConceptSpecializationExpr = 153,1677 1678 /**1679 * Expression that references a C++20 requires expression.1680 */1681 CXCursor_RequiresExpr = 154,1682 1683 /**1684 * Expression that references a C++20 parenthesized list aggregate1685 * initializer.1686 */1687 CXCursor_CXXParenListInitExpr = 155,1688 1689 /**1690 * Represents a C++26 pack indexing expression.1691 */1692 CXCursor_PackIndexingExpr = 156,1693 1694 CXCursor_LastExpr = CXCursor_PackIndexingExpr,1695 1696 /* Statements */1697 CXCursor_FirstStmt = 200,1698 /**1699 * A statement whose specific kind is not exposed via this1700 * interface.1701 *1702 * Unexposed statements have the same operations as any other kind of1703 * statement; one can extract their location information, spelling,1704 * children, etc. However, the specific kind of the statement is not1705 * reported.1706 */1707 CXCursor_UnexposedStmt = 200,1708 1709 /** A labelled statement in a function.1710 *1711 * This cursor kind is used to describe the "start_over:" label statement in1712 * the following example:1713 *1714 * \code1715 * start_over:1716 * ++counter;1717 * \endcode1718 *1719 */1720 CXCursor_LabelStmt = 201,1721 1722 /** A group of statements like { stmt stmt }.1723 *1724 * This cursor kind is used to describe compound statements, e.g. function1725 * bodies.1726 */1727 CXCursor_CompoundStmt = 202,1728 1729 /** A case statement.1730 */1731 CXCursor_CaseStmt = 203,1732 1733 /** A default statement.1734 */1735 CXCursor_DefaultStmt = 204,1736 1737 /** An if statement1738 */1739 CXCursor_IfStmt = 205,1740 1741 /** A switch statement.1742 */1743 CXCursor_SwitchStmt = 206,1744 1745 /** A while statement.1746 */1747 CXCursor_WhileStmt = 207,1748 1749 /** A do statement.1750 */1751 CXCursor_DoStmt = 208,1752 1753 /** A for statement.1754 */1755 CXCursor_ForStmt = 209,1756 1757 /** A goto statement.1758 */1759 CXCursor_GotoStmt = 210,1760 1761 /** An indirect goto statement.1762 */1763 CXCursor_IndirectGotoStmt = 211,1764 1765 /** A continue statement.1766 */1767 CXCursor_ContinueStmt = 212,1768 1769 /** A break statement.1770 */1771 CXCursor_BreakStmt = 213,1772 1773 /** A return statement.1774 */1775 CXCursor_ReturnStmt = 214,1776 1777 /** A GCC inline assembly statement extension.1778 */1779 CXCursor_GCCAsmStmt = 215,1780 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,1781 1782 /** Objective-C's overall \@try-\@catch-\@finally statement.1783 */1784 CXCursor_ObjCAtTryStmt = 216,1785 1786 /** Objective-C's \@catch statement.1787 */1788 CXCursor_ObjCAtCatchStmt = 217,1789 1790 /** Objective-C's \@finally statement.1791 */1792 CXCursor_ObjCAtFinallyStmt = 218,1793 1794 /** Objective-C's \@throw statement.1795 */1796 CXCursor_ObjCAtThrowStmt = 219,1797 1798 /** Objective-C's \@synchronized statement.1799 */1800 CXCursor_ObjCAtSynchronizedStmt = 220,1801 1802 /** Objective-C's autorelease pool statement.1803 */1804 CXCursor_ObjCAutoreleasePoolStmt = 221,1805 1806 /** Objective-C's collection statement.1807 */1808 CXCursor_ObjCForCollectionStmt = 222,1809 1810 /** C++'s catch statement.1811 */1812 CXCursor_CXXCatchStmt = 223,1813 1814 /** C++'s try statement.1815 */1816 CXCursor_CXXTryStmt = 224,1817 1818 /** C++'s for (* : *) statement.1819 */1820 CXCursor_CXXForRangeStmt = 225,1821 1822 /** Windows Structured Exception Handling's try statement.1823 */1824 CXCursor_SEHTryStmt = 226,1825 1826 /** Windows Structured Exception Handling's except statement.1827 */1828 CXCursor_SEHExceptStmt = 227,1829 1830 /** Windows Structured Exception Handling's finally statement.1831 */1832 CXCursor_SEHFinallyStmt = 228,1833 1834 /** A MS inline assembly statement extension.1835 */1836 CXCursor_MSAsmStmt = 229,1837 1838 /** The null statement ";": C99 6.8.3p3.1839 *1840 * This cursor kind is used to describe the null statement.1841 */1842 CXCursor_NullStmt = 230,1843 1844 /** Adaptor class for mixing declarations with statements and1845 * expressions.1846 */1847 CXCursor_DeclStmt = 231,1848 1849 /** OpenMP parallel directive.1850 */1851 CXCursor_OMPParallelDirective = 232,1852 1853 /** OpenMP SIMD directive.1854 */1855 CXCursor_OMPSimdDirective = 233,1856 1857 /** OpenMP for directive.1858 */1859 CXCursor_OMPForDirective = 234,1860 1861 /** OpenMP sections directive.1862 */1863 CXCursor_OMPSectionsDirective = 235,1864 1865 /** OpenMP section directive.1866 */1867 CXCursor_OMPSectionDirective = 236,1868 1869 /** OpenMP single directive.1870 */1871 CXCursor_OMPSingleDirective = 237,1872 1873 /** OpenMP parallel for directive.1874 */1875 CXCursor_OMPParallelForDirective = 238,1876 1877 /** OpenMP parallel sections directive.1878 */1879 CXCursor_OMPParallelSectionsDirective = 239,1880 1881 /** OpenMP task directive.1882 */1883 CXCursor_OMPTaskDirective = 240,1884 1885 /** OpenMP master directive.1886 */1887 CXCursor_OMPMasterDirective = 241,1888 1889 /** OpenMP critical directive.1890 */1891 CXCursor_OMPCriticalDirective = 242,1892 1893 /** OpenMP taskyield directive.1894 */1895 CXCursor_OMPTaskyieldDirective = 243,1896 1897 /** OpenMP barrier directive.1898 */1899 CXCursor_OMPBarrierDirective = 244,1900 1901 /** OpenMP taskwait directive.1902 */1903 CXCursor_OMPTaskwaitDirective = 245,1904 1905 /** OpenMP flush directive.1906 */1907 CXCursor_OMPFlushDirective = 246,1908 1909 /** Windows Structured Exception Handling's leave statement.1910 */1911 CXCursor_SEHLeaveStmt = 247,1912 1913 /** OpenMP ordered directive.1914 */1915 CXCursor_OMPOrderedDirective = 248,1916 1917 /** OpenMP atomic directive.1918 */1919 CXCursor_OMPAtomicDirective = 249,1920 1921 /** OpenMP for SIMD directive.1922 */1923 CXCursor_OMPForSimdDirective = 250,1924 1925 /** OpenMP parallel for SIMD directive.1926 */1927 CXCursor_OMPParallelForSimdDirective = 251,1928 1929 /** OpenMP target directive.1930 */1931 CXCursor_OMPTargetDirective = 252,1932 1933 /** OpenMP teams directive.1934 */1935 CXCursor_OMPTeamsDirective = 253,1936 1937 /** OpenMP taskgroup directive.1938 */1939 CXCursor_OMPTaskgroupDirective = 254,1940 1941 /** OpenMP cancellation point directive.1942 */1943 CXCursor_OMPCancellationPointDirective = 255,1944 1945 /** OpenMP cancel directive.1946 */1947 CXCursor_OMPCancelDirective = 256,1948 1949 /** OpenMP target data directive.1950 */1951 CXCursor_OMPTargetDataDirective = 257,1952 1953 /** OpenMP taskloop directive.1954 */1955 CXCursor_OMPTaskLoopDirective = 258,1956 1957 /** OpenMP taskloop simd directive.1958 */1959 CXCursor_OMPTaskLoopSimdDirective = 259,1960 1961 /** OpenMP distribute directive.1962 */1963 CXCursor_OMPDistributeDirective = 260,1964 1965 /** OpenMP target enter data directive.1966 */1967 CXCursor_OMPTargetEnterDataDirective = 261,1968 1969 /** OpenMP target exit data directive.1970 */1971 CXCursor_OMPTargetExitDataDirective = 262,1972 1973 /** OpenMP target parallel directive.1974 */1975 CXCursor_OMPTargetParallelDirective = 263,1976 1977 /** OpenMP target parallel for directive.1978 */1979 CXCursor_OMPTargetParallelForDirective = 264,1980 1981 /** OpenMP target update directive.1982 */1983 CXCursor_OMPTargetUpdateDirective = 265,1984 1985 /** OpenMP distribute parallel for directive.1986 */1987 CXCursor_OMPDistributeParallelForDirective = 266,1988 1989 /** OpenMP distribute parallel for simd directive.1990 */1991 CXCursor_OMPDistributeParallelForSimdDirective = 267,1992 1993 /** OpenMP distribute simd directive.1994 */1995 CXCursor_OMPDistributeSimdDirective = 268,1996 1997 /** OpenMP target parallel for simd directive.1998 */1999 CXCursor_OMPTargetParallelForSimdDirective = 269,2000 2001 /** OpenMP target simd directive.2002 */2003 CXCursor_OMPTargetSimdDirective = 270,2004 2005 /** OpenMP teams distribute directive.2006 */2007 CXCursor_OMPTeamsDistributeDirective = 271,2008 2009 /** OpenMP teams distribute simd directive.2010 */2011 CXCursor_OMPTeamsDistributeSimdDirective = 272,2012 2013 /** OpenMP teams distribute parallel for simd directive.2014 */2015 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,2016 2017 /** OpenMP teams distribute parallel for directive.2018 */2019 CXCursor_OMPTeamsDistributeParallelForDirective = 274,2020 2021 /** OpenMP target teams directive.2022 */2023 CXCursor_OMPTargetTeamsDirective = 275,2024 2025 /** OpenMP target teams distribute directive.2026 */2027 CXCursor_OMPTargetTeamsDistributeDirective = 276,2028 2029 /** OpenMP target teams distribute parallel for directive.2030 */2031 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,2032 2033 /** OpenMP target teams distribute parallel for simd directive.2034 */2035 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,2036 2037 /** OpenMP target teams distribute simd directive.2038 */2039 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,2040 2041 /** C++2a std::bit_cast expression.2042 */2043 CXCursor_BuiltinBitCastExpr = 280,2044 2045 /** OpenMP master taskloop directive.2046 */2047 CXCursor_OMPMasterTaskLoopDirective = 281,2048 2049 /** OpenMP parallel master taskloop directive.2050 */2051 CXCursor_OMPParallelMasterTaskLoopDirective = 282,2052 2053 /** OpenMP master taskloop simd directive.2054 */2055 CXCursor_OMPMasterTaskLoopSimdDirective = 283,2056 2057 /** OpenMP parallel master taskloop simd directive.2058 */2059 CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,2060 2061 /** OpenMP parallel master directive.2062 */2063 CXCursor_OMPParallelMasterDirective = 285,2064 2065 /** OpenMP depobj directive.2066 */2067 CXCursor_OMPDepobjDirective = 286,2068 2069 /** OpenMP scan directive.2070 */2071 CXCursor_OMPScanDirective = 287,2072 2073 /** OpenMP tile directive.2074 */2075 CXCursor_OMPTileDirective = 288,2076 2077 /** OpenMP canonical loop.2078 */2079 CXCursor_OMPCanonicalLoop = 289,2080 2081 /** OpenMP interop directive.2082 */2083 CXCursor_OMPInteropDirective = 290,2084 2085 /** OpenMP dispatch directive.2086 */2087 CXCursor_OMPDispatchDirective = 291,2088 2089 /** OpenMP masked directive.2090 */2091 CXCursor_OMPMaskedDirective = 292,2092 2093 /** OpenMP unroll directive.2094 */2095 CXCursor_OMPUnrollDirective = 293,2096 2097 /** OpenMP metadirective directive.2098 */2099 CXCursor_OMPMetaDirective = 294,2100 2101 /** OpenMP loop directive.2102 */2103 CXCursor_OMPGenericLoopDirective = 295,2104 2105 /** OpenMP teams loop directive.2106 */2107 CXCursor_OMPTeamsGenericLoopDirective = 296,2108 2109 /** OpenMP target teams loop directive.2110 */2111 CXCursor_OMPTargetTeamsGenericLoopDirective = 297,2112 2113 /** OpenMP parallel loop directive.2114 */2115 CXCursor_OMPParallelGenericLoopDirective = 298,2116 2117 /** OpenMP target parallel loop directive.2118 */2119 CXCursor_OMPTargetParallelGenericLoopDirective = 299,2120 2121 /** OpenMP parallel masked directive.2122 */2123 CXCursor_OMPParallelMaskedDirective = 300,2124 2125 /** OpenMP masked taskloop directive.2126 */2127 CXCursor_OMPMaskedTaskLoopDirective = 301,2128 2129 /** OpenMP masked taskloop simd directive.2130 */2131 CXCursor_OMPMaskedTaskLoopSimdDirective = 302,2132 2133 /** OpenMP parallel masked taskloop directive.2134 */2135 CXCursor_OMPParallelMaskedTaskLoopDirective = 303,2136 2137 /** OpenMP parallel masked taskloop simd directive.2138 */2139 CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304,2140 2141 /** OpenMP error directive.2142 */2143 CXCursor_OMPErrorDirective = 305,2144 2145 /** OpenMP scope directive.2146 */2147 CXCursor_OMPScopeDirective = 306,2148 2149 /** OpenMP reverse directive.2150 */2151 CXCursor_OMPReverseDirective = 307,2152 2153 /** OpenMP interchange directive.2154 */2155 CXCursor_OMPInterchangeDirective = 308,2156 2157 /** OpenMP assume directive.2158 */2159 CXCursor_OMPAssumeDirective = 309,2160 2161 /** OpenMP assume directive.2162 */2163 CXCursor_OMPStripeDirective = 310,2164 2165 /** OpenMP fuse directive2166 */2167 CXCursor_OMPFuseDirective = 311,2168 2169 /** OpenACC Compute Construct.2170 */2171 CXCursor_OpenACCComputeConstruct = 320,2172 2173 /** OpenACC Loop Construct.2174 */2175 CXCursor_OpenACCLoopConstruct = 321,2176 2177 /** OpenACC Combined Constructs.2178 */2179 CXCursor_OpenACCCombinedConstruct = 322,2180 2181 /** OpenACC data Construct.2182 */2183 CXCursor_OpenACCDataConstruct = 323,2184 2185 /** OpenACC enter data Construct.2186 */2187 CXCursor_OpenACCEnterDataConstruct = 324,2188 2189 /** OpenACC exit data Construct.2190 */2191 CXCursor_OpenACCExitDataConstruct = 325,2192 2193 /** OpenACC host_data Construct.2194 */2195 CXCursor_OpenACCHostDataConstruct = 326,2196 2197 /** OpenACC wait Construct.2198 */2199 CXCursor_OpenACCWaitConstruct = 327,2200 2201 /** OpenACC init Construct.2202 */2203 CXCursor_OpenACCInitConstruct = 328,2204 2205 /** OpenACC shutdown Construct.2206 */2207 CXCursor_OpenACCShutdownConstruct = 329,2208 2209 /** OpenACC set Construct.2210 */2211 CXCursor_OpenACCSetConstruct = 330,2212 2213 /** OpenACC update Construct.2214 */2215 CXCursor_OpenACCUpdateConstruct = 331,2216 2217 /** OpenACC atomic Construct.2218 */2219 CXCursor_OpenACCAtomicConstruct = 332,2220 2221 /** OpenACC cache Construct.2222 */2223 CXCursor_OpenACCCacheConstruct = 333,2224 2225 CXCursor_LastStmt = CXCursor_OpenACCCacheConstruct,2226 2227 /**2228 * Cursor that represents the translation unit itself.2229 *2230 * The translation unit cursor exists primarily to act as the root2231 * cursor for traversing the contents of a translation unit.2232 */2233 CXCursor_TranslationUnit = 350,2234 2235 /* Attributes */2236 CXCursor_FirstAttr = 400,2237 /**2238 * An attribute whose specific kind is not exposed via this2239 * interface.2240 */2241 CXCursor_UnexposedAttr = 400,2242 2243 CXCursor_IBActionAttr = 401,2244 CXCursor_IBOutletAttr = 402,2245 CXCursor_IBOutletCollectionAttr = 403,2246 CXCursor_CXXFinalAttr = 404,2247 CXCursor_CXXOverrideAttr = 405,2248 CXCursor_AnnotateAttr = 406,2249 CXCursor_AsmLabelAttr = 407,2250 CXCursor_PackedAttr = 408,2251 CXCursor_PureAttr = 409,2252 CXCursor_ConstAttr = 410,2253 CXCursor_NoDuplicateAttr = 411,2254 CXCursor_CUDAConstantAttr = 412,2255 CXCursor_CUDADeviceAttr = 413,2256 CXCursor_CUDAGlobalAttr = 414,2257 CXCursor_CUDAHostAttr = 415,2258 CXCursor_CUDASharedAttr = 416,2259 CXCursor_VisibilityAttr = 417,2260 CXCursor_DLLExport = 418,2261 CXCursor_DLLImport = 419,2262 CXCursor_NSReturnsRetained = 420,2263 CXCursor_NSReturnsNotRetained = 421,2264 CXCursor_NSReturnsAutoreleased = 422,2265 CXCursor_NSConsumesSelf = 423,2266 CXCursor_NSConsumed = 424,2267 CXCursor_ObjCException = 425,2268 CXCursor_ObjCNSObject = 426,2269 CXCursor_ObjCIndependentClass = 427,2270 CXCursor_ObjCPreciseLifetime = 428,2271 CXCursor_ObjCReturnsInnerPointer = 429,2272 CXCursor_ObjCRequiresSuper = 430,2273 CXCursor_ObjCRootClass = 431,2274 CXCursor_ObjCSubclassingRestricted = 432,2275 CXCursor_ObjCExplicitProtocolImpl = 433,2276 CXCursor_ObjCDesignatedInitializer = 434,2277 CXCursor_ObjCRuntimeVisible = 435,2278 CXCursor_ObjCBoxable = 436,2279 CXCursor_FlagEnum = 437,2280 CXCursor_ConvergentAttr = 438,2281 CXCursor_WarnUnusedAttr = 439,2282 CXCursor_WarnUnusedResultAttr = 440,2283 CXCursor_AlignedAttr = 441,2284 CXCursor_LastAttr = CXCursor_AlignedAttr,2285 2286 /* Preprocessing */2287 CXCursor_PreprocessingDirective = 500,2288 CXCursor_MacroDefinition = 501,2289 CXCursor_MacroExpansion = 502,2290 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,2291 CXCursor_InclusionDirective = 503,2292 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,2293 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,2294 2295 /* Extra Declarations */2296 /**2297 * A module import declaration.2298 */2299 CXCursor_ModuleImportDecl = 600,2300 CXCursor_TypeAliasTemplateDecl = 601,2301 /**2302 * A static_assert or _Static_assert node2303 */2304 CXCursor_StaticAssert = 602,2305 /**2306 * a friend declaration.2307 */2308 CXCursor_FriendDecl = 603,2309 /**2310 * a concept declaration.2311 */2312 CXCursor_ConceptDecl = 604,2313 2314 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,2315 CXCursor_LastExtraDecl = CXCursor_ConceptDecl,2316 2317 /**2318 * A code completion overload candidate.2319 */2320 CXCursor_OverloadCandidate = 7002321};2322 2323/**2324 * A cursor representing some element in the abstract syntax tree for2325 * a translation unit.2326 *2327 * The cursor abstraction unifies the different kinds of entities in a2328 * program--declaration, statements, expressions, references to declarations,2329 * etc.--under a single "cursor" abstraction with a common set of operations.2330 * Common operation for a cursor include: getting the physical location in2331 * a source file where the cursor points, getting the name associated with a2332 * cursor, and retrieving cursors for any child nodes of a particular cursor.2333 *2334 * Cursors can be produced in two specific ways.2335 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,2336 * from which one can use clang_visitChildren() to explore the rest of the2337 * translation unit. clang_getCursor() maps from a physical source location2338 * to the entity that resides at that location, allowing one to map from the2339 * source code into the AST.2340 */2341typedef struct {2342 enum CXCursorKind kind;2343 int xdata;2344 const void *data[3];2345} CXCursor;2346 2347/**2348 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations2349 *2350 * @{2351 */2352 2353/**2354 * Retrieve the NULL cursor, which represents no entity.2355 */2356CINDEX_LINKAGE CXCursor clang_getNullCursor(void);2357 2358/**2359 * Retrieve the cursor that represents the given translation unit.2360 *2361 * The translation unit cursor can be used to start traversing the2362 * various declarations within the given translation unit.2363 */2364CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);2365 2366/**2367 * Determine whether two cursors are equivalent.2368 */2369CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);2370 2371/**2372 * Returns non-zero if \p cursor is null.2373 */2374CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);2375 2376/**2377 * Compute a hash value for the given cursor.2378 */2379CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);2380 2381/**2382 * Retrieve the kind of the given cursor.2383 */2384CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);2385 2386/**2387 * Determine whether the given cursor kind represents a declaration.2388 */2389CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);2390 2391/**2392 * Determine whether the given declaration is invalid.2393 *2394 * A declaration is invalid if it could not be parsed successfully.2395 *2396 * \returns non-zero if the cursor represents a declaration and it is2397 * invalid, otherwise NULL.2398 */2399CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);2400 2401/**2402 * Determine whether the given cursor kind represents a simple2403 * reference.2404 *2405 * Note that other kinds of cursors (such as expressions) can also refer to2406 * other cursors. Use clang_getCursorReferenced() to determine whether a2407 * particular cursor refers to another entity.2408 */2409CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);2410 2411/**2412 * Determine whether the given cursor kind represents an expression.2413 */2414CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);2415 2416/**2417 * Determine whether the given cursor kind represents a statement.2418 */2419CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);2420 2421/**2422 * Determine whether the given cursor kind represents an attribute.2423 */2424CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);2425 2426/**2427 * Determine whether the given cursor has any attributes.2428 */2429CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);2430 2431/**2432 * Determine whether the given cursor kind represents an invalid2433 * cursor.2434 */2435CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);2436 2437/**2438 * Determine whether the given cursor kind represents a translation2439 * unit.2440 */2441CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);2442 2443/***2444 * Determine whether the given cursor represents a preprocessing2445 * element, such as a preprocessor directive or macro instantiation.2446 */2447CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);2448 2449/***2450 * Determine whether the given cursor represents a currently2451 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).2452 */2453CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);2454 2455/**2456 * Describe the linkage of the entity referred to by a cursor.2457 */2458enum CXLinkageKind {2459 /** This value indicates that no linkage information is available2460 * for a provided CXCursor. */2461 CXLinkage_Invalid,2462 /**2463 * This is the linkage for variables, parameters, and so on that2464 * have automatic storage. This covers normal (non-extern) local variables.2465 */2466 CXLinkage_NoLinkage,2467 /** This is the linkage for static variables and static functions. */2468 CXLinkage_Internal,2469 /** This is the linkage for entities with external linkage that live2470 * in C++ anonymous namespaces.*/2471 CXLinkage_UniqueExternal,2472 /** This is the linkage for entities with true, external linkage. */2473 CXLinkage_External2474};2475 2476/**2477 * Determine the linkage of the entity referred to by a given cursor.2478 */2479CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);2480 2481enum CXVisibilityKind {2482 /** This value indicates that no visibility information is available2483 * for a provided CXCursor. */2484 CXVisibility_Invalid,2485 2486 /** Symbol not seen by the linker. */2487 CXVisibility_Hidden,2488 /** Symbol seen by the linker but resolves to a symbol inside this object. */2489 CXVisibility_Protected,2490 /** Symbol seen by the linker and acts like a normal symbol. */2491 CXVisibility_Default2492};2493 2494/**2495 * Describe the visibility of the entity referred to by a cursor.2496 *2497 * This returns the default visibility if not explicitly specified by2498 * a visibility attribute. The default visibility may be changed by2499 * commandline arguments.2500 *2501 * \param cursor The cursor to query.2502 *2503 * \returns The visibility of the cursor.2504 */2505CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);2506 2507/**2508 * Determine the availability of the entity that this cursor refers to,2509 * taking the current target platform into account.2510 *2511 * \param cursor The cursor to query.2512 *2513 * \returns The availability of the cursor.2514 */2515CINDEX_LINKAGE enum CXAvailabilityKind2516clang_getCursorAvailability(CXCursor cursor);2517 2518/**2519 * Describes the availability of a given entity on a particular platform, e.g.,2520 * a particular class might only be available on Mac OS 10.7 or newer.2521 */2522typedef struct CXPlatformAvailability {2523 /**2524 * A string that describes the platform for which this structure2525 * provides availability information.2526 *2527 * Possible values are "ios" or "macos".2528 */2529 CXString Platform;2530 /**2531 * The version number in which this entity was introduced.2532 */2533 CXVersion Introduced;2534 /**2535 * The version number in which this entity was deprecated (but is2536 * still available).2537 */2538 CXVersion Deprecated;2539 /**2540 * The version number in which this entity was obsoleted, and therefore2541 * is no longer available.2542 */2543 CXVersion Obsoleted;2544 /**2545 * Whether the entity is unconditionally unavailable on this platform.2546 */2547 int Unavailable;2548 /**2549 * An optional message to provide to a user of this API, e.g., to2550 * suggest replacement APIs.2551 */2552 CXString Message;2553} CXPlatformAvailability;2554 2555/**2556 * Determine the availability of the entity that this cursor refers to2557 * on any platforms for which availability information is known.2558 *2559 * \param cursor The cursor to query.2560 *2561 * \param always_deprecated If non-NULL, will be set to indicate whether the2562 * entity is deprecated on all platforms.2563 *2564 * \param deprecated_message If non-NULL, will be set to the message text2565 * provided along with the unconditional deprecation of this entity. The client2566 * is responsible for deallocating this string.2567 *2568 * \param always_unavailable If non-NULL, will be set to indicate whether the2569 * entity is unavailable on all platforms.2570 *2571 * \param unavailable_message If non-NULL, will be set to the message text2572 * provided along with the unconditional unavailability of this entity. The2573 * client is responsible for deallocating this string.2574 *2575 * \param availability If non-NULL, an array of CXPlatformAvailability instances2576 * that will be populated with platform availability information, up to either2577 * the number of platforms for which availability information is available (as2578 * returned by this function) or \c availability_size, whichever is smaller.2579 *2580 * \param availability_size The number of elements available in the2581 * \c availability array.2582 *2583 * \returns The number of platforms (N) for which availability information is2584 * available (which is unrelated to \c availability_size).2585 *2586 * Note that the client is responsible for calling2587 * \c clang_disposeCXPlatformAvailability to free each of the2588 * platform-availability structures returned. There are2589 * \c min(N, availability_size) such structures.2590 */2591CINDEX_LINKAGE int clang_getCursorPlatformAvailability(2592 CXCursor cursor, int *always_deprecated, CXString *deprecated_message,2593 int *always_unavailable, CXString *unavailable_message,2594 CXPlatformAvailability *availability, int availability_size);2595 2596/**2597 * Free the memory associated with a \c CXPlatformAvailability structure.2598 */2599CINDEX_LINKAGE void2600clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);2601 2602/**2603 * If cursor refers to a variable declaration and it has initializer returns2604 * cursor referring to the initializer otherwise return null cursor.2605 */2606CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);2607 2608/**2609 * If cursor refers to a variable declaration that has global storage returns 1.2610 * If cursor refers to a variable declaration that doesn't have global storage2611 * returns 0. Otherwise returns -1.2612 */2613CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);2614 2615/**2616 * If cursor refers to a variable declaration that has external storage2617 * returns 1. If cursor refers to a variable declaration that doesn't have2618 * external storage returns 0. Otherwise returns -1.2619 */2620CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);2621 2622/**2623 * Describe the "language" of the entity referred to by a cursor.2624 */2625enum CXLanguageKind {2626 CXLanguage_Invalid = 0,2627 CXLanguage_C,2628 CXLanguage_ObjC,2629 CXLanguage_CPlusPlus2630};2631 2632/**2633 * Determine the "language" of the entity referred to by a given cursor.2634 */2635CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);2636 2637/**2638 * Describe the "thread-local storage (TLS) kind" of the declaration2639 * referred to by a cursor.2640 */2641enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };2642 2643/**2644 * Determine the "thread-local storage (TLS) kind" of the declaration2645 * referred to by a cursor.2646 */2647CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);2648 2649/**2650 * Returns the translation unit that a cursor originated from.2651 */2652CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);2653 2654/**2655 * A fast container representing a set of CXCursors.2656 */2657typedef struct CXCursorSetImpl *CXCursorSet;2658 2659/**2660 * Creates an empty CXCursorSet.2661 */2662CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);2663 2664/**2665 * Disposes a CXCursorSet and releases its associated memory.2666 */2667CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);2668 2669/**2670 * Queries a CXCursorSet to see if it contains a specific CXCursor.2671 *2672 * \returns non-zero if the set contains the specified cursor.2673 */2674CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,2675 CXCursor cursor);2676 2677/**2678 * Inserts a CXCursor into a CXCursorSet.2679 *2680 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.2681 */2682CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,2683 CXCursor cursor);2684 2685/**2686 * Determine the semantic parent of the given cursor.2687 *2688 * The semantic parent of a cursor is the cursor that semantically contains2689 * the given \p cursor. For many declarations, the lexical and semantic parents2690 * are equivalent (the lexical parent is returned by2691 * \c clang_getCursorLexicalParent()). They diverge when declarations or2692 * definitions are provided out-of-line. For example:2693 *2694 * \code2695 * class C {2696 * void f();2697 * };2698 *2699 * void C::f() { }2700 * \endcode2701 *2702 * In the out-of-line definition of \c C::f, the semantic parent is2703 * the class \c C, of which this function is a member. The lexical parent is2704 * the place where the declaration actually occurs in the source code; in this2705 * case, the definition occurs in the translation unit. In general, the2706 * lexical parent for a given entity can change without affecting the semantics2707 * of the program, and the lexical parent of different declarations of the2708 * same entity may be different. Changing the semantic parent of a declaration,2709 * on the other hand, can have a major impact on semantics, and redeclarations2710 * of a particular entity should all have the same semantic context.2711 *2712 * In the example above, both declarations of \c C::f have \c C as their2713 * semantic context, while the lexical context of the first \c C::f is \c C2714 * and the lexical context of the second \c C::f is the translation unit.2715 *2716 * For global declarations, the semantic parent is the translation unit.2717 */2718CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);2719 2720/**2721 * Determine the lexical parent of the given cursor.2722 *2723 * The lexical parent of a cursor is the cursor in which the given \p cursor2724 * was actually written. For many declarations, the lexical and semantic parents2725 * are equivalent (the semantic parent is returned by2726 * \c clang_getCursorSemanticParent()). They diverge when declarations or2727 * definitions are provided out-of-line. For example:2728 *2729 * \code2730 * class C {2731 * void f();2732 * };2733 *2734 * void C::f() { }2735 * \endcode2736 *2737 * In the out-of-line definition of \c C::f, the semantic parent is2738 * the class \c C, of which this function is a member. The lexical parent is2739 * the place where the declaration actually occurs in the source code; in this2740 * case, the definition occurs in the translation unit. In general, the2741 * lexical parent for a given entity can change without affecting the semantics2742 * of the program, and the lexical parent of different declarations of the2743 * same entity may be different. Changing the semantic parent of a declaration,2744 * on the other hand, can have a major impact on semantics, and redeclarations2745 * of a particular entity should all have the same semantic context.2746 *2747 * In the example above, both declarations of \c C::f have \c C as their2748 * semantic context, while the lexical context of the first \c C::f is \c C2749 * and the lexical context of the second \c C::f is the translation unit.2750 *2751 * For declarations written in the global scope, the lexical parent is2752 * the translation unit.2753 */2754CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);2755 2756/**2757 * Determine the set of methods that are overridden by the given2758 * method.2759 *2760 * In both Objective-C and C++, a method (aka virtual member function,2761 * in C++) can override a virtual method in a base class. For2762 * Objective-C, a method is said to override any method in the class's2763 * base class, its protocols, or its categories' protocols, that has the same2764 * selector and is of the same kind (class or instance).2765 * If no such method exists, the search continues to the class's superclass,2766 * its protocols, and its categories, and so on. A method from an Objective-C2767 * implementation is considered to override the same methods as its2768 * corresponding method in the interface.2769 *2770 * For C++, a virtual member function overrides any virtual member2771 * function with the same signature that occurs in its base2772 * classes. With multiple inheritance, a virtual member function can2773 * override several virtual member functions coming from different2774 * base classes.2775 *2776 * In all cases, this function determines the immediate overridden2777 * method, rather than all of the overridden methods. For example, if2778 * a method is originally declared in a class A, then overridden in B2779 * (which in inherits from A) and also in C (which inherited from B),2780 * then the only overridden method returned from this function when2781 * invoked on C's method will be B's method. The client may then2782 * invoke this function again, given the previously-found overridden2783 * methods, to map out the complete method-override set.2784 *2785 * \param cursor A cursor representing an Objective-C or C++2786 * method. This routine will compute the set of methods that this2787 * method overrides.2788 *2789 * \param overridden A pointer whose pointee will be replaced with a2790 * pointer to an array of cursors, representing the set of overridden2791 * methods. If there are no overridden methods, the pointee will be2792 * set to NULL. The pointee must be freed via a call to2793 * \c clang_disposeOverriddenCursors().2794 *2795 * \param num_overridden A pointer to the number of overridden2796 * functions, will be set to the number of overridden functions in the2797 * array pointed to by \p overridden.2798 */2799CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,2800 CXCursor **overridden,2801 unsigned *num_overridden);2802 2803/**2804 * Free the set of overridden cursors returned by \c2805 * clang_getOverriddenCursors().2806 */2807CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);2808 2809/**2810 * Retrieve the file that is included by the given inclusion directive2811 * cursor.2812 */2813CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);2814 2815/**2816 * @}2817 */2818 2819/**2820 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code2821 *2822 * Cursors represent a location within the Abstract Syntax Tree (AST). These2823 * routines help map between cursors and the physical locations where the2824 * described entities occur in the source code. The mapping is provided in2825 * both directions, so one can map from source code to the AST and back.2826 *2827 * @{2828 */2829 2830/**2831 * Map a source location to the cursor that describes the entity at that2832 * location in the source code.2833 *2834 * clang_getCursor() maps an arbitrary source location within a translation2835 * unit down to the most specific cursor that describes the entity at that2836 * location. For example, given an expression \c x + y, invoking2837 * clang_getCursor() with a source location pointing to "x" will return the2838 * cursor for "x"; similarly for "y". If the cursor points anywhere between2839 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()2840 * will return a cursor referring to the "+" expression.2841 *2842 * \returns a cursor representing the entity at the given source location, or2843 * a NULL cursor if no such entity can be found.2844 */2845CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);2846 2847/**2848 * Retrieve the physical location of the source constructor referenced2849 * by the given cursor.2850 *2851 * The location of a declaration is typically the location of the name of that2852 * declaration, where the name of that declaration would occur if it is2853 * unnamed, or some keyword that introduces that particular declaration.2854 * The location of a reference is where that reference occurs within the2855 * source code.2856 */2857CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);2858 2859/**2860 * Retrieve the physical extent of the source construct referenced by2861 * the given cursor.2862 *2863 * The extent of a cursor starts with the file/line/column pointing at the2864 * first character within the source construct that the cursor refers to and2865 * ends with the last character within that source construct. For a2866 * declaration, the extent covers the declaration itself. For a reference,2867 * the extent covers the location of the reference (e.g., where the referenced2868 * entity was actually used).2869 */2870CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);2871 2872/**2873 * @}2874 */2875 2876/**2877 * \defgroup CINDEX_TYPES Type information for CXCursors2878 *2879 * @{2880 */2881 2882/**2883 * Describes the kind of type2884 */2885enum CXTypeKind {2886 /**2887 * Represents an invalid type (e.g., where no type is available).2888 */2889 CXType_Invalid = 0,2890 2891 /**2892 * A type whose specific kind is not exposed via this2893 * interface.2894 */2895 CXType_Unexposed = 1,2896 2897 /* Builtin types */2898 CXType_Void = 2,2899 CXType_Bool = 3,2900 CXType_Char_U = 4,2901 CXType_UChar = 5,2902 CXType_Char16 = 6,2903 CXType_Char32 = 7,2904 CXType_UShort = 8,2905 CXType_UInt = 9,2906 CXType_ULong = 10,2907 CXType_ULongLong = 11,2908 CXType_UInt128 = 12,2909 CXType_Char_S = 13,2910 CXType_SChar = 14,2911 CXType_WChar = 15,2912 CXType_Short = 16,2913 CXType_Int = 17,2914 CXType_Long = 18,2915 CXType_LongLong = 19,2916 CXType_Int128 = 20,2917 CXType_Float = 21,2918 CXType_Double = 22,2919 CXType_LongDouble = 23,2920 CXType_NullPtr = 24,2921 CXType_Overload = 25,2922 CXType_Dependent = 26,2923 CXType_ObjCId = 27,2924 CXType_ObjCClass = 28,2925 CXType_ObjCSel = 29,2926 CXType_Float128 = 30,2927 CXType_Half = 31,2928 CXType_Float16 = 32,2929 CXType_ShortAccum = 33,2930 CXType_Accum = 34,2931 CXType_LongAccum = 35,2932 CXType_UShortAccum = 36,2933 CXType_UAccum = 37,2934 CXType_ULongAccum = 38,2935 CXType_BFloat16 = 39,2936 CXType_Ibm128 = 40,2937 CXType_FirstBuiltin = CXType_Void,2938 CXType_LastBuiltin = CXType_Ibm128,2939 2940 CXType_Complex = 100,2941 CXType_Pointer = 101,2942 CXType_BlockPointer = 102,2943 CXType_LValueReference = 103,2944 CXType_RValueReference = 104,2945 CXType_Record = 105,2946 CXType_Enum = 106,2947 CXType_Typedef = 107,2948 CXType_ObjCInterface = 108,2949 CXType_ObjCObjectPointer = 109,2950 CXType_FunctionNoProto = 110,2951 CXType_FunctionProto = 111,2952 CXType_ConstantArray = 112,2953 CXType_Vector = 113,2954 CXType_IncompleteArray = 114,2955 CXType_VariableArray = 115,2956 CXType_DependentSizedArray = 116,2957 CXType_MemberPointer = 117,2958 CXType_Auto = 118,2959 2960 /**2961 * Represents a type that was referred to using an elaborated type keyword.2962 *2963 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.2964 */2965 CXType_Elaborated = 119,2966 2967 /* OpenCL PipeType. */2968 CXType_Pipe = 120,2969 2970 /* OpenCL builtin types. */2971 CXType_OCLImage1dRO = 121,2972 CXType_OCLImage1dArrayRO = 122,2973 CXType_OCLImage1dBufferRO = 123,2974 CXType_OCLImage2dRO = 124,2975 CXType_OCLImage2dArrayRO = 125,2976 CXType_OCLImage2dDepthRO = 126,2977 CXType_OCLImage2dArrayDepthRO = 127,2978 CXType_OCLImage2dMSAARO = 128,2979 CXType_OCLImage2dArrayMSAARO = 129,2980 CXType_OCLImage2dMSAADepthRO = 130,2981 CXType_OCLImage2dArrayMSAADepthRO = 131,2982 CXType_OCLImage3dRO = 132,2983 CXType_OCLImage1dWO = 133,2984 CXType_OCLImage1dArrayWO = 134,2985 CXType_OCLImage1dBufferWO = 135,2986 CXType_OCLImage2dWO = 136,2987 CXType_OCLImage2dArrayWO = 137,2988 CXType_OCLImage2dDepthWO = 138,2989 CXType_OCLImage2dArrayDepthWO = 139,2990 CXType_OCLImage2dMSAAWO = 140,2991 CXType_OCLImage2dArrayMSAAWO = 141,2992 CXType_OCLImage2dMSAADepthWO = 142,2993 CXType_OCLImage2dArrayMSAADepthWO = 143,2994 CXType_OCLImage3dWO = 144,2995 CXType_OCLImage1dRW = 145,2996 CXType_OCLImage1dArrayRW = 146,2997 CXType_OCLImage1dBufferRW = 147,2998 CXType_OCLImage2dRW = 148,2999 CXType_OCLImage2dArrayRW = 149,3000 CXType_OCLImage2dDepthRW = 150,3001 CXType_OCLImage2dArrayDepthRW = 151,3002 CXType_OCLImage2dMSAARW = 152,3003 CXType_OCLImage2dArrayMSAARW = 153,3004 CXType_OCLImage2dMSAADepthRW = 154,3005 CXType_OCLImage2dArrayMSAADepthRW = 155,3006 CXType_OCLImage3dRW = 156,3007 CXType_OCLSampler = 157,3008 CXType_OCLEvent = 158,3009 CXType_OCLQueue = 159,3010 CXType_OCLReserveID = 160,3011 3012 CXType_ObjCObject = 161,3013 CXType_ObjCTypeParam = 162,3014 CXType_Attributed = 163,3015 3016 CXType_OCLIntelSubgroupAVCMcePayload = 164,3017 CXType_OCLIntelSubgroupAVCImePayload = 165,3018 CXType_OCLIntelSubgroupAVCRefPayload = 166,3019 CXType_OCLIntelSubgroupAVCSicPayload = 167,3020 CXType_OCLIntelSubgroupAVCMceResult = 168,3021 CXType_OCLIntelSubgroupAVCImeResult = 169,3022 CXType_OCLIntelSubgroupAVCRefResult = 170,3023 CXType_OCLIntelSubgroupAVCSicResult = 171,3024 CXType_OCLIntelSubgroupAVCImeResultSingleReferenceStreamout = 172,3025 CXType_OCLIntelSubgroupAVCImeResultDualReferenceStreamout = 173,3026 CXType_OCLIntelSubgroupAVCImeSingleReferenceStreamin = 174,3027 CXType_OCLIntelSubgroupAVCImeDualReferenceStreamin = 175,3028 3029 /* Old aliases for AVC OpenCL extension types. */3030 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,3031 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,3032 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,3033 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,3034 3035 CXType_ExtVector = 176,3036 CXType_Atomic = 177,3037 CXType_BTFTagAttributed = 178,3038 3039 /* HLSL Types */3040 CXType_HLSLResource = 179,3041 CXType_HLSLAttributedResource = 180,3042 CXType_HLSLInlineSpirv = 1813043};3044 3045/**3046 * Describes the calling convention of a function type3047 */3048enum CXCallingConv {3049 CXCallingConv_Default = 0,3050 CXCallingConv_C = 1,3051 CXCallingConv_X86StdCall = 2,3052 CXCallingConv_X86FastCall = 3,3053 CXCallingConv_X86ThisCall = 4,3054 CXCallingConv_X86Pascal = 5,3055 CXCallingConv_AAPCS = 6,3056 CXCallingConv_AAPCS_VFP = 7,3057 CXCallingConv_X86RegCall = 8,3058 CXCallingConv_IntelOclBicc = 9,3059 CXCallingConv_Win64 = 10,3060 /* Alias for compatibility with older versions of API. */3061 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,3062 CXCallingConv_X86_64SysV = 11,3063 CXCallingConv_X86VectorCall = 12,3064 CXCallingConv_Swift = 13,3065 CXCallingConv_PreserveMost = 14,3066 CXCallingConv_PreserveAll = 15,3067 CXCallingConv_AArch64VectorCall = 16,3068 CXCallingConv_SwiftAsync = 17,3069 CXCallingConv_AArch64SVEPCS = 18,3070 CXCallingConv_M68kRTD = 19,3071 CXCallingConv_PreserveNone = 20,3072 CXCallingConv_RISCVVectorCall = 21,3073 CXCallingConv_RISCVVLSCall_32 = 22,3074 CXCallingConv_RISCVVLSCall_64 = 23,3075 CXCallingConv_RISCVVLSCall_128 = 24,3076 CXCallingConv_RISCVVLSCall_256 = 25,3077 CXCallingConv_RISCVVLSCall_512 = 26,3078 CXCallingConv_RISCVVLSCall_1024 = 27,3079 CXCallingConv_RISCVVLSCall_2048 = 28,3080 CXCallingConv_RISCVVLSCall_4096 = 29,3081 CXCallingConv_RISCVVLSCall_8192 = 30,3082 CXCallingConv_RISCVVLSCall_16384 = 31,3083 CXCallingConv_RISCVVLSCall_32768 = 32,3084 CXCallingConv_RISCVVLSCall_65536 = 33,3085 3086 CXCallingConv_Invalid = 100,3087 CXCallingConv_Unexposed = 2003088};3089 3090/**3091 * The type of an element in the abstract syntax tree.3092 *3093 */3094typedef struct {3095 enum CXTypeKind kind;3096 void *data[2];3097} CXType;3098 3099/**3100 * Retrieve the type of a CXCursor (if any).3101 */3102CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);3103 3104/**3105 * Pretty-print the underlying type using the rules of the3106 * language of the translation unit from which it came.3107 *3108 * If the type is invalid, an empty string is returned.3109 */3110CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);3111 3112/**3113 * Retrieve the underlying type of a typedef declaration.3114 *3115 * If the cursor does not reference a typedef declaration, an invalid type is3116 * returned.3117 */3118CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);3119 3120/**3121 * Retrieve the integer type of an enum declaration.3122 *3123 * If the cursor does not reference an enum declaration, an invalid type is3124 * returned.3125 */3126CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);3127 3128/**3129 * Retrieve the integer value of an enum constant declaration as a signed3130 * long long.3131 *3132 * If the cursor does not reference an enum constant declaration, LLONG_MIN is3133 * returned. Since this is also potentially a valid constant value, the kind of3134 * the cursor must be verified before calling this function.3135 */3136CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);3137 3138/**3139 * Retrieve the integer value of an enum constant declaration as an unsigned3140 * long long.3141 *3142 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is3143 * returned. Since this is also potentially a valid constant value, the kind of3144 * the cursor must be verified before calling this function.3145 */3146CINDEX_LINKAGE unsigned long long3147clang_getEnumConstantDeclUnsignedValue(CXCursor C);3148 3149/**3150 * Returns non-zero if the cursor specifies a Record member that is a bit-field.3151 */3152CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);3153 3154/**3155 * Retrieve the bit width of a bit-field declaration as an integer.3156 *3157 * If the cursor does not reference a bit-field, or if the bit-field's width3158 * expression cannot be evaluated, -1 is returned.3159 *3160 * For example:3161 * \code3162 * if (clang_Cursor_isBitField(Cursor)) {3163 * int Width = clang_getFieldDeclBitWidth(Cursor);3164 * if (Width != -1) {3165 * // The bit-field width is not value-dependent.3166 * }3167 * }3168 * \endcode3169 */3170CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);3171 3172/**3173 * Retrieve the number of non-variadic arguments associated with a given3174 * cursor.3175 *3176 * The number of arguments can be determined for calls as well as for3177 * declarations of functions or methods. For other cursors -1 is returned.3178 */3179CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);3180 3181/**3182 * Retrieve the argument cursor of a function or method.3183 *3184 * The argument cursor can be determined for calls as well as for declarations3185 * of functions or methods. For other cursors and for invalid indices, an3186 * invalid cursor is returned.3187 */3188CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);3189 3190/**3191 * Describes the kind of a template argument.3192 *3193 * See the definition of llvm::clang::TemplateArgument::ArgKind for full3194 * element descriptions.3195 */3196enum CXTemplateArgumentKind {3197 CXTemplateArgumentKind_Null,3198 CXTemplateArgumentKind_Type,3199 CXTemplateArgumentKind_Declaration,3200 CXTemplateArgumentKind_NullPtr,3201 CXTemplateArgumentKind_Integral,3202 CXTemplateArgumentKind_Template,3203 CXTemplateArgumentKind_TemplateExpansion,3204 CXTemplateArgumentKind_Expression,3205 CXTemplateArgumentKind_Pack,3206 /* Indicates an error case, preventing the kind from being deduced. */3207 CXTemplateArgumentKind_Invalid3208};3209 3210/**3211 * Returns the number of template args of a function, struct, or class decl3212 * representing a template specialization.3213 *3214 * If the argument cursor cannot be converted into a template function3215 * declaration, -1 is returned.3216 *3217 * For example, for the following declaration and specialization:3218 * template <typename T, int kInt, bool kBool>3219 * void foo() { ... }3220 *3221 * template <>3222 * void foo<float, -7, true>();3223 *3224 * The value 3 would be returned from this call.3225 */3226CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);3227 3228/**3229 * Retrieve the kind of the I'th template argument of the CXCursor C.3230 *3231 * If the argument CXCursor does not represent a FunctionDecl, StructDecl, or3232 * ClassTemplatePartialSpecialization, an invalid template argument kind is3233 * returned.3234 *3235 * For example, for the following declaration and specialization:3236 * template <typename T, int kInt, bool kBool>3237 * void foo() { ... }3238 *3239 * template <>3240 * void foo<float, -7, true>();3241 *3242 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,3243 * respectively.3244 */3245CINDEX_LINKAGE enum CXTemplateArgumentKind3246clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);3247 3248/**3249 * Retrieve a CXType representing the type of a TemplateArgument of a3250 * function decl representing a template specialization.3251 *3252 * If the argument CXCursor does not represent a FunctionDecl, StructDecl,3253 * ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument3254 * has a kind of CXTemplateArgKind_Integral, an invalid type is returned.3255 *3256 * For example, for the following declaration and specialization:3257 * template <typename T, int kInt, bool kBool>3258 * void foo() { ... }3259 *3260 * template <>3261 * void foo<float, -7, true>();3262 *3263 * If called with I = 0, "float", will be returned.3264 * Invalid types will be returned for I == 1 or 2.3265 */3266CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,3267 unsigned I);3268 3269/**3270 * Retrieve the value of an Integral TemplateArgument (of a function3271 * decl representing a template specialization) as a signed long long.3272 *3273 * It is undefined to call this function on a CXCursor that does not represent a3274 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization3275 * whose I'th template argument is not an integral value.3276 *3277 * For example, for the following declaration and specialization:3278 * template <typename T, int kInt, bool kBool>3279 * void foo() { ... }3280 *3281 * template <>3282 * void foo<float, -7, true>();3283 *3284 * If called with I = 1 or 2, -7 or true will be returned, respectively.3285 * For I == 0, this function's behavior is undefined.3286 */3287CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,3288 unsigned I);3289 3290/**3291 * Retrieve the value of an Integral TemplateArgument (of a function3292 * decl representing a template specialization) as an unsigned long long.3293 *3294 * It is undefined to call this function on a CXCursor that does not represent a3295 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or3296 * whose I'th template argument is not an integral value.3297 *3298 * For example, for the following declaration and specialization:3299 * template <typename T, int kInt, bool kBool>3300 * void foo() { ... }3301 *3302 * template <>3303 * void foo<float, 2147483649, true>();3304 *3305 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.3306 * For I == 0, this function's behavior is undefined.3307 */3308CINDEX_LINKAGE unsigned long long3309clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);3310 3311/**3312 * Determine whether two CXTypes represent the same type.3313 *3314 * \returns non-zero if the CXTypes represent the same type and3315 * zero otherwise.3316 */3317CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);3318 3319/**3320 * Return the canonical type for a CXType.3321 *3322 * Clang's type system explicitly models typedefs and all the ways3323 * a specific type can be represented. The canonical type is the underlying3324 * type with all the "sugar" removed. For example, if 'T' is a typedef3325 * for 'int', the canonical type for 'T' would be 'int'.3326 */3327CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);3328 3329/**3330 * Determine whether a CXType has the "const" qualifier set,3331 * without looking through typedefs that may have added "const" at a3332 * different level.3333 */3334CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);3335 3336/**3337 * Determine whether a CXCursor that is a macro, is3338 * function like.3339 */3340CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);3341 3342/**3343 * Determine whether a CXCursor that is a macro, is a3344 * builtin one.3345 */3346CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);3347 3348/**3349 * Determine whether a CXCursor that is a function declaration, is an3350 * inline declaration.3351 */3352CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);3353 3354/**3355 * Determine whether a CXType has the "volatile" qualifier set,3356 * without looking through typedefs that may have added "volatile" at3357 * a different level.3358 */3359CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);3360 3361/**3362 * Determine whether a CXType has the "restrict" qualifier set,3363 * without looking through typedefs that may have added "restrict" at a3364 * different level.3365 */3366CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);3367 3368/**3369 * Returns the address space of the given type.3370 */3371CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);3372 3373/**3374 * Returns the typedef name of the given type.3375 */3376CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);3377 3378/**3379 * For pointer types, returns the type of the pointee.3380 */3381CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);3382 3383/**3384 * Retrieve the unqualified variant of the given type, removing as3385 * little sugar as possible.3386 *3387 * For example, given the following series of typedefs:3388 *3389 * \code3390 * typedef int Integer;3391 * typedef const Integer CInteger;3392 * typedef CInteger DifferenceType;3393 * \endcode3394 *3395 * Executing \c clang_getUnqualifiedType() on a \c CXType that3396 * represents \c DifferenceType, will desugar to a type representing3397 * \c Integer, that has no qualifiers.3398 *3399 * And, executing \c clang_getUnqualifiedType() on the type of the3400 * first argument of the following function declaration:3401 *3402 * \code3403 * void foo(const int);3404 * \endcode3405 *3406 * Will return a type representing \c int, removing the \c const3407 * qualifier.3408 *3409 * Sugar over array types is not desugared.3410 *3411 * A type can be checked for qualifiers with \c3412 * clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType()3413 * and \c clang_isRestrictQualifiedType().3414 *3415 * A type that resulted from a call to \c clang_getUnqualifiedType3416 * will return \c false for all of the above calls.3417 */3418CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);3419 3420/**3421 * For reference types (e.g., "const int&"), returns the type that the3422 * reference refers to (e.g "const int").3423 *3424 * Otherwise, returns the type itself.3425 *3426 * A type that has kind \c CXType_LValueReference or3427 * \c CXType_RValueReference is a reference type.3428 */3429CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);3430 3431/**3432 * Return the cursor for the declaration of the given type.3433 */3434CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);3435 3436/**3437 * Returns the Objective-C type encoding for the specified declaration.3438 */3439CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);3440 3441/**3442 * Returns the Objective-C type encoding for the specified CXType.3443 */3444CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);3445 3446/**3447 * Retrieve the spelling of a given CXTypeKind.3448 */3449CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);3450 3451/**3452 * Retrieve the calling convention associated with a function type.3453 *3454 * If a non-function type is passed in, CXCallingConv_Invalid is returned.3455 */3456CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);3457 3458/**3459 * Retrieve the return type associated with a function type.3460 *3461 * If a non-function type is passed in, an invalid type is returned.3462 */3463CINDEX_LINKAGE CXType clang_getResultType(CXType T);3464 3465/**3466 * Retrieve the exception specification type associated with a function type.3467 * This is a value of type CXCursor_ExceptionSpecificationKind.3468 *3469 * If a non-function type is passed in, an error code of -1 is returned.3470 */3471CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);3472 3473/**3474 * Retrieve the number of non-variadic parameters associated with a3475 * function type.3476 *3477 * If a non-function type is passed in, -1 is returned.3478 */3479CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);3480 3481/**3482 * Retrieve the type of a parameter of a function type.3483 *3484 * If a non-function type is passed in or the function does not have enough3485 * parameters, an invalid type is returned.3486 */3487CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);3488 3489/**3490 * Retrieves the base type of the ObjCObjectType.3491 *3492 * If the type is not an ObjC object, an invalid type is returned.3493 */3494CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);3495 3496/**3497 * Retrieve the number of protocol references associated with an ObjC object/id.3498 *3499 * If the type is not an ObjC object, 0 is returned.3500 */3501CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);3502 3503/**3504 * Retrieve the decl for a protocol reference for an ObjC object/id.3505 *3506 * If the type is not an ObjC object or there are not enough protocol3507 * references, an invalid cursor is returned.3508 */3509CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);3510 3511/**3512 * Retrieve the number of type arguments associated with an ObjC object.3513 *3514 * If the type is not an ObjC object, 0 is returned.3515 */3516CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);3517 3518/**3519 * Retrieve a type argument associated with an ObjC object.3520 *3521 * If the type is not an ObjC or the index is not valid,3522 * an invalid type is returned.3523 */3524CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);3525 3526/**3527 * Return 1 if the CXType is a variadic function type, and 0 otherwise.3528 */3529CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);3530 3531/**3532 * Retrieve the return type associated with a given cursor.3533 *3534 * This only returns a valid type if the cursor refers to a function or method.3535 */3536CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);3537 3538/**3539 * Retrieve the exception specification type associated with a given cursor.3540 * This is a value of type CXCursor_ExceptionSpecificationKind.3541 *3542 * This only returns a valid result if the cursor refers to a function or3543 * method.3544 */3545CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);3546 3547/**3548 * Return 1 if the CXType is a POD (plain old data) type, and 03549 * otherwise.3550 */3551CINDEX_LINKAGE unsigned clang_isPODType(CXType T);3552 3553/**3554 * Return the element type of an array, complex, or vector type.3555 *3556 * If a type is passed in that is not an array, complex, or vector type,3557 * an invalid type is returned.3558 */3559CINDEX_LINKAGE CXType clang_getElementType(CXType T);3560 3561/**3562 * Return the number of elements of an array or vector type.3563 *3564 * If a type is passed in that is not an array or vector type,3565 * -1 is returned.3566 */3567CINDEX_LINKAGE long long clang_getNumElements(CXType T);3568 3569/**3570 * Return the element type of an array type.3571 *3572 * If a non-array type is passed in, an invalid type is returned.3573 */3574CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);3575 3576/**3577 * Return the array size of a constant array.3578 *3579 * If a non-array type is passed in, -1 is returned.3580 */3581CINDEX_LINKAGE long long clang_getArraySize(CXType T);3582 3583/**3584 * Retrieve the type named by the qualified-id.3585 *3586 * If a non-elaborated type is passed in, an invalid type is returned.3587 */3588CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);3589 3590/**3591 * Determine if a typedef is 'transparent' tag.3592 *3593 * A typedef is considered 'transparent' if it shares a name and spelling3594 * location with its underlying tag type, as is the case with the NS_ENUM macro.3595 *3596 * \returns non-zero if transparent and zero otherwise.3597 */3598CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);3599 3600enum CXTypeNullabilityKind {3601 /**3602 * Values of this type can never be null.3603 */3604 CXTypeNullability_NonNull = 0,3605 /**3606 * Values of this type can be null.3607 */3608 CXTypeNullability_Nullable = 1,3609 /**3610 * Whether values of this type can be null is (explicitly)3611 * unspecified. This captures a (fairly rare) case where we3612 * can't conclude anything about the nullability of the type even3613 * though it has been considered.3614 */3615 CXTypeNullability_Unspecified = 2,3616 /**3617 * Nullability is not applicable to this type.3618 */3619 CXTypeNullability_Invalid = 3,3620 3621 /**3622 * Generally behaves like Nullable, except when used in a block parameter that3623 * was imported into a swift async method. There, swift will assume that the3624 * parameter can get null even if no error occurred. _Nullable parameters are3625 * assumed to only get null on error.3626 */3627 CXTypeNullability_NullableResult = 43628};3629 3630/**3631 * Retrieve the nullability kind of a pointer type.3632 */3633CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);3634 3635/**3636 * List the possible error codes for \c clang_Type_getSizeOf,3637 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf,3638 * \c clang_Cursor_getOffsetOf, and \c clang_getOffsetOfBase.3639 *3640 * A value of this enumeration type can be returned if the target type is not3641 * a valid argument to sizeof, alignof or offsetof.3642 */3643enum CXTypeLayoutError {3644 /**3645 * Type is of kind CXType_Invalid.3646 */3647 CXTypeLayoutError_Invalid = -1,3648 /**3649 * The type is an incomplete Type.3650 */3651 CXTypeLayoutError_Incomplete = -2,3652 /**3653 * The type is a dependent Type.3654 */3655 CXTypeLayoutError_Dependent = -3,3656 /**3657 * The type is not a constant size type.3658 */3659 CXTypeLayoutError_NotConstantSize = -4,3660 /**3661 * The Field name is not valid for this record.3662 */3663 CXTypeLayoutError_InvalidFieldName = -5,3664 /**3665 * The type is undeduced.3666 */3667 CXTypeLayoutError_Undeduced = -63668};3669 3670/**3671 * Return the alignment of a type in bytes as per C++[expr.alignof]3672 * standard.3673 *3674 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.3675 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete3676 * is returned.3677 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is3678 * returned.3679 * If the type declaration is not a constant size type,3680 * CXTypeLayoutError_NotConstantSize is returned.3681 */3682CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);3683 3684/**3685 * Return the class type of an member pointer type.3686 *3687 * If a non-member-pointer type is passed in, an invalid type is returned.3688 */3689CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);3690 3691/**3692 * Return the size of a type in bytes as per C++[expr.sizeof] standard.3693 *3694 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.3695 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete3696 * is returned.3697 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is3698 * returned.3699 */3700CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);3701 3702/**3703 * Return the offset of a field named S in a record of type T in bits3704 * as it would be returned by __offsetof__ as per C++11[18.2p4]3705 *3706 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid3707 * is returned.3708 * If the field's type declaration is an incomplete type,3709 * CXTypeLayoutError_Incomplete is returned.3710 * If the field's type declaration is a dependent type,3711 * CXTypeLayoutError_Dependent is returned.3712 * If the field's name S is not found,3713 * CXTypeLayoutError_InvalidFieldName is returned.3714 */3715CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);3716 3717/**3718 * Return the type that was modified by this attributed type.3719 *3720 * If the type is not an attributed type, an invalid type is returned.3721 */3722CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);3723 3724/**3725 * Gets the type contained by this atomic type.3726 *3727 * If a non-atomic type is passed in, an invalid type is returned.3728 */3729CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);3730 3731/**3732 * Return the offset of the field represented by the Cursor.3733 *3734 * If the cursor is not a field declaration, -1 is returned.3735 * If the cursor semantic parent is not a record field declaration,3736 * CXTypeLayoutError_Invalid is returned.3737 * If the field's type declaration is an incomplete type,3738 * CXTypeLayoutError_Incomplete is returned.3739 * If the field's type declaration is a dependent type,3740 * CXTypeLayoutError_Dependent is returned.3741 * If the field's name S is not found,3742 * CXTypeLayoutError_InvalidFieldName is returned.3743 */3744CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);3745 3746/**3747 * Determine whether the given cursor represents an anonymous3748 * tag or namespace3749 */3750CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);3751 3752/**3753 * Determine whether the given cursor represents an anonymous record3754 * declaration.3755 */3756CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);3757 3758/**3759 * Determine whether the given cursor represents an inline namespace3760 * declaration.3761 */3762CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);3763 3764enum CXRefQualifierKind {3765 /** No ref-qualifier was provided. */3766 CXRefQualifier_None = 0,3767 /** An lvalue ref-qualifier was provided (\c &). */3768 CXRefQualifier_LValue,3769 /** An rvalue ref-qualifier was provided (\c &&). */3770 CXRefQualifier_RValue3771};3772 3773/**3774 * Returns the number of template arguments for given template3775 * specialization, or -1 if type \c T is not a template specialization.3776 */3777CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);3778 3779/**3780 * Returns the type template argument of a template class specialization3781 * at given index.3782 *3783 * This function only returns template type arguments and does not handle3784 * template template arguments or variadic packs.3785 */3786CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,3787 unsigned i);3788 3789/**3790 * Retrieve the ref-qualifier kind of a function or method.3791 *3792 * The ref-qualifier is returned for C++ functions or methods. For other types3793 * or non-C++ declarations, CXRefQualifier_None is returned.3794 */3795CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);3796 3797/**3798 * Returns 1 if the base class specified by the cursor with kind3799 * CX_CXXBaseSpecifier is virtual.3800 */3801CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);3802 3803/**3804 * Returns the offset in bits of a CX_CXXBaseSpecifier relative to the parent3805 * class.3806 *3807 * Returns a small negative number if the offset cannot be computed. See3808 * CXTypeLayoutError for error codes.3809 */3810CINDEX_LINKAGE long long clang_getOffsetOfBase(CXCursor Parent, CXCursor Base);3811 3812/**3813 * Represents the C++ access control level to a base class for a3814 * cursor with kind CX_CXXBaseSpecifier.3815 */3816enum CX_CXXAccessSpecifier {3817 CX_CXXInvalidAccessSpecifier,3818 CX_CXXPublic,3819 CX_CXXProtected,3820 CX_CXXPrivate3821};3822 3823/**3824 * Returns the access control level for the referenced object.3825 *3826 * If the cursor refers to a C++ declaration, its access control level within3827 * its parent scope is returned. Otherwise, if the cursor refers to a base3828 * specifier or access specifier, the specifier itself is returned.3829 */3830CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);3831 3832/**3833 * Represents the storage classes as declared in the source. CX_SC_Invalid3834 * was added for the case that the passed cursor in not a declaration.3835 */3836enum CX_StorageClass {3837 CX_SC_Invalid,3838 CX_SC_None,3839 CX_SC_Extern,3840 CX_SC_Static,3841 CX_SC_PrivateExtern,3842 CX_SC_OpenCLWorkGroupLocal,3843 CX_SC_Auto,3844 CX_SC_Register3845};3846 3847/**3848 * Represents a specific kind of binary operator which can appear at a cursor.3849 */3850enum CX_BinaryOperatorKind {3851 CX_BO_Invalid = 0,3852 CX_BO_PtrMemD = 1,3853 CX_BO_PtrMemI = 2,3854 CX_BO_Mul = 3,3855 CX_BO_Div = 4,3856 CX_BO_Rem = 5,3857 CX_BO_Add = 6,3858 CX_BO_Sub = 7,3859 CX_BO_Shl = 8,3860 CX_BO_Shr = 9,3861 CX_BO_Cmp = 10,3862 CX_BO_LT = 11,3863 CX_BO_GT = 12,3864 CX_BO_LE = 13,3865 CX_BO_GE = 14,3866 CX_BO_EQ = 15,3867 CX_BO_NE = 16,3868 CX_BO_And = 17,3869 CX_BO_Xor = 18,3870 CX_BO_Or = 19,3871 CX_BO_LAnd = 20,3872 CX_BO_LOr = 21,3873 CX_BO_Assign = 22,3874 CX_BO_MulAssign = 23,3875 CX_BO_DivAssign = 24,3876 CX_BO_RemAssign = 25,3877 CX_BO_AddAssign = 26,3878 CX_BO_SubAssign = 27,3879 CX_BO_ShlAssign = 28,3880 CX_BO_ShrAssign = 29,3881 CX_BO_AndAssign = 30,3882 CX_BO_XorAssign = 31,3883 CX_BO_OrAssign = 32,3884 CX_BO_Comma = 33,3885 CX_BO_LAST = CX_BO_Comma3886};3887 3888/**3889 * \brief Returns the operator code for the binary operator.3890 *3891 * @deprecated: use clang_getCursorBinaryOperatorKind instead.3892 */3893CINDEX_LINKAGE enum CX_BinaryOperatorKind3894clang_Cursor_getBinaryOpcode(CXCursor C);3895 3896/**3897 * \brief Returns a string containing the spelling of the binary operator.3898 *3899 * @deprecated: use clang_getBinaryOperatorKindSpelling instead3900 */3901CINDEX_LINKAGE CXString3902clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op);3903 3904/**3905 * Returns the storage class for a function or variable declaration.3906 *3907 * If the passed in Cursor is not a function or variable declaration,3908 * CX_SC_Invalid is returned else the storage class.3909 */3910CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);3911 3912/**3913 * Determine the number of overloaded declarations referenced by a3914 * \c CXCursor_OverloadedDeclRef cursor.3915 *3916 * \param cursor The cursor whose overloaded declarations are being queried.3917 *3918 * \returns The number of overloaded declarations referenced by \c cursor. If it3919 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.3920 */3921CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);3922 3923/**3924 * Retrieve a cursor for one of the overloaded declarations referenced3925 * by a \c CXCursor_OverloadedDeclRef cursor.3926 *3927 * \param cursor The cursor whose overloaded declarations are being queried.3928 *3929 * \param index The zero-based index into the set of overloaded declarations in3930 * the cursor.3931 *3932 * \returns A cursor representing the declaration referenced by the given3933 * \c cursor at the specified \c index. If the cursor does not have an3934 * associated set of overloaded declarations, or if the index is out of bounds,3935 * returns \c clang_getNullCursor();3936 */3937CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,3938 unsigned index);3939 3940/**3941 * @}3942 */3943 3944/**3945 * \defgroup CINDEX_ATTRIBUTES Information for attributes3946 *3947 * @{3948 */3949 3950/**3951 * For cursors representing an iboutletcollection attribute,3952 * this function returns the collection element type.3953 *3954 */3955CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);3956 3957/**3958 * @}3959 */3960 3961/**3962 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors3963 *3964 * These routines provide the ability to traverse the abstract syntax tree3965 * using cursors.3966 *3967 * @{3968 */3969 3970/**3971 * Describes how the traversal of the children of a particular3972 * cursor should proceed after visiting a particular child cursor.3973 *3974 * A value of this enumeration type should be returned by each3975 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.3976 */3977enum CXChildVisitResult {3978 /**3979 * Terminates the cursor traversal.3980 */3981 CXChildVisit_Break,3982 /**3983 * Continues the cursor traversal with the next sibling of3984 * the cursor just visited, without visiting its children.3985 */3986 CXChildVisit_Continue,3987 /**3988 * Recursively traverse the children of this cursor, using3989 * the same visitor and client data.3990 */3991 CXChildVisit_Recurse3992};3993 3994/**3995 * Visitor invoked for each cursor found by a traversal.3996 *3997 * This visitor function will be invoked for each cursor found by3998 * clang_visitCursorChildren(). Its first argument is the cursor being3999 * visited, its second argument is the parent visitor for that cursor,4000 * and its third argument is the client data provided to4001 * clang_visitCursorChildren().4002 *4003 * The visitor should return one of the \c CXChildVisitResult values4004 * to direct clang_visitCursorChildren().4005 */4006typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,4007 CXCursor parent,4008 CXClientData client_data);4009 4010/**4011 * Visit the children of a particular cursor.4012 *4013 * This function visits all the direct children of the given cursor,4014 * invoking the given \p visitor function with the cursors of each4015 * visited child. The traversal may be recursive, if the visitor returns4016 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if4017 * the visitor returns \c CXChildVisit_Break.4018 *4019 * \param parent the cursor whose child may be visited. All kinds of4020 * cursors can be visited, including invalid cursors (which, by4021 * definition, have no children).4022 *4023 * \param visitor the visitor function that will be invoked for each4024 * child of \p parent.4025 *4026 * \param client_data pointer data supplied by the client, which will4027 * be passed to the visitor each time it is invoked.4028 *4029 * \returns a non-zero value if the traversal was terminated4030 * prematurely by the visitor returning \c CXChildVisit_Break.4031 */4032CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,4033 CXCursorVisitor visitor,4034 CXClientData client_data);4035/**4036 * Visitor invoked for each cursor found by a traversal.4037 *4038 * This visitor block will be invoked for each cursor found by4039 * clang_visitChildrenWithBlock(). Its first argument is the cursor being4040 * visited, its second argument is the parent visitor for that cursor.4041 *4042 * The visitor should return one of the \c CXChildVisitResult values4043 * to direct clang_visitChildrenWithBlock().4044 */4045#if __has_feature(blocks)4046typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,4047 CXCursor parent);4048#else4049typedef struct _CXChildVisitResult *CXCursorVisitorBlock;4050#endif4051 4052/**4053 * Visits the children of a cursor using the specified block. Behaves4054 * identically to clang_visitChildren() in all other respects.4055 */4056CINDEX_LINKAGE unsigned4057clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);4058 4059/**4060 * @}4061 */4062 4063/**4064 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST4065 *4066 * These routines provide the ability to determine references within and4067 * across translation units, by providing the names of the entities referenced4068 * by cursors, follow reference cursors to the declarations they reference,4069 * and associate declarations with their definitions.4070 *4071 * @{4072 */4073 4074/**4075 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced4076 * by the given cursor.4077 *4078 * A Unified Symbol Resolution (USR) is a string that identifies a particular4079 * entity (function, class, variable, etc.) within a program. USRs can be4080 * compared across translation units to determine, e.g., when references in4081 * one translation refer to an entity defined in another translation unit.4082 */4083CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);4084 4085/**4086 * Construct a USR for a specified Objective-C class.4087 */4088CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);4089 4090/**4091 * Construct a USR for a specified Objective-C category.4092 */4093CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(4094 const char *class_name, const char *category_name);4095 4096/**4097 * Construct a USR for a specified Objective-C protocol.4098 */4099CINDEX_LINKAGE CXString4100clang_constructUSR_ObjCProtocol(const char *protocol_name);4101 4102/**4103 * Construct a USR for a specified Objective-C instance variable and4104 * the USR for its containing class.4105 */4106CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,4107 CXString classUSR);4108 4109/**4110 * Construct a USR for a specified Objective-C method and4111 * the USR for its containing class.4112 */4113CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,4114 unsigned isInstanceMethod,4115 CXString classUSR);4116 4117/**4118 * Construct a USR for a specified Objective-C property and the USR4119 * for its containing class.4120 */4121CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,4122 CXString classUSR);4123 4124/**4125 * Retrieve a name for the entity referenced by this cursor.4126 */4127CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);4128 4129/**4130 * Retrieve a range for a piece that forms the cursors spelling name.4131 * Most of the times there is only one range for the complete spelling but for4132 * Objective-C methods and Objective-C message expressions, there are multiple4133 * pieces for each selector identifier.4134 *4135 * \param pieceIndex the index of the spelling name piece. If this is greater4136 * than the actual number of pieces, it will return a NULL (invalid) range.4137 *4138 * \param options Reserved.4139 */4140CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(4141 CXCursor, unsigned pieceIndex, unsigned options);4142 4143/**4144 * Opaque pointer representing a policy that controls pretty printing4145 * for \c clang_getCursorPrettyPrinted.4146 */4147typedef void *CXPrintingPolicy;4148 4149/**4150 * Properties for the printing policy.4151 *4152 * See \c clang::PrintingPolicy for more information.4153 */4154enum CXPrintingPolicyProperty {4155 CXPrintingPolicy_Indentation,4156 CXPrintingPolicy_SuppressSpecifiers,4157 CXPrintingPolicy_SuppressTagKeyword,4158 CXPrintingPolicy_IncludeTagDefinition,4159 CXPrintingPolicy_SuppressScope,4160 CXPrintingPolicy_SuppressUnwrittenScope,4161 CXPrintingPolicy_SuppressInitializers,4162 CXPrintingPolicy_ConstantArraySizeAsWritten,4163 CXPrintingPolicy_AnonymousTagLocations,4164 CXPrintingPolicy_SuppressStrongLifetime,4165 CXPrintingPolicy_SuppressLifetimeQualifiers,4166 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,4167 CXPrintingPolicy_Bool,4168 CXPrintingPolicy_Restrict,4169 CXPrintingPolicy_Alignof,4170 CXPrintingPolicy_UnderscoreAlignof,4171 CXPrintingPolicy_UseVoidForZeroParams,4172 CXPrintingPolicy_TerseOutput,4173 CXPrintingPolicy_PolishForDeclaration,4174 CXPrintingPolicy_Half,4175 CXPrintingPolicy_MSWChar,4176 CXPrintingPolicy_IncludeNewlines,4177 CXPrintingPolicy_MSVCFormatting,4178 CXPrintingPolicy_ConstantsAsWritten,4179 CXPrintingPolicy_SuppressImplicitBase,4180 CXPrintingPolicy_FullyQualifiedName,4181 4182 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName4183};4184 4185/**4186 * Get a property value for the given printing policy.4187 */4188CINDEX_LINKAGE unsigned4189clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,4190 enum CXPrintingPolicyProperty Property);4191 4192/**4193 * Set a property value for the given printing policy.4194 */4195CINDEX_LINKAGE void4196clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,4197 enum CXPrintingPolicyProperty Property,4198 unsigned Value);4199 4200/**4201 * Retrieve the default policy for the cursor.4202 *4203 * The policy should be released after use with \c4204 * clang_PrintingPolicy_dispose.4205 */4206CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);4207 4208/**4209 * Release a printing policy.4210 */4211CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);4212 4213/**4214 * Pretty print declarations.4215 *4216 * \param Cursor The cursor representing a declaration.4217 *4218 * \param Policy The policy to control the entities being printed. If4219 * NULL, a default policy is used.4220 *4221 * \returns The pretty printed declaration or the empty string for4222 * other cursors.4223 */4224CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,4225 CXPrintingPolicy Policy);4226 4227/**4228 * Pretty-print the underlying type using a custom printing policy.4229 *4230 * If the type is invalid, an empty string is returned.4231 */4232CINDEX_LINKAGE CXString clang_getTypePrettyPrinted(CXType CT,4233 CXPrintingPolicy cxPolicy);4234 4235/**4236 * Get the fully qualified name for a type.4237 *4238 * This includes full qualification of all template parameters.4239 *4240 * Policy - Further refine the type formatting4241 * WithGlobalNsPrefix - If non-zero, function will prepend a '::' to qualified4242 * names4243 */4244CINDEX_LINKAGE CXString clang_getFullyQualifiedName(4245 CXType CT, CXPrintingPolicy Policy, unsigned WithGlobalNsPrefix);4246 4247/**4248 * Retrieve the display name for the entity referenced by this cursor.4249 *4250 * The display name contains extra information that helps identify the cursor,4251 * such as the parameters of a function or template or the arguments of a4252 * class template specialization.4253 */4254CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);4255 4256/** For a cursor that is a reference, retrieve a cursor representing the4257 * entity that it references.4258 *4259 * Reference cursors refer to other entities in the AST. For example, an4260 * Objective-C superclass reference cursor refers to an Objective-C class.4261 * This function produces the cursor for the Objective-C class from the4262 * cursor for the superclass reference. If the input cursor is a declaration or4263 * definition, it returns that declaration or definition unchanged.4264 * Otherwise, returns the NULL cursor.4265 */4266CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);4267 4268/**4269 * For a cursor that is either a reference to or a declaration4270 * of some entity, retrieve a cursor that describes the definition of4271 * that entity.4272 *4273 * Some entities can be declared multiple times within a translation4274 * unit, but only one of those declarations can also be a4275 * definition. For example, given:4276 *4277 * \code4278 * int f(int, int);4279 * int g(int x, int y) { return f(x, y); }4280 * int f(int a, int b) { return a + b; }4281 * int f(int, int);4282 * \endcode4283 *4284 * there are three declarations of the function "f", but only the4285 * second one is a definition. The clang_getCursorDefinition()4286 * function will take any cursor pointing to a declaration of "f"4287 * (the first or fourth lines of the example) or a cursor referenced4288 * that uses "f" (the call to "f' inside "g") and will return a4289 * declaration cursor pointing to the definition (the second "f"4290 * declaration).4291 *4292 * If given a cursor for which there is no corresponding definition,4293 * e.g., because there is no definition of that entity within this4294 * translation unit, returns a NULL cursor.4295 */4296CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);4297 4298/**4299 * Determine whether the declaration pointed to by this cursor4300 * is also a definition of that entity.4301 */4302CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);4303 4304/**4305 * Retrieve the canonical cursor corresponding to the given cursor.4306 *4307 * In the C family of languages, many kinds of entities can be declared several4308 * times within a single translation unit. For example, a structure type can4309 * be forward-declared (possibly multiple times) and later defined:4310 *4311 * \code4312 * struct X;4313 * struct X;4314 * struct X {4315 * int member;4316 * };4317 * \endcode4318 *4319 * The declarations and the definition of \c X are represented by three4320 * different cursors, all of which are declarations of the same underlying4321 * entity. One of these cursor is considered the "canonical" cursor, which4322 * is effectively the representative for the underlying entity. One can4323 * determine if two cursors are declarations of the same underlying entity by4324 * comparing their canonical cursors.4325 *4326 * \returns The canonical cursor for the entity referred to by the given cursor.4327 */4328CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);4329 4330/**4331 * If the cursor points to a selector identifier in an Objective-C4332 * method or message expression, this returns the selector index.4333 *4334 * After getting a cursor with #clang_getCursor, this can be called to4335 * determine if the location points to a selector identifier.4336 *4337 * \returns The selector index if the cursor is an Objective-C method or message4338 * expression and the cursor is pointing to a selector identifier, or -14339 * otherwise.4340 */4341CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);4342 4343/**4344 * Given a cursor pointing to a C++ method call or an Objective-C4345 * message, returns non-zero if the method/message is "dynamic", meaning:4346 *4347 * For a C++ method: the call is virtual.4348 * For an Objective-C message: the receiver is an object instance, not 'super'4349 * or a specific class.4350 *4351 * If the method/message is "static" or the cursor does not point to a4352 * method/message, it will return zero.4353 */4354CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);4355 4356/**4357 * Given a cursor pointing to an Objective-C message or property4358 * reference, or C++ method call, returns the CXType of the receiver.4359 */4360CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);4361 4362/**4363 * Property attributes for a \c CXCursor_ObjCPropertyDecl.4364 */4365typedef enum {4366 CXObjCPropertyAttr_noattr = 0x00,4367 CXObjCPropertyAttr_readonly = 0x01,4368 CXObjCPropertyAttr_getter = 0x02,4369 CXObjCPropertyAttr_assign = 0x04,4370 CXObjCPropertyAttr_readwrite = 0x08,4371 CXObjCPropertyAttr_retain = 0x10,4372 CXObjCPropertyAttr_copy = 0x20,4373 CXObjCPropertyAttr_nonatomic = 0x40,4374 CXObjCPropertyAttr_setter = 0x80,4375 CXObjCPropertyAttr_atomic = 0x100,4376 CXObjCPropertyAttr_weak = 0x200,4377 CXObjCPropertyAttr_strong = 0x400,4378 CXObjCPropertyAttr_unsafe_unretained = 0x800,4379 CXObjCPropertyAttr_class = 0x10004380} CXObjCPropertyAttrKind;4381 4382/**4383 * Given a cursor that represents a property declaration, return the4384 * associated property attributes. The bits are formed from4385 * \c CXObjCPropertyAttrKind.4386 *4387 * \param reserved Reserved for future use, pass 0.4388 */4389CINDEX_LINKAGE unsigned4390clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);4391 4392/**4393 * Given a cursor that represents a property declaration, return the4394 * name of the method that implements the getter.4395 */4396CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);4397 4398/**4399 * Given a cursor that represents a property declaration, return the4400 * name of the method that implements the setter, if any.4401 */4402CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);4403 4404/**4405 * 'Qualifiers' written next to the return and parameter types in4406 * Objective-C method declarations.4407 */4408typedef enum {4409 CXObjCDeclQualifier_None = 0x0,4410 CXObjCDeclQualifier_In = 0x1,4411 CXObjCDeclQualifier_Inout = 0x2,4412 CXObjCDeclQualifier_Out = 0x4,4413 CXObjCDeclQualifier_Bycopy = 0x8,4414 CXObjCDeclQualifier_Byref = 0x10,4415 CXObjCDeclQualifier_Oneway = 0x204416} CXObjCDeclQualifierKind;4417 4418/**4419 * Given a cursor that represents an Objective-C method or parameter4420 * declaration, return the associated Objective-C qualifiers for the return4421 * type or the parameter respectively. The bits are formed from4422 * CXObjCDeclQualifierKind.4423 */4424CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);4425 4426/**4427 * Given a cursor that represents an Objective-C method or property4428 * declaration, return non-zero if the declaration was affected by "\@optional".4429 * Returns zero if the cursor is not such a declaration or it is "\@required".4430 */4431CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);4432 4433/**4434 * Returns non-zero if the given cursor is a variadic function or method.4435 */4436CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);4437 4438/**4439 * Returns non-zero if the given cursor points to a symbol marked with4440 * external_source_symbol attribute.4441 *4442 * \param language If non-NULL, and the attribute is present, will be set to4443 * the 'language' string from the attribute.4444 *4445 * \param definedIn If non-NULL, and the attribute is present, will be set to4446 * the 'definedIn' string from the attribute.4447 *4448 * \param isGenerated If non-NULL, and the attribute is present, will be set to4449 * non-zero if the 'generated_declaration' is set in the attribute.4450 */4451CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,4452 CXString *language,4453 CXString *definedIn,4454 unsigned *isGenerated);4455 4456/**4457 * Given a cursor that represents a declaration, return the associated4458 * comment's source range. The range may include multiple consecutive comments4459 * with whitespace in between.4460 */4461CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);4462 4463/**4464 * Given a cursor that represents a declaration, return the associated4465 * comment text, including comment markers.4466 */4467CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);4468 4469/**4470 * Given a cursor that represents a documentable entity (e.g.,4471 * declaration), return the associated \paragraph; otherwise return the4472 * first paragraph.4473 */4474CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);4475 4476/**4477 * @}4478 */4479 4480/** \defgroup CINDEX_MANGLE Name Mangling API Functions4481 *4482 * @{4483 */4484 4485/**4486 * Retrieve the CXString representing the mangled name of the cursor.4487 */4488CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);4489 4490/**4491 * Retrieve the CXStrings representing the mangled symbols of the C++4492 * constructor or destructor at the cursor.4493 */4494CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);4495 4496/**4497 * Retrieve the CXStrings representing the mangled symbols of the ObjC4498 * class interface or implementation at the cursor.4499 */4500CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);4501 4502/**4503 * @}4504 */4505 4506/**4507 * \defgroup CINDEX_MODULE Inline Assembly introspection4508 *4509 * The functions in this group provide access to information about GCC-style4510 * inline assembly statements.4511 *4512 * @{4513 */4514 4515/**4516 * Given a CXCursor_GCCAsmStmt cursor, return the assembly template string.4517 * As per LLVM IR Assembly Template language, template placeholders for4518 * inputs and outputs are either of the form $N where N is a decimal number4519 * as an index into the input-output specification,4520 * or ${N:M} where N is a decimal number also as an index into the4521 * input-output specification and M is the template argument modifier.4522 * The index N in both cases points into the the total inputs and outputs,4523 * or more specifically, into the list of outputs followed by the inputs,4524 * starting from index 0 as the first available template argument.4525 *4526 * This function also returns a valid empty string if the cursor does not point4527 * at a GCC inline assembly block.4528 *4529 * Users are responsible for releasing the allocation of returned string via4530 * \c clang_disposeString.4531 */4532 4533CINDEX_LINKAGE CXString clang_Cursor_getGCCAssemblyTemplate(CXCursor);4534 4535/**4536 * Given a CXCursor_GCCAsmStmt cursor, check if the assembly block has goto4537 * labels.4538 * This function also returns 0 if the cursor does not point at a GCC inline4539 * assembly block.4540 */4541 4542CINDEX_LINKAGE unsigned clang_Cursor_isGCCAssemblyHasGoto(CXCursor);4543 4544/**4545 * Given a CXCursor_GCCAsmStmt cursor, count the number of outputs.4546 * This function also returns 0 if the cursor does not point at a GCC inline4547 * assembly block.4548 */4549 4550CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyNumOutputs(CXCursor);4551 4552/**4553 * Given a CXCursor_GCCAsmStmt cursor, count the number of inputs.4554 * This function also returns 0 if the cursor does not point at a GCC inline4555 * assembly block.4556 */4557 4558CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyNumInputs(CXCursor);4559 4560/**4561 * Given a CXCursor_GCCAsmStmt cursor, get the constraint and expression cursor4562 * to the Index-th input.4563 * This function returns 1 when the cursor points at a GCC inline assembly4564 * statement, `Index` is within bounds and both the `Constraint` and `Expr` are4565 * not NULL.4566 * Otherwise, this function returns 0 but leaves `Constraint` and `Expr`4567 * intact.4568 *4569 * Users are responsible for releasing the allocation of `Constraint` via4570 * \c clang_disposeString.4571 */4572 4573CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyInput(CXCursor Cursor,4574 unsigned Index,4575 CXString *Constraint,4576 CXCursor *Expr);4577 4578/**4579 * Given a CXCursor_GCCAsmStmt cursor, get the constraint and expression cursor4580 * to the Index-th output.4581 * This function returns 1 when the cursor points at a GCC inline assembly4582 * statement, `Index` is within bounds and both the `Constraint` and `Expr` are4583 * not NULL.4584 * Otherwise, this function returns 0 but leaves `Constraint` and `Expr`4585 * intact.4586 *4587 * Users are responsible for releasing the allocation of `Constraint` via4588 * \c clang_disposeString.4589 */4590 4591CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyOutput(CXCursor Cursor,4592 unsigned Index,4593 CXString *Constraint,4594 CXCursor *Expr);4595 4596/**4597 * Given a CXCursor_GCCAsmStmt cursor, count the clobbers in it.4598 * This function also returns 0 if the cursor does not point at a GCC inline4599 * assembly block.4600 */4601 4602CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyNumClobbers(CXCursor Cursor);4603 4604/**4605 * Given a CXCursor_GCCAsmStmt cursor, get the Index-th clobber of it.4606 * This function returns a valid empty string if the cursor does not point4607 * at a GCC inline assembly block or `Index` is out of bounds.4608 *4609 * Users are responsible for releasing the allocation of returned string via4610 * \c clang_disposeString.4611 */4612 4613CINDEX_LINKAGE CXString clang_Cursor_getGCCAssemblyClobber(CXCursor Cursor,4614 unsigned Index);4615 4616/**4617 * Given a CXCursor_GCCAsmStmt cursor, check if the inline assembly is4618 * `volatile`.4619 * This function returns 0 if the cursor does not point at a GCC inline4620 * assembly block.4621 */4622 4623CINDEX_LINKAGE unsigned clang_Cursor_isGCCAssemblyVolatile(CXCursor Cursor);4624 4625/**4626 * @}4627 */4628 4629/**4630 * \defgroup CINDEX_MODULE Module introspection4631 *4632 * The functions in this group provide access to information about modules.4633 *4634 * @{4635 */4636 4637typedef void *CXModule;4638 4639/**4640 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.4641 */4642CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);4643 4644/**4645 * Given a CXFile header file, return the module that contains it, if one4646 * exists.4647 */4648CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);4649 4650/**4651 * \param Module a module object.4652 *4653 * \returns the module file where the provided module object came from.4654 */4655CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);4656 4657/**4658 * \param Module a module object.4659 *4660 * \returns the parent of a sub-module or NULL if the given module is top-level,4661 * e.g. for 'std.vector' it will return the 'std' module.4662 */4663CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);4664 4665/**4666 * \param Module a module object.4667 *4668 * \returns the name of the module, e.g. for the 'std.vector' sub-module it4669 * will return "vector".4670 */4671CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);4672 4673/**4674 * \param Module a module object.4675 *4676 * \returns the full name of the module, e.g. "std.vector".4677 */4678CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);4679 4680/**4681 * \param Module a module object.4682 *4683 * \returns non-zero if the module is a system one.4684 */4685CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);4686 4687/**4688 * \param Module a module object.4689 *4690 * \returns the number of top level headers associated with this module.4691 */4692CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,4693 CXModule Module);4694 4695/**4696 * \param Module a module object.4697 *4698 * \param Index top level header index (zero-based).4699 *4700 * \returns the specified top level header associated with the module.4701 */4702CINDEX_LINKAGE4703CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,4704 unsigned Index);4705 4706/**4707 * @}4708 */4709 4710/**4711 * \defgroup CINDEX_CPP C++ AST introspection4712 *4713 * The routines in this group provide access information in the ASTs specific4714 * to C++ language features.4715 *4716 * @{4717 */4718 4719/**4720 * Determine if a C++ constructor is a converting constructor.4721 */4722CINDEX_LINKAGE unsigned4723clang_CXXConstructor_isConvertingConstructor(CXCursor C);4724 4725/**4726 * Determine if a C++ constructor is a copy constructor.4727 */4728CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);4729 4730/**4731 * Determine if a C++ constructor is the default constructor.4732 */4733CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);4734 4735/**4736 * Determine if a C++ constructor is a move constructor.4737 */4738CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);4739 4740/**4741 * Determine if a C++ field is declared 'mutable'.4742 */4743CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);4744 4745/**4746 * Determine if a C++ method is declared '= default'.4747 */4748CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);4749 4750/**4751 * Determine if a C++ method is declared '= delete'.4752 */4753CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C);4754 4755/**4756 * Determine if a C++ member function or member function template is4757 * pure virtual.4758 */4759CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);4760 4761/**4762 * Determine if a C++ member function or member function template is4763 * declared 'static'.4764 */4765CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);4766 4767/**4768 * Determine if a C++ member function or member function template is4769 * explicitly declared 'virtual' or if it overrides a virtual method from4770 * one of the base classes.4771 */4772CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);4773 4774/**4775 * Determine if a C++ member function is a copy-assignment operator,4776 * returning 1 if such is the case and 0 otherwise.4777 *4778 * > A copy-assignment operator `X::operator=` is a non-static,4779 * > non-template member function of _class_ `X` with exactly one4780 * > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const4781 * > volatile X&`.4782 *4783 * That is, for example, the `operator=` in:4784 *4785 * class Foo {4786 * bool operator=(const volatile Foo&);4787 * };4788 *4789 * Is a copy-assignment operator, while the `operator=` in:4790 *4791 * class Bar {4792 * bool operator=(const int&);4793 * };4794 *4795 * Is not.4796 */4797CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C);4798 4799/**4800 * Determine if a C++ member function is a move-assignment operator,4801 * returning 1 if such is the case and 0 otherwise.4802 *4803 * > A move-assignment operator `X::operator=` is a non-static,4804 * > non-template member function of _class_ `X` with exactly one4805 * > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const4806 * > volatile X&&`.4807 *4808 * That is, for example, the `operator=` in:4809 *4810 * class Foo {4811 * bool operator=(const volatile Foo&&);4812 * };4813 *4814 * Is a move-assignment operator, while the `operator=` in:4815 *4816 * class Bar {4817 * bool operator=(const int&&);4818 * };4819 *4820 * Is not.4821 */4822CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C);4823 4824/**4825 * Determines if a C++ constructor or conversion function was declared4826 * explicit, returning 1 if such is the case and 0 otherwise.4827 *4828 * Constructors or conversion functions are declared explicit through4829 * the use of the explicit specifier.4830 *4831 * For example, the following constructor and conversion function are4832 * not explicit as they lack the explicit specifier:4833 *4834 * class Foo {4835 * Foo();4836 * operator int();4837 * };4838 *4839 * While the following constructor and conversion function are4840 * explicit as they are declared with the explicit specifier.4841 *4842 * class Foo {4843 * explicit Foo();4844 * explicit operator int();4845 * };4846 *4847 * This function will return 0 when given a cursor pointing to one of4848 * the former declarations and it will return 1 for a cursor pointing4849 * to the latter declarations.4850 *4851 * The explicit specifier allows the user to specify a4852 * conditional compile-time expression whose value decides4853 * whether the marked element is explicit or not.4854 *4855 * For example:4856 *4857 * constexpr bool foo(int i) { return i % 2 == 0; }4858 *4859 * class Foo {4860 * explicit(foo(1)) Foo();4861 * explicit(foo(2)) operator int();4862 * }4863 *4864 * This function will return 0 for the constructor and 1 for4865 * the conversion function.4866 */4867CINDEX_LINKAGE unsigned clang_CXXMethod_isExplicit(CXCursor C);4868 4869/**4870 * Determine if a C++ record is abstract, i.e. whether a class or struct4871 * has a pure virtual member function.4872 */4873CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);4874 4875/**4876 * Determine if an enum declaration refers to a scoped enum.4877 */4878CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);4879 4880/**4881 * Determine if a C++ member function or member function template is4882 * declared 'const'.4883 */4884CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);4885 4886/**4887 * Given a cursor that represents a template, determine4888 * the cursor kind of the specializations would be generated by instantiating4889 * the template.4890 *4891 * This routine can be used to determine what flavor of function template,4892 * class template, or class template partial specialization is stored in the4893 * cursor. For example, it can describe whether a class template cursor is4894 * declared with "struct", "class" or "union".4895 *4896 * \param C The cursor to query. This cursor should represent a template4897 * declaration.4898 *4899 * \returns The cursor kind of the specializations that would be generated4900 * by instantiating the template \p C. If \p C is not a template, returns4901 * \c CXCursor_NoDeclFound.4902 */4903CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);4904 4905/**4906 * Given a cursor that may represent a specialization or instantiation4907 * of a template, retrieve the cursor that represents the template that it4908 * specializes or from which it was instantiated.4909 *4910 * This routine determines the template involved both for explicit4911 * specializations of templates and for implicit instantiations of the template,4912 * both of which are referred to as "specializations". For a class template4913 * specialization (e.g., \c std::vector<bool>), this routine will return4914 * either the primary template (\c std::vector) or, if the specialization was4915 * instantiated from a class template partial specialization, the class template4916 * partial specialization. For a class template partial specialization and a4917 * function template specialization (including instantiations), this4918 * this routine will return the specialized template.4919 *4920 * For members of a class template (e.g., member functions, member classes, or4921 * static data members), returns the specialized or instantiated member.4922 * Although not strictly "templates" in the C++ language, members of class4923 * templates have the same notions of specializations and instantiations that4924 * templates do, so this routine treats them similarly.4925 *4926 * \param C A cursor that may be a specialization of a template or a member4927 * of a template.4928 *4929 * \returns If the given cursor is a specialization or instantiation of a4930 * template or a member thereof, the template or member that it specializes or4931 * from which it was instantiated. Otherwise, returns a NULL cursor.4932 */4933CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);4934 4935/**4936 * Given a cursor that references something else, return the source range4937 * covering that reference.4938 *4939 * \param C A cursor pointing to a member reference, a declaration reference, or4940 * an operator call.4941 * \param NameFlags A bitset with three independent flags:4942 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and4943 * CXNameRange_WantSinglePiece.4944 * \param PieceIndex For contiguous names or when passing the flag4945 * CXNameRange_WantSinglePiece, only one piece with index 0 is4946 * available. When the CXNameRange_WantSinglePiece flag is not passed for a4947 * non-contiguous names, this index can be used to retrieve the individual4948 * pieces of the name. See also CXNameRange_WantSinglePiece.4949 *4950 * \returns The piece of the name pointed to by the given cursor. If there is no4951 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.4952 */4953CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(4954 CXCursor C, unsigned NameFlags, unsigned PieceIndex);4955 4956enum CXNameRefFlags {4957 /**4958 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the4959 * range.4960 */4961 CXNameRange_WantQualifier = 0x1,4962 4963 /**4964 * Include the explicit template arguments, e.g. \<int> in x.f<int>,4965 * in the range.4966 */4967 CXNameRange_WantTemplateArgs = 0x2,4968 4969 /**4970 * If the name is non-contiguous, return the full spanning range.4971 *4972 * Non-contiguous names occur in Objective-C when a selector with two or more4973 * parameters is used, or in C++ when using an operator:4974 * \code4975 * [object doSomething:here withValue:there]; // Objective-C4976 * return some_vector[1]; // C++4977 * \endcode4978 */4979 CXNameRange_WantSinglePiece = 0x44980};4981 4982/**4983 * @}4984 */4985 4986/**4987 * \defgroup CINDEX_LEX Token extraction and manipulation4988 *4989 * The routines in this group provide access to the tokens within a4990 * translation unit, along with a semantic mapping of those tokens to4991 * their corresponding cursors.4992 *4993 * @{4994 */4995 4996/**4997 * Describes a kind of token.4998 */4999typedef enum CXTokenKind {5000 /**5001 * A token that contains some kind of punctuation.5002 */5003 CXToken_Punctuation,5004 5005 /**5006 * A language keyword.5007 */5008 CXToken_Keyword,5009 5010 /**5011 * An identifier (that is not a keyword).5012 */5013 CXToken_Identifier,5014 5015 /**5016 * A numeric, string, or character literal.5017 */5018 CXToken_Literal,5019 5020 /**5021 * A comment.5022 */5023 CXToken_Comment5024} CXTokenKind;5025 5026/**5027 * Describes a single preprocessing token.5028 */5029typedef struct {5030 unsigned int_data[4];5031 void *ptr_data;5032} CXToken;5033 5034/**5035 * Get the raw lexical token starting with the given location.5036 *5037 * \param TU the translation unit whose text is being tokenized.5038 *5039 * \param Location the source location with which the token starts.5040 *5041 * \returns The token starting with the given location or NULL if no such token5042 * exist. The returned pointer must be freed with clang_disposeTokens before the5043 * translation unit is destroyed.5044 */5045CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,5046 CXSourceLocation Location);5047 5048/**5049 * Determine the kind of the given token.5050 */5051CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);5052 5053/**5054 * Determine the spelling of the given token.5055 *5056 * The spelling of a token is the textual representation of that token, e.g.,5057 * the text of an identifier or keyword.5058 */5059CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);5060 5061/**5062 * Retrieve the source location of the given token.5063 */5064CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,5065 CXToken);5066 5067/**5068 * Retrieve a source range that covers the given token.5069 */5070CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);5071 5072/**5073 * Tokenize the source code described by the given range into raw5074 * lexical tokens.5075 *5076 * \param TU the translation unit whose text is being tokenized.5077 *5078 * \param Range the source range in which text should be tokenized. All of the5079 * tokens produced by tokenization will fall within this source range,5080 *5081 * \param Tokens this pointer will be set to point to the array of tokens5082 * that occur within the given source range. The returned pointer must be5083 * freed with clang_disposeTokens() before the translation unit is destroyed.5084 *5085 * \param NumTokens will be set to the number of tokens in the \c *Tokens5086 * array.5087 *5088 */5089CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,5090 CXToken **Tokens, unsigned *NumTokens);5091 5092/**5093 * Annotate the given set of tokens by providing cursors for each token5094 * that can be mapped to a specific entity within the abstract syntax tree.5095 *5096 * This token-annotation routine is equivalent to invoking5097 * clang_getCursor() for the source locations of each of the5098 * tokens. The cursors provided are filtered, so that only those5099 * cursors that have a direct correspondence to the token are5100 * accepted. For example, given a function call \c f(x),5101 * clang_getCursor() would provide the following cursors:5102 *5103 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.5104 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.5105 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.5106 *5107 * Only the first and last of these cursors will occur within the5108 * annotate, since the tokens "f" and "x' directly refer to a function5109 * and a variable, respectively, but the parentheses are just a small5110 * part of the full syntax of the function call expression, which is5111 * not provided as an annotation.5112 *5113 * \param TU the translation unit that owns the given tokens.5114 *5115 * \param Tokens the set of tokens to annotate.5116 *5117 * \param NumTokens the number of tokens in \p Tokens.5118 *5119 * \param Cursors an array of \p NumTokens cursors, whose contents will be5120 * replaced with the cursors corresponding to each token.5121 */5122CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,5123 unsigned NumTokens, CXCursor *Cursors);5124 5125/**5126 * Free the given set of tokens.5127 */5128CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,5129 unsigned NumTokens);5130 5131/**5132 * @}5133 */5134 5135/**5136 * \defgroup CINDEX_DEBUG Debugging facilities5137 *5138 * These routines are used for testing and debugging, only, and should not5139 * be relied upon.5140 *5141 * @{5142 */5143 5144/* for debug/testing */5145CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);5146CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(5147 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,5148 unsigned *startColumn, unsigned *endLine, unsigned *endColumn);5149CINDEX_LINKAGE void clang_enableStackTraces(void);5150CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,5151 unsigned stack_size);5152 5153/**5154 * @}5155 */5156 5157/**5158 * \defgroup CINDEX_CODE_COMPLET Code completion5159 *5160 * Code completion involves taking an (incomplete) source file, along with5161 * knowledge of where the user is actively editing that file, and suggesting5162 * syntactically- and semantically-valid constructs that the user might want to5163 * use at that particular point in the source code. These data structures and5164 * routines provide support for code completion.5165 *5166 * @{5167 */5168 5169/**5170 * A semantic string that describes a code-completion result.5171 *5172 * A semantic string that describes the formatting of a code-completion5173 * result as a single "template" of text that should be inserted into the5174 * source buffer when a particular code-completion result is selected.5175 * Each semantic string is made up of some number of "chunks", each of which5176 * contains some text along with a description of what that text means, e.g.,5177 * the name of the entity being referenced, whether the text chunk is part of5178 * the template, or whether it is a "placeholder" that the user should replace5179 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a5180 * description of the different kinds of chunks.5181 */5182typedef void *CXCompletionString;5183 5184/**5185 * A single result of code completion.5186 */5187typedef struct {5188 /**5189 * The kind of entity that this completion refers to.5190 *5191 * The cursor kind will be a macro, keyword, or a declaration (one of the5192 * *Decl cursor kinds), describing the entity that the completion is5193 * referring to.5194 *5195 * \todo In the future, we would like to provide a full cursor, to allow5196 * the client to extract additional information from declaration.5197 */5198 enum CXCursorKind CursorKind;5199 5200 /**5201 * The code-completion string that describes how to insert this5202 * code-completion result into the editing buffer.5203 */5204 CXCompletionString CompletionString;5205} CXCompletionResult;5206 5207/**5208 * Describes a single piece of text within a code-completion string.5209 *5210 * Each "chunk" within a code-completion string (\c CXCompletionString) is5211 * either a piece of text with a specific "kind" that describes how that text5212 * should be interpreted by the client or is another completion string.5213 */5214enum CXCompletionChunkKind {5215 /**5216 * A code-completion string that describes "optional" text that5217 * could be a part of the template (but is not required).5218 *5219 * The Optional chunk is the only kind of chunk that has a code-completion5220 * string for its representation, which is accessible via5221 * \c clang_getCompletionChunkCompletionString(). The code-completion string5222 * describes an additional part of the template that is completely optional.5223 * For example, optional chunks can be used to describe the placeholders for5224 * arguments that match up with defaulted function parameters, e.g. given:5225 *5226 * \code5227 * void f(int x, float y = 3.14, double z = 2.71828);5228 * \endcode5229 *5230 * The code-completion string for this function would contain:5231 * - a TypedText chunk for "f".5232 * - a LeftParen chunk for "(".5233 * - a Placeholder chunk for "int x"5234 * - an Optional chunk containing the remaining defaulted arguments, e.g.,5235 * - a Comma chunk for ","5236 * - a Placeholder chunk for "float y"5237 * - an Optional chunk containing the last defaulted argument:5238 * - a Comma chunk for ","5239 * - a Placeholder chunk for "double z"5240 * - a RightParen chunk for ")"5241 *5242 * There are many ways to handle Optional chunks. Two simple approaches are:5243 * - Completely ignore optional chunks, in which case the template for the5244 * function "f" would only include the first parameter ("int x").5245 * - Fully expand all optional chunks, in which case the template for the5246 * function "f" would have all of the parameters.5247 */5248 CXCompletionChunk_Optional,5249 /**5250 * Text that a user would be expected to type to get this5251 * code-completion result.5252 *5253 * There will be exactly one "typed text" chunk in a semantic string, which5254 * will typically provide the spelling of a keyword or the name of a5255 * declaration that could be used at the current code point. Clients are5256 * expected to filter the code-completion results based on the text in this5257 * chunk.5258 */5259 CXCompletionChunk_TypedText,5260 /**5261 * Text that should be inserted as part of a code-completion result.5262 *5263 * A "text" chunk represents text that is part of the template to be5264 * inserted into user code should this particular code-completion result5265 * be selected.5266 */5267 CXCompletionChunk_Text,5268 /**5269 * Placeholder text that should be replaced by the user.5270 *5271 * A "placeholder" chunk marks a place where the user should insert text5272 * into the code-completion template. For example, placeholders might mark5273 * the function parameters for a function declaration, to indicate that the5274 * user should provide arguments for each of those parameters. The actual5275 * text in a placeholder is a suggestion for the text to display before5276 * the user replaces the placeholder with real code.5277 */5278 CXCompletionChunk_Placeholder,5279 /**5280 * Informative text that should be displayed but never inserted as5281 * part of the template.5282 *5283 * An "informative" chunk contains annotations that can be displayed to5284 * help the user decide whether a particular code-completion result is the5285 * right option, but which is not part of the actual template to be inserted5286 * by code completion.5287 */5288 CXCompletionChunk_Informative,5289 /**5290 * Text that describes the current parameter when code-completion is5291 * referring to function call, message send, or template specialization.5292 *5293 * A "current parameter" chunk occurs when code-completion is providing5294 * information about a parameter corresponding to the argument at the5295 * code-completion point. For example, given a function5296 *5297 * \code5298 * int add(int x, int y);5299 * \endcode5300 *5301 * and the source code \c add(, where the code-completion point is after the5302 * "(", the code-completion string will contain a "current parameter" chunk5303 * for "int x", indicating that the current argument will initialize that5304 * parameter. After typing further, to \c add(17, (where the code-completion5305 * point is after the ","), the code-completion string will contain a5306 * "current parameter" chunk to "int y".5307 */5308 CXCompletionChunk_CurrentParameter,5309 /**5310 * A left parenthesis ('('), used to initiate a function call or5311 * signal the beginning of a function parameter list.5312 */5313 CXCompletionChunk_LeftParen,5314 /**5315 * A right parenthesis (')'), used to finish a function call or5316 * signal the end of a function parameter list.5317 */5318 CXCompletionChunk_RightParen,5319 /**5320 * A left bracket ('[').5321 */5322 CXCompletionChunk_LeftBracket,5323 /**5324 * A right bracket (']').5325 */5326 CXCompletionChunk_RightBracket,5327 /**5328 * A left brace ('{').5329 */5330 CXCompletionChunk_LeftBrace,5331 /**5332 * A right brace ('}').5333 */5334 CXCompletionChunk_RightBrace,5335 /**5336 * A left angle bracket ('<').5337 */5338 CXCompletionChunk_LeftAngle,5339 /**5340 * A right angle bracket ('>').5341 */5342 CXCompletionChunk_RightAngle,5343 /**5344 * A comma separator (',').5345 */5346 CXCompletionChunk_Comma,5347 /**5348 * Text that specifies the result type of a given result.5349 *5350 * This special kind of informative chunk is not meant to be inserted into5351 * the text buffer. Rather, it is meant to illustrate the type that an5352 * expression using the given completion string would have.5353 */5354 CXCompletionChunk_ResultType,5355 /**5356 * A colon (':').5357 */5358 CXCompletionChunk_Colon,5359 /**5360 * A semicolon (';').5361 */5362 CXCompletionChunk_SemiColon,5363 /**5364 * An '=' sign.5365 */5366 CXCompletionChunk_Equal,5367 /**5368 * Horizontal space (' ').5369 */5370 CXCompletionChunk_HorizontalSpace,5371 /**5372 * Vertical space ('\\n'), after which it is generally a good idea to5373 * perform indentation.5374 */5375 CXCompletionChunk_VerticalSpace5376};5377 5378/**5379 * Determine the kind of a particular chunk within a completion string.5380 *5381 * \param completion_string the completion string to query.5382 *5383 * \param chunk_number the 0-based index of the chunk in the completion string.5384 *5385 * \returns the kind of the chunk at the index \c chunk_number.5386 */5387CINDEX_LINKAGE enum CXCompletionChunkKind5388clang_getCompletionChunkKind(CXCompletionString completion_string,5389 unsigned chunk_number);5390 5391/**5392 * Retrieve the text associated with a particular chunk within a5393 * completion string.5394 *5395 * \param completion_string the completion string to query.5396 *5397 * \param chunk_number the 0-based index of the chunk in the completion string.5398 *5399 * \returns the text associated with the chunk at index \c chunk_number.5400 */5401CINDEX_LINKAGE CXString clang_getCompletionChunkText(5402 CXCompletionString completion_string, unsigned chunk_number);5403 5404/**5405 * Retrieve the completion string associated with a particular chunk5406 * within a completion string.5407 *5408 * \param completion_string the completion string to query.5409 *5410 * \param chunk_number the 0-based index of the chunk in the completion string.5411 *5412 * \returns the completion string associated with the chunk at index5413 * \c chunk_number.5414 */5415CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(5416 CXCompletionString completion_string, unsigned chunk_number);5417 5418/**5419 * Retrieve the number of chunks in the given code-completion string.5420 */5421CINDEX_LINKAGE unsigned5422clang_getNumCompletionChunks(CXCompletionString completion_string);5423 5424/**5425 * Determine the priority of this code completion.5426 *5427 * The priority of a code completion indicates how likely it is that this5428 * particular completion is the completion that the user will select. The5429 * priority is selected by various internal heuristics.5430 *5431 * \param completion_string The completion string to query.5432 *5433 * \returns The priority of this completion string. Smaller values indicate5434 * higher-priority (more likely) completions.5435 */5436CINDEX_LINKAGE unsigned5437clang_getCompletionPriority(CXCompletionString completion_string);5438 5439/**5440 * Determine the availability of the entity that this code-completion5441 * string refers to.5442 *5443 * \param completion_string The completion string to query.5444 *5445 * \returns The availability of the completion string.5446 */5447CINDEX_LINKAGE enum CXAvailabilityKind5448clang_getCompletionAvailability(CXCompletionString completion_string);5449 5450/**5451 * Retrieve the number of annotations associated with the given5452 * completion string.5453 *5454 * \param completion_string the completion string to query.5455 *5456 * \returns the number of annotations associated with the given completion5457 * string.5458 */5459CINDEX_LINKAGE unsigned5460clang_getCompletionNumAnnotations(CXCompletionString completion_string);5461 5462/**5463 * Retrieve the annotation associated with the given completion string.5464 *5465 * \param completion_string the completion string to query.5466 *5467 * \param annotation_number the 0-based index of the annotation of the5468 * completion string.5469 *5470 * \returns annotation string associated with the completion at index5471 * \c annotation_number, or a NULL string if that annotation is not available.5472 */5473CINDEX_LINKAGE CXString clang_getCompletionAnnotation(5474 CXCompletionString completion_string, unsigned annotation_number);5475 5476/**5477 * Retrieve the parent context of the given completion string.5478 *5479 * The parent context of a completion string is the semantic parent of5480 * the declaration (if any) that the code completion represents. For example,5481 * a code completion for an Objective-C method would have the method's class5482 * or protocol as its context.5483 *5484 * \param completion_string The code completion string whose parent is5485 * being queried.5486 *5487 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.5488 *5489 * \returns The name of the completion parent, e.g., "NSObject" if5490 * the completion string represents a method in the NSObject class.5491 */5492CINDEX_LINKAGE CXString clang_getCompletionParent(5493 CXCompletionString completion_string, enum CXCursorKind *kind);5494 5495/**5496 * Retrieve the brief documentation comment attached to the declaration5497 * that corresponds to the given completion string.5498 */5499CINDEX_LINKAGE CXString5500clang_getCompletionBriefComment(CXCompletionString completion_string);5501 5502/**5503 * Retrieve a completion string for an arbitrary declaration or macro5504 * definition cursor.5505 *5506 * \param cursor The cursor to query.5507 *5508 * \returns A non-context-sensitive completion string for declaration and macro5509 * definition cursors, or NULL for other kinds of cursors.5510 */5511CINDEX_LINKAGE CXCompletionString5512clang_getCursorCompletionString(CXCursor cursor);5513 5514/**5515 * Contains the results of code-completion.5516 *5517 * This data structure contains the results of code completion, as5518 * produced by \c clang_codeCompleteAt(). Its contents must be freed by5519 * \c clang_disposeCodeCompleteResults.5520 */5521typedef struct {5522 /**5523 * The code-completion results.5524 */5525 CXCompletionResult *Results;5526 5527 /**5528 * The number of code-completion results stored in the5529 * \c Results array.5530 */5531 unsigned NumResults;5532} CXCodeCompleteResults;5533 5534/**5535 * Retrieve the number of fix-its for the given completion index.5536 *5537 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts5538 * option was set.5539 *5540 * \param results The structure keeping all completion results5541 *5542 * \param completion_index The index of the completion5543 *5544 * \return The number of fix-its which must be applied before the completion at5545 * completion_index can be applied5546 */5547CINDEX_LINKAGE unsigned5548clang_getCompletionNumFixIts(CXCodeCompleteResults *results,5549 unsigned completion_index);5550 5551/**5552 * Fix-its that *must* be applied before inserting the text for the5553 * corresponding completion.5554 *5555 * By default, clang_codeCompleteAt() only returns completions with empty5556 * fix-its. Extra completions with non-empty fix-its should be explicitly5557 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.5558 *5559 * For the clients to be able to compute position of the cursor after applying5560 * fix-its, the following conditions are guaranteed to hold for5561 * replacement_range of the stored fix-its:5562 * - Ranges in the fix-its are guaranteed to never contain the completion5563 * point (or identifier under completion point, if any) inside them, except5564 * at the start or at the end of the range.5565 * - If a fix-it range starts or ends with completion point (or starts or5566 * ends after the identifier under completion point), it will contain at5567 * least one character. It allows to unambiguously recompute completion5568 * point after applying the fix-it.5569 *5570 * The intuition is that provided fix-its change code around the identifier we5571 * complete, but are not allowed to touch the identifier itself or the5572 * completion point. One example of completions with corrections are the ones5573 * replacing '.' with '->' and vice versa:5574 *5575 * std::unique_ptr<std::vector<int>> vec_ptr;5576 * In 'vec_ptr.^', one of the completions is 'push_back', it requires5577 * replacing '.' with '->'.5578 * In 'vec_ptr->^', one of the completions is 'release', it requires5579 * replacing '->' with '.'.5580 *5581 * \param results The structure keeping all completion results5582 *5583 * \param completion_index The index of the completion5584 *5585 * \param fixit_index The index of the fix-it for the completion at5586 * completion_index5587 *5588 * \param replacement_range The fix-it range that must be replaced before the5589 * completion at completion_index can be applied5590 *5591 * \returns The fix-it string that must replace the code at replacement_range5592 * before the completion at completion_index can be applied5593 */5594CINDEX_LINKAGE CXString clang_getCompletionFixIt(5595 CXCodeCompleteResults *results, unsigned completion_index,5596 unsigned fixit_index, CXSourceRange *replacement_range);5597 5598/**5599 * Flags that can be passed to \c clang_codeCompleteAt() to5600 * modify its behavior.5601 *5602 * The enumerators in this enumeration can be bitwise-OR'd together to5603 * provide multiple options to \c clang_codeCompleteAt().5604 */5605enum CXCodeComplete_Flags {5606 /**5607 * Whether to include macros within the set of code5608 * completions returned.5609 */5610 CXCodeComplete_IncludeMacros = 0x01,5611 5612 /**5613 * Whether to include code patterns for language constructs5614 * within the set of code completions, e.g., for loops.5615 */5616 CXCodeComplete_IncludeCodePatterns = 0x02,5617 5618 /**5619 * Whether to include brief documentation within the set of code5620 * completions returned.5621 */5622 CXCodeComplete_IncludeBriefComments = 0x04,5623 5624 /**5625 * Whether to speed up completion by omitting top- or namespace-level entities5626 * defined in the preamble. There's no guarantee any particular entity is5627 * omitted. This may be useful if the headers are indexed externally.5628 */5629 CXCodeComplete_SkipPreamble = 0x08,5630 5631 /**5632 * Whether to include completions with small5633 * fix-its, e.g. change '.' to '->' on member access, etc.5634 */5635 CXCodeComplete_IncludeCompletionsWithFixIts = 0x105636};5637 5638/**5639 * Bits that represent the context under which completion is occurring.5640 *5641 * The enumerators in this enumeration may be bitwise-OR'd together if multiple5642 * contexts are occurring simultaneously.5643 */5644enum CXCompletionContext {5645 /**5646 * The context for completions is unexposed, as only Clang results5647 * should be included. (This is equivalent to having no context bits set.)5648 */5649 CXCompletionContext_Unexposed = 0,5650 5651 /**5652 * Completions for any possible type should be included in the results.5653 */5654 CXCompletionContext_AnyType = 1 << 0,5655 5656 /**5657 * Completions for any possible value (variables, function calls, etc.)5658 * should be included in the results.5659 */5660 CXCompletionContext_AnyValue = 1 << 1,5661 /**5662 * Completions for values that resolve to an Objective-C object should5663 * be included in the results.5664 */5665 CXCompletionContext_ObjCObjectValue = 1 << 2,5666 /**5667 * Completions for values that resolve to an Objective-C selector5668 * should be included in the results.5669 */5670 CXCompletionContext_ObjCSelectorValue = 1 << 3,5671 /**5672 * Completions for values that resolve to a C++ class type should be5673 * included in the results.5674 */5675 CXCompletionContext_CXXClassTypeValue = 1 << 4,5676 5677 /**5678 * Completions for fields of the member being accessed using the dot5679 * operator should be included in the results.5680 */5681 CXCompletionContext_DotMemberAccess = 1 << 5,5682 /**5683 * Completions for fields of the member being accessed using the arrow5684 * operator should be included in the results.5685 */5686 CXCompletionContext_ArrowMemberAccess = 1 << 6,5687 /**5688 * Completions for properties of the Objective-C object being accessed5689 * using the dot operator should be included in the results.5690 */5691 CXCompletionContext_ObjCPropertyAccess = 1 << 7,5692 5693 /**5694 * Completions for enum tags should be included in the results.5695 */5696 CXCompletionContext_EnumTag = 1 << 8,5697 /**5698 * Completions for union tags should be included in the results.5699 */5700 CXCompletionContext_UnionTag = 1 << 9,5701 /**5702 * Completions for struct tags should be included in the results.5703 */5704 CXCompletionContext_StructTag = 1 << 10,5705 5706 /**5707 * Completions for C++ class names should be included in the results.5708 */5709 CXCompletionContext_ClassTag = 1 << 11,5710 /**5711 * Completions for C++ namespaces and namespace aliases should be5712 * included in the results.5713 */5714 CXCompletionContext_Namespace = 1 << 12,5715 /**5716 * Completions for C++ nested name specifiers should be included in5717 * the results.5718 */5719 CXCompletionContext_NestedNameSpecifier = 1 << 13,5720 5721 /**5722 * Completions for Objective-C interfaces (classes) should be included5723 * in the results.5724 */5725 CXCompletionContext_ObjCInterface = 1 << 14,5726 /**5727 * Completions for Objective-C protocols should be included in5728 * the results.5729 */5730 CXCompletionContext_ObjCProtocol = 1 << 15,5731 /**5732 * Completions for Objective-C categories should be included in5733 * the results.5734 */5735 CXCompletionContext_ObjCCategory = 1 << 16,5736 /**5737 * Completions for Objective-C instance messages should be included5738 * in the results.5739 */5740 CXCompletionContext_ObjCInstanceMessage = 1 << 17,5741 /**5742 * Completions for Objective-C class messages should be included in5743 * the results.5744 */5745 CXCompletionContext_ObjCClassMessage = 1 << 18,5746 /**5747 * Completions for Objective-C selector names should be included in5748 * the results.5749 */5750 CXCompletionContext_ObjCSelectorName = 1 << 19,5751 5752 /**5753 * Completions for preprocessor macro names should be included in5754 * the results.5755 */5756 CXCompletionContext_MacroName = 1 << 20,5757 5758 /**5759 * Natural language completions should be included in the results.5760 */5761 CXCompletionContext_NaturalLanguage = 1 << 21,5762 5763 /**5764 * #include file completions should be included in the results.5765 */5766 CXCompletionContext_IncludedFile = 1 << 22,5767 5768 /**5769 * The current context is unknown, so set all contexts.5770 */5771 CXCompletionContext_Unknown = ((1 << 23) - 1)5772};5773 5774/**5775 * Returns a default set of code-completion options that can be5776 * passed to\c clang_codeCompleteAt().5777 */5778CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);5779 5780/**5781 * Perform code completion at a given location in a translation unit.5782 *5783 * This function performs code completion at a particular file, line, and5784 * column within source code, providing results that suggest potential5785 * code snippets based on the context of the completion. The basic model5786 * for code completion is that Clang will parse a complete source file,5787 * performing syntax checking up to the location where code-completion has5788 * been requested. At that point, a special code-completion token is passed5789 * to the parser, which recognizes this token and determines, based on the5790 * current location in the C/Objective-C/C++ grammar and the state of5791 * semantic analysis, what completions to provide. These completions are5792 * returned via a new \c CXCodeCompleteResults structure.5793 *5794 * Code completion itself is meant to be triggered by the client when the5795 * user types punctuation characters or whitespace, at which point the5796 * code-completion location will coincide with the cursor. For example, if \c p5797 * is a pointer, code-completion might be triggered after the "-" and then5798 * after the ">" in \c p->. When the code-completion location is after the ">",5799 * the completion results will provide, e.g., the members of the struct that5800 * "p" points to. The client is responsible for placing the cursor at the5801 * beginning of the token currently being typed, then filtering the results5802 * based on the contents of the token. For example, when code-completing for5803 * the expression \c p->get, the client should provide the location just after5804 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the5805 * client can filter the results based on the current token text ("get"), only5806 * showing those results that start with "get". The intent of this interface5807 * is to separate the relatively high-latency acquisition of code-completion5808 * results from the filtering of results on a per-character basis, which must5809 * have a lower latency.5810 *5811 * \param TU The translation unit in which code-completion should5812 * occur. The source files for this translation unit need not be5813 * completely up-to-date (and the contents of those source files may5814 * be overridden via \p unsaved_files). Cursors referring into the5815 * translation unit may be invalidated by this invocation.5816 *5817 * \param complete_filename The name of the source file where code5818 * completion should be performed. This filename may be any file5819 * included in the translation unit.5820 *5821 * \param complete_line The line at which code-completion should occur.5822 *5823 * \param complete_column The column at which code-completion should occur.5824 * Note that the column should point just after the syntactic construct that5825 * initiated code completion, and not in the middle of a lexical token.5826 *5827 * \param unsaved_files the Files that have not yet been saved to disk5828 * but may be required for parsing or code completion, including the5829 * contents of those files. The contents and name of these files (as5830 * specified by CXUnsavedFile) are copied when necessary, so the5831 * client only needs to guarantee their validity until the call to5832 * this function returns.5833 *5834 * \param num_unsaved_files The number of unsaved file entries in \p5835 * unsaved_files.5836 *5837 * \param options Extra options that control the behavior of code5838 * completion, expressed as a bitwise OR of the enumerators of the5839 * CXCodeComplete_Flags enumeration. The5840 * \c clang_defaultCodeCompleteOptions() function returns a default set5841 * of code-completion options.5842 *5843 * \returns If successful, a new \c CXCodeCompleteResults structure5844 * containing code-completion results, which should eventually be5845 * freed with \c clang_disposeCodeCompleteResults(). If code5846 * completion fails, returns NULL.5847 */5848CINDEX_LINKAGE5849CXCodeCompleteResults *5850clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,5851 unsigned complete_line, unsigned complete_column,5852 struct CXUnsavedFile *unsaved_files,5853 unsigned num_unsaved_files, unsigned options);5854 5855/**5856 * Sort the code-completion results in case-insensitive alphabetical5857 * order.5858 *5859 * \param Results The set of results to sort.5860 * \param NumResults The number of results in \p Results.5861 */5862CINDEX_LINKAGE5863void clang_sortCodeCompletionResults(CXCompletionResult *Results,5864 unsigned NumResults);5865 5866/**5867 * Free the given set of code-completion results.5868 */5869CINDEX_LINKAGE5870void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);5871 5872/**5873 * Determine the number of diagnostics produced prior to the5874 * location where code completion was performed.5875 */5876CINDEX_LINKAGE5877unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);5878 5879/**5880 * Retrieve a diagnostic associated with the given code completion.5881 *5882 * \param Results the code completion results to query.5883 * \param Index the zero-based diagnostic number to retrieve.5884 *5885 * \returns the requested diagnostic. This diagnostic must be freed5886 * via a call to \c clang_disposeDiagnostic().5887 */5888CINDEX_LINKAGE5889CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,5890 unsigned Index);5891 5892/**5893 * Determines what completions are appropriate for the context5894 * the given code completion.5895 *5896 * \param Results the code completion results to query5897 *5898 * \returns the kinds of completions that are appropriate for use5899 * along with the given code completion results.5900 */5901CINDEX_LINKAGE5902unsigned long long5903clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);5904 5905/**5906 * Returns the cursor kind for the container for the current code5907 * completion context. The container is only guaranteed to be set for5908 * contexts where a container exists (i.e. member accesses or Objective-C5909 * message sends); if there is not a container, this function will return5910 * CXCursor_InvalidCode.5911 *5912 * \param Results the code completion results to query5913 *5914 * \param IsIncomplete on return, this value will be false if Clang has complete5915 * information about the container. If Clang does not have complete5916 * information, this value will be true.5917 *5918 * \returns the container kind, or CXCursor_InvalidCode if there is not a5919 * container5920 */5921CINDEX_LINKAGE5922enum CXCursorKind5923clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,5924 unsigned *IsIncomplete);5925 5926/**5927 * Returns the USR for the container for the current code completion5928 * context. If there is not a container for the current context, this5929 * function will return the empty string.5930 *5931 * \param Results the code completion results to query5932 *5933 * \returns the USR for the container5934 */5935CINDEX_LINKAGE5936CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);5937 5938/**5939 * Returns the currently-entered selector for an Objective-C message5940 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a5941 * non-empty string for CXCompletionContext_ObjCInstanceMessage and5942 * CXCompletionContext_ObjCClassMessage.5943 *5944 * \param Results the code completion results to query5945 *5946 * \returns the selector (or partial selector) that has been entered thus far5947 * for an Objective-C message send.5948 */5949CINDEX_LINKAGE5950CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);5951 5952/**5953 * @}5954 */5955 5956/**5957 * \defgroup CINDEX_MISC Miscellaneous utility functions5958 *5959 * @{5960 */5961 5962/**5963 * Return a version string, suitable for showing to a user, but not5964 * intended to be parsed (the format is not guaranteed to be stable).5965 */5966CINDEX_LINKAGE CXString clang_getClangVersion(void);5967 5968/**5969 * Enable/disable crash recovery.5970 *5971 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero5972 * value enables crash recovery, while 0 disables it.5973 */5974CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);5975 5976/**5977 * Visitor invoked for each file in a translation unit5978 * (used with clang_getInclusions()).5979 *5980 * This visitor function will be invoked by clang_getInclusions() for each5981 * file included (either at the top-level or by \#include directives) within5982 * a translation unit. The first argument is the file being included, and5983 * the second and third arguments provide the inclusion stack. The5984 * array is sorted in order of immediate inclusion. For example,5985 * the first element refers to the location that included 'included_file'.5986 */5987typedef void (*CXInclusionVisitor)(CXFile included_file,5988 CXSourceLocation *inclusion_stack,5989 unsigned include_len,5990 CXClientData client_data);5991 5992/**5993 * Visit the set of preprocessor inclusions in a translation unit.5994 * The visitor function is called with the provided data for every included5995 * file. This does not include headers included by the PCH file (unless one5996 * is inspecting the inclusions in the PCH file itself).5997 */5998CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,5999 CXInclusionVisitor visitor,6000 CXClientData client_data);6001 6002typedef enum {6003 CXEval_Int = 1,6004 CXEval_Float = 2,6005 CXEval_ObjCStrLiteral = 3,6006 CXEval_StrLiteral = 4,6007 CXEval_CFStr = 5,6008 CXEval_Other = 6,6009 6010 CXEval_UnExposed = 06011 6012} CXEvalResultKind;6013 6014/**6015 * Evaluation result of a cursor6016 */6017typedef void *CXEvalResult;6018 6019/**6020 * If cursor is a statement declaration tries to evaluate the6021 * statement and if its variable, tries to evaluate its initializer,6022 * into its corresponding type.6023 * If it's an expression, tries to evaluate the expression.6024 */6025CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);6026 6027/**6028 * Returns the kind of the evaluated result.6029 */6030CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);6031 6032/**6033 * Returns the evaluation result as integer if the6034 * kind is Int.6035 */6036CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);6037 6038/**6039 * Returns the evaluation result as a long long integer if the6040 * kind is Int. This prevents overflows that may happen if the result is6041 * returned with clang_EvalResult_getAsInt.6042 */6043CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);6044 6045/**6046 * Returns a non-zero value if the kind is Int and the evaluation6047 * result resulted in an unsigned integer.6048 */6049CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);6050 6051/**6052 * Returns the evaluation result as an unsigned integer if6053 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.6054 */6055CINDEX_LINKAGE unsigned long long6056clang_EvalResult_getAsUnsigned(CXEvalResult E);6057 6058/**6059 * Returns the evaluation result as double if the6060 * kind is double.6061 */6062CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);6063 6064/**6065 * Returns the evaluation result as a constant string if the6066 * kind is other than Int or float. User must not free this pointer,6067 * instead call clang_EvalResult_dispose on the CXEvalResult returned6068 * by clang_Cursor_Evaluate.6069 */6070CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);6071 6072/**6073 * Disposes the created Eval memory.6074 */6075CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);6076/**6077 * @}6078 */6079 6080/** \defgroup CINDEX_HIGH Higher level API functions6081 *6082 * @{6083 */6084 6085enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };6086 6087typedef struct CXCursorAndRangeVisitor {6088 void *context;6089 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);6090} CXCursorAndRangeVisitor;6091 6092typedef enum {6093 /**6094 * Function returned successfully.6095 */6096 CXResult_Success = 0,6097 /**6098 * One of the parameters was invalid for the function.6099 */6100 CXResult_Invalid = 1,6101 /**6102 * The function was terminated by a callback (e.g. it returned6103 * CXVisit_Break)6104 */6105 CXResult_VisitBreak = 26106 6107} CXResult;6108 6109/**6110 * Find references of a declaration in a specific file.6111 *6112 * \param cursor pointing to a declaration or a reference of one.6113 *6114 * \param file to search for references.6115 *6116 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for6117 * each reference found.6118 * The CXSourceRange will point inside the file; if the reference is inside6119 * a macro (and not a macro argument) the CXSourceRange will be invalid.6120 *6121 * \returns one of the CXResult enumerators.6122 */6123CINDEX_LINKAGE CXResult clang_findReferencesInFile(6124 CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);6125 6126/**6127 * Find #import/#include directives in a specific file.6128 *6129 * \param TU translation unit containing the file to query.6130 *6131 * \param file to search for #import/#include directives.6132 *6133 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for6134 * each directive found.6135 *6136 * \returns one of the CXResult enumerators.6137 */6138CINDEX_LINKAGE CXResult clang_findIncludesInFile(6139 CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);6140 6141#if __has_feature(blocks)6142typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,6143 CXSourceRange);6144#else6145typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;6146#endif6147 6148CINDEX_LINKAGE6149CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,6150 CXCursorAndRangeVisitorBlock);6151 6152CINDEX_LINKAGE6153CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,6154 CXCursorAndRangeVisitorBlock);6155 6156/**6157 * The client's data object that is associated with a CXFile.6158 */6159typedef void *CXIdxClientFile;6160 6161/**6162 * The client's data object that is associated with a semantic entity.6163 */6164typedef void *CXIdxClientEntity;6165 6166/**6167 * The client's data object that is associated with a semantic container6168 * of entities.6169 */6170typedef void *CXIdxClientContainer;6171 6172/**6173 * The client's data object that is associated with an AST file (PCH6174 * or module).6175 */6176typedef void *CXIdxClientASTFile;6177 6178/**6179 * Source location passed to index callbacks.6180 */6181typedef struct {6182 void *ptr_data[2];6183 unsigned int_data;6184} CXIdxLoc;6185 6186/**6187 * Data for ppIncludedFile callback.6188 */6189typedef struct {6190 /**6191 * Location of '#' in the \#include/\#import directive.6192 */6193 CXIdxLoc hashLoc;6194 /**6195 * Filename as written in the \#include/\#import directive.6196 */6197 const char *filename;6198 /**6199 * The actual file that the \#include/\#import directive resolved to.6200 */6201 CXFile file;6202 int isImport;6203 int isAngled;6204 /**6205 * Non-zero if the directive was automatically turned into a module6206 * import.6207 */6208 int isModuleImport;6209} CXIdxIncludedFileInfo;6210 6211/**6212 * Data for IndexerCallbacks#importedASTFile.6213 */6214typedef struct {6215 /**6216 * Top level AST file containing the imported PCH, module or submodule.6217 */6218 CXFile file;6219 /**6220 * The imported module or NULL if the AST file is a PCH.6221 */6222 CXModule module;6223 /**6224 * Location where the file is imported. Applicable only for modules.6225 */6226 CXIdxLoc loc;6227 /**6228 * Non-zero if an inclusion directive was automatically turned into6229 * a module import. Applicable only for modules.6230 */6231 int isImplicit;6232 6233} CXIdxImportedASTFileInfo;6234 6235typedef enum {6236 CXIdxEntity_Unexposed = 0,6237 CXIdxEntity_Typedef = 1,6238 CXIdxEntity_Function = 2,6239 CXIdxEntity_Variable = 3,6240 CXIdxEntity_Field = 4,6241 CXIdxEntity_EnumConstant = 5,6242 6243 CXIdxEntity_ObjCClass = 6,6244 CXIdxEntity_ObjCProtocol = 7,6245 CXIdxEntity_ObjCCategory = 8,6246 6247 CXIdxEntity_ObjCInstanceMethod = 9,6248 CXIdxEntity_ObjCClassMethod = 10,6249 CXIdxEntity_ObjCProperty = 11,6250 CXIdxEntity_ObjCIvar = 12,6251 6252 CXIdxEntity_Enum = 13,6253 CXIdxEntity_Struct = 14,6254 CXIdxEntity_Union = 15,6255 6256 CXIdxEntity_CXXClass = 16,6257 CXIdxEntity_CXXNamespace = 17,6258 CXIdxEntity_CXXNamespaceAlias = 18,6259 CXIdxEntity_CXXStaticVariable = 19,6260 CXIdxEntity_CXXStaticMethod = 20,6261 CXIdxEntity_CXXInstanceMethod = 21,6262 CXIdxEntity_CXXConstructor = 22,6263 CXIdxEntity_CXXDestructor = 23,6264 CXIdxEntity_CXXConversionFunction = 24,6265 CXIdxEntity_CXXTypeAlias = 25,6266 CXIdxEntity_CXXInterface = 26,6267 CXIdxEntity_CXXConcept = 276268 6269} CXIdxEntityKind;6270 6271typedef enum {6272 CXIdxEntityLang_None = 0,6273 CXIdxEntityLang_C = 1,6274 CXIdxEntityLang_ObjC = 2,6275 CXIdxEntityLang_CXX = 3,6276 CXIdxEntityLang_Swift = 46277} CXIdxEntityLanguage;6278 6279/**6280 * Extra C++ template information for an entity. This can apply to:6281 * CXIdxEntity_Function6282 * CXIdxEntity_CXXClass6283 * CXIdxEntity_CXXStaticMethod6284 * CXIdxEntity_CXXInstanceMethod6285 * CXIdxEntity_CXXConstructor6286 * CXIdxEntity_CXXConversionFunction6287 * CXIdxEntity_CXXTypeAlias6288 */6289typedef enum {6290 CXIdxEntity_NonTemplate = 0,6291 CXIdxEntity_Template = 1,6292 CXIdxEntity_TemplatePartialSpecialization = 2,6293 CXIdxEntity_TemplateSpecialization = 36294} CXIdxEntityCXXTemplateKind;6295 6296typedef enum {6297 CXIdxAttr_Unexposed = 0,6298 CXIdxAttr_IBAction = 1,6299 CXIdxAttr_IBOutlet = 2,6300 CXIdxAttr_IBOutletCollection = 36301} CXIdxAttrKind;6302 6303typedef struct {6304 CXIdxAttrKind kind;6305 CXCursor cursor;6306 CXIdxLoc loc;6307} CXIdxAttrInfo;6308 6309typedef struct {6310 CXIdxEntityKind kind;6311 CXIdxEntityCXXTemplateKind templateKind;6312 CXIdxEntityLanguage lang;6313 const char *name;6314 const char *USR;6315 CXCursor cursor;6316 const CXIdxAttrInfo *const *attributes;6317 unsigned numAttributes;6318} CXIdxEntityInfo;6319 6320typedef struct {6321 CXCursor cursor;6322} CXIdxContainerInfo;6323 6324typedef struct {6325 const CXIdxAttrInfo *attrInfo;6326 const CXIdxEntityInfo *objcClass;6327 CXCursor classCursor;6328 CXIdxLoc classLoc;6329} CXIdxIBOutletCollectionAttrInfo;6330 6331typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;6332 6333typedef struct {6334 const CXIdxEntityInfo *entityInfo;6335 CXCursor cursor;6336 CXIdxLoc loc;6337 const CXIdxContainerInfo *semanticContainer;6338 /**6339 * Generally same as #semanticContainer but can be different in6340 * cases like out-of-line C++ member functions.6341 */6342 const CXIdxContainerInfo *lexicalContainer;6343 int isRedeclaration;6344 int isDefinition;6345 int isContainer;6346 const CXIdxContainerInfo *declAsContainer;6347 /**6348 * Whether the declaration exists in code or was created implicitly6349 * by the compiler, e.g. implicit Objective-C methods for properties.6350 */6351 int isImplicit;6352 const CXIdxAttrInfo *const *attributes;6353 unsigned numAttributes;6354 6355 unsigned flags;6356 6357} CXIdxDeclInfo;6358 6359typedef enum {6360 CXIdxObjCContainer_ForwardRef = 0,6361 CXIdxObjCContainer_Interface = 1,6362 CXIdxObjCContainer_Implementation = 26363} CXIdxObjCContainerKind;6364 6365typedef struct {6366 const CXIdxDeclInfo *declInfo;6367 CXIdxObjCContainerKind kind;6368} CXIdxObjCContainerDeclInfo;6369 6370typedef struct {6371 const CXIdxEntityInfo *base;6372 CXCursor cursor;6373 CXIdxLoc loc;6374} CXIdxBaseClassInfo;6375 6376typedef struct {6377 const CXIdxEntityInfo *protocol;6378 CXCursor cursor;6379 CXIdxLoc loc;6380} CXIdxObjCProtocolRefInfo;6381 6382typedef struct {6383 const CXIdxObjCProtocolRefInfo *const *protocols;6384 unsigned numProtocols;6385} CXIdxObjCProtocolRefListInfo;6386 6387typedef struct {6388 const CXIdxObjCContainerDeclInfo *containerInfo;6389 const CXIdxBaseClassInfo *superInfo;6390 const CXIdxObjCProtocolRefListInfo *protocols;6391} CXIdxObjCInterfaceDeclInfo;6392 6393typedef struct {6394 const CXIdxObjCContainerDeclInfo *containerInfo;6395 const CXIdxEntityInfo *objcClass;6396 CXCursor classCursor;6397 CXIdxLoc classLoc;6398 const CXIdxObjCProtocolRefListInfo *protocols;6399} CXIdxObjCCategoryDeclInfo;6400 6401typedef struct {6402 const CXIdxDeclInfo *declInfo;6403 const CXIdxEntityInfo *getter;6404 const CXIdxEntityInfo *setter;6405} CXIdxObjCPropertyDeclInfo;6406 6407typedef struct {6408 const CXIdxDeclInfo *declInfo;6409 const CXIdxBaseClassInfo *const *bases;6410 unsigned numBases;6411} CXIdxCXXClassDeclInfo;6412 6413/**6414 * Data for IndexerCallbacks#indexEntityReference.6415 *6416 * This may be deprecated in a future version as this duplicates6417 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.6418 */6419typedef enum {6420 /**6421 * The entity is referenced directly in user's code.6422 */6423 CXIdxEntityRef_Direct = 1,6424 /**6425 * An implicit reference, e.g. a reference of an Objective-C method6426 * via the dot syntax.6427 */6428 CXIdxEntityRef_Implicit = 26429} CXIdxEntityRefKind;6430 6431/**6432 * Roles that are attributed to symbol occurrences.6433 *6434 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with6435 * higher bits zeroed. These high bits may be exposed in the future.6436 */6437typedef enum {6438 CXSymbolRole_None = 0,6439 CXSymbolRole_Declaration = 1 << 0,6440 CXSymbolRole_Definition = 1 << 1,6441 CXSymbolRole_Reference = 1 << 2,6442 CXSymbolRole_Read = 1 << 3,6443 CXSymbolRole_Write = 1 << 4,6444 CXSymbolRole_Call = 1 << 5,6445 CXSymbolRole_Dynamic = 1 << 6,6446 CXSymbolRole_AddressOf = 1 << 7,6447 CXSymbolRole_Implicit = 1 << 86448} CXSymbolRole;6449 6450/**6451 * Data for IndexerCallbacks#indexEntityReference.6452 */6453typedef struct {6454 CXIdxEntityRefKind kind;6455 /**6456 * Reference cursor.6457 */6458 CXCursor cursor;6459 CXIdxLoc loc;6460 /**6461 * The entity that gets referenced.6462 */6463 const CXIdxEntityInfo *referencedEntity;6464 /**6465 * Immediate "parent" of the reference. For example:6466 *6467 * \code6468 * Foo *var;6469 * \endcode6470 *6471 * The parent of reference of type 'Foo' is the variable 'var'.6472 * For references inside statement bodies of functions/methods,6473 * the parentEntity will be the function/method.6474 */6475 const CXIdxEntityInfo *parentEntity;6476 /**6477 * Lexical container context of the reference.6478 */6479 const CXIdxContainerInfo *container;6480 /**6481 * Sets of symbol roles of the reference.6482 */6483 CXSymbolRole role;6484} CXIdxEntityRefInfo;6485 6486/**6487 * A group of callbacks used by #clang_indexSourceFile and6488 * #clang_indexTranslationUnit.6489 */6490typedef struct {6491 /**6492 * Called periodically to check whether indexing should be aborted.6493 * Should return 0 to continue, and non-zero to abort.6494 */6495 int (*abortQuery)(CXClientData client_data, void *reserved);6496 6497 /**6498 * Called at the end of indexing; passes the complete diagnostic set.6499 */6500 void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);6501 6502 CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,6503 void *reserved);6504 6505 /**6506 * Called when a file gets \#included/\#imported.6507 */6508 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,6509 const CXIdxIncludedFileInfo *);6510 6511 /**6512 * Called when a AST file (PCH or module) gets imported.6513 *6514 * AST files will not get indexed (there will not be callbacks to index all6515 * the entities in an AST file). The recommended action is that, if the AST6516 * file is not already indexed, to initiate a new indexing job specific to6517 * the AST file.6518 */6519 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,6520 const CXIdxImportedASTFileInfo *);6521 6522 /**6523 * Called at the beginning of indexing a translation unit.6524 */6525 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,6526 void *reserved);6527 6528 void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);6529 6530 /**6531 * Called to index a reference of an entity.6532 */6533 void (*indexEntityReference)(CXClientData client_data,6534 const CXIdxEntityRefInfo *);6535 6536} IndexerCallbacks;6537 6538CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);6539CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *6540clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);6541 6542CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *6543clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);6544 6545CINDEX_LINKAGE6546const CXIdxObjCCategoryDeclInfo *6547clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);6548 6549CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *6550clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);6551 6552CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *6553clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);6554 6555CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *6556clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);6557 6558CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *6559clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);6560 6561/**6562 * For retrieving a custom CXIdxClientContainer attached to a6563 * container.6564 */6565CINDEX_LINKAGE CXIdxClientContainer6566clang_index_getClientContainer(const CXIdxContainerInfo *);6567 6568/**6569 * For setting a custom CXIdxClientContainer attached to a6570 * container.6571 */6572CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,6573 CXIdxClientContainer);6574 6575/**6576 * For retrieving a custom CXIdxClientEntity attached to an entity.6577 */6578CINDEX_LINKAGE CXIdxClientEntity6579clang_index_getClientEntity(const CXIdxEntityInfo *);6580 6581/**6582 * For setting a custom CXIdxClientEntity attached to an entity.6583 */6584CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,6585 CXIdxClientEntity);6586 6587/**6588 * An indexing action/session, to be applied to one or multiple6589 * translation units.6590 */6591typedef void *CXIndexAction;6592 6593/**6594 * An indexing action/session, to be applied to one or multiple6595 * translation units.6596 *6597 * \param CIdx The index object with which the index action will be associated.6598 */6599CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);6600 6601/**6602 * Destroy the given index action.6603 *6604 * The index action must not be destroyed until all of the translation units6605 * created within that index action have been destroyed.6606 */6607CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);6608 6609typedef enum {6610 /**6611 * Used to indicate that no special indexing options are needed.6612 */6613 CXIndexOpt_None = 0x0,6614 6615 /**6616 * Used to indicate that IndexerCallbacks#indexEntityReference should6617 * be invoked for only one reference of an entity per source file that does6618 * not also include a declaration/definition of the entity.6619 */6620 CXIndexOpt_SuppressRedundantRefs = 0x1,6621 6622 /**6623 * Function-local symbols should be indexed. If this is not set6624 * function-local symbols will be ignored.6625 */6626 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,6627 6628 /**6629 * Implicit function/class template instantiations should be indexed.6630 * If this is not set, implicit instantiations will be ignored.6631 */6632 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,6633 6634 /**6635 * Suppress all compiler warnings when parsing for indexing.6636 */6637 CXIndexOpt_SuppressWarnings = 0x8,6638 6639 /**6640 * Skip a function/method body that was already parsed during an6641 * indexing session associated with a \c CXIndexAction object.6642 * Bodies in system headers are always skipped.6643 */6644 CXIndexOpt_SkipParsedBodiesInSession = 0x106645 6646} CXIndexOptFlags;6647 6648/**6649 * Index the given source file and the translation unit corresponding6650 * to that file via callbacks implemented through #IndexerCallbacks.6651 *6652 * \param client_data pointer data supplied by the client, which will6653 * be passed to the invoked callbacks.6654 *6655 * \param index_callbacks Pointer to indexing callbacks that the client6656 * implements.6657 *6658 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets6659 * passed in index_callbacks.6660 *6661 * \param index_options A bitmask of options that affects how indexing is6662 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.6663 *6664 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be6665 * reused after indexing is finished. Set to \c NULL if you do not require it.6666 *6667 * \returns 0 on success or if there were errors from which the compiler could6668 * recover. If there is a failure from which there is no recovery, returns6669 * a non-zero \c CXErrorCode.6670 *6671 * The rest of the parameters are the same as #clang_parseTranslationUnit.6672 */6673CINDEX_LINKAGE int clang_indexSourceFile(6674 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,6675 unsigned index_callbacks_size, unsigned index_options,6676 const char *source_filename, const char *const *command_line_args,6677 int num_command_line_args, struct CXUnsavedFile *unsaved_files,6678 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);6679 6680/**6681 * Same as clang_indexSourceFile but requires a full command line6682 * for \c command_line_args including argv[0]. This is useful if the standard6683 * library paths are relative to the binary.6684 */6685CINDEX_LINKAGE int clang_indexSourceFileFullArgv(6686 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,6687 unsigned index_callbacks_size, unsigned index_options,6688 const char *source_filename, const char *const *command_line_args,6689 int num_command_line_args, struct CXUnsavedFile *unsaved_files,6690 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);6691 6692/**6693 * Index the given translation unit via callbacks implemented through6694 * #IndexerCallbacks.6695 *6696 * The order of callback invocations is not guaranteed to be the same as6697 * when indexing a source file. The high level order will be:6698 *6699 * -Preprocessor callbacks invocations6700 * -Declaration/reference callbacks invocations6701 * -Diagnostic callback invocations6702 *6703 * The parameters are the same as #clang_indexSourceFile.6704 *6705 * \returns If there is a failure from which there is no recovery, returns6706 * non-zero, otherwise returns 0.6707 */6708CINDEX_LINKAGE int clang_indexTranslationUnit(6709 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,6710 unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);6711 6712/**6713 * Retrieve the CXIdxFile, file, line, column, and offset represented by6714 * the given CXIdxLoc.6715 *6716 * If the location refers into a macro expansion, retrieves the6717 * location of the macro expansion and if it refers into a macro argument6718 * retrieves the location of the argument.6719 */6720CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,6721 CXIdxClientFile *indexFile,6722 CXFile *file, unsigned *line,6723 unsigned *column,6724 unsigned *offset);6725 6726/**6727 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.6728 */6729CINDEX_LINKAGE6730CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);6731 6732/**6733 * Visitor invoked for each field found by a traversal.6734 *6735 * This visitor function will be invoked for each field found by6736 * \c clang_Type_visitFields. Its first argument is the cursor being6737 * visited, its second argument is the client data provided to6738 * \c clang_Type_visitFields.6739 *6740 * The visitor should return one of the \c CXVisitorResult values6741 * to direct \c clang_Type_visitFields.6742 */6743typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,6744 CXClientData client_data);6745 6746/**6747 * Visit the fields of a particular type.6748 *6749 * This function visits all the direct fields of the given cursor,6750 * invoking the given \p visitor function with the cursors of each6751 * visited field. The traversal may be ended prematurely, if6752 * the visitor returns \c CXFieldVisit_Break.6753 *6754 * \param T the record type whose field may be visited.6755 *6756 * \param visitor the visitor function that will be invoked for each6757 * field of \p T.6758 *6759 * \param client_data pointer data supplied by the client, which will6760 * be passed to the visitor each time it is invoked.6761 *6762 * \returns a non-zero value if the traversal was terminated6763 * prematurely by the visitor returning \c CXFieldVisit_Break.6764 */6765CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,6766 CXClientData client_data);6767 6768/**6769 * Visit the base classes of a type.6770 *6771 * This function visits all the direct base classes of a the given cursor,6772 * invoking the given \p visitor function with the cursors of each6773 * visited base. The traversal may be ended prematurely, if6774 * the visitor returns \c CXFieldVisit_Break.6775 *6776 * \param T the record type whose field may be visited.6777 *6778 * \param visitor the visitor function that will be invoked for each6779 * field of \p T.6780 *6781 * \param client_data pointer data supplied by the client, which will6782 * be passed to the visitor each time it is invoked.6783 *6784 * \returns a non-zero value if the traversal was terminated6785 * prematurely by the visitor returning \c CXFieldVisit_Break.6786 */6787CINDEX_LINKAGE unsigned clang_visitCXXBaseClasses(CXType T,6788 CXFieldVisitor visitor,6789 CXClientData client_data);6790 6791/**6792 * Visit the class methods of a type.6793 *6794 * This function visits all the methods of the given cursor,6795 * invoking the given \p visitor function with the cursors of each6796 * visited method. The traversal may be ended prematurely, if6797 * the visitor returns \c CXFieldVisit_Break.6798 *6799 * \param T The record type whose field may be visited.6800 *6801 * \param visitor The visitor function that will be invoked for each6802 * field of \p T.6803 *6804 * \param client_data Pointer data supplied by the client, which will6805 * be passed to the visitor each time it is invoked.6806 *6807 * \returns A non-zero value if the traversal was terminated6808 * prematurely by the visitor returning \c CXFieldVisit_Break.6809 */6810CINDEX_LINKAGE unsigned clang_visitCXXMethods(CXType T, CXFieldVisitor visitor,6811 CXClientData client_data);6812 6813/**6814 * Describes the kind of binary operators.6815 */6816enum CXBinaryOperatorKind {6817 /** This value describes cursors which are not binary operators. */6818 CXBinaryOperator_Invalid = 0,6819 /** C++ Pointer - to - member operator. */6820 CXBinaryOperator_PtrMemD = 1,6821 /** C++ Pointer - to - member operator. */6822 CXBinaryOperator_PtrMemI = 2,6823 /** Multiplication operator. */6824 CXBinaryOperator_Mul = 3,6825 /** Division operator. */6826 CXBinaryOperator_Div = 4,6827 /** Remainder operator. */6828 CXBinaryOperator_Rem = 5,6829 /** Addition operator. */6830 CXBinaryOperator_Add = 6,6831 /** Subtraction operator. */6832 CXBinaryOperator_Sub = 7,6833 /** Bitwise shift left operator. */6834 CXBinaryOperator_Shl = 8,6835 /** Bitwise shift right operator. */6836 CXBinaryOperator_Shr = 9,6837 /** C++ three-way comparison (spaceship) operator. */6838 CXBinaryOperator_Cmp = 10,6839 /** Less than operator. */6840 CXBinaryOperator_LT = 11,6841 /** Greater than operator. */6842 CXBinaryOperator_GT = 12,6843 /** Less or equal operator. */6844 CXBinaryOperator_LE = 13,6845 /** Greater or equal operator. */6846 CXBinaryOperator_GE = 14,6847 /** Equal operator. */6848 CXBinaryOperator_EQ = 15,6849 /** Not equal operator. */6850 CXBinaryOperator_NE = 16,6851 /** Bitwise AND operator. */6852 CXBinaryOperator_And = 17,6853 /** Bitwise XOR operator. */6854 CXBinaryOperator_Xor = 18,6855 /** Bitwise OR operator. */6856 CXBinaryOperator_Or = 19,6857 /** Logical AND operator. */6858 CXBinaryOperator_LAnd = 20,6859 /** Logical OR operator. */6860 CXBinaryOperator_LOr = 21,6861 /** Assignment operator. */6862 CXBinaryOperator_Assign = 22,6863 /** Multiplication assignment operator. */6864 CXBinaryOperator_MulAssign = 23,6865 /** Division assignment operator. */6866 CXBinaryOperator_DivAssign = 24,6867 /** Remainder assignment operator. */6868 CXBinaryOperator_RemAssign = 25,6869 /** Addition assignment operator. */6870 CXBinaryOperator_AddAssign = 26,6871 /** Subtraction assignment operator. */6872 CXBinaryOperator_SubAssign = 27,6873 /** Bitwise shift left assignment operator. */6874 CXBinaryOperator_ShlAssign = 28,6875 /** Bitwise shift right assignment operator. */6876 CXBinaryOperator_ShrAssign = 29,6877 /** Bitwise AND assignment operator. */6878 CXBinaryOperator_AndAssign = 30,6879 /** Bitwise XOR assignment operator. */6880 CXBinaryOperator_XorAssign = 31,6881 /** Bitwise OR assignment operator. */6882 CXBinaryOperator_OrAssign = 32,6883 /** Comma operator. */6884 CXBinaryOperator_Comma = 33,6885 CXBinaryOperator_Last = CXBinaryOperator_Comma6886};6887 6888/**6889 * Retrieve the spelling of a given CXBinaryOperatorKind.6890 */6891CINDEX_LINKAGE CXString6892clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind);6893 6894/**6895 * Retrieve the binary operator kind of this cursor.6896 *6897 * If this cursor is not a binary operator then returns Invalid.6898 */6899CINDEX_LINKAGE enum CXBinaryOperatorKind6900clang_getCursorBinaryOperatorKind(CXCursor cursor);6901 6902/**6903 * Describes the kind of unary operators.6904 */6905enum CXUnaryOperatorKind {6906 /** This value describes cursors which are not unary operators. */6907 CXUnaryOperator_Invalid,6908 /** Postfix increment operator. */6909 CXUnaryOperator_PostInc,6910 /** Postfix decrement operator. */6911 CXUnaryOperator_PostDec,6912 /** Prefix increment operator. */6913 CXUnaryOperator_PreInc,6914 /** Prefix decrement operator. */6915 CXUnaryOperator_PreDec,6916 /** Address of operator. */6917 CXUnaryOperator_AddrOf,6918 /** Dereference operator. */6919 CXUnaryOperator_Deref,6920 /** Plus operator. */6921 CXUnaryOperator_Plus,6922 /** Minus operator. */6923 CXUnaryOperator_Minus,6924 /** Not operator. */6925 CXUnaryOperator_Not,6926 /** LNot operator. */6927 CXUnaryOperator_LNot,6928 /** "__real expr" operator. */6929 CXUnaryOperator_Real,6930 /** "__imag expr" operator. */6931 CXUnaryOperator_Imag,6932 /** __extension__ marker operator. */6933 CXUnaryOperator_Extension,6934 /** C++ co_await operator. */6935 CXUnaryOperator_Coawait6936};6937 6938/**6939 * Retrieve the spelling of a given CXUnaryOperatorKind.6940 */6941CINDEX_LINKAGE CXString6942clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind);6943 6944/**6945 * Retrieve the unary operator kind of this cursor.6946 *6947 * If this cursor is not a unary operator then returns Invalid.6948 */6949CINDEX_LINKAGE enum CXUnaryOperatorKind6950clang_getCursorUnaryOperatorKind(CXCursor cursor);6951 6952/**6953 * @}6954 */6955 6956/**6957 * @}6958 */6959 6960/* CINDEX_DEPRECATED - disabled to silence MSVC deprecation warnings */6961typedef void *CXRemapping;6962 6963CINDEX_DEPRECATED CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *);6964 6965CINDEX_DEPRECATED CINDEX_LINKAGE CXRemapping6966clang_getRemappingsFromFileList(const char **, unsigned);6967 6968CINDEX_DEPRECATED CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);6969 6970CINDEX_DEPRECATED CINDEX_LINKAGE void6971clang_remap_getFilenames(CXRemapping, unsigned, CXString *, CXString *);6972 6973CINDEX_DEPRECATED CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);6974 6975LLVM_CLANG_C_EXTERN_C_END6976 6977#endif6978