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_H
17#define LLVM_CLANG_C_INDEX_H
18
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 ABI
34 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
35 */
36#define CINDEX_VERSION_MAJOR 0
37#define CINDEX_VERSION_MINOR 64
38
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 "." #minor
45#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_feature
52#define __has_feature(feature) 0
53#endif
54
55LLVM_CLANG_C_EXTERN_C_BEGIN
56
57/** \defgroup CINDEX libclang: C Interface to Clang
58 *
59 * The C Interface to Clang provides a relatively small API that exposes
60 * facilities for parsing source code into an abstract syntax tree (AST),
61 * loading already-parsed ASTs, traversing the AST, associating
62 * physical source locations with elements within the AST, and other
63 * facilities that support Clang-based development tools.
64 *
65 * This C interface to Clang will never provide all of the information
66 * representation stored in Clang's C++ AST, nor should it: the intent is to
67 * 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" and
71 * functions are prefixed with "clang_".
72 *
73 * @{
74 */
75
76/**
77 * An "index" that consists of a set of translation units that would
78 * 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 translation
84 * 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 through
95 * 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 the
103 * system along with the current contents of that file that have not
104 * 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 indicates
127 * whether the use of this entity will result in a warning or error due to
128 * 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 is
137 * 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 be
146 * an error.
147 */
148 CXAvailability_NotAccessible
149};
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 negative
157 * 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 value
162 * will be negative if no minor version number was provided, e.g., for
163 * version '10'.
164 */
165 int Minor;
166 /**
167 * The subminor version number, e.g., the '3' in '10.7.3'. This value
168 * 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_NoThrow
229};
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" declaration
238 * is one that belongs in the translation unit itself and not in a precompiled
239 * header that was used by the translation unit. If zero, all declarations
240 * will be enumerated.
241 *
242 * Here is an example:
243 *
244 * \code
245 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
246 * 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 symbols
258 * // 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 * \endcode
266 *
267 * This process of creating the 'pch', loading it separately, and using it (via
268 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
269 * (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 created
278 * 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 process
285 * 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 = 2
296} 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 indexing
306 * 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 editing
315 * purposes should use background priority.
316 *
317 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
318 * #clang_annotateTokens
319 */
320 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
321
322 /**
323 * Used to indicate that all threads that libclang creates should use
324 * background priority.
325 */
326 CXGlobalOpt_ThreadBackgroundPriorityForAll =
327 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
328 CXGlobalOpt_ThreadBackgroundPriorityForEditing
329
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 adapting
337 * code each time a new member is added to it:
338 * \code
339 * CXIndexOptions Opts;
340 * memset(&Opts, 0, sizeof(Opts));
341 * Opts.Size = sizeof(CXIndexOptions);
342 * \endcode
343 * or explicitly initialize the first data member and zero-initialize the rest:
344 * \code
345 * CXIndexOptions Opts = { sizeof(CXIndexOptions) };
346 * \endcode
347 * or to prevent the -Wmissing-field-initializers warning for the above version:
348 * \code
349 * CXIndexOptions Opts{};
350 * Opts.Size = sizeof(CXIndexOptions);
351 * \endcode
352 */
353typedef struct CXIndexOptions {
354 /**
355 * The size of struct CXIndexOptions used for option versioning.
356 *
357 * Always initialize this member to sizeof(CXIndexOptions), or assign
358 * 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_ThreadBackgroundPriorityForIndexing
364 */
365 unsigned char ThreadBackgroundPriorityForIndexing;
366 /**
367 * A CXChoice enumerator that specifies the editing priority policy.
368 * \sa CXGlobalOpt_ThreadBackgroundPriorityForEditing
369 */
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 or
387 * empty, the default system temporary directory is used. These PCH files are
388 * 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 file
393 * 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 libclang
398 * 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 configure
407 * the additional options in CXIndexOptions.
408 *
409 * \returns The created index or null in case of error, such as an unsupported
410 * value of options->Size.
411 *
412 * For example:
413 * \code
414 * CXIndex createIndex(const char *ApplicationTemporaryPath) {
415 * const int ExcludeDeclarationsFromPCH = 1;
416 * const int DisplayDiagnostics = 1;
417 * CXIndex Idx;
418 * #if CINDEX_VERSION_MINOR >= 64
419 * 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 * #else
434 * (void)ApplicationTemporaryPath;
435 * #endif
436 * Idx = clang_createIndex(ExcludeDeclarationsFromPCH, DisplayDiagnostics);
437 * clang_CXIndex_setGlobalOptions(
438 * Idx, clang_CXIndex_getGlobalOptions(Idx) |
439 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
440 * return Idx;
441 * }
442 * \endcode
443 *
444 * \sa clang_createIndex()
445 */
446CINDEX_LINKAGE CXIndex
447clang_createIndexWithOptions(const CXIndexOptions *options);
448
449/**
450 * Sets general options associated with a CXIndex.
451 *
452 * This function is DEPRECATED. Set
453 * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
454 * CXIndexOptions::ThreadBackgroundPriorityForEditing and call
455 * clang_createIndexWithOptions() instead.
456 *
457 * For example:
458 * \code
459 * CXIndex idx = ...;
460 * clang_CXIndex_setGlobalOptions(idx,
461 * clang_CXIndex_getGlobalOptions(idx) |
462 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
463 * \endcode
464 *
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 after
473 * specifying the option policies via CXChoice enumerators.
474 *
475 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
476 * 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 and
484 * call clang_createIndexWithOptions() instead.
485 *
486 * The invocation emission path specifies a path which will contain log
487 * files for certain libclang invocations. A null value (default) implies that
488 * libclang invocations are not logged..
489 */
490CINDEX_LINKAGE void
491clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
492
493/**
494 * Determine whether the given header is guarded against
495 * multiple inclusions, either with the conventional
496 * \#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 unit
505 *
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 unit
518 *
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 of
524 * \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/column
531 * 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 offset
538 * 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 an
548 * 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 the
555 * preprocessor.
556 *
557 * The preprocessor will skip lines when they are surrounded by an
558 * 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 given
565 * 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 freed
576 * 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 a
583 * translation unit.
584 *
585 * \param Unit the translation unit to query.
586 */
587CINDEX_LINKAGE CXDiagnosticSet
588clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
589
590/**
591 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
592 *
593 * The routines in this group provide the ability to create and destroy
594 * translation units from files, either by parsing the contents of the files or
595 * 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 CXString
604clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
605
606/**
607 * Return the CXTranslationUnit for a given source file and the provided
608 * command line arguments one would pass to the compiler.
609 *
610 * Note: The 'source_filename' argument is optional. If the caller provides a
611 * NULL pointer, the name of the source file is expected to reside in the
612 * specified command line arguments.
613 *
614 * Note: When encountered in 'clang_command_line_args', the following options
615 * 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 be
623 * associated.
624 *
625 * \param source_filename The name of the source file to load, or NULL if the
626 * source file is included in \p clang_command_line_args.
627 *
628 * \param num_clang_command_line_args The number of command-line arguments in
629 * \p clang_command_line_args.
630 *
631 * \param clang_command_line_args The command-line arguments that would be
632 * 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 translation
634 * 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 \p
638 * unsaved_files.
639 *
640 * \param unsaved_files the files that have not yet been saved to disk
641 * but may be required for code completion, including the contents of
642 * those files. The contents and name of these files (as specified by
643 * CXUnsavedFile) are copied when necessary, so the client only needs to
644 * 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 returns
653 * the \c CXTranslationUnit instead of an error code. In case of an error this
654 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
655 * error codes.
656 */
657CINDEX_LINKAGE CXTranslationUnit
658clang_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 created
664 * \c CXTranslationUnit.
665 *
666 * \returns Zero on success, otherwise returns an error code.
667 */
668CINDEX_LINKAGE enum CXErrorCode
669clang_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 bitwise
676 * ORed together to specify which options should be used when
677 * constructing the translation unit.
678 */
679enum CXTranslationUnit_Flags {
680 /**
681 * Used to indicate that no special translation-unit options are
682 * 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 memory
691 * and time to parse, since the information contained in the record
692 * is usually not retained. However, it can be useful for
693 * applications that require more detailed information about the
694 * 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", semantic
702 * analysis that is typically performed at the end of the
703 * translation unit will be suppressed. For example, this suppresses
704 * the completion of tentative declarations in C and of
705 * instantiation of implicitly-instantiation function templates in
706 * C++. This option is typically used when parsing a header with the
707 * 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 an
713 * implicit precompiled header for the preamble.
714 *
715 * An implicit precompiled header is used as an optimization when a
716 * particular translation unit is likely to be reparsed many times
717 * when the sources aren't changing that often. In this case, an
718 * implicit precompiled header will be built containing all of the
719 * initial includes at the top of the main file (what we refer to as
720 * the "preamble" of the file). In subsequent parses, if the
721 * preamble or the files in it have not changed, \c
722 * clang_reparseTranslationUnit() will re-use the implicit
723 * precompiled header to improve parsing performance.
724 */
725 CXTranslationUnit_PrecompiledPreamble = 0x04,
726
727 /**
728 * Used to indicate that the translation unit should cache some
729 * code-completion results with each reparse of the source file.
730 *
731 * Caching of code-completion results is a performance optimization that
732 * introduces some overhead to reparsing but improves the performance of
733 * code-completion operations.
734 */
735 CXTranslationUnit_CacheCompletionResults = 0x08,
736
737 /**
738 * Used to indicate that the translation unit will be serialized with
739 * \c clang_saveTranslationUnit.
740 *
741 * This option is typically used when parsing a header with the intent of
742 * 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 while
750 * 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 while
756 * parsing.
757 *
758 * This option can be used to search for declarations/definitions while
759 * ignoring the usages.
760 */
761 CXTranslationUnit_SkipFunctionBodies = 0x40,
762
763 /**
764 * Used to indicate that brief documentation comments should be
765 * included into the set of code completions returned from this translation
766 * unit.
767 */
768 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
769
770 /**
771 * Used to indicate that the precompiled preamble should be created on
772 * the first parse. Otherwise it will be created on the first reparse. This
773 * trades runtime on the first parse (serializing the preamble takes time) for
774 * 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 common
783 * source for fatal errors are unresolvable include files. For the
784 * purposes of an IDE, this is undesirable behavior and as much information
785 * 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 to
796 * 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 from
816 * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
817 * the case where these warnings are not of interest, as for an IDE for
818 * 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 = 0x8000
826};
827
828/**
829 * Returns the set of flags that is suitable for parsing a translation
830 * 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 implicitly
835 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
836 * set contains an unspecified set of optimizations (e.g., the precompiled
837 * preamble) geared toward improving the performance of these routines. The
838 * 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 returns
844 * the \c CXTranslationUnit instead of an error code. In case of an error this
845 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
846 * 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 corresponding
856 * to that file.
857 *
858 * This routine is the main entry point for the Clang C API, providing the
859 * ability to parse a source file into a translation unit that can then be
860 * queried by other functions in the API. This routine accepts a set of
861 * command-line arguments so that the compilation can be configured in the same
862 * way that the compiler is configured on the command line.
863 *
864 * \param CIdx The index object with which the translation unit will be
865 * associated.
866 *
867 * \param source_filename The name of the source file to load, or NULL if the
868 * source file is included in \c command_line_args.
869 *
870 * \param command_line_args The command-line arguments that would be
871 * 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 translation
873 * 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 in
877 * \c command_line_args.
878 *
879 * \param unsaved_files the files that have not yet been saved to disk
880 * but may be required for parsing, including the contents of
881 * those files. The contents and name of these files (as specified by
882 * CXUnsavedFile) are copied when necessary, so the client only needs to
883 * guarantee their validity until the call to this function returns.
884 *
885 * \param num_unsaved_files the number of unsaved file entries in \p
886 * unsaved_files.
887 *
888 * \param options A bitmask of options that affects how the translation unit
889 * is managed but not its compilation. This should be a bitwise OR of the
890 * CXTranslationUnit_XXX flags.
891 *
892 * \param[out] out_TU A non-NULL pointer to store the created
893 * \c CXTranslationUnit, describing the parsed code and containing any
894 * 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 line
906 * for \c command_line_args including argv[0]. This is useful if the standard
907 * 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 bitwise
919 * ORed together to specify which options should be used when
920 * saving the translation unit.
921 */
922enum CXSaveTranslationUnit_Flags {
923 /**
924 * Used to indicate that no special saving options are needed.
925 */
926 CXSaveTranslationUnit_None = 0x0
927};
928
929/**
930 * Returns the set of flags that is suitable for saving a translation
931 * unit.
932 *
933 * The set of flags returned provide options for
934 * \c clang_saveTranslationUnit() by default. The returned flag
935 * set contains an unspecified set of options that save translation units with
936 * 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 to
942 * \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 save
952 * the file.
953 *
954 * This error typically indicates that file I/O failed when attempting to
955 * write the file.
956 */
957 CXSaveError_Unknown = 1,
958
959 /**
960 * Indicates that errors during translation prevented this attempt
961 * to save the translation unit.
962 *
963 * Errors that prevent the translation unit from being saved can be
964 * 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 somehow
970 * invalid (e.g., NULL).
971 */
972 CXSaveError_InvalidTU = 3
973};
974
975/**
976 * Saves a translation unit into a serialized representation of
977 * that translation unit on disk.
978 *
979 * Any translation unit that was parsed without error can be saved
980 * into a file. The translation unit can then be deserialized into a
981 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
982 * if it is an incomplete translation unit that corresponds to a
983 * header, used as a precompiled header when parsing other translation
984 * 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 unit
991 * is saved. This should be a bitwise OR of the
992 * CXSaveTranslationUnit_XXX flags.
993 *
994 * \returns A value that will match one of the enumerators of the CXSaveError
995 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
996 * 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 other
1006 * side does not support any other calls than \c clang_reparseTranslationUnit
1007 * 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 bitwise
1020 * ORed together to specify which options should be used when
1021 * reparsing the translation unit.
1022 */
1023enum CXReparse_Flags {
1024 /**
1025 * Used to indicate that no special reparsing options are needed.
1026 */
1027 CXReparse_None = 0x0
1028};
1029
1030/**
1031 * Returns the set of flags that is suitable for reparsing a translation
1032 * unit.
1033 *
1034 * The set of flags returned provide options for
1035 * \c clang_reparseTranslationUnit() by default. The returned flag
1036 * set contains an unspecified set of optimizations geared toward common uses
1037 * of reparsing. The set of optimizations enabled may change from one version
1038 * 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 originally
1046 * created the given translation unit, for example because those source files
1047 * have changed (either on disk or as passed via \p unsaved_files). The
1048 * source code will be reparsed with the same command-line options as it
1049 * was originally parsed.
1050 *
1051 * Reparsing a translation unit invalidates all cursors and source locations
1052 * that refer into that translation unit. This makes reparsing a translation
1053 * unit semantically equivalent to destroying the translation unit and then
1054 * creating a new translation unit with the same command-line arguments.
1055 * However, it may be more efficient to reparse a translation
1056 * unit using this routine.
1057 *
1058 * \param TU The translation unit whose contents will be re-parsed. The
1059 * translation unit must originally have been built with
1060 * \c clang_createTranslationUnitFromSourceFile().
1061 *
1062 * \param num_unsaved_files The number of unsaved file entries in \p
1063 * unsaved_files.
1064 *
1065 * \param unsaved_files The files that have not yet been saved to disk
1066 * but may be required for parsing, including the contents of
1067 * those files. The contents and name of these files (as specified by
1068 * CXUnsavedFile) are copied when necessary, so the client only needs to
1069 * 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 of
1073 * 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 be
1076 * returned if reparsing was impossible, such that the translation unit is
1077 * invalid. In such cases, the only valid call for \c TU is
1078 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1079 * routine are described by the \c CXErrorCode enum.
1080 */
1081CINDEX_LINKAGE int
1082clang_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_HeaderSearch
1110};
1111
1112/**
1113 * Returns the human-readable null-terminated C string that represents
1114 * the name of the memory category. This string should never be freed.
1115 */
1116CINDEX_LINKAGE
1117const 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 memory
1138 usage. */
1139 CXTUResourceUsageEntry *entries;
1140
1141} CXTUResourceUsage;
1142
1143/**
1144 * Return the memory usage of a translation unit. This object
1145 * should be released with clang_disposeCXTUResourceUsage().
1146 */
1147CINDEX_LINKAGE CXTUResourceUsage
1148clang_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 CXTargetInfo
1158clang_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 this
1190 * interface.
1191 *
1192 * Unexposed declarations have the same operations as any other kind
1193 * of declaration; one can extract their location information,
1194 * spelling, find their definitions, etc. However, the specific kind
1195 * 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 a
1208 * 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 not
1290 * declared. For example, given:
1291 *
1292 * \code
1293 * typedef unsigned size_type;
1294 * size_type size;
1295 * \endcode
1296 *
1297 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1298 * while the type of the variable "size" is referenced. The cursor
1299 * 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, template
1305 * 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 in
1314 * 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 the
1321 * goto statement in the following example:
1322 *
1323 * \code
1324 * start_over:
1325 * ++counter;
1326 *
1327 * goto start_over;
1328 * \endcode
1329 *
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 templates
1336 * that has not yet been resolved to a specific function or function template.
1337 *
1338 * An overloaded declaration reference cursor occurs in C++ templates where
1339 * a dependent name refers to a function. For example:
1340 *
1341 * \code
1342 * 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 * \endcode
1358 *
1359 * Here, the identifier "swap" is associated with an overloaded declaration
1360 * reference. In the template definition, "swap" refers to either of the two
1361 * "swap" functions declared above, so both results will be available. At
1362 * instantiation time, "swap" may also refer to other functions found via
1363 * argument-dependent lookup (e.g., the "swap" function at the end of the
1364 * example).
1365 *
1366 * The functions \c clang_getNumOverloadedDecls() and
1367 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1368 * referenced by this cursor.
1369 */
1370 CXCursor_OverloadedDeclRef = 49,
1371
1372 /**
1373 * A reference to a variable that occurs in some non-expression
1374 * 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 this
1393 * interface.
1394 *
1395 * Unexposed expressions have the same operations as any other kind
1396 * of expression; one can extract their location information,
1397 * spelling, children, etc. However, the specific kind of the
1398 * expression is not reported.
1399 */
1400 CXCursor_UnexposedExpr = 100,
1401
1402 /**
1403 * An expression that refers to some value declaration, such
1404 * 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-C
1418 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 and
1451 * 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" or
1460 * "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 null
1500 * pointer constant that has integral type (e.g., int or long) and is the same
1501 * size and alignment as a pointer.
1502 *
1503 * The __null extension is typically only used by system headers, which define
1504 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1505 * 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 * \code
1530 * x = int(0.5);
1531 * \endcode
1532 */
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. When
1554 * 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 between
1589 * Objective-C pointers and C pointers, transferring ownership in the process.
1590 *
1591 * \code
1592 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
1593 * \endcode
1594 */
1595 CXCursor_ObjCBridgedCastExpr = 141,
1596
1597 /** Represents a C++0x pack expansion that produces a sequence of
1598 * expressions.
1599 *
1600 * A pack expansion expression contains a pattern (which itself is an
1601 * expression) followed by an ellipsis. For example:
1602 *
1603 * \code
1604 * template<typename F, typename ...Types>
1605 * void forward(F f, Types &&...args) {
1606 * f(static_cast<Types&&>(args)...);
1607 * }
1608 * \endcode
1609 */
1610 CXCursor_PackExpansionExpr = 142,
1611
1612 /** Represents an expression that computes the length of a parameter
1613 * pack.
1614 *
1615 * \code
1616 * template<typename ...Types>
1617 * struct count {
1618 * static const unsigned value = sizeof...(Types);
1619 * };
1620 * \endcode
1621 */
1622 CXCursor_SizeOfPackExpr = 143,
1623
1624 /* Represents a C++ lambda expression that produces a local function
1625 * object.
1626 *
1627 * \code
1628 * 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 * \endcode
1635 */
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 literal
1657 */
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 aggregate
1685 * 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 this
1700 * interface.
1701 *
1702 * Unexposed statements have the same operations as any other kind of
1703 * statement; one can extract their location information, spelling,
1704 * children, etc. However, the specific kind of the statement is not
1705 * 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 in
1712 * the following example:
1713 *
1714 * \code
1715 * start_over:
1716 * ++counter;
1717 * \endcode
1718 *
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. function
1725 * 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 statement
1738 */
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 and
1845 * 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 /** OpenACC Compute Construct.
2166 */
2167 CXCursor_OpenACCComputeConstruct = 320,
2168
2169 /** OpenACC Loop Construct.
2170 */
2171 CXCursor_OpenACCLoopConstruct = 321,
2172
2173 /** OpenACC Combined Constructs.
2174 */
2175 CXCursor_OpenACCCombinedConstruct = 322,
2176
2177 /** OpenACC data Construct.
2178 */
2179 CXCursor_OpenACCDataConstruct = 323,
2180
2181 /** OpenACC enter data Construct.
2182 */
2183 CXCursor_OpenACCEnterDataConstruct = 324,
2184
2185 /** OpenACC exit data Construct.
2186 */
2187 CXCursor_OpenACCExitDataConstruct = 325,
2188
2189 /** OpenACC host_data Construct.
2190 */
2191 CXCursor_OpenACCHostDataConstruct = 326,
2192
2193 /** OpenACC wait Construct.
2194 */
2195 CXCursor_OpenACCWaitConstruct = 327,
2196
2197 /** OpenACC init Construct.
2198 */
2199 CXCursor_OpenACCInitConstruct = 328,
2200
2201 /** OpenACC shutdown Construct.
2202 */
2203 CXCursor_OpenACCShutdownConstruct = 329,
2204
2205 /** OpenACC set Construct.
2206 */
2207 CXCursor_OpenACCSetConstruct = 330,
2208
2209 /** OpenACC update Construct.
2210 */
2211 CXCursor_OpenACCUpdateConstruct = 331,
2212
2213 /** OpenACC atomic Construct.
2214 */
2215 CXCursor_OpenACCAtomicConstruct = 332,
2216
2217 /** OpenACC cache Construct.
2218 */
2219 CXCursor_OpenACCCacheConstruct = 333,
2220
2221 CXCursor_LastStmt = CXCursor_OpenACCCacheConstruct,
2222
2223 /**
2224 * Cursor that represents the translation unit itself.
2225 *
2226 * The translation unit cursor exists primarily to act as the root
2227 * cursor for traversing the contents of a translation unit.
2228 */
2229 CXCursor_TranslationUnit = 350,
2230
2231 /* Attributes */
2232 CXCursor_FirstAttr = 400,
2233 /**
2234 * An attribute whose specific kind is not exposed via this
2235 * interface.
2236 */
2237 CXCursor_UnexposedAttr = 400,
2238
2239 CXCursor_IBActionAttr = 401,
2240 CXCursor_IBOutletAttr = 402,
2241 CXCursor_IBOutletCollectionAttr = 403,
2242 CXCursor_CXXFinalAttr = 404,
2243 CXCursor_CXXOverrideAttr = 405,
2244 CXCursor_AnnotateAttr = 406,
2245 CXCursor_AsmLabelAttr = 407,
2246 CXCursor_PackedAttr = 408,
2247 CXCursor_PureAttr = 409,
2248 CXCursor_ConstAttr = 410,
2249 CXCursor_NoDuplicateAttr = 411,
2250 CXCursor_CUDAConstantAttr = 412,
2251 CXCursor_CUDADeviceAttr = 413,
2252 CXCursor_CUDAGlobalAttr = 414,
2253 CXCursor_CUDAHostAttr = 415,
2254 CXCursor_CUDASharedAttr = 416,
2255 CXCursor_VisibilityAttr = 417,
2256 CXCursor_DLLExport = 418,
2257 CXCursor_DLLImport = 419,
2258 CXCursor_NSReturnsRetained = 420,
2259 CXCursor_NSReturnsNotRetained = 421,
2260 CXCursor_NSReturnsAutoreleased = 422,
2261 CXCursor_NSConsumesSelf = 423,
2262 CXCursor_NSConsumed = 424,
2263 CXCursor_ObjCException = 425,
2264 CXCursor_ObjCNSObject = 426,
2265 CXCursor_ObjCIndependentClass = 427,
2266 CXCursor_ObjCPreciseLifetime = 428,
2267 CXCursor_ObjCReturnsInnerPointer = 429,
2268 CXCursor_ObjCRequiresSuper = 430,
2269 CXCursor_ObjCRootClass = 431,
2270 CXCursor_ObjCSubclassingRestricted = 432,
2271 CXCursor_ObjCExplicitProtocolImpl = 433,
2272 CXCursor_ObjCDesignatedInitializer = 434,
2273 CXCursor_ObjCRuntimeVisible = 435,
2274 CXCursor_ObjCBoxable = 436,
2275 CXCursor_FlagEnum = 437,
2276 CXCursor_ConvergentAttr = 438,
2277 CXCursor_WarnUnusedAttr = 439,
2278 CXCursor_WarnUnusedResultAttr = 440,
2279 CXCursor_AlignedAttr = 441,
2280 CXCursor_LastAttr = CXCursor_AlignedAttr,
2281
2282 /* Preprocessing */
2283 CXCursor_PreprocessingDirective = 500,
2284 CXCursor_MacroDefinition = 501,
2285 CXCursor_MacroExpansion = 502,
2286 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
2287 CXCursor_InclusionDirective = 503,
2288 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
2289 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2290
2291 /* Extra Declarations */
2292 /**
2293 * A module import declaration.
2294 */
2295 CXCursor_ModuleImportDecl = 600,
2296 CXCursor_TypeAliasTemplateDecl = 601,
2297 /**
2298 * A static_assert or _Static_assert node
2299 */
2300 CXCursor_StaticAssert = 602,
2301 /**
2302 * a friend declaration.
2303 */
2304 CXCursor_FriendDecl = 603,
2305 /**
2306 * a concept declaration.
2307 */
2308 CXCursor_ConceptDecl = 604,
2309
2310 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2311 CXCursor_LastExtraDecl = CXCursor_ConceptDecl,
2312
2313 /**
2314 * A code completion overload candidate.
2315 */
2316 CXCursor_OverloadCandidate = 700
2317};
2318
2319/**
2320 * A cursor representing some element in the abstract syntax tree for
2321 * a translation unit.
2322 *
2323 * The cursor abstraction unifies the different kinds of entities in a
2324 * program--declaration, statements, expressions, references to declarations,
2325 * etc.--under a single "cursor" abstraction with a common set of operations.
2326 * Common operation for a cursor include: getting the physical location in
2327 * a source file where the cursor points, getting the name associated with a
2328 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2329 *
2330 * Cursors can be produced in two specific ways.
2331 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2332 * from which one can use clang_visitChildren() to explore the rest of the
2333 * translation unit. clang_getCursor() maps from a physical source location
2334 * to the entity that resides at that location, allowing one to map from the
2335 * source code into the AST.
2336 */
2337typedef struct {
2338 enum CXCursorKind kind;
2339 int xdata;
2340 const void *data[3];
2341} CXCursor;
2342
2343/**
2344 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2345 *
2346 * @{
2347 */
2348
2349/**
2350 * Retrieve the NULL cursor, which represents no entity.
2351 */
2352CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2353
2354/**
2355 * Retrieve the cursor that represents the given translation unit.
2356 *
2357 * The translation unit cursor can be used to start traversing the
2358 * various declarations within the given translation unit.
2359 */
2360CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2361
2362/**
2363 * Determine whether two cursors are equivalent.
2364 */
2365CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2366
2367/**
2368 * Returns non-zero if \p cursor is null.
2369 */
2370CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2371
2372/**
2373 * Compute a hash value for the given cursor.
2374 */
2375CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2376
2377/**
2378 * Retrieve the kind of the given cursor.
2379 */
2380CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2381
2382/**
2383 * Determine whether the given cursor kind represents a declaration.
2384 */
2385CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2386
2387/**
2388 * Determine whether the given declaration is invalid.
2389 *
2390 * A declaration is invalid if it could not be parsed successfully.
2391 *
2392 * \returns non-zero if the cursor represents a declaration and it is
2393 * invalid, otherwise NULL.
2394 */
2395CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2396
2397/**
2398 * Determine whether the given cursor kind represents a simple
2399 * reference.
2400 *
2401 * Note that other kinds of cursors (such as expressions) can also refer to
2402 * other cursors. Use clang_getCursorReferenced() to determine whether a
2403 * particular cursor refers to another entity.
2404 */
2405CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2406
2407/**
2408 * Determine whether the given cursor kind represents an expression.
2409 */
2410CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2411
2412/**
2413 * Determine whether the given cursor kind represents a statement.
2414 */
2415CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2416
2417/**
2418 * Determine whether the given cursor kind represents an attribute.
2419 */
2420CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2421
2422/**
2423 * Determine whether the given cursor has any attributes.
2424 */
2425CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2426
2427/**
2428 * Determine whether the given cursor kind represents an invalid
2429 * cursor.
2430 */
2431CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2432
2433/**
2434 * Determine whether the given cursor kind represents a translation
2435 * unit.
2436 */
2437CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2438
2439/***
2440 * Determine whether the given cursor represents a preprocessing
2441 * element, such as a preprocessor directive or macro instantiation.
2442 */
2443CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2444
2445/***
2446 * Determine whether the given cursor represents a currently
2447 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2448 */
2449CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2450
2451/**
2452 * Describe the linkage of the entity referred to by a cursor.
2453 */
2454enum CXLinkageKind {
2455 /** This value indicates that no linkage information is available
2456 * for a provided CXCursor. */
2457 CXLinkage_Invalid,
2458 /**
2459 * This is the linkage for variables, parameters, and so on that
2460 * have automatic storage. This covers normal (non-extern) local variables.
2461 */
2462 CXLinkage_NoLinkage,
2463 /** This is the linkage for static variables and static functions. */
2464 CXLinkage_Internal,
2465 /** This is the linkage for entities with external linkage that live
2466 * in C++ anonymous namespaces.*/
2467 CXLinkage_UniqueExternal,
2468 /** This is the linkage for entities with true, external linkage. */
2469 CXLinkage_External
2470};
2471
2472/**
2473 * Determine the linkage of the entity referred to by a given cursor.
2474 */
2475CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2476
2477enum CXVisibilityKind {
2478 /** This value indicates that no visibility information is available
2479 * for a provided CXCursor. */
2480 CXVisibility_Invalid,
2481
2482 /** Symbol not seen by the linker. */
2483 CXVisibility_Hidden,
2484 /** Symbol seen by the linker but resolves to a symbol inside this object. */
2485 CXVisibility_Protected,
2486 /** Symbol seen by the linker and acts like a normal symbol. */
2487 CXVisibility_Default
2488};
2489
2490/**
2491 * Describe the visibility of the entity referred to by a cursor.
2492 *
2493 * This returns the default visibility if not explicitly specified by
2494 * a visibility attribute. The default visibility may be changed by
2495 * commandline arguments.
2496 *
2497 * \param cursor The cursor to query.
2498 *
2499 * \returns The visibility of the cursor.
2500 */
2501CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2502
2503/**
2504 * Determine the availability of the entity that this cursor refers to,
2505 * taking the current target platform into account.
2506 *
2507 * \param cursor The cursor to query.
2508 *
2509 * \returns The availability of the cursor.
2510 */
2511CINDEX_LINKAGE enum CXAvailabilityKind
2512clang_getCursorAvailability(CXCursor cursor);
2513
2514/**
2515 * Describes the availability of a given entity on a particular platform, e.g.,
2516 * a particular class might only be available on Mac OS 10.7 or newer.
2517 */
2518typedef struct CXPlatformAvailability {
2519 /**
2520 * A string that describes the platform for which this structure
2521 * provides availability information.
2522 *
2523 * Possible values are "ios" or "macos".
2524 */
2525 CXString Platform;
2526 /**
2527 * The version number in which this entity was introduced.
2528 */
2529 CXVersion Introduced;
2530 /**
2531 * The version number in which this entity was deprecated (but is
2532 * still available).
2533 */
2534 CXVersion Deprecated;
2535 /**
2536 * The version number in which this entity was obsoleted, and therefore
2537 * is no longer available.
2538 */
2539 CXVersion Obsoleted;
2540 /**
2541 * Whether the entity is unconditionally unavailable on this platform.
2542 */
2543 int Unavailable;
2544 /**
2545 * An optional message to provide to a user of this API, e.g., to
2546 * suggest replacement APIs.
2547 */
2548 CXString Message;
2549} CXPlatformAvailability;
2550
2551/**
2552 * Determine the availability of the entity that this cursor refers to
2553 * on any platforms for which availability information is known.
2554 *
2555 * \param cursor The cursor to query.
2556 *
2557 * \param always_deprecated If non-NULL, will be set to indicate whether the
2558 * entity is deprecated on all platforms.
2559 *
2560 * \param deprecated_message If non-NULL, will be set to the message text
2561 * provided along with the unconditional deprecation of this entity. The client
2562 * is responsible for deallocating this string.
2563 *
2564 * \param always_unavailable If non-NULL, will be set to indicate whether the
2565 * entity is unavailable on all platforms.
2566 *
2567 * \param unavailable_message If non-NULL, will be set to the message text
2568 * provided along with the unconditional unavailability of this entity. The
2569 * client is responsible for deallocating this string.
2570 *
2571 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2572 * that will be populated with platform availability information, up to either
2573 * the number of platforms for which availability information is available (as
2574 * returned by this function) or \c availability_size, whichever is smaller.
2575 *
2576 * \param availability_size The number of elements available in the
2577 * \c availability array.
2578 *
2579 * \returns The number of platforms (N) for which availability information is
2580 * available (which is unrelated to \c availability_size).
2581 *
2582 * Note that the client is responsible for calling
2583 * \c clang_disposeCXPlatformAvailability to free each of the
2584 * platform-availability structures returned. There are
2585 * \c min(N, availability_size) such structures.
2586 */
2587CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
2588 CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
2589 int *always_unavailable, CXString *unavailable_message,
2590 CXPlatformAvailability *availability, int availability_size);
2591
2592/**
2593 * Free the memory associated with a \c CXPlatformAvailability structure.
2594 */
2595CINDEX_LINKAGE void
2596clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2597
2598/**
2599 * If cursor refers to a variable declaration and it has initializer returns
2600 * cursor referring to the initializer otherwise return null cursor.
2601 */
2602CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);
2603
2604/**
2605 * If cursor refers to a variable declaration that has global storage returns 1.
2606 * If cursor refers to a variable declaration that doesn't have global storage
2607 * returns 0. Otherwise returns -1.
2608 */
2609CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);
2610
2611/**
2612 * If cursor refers to a variable declaration that has external storage
2613 * returns 1. If cursor refers to a variable declaration that doesn't have
2614 * external storage returns 0. Otherwise returns -1.
2615 */
2616CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);
2617
2618/**
2619 * Describe the "language" of the entity referred to by a cursor.
2620 */
2621enum CXLanguageKind {
2622 CXLanguage_Invalid = 0,
2623 CXLanguage_C,
2624 CXLanguage_ObjC,
2625 CXLanguage_CPlusPlus
2626};
2627
2628/**
2629 * Determine the "language" of the entity referred to by a given cursor.
2630 */
2631CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2632
2633/**
2634 * Describe the "thread-local storage (TLS) kind" of the declaration
2635 * referred to by a cursor.
2636 */
2637enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
2638
2639/**
2640 * Determine the "thread-local storage (TLS) kind" of the declaration
2641 * referred to by a cursor.
2642 */
2643CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2644
2645/**
2646 * Returns the translation unit that a cursor originated from.
2647 */
2648CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2649
2650/**
2651 * A fast container representing a set of CXCursors.
2652 */
2653typedef struct CXCursorSetImpl *CXCursorSet;
2654
2655/**
2656 * Creates an empty CXCursorSet.
2657 */
2658CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2659
2660/**
2661 * Disposes a CXCursorSet and releases its associated memory.
2662 */
2663CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2664
2665/**
2666 * Queries a CXCursorSet to see if it contains a specific CXCursor.
2667 *
2668 * \returns non-zero if the set contains the specified cursor.
2669 */
2670CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2671 CXCursor cursor);
2672
2673/**
2674 * Inserts a CXCursor into a CXCursorSet.
2675 *
2676 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2677 */
2678CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2679 CXCursor cursor);
2680
2681/**
2682 * Determine the semantic parent of the given cursor.
2683 *
2684 * The semantic parent of a cursor is the cursor that semantically contains
2685 * the given \p cursor. For many declarations, the lexical and semantic parents
2686 * are equivalent (the lexical parent is returned by
2687 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2688 * definitions are provided out-of-line. For example:
2689 *
2690 * \code
2691 * class C {
2692 * void f();
2693 * };
2694 *
2695 * void C::f() { }
2696 * \endcode
2697 *
2698 * In the out-of-line definition of \c C::f, the semantic parent is
2699 * the class \c C, of which this function is a member. The lexical parent is
2700 * the place where the declaration actually occurs in the source code; in this
2701 * case, the definition occurs in the translation unit. In general, the
2702 * lexical parent for a given entity can change without affecting the semantics
2703 * of the program, and the lexical parent of different declarations of the
2704 * same entity may be different. Changing the semantic parent of a declaration,
2705 * on the other hand, can have a major impact on semantics, and redeclarations
2706 * of a particular entity should all have the same semantic context.
2707 *
2708 * In the example above, both declarations of \c C::f have \c C as their
2709 * semantic context, while the lexical context of the first \c C::f is \c C
2710 * and the lexical context of the second \c C::f is the translation unit.
2711 *
2712 * For global declarations, the semantic parent is the translation unit.
2713 */
2714CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2715
2716/**
2717 * Determine the lexical parent of the given cursor.
2718 *
2719 * The lexical parent of a cursor is the cursor in which the given \p cursor
2720 * was actually written. For many declarations, the lexical and semantic parents
2721 * are equivalent (the semantic parent is returned by
2722 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2723 * definitions are provided out-of-line. For example:
2724 *
2725 * \code
2726 * class C {
2727 * void f();
2728 * };
2729 *
2730 * void C::f() { }
2731 * \endcode
2732 *
2733 * In the out-of-line definition of \c C::f, the semantic parent is
2734 * the class \c C, of which this function is a member. The lexical parent is
2735 * the place where the declaration actually occurs in the source code; in this
2736 * case, the definition occurs in the translation unit. In general, the
2737 * lexical parent for a given entity can change without affecting the semantics
2738 * of the program, and the lexical parent of different declarations of the
2739 * same entity may be different. Changing the semantic parent of a declaration,
2740 * on the other hand, can have a major impact on semantics, and redeclarations
2741 * of a particular entity should all have the same semantic context.
2742 *
2743 * In the example above, both declarations of \c C::f have \c C as their
2744 * semantic context, while the lexical context of the first \c C::f is \c C
2745 * and the lexical context of the second \c C::f is the translation unit.
2746 *
2747 * For declarations written in the global scope, the lexical parent is
2748 * the translation unit.
2749 */
2750CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2751
2752/**
2753 * Determine the set of methods that are overridden by the given
2754 * method.
2755 *
2756 * In both Objective-C and C++, a method (aka virtual member function,
2757 * in C++) can override a virtual method in a base class. For
2758 * Objective-C, a method is said to override any method in the class's
2759 * base class, its protocols, or its categories' protocols, that has the same
2760 * selector and is of the same kind (class or instance).
2761 * If no such method exists, the search continues to the class's superclass,
2762 * its protocols, and its categories, and so on. A method from an Objective-C
2763 * implementation is considered to override the same methods as its
2764 * corresponding method in the interface.
2765 *
2766 * For C++, a virtual member function overrides any virtual member
2767 * function with the same signature that occurs in its base
2768 * classes. With multiple inheritance, a virtual member function can
2769 * override several virtual member functions coming from different
2770 * base classes.
2771 *
2772 * In all cases, this function determines the immediate overridden
2773 * method, rather than all of the overridden methods. For example, if
2774 * a method is originally declared in a class A, then overridden in B
2775 * (which in inherits from A) and also in C (which inherited from B),
2776 * then the only overridden method returned from this function when
2777 * invoked on C's method will be B's method. The client may then
2778 * invoke this function again, given the previously-found overridden
2779 * methods, to map out the complete method-override set.
2780 *
2781 * \param cursor A cursor representing an Objective-C or C++
2782 * method. This routine will compute the set of methods that this
2783 * method overrides.
2784 *
2785 * \param overridden A pointer whose pointee will be replaced with a
2786 * pointer to an array of cursors, representing the set of overridden
2787 * methods. If there are no overridden methods, the pointee will be
2788 * set to NULL. The pointee must be freed via a call to
2789 * \c clang_disposeOverriddenCursors().
2790 *
2791 * \param num_overridden A pointer to the number of overridden
2792 * functions, will be set to the number of overridden functions in the
2793 * array pointed to by \p overridden.
2794 */
2795CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2796 CXCursor **overridden,
2797 unsigned *num_overridden);
2798
2799/**
2800 * Free the set of overridden cursors returned by \c
2801 * clang_getOverriddenCursors().
2802 */
2803CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2804
2805/**
2806 * Retrieve the file that is included by the given inclusion directive
2807 * cursor.
2808 */
2809CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2810
2811/**
2812 * @}
2813 */
2814
2815/**
2816 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2817 *
2818 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2819 * routines help map between cursors and the physical locations where the
2820 * described entities occur in the source code. The mapping is provided in
2821 * both directions, so one can map from source code to the AST and back.
2822 *
2823 * @{
2824 */
2825
2826/**
2827 * Map a source location to the cursor that describes the entity at that
2828 * location in the source code.
2829 *
2830 * clang_getCursor() maps an arbitrary source location within a translation
2831 * unit down to the most specific cursor that describes the entity at that
2832 * location. For example, given an expression \c x + y, invoking
2833 * clang_getCursor() with a source location pointing to "x" will return the
2834 * cursor for "x"; similarly for "y". If the cursor points anywhere between
2835 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2836 * will return a cursor referring to the "+" expression.
2837 *
2838 * \returns a cursor representing the entity at the given source location, or
2839 * a NULL cursor if no such entity can be found.
2840 */
2841CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2842
2843/**
2844 * Retrieve the physical location of the source constructor referenced
2845 * by the given cursor.
2846 *
2847 * The location of a declaration is typically the location of the name of that
2848 * declaration, where the name of that declaration would occur if it is
2849 * unnamed, or some keyword that introduces that particular declaration.
2850 * The location of a reference is where that reference occurs within the
2851 * source code.
2852 */
2853CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2854
2855/**
2856 * Retrieve the physical extent of the source construct referenced by
2857 * the given cursor.
2858 *
2859 * The extent of a cursor starts with the file/line/column pointing at the
2860 * first character within the source construct that the cursor refers to and
2861 * ends with the last character within that source construct. For a
2862 * declaration, the extent covers the declaration itself. For a reference,
2863 * the extent covers the location of the reference (e.g., where the referenced
2864 * entity was actually used).
2865 */
2866CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
2867
2868/**
2869 * @}
2870 */
2871
2872/**
2873 * \defgroup CINDEX_TYPES Type information for CXCursors
2874 *
2875 * @{
2876 */
2877
2878/**
2879 * Describes the kind of type
2880 */
2881enum CXTypeKind {
2882 /**
2883 * Represents an invalid type (e.g., where no type is available).
2884 */
2885 CXType_Invalid = 0,
2886
2887 /**
2888 * A type whose specific kind is not exposed via this
2889 * interface.
2890 */
2891 CXType_Unexposed = 1,
2892
2893 /* Builtin types */
2894 CXType_Void = 2,
2895 CXType_Bool = 3,
2896 CXType_Char_U = 4,
2897 CXType_UChar = 5,
2898 CXType_Char16 = 6,
2899 CXType_Char32 = 7,
2900 CXType_UShort = 8,
2901 CXType_UInt = 9,
2902 CXType_ULong = 10,
2903 CXType_ULongLong = 11,
2904 CXType_UInt128 = 12,
2905 CXType_Char_S = 13,
2906 CXType_SChar = 14,
2907 CXType_WChar = 15,
2908 CXType_Short = 16,
2909 CXType_Int = 17,
2910 CXType_Long = 18,
2911 CXType_LongLong = 19,
2912 CXType_Int128 = 20,
2913 CXType_Float = 21,
2914 CXType_Double = 22,
2915 CXType_LongDouble = 23,
2916 CXType_NullPtr = 24,
2917 CXType_Overload = 25,
2918 CXType_Dependent = 26,
2919 CXType_ObjCId = 27,
2920 CXType_ObjCClass = 28,
2921 CXType_ObjCSel = 29,
2922 CXType_Float128 = 30,
2923 CXType_Half = 31,
2924 CXType_Float16 = 32,
2925 CXType_ShortAccum = 33,
2926 CXType_Accum = 34,
2927 CXType_LongAccum = 35,
2928 CXType_UShortAccum = 36,
2929 CXType_UAccum = 37,
2930 CXType_ULongAccum = 38,
2931 CXType_BFloat16 = 39,
2932 CXType_Ibm128 = 40,
2933 CXType_FirstBuiltin = CXType_Void,
2934 CXType_LastBuiltin = CXType_Ibm128,
2935
2936 CXType_Complex = 100,
2937 CXType_Pointer = 101,
2938 CXType_BlockPointer = 102,
2939 CXType_LValueReference = 103,
2940 CXType_RValueReference = 104,
2941 CXType_Record = 105,
2942 CXType_Enum = 106,
2943 CXType_Typedef = 107,
2944 CXType_ObjCInterface = 108,
2945 CXType_ObjCObjectPointer = 109,
2946 CXType_FunctionNoProto = 110,
2947 CXType_FunctionProto = 111,
2948 CXType_ConstantArray = 112,
2949 CXType_Vector = 113,
2950 CXType_IncompleteArray = 114,
2951 CXType_VariableArray = 115,
2952 CXType_DependentSizedArray = 116,
2953 CXType_MemberPointer = 117,
2954 CXType_Auto = 118,
2955
2956 /**
2957 * Represents a type that was referred to using an elaborated type keyword.
2958 *
2959 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
2960 */
2961 CXType_Elaborated = 119,
2962
2963 /* OpenCL PipeType. */
2964 CXType_Pipe = 120,
2965
2966 /* OpenCL builtin types. */
2967 CXType_OCLImage1dRO = 121,
2968 CXType_OCLImage1dArrayRO = 122,
2969 CXType_OCLImage1dBufferRO = 123,
2970 CXType_OCLImage2dRO = 124,
2971 CXType_OCLImage2dArrayRO = 125,
2972 CXType_OCLImage2dDepthRO = 126,
2973 CXType_OCLImage2dArrayDepthRO = 127,
2974 CXType_OCLImage2dMSAARO = 128,
2975 CXType_OCLImage2dArrayMSAARO = 129,
2976 CXType_OCLImage2dMSAADepthRO = 130,
2977 CXType_OCLImage2dArrayMSAADepthRO = 131,
2978 CXType_OCLImage3dRO = 132,
2979 CXType_OCLImage1dWO = 133,
2980 CXType_OCLImage1dArrayWO = 134,
2981 CXType_OCLImage1dBufferWO = 135,
2982 CXType_OCLImage2dWO = 136,
2983 CXType_OCLImage2dArrayWO = 137,
2984 CXType_OCLImage2dDepthWO = 138,
2985 CXType_OCLImage2dArrayDepthWO = 139,
2986 CXType_OCLImage2dMSAAWO = 140,
2987 CXType_OCLImage2dArrayMSAAWO = 141,
2988 CXType_OCLImage2dMSAADepthWO = 142,
2989 CXType_OCLImage2dArrayMSAADepthWO = 143,
2990 CXType_OCLImage3dWO = 144,
2991 CXType_OCLImage1dRW = 145,
2992 CXType_OCLImage1dArrayRW = 146,
2993 CXType_OCLImage1dBufferRW = 147,
2994 CXType_OCLImage2dRW = 148,
2995 CXType_OCLImage2dArrayRW = 149,
2996 CXType_OCLImage2dDepthRW = 150,
2997 CXType_OCLImage2dArrayDepthRW = 151,
2998 CXType_OCLImage2dMSAARW = 152,
2999 CXType_OCLImage2dArrayMSAARW = 153,
3000 CXType_OCLImage2dMSAADepthRW = 154,
3001 CXType_OCLImage2dArrayMSAADepthRW = 155,
3002 CXType_OCLImage3dRW = 156,
3003 CXType_OCLSampler = 157,
3004 CXType_OCLEvent = 158,
3005 CXType_OCLQueue = 159,
3006 CXType_OCLReserveID = 160,
3007
3008 CXType_ObjCObject = 161,
3009 CXType_ObjCTypeParam = 162,
3010 CXType_Attributed = 163,
3011
3012 CXType_OCLIntelSubgroupAVCMcePayload = 164,
3013 CXType_OCLIntelSubgroupAVCImePayload = 165,
3014 CXType_OCLIntelSubgroupAVCRefPayload = 166,
3015 CXType_OCLIntelSubgroupAVCSicPayload = 167,
3016 CXType_OCLIntelSubgroupAVCMceResult = 168,
3017 CXType_OCLIntelSubgroupAVCImeResult = 169,
3018 CXType_OCLIntelSubgroupAVCRefResult = 170,
3019 CXType_OCLIntelSubgroupAVCSicResult = 171,
3020 CXType_OCLIntelSubgroupAVCImeResultSingleReferenceStreamout = 172,
3021 CXType_OCLIntelSubgroupAVCImeResultDualReferenceStreamout = 173,
3022 CXType_OCLIntelSubgroupAVCImeSingleReferenceStreamin = 174,
3023 CXType_OCLIntelSubgroupAVCImeDualReferenceStreamin = 175,
3024
3025 /* Old aliases for AVC OpenCL extension types. */
3026 CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3027 CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3028 CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3029 CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
3030
3031 CXType_ExtVector = 176,
3032 CXType_Atomic = 177,
3033 CXType_BTFTagAttributed = 178,
3034
3035 /* HLSL Types */
3036 CXType_HLSLResource = 179,
3037 CXType_HLSLAttributedResource = 180,
3038 CXType_HLSLInlineSpirv = 181
3039};
3040
3041/**
3042 * Describes the calling convention of a function type
3043 */
3044enum CXCallingConv {
3045 CXCallingConv_Default = 0,
3046 CXCallingConv_C = 1,
3047 CXCallingConv_X86StdCall = 2,
3048 CXCallingConv_X86FastCall = 3,
3049 CXCallingConv_X86ThisCall = 4,
3050 CXCallingConv_X86Pascal = 5,
3051 CXCallingConv_AAPCS = 6,
3052 CXCallingConv_AAPCS_VFP = 7,
3053 CXCallingConv_X86RegCall = 8,
3054 CXCallingConv_IntelOclBicc = 9,
3055 CXCallingConv_Win64 = 10,
3056 /* Alias for compatibility with older versions of API. */
3057 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
3058 CXCallingConv_X86_64SysV = 11,
3059 CXCallingConv_X86VectorCall = 12,
3060 CXCallingConv_Swift = 13,
3061 CXCallingConv_PreserveMost = 14,
3062 CXCallingConv_PreserveAll = 15,
3063 CXCallingConv_AArch64VectorCall = 16,
3064 CXCallingConv_SwiftAsync = 17,
3065 CXCallingConv_AArch64SVEPCS = 18,
3066 CXCallingConv_M68kRTD = 19,
3067 CXCallingConv_PreserveNone = 20,
3068 CXCallingConv_RISCVVectorCall = 21,
3069 CXCallingConv_RISCVVLSCall_32 = 22,
3070 CXCallingConv_RISCVVLSCall_64 = 23,
3071 CXCallingConv_RISCVVLSCall_128 = 24,
3072 CXCallingConv_RISCVVLSCall_256 = 25,
3073 CXCallingConv_RISCVVLSCall_512 = 26,
3074 CXCallingConv_RISCVVLSCall_1024 = 27,
3075 CXCallingConv_RISCVVLSCall_2048 = 28,
3076 CXCallingConv_RISCVVLSCall_4096 = 29,
3077 CXCallingConv_RISCVVLSCall_8192 = 30,
3078 CXCallingConv_RISCVVLSCall_16384 = 31,
3079 CXCallingConv_RISCVVLSCall_32768 = 32,
3080 CXCallingConv_RISCVVLSCall_65536 = 33,
3081
3082 CXCallingConv_Invalid = 100,
3083 CXCallingConv_Unexposed = 200
3084};
3085
3086/**
3087 * The type of an element in the abstract syntax tree.
3088 *
3089 */
3090typedef struct {
3091 enum CXTypeKind kind;
3092 void *data[2];
3093} CXType;
3094
3095/**
3096 * Retrieve the type of a CXCursor (if any).
3097 */
3098CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3099
3100/**
3101 * Pretty-print the underlying type using the rules of the
3102 * language of the translation unit from which it came.
3103 *
3104 * If the type is invalid, an empty string is returned.
3105 */
3106CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3107
3108/**
3109 * Retrieve the underlying type of a typedef declaration.
3110 *
3111 * If the cursor does not reference a typedef declaration, an invalid type is
3112 * returned.
3113 */
3114CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3115
3116/**
3117 * Retrieve the integer type of an enum declaration.
3118 *
3119 * If the cursor does not reference an enum declaration, an invalid type is
3120 * returned.
3121 */
3122CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3123
3124/**
3125 * Retrieve the integer value of an enum constant declaration as a signed
3126 * long long.
3127 *
3128 * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3129 * returned. Since this is also potentially a valid constant value, the kind of
3130 * the cursor must be verified before calling this function.
3131 */
3132CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3133
3134/**
3135 * Retrieve the integer value of an enum constant declaration as an unsigned
3136 * long long.
3137 *
3138 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3139 * returned. Since this is also potentially a valid constant value, the kind of
3140 * the cursor must be verified before calling this function.
3141 */
3142CINDEX_LINKAGE unsigned long long
3143clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3144
3145/**
3146 * Returns non-zero if the cursor specifies a Record member that is a bit-field.
3147 */
3148CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3149
3150/**
3151 * Retrieve the bit width of a bit-field declaration as an integer.
3152 *
3153 * If the cursor does not reference a bit-field, or if the bit-field's width
3154 * expression cannot be evaluated, -1 is returned.
3155 *
3156 * For example:
3157 * \code
3158 * if (clang_Cursor_isBitField(Cursor)) {
3159 * int Width = clang_getFieldDeclBitWidth(Cursor);
3160 * if (Width != -1) {
3161 * // The bit-field width is not value-dependent.
3162 * }
3163 * }
3164 * \endcode
3165 */
3166CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3167
3168/**
3169 * Retrieve the number of non-variadic arguments associated with a given
3170 * cursor.
3171 *
3172 * The number of arguments can be determined for calls as well as for
3173 * declarations of functions or methods. For other cursors -1 is returned.
3174 */
3175CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3176
3177/**
3178 * Retrieve the argument cursor of a function or method.
3179 *
3180 * The argument cursor can be determined for calls as well as for declarations
3181 * of functions or methods. For other cursors and for invalid indices, an
3182 * invalid cursor is returned.
3183 */
3184CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3185
3186/**
3187 * Describes the kind of a template argument.
3188 *
3189 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3190 * element descriptions.
3191 */
3192enum CXTemplateArgumentKind {
3193 CXTemplateArgumentKind_Null,
3194 CXTemplateArgumentKind_Type,
3195 CXTemplateArgumentKind_Declaration,
3196 CXTemplateArgumentKind_NullPtr,
3197 CXTemplateArgumentKind_Integral,
3198 CXTemplateArgumentKind_Template,
3199 CXTemplateArgumentKind_TemplateExpansion,
3200 CXTemplateArgumentKind_Expression,
3201 CXTemplateArgumentKind_Pack,
3202 /* Indicates an error case, preventing the kind from being deduced. */
3203 CXTemplateArgumentKind_Invalid
3204};
3205
3206/**
3207 * Returns the number of template args of a function, struct, or class decl
3208 * representing a template specialization.
3209 *
3210 * If the argument cursor cannot be converted into a template function
3211 * declaration, -1 is returned.
3212 *
3213 * For example, for the following declaration and specialization:
3214 * template <typename T, int kInt, bool kBool>
3215 * void foo() { ... }
3216 *
3217 * template <>
3218 * void foo<float, -7, true>();
3219 *
3220 * The value 3 would be returned from this call.
3221 */
3222CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3223
3224/**
3225 * Retrieve the kind of the I'th template argument of the CXCursor C.
3226 *
3227 * If the argument CXCursor does not represent a FunctionDecl, StructDecl, or
3228 * ClassTemplatePartialSpecialization, an invalid template argument kind is
3229 * returned.
3230 *
3231 * For example, for the following declaration and specialization:
3232 * template <typename T, int kInt, bool kBool>
3233 * void foo() { ... }
3234 *
3235 * template <>
3236 * void foo<float, -7, true>();
3237 *
3238 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3239 * respectively.
3240 */
3241CINDEX_LINKAGE enum CXTemplateArgumentKind
3242clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
3243
3244/**
3245 * Retrieve a CXType representing the type of a TemplateArgument of a
3246 * function decl representing a template specialization.
3247 *
3248 * If the argument CXCursor does not represent a FunctionDecl, StructDecl,
3249 * ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument
3250 * has a kind of CXTemplateArgKind_Integral, an invalid type is returned.
3251 *
3252 * For example, for the following declaration and specialization:
3253 * template <typename T, int kInt, bool kBool>
3254 * void foo() { ... }
3255 *
3256 * template <>
3257 * void foo<float, -7, true>();
3258 *
3259 * If called with I = 0, "float", will be returned.
3260 * Invalid types will be returned for I == 1 or 2.
3261 */
3262CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3263 unsigned I);
3264
3265/**
3266 * Retrieve the value of an Integral TemplateArgument (of a function
3267 * decl representing a template specialization) as a signed long long.
3268 *
3269 * It is undefined to call this function on a CXCursor that does not represent a
3270 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization
3271 * whose I'th template argument is not an integral value.
3272 *
3273 * For example, for the following declaration and specialization:
3274 * template <typename T, int kInt, bool kBool>
3275 * void foo() { ... }
3276 *
3277 * template <>
3278 * void foo<float, -7, true>();
3279 *
3280 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3281 * For I == 0, this function's behavior is undefined.
3282 */
3283CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3284 unsigned I);
3285
3286/**
3287 * Retrieve the value of an Integral TemplateArgument (of a function
3288 * decl representing a template specialization) as an unsigned long long.
3289 *
3290 * It is undefined to call this function on a CXCursor that does not represent a
3291 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or
3292 * whose I'th template argument is not an integral value.
3293 *
3294 * For example, for the following declaration and specialization:
3295 * template <typename T, int kInt, bool kBool>
3296 * void foo() { ... }
3297 *
3298 * template <>
3299 * void foo<float, 2147483649, true>();
3300 *
3301 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3302 * For I == 0, this function's behavior is undefined.
3303 */
3304CINDEX_LINKAGE unsigned long long
3305clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
3306
3307/**
3308 * Determine whether two CXTypes represent the same type.
3309 *
3310 * \returns non-zero if the CXTypes represent the same type and
3311 * zero otherwise.
3312 */
3313CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3314
3315/**
3316 * Return the canonical type for a CXType.
3317 *
3318 * Clang's type system explicitly models typedefs and all the ways
3319 * a specific type can be represented. The canonical type is the underlying
3320 * type with all the "sugar" removed. For example, if 'T' is a typedef
3321 * for 'int', the canonical type for 'T' would be 'int'.
3322 */
3323CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3324
3325/**
3326 * Determine whether a CXType has the "const" qualifier set,
3327 * without looking through typedefs that may have added "const" at a
3328 * different level.
3329 */
3330CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3331
3332/**
3333 * Determine whether a CXCursor that is a macro, is
3334 * function like.
3335 */
3336CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3337
3338/**
3339 * Determine whether a CXCursor that is a macro, is a
3340 * builtin one.
3341 */
3342CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3343
3344/**
3345 * Determine whether a CXCursor that is a function declaration, is an
3346 * inline declaration.
3347 */
3348CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3349
3350/**
3351 * Determine whether a CXType has the "volatile" qualifier set,
3352 * without looking through typedefs that may have added "volatile" at
3353 * a different level.
3354 */
3355CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3356
3357/**
3358 * Determine whether a CXType has the "restrict" qualifier set,
3359 * without looking through typedefs that may have added "restrict" at a
3360 * different level.
3361 */
3362CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3363
3364/**
3365 * Returns the address space of the given type.
3366 */
3367CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3368
3369/**
3370 * Returns the typedef name of the given type.
3371 */
3372CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3373
3374/**
3375 * For pointer types, returns the type of the pointee.
3376 */
3377CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3378
3379/**
3380 * Retrieve the unqualified variant of the given type, removing as
3381 * little sugar as possible.
3382 *
3383 * For example, given the following series of typedefs:
3384 *
3385 * \code
3386 * typedef int Integer;
3387 * typedef const Integer CInteger;
3388 * typedef CInteger DifferenceType;
3389 * \endcode
3390 *
3391 * Executing \c clang_getUnqualifiedType() on a \c CXType that
3392 * represents \c DifferenceType, will desugar to a type representing
3393 * \c Integer, that has no qualifiers.
3394 *
3395 * And, executing \c clang_getUnqualifiedType() on the type of the
3396 * first argument of the following function declaration:
3397 *
3398 * \code
3399 * void foo(const int);
3400 * \endcode
3401 *
3402 * Will return a type representing \c int, removing the \c const
3403 * qualifier.
3404 *
3405 * Sugar over array types is not desugared.
3406 *
3407 * A type can be checked for qualifiers with \c
3408 * clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType()
3409 * and \c clang_isRestrictQualifiedType().
3410 *
3411 * A type that resulted from a call to \c clang_getUnqualifiedType
3412 * will return \c false for all of the above calls.
3413 */
3414CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT);
3415
3416/**
3417 * For reference types (e.g., "const int&"), returns the type that the
3418 * reference refers to (e.g "const int").
3419 *
3420 * Otherwise, returns the type itself.
3421 *
3422 * A type that has kind \c CXType_LValueReference or
3423 * \c CXType_RValueReference is a reference type.
3424 */
3425CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT);
3426
3427/**
3428 * Return the cursor for the declaration of the given type.
3429 */
3430CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3431
3432/**
3433 * Returns the Objective-C type encoding for the specified declaration.
3434 */
3435CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3436
3437/**
3438 * Returns the Objective-C type encoding for the specified CXType.
3439 */
3440CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3441
3442/**
3443 * Retrieve the spelling of a given CXTypeKind.
3444 */
3445CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3446
3447/**
3448 * Retrieve the calling convention associated with a function type.
3449 *
3450 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3451 */
3452CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3453
3454/**
3455 * Retrieve the return type associated with a function type.
3456 *
3457 * If a non-function type is passed in, an invalid type is returned.
3458 */
3459CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3460
3461/**
3462 * Retrieve the exception specification type associated with a function type.
3463 * This is a value of type CXCursor_ExceptionSpecificationKind.
3464 *
3465 * If a non-function type is passed in, an error code of -1 is returned.
3466 */
3467CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3468
3469/**
3470 * Retrieve the number of non-variadic parameters associated with a
3471 * function type.
3472 *
3473 * If a non-function type is passed in, -1 is returned.
3474 */
3475CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3476
3477/**
3478 * Retrieve the type of a parameter of a function type.
3479 *
3480 * If a non-function type is passed in or the function does not have enough
3481 * parameters, an invalid type is returned.
3482 */
3483CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3484
3485/**
3486 * Retrieves the base type of the ObjCObjectType.
3487 *
3488 * If the type is not an ObjC object, an invalid type is returned.
3489 */
3490CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3491
3492/**
3493 * Retrieve the number of protocol references associated with an ObjC object/id.
3494 *
3495 * If the type is not an ObjC object, 0 is returned.
3496 */
3497CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3498
3499/**
3500 * Retrieve the decl for a protocol reference for an ObjC object/id.
3501 *
3502 * If the type is not an ObjC object or there are not enough protocol
3503 * references, an invalid cursor is returned.
3504 */
3505CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3506
3507/**
3508 * Retrieve the number of type arguments associated with an ObjC object.
3509 *
3510 * If the type is not an ObjC object, 0 is returned.
3511 */
3512CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3513
3514/**
3515 * Retrieve a type argument associated with an ObjC object.
3516 *
3517 * If the type is not an ObjC or the index is not valid,
3518 * an invalid type is returned.
3519 */
3520CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3521
3522/**
3523 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3524 */
3525CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3526
3527/**
3528 * Retrieve the return type associated with a given cursor.
3529 *
3530 * This only returns a valid type if the cursor refers to a function or method.
3531 */
3532CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3533
3534/**
3535 * Retrieve the exception specification type associated with a given cursor.
3536 * This is a value of type CXCursor_ExceptionSpecificationKind.
3537 *
3538 * This only returns a valid result if the cursor refers to a function or
3539 * method.
3540 */
3541CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3542
3543/**
3544 * Return 1 if the CXType is a POD (plain old data) type, and 0
3545 * otherwise.
3546 */
3547CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3548
3549/**
3550 * Return the element type of an array, complex, or vector type.
3551 *
3552 * If a type is passed in that is not an array, complex, or vector type,
3553 * an invalid type is returned.
3554 */
3555CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3556
3557/**
3558 * Return the number of elements of an array or vector type.
3559 *
3560 * If a type is passed in that is not an array or vector type,
3561 * -1 is returned.
3562 */
3563CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3564
3565/**
3566 * Return the element type of an array type.
3567 *
3568 * If a non-array type is passed in, an invalid type is returned.
3569 */
3570CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3571
3572/**
3573 * Return the array size of a constant array.
3574 *
3575 * If a non-array type is passed in, -1 is returned.
3576 */
3577CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3578
3579/**
3580 * Retrieve the type named by the qualified-id.
3581 *
3582 * If a non-elaborated type is passed in, an invalid type is returned.
3583 */
3584CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3585
3586/**
3587 * Determine if a typedef is 'transparent' tag.
3588 *
3589 * A typedef is considered 'transparent' if it shares a name and spelling
3590 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3591 *
3592 * \returns non-zero if transparent and zero otherwise.
3593 */
3594CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3595
3596enum CXTypeNullabilityKind {
3597 /**
3598 * Values of this type can never be null.
3599 */
3600 CXTypeNullability_NonNull = 0,
3601 /**
3602 * Values of this type can be null.
3603 */
3604 CXTypeNullability_Nullable = 1,
3605 /**
3606 * Whether values of this type can be null is (explicitly)
3607 * unspecified. This captures a (fairly rare) case where we
3608 * can't conclude anything about the nullability of the type even
3609 * though it has been considered.
3610 */
3611 CXTypeNullability_Unspecified = 2,
3612 /**
3613 * Nullability is not applicable to this type.
3614 */
3615 CXTypeNullability_Invalid = 3,
3616
3617 /**
3618 * Generally behaves like Nullable, except when used in a block parameter that
3619 * was imported into a swift async method. There, swift will assume that the
3620 * parameter can get null even if no error occurred. _Nullable parameters are
3621 * assumed to only get null on error.
3622 */
3623 CXTypeNullability_NullableResult = 4
3624};
3625
3626/**
3627 * Retrieve the nullability kind of a pointer type.
3628 */
3629CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3630
3631/**
3632 * List the possible error codes for \c clang_Type_getSizeOf,
3633 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf,
3634 * \c clang_Cursor_getOffsetOf, and \c clang_getOffsetOfBase.
3635 *
3636 * A value of this enumeration type can be returned if the target type is not
3637 * a valid argument to sizeof, alignof or offsetof.
3638 */
3639enum CXTypeLayoutError {
3640 /**
3641 * Type is of kind CXType_Invalid.
3642 */
3643 CXTypeLayoutError_Invalid = -1,
3644 /**
3645 * The type is an incomplete Type.
3646 */
3647 CXTypeLayoutError_Incomplete = -2,
3648 /**
3649 * The type is a dependent Type.
3650 */
3651 CXTypeLayoutError_Dependent = -3,
3652 /**
3653 * The type is not a constant size type.
3654 */
3655 CXTypeLayoutError_NotConstantSize = -4,
3656 /**
3657 * The Field name is not valid for this record.
3658 */
3659 CXTypeLayoutError_InvalidFieldName = -5,
3660 /**
3661 * The type is undeduced.
3662 */
3663 CXTypeLayoutError_Undeduced = -6
3664};
3665
3666/**
3667 * Return the alignment of a type in bytes as per C++[expr.alignof]
3668 * standard.
3669 *
3670 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3671 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3672 * is returned.
3673 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3674 * returned.
3675 * If the type declaration is not a constant size type,
3676 * CXTypeLayoutError_NotConstantSize is returned.
3677 */
3678CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3679
3680/**
3681 * Return the class type of an member pointer type.
3682 *
3683 * If a non-member-pointer type is passed in, an invalid type is returned.
3684 */
3685CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3686
3687/**
3688 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3689 *
3690 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3691 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3692 * is returned.
3693 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3694 * returned.
3695 */
3696CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3697
3698/**
3699 * Return the offset of a field named S in a record of type T in bits
3700 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3701 *
3702 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3703 * is returned.
3704 * If the field's type declaration is an incomplete type,
3705 * CXTypeLayoutError_Incomplete is returned.
3706 * If the field's type declaration is a dependent type,
3707 * CXTypeLayoutError_Dependent is returned.
3708 * If the field's name S is not found,
3709 * CXTypeLayoutError_InvalidFieldName is returned.
3710 */
3711CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3712
3713/**
3714 * Return the type that was modified by this attributed type.
3715 *
3716 * If the type is not an attributed type, an invalid type is returned.
3717 */
3718CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3719
3720/**
3721 * Gets the type contained by this atomic type.
3722 *
3723 * If a non-atomic type is passed in, an invalid type is returned.
3724 */
3725CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
3726
3727/**
3728 * Return the offset of the field represented by the Cursor.
3729 *
3730 * If the cursor is not a field declaration, -1 is returned.
3731 * If the cursor semantic parent is not a record field declaration,
3732 * CXTypeLayoutError_Invalid is returned.
3733 * If the field's type declaration is an incomplete type,
3734 * CXTypeLayoutError_Incomplete is returned.
3735 * If the field's type declaration is a dependent type,
3736 * CXTypeLayoutError_Dependent is returned.
3737 * If the field's name S is not found,
3738 * CXTypeLayoutError_InvalidFieldName is returned.
3739 */
3740CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3741
3742/**
3743 * Determine whether the given cursor represents an anonymous
3744 * tag or namespace
3745 */
3746CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3747
3748/**
3749 * Determine whether the given cursor represents an anonymous record
3750 * declaration.
3751 */
3752CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
3753
3754/**
3755 * Determine whether the given cursor represents an inline namespace
3756 * declaration.
3757 */
3758CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
3759
3760enum CXRefQualifierKind {
3761 /** No ref-qualifier was provided. */
3762 CXRefQualifier_None = 0,
3763 /** An lvalue ref-qualifier was provided (\c &). */
3764 CXRefQualifier_LValue,
3765 /** An rvalue ref-qualifier was provided (\c &&). */
3766 CXRefQualifier_RValue
3767};
3768
3769/**
3770 * Returns the number of template arguments for given template
3771 * specialization, or -1 if type \c T is not a template specialization.
3772 */
3773CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3774
3775/**
3776 * Returns the type template argument of a template class specialization
3777 * at given index.
3778 *
3779 * This function only returns template type arguments and does not handle
3780 * template template arguments or variadic packs.
3781 */
3782CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
3783 unsigned i);
3784
3785/**
3786 * Retrieve the ref-qualifier kind of a function or method.
3787 *
3788 * The ref-qualifier is returned for C++ functions or methods. For other types
3789 * or non-C++ declarations, CXRefQualifier_None is returned.
3790 */
3791CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3792
3793/**
3794 * Returns 1 if the base class specified by the cursor with kind
3795 * CX_CXXBaseSpecifier is virtual.
3796 */
3797CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3798
3799/**
3800 * Returns the offset in bits of a CX_CXXBaseSpecifier relative to the parent
3801 * class.
3802 *
3803 * Returns a small negative number if the offset cannot be computed. See
3804 * CXTypeLayoutError for error codes.
3805 */
3806CINDEX_LINKAGE long long clang_getOffsetOfBase(CXCursor Parent, CXCursor Base);
3807
3808/**
3809 * Represents the C++ access control level to a base class for a
3810 * cursor with kind CX_CXXBaseSpecifier.
3811 */
3812enum CX_CXXAccessSpecifier {
3813 CX_CXXInvalidAccessSpecifier,
3814 CX_CXXPublic,
3815 CX_CXXProtected,
3816 CX_CXXPrivate
3817};
3818
3819/**
3820 * Returns the access control level for the referenced object.
3821 *
3822 * If the cursor refers to a C++ declaration, its access control level within
3823 * its parent scope is returned. Otherwise, if the cursor refers to a base
3824 * specifier or access specifier, the specifier itself is returned.
3825 */
3826CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3827
3828/**
3829 * Represents the storage classes as declared in the source. CX_SC_Invalid
3830 * was added for the case that the passed cursor in not a declaration.
3831 */
3832enum CX_StorageClass {
3833 CX_SC_Invalid,
3834 CX_SC_None,
3835 CX_SC_Extern,
3836 CX_SC_Static,
3837 CX_SC_PrivateExtern,
3838 CX_SC_OpenCLWorkGroupLocal,
3839 CX_SC_Auto,
3840 CX_SC_Register
3841};
3842
3843/**
3844 * Represents a specific kind of binary operator which can appear at a cursor.
3845 */
3846enum CX_BinaryOperatorKind {
3847 CX_BO_Invalid = 0,
3848 CX_BO_PtrMemD = 1,
3849 CX_BO_PtrMemI = 2,
3850 CX_BO_Mul = 3,
3851 CX_BO_Div = 4,
3852 CX_BO_Rem = 5,
3853 CX_BO_Add = 6,
3854 CX_BO_Sub = 7,
3855 CX_BO_Shl = 8,
3856 CX_BO_Shr = 9,
3857 CX_BO_Cmp = 10,
3858 CX_BO_LT = 11,
3859 CX_BO_GT = 12,
3860 CX_BO_LE = 13,
3861 CX_BO_GE = 14,
3862 CX_BO_EQ = 15,
3863 CX_BO_NE = 16,
3864 CX_BO_And = 17,
3865 CX_BO_Xor = 18,
3866 CX_BO_Or = 19,
3867 CX_BO_LAnd = 20,
3868 CX_BO_LOr = 21,
3869 CX_BO_Assign = 22,
3870 CX_BO_MulAssign = 23,
3871 CX_BO_DivAssign = 24,
3872 CX_BO_RemAssign = 25,
3873 CX_BO_AddAssign = 26,
3874 CX_BO_SubAssign = 27,
3875 CX_BO_ShlAssign = 28,
3876 CX_BO_ShrAssign = 29,
3877 CX_BO_AndAssign = 30,
3878 CX_BO_XorAssign = 31,
3879 CX_BO_OrAssign = 32,
3880 CX_BO_Comma = 33,
3881 CX_BO_LAST = CX_BO_Comma
3882};
3883
3884/**
3885 * \brief Returns the operator code for the binary operator.
3886 *
3887 * @deprecated: use clang_getCursorBinaryOperatorKind instead.
3888 */
3889CINDEX_LINKAGE enum CX_BinaryOperatorKind
3890clang_Cursor_getBinaryOpcode(CXCursor C);
3891
3892/**
3893 * \brief Returns a string containing the spelling of the binary operator.
3894 *
3895 * @deprecated: use clang_getBinaryOperatorKindSpelling instead
3896 */
3897CINDEX_LINKAGE CXString
3898clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op);
3899
3900/**
3901 * Returns the storage class for a function or variable declaration.
3902 *
3903 * If the passed in Cursor is not a function or variable declaration,
3904 * CX_SC_Invalid is returned else the storage class.
3905 */
3906CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
3907
3908/**
3909 * Determine the number of overloaded declarations referenced by a
3910 * \c CXCursor_OverloadedDeclRef cursor.
3911 *
3912 * \param cursor The cursor whose overloaded declarations are being queried.
3913 *
3914 * \returns The number of overloaded declarations referenced by \c cursor. If it
3915 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3916 */
3917CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3918
3919/**
3920 * Retrieve a cursor for one of the overloaded declarations referenced
3921 * by a \c CXCursor_OverloadedDeclRef cursor.
3922 *
3923 * \param cursor The cursor whose overloaded declarations are being queried.
3924 *
3925 * \param index The zero-based index into the set of overloaded declarations in
3926 * the cursor.
3927 *
3928 * \returns A cursor representing the declaration referenced by the given
3929 * \c cursor at the specified \c index. If the cursor does not have an
3930 * associated set of overloaded declarations, or if the index is out of bounds,
3931 * returns \c clang_getNullCursor();
3932 */
3933CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3934 unsigned index);
3935
3936/**
3937 * @}
3938 */
3939
3940/**
3941 * \defgroup CINDEX_ATTRIBUTES Information for attributes
3942 *
3943 * @{
3944 */
3945
3946/**
3947 * For cursors representing an iboutletcollection attribute,
3948 * this function returns the collection element type.
3949 *
3950 */
3951CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3952
3953/**
3954 * @}
3955 */
3956
3957/**
3958 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3959 *
3960 * These routines provide the ability to traverse the abstract syntax tree
3961 * using cursors.
3962 *
3963 * @{
3964 */
3965
3966/**
3967 * Describes how the traversal of the children of a particular
3968 * cursor should proceed after visiting a particular child cursor.
3969 *
3970 * A value of this enumeration type should be returned by each
3971 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3972 */
3973enum CXChildVisitResult {
3974 /**
3975 * Terminates the cursor traversal.
3976 */
3977 CXChildVisit_Break,
3978 /**
3979 * Continues the cursor traversal with the next sibling of
3980 * the cursor just visited, without visiting its children.
3981 */
3982 CXChildVisit_Continue,
3983 /**
3984 * Recursively traverse the children of this cursor, using
3985 * the same visitor and client data.
3986 */
3987 CXChildVisit_Recurse
3988};
3989
3990/**
3991 * Visitor invoked for each cursor found by a traversal.
3992 *
3993 * This visitor function will be invoked for each cursor found by
3994 * clang_visitCursorChildren(). Its first argument is the cursor being
3995 * visited, its second argument is the parent visitor for that cursor,
3996 * and its third argument is the client data provided to
3997 * clang_visitCursorChildren().
3998 *
3999 * The visitor should return one of the \c CXChildVisitResult values
4000 * to direct clang_visitCursorChildren().
4001 */
4002typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4003 CXCursor parent,
4004 CXClientData client_data);
4005
4006/**
4007 * Visit the children of a particular cursor.
4008 *
4009 * This function visits all the direct children of the given cursor,
4010 * invoking the given \p visitor function with the cursors of each
4011 * visited child. The traversal may be recursive, if the visitor returns
4012 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4013 * the visitor returns \c CXChildVisit_Break.
4014 *
4015 * \param parent the cursor whose child may be visited. All kinds of
4016 * cursors can be visited, including invalid cursors (which, by
4017 * definition, have no children).
4018 *
4019 * \param visitor the visitor function that will be invoked for each
4020 * child of \p parent.
4021 *
4022 * \param client_data pointer data supplied by the client, which will
4023 * be passed to the visitor each time it is invoked.
4024 *
4025 * \returns a non-zero value if the traversal was terminated
4026 * prematurely by the visitor returning \c CXChildVisit_Break.
4027 */
4028CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
4029 CXCursorVisitor visitor,
4030 CXClientData client_data);
4031/**
4032 * Visitor invoked for each cursor found by a traversal.
4033 *
4034 * This visitor block will be invoked for each cursor found by
4035 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4036 * visited, its second argument is the parent visitor for that cursor.
4037 *
4038 * The visitor should return one of the \c CXChildVisitResult values
4039 * to direct clang_visitChildrenWithBlock().
4040 */
4041#if __has_feature(blocks)
4042typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
4043 CXCursor parent);
4044#else
4045typedef struct _CXChildVisitResult *CXCursorVisitorBlock;
4046#endif
4047
4048/**
4049 * Visits the children of a cursor using the specified block. Behaves
4050 * identically to clang_visitChildren() in all other respects.
4051 */
4052CINDEX_LINKAGE unsigned
4053clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
4054
4055/**
4056 * @}
4057 */
4058
4059/**
4060 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4061 *
4062 * These routines provide the ability to determine references within and
4063 * across translation units, by providing the names of the entities referenced
4064 * by cursors, follow reference cursors to the declarations they reference,
4065 * and associate declarations with their definitions.
4066 *
4067 * @{
4068 */
4069
4070/**
4071 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4072 * by the given cursor.
4073 *
4074 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4075 * entity (function, class, variable, etc.) within a program. USRs can be
4076 * compared across translation units to determine, e.g., when references in
4077 * one translation refer to an entity defined in another translation unit.
4078 */
4079CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4080
4081/**
4082 * Construct a USR for a specified Objective-C class.
4083 */
4084CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4085
4086/**
4087 * Construct a USR for a specified Objective-C category.
4088 */
4089CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
4090 const char *class_name, const char *category_name);
4091
4092/**
4093 * Construct a USR for a specified Objective-C protocol.
4094 */
4095CINDEX_LINKAGE CXString
4096clang_constructUSR_ObjCProtocol(const char *protocol_name);
4097
4098/**
4099 * Construct a USR for a specified Objective-C instance variable and
4100 * the USR for its containing class.
4101 */
4102CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4103 CXString classUSR);
4104
4105/**
4106 * Construct a USR for a specified Objective-C method and
4107 * the USR for its containing class.
4108 */
4109CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4110 unsigned isInstanceMethod,
4111 CXString classUSR);
4112
4113/**
4114 * Construct a USR for a specified Objective-C property and the USR
4115 * for its containing class.
4116 */
4117CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4118 CXString classUSR);
4119
4120/**
4121 * Retrieve a name for the entity referenced by this cursor.
4122 */
4123CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4124
4125/**
4126 * Retrieve a range for a piece that forms the cursors spelling name.
4127 * Most of the times there is only one range for the complete spelling but for
4128 * Objective-C methods and Objective-C message expressions, there are multiple
4129 * pieces for each selector identifier.
4130 *
4131 * \param pieceIndex the index of the spelling name piece. If this is greater
4132 * than the actual number of pieces, it will return a NULL (invalid) range.
4133 *
4134 * \param options Reserved.
4135 */
4136CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
4137 CXCursor, unsigned pieceIndex, unsigned options);
4138
4139/**
4140 * Opaque pointer representing a policy that controls pretty printing
4141 * for \c clang_getCursorPrettyPrinted.
4142 */
4143typedef void *CXPrintingPolicy;
4144
4145/**
4146 * Properties for the printing policy.
4147 *
4148 * See \c clang::PrintingPolicy for more information.
4149 */
4150enum CXPrintingPolicyProperty {
4151 CXPrintingPolicy_Indentation,
4152 CXPrintingPolicy_SuppressSpecifiers,
4153 CXPrintingPolicy_SuppressTagKeyword,
4154 CXPrintingPolicy_IncludeTagDefinition,
4155 CXPrintingPolicy_SuppressScope,
4156 CXPrintingPolicy_SuppressUnwrittenScope,
4157 CXPrintingPolicy_SuppressInitializers,
4158 CXPrintingPolicy_ConstantArraySizeAsWritten,
4159 CXPrintingPolicy_AnonymousTagLocations,
4160 CXPrintingPolicy_SuppressStrongLifetime,
4161 CXPrintingPolicy_SuppressLifetimeQualifiers,
4162 CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4163 CXPrintingPolicy_Bool,
4164 CXPrintingPolicy_Restrict,
4165 CXPrintingPolicy_Alignof,
4166 CXPrintingPolicy_UnderscoreAlignof,
4167 CXPrintingPolicy_UseVoidForZeroParams,
4168 CXPrintingPolicy_TerseOutput,
4169 CXPrintingPolicy_PolishForDeclaration,
4170 CXPrintingPolicy_Half,
4171 CXPrintingPolicy_MSWChar,
4172 CXPrintingPolicy_IncludeNewlines,
4173 CXPrintingPolicy_MSVCFormatting,
4174 CXPrintingPolicy_ConstantsAsWritten,
4175 CXPrintingPolicy_SuppressImplicitBase,
4176 CXPrintingPolicy_FullyQualifiedName,
4177
4178 CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4179};
4180
4181/**
4182 * Get a property value for the given printing policy.
4183 */
4184CINDEX_LINKAGE unsigned
4185clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4186 enum CXPrintingPolicyProperty Property);
4187
4188/**
4189 * Set a property value for the given printing policy.
4190 */
4191CINDEX_LINKAGE void
4192clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4193 enum CXPrintingPolicyProperty Property,
4194 unsigned Value);
4195
4196/**
4197 * Retrieve the default policy for the cursor.
4198 *
4199 * The policy should be released after use with \c
4200 * clang_PrintingPolicy_dispose.
4201 */
4202CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4203
4204/**
4205 * Release a printing policy.
4206 */
4207CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4208
4209/**
4210 * Pretty print declarations.
4211 *
4212 * \param Cursor The cursor representing a declaration.
4213 *
4214 * \param Policy The policy to control the entities being printed. If
4215 * NULL, a default policy is used.
4216 *
4217 * \returns The pretty printed declaration or the empty string for
4218 * other cursors.
4219 */
4220CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4221 CXPrintingPolicy Policy);
4222
4223/**
4224 * Pretty-print the underlying type using a custom printing policy.
4225 *
4226 * If the type is invalid, an empty string is returned.
4227 */
4228CINDEX_LINKAGE CXString clang_getTypePrettyPrinted(CXType CT,
4229 CXPrintingPolicy cxPolicy);
4230
4231/**
4232 * Get the fully qualified name for a type.
4233 *
4234 * This includes full qualification of all template parameters.
4235 *
4236 * Policy - Further refine the type formatting
4237 * WithGlobalNsPrefix - If non-zero, function will prepend a '::' to qualified
4238 * names
4239 */
4240CINDEX_LINKAGE CXString clang_getFullyQualifiedName(
4241 CXType CT, CXPrintingPolicy Policy, unsigned WithGlobalNsPrefix);
4242
4243/**
4244 * Retrieve the display name for the entity referenced by this cursor.
4245 *
4246 * The display name contains extra information that helps identify the cursor,
4247 * such as the parameters of a function or template or the arguments of a
4248 * class template specialization.
4249 */
4250CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
4251
4252/** For a cursor that is a reference, retrieve a cursor representing the
4253 * entity that it references.
4254 *
4255 * Reference cursors refer to other entities in the AST. For example, an
4256 * Objective-C superclass reference cursor refers to an Objective-C class.
4257 * This function produces the cursor for the Objective-C class from the
4258 * cursor for the superclass reference. If the input cursor is a declaration or
4259 * definition, it returns that declaration or definition unchanged.
4260 * Otherwise, returns the NULL cursor.
4261 */
4262CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
4263
4264/**
4265 * For a cursor that is either a reference to or a declaration
4266 * of some entity, retrieve a cursor that describes the definition of
4267 * that entity.
4268 *
4269 * Some entities can be declared multiple times within a translation
4270 * unit, but only one of those declarations can also be a
4271 * definition. For example, given:
4272 *
4273 * \code
4274 * int f(int, int);
4275 * int g(int x, int y) { return f(x, y); }
4276 * int f(int a, int b) { return a + b; }
4277 * int f(int, int);
4278 * \endcode
4279 *
4280 * there are three declarations of the function "f", but only the
4281 * second one is a definition. The clang_getCursorDefinition()
4282 * function will take any cursor pointing to a declaration of "f"
4283 * (the first or fourth lines of the example) or a cursor referenced
4284 * that uses "f" (the call to "f' inside "g") and will return a
4285 * declaration cursor pointing to the definition (the second "f"
4286 * declaration).
4287 *
4288 * If given a cursor for which there is no corresponding definition,
4289 * e.g., because there is no definition of that entity within this
4290 * translation unit, returns a NULL cursor.
4291 */
4292CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4293
4294/**
4295 * Determine whether the declaration pointed to by this cursor
4296 * is also a definition of that entity.
4297 */
4298CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4299
4300/**
4301 * Retrieve the canonical cursor corresponding to the given cursor.
4302 *
4303 * In the C family of languages, many kinds of entities can be declared several
4304 * times within a single translation unit. For example, a structure type can
4305 * be forward-declared (possibly multiple times) and later defined:
4306 *
4307 * \code
4308 * struct X;
4309 * struct X;
4310 * struct X {
4311 * int member;
4312 * };
4313 * \endcode
4314 *
4315 * The declarations and the definition of \c X are represented by three
4316 * different cursors, all of which are declarations of the same underlying
4317 * entity. One of these cursor is considered the "canonical" cursor, which
4318 * is effectively the representative for the underlying entity. One can
4319 * determine if two cursors are declarations of the same underlying entity by
4320 * comparing their canonical cursors.
4321 *
4322 * \returns The canonical cursor for the entity referred to by the given cursor.
4323 */
4324CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4325
4326/**
4327 * If the cursor points to a selector identifier in an Objective-C
4328 * method or message expression, this returns the selector index.
4329 *
4330 * After getting a cursor with #clang_getCursor, this can be called to
4331 * determine if the location points to a selector identifier.
4332 *
4333 * \returns The selector index if the cursor is an Objective-C method or message
4334 * expression and the cursor is pointing to a selector identifier, or -1
4335 * otherwise.
4336 */
4337CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4338
4339/**
4340 * Given a cursor pointing to a C++ method call or an Objective-C
4341 * message, returns non-zero if the method/message is "dynamic", meaning:
4342 *
4343 * For a C++ method: the call is virtual.
4344 * For an Objective-C message: the receiver is an object instance, not 'super'
4345 * or a specific class.
4346 *
4347 * If the method/message is "static" or the cursor does not point to a
4348 * method/message, it will return zero.
4349 */
4350CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4351
4352/**
4353 * Given a cursor pointing to an Objective-C message or property
4354 * reference, or C++ method call, returns the CXType of the receiver.
4355 */
4356CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4357
4358/**
4359 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4360 */
4361typedef enum {
4362 CXObjCPropertyAttr_noattr = 0x00,
4363 CXObjCPropertyAttr_readonly = 0x01,
4364 CXObjCPropertyAttr_getter = 0x02,
4365 CXObjCPropertyAttr_assign = 0x04,
4366 CXObjCPropertyAttr_readwrite = 0x08,
4367 CXObjCPropertyAttr_retain = 0x10,
4368 CXObjCPropertyAttr_copy = 0x20,
4369 CXObjCPropertyAttr_nonatomic = 0x40,
4370 CXObjCPropertyAttr_setter = 0x80,
4371 CXObjCPropertyAttr_atomic = 0x100,
4372 CXObjCPropertyAttr_weak = 0x200,
4373 CXObjCPropertyAttr_strong = 0x400,
4374 CXObjCPropertyAttr_unsafe_unretained = 0x800,
4375 CXObjCPropertyAttr_class = 0x1000
4376} CXObjCPropertyAttrKind;
4377
4378/**
4379 * Given a cursor that represents a property declaration, return the
4380 * associated property attributes. The bits are formed from
4381 * \c CXObjCPropertyAttrKind.
4382 *
4383 * \param reserved Reserved for future use, pass 0.
4384 */
4385CINDEX_LINKAGE unsigned
4386clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
4387
4388/**
4389 * Given a cursor that represents a property declaration, return the
4390 * name of the method that implements the getter.
4391 */
4392CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4393
4394/**
4395 * Given a cursor that represents a property declaration, return the
4396 * name of the method that implements the setter, if any.
4397 */
4398CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4399
4400/**
4401 * 'Qualifiers' written next to the return and parameter types in
4402 * Objective-C method declarations.
4403 */
4404typedef enum {
4405 CXObjCDeclQualifier_None = 0x0,
4406 CXObjCDeclQualifier_In = 0x1,
4407 CXObjCDeclQualifier_Inout = 0x2,
4408 CXObjCDeclQualifier_Out = 0x4,
4409 CXObjCDeclQualifier_Bycopy = 0x8,
4410 CXObjCDeclQualifier_Byref = 0x10,
4411 CXObjCDeclQualifier_Oneway = 0x20
4412} CXObjCDeclQualifierKind;
4413
4414/**
4415 * Given a cursor that represents an Objective-C method or parameter
4416 * declaration, return the associated Objective-C qualifiers for the return
4417 * type or the parameter respectively. The bits are formed from
4418 * CXObjCDeclQualifierKind.
4419 */
4420CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4421
4422/**
4423 * Given a cursor that represents an Objective-C method or property
4424 * declaration, return non-zero if the declaration was affected by "\@optional".
4425 * Returns zero if the cursor is not such a declaration or it is "\@required".
4426 */
4427CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4428
4429/**
4430 * Returns non-zero if the given cursor is a variadic function or method.
4431 */
4432CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4433
4434/**
4435 * Returns non-zero if the given cursor points to a symbol marked with
4436 * external_source_symbol attribute.
4437 *
4438 * \param language If non-NULL, and the attribute is present, will be set to
4439 * the 'language' string from the attribute.
4440 *
4441 * \param definedIn If non-NULL, and the attribute is present, will be set to
4442 * the 'definedIn' string from the attribute.
4443 *
4444 * \param isGenerated If non-NULL, and the attribute is present, will be set to
4445 * non-zero if the 'generated_declaration' is set in the attribute.
4446 */
4447CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4448 CXString *language,
4449 CXString *definedIn,
4450 unsigned *isGenerated);
4451
4452/**
4453 * Given a cursor that represents a declaration, return the associated
4454 * comment's source range. The range may include multiple consecutive comments
4455 * with whitespace in between.
4456 */
4457CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4458
4459/**
4460 * Given a cursor that represents a declaration, return the associated
4461 * comment text, including comment markers.
4462 */
4463CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4464
4465/**
4466 * Given a cursor that represents a documentable entity (e.g.,
4467 * declaration), return the associated \paragraph; otherwise return the
4468 * first paragraph.
4469 */
4470CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4471
4472/**
4473 * @}
4474 */
4475
4476/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4477 *
4478 * @{
4479 */
4480
4481/**
4482 * Retrieve the CXString representing the mangled name of the cursor.
4483 */
4484CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4485
4486/**
4487 * Retrieve the CXStrings representing the mangled symbols of the C++
4488 * constructor or destructor at the cursor.
4489 */
4490CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4491
4492/**
4493 * Retrieve the CXStrings representing the mangled symbols of the ObjC
4494 * class interface or implementation at the cursor.
4495 */
4496CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4497
4498/**
4499 * @}
4500 */
4501
4502/**
4503 * \defgroup CINDEX_MODULE Module introspection
4504 *
4505 * The functions in this group provide access to information about modules.
4506 *
4507 * @{
4508 */
4509
4510typedef void *CXModule;
4511
4512/**
4513 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4514 */
4515CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4516
4517/**
4518 * Given a CXFile header file, return the module that contains it, if one
4519 * exists.
4520 */
4521CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4522
4523/**
4524 * \param Module a module object.
4525 *
4526 * \returns the module file where the provided module object came from.
4527 */
4528CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4529
4530/**
4531 * \param Module a module object.
4532 *
4533 * \returns the parent of a sub-module or NULL if the given module is top-level,
4534 * e.g. for 'std.vector' it will return the 'std' module.
4535 */
4536CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4537
4538/**
4539 * \param Module a module object.
4540 *
4541 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4542 * will return "vector".
4543 */
4544CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4545
4546/**
4547 * \param Module a module object.
4548 *
4549 * \returns the full name of the module, e.g. "std.vector".
4550 */
4551CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4552
4553/**
4554 * \param Module a module object.
4555 *
4556 * \returns non-zero if the module is a system one.
4557 */
4558CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4559
4560/**
4561 * \param Module a module object.
4562 *
4563 * \returns the number of top level headers associated with this module.
4564 */
4565CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4566 CXModule Module);
4567
4568/**
4569 * \param Module a module object.
4570 *
4571 * \param Index top level header index (zero-based).
4572 *
4573 * \returns the specified top level header associated with the module.
4574 */
4575CINDEX_LINKAGE
4576CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
4577 unsigned Index);
4578
4579/**
4580 * @}
4581 */
4582
4583/**
4584 * \defgroup CINDEX_CPP C++ AST introspection
4585 *
4586 * The routines in this group provide access information in the ASTs specific
4587 * to C++ language features.
4588 *
4589 * @{
4590 */
4591
4592/**
4593 * Determine if a C++ constructor is a converting constructor.
4594 */
4595CINDEX_LINKAGE unsigned
4596clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4597
4598/**
4599 * Determine if a C++ constructor is a copy constructor.
4600 */
4601CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4602
4603/**
4604 * Determine if a C++ constructor is the default constructor.
4605 */
4606CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4607
4608/**
4609 * Determine if a C++ constructor is a move constructor.
4610 */
4611CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4612
4613/**
4614 * Determine if a C++ field is declared 'mutable'.
4615 */
4616CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4617
4618/**
4619 * Determine if a C++ method is declared '= default'.
4620 */
4621CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4622
4623/**
4624 * Determine if a C++ method is declared '= delete'.
4625 */
4626CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C);
4627
4628/**
4629 * Determine if a C++ member function or member function template is
4630 * pure virtual.
4631 */
4632CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4633
4634/**
4635 * Determine if a C++ member function or member function template is
4636 * declared 'static'.
4637 */
4638CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4639
4640/**
4641 * Determine if a C++ member function or member function template is
4642 * explicitly declared 'virtual' or if it overrides a virtual method from
4643 * one of the base classes.
4644 */
4645CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4646
4647/**
4648 * Determine if a C++ member function is a copy-assignment operator,
4649 * returning 1 if such is the case and 0 otherwise.
4650 *
4651 * > A copy-assignment operator `X::operator=` is a non-static,
4652 * > non-template member function of _class_ `X` with exactly one
4653 * > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
4654 * > volatile X&`.
4655 *
4656 * That is, for example, the `operator=` in:
4657 *
4658 * class Foo {
4659 * bool operator=(const volatile Foo&);
4660 * };
4661 *
4662 * Is a copy-assignment operator, while the `operator=` in:
4663 *
4664 * class Bar {
4665 * bool operator=(const int&);
4666 * };
4667 *
4668 * Is not.
4669 */
4670CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C);
4671
4672/**
4673 * Determine if a C++ member function is a move-assignment operator,
4674 * returning 1 if such is the case and 0 otherwise.
4675 *
4676 * > A move-assignment operator `X::operator=` is a non-static,
4677 * > non-template member function of _class_ `X` with exactly one
4678 * > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
4679 * > volatile X&&`.
4680 *
4681 * That is, for example, the `operator=` in:
4682 *
4683 * class Foo {
4684 * bool operator=(const volatile Foo&&);
4685 * };
4686 *
4687 * Is a move-assignment operator, while the `operator=` in:
4688 *
4689 * class Bar {
4690 * bool operator=(const int&&);
4691 * };
4692 *
4693 * Is not.
4694 */
4695CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C);
4696
4697/**
4698 * Determines if a C++ constructor or conversion function was declared
4699 * explicit, returning 1 if such is the case and 0 otherwise.
4700 *
4701 * Constructors or conversion functions are declared explicit through
4702 * the use of the explicit specifier.
4703 *
4704 * For example, the following constructor and conversion function are
4705 * not explicit as they lack the explicit specifier:
4706 *
4707 * class Foo {
4708 * Foo();
4709 * operator int();
4710 * };
4711 *
4712 * While the following constructor and conversion function are
4713 * explicit as they are declared with the explicit specifier.
4714 *
4715 * class Foo {
4716 * explicit Foo();
4717 * explicit operator int();
4718 * };
4719 *
4720 * This function will return 0 when given a cursor pointing to one of
4721 * the former declarations and it will return 1 for a cursor pointing
4722 * to the latter declarations.
4723 *
4724 * The explicit specifier allows the user to specify a
4725 * conditional compile-time expression whose value decides
4726 * whether the marked element is explicit or not.
4727 *
4728 * For example:
4729 *
4730 * constexpr bool foo(int i) { return i % 2 == 0; }
4731 *
4732 * class Foo {
4733 * explicit(foo(1)) Foo();
4734 * explicit(foo(2)) operator int();
4735 * }
4736 *
4737 * This function will return 0 for the constructor and 1 for
4738 * the conversion function.
4739 */
4740CINDEX_LINKAGE unsigned clang_CXXMethod_isExplicit(CXCursor C);
4741
4742/**
4743 * Determine if a C++ record is abstract, i.e. whether a class or struct
4744 * has a pure virtual member function.
4745 */
4746CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4747
4748/**
4749 * Determine if an enum declaration refers to a scoped enum.
4750 */
4751CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4752
4753/**
4754 * Determine if a C++ member function or member function template is
4755 * declared 'const'.
4756 */
4757CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4758
4759/**
4760 * Given a cursor that represents a template, determine
4761 * the cursor kind of the specializations would be generated by instantiating
4762 * the template.
4763 *
4764 * This routine can be used to determine what flavor of function template,
4765 * class template, or class template partial specialization is stored in the
4766 * cursor. For example, it can describe whether a class template cursor is
4767 * declared with "struct", "class" or "union".
4768 *
4769 * \param C The cursor to query. This cursor should represent a template
4770 * declaration.
4771 *
4772 * \returns The cursor kind of the specializations that would be generated
4773 * by instantiating the template \p C. If \p C is not a template, returns
4774 * \c CXCursor_NoDeclFound.
4775 */
4776CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4777
4778/**
4779 * Given a cursor that may represent a specialization or instantiation
4780 * of a template, retrieve the cursor that represents the template that it
4781 * specializes or from which it was instantiated.
4782 *
4783 * This routine determines the template involved both for explicit
4784 * specializations of templates and for implicit instantiations of the template,
4785 * both of which are referred to as "specializations". For a class template
4786 * specialization (e.g., \c std::vector<bool>), this routine will return
4787 * either the primary template (\c std::vector) or, if the specialization was
4788 * instantiated from a class template partial specialization, the class template
4789 * partial specialization. For a class template partial specialization and a
4790 * function template specialization (including instantiations), this
4791 * this routine will return the specialized template.
4792 *
4793 * For members of a class template (e.g., member functions, member classes, or
4794 * static data members), returns the specialized or instantiated member.
4795 * Although not strictly "templates" in the C++ language, members of class
4796 * templates have the same notions of specializations and instantiations that
4797 * templates do, so this routine treats them similarly.
4798 *
4799 * \param C A cursor that may be a specialization of a template or a member
4800 * of a template.
4801 *
4802 * \returns If the given cursor is a specialization or instantiation of a
4803 * template or a member thereof, the template or member that it specializes or
4804 * from which it was instantiated. Otherwise, returns a NULL cursor.
4805 */
4806CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4807
4808/**
4809 * Given a cursor that references something else, return the source range
4810 * covering that reference.
4811 *
4812 * \param C A cursor pointing to a member reference, a declaration reference, or
4813 * an operator call.
4814 * \param NameFlags A bitset with three independent flags:
4815 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4816 * CXNameRange_WantSinglePiece.
4817 * \param PieceIndex For contiguous names or when passing the flag
4818 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4819 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4820 * non-contiguous names, this index can be used to retrieve the individual
4821 * pieces of the name. See also CXNameRange_WantSinglePiece.
4822 *
4823 * \returns The piece of the name pointed to by the given cursor. If there is no
4824 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4825 */
4826CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
4827 CXCursor C, unsigned NameFlags, unsigned PieceIndex);
4828
4829enum CXNameRefFlags {
4830 /**
4831 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4832 * range.
4833 */
4834 CXNameRange_WantQualifier = 0x1,
4835
4836 /**
4837 * Include the explicit template arguments, e.g. \<int> in x.f<int>,
4838 * in the range.
4839 */
4840 CXNameRange_WantTemplateArgs = 0x2,
4841
4842 /**
4843 * If the name is non-contiguous, return the full spanning range.
4844 *
4845 * Non-contiguous names occur in Objective-C when a selector with two or more
4846 * parameters is used, or in C++ when using an operator:
4847 * \code
4848 * [object doSomething:here withValue:there]; // Objective-C
4849 * return some_vector[1]; // C++
4850 * \endcode
4851 */
4852 CXNameRange_WantSinglePiece = 0x4
4853};
4854
4855/**
4856 * @}
4857 */
4858
4859/**
4860 * \defgroup CINDEX_LEX Token extraction and manipulation
4861 *
4862 * The routines in this group provide access to the tokens within a
4863 * translation unit, along with a semantic mapping of those tokens to
4864 * their corresponding cursors.
4865 *
4866 * @{
4867 */
4868
4869/**
4870 * Describes a kind of token.
4871 */
4872typedef enum CXTokenKind {
4873 /**
4874 * A token that contains some kind of punctuation.
4875 */
4876 CXToken_Punctuation,
4877
4878 /**
4879 * A language keyword.
4880 */
4881 CXToken_Keyword,
4882
4883 /**
4884 * An identifier (that is not a keyword).
4885 */
4886 CXToken_Identifier,
4887
4888 /**
4889 * A numeric, string, or character literal.
4890 */
4891 CXToken_Literal,
4892
4893 /**
4894 * A comment.
4895 */
4896 CXToken_Comment
4897} CXTokenKind;
4898
4899/**
4900 * Describes a single preprocessing token.
4901 */
4902typedef struct {
4903 unsigned int_data[4];
4904 void *ptr_data;
4905} CXToken;
4906
4907/**
4908 * Get the raw lexical token starting with the given location.
4909 *
4910 * \param TU the translation unit whose text is being tokenized.
4911 *
4912 * \param Location the source location with which the token starts.
4913 *
4914 * \returns The token starting with the given location or NULL if no such token
4915 * exist. The returned pointer must be freed with clang_disposeTokens before the
4916 * translation unit is destroyed.
4917 */
4918CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4919 CXSourceLocation Location);
4920
4921/**
4922 * Determine the kind of the given token.
4923 */
4924CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4925
4926/**
4927 * Determine the spelling of the given token.
4928 *
4929 * The spelling of a token is the textual representation of that token, e.g.,
4930 * the text of an identifier or keyword.
4931 */
4932CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4933
4934/**
4935 * Retrieve the source location of the given token.
4936 */
4937CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4938 CXToken);
4939
4940/**
4941 * Retrieve a source range that covers the given token.
4942 */
4943CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4944
4945/**
4946 * Tokenize the source code described by the given range into raw
4947 * lexical tokens.
4948 *
4949 * \param TU the translation unit whose text is being tokenized.
4950 *
4951 * \param Range the source range in which text should be tokenized. All of the
4952 * tokens produced by tokenization will fall within this source range,
4953 *
4954 * \param Tokens this pointer will be set to point to the array of tokens
4955 * that occur within the given source range. The returned pointer must be
4956 * freed with clang_disposeTokens() before the translation unit is destroyed.
4957 *
4958 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4959 * array.
4960 *
4961 */
4962CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4963 CXToken **Tokens, unsigned *NumTokens);
4964
4965/**
4966 * Annotate the given set of tokens by providing cursors for each token
4967 * that can be mapped to a specific entity within the abstract syntax tree.
4968 *
4969 * This token-annotation routine is equivalent to invoking
4970 * clang_getCursor() for the source locations of each of the
4971 * tokens. The cursors provided are filtered, so that only those
4972 * cursors that have a direct correspondence to the token are
4973 * accepted. For example, given a function call \c f(x),
4974 * clang_getCursor() would provide the following cursors:
4975 *
4976 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4977 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4978 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4979 *
4980 * Only the first and last of these cursors will occur within the
4981 * annotate, since the tokens "f" and "x' directly refer to a function
4982 * and a variable, respectively, but the parentheses are just a small
4983 * part of the full syntax of the function call expression, which is
4984 * not provided as an annotation.
4985 *
4986 * \param TU the translation unit that owns the given tokens.
4987 *
4988 * \param Tokens the set of tokens to annotate.
4989 *
4990 * \param NumTokens the number of tokens in \p Tokens.
4991 *
4992 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4993 * replaced with the cursors corresponding to each token.
4994 */
4995CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
4996 unsigned NumTokens, CXCursor *Cursors);
4997
4998/**
4999 * Free the given set of tokens.
5000 */
5001CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
5002 unsigned NumTokens);
5003
5004/**
5005 * @}
5006 */
5007
5008/**
5009 * \defgroup CINDEX_DEBUG Debugging facilities
5010 *
5011 * These routines are used for testing and debugging, only, and should not
5012 * be relied upon.
5013 *
5014 * @{
5015 */
5016
5017/* for debug/testing */
5018CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
5019CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
5020 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
5021 unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
5022CINDEX_LINKAGE void clang_enableStackTraces(void);
5023CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
5024 unsigned stack_size);
5025
5026/**
5027 * @}
5028 */
5029
5030/**
5031 * \defgroup CINDEX_CODE_COMPLET Code completion
5032 *
5033 * Code completion involves taking an (incomplete) source file, along with
5034 * knowledge of where the user is actively editing that file, and suggesting
5035 * syntactically- and semantically-valid constructs that the user might want to
5036 * use at that particular point in the source code. These data structures and
5037 * routines provide support for code completion.
5038 *
5039 * @{
5040 */
5041
5042/**
5043 * A semantic string that describes a code-completion result.
5044 *
5045 * A semantic string that describes the formatting of a code-completion
5046 * result as a single "template" of text that should be inserted into the
5047 * source buffer when a particular code-completion result is selected.
5048 * Each semantic string is made up of some number of "chunks", each of which
5049 * contains some text along with a description of what that text means, e.g.,
5050 * the name of the entity being referenced, whether the text chunk is part of
5051 * the template, or whether it is a "placeholder" that the user should replace
5052 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
5053 * description of the different kinds of chunks.
5054 */
5055typedef void *CXCompletionString;
5056
5057/**
5058 * A single result of code completion.
5059 */
5060typedef struct {
5061 /**
5062 * The kind of entity that this completion refers to.
5063 *
5064 * The cursor kind will be a macro, keyword, or a declaration (one of the
5065 * *Decl cursor kinds), describing the entity that the completion is
5066 * referring to.
5067 *
5068 * \todo In the future, we would like to provide a full cursor, to allow
5069 * the client to extract additional information from declaration.
5070 */
5071 enum CXCursorKind CursorKind;
5072
5073 /**
5074 * The code-completion string that describes how to insert this
5075 * code-completion result into the editing buffer.
5076 */
5077 CXCompletionString CompletionString;
5078} CXCompletionResult;
5079
5080/**
5081 * Describes a single piece of text within a code-completion string.
5082 *
5083 * Each "chunk" within a code-completion string (\c CXCompletionString) is
5084 * either a piece of text with a specific "kind" that describes how that text
5085 * should be interpreted by the client or is another completion string.
5086 */
5087enum CXCompletionChunkKind {
5088 /**
5089 * A code-completion string that describes "optional" text that
5090 * could be a part of the template (but is not required).
5091 *
5092 * The Optional chunk is the only kind of chunk that has a code-completion
5093 * string for its representation, which is accessible via
5094 * \c clang_getCompletionChunkCompletionString(). The code-completion string
5095 * describes an additional part of the template that is completely optional.
5096 * For example, optional chunks can be used to describe the placeholders for
5097 * arguments that match up with defaulted function parameters, e.g. given:
5098 *
5099 * \code
5100 * void f(int x, float y = 3.14, double z = 2.71828);
5101 * \endcode
5102 *
5103 * The code-completion string for this function would contain:
5104 * - a TypedText chunk for "f".
5105 * - a LeftParen chunk for "(".
5106 * - a Placeholder chunk for "int x"
5107 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
5108 * - a Comma chunk for ","
5109 * - a Placeholder chunk for "float y"
5110 * - an Optional chunk containing the last defaulted argument:
5111 * - a Comma chunk for ","
5112 * - a Placeholder chunk for "double z"
5113 * - a RightParen chunk for ")"
5114 *
5115 * There are many ways to handle Optional chunks. Two simple approaches are:
5116 * - Completely ignore optional chunks, in which case the template for the
5117 * function "f" would only include the first parameter ("int x").
5118 * - Fully expand all optional chunks, in which case the template for the
5119 * function "f" would have all of the parameters.
5120 */
5121 CXCompletionChunk_Optional,
5122 /**
5123 * Text that a user would be expected to type to get this
5124 * code-completion result.
5125 *
5126 * There will be exactly one "typed text" chunk in a semantic string, which
5127 * will typically provide the spelling of a keyword or the name of a
5128 * declaration that could be used at the current code point. Clients are
5129 * expected to filter the code-completion results based on the text in this
5130 * chunk.
5131 */
5132 CXCompletionChunk_TypedText,
5133 /**
5134 * Text that should be inserted as part of a code-completion result.
5135 *
5136 * A "text" chunk represents text that is part of the template to be
5137 * inserted into user code should this particular code-completion result
5138 * be selected.
5139 */
5140 CXCompletionChunk_Text,
5141 /**
5142 * Placeholder text that should be replaced by the user.
5143 *
5144 * A "placeholder" chunk marks a place where the user should insert text
5145 * into the code-completion template. For example, placeholders might mark
5146 * the function parameters for a function declaration, to indicate that the
5147 * user should provide arguments for each of those parameters. The actual
5148 * text in a placeholder is a suggestion for the text to display before
5149 * the user replaces the placeholder with real code.
5150 */
5151 CXCompletionChunk_Placeholder,
5152 /**
5153 * Informative text that should be displayed but never inserted as
5154 * part of the template.
5155 *
5156 * An "informative" chunk contains annotations that can be displayed to
5157 * help the user decide whether a particular code-completion result is the
5158 * right option, but which is not part of the actual template to be inserted
5159 * by code completion.
5160 */
5161 CXCompletionChunk_Informative,
5162 /**
5163 * Text that describes the current parameter when code-completion is
5164 * referring to function call, message send, or template specialization.
5165 *
5166 * A "current parameter" chunk occurs when code-completion is providing
5167 * information about a parameter corresponding to the argument at the
5168 * code-completion point. For example, given a function
5169 *
5170 * \code
5171 * int add(int x, int y);
5172 * \endcode
5173 *
5174 * and the source code \c add(, where the code-completion point is after the
5175 * "(", the code-completion string will contain a "current parameter" chunk
5176 * for "int x", indicating that the current argument will initialize that
5177 * parameter. After typing further, to \c add(17, (where the code-completion
5178 * point is after the ","), the code-completion string will contain a
5179 * "current parameter" chunk to "int y".
5180 */
5181 CXCompletionChunk_CurrentParameter,
5182 /**
5183 * A left parenthesis ('('), used to initiate a function call or
5184 * signal the beginning of a function parameter list.
5185 */
5186 CXCompletionChunk_LeftParen,
5187 /**
5188 * A right parenthesis (')'), used to finish a function call or
5189 * signal the end of a function parameter list.
5190 */
5191 CXCompletionChunk_RightParen,
5192 /**
5193 * A left bracket ('[').
5194 */
5195 CXCompletionChunk_LeftBracket,
5196 /**
5197 * A right bracket (']').
5198 */
5199 CXCompletionChunk_RightBracket,
5200 /**
5201 * A left brace ('{').
5202 */
5203 CXCompletionChunk_LeftBrace,
5204 /**
5205 * A right brace ('}').
5206 */
5207 CXCompletionChunk_RightBrace,
5208 /**
5209 * A left angle bracket ('<').
5210 */
5211 CXCompletionChunk_LeftAngle,
5212 /**
5213 * A right angle bracket ('>').
5214 */
5215 CXCompletionChunk_RightAngle,
5216 /**
5217 * A comma separator (',').
5218 */
5219 CXCompletionChunk_Comma,
5220 /**
5221 * Text that specifies the result type of a given result.
5222 *
5223 * This special kind of informative chunk is not meant to be inserted into
5224 * the text buffer. Rather, it is meant to illustrate the type that an
5225 * expression using the given completion string would have.
5226 */
5227 CXCompletionChunk_ResultType,
5228 /**
5229 * A colon (':').
5230 */
5231 CXCompletionChunk_Colon,
5232 /**
5233 * A semicolon (';').
5234 */
5235 CXCompletionChunk_SemiColon,
5236 /**
5237 * An '=' sign.
5238 */
5239 CXCompletionChunk_Equal,
5240 /**
5241 * Horizontal space (' ').
5242 */
5243 CXCompletionChunk_HorizontalSpace,
5244 /**
5245 * Vertical space ('\\n'), after which it is generally a good idea to
5246 * perform indentation.
5247 */
5248 CXCompletionChunk_VerticalSpace
5249};
5250
5251/**
5252 * Determine the kind of a particular chunk within a completion string.
5253 *
5254 * \param completion_string the completion string to query.
5255 *
5256 * \param chunk_number the 0-based index of the chunk in the completion string.
5257 *
5258 * \returns the kind of the chunk at the index \c chunk_number.
5259 */
5260CINDEX_LINKAGE enum CXCompletionChunkKind
5261clang_getCompletionChunkKind(CXCompletionString completion_string,
5262 unsigned chunk_number);
5263
5264/**
5265 * Retrieve the text associated with a particular chunk within a
5266 * completion string.
5267 *
5268 * \param completion_string the completion string to query.
5269 *
5270 * \param chunk_number the 0-based index of the chunk in the completion string.
5271 *
5272 * \returns the text associated with the chunk at index \c chunk_number.
5273 */
5274CINDEX_LINKAGE CXString clang_getCompletionChunkText(
5275 CXCompletionString completion_string, unsigned chunk_number);
5276
5277/**
5278 * Retrieve the completion string associated with a particular chunk
5279 * within a completion string.
5280 *
5281 * \param completion_string the completion string to query.
5282 *
5283 * \param chunk_number the 0-based index of the chunk in the completion string.
5284 *
5285 * \returns the completion string associated with the chunk at index
5286 * \c chunk_number.
5287 */
5288CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
5289 CXCompletionString completion_string, unsigned chunk_number);
5290
5291/**
5292 * Retrieve the number of chunks in the given code-completion string.
5293 */
5294CINDEX_LINKAGE unsigned
5295clang_getNumCompletionChunks(CXCompletionString completion_string);
5296
5297/**
5298 * Determine the priority of this code completion.
5299 *
5300 * The priority of a code completion indicates how likely it is that this
5301 * particular completion is the completion that the user will select. The
5302 * priority is selected by various internal heuristics.
5303 *
5304 * \param completion_string The completion string to query.
5305 *
5306 * \returns The priority of this completion string. Smaller values indicate
5307 * higher-priority (more likely) completions.
5308 */
5309CINDEX_LINKAGE unsigned
5310clang_getCompletionPriority(CXCompletionString completion_string);
5311
5312/**
5313 * Determine the availability of the entity that this code-completion
5314 * string refers to.
5315 *
5316 * \param completion_string The completion string to query.
5317 *
5318 * \returns The availability of the completion string.
5319 */
5320CINDEX_LINKAGE enum CXAvailabilityKind
5321clang_getCompletionAvailability(CXCompletionString completion_string);
5322
5323/**
5324 * Retrieve the number of annotations associated with the given
5325 * completion string.
5326 *
5327 * \param completion_string the completion string to query.
5328 *
5329 * \returns the number of annotations associated with the given completion
5330 * string.
5331 */
5332CINDEX_LINKAGE unsigned
5333clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5334
5335/**
5336 * Retrieve the annotation associated with the given completion string.
5337 *
5338 * \param completion_string the completion string to query.
5339 *
5340 * \param annotation_number the 0-based index of the annotation of the
5341 * completion string.
5342 *
5343 * \returns annotation string associated with the completion at index
5344 * \c annotation_number, or a NULL string if that annotation is not available.
5345 */
5346CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
5347 CXCompletionString completion_string, unsigned annotation_number);
5348
5349/**
5350 * Retrieve the parent context of the given completion string.
5351 *
5352 * The parent context of a completion string is the semantic parent of
5353 * the declaration (if any) that the code completion represents. For example,
5354 * a code completion for an Objective-C method would have the method's class
5355 * or protocol as its context.
5356 *
5357 * \param completion_string The code completion string whose parent is
5358 * being queried.
5359 *
5360 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5361 *
5362 * \returns The name of the completion parent, e.g., "NSObject" if
5363 * the completion string represents a method in the NSObject class.
5364 */
5365CINDEX_LINKAGE CXString clang_getCompletionParent(
5366 CXCompletionString completion_string, enum CXCursorKind *kind);
5367
5368/**
5369 * Retrieve the brief documentation comment attached to the declaration
5370 * that corresponds to the given completion string.
5371 */
5372CINDEX_LINKAGE CXString
5373clang_getCompletionBriefComment(CXCompletionString completion_string);
5374
5375/**
5376 * Retrieve a completion string for an arbitrary declaration or macro
5377 * definition cursor.
5378 *
5379 * \param cursor The cursor to query.
5380 *
5381 * \returns A non-context-sensitive completion string for declaration and macro
5382 * definition cursors, or NULL for other kinds of cursors.
5383 */
5384CINDEX_LINKAGE CXCompletionString
5385clang_getCursorCompletionString(CXCursor cursor);
5386
5387/**
5388 * Contains the results of code-completion.
5389 *
5390 * This data structure contains the results of code completion, as
5391 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5392 * \c clang_disposeCodeCompleteResults.
5393 */
5394typedef struct {
5395 /**
5396 * The code-completion results.
5397 */
5398 CXCompletionResult *Results;
5399
5400 /**
5401 * The number of code-completion results stored in the
5402 * \c Results array.
5403 */
5404 unsigned NumResults;
5405} CXCodeCompleteResults;
5406
5407/**
5408 * Retrieve the number of fix-its for the given completion index.
5409 *
5410 * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5411 * option was set.
5412 *
5413 * \param results The structure keeping all completion results
5414 *
5415 * \param completion_index The index of the completion
5416 *
5417 * \return The number of fix-its which must be applied before the completion at
5418 * completion_index can be applied
5419 */
5420CINDEX_LINKAGE unsigned
5421clang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5422 unsigned completion_index);
5423
5424/**
5425 * Fix-its that *must* be applied before inserting the text for the
5426 * corresponding completion.
5427 *
5428 * By default, clang_codeCompleteAt() only returns completions with empty
5429 * fix-its. Extra completions with non-empty fix-its should be explicitly
5430 * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5431 *
5432 * For the clients to be able to compute position of the cursor after applying
5433 * fix-its, the following conditions are guaranteed to hold for
5434 * replacement_range of the stored fix-its:
5435 * - Ranges in the fix-its are guaranteed to never contain the completion
5436 * point (or identifier under completion point, if any) inside them, except
5437 * at the start or at the end of the range.
5438 * - If a fix-it range starts or ends with completion point (or starts or
5439 * ends after the identifier under completion point), it will contain at
5440 * least one character. It allows to unambiguously recompute completion
5441 * point after applying the fix-it.
5442 *
5443 * The intuition is that provided fix-its change code around the identifier we
5444 * complete, but are not allowed to touch the identifier itself or the
5445 * completion point. One example of completions with corrections are the ones
5446 * replacing '.' with '->' and vice versa:
5447 *
5448 * std::unique_ptr<std::vector<int>> vec_ptr;
5449 * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5450 * replacing '.' with '->'.
5451 * In 'vec_ptr->^', one of the completions is 'release', it requires
5452 * replacing '->' with '.'.
5453 *
5454 * \param results The structure keeping all completion results
5455 *
5456 * \param completion_index The index of the completion
5457 *
5458 * \param fixit_index The index of the fix-it for the completion at
5459 * completion_index
5460 *
5461 * \param replacement_range The fix-it range that must be replaced before the
5462 * completion at completion_index can be applied
5463 *
5464 * \returns The fix-it string that must replace the code at replacement_range
5465 * before the completion at completion_index can be applied
5466 */
5467CINDEX_LINKAGE CXString clang_getCompletionFixIt(
5468 CXCodeCompleteResults *results, unsigned completion_index,
5469 unsigned fixit_index, CXSourceRange *replacement_range);
5470
5471/**
5472 * Flags that can be passed to \c clang_codeCompleteAt() to
5473 * modify its behavior.
5474 *
5475 * The enumerators in this enumeration can be bitwise-OR'd together to
5476 * provide multiple options to \c clang_codeCompleteAt().
5477 */
5478enum CXCodeComplete_Flags {
5479 /**
5480 * Whether to include macros within the set of code
5481 * completions returned.
5482 */
5483 CXCodeComplete_IncludeMacros = 0x01,
5484
5485 /**
5486 * Whether to include code patterns for language constructs
5487 * within the set of code completions, e.g., for loops.
5488 */
5489 CXCodeComplete_IncludeCodePatterns = 0x02,
5490
5491 /**
5492 * Whether to include brief documentation within the set of code
5493 * completions returned.
5494 */
5495 CXCodeComplete_IncludeBriefComments = 0x04,
5496
5497 /**
5498 * Whether to speed up completion by omitting top- or namespace-level entities
5499 * defined in the preamble. There's no guarantee any particular entity is
5500 * omitted. This may be useful if the headers are indexed externally.
5501 */
5502 CXCodeComplete_SkipPreamble = 0x08,
5503
5504 /**
5505 * Whether to include completions with small
5506 * fix-its, e.g. change '.' to '->' on member access, etc.
5507 */
5508 CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
5509};
5510
5511/**
5512 * Bits that represent the context under which completion is occurring.
5513 *
5514 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5515 * contexts are occurring simultaneously.
5516 */
5517enum CXCompletionContext {
5518 /**
5519 * The context for completions is unexposed, as only Clang results
5520 * should be included. (This is equivalent to having no context bits set.)
5521 */
5522 CXCompletionContext_Unexposed = 0,
5523
5524 /**
5525 * Completions for any possible type should be included in the results.
5526 */
5527 CXCompletionContext_AnyType = 1 << 0,
5528
5529 /**
5530 * Completions for any possible value (variables, function calls, etc.)
5531 * should be included in the results.
5532 */
5533 CXCompletionContext_AnyValue = 1 << 1,
5534 /**
5535 * Completions for values that resolve to an Objective-C object should
5536 * be included in the results.
5537 */
5538 CXCompletionContext_ObjCObjectValue = 1 << 2,
5539 /**
5540 * Completions for values that resolve to an Objective-C selector
5541 * should be included in the results.
5542 */
5543 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5544 /**
5545 * Completions for values that resolve to a C++ class type should be
5546 * included in the results.
5547 */
5548 CXCompletionContext_CXXClassTypeValue = 1 << 4,
5549
5550 /**
5551 * Completions for fields of the member being accessed using the dot
5552 * operator should be included in the results.
5553 */
5554 CXCompletionContext_DotMemberAccess = 1 << 5,
5555 /**
5556 * Completions for fields of the member being accessed using the arrow
5557 * operator should be included in the results.
5558 */
5559 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5560 /**
5561 * Completions for properties of the Objective-C object being accessed
5562 * using the dot operator should be included in the results.
5563 */
5564 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5565
5566 /**
5567 * Completions for enum tags should be included in the results.
5568 */
5569 CXCompletionContext_EnumTag = 1 << 8,
5570 /**
5571 * Completions for union tags should be included in the results.
5572 */
5573 CXCompletionContext_UnionTag = 1 << 9,
5574 /**
5575 * Completions for struct tags should be included in the results.
5576 */
5577 CXCompletionContext_StructTag = 1 << 10,
5578
5579 /**
5580 * Completions for C++ class names should be included in the results.
5581 */
5582 CXCompletionContext_ClassTag = 1 << 11,
5583 /**
5584 * Completions for C++ namespaces and namespace aliases should be
5585 * included in the results.
5586 */
5587 CXCompletionContext_Namespace = 1 << 12,
5588 /**
5589 * Completions for C++ nested name specifiers should be included in
5590 * the results.
5591 */
5592 CXCompletionContext_NestedNameSpecifier = 1 << 13,
5593
5594 /**
5595 * Completions for Objective-C interfaces (classes) should be included
5596 * in the results.
5597 */
5598 CXCompletionContext_ObjCInterface = 1 << 14,
5599 /**
5600 * Completions for Objective-C protocols should be included in
5601 * the results.
5602 */
5603 CXCompletionContext_ObjCProtocol = 1 << 15,
5604 /**
5605 * Completions for Objective-C categories should be included in
5606 * the results.
5607 */
5608 CXCompletionContext_ObjCCategory = 1 << 16,
5609 /**
5610 * Completions for Objective-C instance messages should be included
5611 * in the results.
5612 */
5613 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5614 /**
5615 * Completions for Objective-C class messages should be included in
5616 * the results.
5617 */
5618 CXCompletionContext_ObjCClassMessage = 1 << 18,
5619 /**
5620 * Completions for Objective-C selector names should be included in
5621 * the results.
5622 */
5623 CXCompletionContext_ObjCSelectorName = 1 << 19,
5624
5625 /**
5626 * Completions for preprocessor macro names should be included in
5627 * the results.
5628 */
5629 CXCompletionContext_MacroName = 1 << 20,
5630
5631 /**
5632 * Natural language completions should be included in the results.
5633 */
5634 CXCompletionContext_NaturalLanguage = 1 << 21,
5635
5636 /**
5637 * #include file completions should be included in the results.
5638 */
5639 CXCompletionContext_IncludedFile = 1 << 22,
5640
5641 /**
5642 * The current context is unknown, so set all contexts.
5643 */
5644 CXCompletionContext_Unknown = ((1 << 23) - 1)
5645};
5646
5647/**
5648 * Returns a default set of code-completion options that can be
5649 * passed to\c clang_codeCompleteAt().
5650 */
5651CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5652
5653/**
5654 * Perform code completion at a given location in a translation unit.
5655 *
5656 * This function performs code completion at a particular file, line, and
5657 * column within source code, providing results that suggest potential
5658 * code snippets based on the context of the completion. The basic model
5659 * for code completion is that Clang will parse a complete source file,
5660 * performing syntax checking up to the location where code-completion has
5661 * been requested. At that point, a special code-completion token is passed
5662 * to the parser, which recognizes this token and determines, based on the
5663 * current location in the C/Objective-C/C++ grammar and the state of
5664 * semantic analysis, what completions to provide. These completions are
5665 * returned via a new \c CXCodeCompleteResults structure.
5666 *
5667 * Code completion itself is meant to be triggered by the client when the
5668 * user types punctuation characters or whitespace, at which point the
5669 * code-completion location will coincide with the cursor. For example, if \c p
5670 * is a pointer, code-completion might be triggered after the "-" and then
5671 * after the ">" in \c p->. When the code-completion location is after the ">",
5672 * the completion results will provide, e.g., the members of the struct that
5673 * "p" points to. The client is responsible for placing the cursor at the
5674 * beginning of the token currently being typed, then filtering the results
5675 * based on the contents of the token. For example, when code-completing for
5676 * the expression \c p->get, the client should provide the location just after
5677 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5678 * client can filter the results based on the current token text ("get"), only
5679 * showing those results that start with "get". The intent of this interface
5680 * is to separate the relatively high-latency acquisition of code-completion
5681 * results from the filtering of results on a per-character basis, which must
5682 * have a lower latency.
5683 *
5684 * \param TU The translation unit in which code-completion should
5685 * occur. The source files for this translation unit need not be
5686 * completely up-to-date (and the contents of those source files may
5687 * be overridden via \p unsaved_files). Cursors referring into the
5688 * translation unit may be invalidated by this invocation.
5689 *
5690 * \param complete_filename The name of the source file where code
5691 * completion should be performed. This filename may be any file
5692 * included in the translation unit.
5693 *
5694 * \param complete_line The line at which code-completion should occur.
5695 *
5696 * \param complete_column The column at which code-completion should occur.
5697 * Note that the column should point just after the syntactic construct that
5698 * initiated code completion, and not in the middle of a lexical token.
5699 *
5700 * \param unsaved_files the Files that have not yet been saved to disk
5701 * but may be required for parsing or code completion, including the
5702 * contents of those files. The contents and name of these files (as
5703 * specified by CXUnsavedFile) are copied when necessary, so the
5704 * client only needs to guarantee their validity until the call to
5705 * this function returns.
5706 *
5707 * \param num_unsaved_files The number of unsaved file entries in \p
5708 * unsaved_files.
5709 *
5710 * \param options Extra options that control the behavior of code
5711 * completion, expressed as a bitwise OR of the enumerators of the
5712 * CXCodeComplete_Flags enumeration. The
5713 * \c clang_defaultCodeCompleteOptions() function returns a default set
5714 * of code-completion options.
5715 *
5716 * \returns If successful, a new \c CXCodeCompleteResults structure
5717 * containing code-completion results, which should eventually be
5718 * freed with \c clang_disposeCodeCompleteResults(). If code
5719 * completion fails, returns NULL.
5720 */
5721CINDEX_LINKAGE
5722CXCodeCompleteResults *
5723clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
5724 unsigned complete_line, unsigned complete_column,
5725 struct CXUnsavedFile *unsaved_files,
5726 unsigned num_unsaved_files, unsigned options);
5727
5728/**
5729 * Sort the code-completion results in case-insensitive alphabetical
5730 * order.
5731 *
5732 * \param Results The set of results to sort.
5733 * \param NumResults The number of results in \p Results.
5734 */
5735CINDEX_LINKAGE
5736void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5737 unsigned NumResults);
5738
5739/**
5740 * Free the given set of code-completion results.
5741 */
5742CINDEX_LINKAGE
5743void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
5744
5745/**
5746 * Determine the number of diagnostics produced prior to the
5747 * location where code completion was performed.
5748 */
5749CINDEX_LINKAGE
5750unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5751
5752/**
5753 * Retrieve a diagnostic associated with the given code completion.
5754 *
5755 * \param Results the code completion results to query.
5756 * \param Index the zero-based diagnostic number to retrieve.
5757 *
5758 * \returns the requested diagnostic. This diagnostic must be freed
5759 * via a call to \c clang_disposeDiagnostic().
5760 */
5761CINDEX_LINKAGE
5762CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5763 unsigned Index);
5764
5765/**
5766 * Determines what completions are appropriate for the context
5767 * the given code completion.
5768 *
5769 * \param Results the code completion results to query
5770 *
5771 * \returns the kinds of completions that are appropriate for use
5772 * along with the given code completion results.
5773 */
5774CINDEX_LINKAGE
5775unsigned long long
5776clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
5777
5778/**
5779 * Returns the cursor kind for the container for the current code
5780 * completion context. The container is only guaranteed to be set for
5781 * contexts where a container exists (i.e. member accesses or Objective-C
5782 * message sends); if there is not a container, this function will return
5783 * CXCursor_InvalidCode.
5784 *
5785 * \param Results the code completion results to query
5786 *
5787 * \param IsIncomplete on return, this value will be false if Clang has complete
5788 * information about the container. If Clang does not have complete
5789 * information, this value will be true.
5790 *
5791 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5792 * container
5793 */
5794CINDEX_LINKAGE
5795enum CXCursorKind
5796clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
5797 unsigned *IsIncomplete);
5798
5799/**
5800 * Returns the USR for the container for the current code completion
5801 * context. If there is not a container for the current context, this
5802 * function will return the empty string.
5803 *
5804 * \param Results the code completion results to query
5805 *
5806 * \returns the USR for the container
5807 */
5808CINDEX_LINKAGE
5809CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5810
5811/**
5812 * Returns the currently-entered selector for an Objective-C message
5813 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5814 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5815 * CXCompletionContext_ObjCClassMessage.
5816 *
5817 * \param Results the code completion results to query
5818 *
5819 * \returns the selector (or partial selector) that has been entered thus far
5820 * for an Objective-C message send.
5821 */
5822CINDEX_LINKAGE
5823CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5824
5825/**
5826 * @}
5827 */
5828
5829/**
5830 * \defgroup CINDEX_MISC Miscellaneous utility functions
5831 *
5832 * @{
5833 */
5834
5835/**
5836 * Return a version string, suitable for showing to a user, but not
5837 * intended to be parsed (the format is not guaranteed to be stable).
5838 */
5839CINDEX_LINKAGE CXString clang_getClangVersion(void);
5840
5841/**
5842 * Enable/disable crash recovery.
5843 *
5844 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5845 * value enables crash recovery, while 0 disables it.
5846 */
5847CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5848
5849/**
5850 * Visitor invoked for each file in a translation unit
5851 * (used with clang_getInclusions()).
5852 *
5853 * This visitor function will be invoked by clang_getInclusions() for each
5854 * file included (either at the top-level or by \#include directives) within
5855 * a translation unit. The first argument is the file being included, and
5856 * the second and third arguments provide the inclusion stack. The
5857 * array is sorted in order of immediate inclusion. For example,
5858 * the first element refers to the location that included 'included_file'.
5859 */
5860typedef void (*CXInclusionVisitor)(CXFile included_file,
5861 CXSourceLocation *inclusion_stack,
5862 unsigned include_len,
5863 CXClientData client_data);
5864
5865/**
5866 * Visit the set of preprocessor inclusions in a translation unit.
5867 * The visitor function is called with the provided data for every included
5868 * file. This does not include headers included by the PCH file (unless one
5869 * is inspecting the inclusions in the PCH file itself).
5870 */
5871CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5872 CXInclusionVisitor visitor,
5873 CXClientData client_data);
5874
5875typedef enum {
5876 CXEval_Int = 1,
5877 CXEval_Float = 2,
5878 CXEval_ObjCStrLiteral = 3,
5879 CXEval_StrLiteral = 4,
5880 CXEval_CFStr = 5,
5881 CXEval_Other = 6,
5882
5883 CXEval_UnExposed = 0
5884
5885} CXEvalResultKind;
5886
5887/**
5888 * Evaluation result of a cursor
5889 */
5890typedef void *CXEvalResult;
5891
5892/**
5893 * If cursor is a statement declaration tries to evaluate the
5894 * statement and if its variable, tries to evaluate its initializer,
5895 * into its corresponding type.
5896 * If it's an expression, tries to evaluate the expression.
5897 */
5898CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5899
5900/**
5901 * Returns the kind of the evaluated result.
5902 */
5903CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
5904
5905/**
5906 * Returns the evaluation result as integer if the
5907 * kind is Int.
5908 */
5909CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5910
5911/**
5912 * Returns the evaluation result as a long long integer if the
5913 * kind is Int. This prevents overflows that may happen if the result is
5914 * returned with clang_EvalResult_getAsInt.
5915 */
5916CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5917
5918/**
5919 * Returns a non-zero value if the kind is Int and the evaluation
5920 * result resulted in an unsigned integer.
5921 */
5922CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5923
5924/**
5925 * Returns the evaluation result as an unsigned integer if
5926 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5927 */
5928CINDEX_LINKAGE unsigned long long
5929clang_EvalResult_getAsUnsigned(CXEvalResult E);
5930
5931/**
5932 * Returns the evaluation result as double if the
5933 * kind is double.
5934 */
5935CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5936
5937/**
5938 * Returns the evaluation result as a constant string if the
5939 * kind is other than Int or float. User must not free this pointer,
5940 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5941 * by clang_Cursor_Evaluate.
5942 */
5943CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
5944
5945/**
5946 * Disposes the created Eval memory.
5947 */
5948CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5949/**
5950 * @}
5951 */
5952
5953/** \defgroup CINDEX_HIGH Higher level API functions
5954 *
5955 * @{
5956 */
5957
5958enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
5959
5960typedef struct CXCursorAndRangeVisitor {
5961 void *context;
5962 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5963} CXCursorAndRangeVisitor;
5964
5965typedef enum {
5966 /**
5967 * Function returned successfully.
5968 */
5969 CXResult_Success = 0,
5970 /**
5971 * One of the parameters was invalid for the function.
5972 */
5973 CXResult_Invalid = 1,
5974 /**
5975 * The function was terminated by a callback (e.g. it returned
5976 * CXVisit_Break)
5977 */
5978 CXResult_VisitBreak = 2
5979
5980} CXResult;
5981
5982/**
5983 * Find references of a declaration in a specific file.
5984 *
5985 * \param cursor pointing to a declaration or a reference of one.
5986 *
5987 * \param file to search for references.
5988 *
5989 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5990 * each reference found.
5991 * The CXSourceRange will point inside the file; if the reference is inside
5992 * a macro (and not a macro argument) the CXSourceRange will be invalid.
5993 *
5994 * \returns one of the CXResult enumerators.
5995 */
5996CINDEX_LINKAGE CXResult clang_findReferencesInFile(
5997 CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
5998
5999/**
6000 * Find #import/#include directives in a specific file.
6001 *
6002 * \param TU translation unit containing the file to query.
6003 *
6004 * \param file to search for #import/#include directives.
6005 *
6006 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6007 * each directive found.
6008 *
6009 * \returns one of the CXResult enumerators.
6010 */
6011CINDEX_LINKAGE CXResult clang_findIncludesInFile(
6012 CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
6013
6014#if __has_feature(blocks)
6015typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
6016 CXSourceRange);
6017#else
6018typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;
6019#endif
6020
6021CINDEX_LINKAGE
6022CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6023 CXCursorAndRangeVisitorBlock);
6024
6025CINDEX_LINKAGE
6026CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6027 CXCursorAndRangeVisitorBlock);
6028
6029/**
6030 * The client's data object that is associated with a CXFile.
6031 */
6032typedef void *CXIdxClientFile;
6033
6034/**
6035 * The client's data object that is associated with a semantic entity.
6036 */
6037typedef void *CXIdxClientEntity;
6038
6039/**
6040 * The client's data object that is associated with a semantic container
6041 * of entities.
6042 */
6043typedef void *CXIdxClientContainer;
6044
6045/**
6046 * The client's data object that is associated with an AST file (PCH
6047 * or module).
6048 */
6049typedef void *CXIdxClientASTFile;
6050
6051/**
6052 * Source location passed to index callbacks.
6053 */
6054typedef struct {
6055 void *ptr_data[2];
6056 unsigned int_data;
6057} CXIdxLoc;
6058
6059/**
6060 * Data for ppIncludedFile callback.
6061 */
6062typedef struct {
6063 /**
6064 * Location of '#' in the \#include/\#import directive.
6065 */
6066 CXIdxLoc hashLoc;
6067 /**
6068 * Filename as written in the \#include/\#import directive.
6069 */
6070 const char *filename;
6071 /**
6072 * The actual file that the \#include/\#import directive resolved to.
6073 */
6074 CXFile file;
6075 int isImport;
6076 int isAngled;
6077 /**
6078 * Non-zero if the directive was automatically turned into a module
6079 * import.
6080 */
6081 int isModuleImport;
6082} CXIdxIncludedFileInfo;
6083
6084/**
6085 * Data for IndexerCallbacks#importedASTFile.
6086 */
6087typedef struct {
6088 /**
6089 * Top level AST file containing the imported PCH, module or submodule.
6090 */
6091 CXFile file;
6092 /**
6093 * The imported module or NULL if the AST file is a PCH.
6094 */
6095 CXModule module;
6096 /**
6097 * Location where the file is imported. Applicable only for modules.
6098 */
6099 CXIdxLoc loc;
6100 /**
6101 * Non-zero if an inclusion directive was automatically turned into
6102 * a module import. Applicable only for modules.
6103 */
6104 int isImplicit;
6105
6106} CXIdxImportedASTFileInfo;
6107
6108typedef enum {
6109 CXIdxEntity_Unexposed = 0,
6110 CXIdxEntity_Typedef = 1,
6111 CXIdxEntity_Function = 2,
6112 CXIdxEntity_Variable = 3,
6113 CXIdxEntity_Field = 4,
6114 CXIdxEntity_EnumConstant = 5,
6115
6116 CXIdxEntity_ObjCClass = 6,
6117 CXIdxEntity_ObjCProtocol = 7,
6118 CXIdxEntity_ObjCCategory = 8,
6119
6120 CXIdxEntity_ObjCInstanceMethod = 9,
6121 CXIdxEntity_ObjCClassMethod = 10,
6122 CXIdxEntity_ObjCProperty = 11,
6123 CXIdxEntity_ObjCIvar = 12,
6124
6125 CXIdxEntity_Enum = 13,
6126 CXIdxEntity_Struct = 14,
6127 CXIdxEntity_Union = 15,
6128
6129 CXIdxEntity_CXXClass = 16,
6130 CXIdxEntity_CXXNamespace = 17,
6131 CXIdxEntity_CXXNamespaceAlias = 18,
6132 CXIdxEntity_CXXStaticVariable = 19,
6133 CXIdxEntity_CXXStaticMethod = 20,
6134 CXIdxEntity_CXXInstanceMethod = 21,
6135 CXIdxEntity_CXXConstructor = 22,
6136 CXIdxEntity_CXXDestructor = 23,
6137 CXIdxEntity_CXXConversionFunction = 24,
6138 CXIdxEntity_CXXTypeAlias = 25,
6139 CXIdxEntity_CXXInterface = 26,
6140 CXIdxEntity_CXXConcept = 27
6141
6142} CXIdxEntityKind;
6143
6144typedef enum {
6145 CXIdxEntityLang_None = 0,
6146 CXIdxEntityLang_C = 1,
6147 CXIdxEntityLang_ObjC = 2,
6148 CXIdxEntityLang_CXX = 3,
6149 CXIdxEntityLang_Swift = 4
6150} CXIdxEntityLanguage;
6151
6152/**
6153 * Extra C++ template information for an entity. This can apply to:
6154 * CXIdxEntity_Function
6155 * CXIdxEntity_CXXClass
6156 * CXIdxEntity_CXXStaticMethod
6157 * CXIdxEntity_CXXInstanceMethod
6158 * CXIdxEntity_CXXConstructor
6159 * CXIdxEntity_CXXConversionFunction
6160 * CXIdxEntity_CXXTypeAlias
6161 */
6162typedef enum {
6163 CXIdxEntity_NonTemplate = 0,
6164 CXIdxEntity_Template = 1,
6165 CXIdxEntity_TemplatePartialSpecialization = 2,
6166 CXIdxEntity_TemplateSpecialization = 3
6167} CXIdxEntityCXXTemplateKind;
6168
6169typedef enum {
6170 CXIdxAttr_Unexposed = 0,
6171 CXIdxAttr_IBAction = 1,
6172 CXIdxAttr_IBOutlet = 2,
6173 CXIdxAttr_IBOutletCollection = 3
6174} CXIdxAttrKind;
6175
6176typedef struct {
6177 CXIdxAttrKind kind;
6178 CXCursor cursor;
6179 CXIdxLoc loc;
6180} CXIdxAttrInfo;
6181
6182typedef struct {
6183 CXIdxEntityKind kind;
6184 CXIdxEntityCXXTemplateKind templateKind;
6185 CXIdxEntityLanguage lang;
6186 const char *name;
6187 const char *USR;
6188 CXCursor cursor;
6189 const CXIdxAttrInfo *const *attributes;
6190 unsigned numAttributes;
6191} CXIdxEntityInfo;
6192
6193typedef struct {
6194 CXCursor cursor;
6195} CXIdxContainerInfo;
6196
6197typedef struct {
6198 const CXIdxAttrInfo *attrInfo;
6199 const CXIdxEntityInfo *objcClass;
6200 CXCursor classCursor;
6201 CXIdxLoc classLoc;
6202} CXIdxIBOutletCollectionAttrInfo;
6203
6204typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
6205
6206typedef struct {
6207 const CXIdxEntityInfo *entityInfo;
6208 CXCursor cursor;
6209 CXIdxLoc loc;
6210 const CXIdxContainerInfo *semanticContainer;
6211 /**
6212 * Generally same as #semanticContainer but can be different in
6213 * cases like out-of-line C++ member functions.
6214 */
6215 const CXIdxContainerInfo *lexicalContainer;
6216 int isRedeclaration;
6217 int isDefinition;
6218 int isContainer;
6219 const CXIdxContainerInfo *declAsContainer;
6220 /**
6221 * Whether the declaration exists in code or was created implicitly
6222 * by the compiler, e.g. implicit Objective-C methods for properties.
6223 */
6224 int isImplicit;
6225 const CXIdxAttrInfo *const *attributes;
6226 unsigned numAttributes;
6227
6228 unsigned flags;
6229
6230} CXIdxDeclInfo;
6231
6232typedef enum {
6233 CXIdxObjCContainer_ForwardRef = 0,
6234 CXIdxObjCContainer_Interface = 1,
6235 CXIdxObjCContainer_Implementation = 2
6236} CXIdxObjCContainerKind;
6237
6238typedef struct {
6239 const CXIdxDeclInfo *declInfo;
6240 CXIdxObjCContainerKind kind;
6241} CXIdxObjCContainerDeclInfo;
6242
6243typedef struct {
6244 const CXIdxEntityInfo *base;
6245 CXCursor cursor;
6246 CXIdxLoc loc;
6247} CXIdxBaseClassInfo;
6248
6249typedef struct {
6250 const CXIdxEntityInfo *protocol;
6251 CXCursor cursor;
6252 CXIdxLoc loc;
6253} CXIdxObjCProtocolRefInfo;
6254
6255typedef struct {
6256 const CXIdxObjCProtocolRefInfo *const *protocols;
6257 unsigned numProtocols;
6258} CXIdxObjCProtocolRefListInfo;
6259
6260typedef struct {
6261 const CXIdxObjCContainerDeclInfo *containerInfo;
6262 const CXIdxBaseClassInfo *superInfo;
6263 const CXIdxObjCProtocolRefListInfo *protocols;
6264} CXIdxObjCInterfaceDeclInfo;
6265
6266typedef struct {
6267 const CXIdxObjCContainerDeclInfo *containerInfo;
6268 const CXIdxEntityInfo *objcClass;
6269 CXCursor classCursor;
6270 CXIdxLoc classLoc;
6271 const CXIdxObjCProtocolRefListInfo *protocols;
6272} CXIdxObjCCategoryDeclInfo;
6273
6274typedef struct {
6275 const CXIdxDeclInfo *declInfo;
6276 const CXIdxEntityInfo *getter;
6277 const CXIdxEntityInfo *setter;
6278} CXIdxObjCPropertyDeclInfo;
6279
6280typedef struct {
6281 const CXIdxDeclInfo *declInfo;
6282 const CXIdxBaseClassInfo *const *bases;
6283 unsigned numBases;
6284} CXIdxCXXClassDeclInfo;
6285
6286/**
6287 * Data for IndexerCallbacks#indexEntityReference.
6288 *
6289 * This may be deprecated in a future version as this duplicates
6290 * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6291 */
6292typedef enum {
6293 /**
6294 * The entity is referenced directly in user's code.
6295 */
6296 CXIdxEntityRef_Direct = 1,
6297 /**
6298 * An implicit reference, e.g. a reference of an Objective-C method
6299 * via the dot syntax.
6300 */
6301 CXIdxEntityRef_Implicit = 2
6302} CXIdxEntityRefKind;
6303
6304/**
6305 * Roles that are attributed to symbol occurrences.
6306 *
6307 * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6308 * higher bits zeroed. These high bits may be exposed in the future.
6309 */
6310typedef enum {
6311 CXSymbolRole_None = 0,
6312 CXSymbolRole_Declaration = 1 << 0,
6313 CXSymbolRole_Definition = 1 << 1,
6314 CXSymbolRole_Reference = 1 << 2,
6315 CXSymbolRole_Read = 1 << 3,
6316 CXSymbolRole_Write = 1 << 4,
6317 CXSymbolRole_Call = 1 << 5,
6318 CXSymbolRole_Dynamic = 1 << 6,
6319 CXSymbolRole_AddressOf = 1 << 7,
6320 CXSymbolRole_Implicit = 1 << 8
6321} CXSymbolRole;
6322
6323/**
6324 * Data for IndexerCallbacks#indexEntityReference.
6325 */
6326typedef struct {
6327 CXIdxEntityRefKind kind;
6328 /**
6329 * Reference cursor.
6330 */
6331 CXCursor cursor;
6332 CXIdxLoc loc;
6333 /**
6334 * The entity that gets referenced.
6335 */
6336 const CXIdxEntityInfo *referencedEntity;
6337 /**
6338 * Immediate "parent" of the reference. For example:
6339 *
6340 * \code
6341 * Foo *var;
6342 * \endcode
6343 *
6344 * The parent of reference of type 'Foo' is the variable 'var'.
6345 * For references inside statement bodies of functions/methods,
6346 * the parentEntity will be the function/method.
6347 */
6348 const CXIdxEntityInfo *parentEntity;
6349 /**
6350 * Lexical container context of the reference.
6351 */
6352 const CXIdxContainerInfo *container;
6353 /**
6354 * Sets of symbol roles of the reference.
6355 */
6356 CXSymbolRole role;
6357} CXIdxEntityRefInfo;
6358
6359/**
6360 * A group of callbacks used by #clang_indexSourceFile and
6361 * #clang_indexTranslationUnit.
6362 */
6363typedef struct {
6364 /**
6365 * Called periodically to check whether indexing should be aborted.
6366 * Should return 0 to continue, and non-zero to abort.
6367 */
6368 int (*abortQuery)(CXClientData client_data, void *reserved);
6369
6370 /**
6371 * Called at the end of indexing; passes the complete diagnostic set.
6372 */
6373 void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
6374
6375 CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
6376 void *reserved);
6377
6378 /**
6379 * Called when a file gets \#included/\#imported.
6380 */
6381 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
6382 const CXIdxIncludedFileInfo *);
6383
6384 /**
6385 * Called when a AST file (PCH or module) gets imported.
6386 *
6387 * AST files will not get indexed (there will not be callbacks to index all
6388 * the entities in an AST file). The recommended action is that, if the AST
6389 * file is not already indexed, to initiate a new indexing job specific to
6390 * the AST file.
6391 */
6392 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
6393 const CXIdxImportedASTFileInfo *);
6394
6395 /**
6396 * Called at the beginning of indexing a translation unit.
6397 */
6398 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
6399 void *reserved);
6400
6401 void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
6402
6403 /**
6404 * Called to index a reference of an entity.
6405 */
6406 void (*indexEntityReference)(CXClientData client_data,
6407 const CXIdxEntityRefInfo *);
6408
6409} IndexerCallbacks;
6410
6411CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6412CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6413clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
6414
6415CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6416clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6417
6418CINDEX_LINKAGE
6419const CXIdxObjCCategoryDeclInfo *
6420clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6421
6422CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6423clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
6424
6425CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6426clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6427
6428CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6429clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6430
6431CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6432clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6433
6434/**
6435 * For retrieving a custom CXIdxClientContainer attached to a
6436 * container.
6437 */
6438CINDEX_LINKAGE CXIdxClientContainer
6439clang_index_getClientContainer(const CXIdxContainerInfo *);
6440
6441/**
6442 * For setting a custom CXIdxClientContainer attached to a
6443 * container.
6444 */
6445CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
6446 CXIdxClientContainer);
6447
6448/**
6449 * For retrieving a custom CXIdxClientEntity attached to an entity.
6450 */
6451CINDEX_LINKAGE CXIdxClientEntity
6452clang_index_getClientEntity(const CXIdxEntityInfo *);
6453
6454/**
6455 * For setting a custom CXIdxClientEntity attached to an entity.
6456 */
6457CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
6458 CXIdxClientEntity);
6459
6460/**
6461 * An indexing action/session, to be applied to one or multiple
6462 * translation units.
6463 */
6464typedef void *CXIndexAction;
6465
6466/**
6467 * An indexing action/session, to be applied to one or multiple
6468 * translation units.
6469 *
6470 * \param CIdx The index object with which the index action will be associated.
6471 */
6472CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6473
6474/**
6475 * Destroy the given index action.
6476 *
6477 * The index action must not be destroyed until all of the translation units
6478 * created within that index action have been destroyed.
6479 */
6480CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6481
6482typedef enum {
6483 /**
6484 * Used to indicate that no special indexing options are needed.
6485 */
6486 CXIndexOpt_None = 0x0,
6487
6488 /**
6489 * Used to indicate that IndexerCallbacks#indexEntityReference should
6490 * be invoked for only one reference of an entity per source file that does
6491 * not also include a declaration/definition of the entity.
6492 */
6493 CXIndexOpt_SuppressRedundantRefs = 0x1,
6494
6495 /**
6496 * Function-local symbols should be indexed. If this is not set
6497 * function-local symbols will be ignored.
6498 */
6499 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6500
6501 /**
6502 * Implicit function/class template instantiations should be indexed.
6503 * If this is not set, implicit instantiations will be ignored.
6504 */
6505 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6506
6507 /**
6508 * Suppress all compiler warnings when parsing for indexing.
6509 */
6510 CXIndexOpt_SuppressWarnings = 0x8,
6511
6512 /**
6513 * Skip a function/method body that was already parsed during an
6514 * indexing session associated with a \c CXIndexAction object.
6515 * Bodies in system headers are always skipped.
6516 */
6517 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6518
6519} CXIndexOptFlags;
6520
6521/**
6522 * Index the given source file and the translation unit corresponding
6523 * to that file via callbacks implemented through #IndexerCallbacks.
6524 *
6525 * \param client_data pointer data supplied by the client, which will
6526 * be passed to the invoked callbacks.
6527 *
6528 * \param index_callbacks Pointer to indexing callbacks that the client
6529 * implements.
6530 *
6531 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6532 * passed in index_callbacks.
6533 *
6534 * \param index_options A bitmask of options that affects how indexing is
6535 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6536 *
6537 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6538 * reused after indexing is finished. Set to \c NULL if you do not require it.
6539 *
6540 * \returns 0 on success or if there were errors from which the compiler could
6541 * recover. If there is a failure from which there is no recovery, returns
6542 * a non-zero \c CXErrorCode.
6543 *
6544 * The rest of the parameters are the same as #clang_parseTranslationUnit.
6545 */
6546CINDEX_LINKAGE int clang_indexSourceFile(
6547 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6548 unsigned index_callbacks_size, unsigned index_options,
6549 const char *source_filename, const char *const *command_line_args,
6550 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6551 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6552
6553/**
6554 * Same as clang_indexSourceFile but requires a full command line
6555 * for \c command_line_args including argv[0]. This is useful if the standard
6556 * library paths are relative to the binary.
6557 */
6558CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6559 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6560 unsigned index_callbacks_size, unsigned index_options,
6561 const char *source_filename, const char *const *command_line_args,
6562 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6563 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6564
6565/**
6566 * Index the given translation unit via callbacks implemented through
6567 * #IndexerCallbacks.
6568 *
6569 * The order of callback invocations is not guaranteed to be the same as
6570 * when indexing a source file. The high level order will be:
6571 *
6572 * -Preprocessor callbacks invocations
6573 * -Declaration/reference callbacks invocations
6574 * -Diagnostic callback invocations
6575 *
6576 * The parameters are the same as #clang_indexSourceFile.
6577 *
6578 * \returns If there is a failure from which there is no recovery, returns
6579 * non-zero, otherwise returns 0.
6580 */
6581CINDEX_LINKAGE int clang_indexTranslationUnit(
6582 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6583 unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
6584
6585/**
6586 * Retrieve the CXIdxFile, file, line, column, and offset represented by
6587 * the given CXIdxLoc.
6588 *
6589 * If the location refers into a macro expansion, retrieves the
6590 * location of the macro expansion and if it refers into a macro argument
6591 * retrieves the location of the argument.
6592 */
6593CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6594 CXIdxClientFile *indexFile,
6595 CXFile *file, unsigned *line,
6596 unsigned *column,
6597 unsigned *offset);
6598
6599/**
6600 * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6601 */
6602CINDEX_LINKAGE
6603CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6604
6605/**
6606 * Visitor invoked for each field found by a traversal.
6607 *
6608 * This visitor function will be invoked for each field found by
6609 * \c clang_Type_visitFields. Its first argument is the cursor being
6610 * visited, its second argument is the client data provided to
6611 * \c clang_Type_visitFields.
6612 *
6613 * The visitor should return one of the \c CXVisitorResult values
6614 * to direct \c clang_Type_visitFields.
6615 */
6616typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6617 CXClientData client_data);
6618
6619/**
6620 * Visit the fields of a particular type.
6621 *
6622 * This function visits all the direct fields of the given cursor,
6623 * invoking the given \p visitor function with the cursors of each
6624 * visited field. The traversal may be ended prematurely, if
6625 * the visitor returns \c CXFieldVisit_Break.
6626 *
6627 * \param T the record type whose field may be visited.
6628 *
6629 * \param visitor the visitor function that will be invoked for each
6630 * field of \p T.
6631 *
6632 * \param client_data pointer data supplied by the client, which will
6633 * be passed to the visitor each time it is invoked.
6634 *
6635 * \returns a non-zero value if the traversal was terminated
6636 * prematurely by the visitor returning \c CXFieldVisit_Break.
6637 */
6638CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
6639 CXClientData client_data);
6640
6641/**
6642 * Visit the base classes of a type.
6643 *
6644 * This function visits all the direct base classes of a the given cursor,
6645 * invoking the given \p visitor function with the cursors of each
6646 * visited base. The traversal may be ended prematurely, if
6647 * the visitor returns \c CXFieldVisit_Break.
6648 *
6649 * \param T the record type whose field may be visited.
6650 *
6651 * \param visitor the visitor function that will be invoked for each
6652 * field of \p T.
6653 *
6654 * \param client_data pointer data supplied by the client, which will
6655 * be passed to the visitor each time it is invoked.
6656 *
6657 * \returns a non-zero value if the traversal was terminated
6658 * prematurely by the visitor returning \c CXFieldVisit_Break.
6659 */
6660CINDEX_LINKAGE unsigned clang_visitCXXBaseClasses(CXType T,
6661 CXFieldVisitor visitor,
6662 CXClientData client_data);
6663
6664/**
6665 * Visit the class methods of a type.
6666 *
6667 * This function visits all the methods of the given cursor,
6668 * invoking the given \p visitor function with the cursors of each
6669 * visited method. The traversal may be ended prematurely, if
6670 * the visitor returns \c CXFieldVisit_Break.
6671 *
6672 * \param T The record type whose field may be visited.
6673 *
6674 * \param visitor The visitor function that will be invoked for each
6675 * field of \p T.
6676 *
6677 * \param client_data Pointer data supplied by the client, which will
6678 * be passed to the visitor each time it is invoked.
6679 *
6680 * \returns A non-zero value if the traversal was terminated
6681 * prematurely by the visitor returning \c CXFieldVisit_Break.
6682 */
6683CINDEX_LINKAGE unsigned clang_visitCXXMethods(CXType T, CXFieldVisitor visitor,
6684 CXClientData client_data);
6685
6686/**
6687 * Describes the kind of binary operators.
6688 */
6689enum CXBinaryOperatorKind {
6690 /** This value describes cursors which are not binary operators. */
6691 CXBinaryOperator_Invalid = 0,
6692 /** C++ Pointer - to - member operator. */
6693 CXBinaryOperator_PtrMemD = 1,
6694 /** C++ Pointer - to - member operator. */
6695 CXBinaryOperator_PtrMemI = 2,
6696 /** Multiplication operator. */
6697 CXBinaryOperator_Mul = 3,
6698 /** Division operator. */
6699 CXBinaryOperator_Div = 4,
6700 /** Remainder operator. */
6701 CXBinaryOperator_Rem = 5,
6702 /** Addition operator. */
6703 CXBinaryOperator_Add = 6,
6704 /** Subtraction operator. */
6705 CXBinaryOperator_Sub = 7,
6706 /** Bitwise shift left operator. */
6707 CXBinaryOperator_Shl = 8,
6708 /** Bitwise shift right operator. */
6709 CXBinaryOperator_Shr = 9,
6710 /** C++ three-way comparison (spaceship) operator. */
6711 CXBinaryOperator_Cmp = 10,
6712 /** Less than operator. */
6713 CXBinaryOperator_LT = 11,
6714 /** Greater than operator. */
6715 CXBinaryOperator_GT = 12,
6716 /** Less or equal operator. */
6717 CXBinaryOperator_LE = 13,
6718 /** Greater or equal operator. */
6719 CXBinaryOperator_GE = 14,
6720 /** Equal operator. */
6721 CXBinaryOperator_EQ = 15,
6722 /** Not equal operator. */
6723 CXBinaryOperator_NE = 16,
6724 /** Bitwise AND operator. */
6725 CXBinaryOperator_And = 17,
6726 /** Bitwise XOR operator. */
6727 CXBinaryOperator_Xor = 18,
6728 /** Bitwise OR operator. */
6729 CXBinaryOperator_Or = 19,
6730 /** Logical AND operator. */
6731 CXBinaryOperator_LAnd = 20,
6732 /** Logical OR operator. */
6733 CXBinaryOperator_LOr = 21,
6734 /** Assignment operator. */
6735 CXBinaryOperator_Assign = 22,
6736 /** Multiplication assignment operator. */
6737 CXBinaryOperator_MulAssign = 23,
6738 /** Division assignment operator. */
6739 CXBinaryOperator_DivAssign = 24,
6740 /** Remainder assignment operator. */
6741 CXBinaryOperator_RemAssign = 25,
6742 /** Addition assignment operator. */
6743 CXBinaryOperator_AddAssign = 26,
6744 /** Subtraction assignment operator. */
6745 CXBinaryOperator_SubAssign = 27,
6746 /** Bitwise shift left assignment operator. */
6747 CXBinaryOperator_ShlAssign = 28,
6748 /** Bitwise shift right assignment operator. */
6749 CXBinaryOperator_ShrAssign = 29,
6750 /** Bitwise AND assignment operator. */
6751 CXBinaryOperator_AndAssign = 30,
6752 /** Bitwise XOR assignment operator. */
6753 CXBinaryOperator_XorAssign = 31,
6754 /** Bitwise OR assignment operator. */
6755 CXBinaryOperator_OrAssign = 32,
6756 /** Comma operator. */
6757 CXBinaryOperator_Comma = 33,
6758 CXBinaryOperator_Last = CXBinaryOperator_Comma
6759};
6760
6761/**
6762 * Retrieve the spelling of a given CXBinaryOperatorKind.
6763 */
6764CINDEX_LINKAGE CXString
6765clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind);
6766
6767/**
6768 * Retrieve the binary operator kind of this cursor.
6769 *
6770 * If this cursor is not a binary operator then returns Invalid.
6771 */
6772CINDEX_LINKAGE enum CXBinaryOperatorKind
6773clang_getCursorBinaryOperatorKind(CXCursor cursor);
6774
6775/**
6776 * Describes the kind of unary operators.
6777 */
6778enum CXUnaryOperatorKind {
6779 /** This value describes cursors which are not unary operators. */
6780 CXUnaryOperator_Invalid,
6781 /** Postfix increment operator. */
6782 CXUnaryOperator_PostInc,
6783 /** Postfix decrement operator. */
6784 CXUnaryOperator_PostDec,
6785 /** Prefix increment operator. */
6786 CXUnaryOperator_PreInc,
6787 /** Prefix decrement operator. */
6788 CXUnaryOperator_PreDec,
6789 /** Address of operator. */
6790 CXUnaryOperator_AddrOf,
6791 /** Dereference operator. */
6792 CXUnaryOperator_Deref,
6793 /** Plus operator. */
6794 CXUnaryOperator_Plus,
6795 /** Minus operator. */
6796 CXUnaryOperator_Minus,
6797 /** Not operator. */
6798 CXUnaryOperator_Not,
6799 /** LNot operator. */
6800 CXUnaryOperator_LNot,
6801 /** "__real expr" operator. */
6802 CXUnaryOperator_Real,
6803 /** "__imag expr" operator. */
6804 CXUnaryOperator_Imag,
6805 /** __extension__ marker operator. */
6806 CXUnaryOperator_Extension,
6807 /** C++ co_await operator. */
6808 CXUnaryOperator_Coawait
6809};
6810
6811/**
6812 * Retrieve the spelling of a given CXUnaryOperatorKind.
6813 */
6814CINDEX_LINKAGE CXString
6815clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind);
6816
6817/**
6818 * Retrieve the unary operator kind of this cursor.
6819 *
6820 * If this cursor is not a unary operator then returns Invalid.
6821 */
6822CINDEX_LINKAGE enum CXUnaryOperatorKind
6823clang_getCursorUnaryOperatorKind(CXCursor cursor);
6824
6825/**
6826 * @}
6827 */
6828
6829/**
6830 * @}
6831 */
6832
6833LLVM_CLANG_C_EXTERN_C_END
6834
6835#endif
6836

source code of clang/include/clang-c/Index.h