clang 17.0.0git
Index.h
Go to the documentation of this file.
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"
21#include "clang-c/CXErrorCode.h"
22#include "clang-c/CXFile.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
52
53/** \defgroup CINDEX libclang: C Interface to Clang
54 *
55 * The C Interface to Clang provides a relatively small API that exposes
56 * facilities for parsing source code into an abstract syntax tree (AST),
57 * loading already-parsed ASTs, traversing the AST, associating
58 * physical source locations with elements within the AST, and other
59 * facilities that support Clang-based development tools.
60 *
61 * This C interface to Clang will never provide all of the information
62 * representation stored in Clang's C++ AST, nor should it: the intent is to
63 * maintain an API that is relatively stable from one release to the next,
64 * providing only the basic functionality needed to support development tools.
65 *
66 * To avoid namespace pollution, data types are prefixed with "CX" and
67 * functions are prefixed with "clang_".
68 *
69 * @{
70 */
71
72/**
73 * An "index" that consists of a set of translation units that would
74 * typically be linked together into an executable or library.
75 */
76typedef void *CXIndex;
77
78/**
79 * An opaque type representing target information for a given translation
80 * unit.
81 */
82typedef struct CXTargetInfoImpl *CXTargetInfo;
83
84/**
85 * A single translation unit, which resides in an index.
86 */
87typedef struct CXTranslationUnitImpl *CXTranslationUnit;
88
89/**
90 * Opaque pointer representing client data that will be passed through
91 * to various callbacks and visitors.
92 */
93typedef void *CXClientData;
94
95/**
96 * Provides the contents of a file that has not yet been saved to disk.
97 *
98 * Each CXUnsavedFile instance provides the name of a file on the
99 * system along with the current contents of that file that have not
100 * yet been saved to disk.
101 */
103 /**
104 * The file whose contents have not yet been saved.
105 *
106 * This file must already exist in the file system.
107 */
108 const char *Filename;
109
110 /**
111 * A buffer containing the unsaved contents of this file.
112 */
113 const char *Contents;
114
115 /**
116 * The length of the unsaved contents of this buffer.
117 */
118 unsigned long Length;
119};
120
121/**
122 * Describes the availability of a particular entity, which indicates
123 * whether the use of this entity will result in a warning or error due to
124 * it being deprecated or unavailable.
125 */
127 /**
128 * The entity is available.
129 */
131 /**
132 * The entity is available, but has been deprecated (and its use is
133 * not recommended).
134 */
136 /**
137 * The entity is not available; any use of it will be an error.
138 */
140 /**
141 * The entity is available, but not accessible; any use of it will be
142 * an error.
143 */
146
147/**
148 * Describes a version number of the form major.minor.subminor.
149 */
150typedef struct CXVersion {
151 /**
152 * The major version number, e.g., the '10' in '10.7.3'. A negative
153 * value indicates that there is no version number at all.
154 */
155 int Major;
156 /**
157 * The minor version number, e.g., the '7' in '10.7.3'. This value
158 * will be negative if no minor version number was provided, e.g., for
159 * version '10'.
160 */
161 int Minor;
162 /**
163 * The subminor version number, e.g., the '3' in '10.7.3'. This value
164 * will be negative if no minor or subminor version number was provided,
165 * e.g., in version '10' or '10.7'.
166 */
169
170/**
171 * Describes the exception specification of a cursor.
172 *
173 * A negative value indicates that the cursor is not a function declaration.
174 */
176 /**
177 * The cursor has no exception specification.
178 */
180
181 /**
182 * The cursor has exception specification throw()
183 */
185
186 /**
187 * The cursor has exception specification throw(T1, T2)
188 */
190
191 /**
192 * The cursor has exception specification throw(...).
193 */
195
196 /**
197 * The cursor has exception specification basic noexcept.
198 */
200
201 /**
202 * The cursor has exception specification computed noexcept.
203 */
205
206 /**
207 * The exception specification has not yet been evaluated.
208 */
210
211 /**
212 * The exception specification has not yet been instantiated.
213 */
215
216 /**
217 * The exception specification has not been parsed yet.
218 */
220
221 /**
222 * The cursor has a __declspec(nothrow) exception specification.
223 */
226
227/**
228 * Provides a shared context for creating translation units.
229 *
230 * It provides two options:
231 *
232 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
233 * declarations (when loading any new translation units). A "local" declaration
234 * is one that belongs in the translation unit itself and not in a precompiled
235 * header that was used by the translation unit. If zero, all declarations
236 * will be enumerated.
237 *
238 * Here is an example:
239 *
240 * \code
241 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
242 * Idx = clang_createIndex(1, 1);
243 *
244 * // IndexTest.pch was produced with the following command:
245 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
246 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
247 *
248 * // This will load all the symbols from 'IndexTest.pch'
249 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
250 * TranslationUnitVisitor, 0);
251 * clang_disposeTranslationUnit(TU);
252 *
253 * // This will load all the symbols from 'IndexTest.c', excluding symbols
254 * // from 'IndexTest.pch'.
255 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
256 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
257 * 0, 0);
258 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
259 * TranslationUnitVisitor, 0);
260 * clang_disposeTranslationUnit(TU);
261 * \endcode
262 *
263 * This process of creating the 'pch', loading it separately, and using it (via
264 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
265 * (which gives the indexer the same performance benefit as the compiler).
266 */
267CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
268 int displayDiagnostics);
269
270/**
271 * Destroy the given index.
272 *
273 * The index must not be destroyed until all of the translation units created
274 * within that index have been destroyed.
275 */
277
278typedef enum {
279 /**
280 * Use the default value of an option that may depend on the process
281 * environment.
282 */
284 /**
285 * Enable the option.
286 */
288 /**
289 * Disable the option.
290 */
293
294typedef enum {
295 /**
296 * Used to indicate that no special CXIndex options are needed.
297 */
299
300 /**
301 * Used to indicate that threads that libclang creates for indexing
302 * purposes should use background priority.
303 *
304 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
305 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
306 */
308
309 /**
310 * Used to indicate that threads that libclang creates for editing
311 * purposes should use background priority.
312 *
313 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
314 * #clang_annotateTokens
315 */
317
318 /**
319 * Used to indicate that all threads that libclang creates should use
320 * background priority.
321 */
325
327
328/**
329 * Index initialization options.
330 *
331 * 0 is the default value of each member of this struct except for Size.
332 * Initialize the struct in one of the following three ways to avoid adapting
333 * code each time a new member is added to it:
334 * \code
335 * CXIndexOptions Opts;
336 * memset(&Opts, 0, sizeof(Opts));
337 * Opts.Size = sizeof(CXIndexOptions);
338 * \endcode
339 * or explicitly initialize the first data member and zero-initialize the rest:
340 * \code
341 * CXIndexOptions Opts = { sizeof(CXIndexOptions) };
342 * \endcode
343 * or to prevent the -Wmissing-field-initializers warning for the above version:
344 * \code
345 * CXIndexOptions Opts{};
346 * Opts.Size = sizeof(CXIndexOptions);
347 * \endcode
348 */
349typedef struct CXIndexOptions {
350 /**
351 * The size of struct CXIndexOptions used for option versioning.
352 *
353 * Always initialize this member to sizeof(CXIndexOptions), or assign
354 * sizeof(CXIndexOptions) to it right after creating a CXIndexOptions object.
355 */
356 unsigned Size;
357 /**
358 * A CXChoice enumerator that specifies the indexing priority policy.
359 * \sa CXGlobalOpt_ThreadBackgroundPriorityForIndexing
360 */
362 /**
363 * A CXChoice enumerator that specifies the editing priority policy.
364 * \sa CXGlobalOpt_ThreadBackgroundPriorityForEditing
365 */
367 /**
368 * \see clang_createIndex()
369 */
371 /**
372 * \see clang_createIndex()
373 */
374 unsigned DisplayDiagnostics : 1;
375 /**
376 * Store PCH in memory. If zero, PCH are stored in temporary files.
377 */
379 unsigned /*Reserved*/ : 13;
380
381 /**
382 * The path to a directory, in which to store temporary PCH files. If null or
383 * empty, the default system temporary directory is used. These PCH files are
384 * deleted on clean exit but stay on disk if the program crashes or is killed.
385 *
386 * This option is ignored if \a StorePreamblesInMemory is non-zero.
387 *
388 * Libclang does not create the directory at the specified path in the file
389 * system. Therefore it must exist, or storing PCH files will fail.
390 */
392 /**
393 * Specifies a path which will contain log files for certain libclang
394 * invocations. A null value implies that libclang invocations are not logged.
395 */
398
399/**
400 * Provides a shared context for creating translation units.
401 *
402 * Call this function instead of clang_createIndex() if you need to configure
403 * the additional options in CXIndexOptions.
404 *
405 * \returns The created index or null in case of error, such as an unsupported
406 * value of options->Size.
407 *
408 * For example:
409 * \code
410 * CXIndex createIndex(const char *ApplicationTemporaryPath) {
411 * const int ExcludeDeclarationsFromPCH = 1;
412 * const int DisplayDiagnostics = 1;
413 * CXIndex Idx;
414 * #if CINDEX_VERSION_MINOR >= 64
415 * CXIndexOptions Opts;
416 * memset(&Opts, 0, sizeof(Opts));
417 * Opts.Size = sizeof(CXIndexOptions);
418 * Opts.ThreadBackgroundPriorityForIndexing = 1;
419 * Opts.ExcludeDeclarationsFromPCH = ExcludeDeclarationsFromPCH;
420 * Opts.DisplayDiagnostics = DisplayDiagnostics;
421 * Opts.PreambleStoragePath = ApplicationTemporaryPath;
422 * Idx = clang_createIndexWithOptions(&Opts);
423 * if (Idx)
424 * return Idx;
425 * fprintf(stderr,
426 * "clang_createIndexWithOptions() failed. "
427 * "CINDEX_VERSION_MINOR = %d, sizeof(CXIndexOptions) = %u\n",
428 * CINDEX_VERSION_MINOR, Opts.Size);
429 * #else
430 * (void)ApplicationTemporaryPath;
431 * #endif
432 * Idx = clang_createIndex(ExcludeDeclarationsFromPCH, DisplayDiagnostics);
433 * clang_CXIndex_setGlobalOptions(
434 * Idx, clang_CXIndex_getGlobalOptions(Idx) |
435 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
436 * return Idx;
437 * }
438 * \endcode
439 *
440 * \sa clang_createIndex()
441 */
444
445/**
446 * Sets general options associated with a CXIndex.
447 *
448 * This function is DEPRECATED. Set
449 * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
450 * CXIndexOptions::ThreadBackgroundPriorityForEditing and call
451 * clang_createIndexWithOptions() instead.
452 *
453 * For example:
454 * \code
455 * CXIndex idx = ...;
456 * clang_CXIndex_setGlobalOptions(idx,
457 * clang_CXIndex_getGlobalOptions(idx) |
458 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
459 * \endcode
460 *
461 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
462 */
464
465/**
466 * Gets the general options associated with a CXIndex.
467 *
468 * This function allows to obtain the final option values used by libclang after
469 * specifying the option policies via CXChoice enumerators.
470 *
471 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
472 * are associated with the given CXIndex object.
473 */
475
476/**
477 * Sets the invocation emission path option in a CXIndex.
478 *
479 * This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and
480 * call clang_createIndexWithOptions() instead.
481 *
482 * The invocation emission path specifies a path which will contain log
483 * files for certain libclang invocations. A null value (default) implies that
484 * libclang invocations are not logged..
485 */
488
489/**
490 * Determine whether the given header is guarded against
491 * multiple inclusions, either with the conventional
492 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
493 */
495 CXFile file);
496
497/**
498 * Retrieve a file handle within the given translation unit.
499 *
500 * \param tu the translation unit
501 *
502 * \param file_name the name of the file.
503 *
504 * \returns the file handle for the named file in the translation unit \p tu,
505 * or a NULL file handle if the file was not a part of this translation unit.
506 */
508 const char *file_name);
509
510/**
511 * Retrieve the buffer associated with the given file.
512 *
513 * \param tu the translation unit
514 *
515 * \param file the file for which to retrieve the buffer.
516 *
517 * \param size [out] if non-NULL, will be set to the size of the buffer.
518 *
519 * \returns a pointer to the buffer in memory that holds the contents of
520 * \p file, or a NULL pointer when the file is not loaded.
521 */
523 CXFile file, size_t *size);
524
525/**
526 * Retrieves the source location associated with a given file/line/column
527 * in a particular translation unit.
528 */
530 CXFile file, unsigned line,
531 unsigned column);
532/**
533 * Retrieves the source location associated with a given character offset
534 * in a particular translation unit.
535 */
537 CXFile file,
538 unsigned offset);
539
540/**
541 * Retrieve all ranges that were skipped by the preprocessor.
542 *
543 * The preprocessor will skip lines when they are surrounded by an
544 * if/ifdef/ifndef directive whose condition does not evaluate to true.
545 */
547 CXFile file);
548
549/**
550 * Retrieve all ranges from all files that were skipped by the
551 * preprocessor.
552 *
553 * The preprocessor will skip lines when they are surrounded by an
554 * if/ifdef/ifndef directive whose condition does not evaluate to true.
555 */
558
559/**
560 * Determine the number of diagnostics produced for the given
561 * translation unit.
562 */
564
565/**
566 * Retrieve a diagnostic associated with the given translation unit.
567 *
568 * \param Unit the translation unit to query.
569 * \param Index the zero-based diagnostic number to retrieve.
570 *
571 * \returns the requested diagnostic. This diagnostic must be freed
572 * via a call to \c clang_disposeDiagnostic().
573 */
575 unsigned Index);
576
577/**
578 * Retrieve the complete set of diagnostics associated with a
579 * translation unit.
580 *
581 * \param Unit the translation unit to query.
582 */
585
586/**
587 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
588 *
589 * The routines in this group provide the ability to create and destroy
590 * translation units from files, either by parsing the contents of the files or
591 * by reading in a serialized representation of a translation unit.
592 *
593 * @{
594 */
595
596/**
597 * Get the original translation unit source file name.
598 */
601
602/**
603 * Return the CXTranslationUnit for a given source file and the provided
604 * command line arguments one would pass to the compiler.
605 *
606 * Note: The 'source_filename' argument is optional. If the caller provides a
607 * NULL pointer, the name of the source file is expected to reside in the
608 * specified command line arguments.
609 *
610 * Note: When encountered in 'clang_command_line_args', the following options
611 * are ignored:
612 *
613 * '-c'
614 * '-emit-ast'
615 * '-fsyntax-only'
616 * '-o <output file>' (both '-o' and '<output file>' are ignored)
617 *
618 * \param CIdx The index object with which the translation unit will be
619 * associated.
620 *
621 * \param source_filename The name of the source file to load, or NULL if the
622 * source file is included in \p clang_command_line_args.
623 *
624 * \param num_clang_command_line_args The number of command-line arguments in
625 * \p clang_command_line_args.
626 *
627 * \param clang_command_line_args The command-line arguments that would be
628 * passed to the \c clang executable if it were being invoked out-of-process.
629 * These command-line options will be parsed and will affect how the translation
630 * unit is parsed. Note that the following options are ignored: '-c',
631 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
632 *
633 * \param num_unsaved_files the number of unsaved file entries in \p
634 * unsaved_files.
635 *
636 * \param unsaved_files the files that have not yet been saved to disk
637 * but may be required for code completion, including the contents of
638 * those files. The contents and name of these files (as specified by
639 * CXUnsavedFile) are copied when necessary, so the client only needs to
640 * guarantee their validity until the call to this function returns.
641 */
643 CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
644 const char *const *clang_command_line_args, unsigned num_unsaved_files,
645 struct CXUnsavedFile *unsaved_files);
646
647/**
648 * Same as \c clang_createTranslationUnit2, but returns
649 * the \c CXTranslationUnit instead of an error code. In case of an error this
650 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
651 * error codes.
652 */
654clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
655
656/**
657 * Create a translation unit from an AST file (\c -emit-ast).
658 *
659 * \param[out] out_TU A non-NULL pointer to store the created
660 * \c CXTranslationUnit.
661 *
662 * \returns Zero on success, otherwise returns an error code.
663 */
665clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
666 CXTranslationUnit *out_TU);
667
668/**
669 * Flags that control the creation of translation units.
670 *
671 * The enumerators in this enumeration type are meant to be bitwise
672 * ORed together to specify which options should be used when
673 * constructing the translation unit.
674 */
676 /**
677 * Used to indicate that no special translation-unit options are
678 * needed.
679 */
681
682 /**
683 * Used to indicate that the parser should construct a "detailed"
684 * preprocessing record, including all macro definitions and instantiations.
685 *
686 * Constructing a detailed preprocessing record requires more memory
687 * and time to parse, since the information contained in the record
688 * is usually not retained. However, it can be useful for
689 * applications that require more detailed information about the
690 * behavior of the preprocessor.
691 */
693
694 /**
695 * Used to indicate that the translation unit is incomplete.
696 *
697 * When a translation unit is considered "incomplete", semantic
698 * analysis that is typically performed at the end of the
699 * translation unit will be suppressed. For example, this suppresses
700 * the completion of tentative declarations in C and of
701 * instantiation of implicitly-instantiation function templates in
702 * C++. This option is typically used when parsing a header with the
703 * intent of producing a precompiled header.
704 */
706
707 /**
708 * Used to indicate that the translation unit should be built with an
709 * implicit precompiled header for the preamble.
710 *
711 * An implicit precompiled header is used as an optimization when a
712 * particular translation unit is likely to be reparsed many times
713 * when the sources aren't changing that often. In this case, an
714 * implicit precompiled header will be built containing all of the
715 * initial includes at the top of the main file (what we refer to as
716 * the "preamble" of the file). In subsequent parses, if the
717 * preamble or the files in it have not changed, \c
718 * clang_reparseTranslationUnit() will re-use the implicit
719 * precompiled header to improve parsing performance.
720 */
722
723 /**
724 * Used to indicate that the translation unit should cache some
725 * code-completion results with each reparse of the source file.
726 *
727 * Caching of code-completion results is a performance optimization that
728 * introduces some overhead to reparsing but improves the performance of
729 * code-completion operations.
730 */
732
733 /**
734 * Used to indicate that the translation unit will be serialized with
735 * \c clang_saveTranslationUnit.
736 *
737 * This option is typically used when parsing a header with the intent of
738 * producing a precompiled header.
739 */
741
742 /**
743 * DEPRECATED: Enabled chained precompiled preambles in C++.
744 *
745 * Note: this is a *temporary* option that is available only while
746 * we are testing C++ precompiled preamble support. It is deprecated.
747 */
749
750 /**
751 * Used to indicate that function/method bodies should be skipped while
752 * parsing.
753 *
754 * This option can be used to search for declarations/definitions while
755 * ignoring the usages.
756 */
758
759 /**
760 * Used to indicate that brief documentation comments should be
761 * included into the set of code completions returned from this translation
762 * unit.
763 */
765
766 /**
767 * Used to indicate that the precompiled preamble should be created on
768 * the first parse. Otherwise it will be created on the first reparse. This
769 * trades runtime on the first parse (serializing the preamble takes time) for
770 * reduced runtime on the second parse (can now reuse the preamble).
771 */
773
774 /**
775 * Do not stop processing when fatal errors are encountered.
776 *
777 * When fatal errors are encountered while parsing a translation unit,
778 * semantic analysis is typically stopped early when compiling code. A common
779 * source for fatal errors are unresolvable include files. For the
780 * purposes of an IDE, this is undesirable behavior and as much information
781 * as possible should be reported. Use this flag to enable this behavior.
782 */
784
785 /**
786 * Sets the preprocessor in a mode for parsing a single file only.
787 */
789
790 /**
791 * Used in combination with CXTranslationUnit_SkipFunctionBodies to
792 * constrain the skipping of function bodies to the preamble.
793 *
794 * The function bodies of the main file are not skipped.
795 */
797
798 /**
799 * Used to indicate that attributed types should be included in CXType.
800 */
802
803 /**
804 * Used to indicate that implicit attributes should be visited.
805 */
807
808 /**
809 * Used to indicate that non-errors from included files should be ignored.
810 *
811 * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
812 * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
813 * the case where these warnings are not of interest, as for an IDE for
814 * example, which typically shows only the diagnostics in the main file.
815 */
817
818 /**
819 * Tells the preprocessor not to skip excluded conditional blocks.
820 */
823
824/**
825 * Returns the set of flags that is suitable for parsing a translation
826 * unit that is being edited.
827 *
828 * The set of flags returned provide options for \c clang_parseTranslationUnit()
829 * to indicate that the translation unit is likely to be reparsed many times,
830 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
831 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
832 * set contains an unspecified set of optimizations (e.g., the precompiled
833 * preamble) geared toward improving the performance of these routines. The
834 * set of optimizations enabled may change from one version to the next.
835 */
837
838/**
839 * Same as \c clang_parseTranslationUnit2, but returns
840 * the \c CXTranslationUnit instead of an error code. In case of an error this
841 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
842 * error codes.
843 */
845 CXIndex CIdx, const char *source_filename,
846 const char *const *command_line_args, int num_command_line_args,
847 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
848 unsigned options);
849
850/**
851 * Parse the given source file and the translation unit corresponding
852 * to that file.
853 *
854 * This routine is the main entry point for the Clang C API, providing the
855 * ability to parse a source file into a translation unit that can then be
856 * queried by other functions in the API. This routine accepts a set of
857 * command-line arguments so that the compilation can be configured in the same
858 * way that the compiler is configured on the command line.
859 *
860 * \param CIdx The index object with which the translation unit will be
861 * associated.
862 *
863 * \param source_filename The name of the source file to load, or NULL if the
864 * source file is included in \c command_line_args.
865 *
866 * \param command_line_args The command-line arguments that would be
867 * passed to the \c clang executable if it were being invoked out-of-process.
868 * These command-line options will be parsed and will affect how the translation
869 * unit is parsed. Note that the following options are ignored: '-c',
870 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
871 *
872 * \param num_command_line_args The number of command-line arguments in
873 * \c command_line_args.
874 *
875 * \param unsaved_files the files that have not yet been saved to disk
876 * but may be required for parsing, including the contents of
877 * those files. The contents and name of these files (as specified by
878 * CXUnsavedFile) are copied when necessary, so the client only needs to
879 * guarantee their validity until the call to this function returns.
880 *
881 * \param num_unsaved_files the number of unsaved file entries in \p
882 * unsaved_files.
883 *
884 * \param options A bitmask of options that affects how the translation unit
885 * is managed but not its compilation. This should be a bitwise OR of the
886 * CXTranslationUnit_XXX flags.
887 *
888 * \param[out] out_TU A non-NULL pointer to store the created
889 * \c CXTranslationUnit, describing the parsed code and containing any
890 * diagnostics produced by the compiler.
891 *
892 * \returns Zero on success, otherwise returns an error code.
893 */
895 CXIndex CIdx, const char *source_filename,
896 const char *const *command_line_args, int num_command_line_args,
897 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
898 unsigned options, CXTranslationUnit *out_TU);
899
900/**
901 * Same as clang_parseTranslationUnit2 but requires a full command line
902 * for \c command_line_args including argv[0]. This is useful if the standard
903 * library paths are relative to the binary.
904 */
906 CXIndex CIdx, const char *source_filename,
907 const char *const *command_line_args, int num_command_line_args,
908 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
909 unsigned options, CXTranslationUnit *out_TU);
910
911/**
912 * Flags that control how translation units are saved.
913 *
914 * The enumerators in this enumeration type are meant to be bitwise
915 * ORed together to specify which options should be used when
916 * saving the translation unit.
917 */
919 /**
920 * Used to indicate that no special saving options are needed.
921 */
924
925/**
926 * Returns the set of flags that is suitable for saving a translation
927 * unit.
928 *
929 * The set of flags returned provide options for
930 * \c clang_saveTranslationUnit() by default. The returned flag
931 * set contains an unspecified set of options that save translation units with
932 * the most commonly-requested data.
933 */
935
936/**
937 * Describes the kind of error that occurred (if any) in a call to
938 * \c clang_saveTranslationUnit().
939 */
941 /**
942 * Indicates that no error occurred while saving a translation unit.
943 */
945
946 /**
947 * Indicates that an unknown error occurred while attempting to save
948 * the file.
949 *
950 * This error typically indicates that file I/O failed when attempting to
951 * write the file.
952 */
954
955 /**
956 * Indicates that errors during translation prevented this attempt
957 * to save the translation unit.
958 *
959 * Errors that prevent the translation unit from being saved can be
960 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
961 */
963
964 /**
965 * Indicates that the translation unit to be saved was somehow
966 * invalid (e.g., NULL).
967 */
970
971/**
972 * Saves a translation unit into a serialized representation of
973 * that translation unit on disk.
974 *
975 * Any translation unit that was parsed without error can be saved
976 * into a file. The translation unit can then be deserialized into a
977 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
978 * if it is an incomplete translation unit that corresponds to a
979 * header, used as a precompiled header when parsing other translation
980 * units.
981 *
982 * \param TU The translation unit to save.
983 *
984 * \param FileName The file to which the translation unit will be saved.
985 *
986 * \param options A bitmask of options that affects how the translation unit
987 * is saved. This should be a bitwise OR of the
988 * CXSaveTranslationUnit_XXX flags.
989 *
990 * \returns A value that will match one of the enumerators of the CXSaveError
991 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
992 * saved successfully, while a non-zero value indicates that a problem occurred.
993 */
995 const char *FileName,
996 unsigned options);
997
998/**
999 * Suspend a translation unit in order to free memory associated with it.
1000 *
1001 * A suspended translation unit uses significantly less memory but on the other
1002 * side does not support any other calls than \c clang_reparseTranslationUnit
1003 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1004 */
1006
1007/**
1008 * Destroy the specified CXTranslationUnit object.
1009 */
1011
1012/**
1013 * Flags that control the reparsing of translation units.
1014 *
1015 * The enumerators in this enumeration type are meant to be bitwise
1016 * ORed together to specify which options should be used when
1017 * reparsing the translation unit.
1018 */
1020 /**
1021 * Used to indicate that no special reparsing options are needed.
1022 */
1023 CXReparse_None = 0x0
1025
1026/**
1027 * Returns the set of flags that is suitable for reparsing a translation
1028 * unit.
1029 *
1030 * The set of flags returned provide options for
1031 * \c clang_reparseTranslationUnit() by default. The returned flag
1032 * set contains an unspecified set of optimizations geared toward common uses
1033 * of reparsing. The set of optimizations enabled may change from one version
1034 * to the next.
1035 */
1037
1038/**
1039 * Reparse the source files that produced this translation unit.
1040 *
1041 * This routine can be used to re-parse the source files that originally
1042 * created the given translation unit, for example because those source files
1043 * have changed (either on disk or as passed via \p unsaved_files). The
1044 * source code will be reparsed with the same command-line options as it
1045 * was originally parsed.
1046 *
1047 * Reparsing a translation unit invalidates all cursors and source locations
1048 * that refer into that translation unit. This makes reparsing a translation
1049 * unit semantically equivalent to destroying the translation unit and then
1050 * creating a new translation unit with the same command-line arguments.
1051 * However, it may be more efficient to reparse a translation
1052 * unit using this routine.
1053 *
1054 * \param TU The translation unit whose contents will be re-parsed. The
1055 * translation unit must originally have been built with
1056 * \c clang_createTranslationUnitFromSourceFile().
1057 *
1058 * \param num_unsaved_files The number of unsaved file entries in \p
1059 * unsaved_files.
1060 *
1061 * \param unsaved_files The files that have not yet been saved to disk
1062 * but may be required for parsing, including the contents of
1063 * those files. The contents and name of these files (as specified by
1064 * CXUnsavedFile) are copied when necessary, so the client only needs to
1065 * guarantee their validity until the call to this function returns.
1066 *
1067 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1068 * The function \c clang_defaultReparseOptions() produces a default set of
1069 * options recommended for most uses, based on the translation unit.
1070 *
1071 * \returns 0 if the sources could be reparsed. A non-zero error code will be
1072 * returned if reparsing was impossible, such that the translation unit is
1073 * invalid. In such cases, the only valid call for \c TU is
1074 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1075 * routine are described by the \c CXErrorCode enum.
1076 */
1079 struct CXUnsavedFile *unsaved_files,
1080 unsigned options);
1081
1082/**
1083 * Categorizes how memory is being used by a translation unit.
1084 */
1103
1107
1108/**
1109 * Returns the human-readable null-terminated C string that represents
1110 * the name of the memory category. This string should never be freed.
1111 */
1114
1116 /* The memory usage category. */
1118 /* Amount of resources used.
1119 The units will depend on the resource kind. */
1120 unsigned long amount;
1122
1123/**
1124 * The memory usage of a CXTranslationUnit, broken into categories.
1125 */
1126typedef struct CXTUResourceUsage {
1127 /* Private data member, used for queries. */
1128 void *data;
1129
1130 /* The number of entries in the 'entries' array. */
1131 unsigned numEntries;
1132
1133 /* An array of key-value pairs, representing the breakdown of memory
1134 usage. */
1136
1138
1139/**
1140 * Return the memory usage of a translation unit. This object
1141 * should be released with clang_disposeCXTUResourceUsage().
1142 */
1145
1147
1148/**
1149 * Get target information for this translation unit.
1150 *
1151 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1152 */
1155
1156/**
1157 * Destroy the CXTargetInfo object.
1158 */
1160
1161/**
1162 * Get the normalized target triple as a string.
1163 *
1164 * Returns the empty string in case of any error.
1165 */
1167
1168/**
1169 * Get the pointer width of the target in bits.
1170 *
1171 * Returns -1 in case of error.
1172 */
1174
1175/**
1176 * @}
1177 */
1178
1179/**
1180 * Describes the kind of entity that a cursor refers to.
1181 */
1183 /* Declarations */
1184 /**
1185 * A declaration whose specific kind is not exposed via this
1186 * interface.
1187 *
1188 * Unexposed declarations have the same operations as any other kind
1189 * of declaration; one can extract their location information,
1190 * spelling, find their definitions, etc. However, the specific kind
1191 * of the declaration is not reported.
1192 */
1194 /** A C or C++ struct. */
1196 /** A C or C++ union. */
1198 /** A C++ class. */
1200 /** An enumeration. */
1202 /**
1203 * A field (in C) or non-static data member (in C++) in a
1204 * struct, union, or C++ class.
1205 */
1207 /** An enumerator constant. */
1209 /** A function. */
1211 /** A variable. */
1213 /** A function or method parameter. */
1215 /** An Objective-C \@interface. */
1217 /** An Objective-C \@interface for a category. */
1219 /** An Objective-C \@protocol declaration. */
1221 /** An Objective-C \@property declaration. */
1223 /** An Objective-C instance variable. */
1225 /** An Objective-C instance method. */
1227 /** An Objective-C class method. */
1229 /** An Objective-C \@implementation. */
1231 /** An Objective-C \@implementation for a category. */
1233 /** A typedef. */
1235 /** A C++ class method. */
1237 /** A C++ namespace. */
1239 /** A linkage specification, e.g. 'extern "C"'. */
1241 /** A C++ constructor. */
1243 /** A C++ destructor. */
1245 /** A C++ conversion function. */
1247 /** A C++ template type parameter. */
1249 /** A C++ non-type template parameter. */
1251 /** A C++ template template parameter. */
1253 /** A C++ function template. */
1255 /** A C++ class template. */
1257 /** A C++ class template partial specialization. */
1259 /** A C++ namespace alias declaration. */
1261 /** A C++ using directive. */
1263 /** A C++ using declaration. */
1265 /** A C++ alias declaration */
1267 /** An Objective-C \@synthesize definition. */
1269 /** An Objective-C \@dynamic definition. */
1271 /** An access specifier. */
1273
1276
1277 /* References */
1278 CXCursor_FirstRef = 40, /* Decl references */
1282 /**
1283 * A reference to a type declaration.
1284 *
1285 * A type reference occurs anywhere where a type is named but not
1286 * declared. For example, given:
1287 *
1288 * \code
1289 * typedef unsigned size_type;
1290 * size_type size;
1291 * \endcode
1292 *
1293 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1294 * while the type of the variable "size" is referenced. The cursor
1295 * referenced by the type of size is the typedef for size_type.
1296 */
1299 /**
1300 * A reference to a class template, function template, template
1301 * template parameter, or class template partial specialization.
1302 */
1304 /**
1305 * A reference to a namespace or namespace alias.
1306 */
1308 /**
1309 * A reference to a member of a struct, union, or class that occurs in
1310 * some non-expression context, e.g., a designated initializer.
1311 */
1313 /**
1314 * A reference to a labeled statement.
1315 *
1316 * This cursor kind is used to describe the jump to "start_over" in the
1317 * goto statement in the following example:
1318 *
1319 * \code
1320 * start_over:
1321 * ++counter;
1322 *
1323 * goto start_over;
1324 * \endcode
1325 *
1326 * A label reference cursor refers to a label statement.
1327 */
1329
1330 /**
1331 * A reference to a set of overloaded functions or function templates
1332 * that has not yet been resolved to a specific function or function template.
1333 *
1334 * An overloaded declaration reference cursor occurs in C++ templates where
1335 * a dependent name refers to a function. For example:
1336 *
1337 * \code
1338 * template<typename T> void swap(T&, T&);
1339 *
1340 * struct X { ... };
1341 * void swap(X&, X&);
1342 *
1343 * template<typename T>
1344 * void reverse(T* first, T* last) {
1345 * while (first < last - 1) {
1346 * swap(*first, *--last);
1347 * ++first;
1348 * }
1349 * }
1350 *
1351 * struct Y { };
1352 * void swap(Y&, Y&);
1353 * \endcode
1354 *
1355 * Here, the identifier "swap" is associated with an overloaded declaration
1356 * reference. In the template definition, "swap" refers to either of the two
1357 * "swap" functions declared above, so both results will be available. At
1358 * instantiation time, "swap" may also refer to other functions found via
1359 * argument-dependent lookup (e.g., the "swap" function at the end of the
1360 * example).
1361 *
1362 * The functions \c clang_getNumOverloadedDecls() and
1363 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1364 * referenced by this cursor.
1365 */
1367
1368 /**
1369 * A reference to a variable that occurs in some non-expression
1370 * context, e.g., a C++ lambda capture list.
1371 */
1373
1375
1376 /* Error conditions */
1383
1384 /* Expressions */
1386
1387 /**
1388 * An expression whose specific kind is not exposed via this
1389 * interface.
1390 *
1391 * Unexposed expressions have the same operations as any other kind
1392 * of expression; one can extract their location information,
1393 * spelling, children, etc. However, the specific kind of the
1394 * expression is not reported.
1395 */
1397
1398 /**
1399 * An expression that refers to some value declaration, such
1400 * as a function, variable, or enumerator.
1401 */
1403
1404 /**
1405 * An expression that refers to a member of a struct, union,
1406 * class, Objective-C class, etc.
1407 */
1409
1410 /** An expression that calls a function. */
1412
1413 /** An expression that sends a message to an Objective-C
1414 object or class. */
1416
1417 /** An expression that represents a block literal. */
1419
1420 /** An integer literal.
1421 */
1423
1424 /** A floating point number literal.
1425 */
1427
1428 /** An imaginary number literal.
1429 */
1431
1432 /** A string literal.
1433 */
1435
1436 /** A character literal.
1437 */
1439
1440 /** A parenthesized expression, e.g. "(1)".
1441 *
1442 * This AST node is only formed if full location information is requested.
1443 */
1445
1446 /** This represents the unary-expression's (except sizeof and
1447 * alignof).
1448 */
1450
1451 /** [C99 6.5.2.1] Array Subscripting.
1452 */
1454
1455 /** A builtin binary operation expression such as "x + y" or
1456 * "x <= y".
1457 */
1459
1460 /** Compound assignment such as "+=".
1461 */
1463
1464 /** The ?: ternary operator.
1465 */
1467
1468 /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1469 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1470 *
1471 * For example: (int)f.
1472 */
1474
1475 /** [C99 6.5.2.5]
1476 */
1478
1479 /** Describes an C or C++ initializer list.
1480 */
1482
1483 /** The GNU address of label extension, representing &&label.
1484 */
1486
1487 /** This is the GNU Statement Expression extension: ({int X=4; X;})
1488 */
1490
1491 /** Represents a C11 generic selection.
1492 */
1494
1495 /** Implements the GNU __null extension, which is a name for a null
1496 * pointer constant that has integral type (e.g., int or long) and is the same
1497 * size and alignment as a pointer.
1498 *
1499 * The __null extension is typically only used by system headers, which define
1500 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1501 * match the size of a pointer).
1502 */
1504
1505 /** C++'s static_cast<> expression.
1506 */
1508
1509 /** C++'s dynamic_cast<> expression.
1510 */
1512
1513 /** C++'s reinterpret_cast<> expression.
1514 */
1516
1517 /** C++'s const_cast<> expression.
1518 */
1520
1521 /** Represents an explicit C++ type conversion that uses "functional"
1522 * notion (C++ [expr.type.conv]).
1523 *
1524 * Example:
1525 * \code
1526 * x = int(0.5);
1527 * \endcode
1528 */
1530
1531 /** A C++ typeid expression (C++ [expr.typeid]).
1532 */
1534
1535 /** [C++ 2.13.5] C++ Boolean Literal.
1536 */
1538
1539 /** [C++0x 2.14.7] C++ Pointer Literal.
1540 */
1542
1543 /** Represents the "this" expression in C++
1544 */
1546
1547 /** [C++ 15] C++ Throw Expression.
1548 *
1549 * This handles 'throw' and 'throw' assignment-expression. When
1550 * assignment-expression isn't present, Op will be null.
1551 */
1553
1554 /** A new expression for memory allocation and constructor calls, e.g:
1555 * "new CXXNewExpr(foo)".
1556 */
1558
1559 /** A delete expression for memory deallocation and destructor calls,
1560 * e.g. "delete[] pArray".
1561 */
1563
1564 /** A unary expression. (noexcept, sizeof, or other traits)
1565 */
1567
1568 /** An Objective-C string literal i.e. @"foo".
1569 */
1571
1572 /** An Objective-C \@encode expression.
1573 */
1575
1576 /** An Objective-C \@selector expression.
1577 */
1579
1580 /** An Objective-C \@protocol expression.
1581 */
1583
1584 /** An Objective-C "bridged" cast expression, which casts between
1585 * Objective-C pointers and C pointers, transferring ownership in the process.
1586 *
1587 * \code
1588 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
1589 * \endcode
1590 */
1592
1593 /** Represents a C++0x pack expansion that produces a sequence of
1594 * expressions.
1595 *
1596 * A pack expansion expression contains a pattern (which itself is an
1597 * expression) followed by an ellipsis. For example:
1598 *
1599 * \code
1600 * template<typename F, typename ...Types>
1601 * void forward(F f, Types &&...args) {
1602 * f(static_cast<Types&&>(args)...);
1603 * }
1604 * \endcode
1605 */
1607
1608 /** Represents an expression that computes the length of a parameter
1609 * pack.
1610 *
1611 * \code
1612 * template<typename ...Types>
1613 * struct count {
1614 * static const unsigned value = sizeof...(Types);
1615 * };
1616 * \endcode
1617 */
1619
1620 /* Represents a C++ lambda expression that produces a local function
1621 * object.
1622 *
1623 * \code
1624 * void abssort(float *x, unsigned N) {
1625 * std::sort(x, x + N,
1626 * [](float a, float b) {
1627 * return std::abs(a) < std::abs(b);
1628 * });
1629 * }
1630 * \endcode
1631 */
1633
1634 /** Objective-c Boolean Literal.
1635 */
1637
1638 /** Represents the "self" expression in an Objective-C method.
1639 */
1641
1642 /** OpenMP 5.0 [2.1.5, Array Section].
1643 */
1645
1646 /** Represents an @available(...) check.
1647 */
1649
1650 /**
1651 * Fixed point literal
1652 */
1654
1655 /** OpenMP 5.0 [2.1.4, Array Shaping].
1656 */
1658
1659 /**
1660 * OpenMP 5.0 [2.1.6 Iterators]
1661 */
1663
1664 /** OpenCL's addrspace_cast<> expression.
1665 */
1667
1668 /**
1669 * Expression that references a C++20 concept.
1670 */
1672
1673 /**
1674 * Expression that references a C++20 concept.
1675 */
1677
1678 /**
1679 * Expression that references a C++20 parenthesized list aggregate
1680 * initializer.
1681 */
1683
1685
1686 /* Statements */
1688 /**
1689 * A statement whose specific kind is not exposed via this
1690 * interface.
1691 *
1692 * Unexposed statements have the same operations as any other kind of
1693 * statement; one can extract their location information, spelling,
1694 * children, etc. However, the specific kind of the statement is not
1695 * reported.
1696 */
1698
1699 /** A labelled statement in a function.
1700 *
1701 * This cursor kind is used to describe the "start_over:" label statement in
1702 * the following example:
1703 *
1704 * \code
1705 * start_over:
1706 * ++counter;
1707 * \endcode
1708 *
1709 */
1711
1712 /** A group of statements like { stmt stmt }.
1713 *
1714 * This cursor kind is used to describe compound statements, e.g. function
1715 * bodies.
1716 */
1718
1719 /** A case statement.
1720 */
1722
1723 /** A default statement.
1724 */
1726
1727 /** An if statement
1728 */
1730
1731 /** A switch statement.
1732 */
1734
1735 /** A while statement.
1736 */
1738
1739 /** A do statement.
1740 */
1742
1743 /** A for statement.
1744 */
1746
1747 /** A goto statement.
1748 */
1750
1751 /** An indirect goto statement.
1752 */
1754
1755 /** A continue statement.
1756 */
1758
1759 /** A break statement.
1760 */
1762
1763 /** A return statement.
1764 */
1766
1767 /** A GCC inline assembly statement extension.
1768 */
1771
1772 /** Objective-C's overall \@try-\@catch-\@finally statement.
1773 */
1775
1776 /** Objective-C's \@catch statement.
1777 */
1779
1780 /** Objective-C's \@finally statement.
1781 */
1783
1784 /** Objective-C's \@throw statement.
1785 */
1787
1788 /** Objective-C's \@synchronized statement.
1789 */
1791
1792 /** Objective-C's autorelease pool statement.
1793 */
1795
1796 /** Objective-C's collection statement.
1797 */
1799
1800 /** C++'s catch statement.
1801 */
1803
1804 /** C++'s try statement.
1805 */
1807
1808 /** C++'s for (* : *) statement.
1809 */
1811
1812 /** Windows Structured Exception Handling's try statement.
1813 */
1815
1816 /** Windows Structured Exception Handling's except statement.
1817 */
1819
1820 /** Windows Structured Exception Handling's finally statement.
1821 */
1823
1824 /** A MS inline assembly statement extension.
1825 */
1827
1828 /** The null statement ";": C99 6.8.3p3.
1829 *
1830 * This cursor kind is used to describe the null statement.
1831 */
1833
1834 /** Adaptor class for mixing declarations with statements and
1835 * expressions.
1836 */
1838
1839 /** OpenMP parallel directive.
1840 */
1842
1843 /** OpenMP SIMD directive.
1844 */
1846
1847 /** OpenMP for directive.
1848 */
1850
1851 /** OpenMP sections directive.
1852 */
1854
1855 /** OpenMP section directive.
1856 */
1858
1859 /** OpenMP single directive.
1860 */
1862
1863 /** OpenMP parallel for directive.
1864 */
1866
1867 /** OpenMP parallel sections directive.
1868 */
1870
1871 /** OpenMP task directive.
1872 */
1874
1875 /** OpenMP master directive.
1876 */
1878
1879 /** OpenMP critical directive.
1880 */
1882
1883 /** OpenMP taskyield directive.
1884 */
1886
1887 /** OpenMP barrier directive.
1888 */
1890
1891 /** OpenMP taskwait directive.
1892 */
1894
1895 /** OpenMP flush directive.
1896 */
1898
1899 /** Windows Structured Exception Handling's leave statement.
1900 */
1902
1903 /** OpenMP ordered directive.
1904 */
1906
1907 /** OpenMP atomic directive.
1908 */
1910
1911 /** OpenMP for SIMD directive.
1912 */
1914
1915 /** OpenMP parallel for SIMD directive.
1916 */
1918
1919 /** OpenMP target directive.
1920 */
1922
1923 /** OpenMP teams directive.
1924 */
1926
1927 /** OpenMP taskgroup directive.
1928 */
1930
1931 /** OpenMP cancellation point directive.
1932 */
1934
1935 /** OpenMP cancel directive.
1936 */
1938
1939 /** OpenMP target data directive.
1940 */
1942
1943 /** OpenMP taskloop directive.
1944 */
1946
1947 /** OpenMP taskloop simd directive.
1948 */
1950
1951 /** OpenMP distribute directive.
1952 */
1954
1955 /** OpenMP target enter data directive.
1956 */
1958
1959 /** OpenMP target exit data directive.
1960 */
1962
1963 /** OpenMP target parallel directive.
1964 */
1966
1967 /** OpenMP target parallel for directive.
1968 */
1970
1971 /** OpenMP target update directive.
1972 */
1974
1975 /** OpenMP distribute parallel for directive.
1976 */
1978
1979 /** OpenMP distribute parallel for simd directive.
1980 */
1982
1983 /** OpenMP distribute simd directive.
1984 */
1986
1987 /** OpenMP target parallel for simd directive.
1988 */
1990
1991 /** OpenMP target simd directive.
1992 */
1994
1995 /** OpenMP teams distribute directive.
1996 */
1998
1999 /** OpenMP teams distribute simd directive.
2000 */
2002
2003 /** OpenMP teams distribute parallel for simd directive.
2004 */
2006
2007 /** OpenMP teams distribute parallel for directive.
2008 */
2010
2011 /** OpenMP target teams directive.
2012 */
2014
2015 /** OpenMP target teams distribute directive.
2016 */
2018
2019 /** OpenMP target teams distribute parallel for directive.
2020 */
2022
2023 /** OpenMP target teams distribute parallel for simd directive.
2024 */
2026
2027 /** OpenMP target teams distribute simd directive.
2028 */
2030
2031 /** C++2a std::bit_cast expression.
2032 */
2034
2035 /** OpenMP master taskloop directive.
2036 */
2038
2039 /** OpenMP parallel master taskloop directive.
2040 */
2042
2043 /** OpenMP master taskloop simd directive.
2044 */
2046
2047 /** OpenMP parallel master taskloop simd directive.
2048 */
2050
2051 /** OpenMP parallel master directive.
2052 */
2054
2055 /** OpenMP depobj directive.
2056 */
2058
2059 /** OpenMP scan directive.
2060 */
2062
2063 /** OpenMP tile directive.
2064 */
2066
2067 /** OpenMP canonical loop.
2068 */
2070
2071 /** OpenMP interop directive.
2072 */
2074
2075 /** OpenMP dispatch directive.
2076 */
2078
2079 /** OpenMP masked directive.
2080 */
2082
2083 /** OpenMP unroll directive.
2084 */
2086
2087 /** OpenMP metadirective directive.
2088 */
2090
2091 /** OpenMP loop directive.
2092 */
2094
2095 /** OpenMP teams loop directive.
2096 */
2098
2099 /** OpenMP target teams loop directive.
2100 */
2102
2103 /** OpenMP parallel loop directive.
2104 */
2106
2107 /** OpenMP target parallel loop directive.
2108 */
2110
2111 /** OpenMP parallel masked directive.
2112 */
2114
2115 /** OpenMP masked taskloop directive.
2116 */
2118
2119 /** OpenMP masked taskloop simd directive.
2120 */
2122
2123 /** OpenMP parallel masked taskloop directive.
2124 */
2126
2127 /** OpenMP parallel masked taskloop simd directive.
2128 */
2130
2131 /** OpenMP error directive.
2132 */
2134
2136
2137 /**
2138 * Cursor that represents the translation unit itself.
2139 *
2140 * The translation unit cursor exists primarily to act as the root
2141 * cursor for traversing the contents of a translation unit.
2142 */
2144
2145 /* Attributes */
2147 /**
2148 * An attribute whose specific kind is not exposed via this
2149 * interface.
2150 */
2152
2195
2196 /* Preprocessing */
2204
2205 /* Extra Declarations */
2206 /**
2207 * A module import declaration.
2208 */
2211 /**
2212 * A static_assert or _Static_assert node
2213 */
2215 /**
2216 * a friend declaration.
2217 */
2219 /**
2220 * a concept declaration.
2221 */
2223
2226
2227 /**
2228 * A code completion overload candidate.
2229 */
2232
2233/**
2234 * A cursor representing some element in the abstract syntax tree for
2235 * a translation unit.
2236 *
2237 * The cursor abstraction unifies the different kinds of entities in a
2238 * program--declaration, statements, expressions, references to declarations,
2239 * etc.--under a single "cursor" abstraction with a common set of operations.
2240 * Common operation for a cursor include: getting the physical location in
2241 * a source file where the cursor points, getting the name associated with a
2242 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2243 *
2244 * Cursors can be produced in two specific ways.
2245 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2246 * from which one can use clang_visitChildren() to explore the rest of the
2247 * translation unit. clang_getCursor() maps from a physical source location
2248 * to the entity that resides at that location, allowing one to map from the
2249 * source code into the AST.
2250 */
2251typedef struct {
2254 const void *data[3];
2255} CXCursor;
2256
2257/**
2258 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2259 *
2260 * @{
2261 */
2262
2263/**
2264 * Retrieve the NULL cursor, which represents no entity.
2265 */
2267
2268/**
2269 * Retrieve the cursor that represents the given translation unit.
2270 *
2271 * The translation unit cursor can be used to start traversing the
2272 * various declarations within the given translation unit.
2273 */
2275
2276/**
2277 * Determine whether two cursors are equivalent.
2278 */
2280
2281/**
2282 * Returns non-zero if \p cursor is null.
2283 */
2285
2286/**
2287 * Compute a hash value for the given cursor.
2288 */
2290
2291/**
2292 * Retrieve the kind of the given cursor.
2293 */
2295
2296/**
2297 * Determine whether the given cursor kind represents a declaration.
2298 */
2300
2301/**
2302 * Determine whether the given declaration is invalid.
2303 *
2304 * A declaration is invalid if it could not be parsed successfully.
2305 *
2306 * \returns non-zero if the cursor represents a declaration and it is
2307 * invalid, otherwise NULL.
2308 */
2310
2311/**
2312 * Determine whether the given cursor kind represents a simple
2313 * reference.
2314 *
2315 * Note that other kinds of cursors (such as expressions) can also refer to
2316 * other cursors. Use clang_getCursorReferenced() to determine whether a
2317 * particular cursor refers to another entity.
2318 */
2320
2321/**
2322 * Determine whether the given cursor kind represents an expression.
2323 */
2325
2326/**
2327 * Determine whether the given cursor kind represents a statement.
2328 */
2330
2331/**
2332 * Determine whether the given cursor kind represents an attribute.
2333 */
2335
2336/**
2337 * Determine whether the given cursor has any attributes.
2338 */
2340
2341/**
2342 * Determine whether the given cursor kind represents an invalid
2343 * cursor.
2344 */
2346
2347/**
2348 * Determine whether the given cursor kind represents a translation
2349 * unit.
2350 */
2352
2353/***
2354 * Determine whether the given cursor represents a preprocessing
2355 * element, such as a preprocessor directive or macro instantiation.
2356 */
2358
2359/***
2360 * Determine whether the given cursor represents a currently
2361 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2362 */
2364
2365/**
2366 * Describe the linkage of the entity referred to by a cursor.
2367 */
2369 /** This value indicates that no linkage information is available
2370 * for a provided CXCursor. */
2372 /**
2373 * This is the linkage for variables, parameters, and so on that
2374 * have automatic storage. This covers normal (non-extern) local variables.
2375 */
2377 /** This is the linkage for static variables and static functions. */
2379 /** This is the linkage for entities with external linkage that live
2380 * in C++ anonymous namespaces.*/
2382 /** This is the linkage for entities with true, external linkage. */
2385
2386/**
2387 * Determine the linkage of the entity referred to by a given cursor.
2388 */
2390
2392 /** This value indicates that no visibility information is available
2393 * for a provided CXCursor. */
2395
2396 /** Symbol not seen by the linker. */
2398 /** Symbol seen by the linker but resolves to a symbol inside this object. */
2400 /** Symbol seen by the linker and acts like a normal symbol. */
2403
2404/**
2405 * Describe the visibility of the entity referred to by a cursor.
2406 *
2407 * This returns the default visibility if not explicitly specified by
2408 * a visibility attribute. The default visibility may be changed by
2409 * commandline arguments.
2410 *
2411 * \param cursor The cursor to query.
2412 *
2413 * \returns The visibility of the cursor.
2414 */
2416
2417/**
2418 * Determine the availability of the entity that this cursor refers to,
2419 * taking the current target platform into account.
2420 *
2421 * \param cursor The cursor to query.
2422 *
2423 * \returns The availability of the cursor.
2424 */
2427
2428/**
2429 * Describes the availability of a given entity on a particular platform, e.g.,
2430 * a particular class might only be available on Mac OS 10.7 or newer.
2431 */
2433 /**
2434 * A string that describes the platform for which this structure
2435 * provides availability information.
2436 *
2437 * Possible values are "ios" or "macos".
2438 */
2440 /**
2441 * The version number in which this entity was introduced.
2442 */
2444 /**
2445 * The version number in which this entity was deprecated (but is
2446 * still available).
2447 */
2449 /**
2450 * The version number in which this entity was obsoleted, and therefore
2451 * is no longer available.
2452 */
2454 /**
2455 * Whether the entity is unconditionally unavailable on this platform.
2456 */
2458 /**
2459 * An optional message to provide to a user of this API, e.g., to
2460 * suggest replacement APIs.
2461 */
2464
2465/**
2466 * Determine the availability of the entity that this cursor refers to
2467 * on any platforms for which availability information is known.
2468 *
2469 * \param cursor The cursor to query.
2470 *
2471 * \param always_deprecated If non-NULL, will be set to indicate whether the
2472 * entity is deprecated on all platforms.
2473 *
2474 * \param deprecated_message If non-NULL, will be set to the message text
2475 * provided along with the unconditional deprecation of this entity. The client
2476 * is responsible for deallocating this string.
2477 *
2478 * \param always_unavailable If non-NULL, will be set to indicate whether the
2479 * entity is unavailable on all platforms.
2480 *
2481 * \param unavailable_message If non-NULL, will be set to the message text
2482 * provided along with the unconditional unavailability of this entity. The
2483 * client is responsible for deallocating this string.
2484 *
2485 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2486 * that will be populated with platform availability information, up to either
2487 * the number of platforms for which availability information is available (as
2488 * returned by this function) or \c availability_size, whichever is smaller.
2489 *
2490 * \param availability_size The number of elements available in the
2491 * \c availability array.
2492 *
2493 * \returns The number of platforms (N) for which availability information is
2494 * available (which is unrelated to \c availability_size).
2495 *
2496 * Note that the client is responsible for calling
2497 * \c clang_disposeCXPlatformAvailability to free each of the
2498 * platform-availability structures returned. There are
2499 * \c min(N, availability_size) such structures.
2500 */
2502 CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
2503 int *always_unavailable, CXString *unavailable_message,
2504 CXPlatformAvailability *availability, int availability_size);
2505
2506/**
2507 * Free the memory associated with a \c CXPlatformAvailability structure.
2508 */
2509CINDEX_LINKAGE void
2511
2512/**
2513 * If cursor refers to a variable declaration and it has initializer returns
2514 * cursor referring to the initializer otherwise return null cursor.
2515 */
2517
2518/**
2519 * If cursor refers to a variable declaration that has global storage returns 1.
2520 * If cursor refers to a variable declaration that doesn't have global storage
2521 * returns 0. Otherwise returns -1.
2522 */
2524
2525/**
2526 * If cursor refers to a variable declaration that has external storage
2527 * returns 1. If cursor refers to a variable declaration that doesn't have
2528 * external storage returns 0. Otherwise returns -1.
2529 */
2531
2532/**
2533 * Describe the "language" of the entity referred to by a cursor.
2534 */
2541
2542/**
2543 * Determine the "language" of the entity referred to by a given cursor.
2544 */
2546
2547/**
2548 * Describe the "thread-local storage (TLS) kind" of the declaration
2549 * referred to by a cursor.
2550 */
2552
2553/**
2554 * Determine the "thread-local storage (TLS) kind" of the declaration
2555 * referred to by a cursor.
2556 */
2558
2559/**
2560 * Returns the translation unit that a cursor originated from.
2561 */
2563
2564/**
2565 * A fast container representing a set of CXCursors.
2566 */
2567typedef struct CXCursorSetImpl *CXCursorSet;
2568
2569/**
2570 * Creates an empty CXCursorSet.
2571 */
2573
2574/**
2575 * Disposes a CXCursorSet and releases its associated memory.
2576 */
2578
2579/**
2580 * Queries a CXCursorSet to see if it contains a specific CXCursor.
2581 *
2582 * \returns non-zero if the set contains the specified cursor.
2583 */
2585 CXCursor cursor);
2586
2587/**
2588 * Inserts a CXCursor into a CXCursorSet.
2589 *
2590 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2591 */
2593 CXCursor cursor);
2594
2595/**
2596 * Determine the semantic parent of the given cursor.
2597 *
2598 * The semantic parent of a cursor is the cursor that semantically contains
2599 * the given \p cursor. For many declarations, the lexical and semantic parents
2600 * are equivalent (the lexical parent is returned by
2601 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2602 * definitions are provided out-of-line. For example:
2603 *
2604 * \code
2605 * class C {
2606 * void f();
2607 * };
2608 *
2609 * void C::f() { }
2610 * \endcode
2611 *
2612 * In the out-of-line definition of \c C::f, the semantic parent is
2613 * the class \c C, of which this function is a member. The lexical parent is
2614 * the place where the declaration actually occurs in the source code; in this
2615 * case, the definition occurs in the translation unit. In general, the
2616 * lexical parent for a given entity can change without affecting the semantics
2617 * of the program, and the lexical parent of different declarations of the
2618 * same entity may be different. Changing the semantic parent of a declaration,
2619 * on the other hand, can have a major impact on semantics, and redeclarations
2620 * of a particular entity should all have the same semantic context.
2621 *
2622 * In the example above, both declarations of \c C::f have \c C as their
2623 * semantic context, while the lexical context of the first \c C::f is \c C
2624 * and the lexical context of the second \c C::f is the translation unit.
2625 *
2626 * For global declarations, the semantic parent is the translation unit.
2627 */
2629
2630/**
2631 * Determine the lexical parent of the given cursor.
2632 *
2633 * The lexical parent of a cursor is the cursor in which the given \p cursor
2634 * was actually written. For many declarations, the lexical and semantic parents
2635 * are equivalent (the semantic parent is returned by
2636 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2637 * definitions are provided out-of-line. For example:
2638 *
2639 * \code
2640 * class C {
2641 * void f();
2642 * };
2643 *
2644 * void C::f() { }
2645 * \endcode
2646 *
2647 * In the out-of-line definition of \c C::f, the semantic parent is
2648 * the class \c C, of which this function is a member. The lexical parent is
2649 * the place where the declaration actually occurs in the source code; in this
2650 * case, the definition occurs in the translation unit. In general, the
2651 * lexical parent for a given entity can change without affecting the semantics
2652 * of the program, and the lexical parent of different declarations of the
2653 * same entity may be different. Changing the semantic parent of a declaration,
2654 * on the other hand, can have a major impact on semantics, and redeclarations
2655 * of a particular entity should all have the same semantic context.
2656 *
2657 * In the example above, both declarations of \c C::f have \c C as their
2658 * semantic context, while the lexical context of the first \c C::f is \c C
2659 * and the lexical context of the second \c C::f is the translation unit.
2660 *
2661 * For declarations written in the global scope, the lexical parent is
2662 * the translation unit.
2663 */
2665
2666/**
2667 * Determine the set of methods that are overridden by the given
2668 * method.
2669 *
2670 * In both Objective-C and C++, a method (aka virtual member function,
2671 * in C++) can override a virtual method in a base class. For
2672 * Objective-C, a method is said to override any method in the class's
2673 * base class, its protocols, or its categories' protocols, that has the same
2674 * selector and is of the same kind (class or instance).
2675 * If no such method exists, the search continues to the class's superclass,
2676 * its protocols, and its categories, and so on. A method from an Objective-C
2677 * implementation is considered to override the same methods as its
2678 * corresponding method in the interface.
2679 *
2680 * For C++, a virtual member function overrides any virtual member
2681 * function with the same signature that occurs in its base
2682 * classes. With multiple inheritance, a virtual member function can
2683 * override several virtual member functions coming from different
2684 * base classes.
2685 *
2686 * In all cases, this function determines the immediate overridden
2687 * method, rather than all of the overridden methods. For example, if
2688 * a method is originally declared in a class A, then overridden in B
2689 * (which in inherits from A) and also in C (which inherited from B),
2690 * then the only overridden method returned from this function when
2691 * invoked on C's method will be B's method. The client may then
2692 * invoke this function again, given the previously-found overridden
2693 * methods, to map out the complete method-override set.
2694 *
2695 * \param cursor A cursor representing an Objective-C or C++
2696 * method. This routine will compute the set of methods that this
2697 * method overrides.
2698 *
2699 * \param overridden A pointer whose pointee will be replaced with a
2700 * pointer to an array of cursors, representing the set of overridden
2701 * methods. If there are no overridden methods, the pointee will be
2702 * set to NULL. The pointee must be freed via a call to
2703 * \c clang_disposeOverriddenCursors().
2704 *
2705 * \param num_overridden A pointer to the number of overridden
2706 * functions, will be set to the number of overridden functions in the
2707 * array pointed to by \p overridden.
2708 */
2710 CXCursor **overridden,
2711 unsigned *num_overridden);
2712
2713/**
2714 * Free the set of overridden cursors returned by \c
2715 * clang_getOverriddenCursors().
2716 */
2718
2719/**
2720 * Retrieve the file that is included by the given inclusion directive
2721 * cursor.
2722 */
2724
2725/**
2726 * @}
2727 */
2728
2729/**
2730 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2731 *
2732 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2733 * routines help map between cursors and the physical locations where the
2734 * described entities occur in the source code. The mapping is provided in
2735 * both directions, so one can map from source code to the AST and back.
2736 *
2737 * @{
2738 */
2739
2740/**
2741 * Map a source location to the cursor that describes the entity at that
2742 * location in the source code.
2743 *
2744 * clang_getCursor() maps an arbitrary source location within a translation
2745 * unit down to the most specific cursor that describes the entity at that
2746 * location. For example, given an expression \c x + y, invoking
2747 * clang_getCursor() with a source location pointing to "x" will return the
2748 * cursor for "x"; similarly for "y". If the cursor points anywhere between
2749 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2750 * will return a cursor referring to the "+" expression.
2751 *
2752 * \returns a cursor representing the entity at the given source location, or
2753 * a NULL cursor if no such entity can be found.
2754 */
2756
2757/**
2758 * Retrieve the physical location of the source constructor referenced
2759 * by the given cursor.
2760 *
2761 * The location of a declaration is typically the location of the name of that
2762 * declaration, where the name of that declaration would occur if it is
2763 * unnamed, or some keyword that introduces that particular declaration.
2764 * The location of a reference is where that reference occurs within the
2765 * source code.
2766 */
2768
2769/**
2770 * Retrieve the physical extent of the source construct referenced by
2771 * the given cursor.
2772 *
2773 * The extent of a cursor starts with the file/line/column pointing at the
2774 * first character within the source construct that the cursor refers to and
2775 * ends with the last character within that source construct. For a
2776 * declaration, the extent covers the declaration itself. For a reference,
2777 * the extent covers the location of the reference (e.g., where the referenced
2778 * entity was actually used).
2779 */
2781
2782/**
2783 * @}
2784 */
2785
2786/**
2787 * \defgroup CINDEX_TYPES Type information for CXCursors
2788 *
2789 * @{
2790 */
2791
2792/**
2793 * Describes the kind of type
2794 */
2796 /**
2797 * Represents an invalid type (e.g., where no type is available).
2798 */
2800
2801 /**
2802 * A type whose specific kind is not exposed via this
2803 * interface.
2804 */
2806
2807 /* Builtin types */
2849
2869
2870 /**
2871 * Represents a type that was referred to using an elaborated type keyword.
2872 *
2873 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
2874 */
2876
2877 /* OpenCL PipeType. */
2879
2880 /* OpenCL builtin types. */
2921
2925
2938
2939 /* Old aliases for AVC OpenCL extension types. */
2944
2949
2950/**
2951 * Describes the calling convention of a function type
2952 */
2965 /* Alias for compatibility with older versions of API. */
2975
2979
2980/**
2981 * The type of an element in the abstract syntax tree.
2982 *
2983 */
2984typedef struct {
2986 void *data[2];
2987} CXType;
2988
2989/**
2990 * Retrieve the type of a CXCursor (if any).
2991 */
2993
2994/**
2995 * Pretty-print the underlying type using the rules of the
2996 * language of the translation unit from which it came.
2997 *
2998 * If the type is invalid, an empty string is returned.
2999 */
3001
3002/**
3003 * Retrieve the underlying type of a typedef declaration.
3004 *
3005 * If the cursor does not reference a typedef declaration, an invalid type is
3006 * returned.
3007 */
3009
3010/**
3011 * Retrieve the integer type of an enum declaration.
3012 *
3013 * If the cursor does not reference an enum declaration, an invalid type is
3014 * returned.
3015 */
3017
3018/**
3019 * Retrieve the integer value of an enum constant declaration as a signed
3020 * long long.
3021 *
3022 * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3023 * returned. Since this is also potentially a valid constant value, the kind of
3024 * the cursor must be verified before calling this function.
3025 */
3027
3028/**
3029 * Retrieve the integer value of an enum constant declaration as an unsigned
3030 * long long.
3031 *
3032 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3033 * returned. Since this is also potentially a valid constant value, the kind of
3034 * the cursor must be verified before calling this function.
3035 */
3036CINDEX_LINKAGE unsigned long long
3038
3039/**
3040 * Returns non-zero if the cursor specifies a Record member that is a bit-field.
3041 */
3043
3044/**
3045 * Retrieve the bit width of a bit-field declaration as an integer.
3046 *
3047 * If the cursor does not reference a bit-field, or if the bit-field's width
3048 * expression cannot be evaluated, -1 is returned.
3049 *
3050 * For example:
3051 * \code
3052 * if (clang_Cursor_isBitField(Cursor)) {
3053 * int Width = clang_getFieldDeclBitWidth(Cursor);
3054 * if (Width != -1) {
3055 * // The bit-field width is not value-dependent.
3056 * }
3057 * }
3058 * \endcode
3059 */
3061
3062/**
3063 * Retrieve the number of non-variadic arguments associated with a given
3064 * cursor.
3065 *
3066 * The number of arguments can be determined for calls as well as for
3067 * declarations of functions or methods. For other cursors -1 is returned.
3068 */
3070
3071/**
3072 * Retrieve the argument cursor of a function or method.
3073 *
3074 * The argument cursor can be determined for calls as well as for declarations
3075 * of functions or methods. For other cursors and for invalid indices, an
3076 * invalid cursor is returned.
3077 */
3079
3080/**
3081 * Describes the kind of a template argument.
3082 *
3083 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3084 * element descriptions.
3085 */
3096 /* Indicates an error case, preventing the kind from being deduced. */
3099
3100/**
3101 * Returns the number of template args of a function, struct, or class decl
3102 * representing a template specialization.
3103 *
3104 * If the argument cursor cannot be converted into a template function
3105 * declaration, -1 is returned.
3106 *
3107 * For example, for the following declaration and specialization:
3108 * template <typename T, int kInt, bool kBool>
3109 * void foo() { ... }
3110 *
3111 * template <>
3112 * void foo<float, -7, true>();
3113 *
3114 * The value 3 would be returned from this call.
3115 */
3117
3118/**
3119 * Retrieve the kind of the I'th template argument of the CXCursor C.
3120 *
3121 * If the argument CXCursor does not represent a FunctionDecl, StructDecl, or
3122 * ClassTemplatePartialSpecialization, an invalid template argument kind is
3123 * returned.
3124 *
3125 * For example, for the following declaration and specialization:
3126 * template <typename T, int kInt, bool kBool>
3127 * void foo() { ... }
3128 *
3129 * template <>
3130 * void foo<float, -7, true>();
3131 *
3132 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3133 * respectively.
3134 */
3137
3138/**
3139 * Retrieve a CXType representing the type of a TemplateArgument of a
3140 * function decl representing a template specialization.
3141 *
3142 * If the argument CXCursor does not represent a FunctionDecl, StructDecl,
3143 * ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument
3144 * has a kind of CXTemplateArgKind_Integral, an invalid type is returned.
3145 *
3146 * For example, for the following declaration and specialization:
3147 * template <typename T, int kInt, bool kBool>
3148 * void foo() { ... }
3149 *
3150 * template <>
3151 * void foo<float, -7, true>();
3152 *
3153 * If called with I = 0, "float", will be returned.
3154 * Invalid types will be returned for I == 1 or 2.
3155 */
3157 unsigned I);
3158
3159/**
3160 * Retrieve the value of an Integral TemplateArgument (of a function
3161 * decl representing a template specialization) as a signed long long.
3162 *
3163 * It is undefined to call this function on a CXCursor that does not represent a
3164 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization
3165 * whose I'th template argument is not an integral value.
3166 *
3167 * For example, for the following declaration and specialization:
3168 * template <typename T, int kInt, bool kBool>
3169 * void foo() { ... }
3170 *
3171 * template <>
3172 * void foo<float, -7, true>();
3173 *
3174 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3175 * For I == 0, this function's behavior is undefined.
3176 */
3178 unsigned I);
3179
3180/**
3181 * Retrieve the value of an Integral TemplateArgument (of a function
3182 * decl representing a template specialization) as an unsigned long long.
3183 *
3184 * It is undefined to call this function on a CXCursor that does not represent a
3185 * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or
3186 * whose I'th template argument is not an integral value.
3187 *
3188 * For example, for the following declaration and specialization:
3189 * template <typename T, int kInt, bool kBool>
3190 * void foo() { ... }
3191 *
3192 * template <>
3193 * void foo<float, 2147483649, true>();
3194 *
3195 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3196 * For I == 0, this function's behavior is undefined.
3197 */
3198CINDEX_LINKAGE unsigned long long
3200
3201/**
3202 * Determine whether two CXTypes represent the same type.
3203 *
3204 * \returns non-zero if the CXTypes represent the same type and
3205 * zero otherwise.
3206 */
3208
3209/**
3210 * Return the canonical type for a CXType.
3211 *
3212 * Clang's type system explicitly models typedefs and all the ways
3213 * a specific type can be represented. The canonical type is the underlying
3214 * type with all the "sugar" removed. For example, if 'T' is a typedef
3215 * for 'int', the canonical type for 'T' would be 'int'.
3216 */
3218
3219/**
3220 * Determine whether a CXType has the "const" qualifier set,
3221 * without looking through typedefs that may have added "const" at a
3222 * different level.
3223 */
3225
3226/**
3227 * Determine whether a CXCursor that is a macro, is
3228 * function like.
3229 */
3231
3232/**
3233 * Determine whether a CXCursor that is a macro, is a
3234 * builtin one.
3235 */
3237
3238/**
3239 * Determine whether a CXCursor that is a function declaration, is an
3240 * inline declaration.
3241 */
3243
3244/**
3245 * Determine whether a CXType has the "volatile" qualifier set,
3246 * without looking through typedefs that may have added "volatile" at
3247 * a different level.
3248 */
3250
3251/**
3252 * Determine whether a CXType has the "restrict" qualifier set,
3253 * without looking through typedefs that may have added "restrict" at a
3254 * different level.
3255 */
3257
3258/**
3259 * Returns the address space of the given type.
3260 */
3262
3263/**
3264 * Returns the typedef name of the given type.
3265 */
3267
3268/**
3269 * For pointer types, returns the type of the pointee.
3270 */
3272
3273/**
3274 * Retrieve the unqualified variant of the given type, removing as
3275 * little sugar as possible.
3276 *
3277 * For example, given the following series of typedefs:
3278 *
3279 * \code
3280 * typedef int Integer;
3281 * typedef const Integer CInteger;
3282 * typedef CInteger DifferenceType;
3283 * \endcode
3284 *
3285 * Executing \c clang_getUnqualifiedType() on a \c CXType that
3286 * represents \c DifferenceType, will desugar to a type representing
3287 * \c Integer, that has no qualifiers.
3288 *
3289 * And, executing \c clang_getUnqualifiedType() on the type of the
3290 * first argument of the following function declaration:
3291 *
3292 * \code
3293 * void foo(const int);
3294 * \endcode
3295 *
3296 * Will return a type representing \c int, removing the \c const
3297 * qualifier.
3298 *
3299 * Sugar over array types is not desugared.
3300 *
3301 * A type can be checked for qualifiers with \c
3302 * clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType()
3303 * and \c clang_isRestrictQualifiedType().
3304 *
3305 * A type that resulted from a call to \c clang_getUnqualifiedType
3306 * will return \c false for all of the above calls.
3307 */
3309
3310/**
3311 * For reference types (e.g., "const int&"), returns the type that the
3312 * reference refers to (e.g "const int").
3313 *
3314 * Otherwise, returns the type itself.
3315 *
3316 * A type that has kind \c CXType_LValueReference or
3317 * \c CXType_RValueReference is a reference type.
3318 */
3320
3321/**
3322 * Return the cursor for the declaration of the given type.
3323 */
3325
3326/**
3327 * Returns the Objective-C type encoding for the specified declaration.
3328 */
3330
3331/**
3332 * Returns the Objective-C type encoding for the specified CXType.
3333 */
3335
3336/**
3337 * Retrieve the spelling of a given CXTypeKind.
3338 */
3340
3341/**
3342 * Retrieve the calling convention associated with a function type.
3343 *
3344 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3345 */
3347
3348/**
3349 * Retrieve the return type associated with a function type.
3350 *
3351 * If a non-function type is passed in, an invalid type is returned.
3352 */
3354
3355/**
3356 * Retrieve the exception specification type associated with a function type.
3357 * This is a value of type CXCursor_ExceptionSpecificationKind.
3358 *
3359 * If a non-function type is passed in, an error code of -1 is returned.
3360 */
3362
3363/**
3364 * Retrieve the number of non-variadic parameters associated with a
3365 * function type.
3366 *
3367 * If a non-function type is passed in, -1 is returned.
3368 */
3370
3371/**
3372 * Retrieve the type of a parameter of a function type.
3373 *
3374 * If a non-function type is passed in or the function does not have enough
3375 * parameters, an invalid type is returned.
3376 */
3378
3379/**
3380 * Retrieves the base type of the ObjCObjectType.
3381 *
3382 * If the type is not an ObjC object, an invalid type is returned.
3383 */
3385
3386/**
3387 * Retrieve the number of protocol references associated with an ObjC object/id.
3388 *
3389 * If the type is not an ObjC object, 0 is returned.
3390 */
3392
3393/**
3394 * Retrieve the decl for a protocol reference for an ObjC object/id.
3395 *
3396 * If the type is not an ObjC object or there are not enough protocol
3397 * references, an invalid cursor is returned.
3398 */
3400
3401/**
3402 * Retrieve the number of type arguments associated with an ObjC object.
3403 *
3404 * If the type is not an ObjC object, 0 is returned.
3405 */
3407
3408/**
3409 * Retrieve a type argument associated with an ObjC object.
3410 *
3411 * If the type is not an ObjC or the index is not valid,
3412 * an invalid type is returned.
3413 */
3415
3416/**
3417 * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3418 */
3420
3421/**
3422 * Retrieve the return type associated with a given cursor.
3423 *
3424 * This only returns a valid type if the cursor refers to a function or method.
3425 */
3427
3428/**
3429 * Retrieve the exception specification type associated with a given cursor.
3430 * This is a value of type CXCursor_ExceptionSpecificationKind.
3431 *
3432 * This only returns a valid result if the cursor refers to a function or
3433 * method.
3434 */
3436
3437/**
3438 * Return 1 if the CXType is a POD (plain old data) type, and 0
3439 * otherwise.
3440 */
3442
3443/**
3444 * Return the element type of an array, complex, or vector type.
3445 *
3446 * If a type is passed in that is not an array, complex, or vector type,
3447 * an invalid type is returned.
3448 */
3450
3451/**
3452 * Return the number of elements of an array or vector type.
3453 *
3454 * If a type is passed in that is not an array or vector type,
3455 * -1 is returned.
3456 */
3458
3459/**
3460 * Return the element type of an array type.
3461 *
3462 * If a non-array type is passed in, an invalid type is returned.
3463 */
3465
3466/**
3467 * Return the array size of a constant array.
3468 *
3469 * If a non-array type is passed in, -1 is returned.
3470 */
3472
3473/**
3474 * Retrieve the type named by the qualified-id.
3475 *
3476 * If a non-elaborated type is passed in, an invalid type is returned.
3477 */
3479
3480/**
3481 * Determine if a typedef is 'transparent' tag.
3482 *
3483 * A typedef is considered 'transparent' if it shares a name and spelling
3484 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3485 *
3486 * \returns non-zero if transparent and zero otherwise.
3487 */
3489
3491 /**
3492 * Values of this type can never be null.
3493 */
3495 /**
3496 * Values of this type can be null.
3497 */
3499 /**
3500 * Whether values of this type can be null is (explicitly)
3501 * unspecified. This captures a (fairly rare) case where we
3502 * can't conclude anything about the nullability of the type even
3503 * though it has been considered.
3504 */
3506 /**
3507 * Nullability is not applicable to this type.
3508 */
3510
3511 /**
3512 * Generally behaves like Nullable, except when used in a block parameter that
3513 * was imported into a swift async method. There, swift will assume that the
3514 * parameter can get null even if no error occurred. _Nullable parameters are
3515 * assumed to only get null on error.
3516 */
3519
3520/**
3521 * Retrieve the nullability kind of a pointer type.
3522 */
3524
3525/**
3526 * List the possible error codes for \c clang_Type_getSizeOf,
3527 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3528 * \c clang_Cursor_getOffsetOf.
3529 *
3530 * A value of this enumeration type can be returned if the target type is not
3531 * a valid argument to sizeof, alignof or offsetof.
3532 */
3534 /**
3535 * Type is of kind CXType_Invalid.
3536 */
3538 /**
3539 * The type is an incomplete Type.
3540 */
3542 /**
3543 * The type is a dependent Type.
3544 */
3546 /**
3547 * The type is not a constant size type.
3548 */
3550 /**
3551 * The Field name is not valid for this record.
3552 */
3554 /**
3555 * The type is undeduced.
3556 */
3559
3560/**
3561 * Return the alignment of a type in bytes as per C++[expr.alignof]
3562 * standard.
3563 *
3564 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3565 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3566 * is returned.
3567 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3568 * returned.
3569 * If the type declaration is not a constant size type,
3570 * CXTypeLayoutError_NotConstantSize is returned.
3571 */
3573
3574/**
3575 * Return the class type of an member pointer type.
3576 *
3577 * If a non-member-pointer type is passed in, an invalid type is returned.
3578 */
3580
3581/**
3582 * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3583 *
3584 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3585 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3586 * is returned.
3587 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3588 * returned.
3589 */
3591
3592/**
3593 * Return the offset of a field named S in a record of type T in bits
3594 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3595 *
3596 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3597 * is returned.
3598 * If the field's type declaration is an incomplete type,
3599 * CXTypeLayoutError_Incomplete is returned.
3600 * If the field's type declaration is a dependent type,
3601 * CXTypeLayoutError_Dependent is returned.
3602 * If the field's name S is not found,
3603 * CXTypeLayoutError_InvalidFieldName is returned.
3604 */
3606
3607/**
3608 * Return the type that was modified by this attributed type.
3609 *
3610 * If the type is not an attributed type, an invalid type is returned.
3611 */
3613
3614/**
3615 * Gets the type contained by this atomic type.
3616 *
3617 * If a non-atomic type is passed in, an invalid type is returned.
3618 */
3620
3621/**
3622 * Return the offset of the field represented by the Cursor.
3623 *
3624 * If the cursor is not a field declaration, -1 is returned.
3625 * If the cursor semantic parent is not a record field declaration,
3626 * CXTypeLayoutError_Invalid is returned.
3627 * If the field's type declaration is an incomplete type,
3628 * CXTypeLayoutError_Incomplete is returned.
3629 * If the field's type declaration is a dependent type,
3630 * CXTypeLayoutError_Dependent is returned.
3631 * If the field's name S is not found,
3632 * CXTypeLayoutError_InvalidFieldName is returned.
3633 */
3635
3636/**
3637 * Determine whether the given cursor represents an anonymous
3638 * tag or namespace
3639 */
3641
3642/**
3643 * Determine whether the given cursor represents an anonymous record
3644 * declaration.
3645 */
3647
3648/**
3649 * Determine whether the given cursor represents an inline namespace
3650 * declaration.
3651 */
3653
3655 /** No ref-qualifier was provided. */
3657 /** An lvalue ref-qualifier was provided (\c &). */
3659 /** An rvalue ref-qualifier was provided (\c &&). */
3662
3663/**
3664 * Returns the number of template arguments for given template
3665 * specialization, or -1 if type \c T is not a template specialization.
3666 */
3668
3669/**
3670 * Returns the type template argument of a template class specialization
3671 * at given index.
3672 *
3673 * This function only returns template type arguments and does not handle
3674 * template template arguments or variadic packs.
3675 */
3677 unsigned i);
3678
3679/**
3680 * Retrieve the ref-qualifier kind of a function or method.
3681 *
3682 * The ref-qualifier is returned for C++ functions or methods. For other types
3683 * or non-C++ declarations, CXRefQualifier_None is returned.
3684 */
3686
3687/**
3688 * Returns 1 if the base class specified by the cursor with kind
3689 * CX_CXXBaseSpecifier is virtual.
3690 */
3692
3693/**
3694 * Represents the C++ access control level to a base class for a
3695 * cursor with kind CX_CXXBaseSpecifier.
3696 */
3703
3704/**
3705 * Returns the access control level for the referenced object.
3706 *
3707 * If the cursor refers to a C++ declaration, its access control level within
3708 * its parent scope is returned. Otherwise, if the cursor refers to a base
3709 * specifier or access specifier, the specifier itself is returned.
3710 */
3712
3713/**
3714 * Represents the storage classes as declared in the source. CX_SC_Invalid
3715 * was added for the case that the passed cursor in not a declaration.
3716 */
3727
3728/**
3729 * Returns the storage class for a function or variable declaration.
3730 *
3731 * If the passed in Cursor is not a function or variable declaration,
3732 * CX_SC_Invalid is returned else the storage class.
3733 */
3735
3736/**
3737 * Determine the number of overloaded declarations referenced by a
3738 * \c CXCursor_OverloadedDeclRef cursor.
3739 *
3740 * \param cursor The cursor whose overloaded declarations are being queried.
3741 *
3742 * \returns The number of overloaded declarations referenced by \c cursor. If it
3743 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3744 */
3746
3747/**
3748 * Retrieve a cursor for one of the overloaded declarations referenced
3749 * by a \c CXCursor_OverloadedDeclRef cursor.
3750 *
3751 * \param cursor The cursor whose overloaded declarations are being queried.
3752 *
3753 * \param index The zero-based index into the set of overloaded declarations in
3754 * the cursor.
3755 *
3756 * \returns A cursor representing the declaration referenced by the given
3757 * \c cursor at the specified \c index. If the cursor does not have an
3758 * associated set of overloaded declarations, or if the index is out of bounds,
3759 * returns \c clang_getNullCursor();
3760 */
3762 unsigned index);
3763
3764/**
3765 * @}
3766 */
3767
3768/**
3769 * \defgroup CINDEX_ATTRIBUTES Information for attributes
3770 *
3771 * @{
3772 */
3773
3774/**
3775 * For cursors representing an iboutletcollection attribute,
3776 * this function returns the collection element type.
3777 *
3778 */
3780
3781/**
3782 * @}
3783 */
3784
3785/**
3786 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3787 *
3788 * These routines provide the ability to traverse the abstract syntax tree
3789 * using cursors.
3790 *
3791 * @{
3792 */
3793
3794/**
3795 * Describes how the traversal of the children of a particular
3796 * cursor should proceed after visiting a particular child cursor.
3797 *
3798 * A value of this enumeration type should be returned by each
3799 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3800 */
3802 /**
3803 * Terminates the cursor traversal.
3804 */
3806 /**
3807 * Continues the cursor traversal with the next sibling of
3808 * the cursor just visited, without visiting its children.
3809 */
3811 /**
3812 * Recursively traverse the children of this cursor, using
3813 * the same visitor and client data.
3814 */
3817
3818/**
3819 * Visitor invoked for each cursor found by a traversal.
3820 *
3821 * This visitor function will be invoked for each cursor found by
3822 * clang_visitCursorChildren(). Its first argument is the cursor being
3823 * visited, its second argument is the parent visitor for that cursor,
3824 * and its third argument is the client data provided to
3825 * clang_visitCursorChildren().
3826 *
3827 * The visitor should return one of the \c CXChildVisitResult values
3828 * to direct clang_visitCursorChildren().
3829 */
3830typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3831 CXCursor parent,
3832 CXClientData client_data);
3833
3834/**
3835 * Visit the children of a particular cursor.
3836 *
3837 * This function visits all the direct children of the given cursor,
3838 * invoking the given \p visitor function with the cursors of each
3839 * visited child. The traversal may be recursive, if the visitor returns
3840 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3841 * the visitor returns \c CXChildVisit_Break.
3842 *
3843 * \param parent the cursor whose child may be visited. All kinds of
3844 * cursors can be visited, including invalid cursors (which, by
3845 * definition, have no children).
3846 *
3847 * \param visitor the visitor function that will be invoked for each
3848 * child of \p parent.
3849 *
3850 * \param client_data pointer data supplied by the client, which will
3851 * be passed to the visitor each time it is invoked.
3852 *
3853 * \returns a non-zero value if the traversal was terminated
3854 * prematurely by the visitor returning \c CXChildVisit_Break.
3855 */
3857 CXCursorVisitor visitor,
3858 CXClientData client_data);
3859#ifdef __has_feature
3860#if __has_feature(blocks)
3861/**
3862 * Visitor invoked for each cursor found by a traversal.
3863 *
3864 * This visitor block will be invoked for each cursor found by
3865 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3866 * visited, its second argument is the parent visitor for that cursor.
3867 *
3868 * The visitor should return one of the \c CXChildVisitResult values
3869 * to direct clang_visitChildrenWithBlock().
3870 */
3871typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
3872 CXCursor parent);
3873
3874/**
3875 * Visits the children of a cursor using the specified block. Behaves
3876 * identically to clang_visitChildren() in all other respects.
3877 */
3878CINDEX_LINKAGE unsigned
3879clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
3880#endif
3881#endif
3882
3883/**
3884 * @}
3885 */
3886
3887/**
3888 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3889 *
3890 * These routines provide the ability to determine references within and
3891 * across translation units, by providing the names of the entities referenced
3892 * by cursors, follow reference cursors to the declarations they reference,
3893 * and associate declarations with their definitions.
3894 *
3895 * @{
3896 */
3897
3898/**
3899 * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3900 * by the given cursor.
3901 *
3902 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3903 * entity (function, class, variable, etc.) within a program. USRs can be
3904 * compared across translation units to determine, e.g., when references in
3905 * one translation refer to an entity defined in another translation unit.
3906 */
3908
3909/**
3910 * Construct a USR for a specified Objective-C class.
3911 */
3913
3914/**
3915 * Construct a USR for a specified Objective-C category.
3916 */
3918 const char *class_name, const char *category_name);
3919
3920/**
3921 * Construct a USR for a specified Objective-C protocol.
3922 */
3924clang_constructUSR_ObjCProtocol(const char *protocol_name);
3925
3926/**
3927 * Construct a USR for a specified Objective-C instance variable and
3928 * the USR for its containing class.
3929 */
3931 CXString classUSR);
3932
3933/**
3934 * Construct a USR for a specified Objective-C method and
3935 * the USR for its containing class.
3936 */
3938 unsigned isInstanceMethod,
3939 CXString classUSR);
3940
3941/**
3942 * Construct a USR for a specified Objective-C property and the USR
3943 * for its containing class.
3944 */
3946 CXString classUSR);
3947
3948/**
3949 * Retrieve a name for the entity referenced by this cursor.
3950 */
3952
3953/**
3954 * Retrieve a range for a piece that forms the cursors spelling name.
3955 * Most of the times there is only one range for the complete spelling but for
3956 * Objective-C methods and Objective-C message expressions, there are multiple
3957 * pieces for each selector identifier.
3958 *
3959 * \param pieceIndex the index of the spelling name piece. If this is greater
3960 * than the actual number of pieces, it will return a NULL (invalid) range.
3961 *
3962 * \param options Reserved.
3963 */
3965 CXCursor, unsigned pieceIndex, unsigned options);
3966
3967/**
3968 * Opaque pointer representing a policy that controls pretty printing
3969 * for \c clang_getCursorPrettyPrinted.
3970 */
3971typedef void *CXPrintingPolicy;
3972
3973/**
3974 * Properties for the printing policy.
3975 *
3976 * See \c clang::PrintingPolicy for more information.
3977 */
4005
4008
4009/**
4010 * Get a property value for the given printing policy.
4011 */
4012CINDEX_LINKAGE unsigned
4014 enum CXPrintingPolicyProperty Property);
4015
4016/**
4017 * Set a property value for the given printing policy.
4018 */
4019CINDEX_LINKAGE void
4021 enum CXPrintingPolicyProperty Property,
4022 unsigned Value);
4023
4024/**
4025 * Retrieve the default policy for the cursor.
4026 *
4027 * The policy should be released after use with \c
4028 * clang_PrintingPolicy_dispose.
4029 */
4031
4032/**
4033 * Release a printing policy.
4034 */
4036
4037/**
4038 * Pretty print declarations.
4039 *
4040 * \param Cursor The cursor representing a declaration.
4041 *
4042 * \param Policy The policy to control the entities being printed. If
4043 * NULL, a default policy is used.
4044 *
4045 * \returns The pretty printed declaration or the empty string for
4046 * other cursors.
4047 */
4049 CXPrintingPolicy Policy);
4050
4051/**
4052 * Retrieve the display name for the entity referenced by this cursor.
4053 *
4054 * The display name contains extra information that helps identify the cursor,
4055 * such as the parameters of a function or template or the arguments of a
4056 * class template specialization.
4057 */
4059
4060/** For a cursor that is a reference, retrieve a cursor representing the
4061 * entity that it references.
4062 *
4063 * Reference cursors refer to other entities in the AST. For example, an
4064 * Objective-C superclass reference cursor refers to an Objective-C class.
4065 * This function produces the cursor for the Objective-C class from the
4066 * cursor for the superclass reference. If the input cursor is a declaration or
4067 * definition, it returns that declaration or definition unchanged.
4068 * Otherwise, returns the NULL cursor.
4069 */
4071
4072/**
4073 * For a cursor that is either a reference to or a declaration
4074 * of some entity, retrieve a cursor that describes the definition of
4075 * that entity.
4076 *
4077 * Some entities can be declared multiple times within a translation
4078 * unit, but only one of those declarations can also be a
4079 * definition. For example, given:
4080 *
4081 * \code
4082 * int f(int, int);
4083 * int g(int x, int y) { return f(x, y); }
4084 * int f(int a, int b) { return a + b; }
4085 * int f(int, int);
4086 * \endcode
4087 *
4088 * there are three declarations of the function "f", but only the
4089 * second one is a definition. The clang_getCursorDefinition()
4090 * function will take any cursor pointing to a declaration of "f"
4091 * (the first or fourth lines of the example) or a cursor referenced
4092 * that uses "f" (the call to "f' inside "g") and will return a
4093 * declaration cursor pointing to the definition (the second "f"
4094 * declaration).
4095 *
4096 * If given a cursor for which there is no corresponding definition,
4097 * e.g., because there is no definition of that entity within this
4098 * translation unit, returns a NULL cursor.
4099 */
4101
4102/**
4103 * Determine whether the declaration pointed to by this cursor
4104 * is also a definition of that entity.
4105 */
4107
4108/**
4109 * Retrieve the canonical cursor corresponding to the given cursor.
4110 *
4111 * In the C family of languages, many kinds of entities can be declared several
4112 * times within a single translation unit. For example, a structure type can
4113 * be forward-declared (possibly multiple times) and later defined:
4114 *
4115 * \code
4116 * struct X;
4117 * struct X;
4118 * struct X {
4119 * int member;
4120 * };
4121 * \endcode
4122 *
4123 * The declarations and the definition of \c X are represented by three
4124 * different cursors, all of which are declarations of the same underlying
4125 * entity. One of these cursor is considered the "canonical" cursor, which
4126 * is effectively the representative for the underlying entity. One can
4127 * determine if two cursors are declarations of the same underlying entity by
4128 * comparing their canonical cursors.
4129 *
4130 * \returns The canonical cursor for the entity referred to by the given cursor.
4131 */
4133
4134/**
4135 * If the cursor points to a selector identifier in an Objective-C
4136 * method or message expression, this returns the selector index.
4137 *
4138 * After getting a cursor with #clang_getCursor, this can be called to
4139 * determine if the location points to a selector identifier.
4140 *
4141 * \returns The selector index if the cursor is an Objective-C method or message
4142 * expression and the cursor is pointing to a selector identifier, or -1
4143 * otherwise.
4144 */
4146
4147/**
4148 * Given a cursor pointing to a C++ method call or an Objective-C
4149 * message, returns non-zero if the method/message is "dynamic", meaning:
4150 *
4151 * For a C++ method: the call is virtual.
4152 * For an Objective-C message: the receiver is an object instance, not 'super'
4153 * or a specific class.
4154 *
4155 * If the method/message is "static" or the cursor does not point to a
4156 * method/message, it will return zero.
4157 */
4159
4160/**
4161 * Given a cursor pointing to an Objective-C message or property
4162 * reference, or C++ method call, returns the CXType of the receiver.
4163 */
4165
4166/**
4167 * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4168 */
4169typedef enum {
4185
4186/**
4187 * Given a cursor that represents a property declaration, return the
4188 * associated property attributes. The bits are formed from
4189 * \c CXObjCPropertyAttrKind.
4190 *
4191 * \param reserved Reserved for future use, pass 0.
4192 */
4193CINDEX_LINKAGE unsigned
4195
4196/**
4197 * Given a cursor that represents a property declaration, return the
4198 * name of the method that implements the getter.
4199 */
4201
4202/**
4203 * Given a cursor that represents a property declaration, return the
4204 * name of the method that implements the setter, if any.
4205 */
4207
4208/**
4209 * 'Qualifiers' written next to the return and parameter types in
4210 * Objective-C method declarations.
4211 */
4212typedef enum {
4221
4222/**
4223 * Given a cursor that represents an Objective-C method or parameter
4224 * declaration, return the associated Objective-C qualifiers for the return
4225 * type or the parameter respectively. The bits are formed from
4226 * CXObjCDeclQualifierKind.
4227 */
4229
4230/**
4231 * Given a cursor that represents an Objective-C method or property
4232 * declaration, return non-zero if the declaration was affected by "\@optional".
4233 * Returns zero if the cursor is not such a declaration or it is "\@required".
4234 */
4236
4237/**
4238 * Returns non-zero if the given cursor is a variadic function or method.
4239 */
4241
4242/**
4243 * Returns non-zero if the given cursor points to a symbol marked with
4244 * external_source_symbol attribute.
4245 *
4246 * \param language If non-NULL, and the attribute is present, will be set to
4247 * the 'language' string from the attribute.
4248 *
4249 * \param definedIn If non-NULL, and the attribute is present, will be set to
4250 * the 'definedIn' string from the attribute.
4251 *
4252 * \param isGenerated If non-NULL, and the attribute is present, will be set to
4253 * non-zero if the 'generated_declaration' is set in the attribute.
4254 */
4256 CXString *language,
4257 CXString *definedIn,
4258 unsigned *isGenerated);
4259
4260/**
4261 * Given a cursor that represents a declaration, return the associated
4262 * comment's source range. The range may include multiple consecutive comments
4263 * with whitespace in between.
4264 */
4266
4267/**
4268 * Given a cursor that represents a declaration, return the associated
4269 * comment text, including comment markers.
4270 */
4272
4273/**
4274 * Given a cursor that represents a documentable entity (e.g.,
4275 * declaration), return the associated \paragraph; otherwise return the
4276 * first paragraph.
4277 */
4279
4280/**
4281 * @}
4282 */
4283
4284/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4285 *
4286 * @{
4287 */
4288
4289/**
4290 * Retrieve the CXString representing the mangled name of the cursor.
4291 */
4293
4294/**
4295 * Retrieve the CXStrings representing the mangled symbols of the C++
4296 * constructor or destructor at the cursor.
4297 */
4299
4300/**
4301 * Retrieve the CXStrings representing the mangled symbols of the ObjC
4302 * class interface or implementation at the cursor.
4303 */
4305
4306/**
4307 * @}
4308 */
4309
4310/**
4311 * \defgroup CINDEX_MODULE Module introspection
4312 *
4313 * The functions in this group provide access to information about modules.
4314 *
4315 * @{
4316 */
4317
4318typedef void *CXModule;
4319
4320/**
4321 * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4322 */
4324
4325/**
4326 * Given a CXFile header file, return the module that contains it, if one
4327 * exists.
4328 */
4330
4331/**
4332 * \param Module a module object.
4333 *
4334 * \returns the module file where the provided module object came from.
4335 */
4337
4338/**
4339 * \param Module a module object.
4340 *
4341 * \returns the parent of a sub-module or NULL if the given module is top-level,
4342 * e.g. for 'std.vector' it will return the 'std' module.
4343 */
4345
4346/**
4347 * \param Module a module object.
4348 *
4349 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4350 * will return "vector".
4351 */
4353
4354/**
4355 * \param Module a module object.
4356 *
4357 * \returns the full name of the module, e.g. "std.vector".
4358 */
4360
4361/**
4362 * \param Module a module object.
4363 *
4364 * \returns non-zero if the module is a system one.
4365 */
4367
4368/**
4369 * \param Module a module object.
4370 *
4371 * \returns the number of top level headers associated with this module.
4372 */
4374 CXModule Module);
4375
4376/**
4377 * \param Module a module object.
4378 *
4379 * \param Index top level header index (zero-based).
4380 *
4381 * \returns the specified top level header associated with the module.
4382 */
4385 unsigned Index);
4386
4387/**
4388 * @}
4389 */
4390
4391/**
4392 * \defgroup CINDEX_CPP C++ AST introspection
4393 *
4394 * The routines in this group provide access information in the ASTs specific
4395 * to C++ language features.
4396 *
4397 * @{
4398 */
4399
4400/**
4401 * Determine if a C++ constructor is a converting constructor.
4402 */
4403CINDEX_LINKAGE unsigned
4405
4406/**
4407 * Determine if a C++ constructor is a copy constructor.
4408 */
4410
4411/**
4412 * Determine if a C++ constructor is the default constructor.
4413 */
4415
4416/**
4417 * Determine if a C++ constructor is a move constructor.
4418 */
4420
4421/**
4422 * Determine if a C++ field is declared 'mutable'.
4423 */
4425
4426/**
4427 * Determine if a C++ method is declared '= default'.
4428 */
4430
4431/**
4432 * Determine if a C++ method is declared '= delete'.
4433 */
4435
4436/**
4437 * Determine if a C++ member function or member function template is
4438 * pure virtual.
4439 */
4441
4442/**
4443 * Determine if a C++ member function or member function template is
4444 * declared 'static'.
4445 */
4447
4448/**
4449 * Determine if a C++ member function or member function template is
4450 * explicitly declared 'virtual' or if it overrides a virtual method from
4451 * one of the base classes.
4452 */
4454
4455/**
4456 * Determine if a C++ member function is a copy-assignment operator,
4457 * returning 1 if such is the case and 0 otherwise.
4458 *
4459 * > A copy-assignment operator `X::operator=` is a non-static,
4460 * > non-template member function of _class_ `X` with exactly one
4461 * > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
4462 * > volatile X&`.
4463 *
4464 * That is, for example, the `operator=` in:
4465 *
4466 * class Foo {
4467 * bool operator=(const volatile Foo&);
4468 * };
4469 *
4470 * Is a copy-assignment operator, while the `operator=` in:
4471 *
4472 * class Bar {
4473 * bool operator=(const int&);
4474 * };
4475 *
4476 * Is not.
4477 */
4479
4480/**
4481 * Determine if a C++ member function is a move-assignment operator,
4482 * returning 1 if such is the case and 0 otherwise.
4483 *
4484 * > A move-assignment operator `X::operator=` is a non-static,
4485 * > non-template member function of _class_ `X` with exactly one
4486 * > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
4487 * > volatile X&&`.
4488 *
4489 * That is, for example, the `operator=` in:
4490 *
4491 * class Foo {
4492 * bool operator=(const volatile Foo&&);
4493 * };
4494 *
4495 * Is a move-assignment operator, while the `operator=` in:
4496 *
4497 * class Bar {
4498 * bool operator=(const int&&);
4499 * };
4500 *
4501 * Is not.
4502 */
4504
4505/**
4506 * Determines if a C++ constructor or conversion function was declared
4507 * explicit, returning 1 if such is the case and 0 otherwise.
4508 *
4509 * Constructors or conversion functions are declared explicit through
4510 * the use of the explicit specifier.
4511 *
4512 * For example, the following constructor and conversion function are
4513 * not explicit as they lack the explicit specifier:
4514 *
4515 * class Foo {
4516 * Foo();
4517 * operator int();
4518 * };
4519 *
4520 * While the following constructor and conversion function are
4521 * explicit as they are declared with the explicit specifier.
4522 *
4523 * class Foo {
4524 * explicit Foo();
4525 * explicit operator int();
4526 * };
4527 *
4528 * This function will return 0 when given a cursor pointing to one of
4529 * the former declarations and it will return 1 for a cursor pointing
4530 * to the latter declarations.
4531 *
4532 * The explicit specifier allows the user to specify a
4533 * conditional compile-time expression whose value decides
4534 * whether the marked element is explicit or not.
4535 *
4536 * For example:
4537 *
4538 * constexpr bool foo(int i) { return i % 2 == 0; }
4539 *
4540 * class Foo {
4541 * explicit(foo(1)) Foo();
4542 * explicit(foo(2)) operator int();
4543 * }
4544 *
4545 * This function will return 0 for the constructor and 1 for
4546 * the conversion function.
4547 */
4549
4550/**
4551 * Determine if a C++ record is abstract, i.e. whether a class or struct
4552 * has a pure virtual member function.
4553 */
4555
4556/**
4557 * Determine if an enum declaration refers to a scoped enum.
4558 */
4560
4561/**
4562 * Determine if a C++ member function or member function template is
4563 * declared 'const'.
4564 */
4566
4567/**
4568 * Given a cursor that represents a template, determine
4569 * the cursor kind of the specializations would be generated by instantiating
4570 * the template.
4571 *
4572 * This routine can be used to determine what flavor of function template,
4573 * class template, or class template partial specialization is stored in the
4574 * cursor. For example, it can describe whether a class template cursor is
4575 * declared with "struct", "class" or "union".
4576 *
4577 * \param C The cursor to query. This cursor should represent a template
4578 * declaration.
4579 *
4580 * \returns The cursor kind of the specializations that would be generated
4581 * by instantiating the template \p C. If \p C is not a template, returns
4582 * \c CXCursor_NoDeclFound.
4583 */
4585
4586/**
4587 * Given a cursor that may represent a specialization or instantiation
4588 * of a template, retrieve the cursor that represents the template that it
4589 * specializes or from which it was instantiated.
4590 *
4591 * This routine determines the template involved both for explicit
4592 * specializations of templates and for implicit instantiations of the template,
4593 * both of which are referred to as "specializations". For a class template
4594 * specialization (e.g., \c std::vector<bool>), this routine will return
4595 * either the primary template (\c std::vector) or, if the specialization was
4596 * instantiated from a class template partial specialization, the class template
4597 * partial specialization. For a class template partial specialization and a
4598 * function template specialization (including instantiations), this
4599 * this routine will return the specialized template.
4600 *
4601 * For members of a class template (e.g., member functions, member classes, or
4602 * static data members), returns the specialized or instantiated member.
4603 * Although not strictly "templates" in the C++ language, members of class
4604 * templates have the same notions of specializations and instantiations that
4605 * templates do, so this routine treats them similarly.
4606 *
4607 * \param C A cursor that may be a specialization of a template or a member
4608 * of a template.
4609 *
4610 * \returns If the given cursor is a specialization or instantiation of a
4611 * template or a member thereof, the template or member that it specializes or
4612 * from which it was instantiated. Otherwise, returns a NULL cursor.
4613 */
4615
4616/**
4617 * Given a cursor that references something else, return the source range
4618 * covering that reference.
4619 *
4620 * \param C A cursor pointing to a member reference, a declaration reference, or
4621 * an operator call.
4622 * \param NameFlags A bitset with three independent flags:
4623 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4624 * CXNameRange_WantSinglePiece.
4625 * \param PieceIndex For contiguous names or when passing the flag
4626 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4627 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4628 * non-contiguous names, this index can be used to retrieve the individual
4629 * pieces of the name. See also CXNameRange_WantSinglePiece.
4630 *
4631 * \returns The piece of the name pointed to by the given cursor. If there is no
4632 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4633 */
4635 CXCursor C, unsigned NameFlags, unsigned PieceIndex);
4636
4638 /**
4639 * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4640 * range.
4641 */
4643
4644 /**
4645 * Include the explicit template arguments, e.g. <int> in x.f<int>,
4646 * in the range.
4647 */
4649
4650 /**
4651 * If the name is non-contiguous, return the full spanning range.
4652 *
4653 * Non-contiguous names occur in Objective-C when a selector with two or more
4654 * parameters is used, or in C++ when using an operator:
4655 * \code
4656 * [object doSomething:here withValue:there]; // Objective-C
4657 * return some_vector[1]; // C++
4658 * \endcode
4659 */
4662
4663/**
4664 * @}
4665 */
4666
4667/**
4668 * \defgroup CINDEX_LEX Token extraction and manipulation
4669 *
4670 * The routines in this group provide access to the tokens within a
4671 * translation unit, along with a semantic mapping of those tokens to
4672 * their corresponding cursors.
4673 *
4674 * @{
4675 */
4676
4677/**
4678 * Describes a kind of token.
4679 */
4680typedef enum CXTokenKind {
4681 /**
4682 * A token that contains some kind of punctuation.
4683 */
4685
4686 /**
4687 * A language keyword.
4688 */
4690
4691 /**
4692 * An identifier (that is not a keyword).
4693 */
4695
4696 /**
4697 * A numeric, string, or character literal.
4698 */
4700
4701 /**
4702 * A comment.
4703 */
4706
4707/**
4708 * Describes a single preprocessing token.
4709 */
4710typedef struct {
4711 unsigned int_data[4];
4713} CXToken;
4714
4715/**
4716 * Get the raw lexical token starting with the given location.
4717 *
4718 * \param TU the translation unit whose text is being tokenized.
4719 *
4720 * \param Location the source location with which the token starts.
4721 *
4722 * \returns The token starting with the given location or NULL if no such token
4723 * exist. The returned pointer must be freed with clang_disposeTokens before the
4724 * translation unit is destroyed.
4725 */
4727 CXSourceLocation Location);
4728
4729/**
4730 * Determine the kind of the given token.
4731 */
4733
4734/**
4735 * Determine the spelling of the given token.
4736 *
4737 * The spelling of a token is the textual representation of that token, e.g.,
4738 * the text of an identifier or keyword.
4739 */
4741
4742/**
4743 * Retrieve the source location of the given token.
4744 */
4746 CXToken);
4747
4748/**
4749 * Retrieve a source range that covers the given token.
4750 */
4752
4753/**
4754 * Tokenize the source code described by the given range into raw
4755 * lexical tokens.
4756 *
4757 * \param TU the translation unit whose text is being tokenized.
4758 *
4759 * \param Range the source range in which text should be tokenized. All of the
4760 * tokens produced by tokenization will fall within this source range,
4761 *
4762 * \param Tokens this pointer will be set to point to the array of tokens
4763 * that occur within the given source range. The returned pointer must be
4764 * freed with clang_disposeTokens() before the translation unit is destroyed.
4765 *
4766 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4767 * array.
4768 *
4769 */
4771 CXToken **Tokens, unsigned *NumTokens);
4772
4773/**
4774 * Annotate the given set of tokens by providing cursors for each token
4775 * that can be mapped to a specific entity within the abstract syntax tree.
4776 *
4777 * This token-annotation routine is equivalent to invoking
4778 * clang_getCursor() for the source locations of each of the
4779 * tokens. The cursors provided are filtered, so that only those
4780 * cursors that have a direct correspondence to the token are
4781 * accepted. For example, given a function call \c f(x),
4782 * clang_getCursor() would provide the following cursors:
4783 *
4784 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4785 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4786 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4787 *
4788 * Only the first and last of these cursors will occur within the
4789 * annotate, since the tokens "f" and "x' directly refer to a function
4790 * and a variable, respectively, but the parentheses are just a small
4791 * part of the full syntax of the function call expression, which is
4792 * not provided as an annotation.
4793 *
4794 * \param TU the translation unit that owns the given tokens.
4795 *
4796 * \param Tokens the set of tokens to annotate.
4797 *
4798 * \param NumTokens the number of tokens in \p Tokens.
4799 *
4800 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4801 * replaced with the cursors corresponding to each token.
4802 */
4804 unsigned NumTokens, CXCursor *Cursors);
4805
4806/**
4807 * Free the given set of tokens.
4808 */
4810 unsigned NumTokens);
4811
4812/**
4813 * @}
4814 */
4815
4816/**
4817 * \defgroup CINDEX_DEBUG Debugging facilities
4818 *
4819 * These routines are used for testing and debugging, only, and should not
4820 * be relied upon.
4821 *
4822 * @{
4823 */
4824
4825/* for debug/testing */
4828 CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
4829 unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
4831CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
4832 unsigned stack_size);
4833
4834/**
4835 * @}
4836 */
4837
4838/**
4839 * \defgroup CINDEX_CODE_COMPLET Code completion
4840 *
4841 * Code completion involves taking an (incomplete) source file, along with
4842 * knowledge of where the user is actively editing that file, and suggesting
4843 * syntactically- and semantically-valid constructs that the user might want to
4844 * use at that particular point in the source code. These data structures and
4845 * routines provide support for code completion.
4846 *
4847 * @{
4848 */
4849
4850/**
4851 * A semantic string that describes a code-completion result.
4852 *
4853 * A semantic string that describes the formatting of a code-completion
4854 * result as a single "template" of text that should be inserted into the
4855 * source buffer when a particular code-completion result is selected.
4856 * Each semantic string is made up of some number of "chunks", each of which
4857 * contains some text along with a description of what that text means, e.g.,
4858 * the name of the entity being referenced, whether the text chunk is part of
4859 * the template, or whether it is a "placeholder" that the user should replace
4860 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4861 * description of the different kinds of chunks.
4862 */
4864
4865/**
4866 * A single result of code completion.
4867 */
4868typedef struct {
4869 /**
4870 * The kind of entity that this completion refers to.
4871 *
4872 * The cursor kind will be a macro, keyword, or a declaration (one of the
4873 * *Decl cursor kinds), describing the entity that the completion is
4874 * referring to.
4875 *
4876 * \todo In the future, we would like to provide a full cursor, to allow
4877 * the client to extract additional information from declaration.
4878 */
4880
4881 /**
4882 * The code-completion string that describes how to insert this
4883 * code-completion result into the editing buffer.
4884 */
4887
4888/**
4889 * Describes a single piece of text within a code-completion string.
4890 *
4891 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4892 * either a piece of text with a specific "kind" that describes how that text
4893 * should be interpreted by the client or is another completion string.
4894 */
4896 /**
4897 * A code-completion string that describes "optional" text that
4898 * could be a part of the template (but is not required).
4899 *
4900 * The Optional chunk is the only kind of chunk that has a code-completion
4901 * string for its representation, which is accessible via
4902 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4903 * describes an additional part of the template that is completely optional.
4904 * For example, optional chunks can be used to describe the placeholders for
4905 * arguments that match up with defaulted function parameters, e.g. given:
4906 *
4907 * \code
4908 * void f(int x, float y = 3.14, double z = 2.71828);
4909 * \endcode
4910 *
4911 * The code-completion string for this function would contain:
4912 * - a TypedText chunk for "f".
4913 * - a LeftParen chunk for "(".
4914 * - a Placeholder chunk for "int x"
4915 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4916 * - a Comma chunk for ","
4917 * - a Placeholder chunk for "float y"
4918 * - an Optional chunk containing the last defaulted argument:
4919 * - a Comma chunk for ","
4920 * - a Placeholder chunk for "double z"
4921 * - a RightParen chunk for ")"
4922 *
4923 * There are many ways to handle Optional chunks. Two simple approaches are:
4924 * - Completely ignore optional chunks, in which case the template for the
4925 * function "f" would only include the first parameter ("int x").
4926 * - Fully expand all optional chunks, in which case the template for the
4927 * function "f" would have all of the parameters.
4928 */
4930 /**
4931 * Text that a user would be expected to type to get this
4932 * code-completion result.
4933 *
4934 * There will be exactly one "typed text" chunk in a semantic string, which
4935 * will typically provide the spelling of a keyword or the name of a
4936 * declaration that could be used at the current code point. Clients are
4937 * expected to filter the code-completion results based on the text in this
4938 * chunk.
4939 */
4941 /**
4942 * Text that should be inserted as part of a code-completion result.
4943 *
4944 * A "text" chunk represents text that is part of the template to be
4945 * inserted into user code should this particular code-completion result
4946 * be selected.
4947 */
4949 /**
4950 * Placeholder text that should be replaced by the user.
4951 *
4952 * A "placeholder" chunk marks a place where the user should insert text
4953 * into the code-completion template. For example, placeholders might mark
4954 * the function parameters for a function declaration, to indicate that the
4955 * user should provide arguments for each of those parameters. The actual
4956 * text in a placeholder is a suggestion for the text to display before
4957 * the user replaces the placeholder with real code.
4958 */
4960 /**
4961 * Informative text that should be displayed but never inserted as
4962 * part of the template.
4963 *
4964 * An "informative" chunk contains annotations that can be displayed to
4965 * help the user decide whether a particular code-completion result is the
4966 * right option, but which is not part of the actual template to be inserted
4967 * by code completion.
4968 */
4970 /**
4971 * Text that describes the current parameter when code-completion is
4972 * referring to function call, message send, or template specialization.
4973 *
4974 * A "current parameter" chunk occurs when code-completion is providing
4975 * information about a parameter corresponding to the argument at the
4976 * code-completion point. For example, given a function
4977 *
4978 * \code
4979 * int add(int x, int y);
4980 * \endcode
4981 *
4982 * and the source code \c add(, where the code-completion point is after the
4983 * "(", the code-completion string will contain a "current parameter" chunk
4984 * for "int x", indicating that the current argument will initialize that
4985 * parameter. After typing further, to \c add(17, (where the code-completion
4986 * point is after the ","), the code-completion string will contain a
4987 * "current parameter" chunk to "int y".
4988 */
4990 /**
4991 * A left parenthesis ('('), used to initiate a function call or
4992 * signal the beginning of a function parameter list.
4993 */
4995 /**
4996 * A right parenthesis (')'), used to finish a function call or
4997 * signal the end of a function parameter list.
4998 */
5000 /**
5001 * A left bracket ('[').
5002 */
5004 /**
5005 * A right bracket (']').
5006 */
5008 /**
5009 * A left brace ('{').
5010 */
5012 /**
5013 * A right brace ('}').
5014 */
5016 /**
5017 * A left angle bracket ('<').
5018 */
5020 /**
5021 * A right angle bracket ('>').
5022 */
5024 /**
5025 * A comma separator (',').
5026 */
5028 /**
5029 * Text that specifies the result type of a given result.
5030 *
5031 * This special kind of informative chunk is not meant to be inserted into
5032 * the text buffer. Rather, it is meant to illustrate the type that an
5033 * expression using the given completion string would have.
5034 */
5036 /**
5037 * A colon (':').
5038 */
5040 /**
5041 * A semicolon (';').
5042 */
5044 /**
5045 * An '=' sign.
5046 */
5048 /**
5049 * Horizontal space (' ').
5050 */
5052 /**
5053 * Vertical space ('\\n'), after which it is generally a good idea to
5054 * perform indentation.
5055 */
5058
5059/**
5060 * Determine the kind of a particular chunk within a completion string.
5061 *
5062 * \param completion_string the completion string to query.
5063 *
5064 * \param chunk_number the 0-based index of the chunk in the completion string.
5065 *
5066 * \returns the kind of the chunk at the index \c chunk_number.
5067 */
5070 unsigned chunk_number);
5071
5072/**
5073 * Retrieve the text associated with a particular chunk within a
5074 * completion string.
5075 *
5076 * \param completion_string the completion string to query.
5077 *
5078 * \param chunk_number the 0-based index of the chunk in the completion string.
5079 *
5080 * \returns the text associated with the chunk at index \c chunk_number.
5081 */
5083 CXCompletionString completion_string, unsigned chunk_number);
5084
5085/**
5086 * Retrieve the completion string associated with a particular chunk
5087 * within a completion string.
5088 *
5089 * \param completion_string the completion string to query.
5090 *
5091 * \param chunk_number the 0-based index of the chunk in the completion string.
5092 *
5093 * \returns the completion string associated with the chunk at index
5094 * \c chunk_number.
5095 */
5097 CXCompletionString completion_string, unsigned chunk_number);
5098
5099/**
5100 * Retrieve the number of chunks in the given code-completion string.
5101 */
5102CINDEX_LINKAGE unsigned
5104
5105/**
5106 * Determine the priority of this code completion.
5107 *
5108 * The priority of a code completion indicates how likely it is that this
5109 * particular completion is the completion that the user will select. The
5110 * priority is selected by various internal heuristics.
5111 *
5112 * \param completion_string The completion string to query.
5113 *
5114 * \returns The priority of this completion string. Smaller values indicate
5115 * higher-priority (more likely) completions.
5116 */
5117CINDEX_LINKAGE unsigned
5119
5120/**
5121 * Determine the availability of the entity that this code-completion
5122 * string refers to.
5123 *
5124 * \param completion_string The completion string to query.
5125 *
5126 * \returns The availability of the completion string.
5127 */
5130
5131/**
5132 * Retrieve the number of annotations associated with the given
5133 * completion string.
5134 *
5135 * \param completion_string the completion string to query.
5136 *
5137 * \returns the number of annotations associated with the given completion
5138 * string.
5139 */
5140CINDEX_LINKAGE unsigned
5142
5143/**
5144 * Retrieve the annotation associated with the given completion string.
5145 *
5146 * \param completion_string the completion string to query.
5147 *
5148 * \param annotation_number the 0-based index of the annotation of the
5149 * completion string.
5150 *
5151 * \returns annotation string associated with the completion at index
5152 * \c annotation_number, or a NULL string if that annotation is not available.
5153 */
5155 CXCompletionString completion_string, unsigned annotation_number);
5156
5157/**
5158 * Retrieve the parent context of the given completion string.
5159 *
5160 * The parent context of a completion string is the semantic parent of
5161 * the declaration (if any) that the code completion represents. For example,
5162 * a code completion for an Objective-C method would have the method's class
5163 * or protocol as its context.
5164 *
5165 * \param completion_string The code completion string whose parent is
5166 * being queried.
5167 *
5168 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5169 *
5170 * \returns The name of the completion parent, e.g., "NSObject" if
5171 * the completion string represents a method in the NSObject class.
5172 */
5174 CXCompletionString completion_string, enum CXCursorKind *kind);
5175
5176/**
5177 * Retrieve the brief documentation comment attached to the declaration
5178 * that corresponds to the given completion string.
5179 */
5182
5183/**
5184 * Retrieve a completion string for an arbitrary declaration or macro
5185 * definition cursor.
5186 *
5187 * \param cursor The cursor to query.
5188 *
5189 * \returns A non-context-sensitive completion string for declaration and macro
5190 * definition cursors, or NULL for other kinds of cursors.
5191 */
5194
5195/**
5196 * Contains the results of code-completion.
5197 *
5198 * This data structure contains the results of code completion, as
5199 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5200 * \c clang_disposeCodeCompleteResults.
5201 */
5202typedef struct {
5203 /**
5204 * The code-completion results.
5205 */