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