clang  14.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 <time.h>
20 
21 #include "clang-c/BuildSystem.h"
22 #include "clang-c/CXErrorCode.h"
23 #include "clang-c/CXString.h"
24 #include "clang-c/ExternC.h"
25 #include "clang-c/Platform.h"
26 
27 /**
28  * The version constants for the libclang API.
29  * CINDEX_VERSION_MINOR should increase when there are API additions.
30  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
31  *
32  * The policy about the libclang API was always to keep it source and ABI
33  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
34  */
35 #define CINDEX_VERSION_MAJOR 0
36 #define CINDEX_VERSION_MINOR 62
37 
38 #define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
39 
40 #define CINDEX_VERSION \
41  CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
42 
43 #define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
44 #define CINDEX_VERSION_STRINGIZE(major, minor) \
45  CINDEX_VERSION_STRINGIZE_(major, minor)
46 
47 #define CINDEX_VERSION_STRING \
48  CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
49 
51 
52 /** \defgroup CINDEX libclang: C Interface to Clang
53  *
54  * The C Interface to Clang provides a relatively small API that exposes
55  * facilities for parsing source code into an abstract syntax tree (AST),
56  * loading already-parsed ASTs, traversing the AST, associating
57  * physical source locations with elements within the AST, and other
58  * facilities that support Clang-based development tools.
59  *
60  * This C interface to Clang will never provide all of the information
61  * representation stored in Clang's C++ AST, nor should it: the intent is to
62  * maintain an API that is relatively stable from one release to the next,
63  * providing only the basic functionality needed to support development tools.
64  *
65  * To avoid namespace pollution, data types are prefixed with "CX" and
66  * functions are prefixed with "clang_".
67  *
68  * @{
69  */
70 
71 /**
72  * An "index" that consists of a set of translation units that would
73  * typically be linked together into an executable or library.
74  */
75 typedef void *CXIndex;
76 
77 /**
78  * An opaque type representing target information for a given translation
79  * unit.
80  */
81 typedef struct CXTargetInfoImpl *CXTargetInfo;
82 
83 /**
84  * A single translation unit, which resides in an index.
85  */
86 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
87 
88 /**
89  * Opaque pointer representing client data that will be passed through
90  * to various callbacks and visitors.
91  */
92 typedef void *CXClientData;
93 
94 /**
95  * Provides the contents of a file that has not yet been saved to disk.
96  *
97  * Each CXUnsavedFile instance provides the name of a file on the
98  * system along with the current contents of that file that have not
99  * yet been saved to disk.
100  */
102  /**
103  * The file whose contents have not yet been saved.
104  *
105  * This file must already exist in the file system.
106  */
107  const char *Filename;
108 
109  /**
110  * A buffer containing the unsaved contents of this file.
111  */
112  const char *Contents;
113 
114  /**
115  * The length of the unsaved contents of this buffer.
116  */
117  unsigned long Length;
118 };
119 
120 /**
121  * Describes the availability of a particular entity, which indicates
122  * whether the use of this entity will result in a warning or error due to
123  * it being deprecated or unavailable.
124  */
126  /**
127  * The entity is available.
128  */
130  /**
131  * The entity is available, but has been deprecated (and its use is
132  * not recommended).
133  */
135  /**
136  * The entity is not available; any use of it will be an error.
137  */
139  /**
140  * The entity is available, but not accessible; any use of it will be
141  * an error.
142  */
144 };
145 
146 /**
147  * Describes a version number of the form major.minor.subminor.
148  */
149 typedef struct CXVersion {
150  /**
151  * The major version number, e.g., the '10' in '10.7.3'. A negative
152  * value indicates that there is no version number at all.
153  */
154  int Major;
155  /**
156  * The minor version number, e.g., the '7' in '10.7.3'. This value
157  * will be negative if no minor version number was provided, e.g., for
158  * version '10'.
159  */
160  int Minor;
161  /**
162  * The subminor version number, e.g., the '3' in '10.7.3'. This value
163  * will be negative if no minor or subminor version number was provided,
164  * e.g., in version '10' or '10.7'.
165  */
166  int Subminor;
167 } CXVersion;
168 
169 /**
170  * Describes the exception specification of a cursor.
171  *
172  * A negative value indicates that the cursor is not a function declaration.
173  */
175  /**
176  * The cursor has no exception specification.
177  */
179 
180  /**
181  * The cursor has exception specification throw()
182  */
184 
185  /**
186  * The cursor has exception specification throw(T1, T2)
187  */
189 
190  /**
191  * The cursor has exception specification throw(...).
192  */
194 
195  /**
196  * The cursor has exception specification basic noexcept.
197  */
199 
200  /**
201  * The cursor has exception specification computed noexcept.
202  */
204 
205  /**
206  * The exception specification has not yet been evaluated.
207  */
209 
210  /**
211  * The exception specification has not yet been instantiated.
212  */
214 
215  /**
216  * The exception specification has not been parsed yet.
217  */
219 
220  /**
221  * The cursor has a __declspec(nothrow) exception specification.
222  */
224 };
225 
226 /**
227  * Provides a shared context for creating translation units.
228  *
229  * It provides two options:
230  *
231  * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
232  * declarations (when loading any new translation units). A "local" declaration
233  * is one that belongs in the translation unit itself and not in a precompiled
234  * header that was used by the translation unit. If zero, all declarations
235  * will be enumerated.
236  *
237  * Here is an example:
238  *
239  * \code
240  * // excludeDeclsFromPCH = 1, displayDiagnostics=1
241  * Idx = clang_createIndex(1, 1);
242  *
243  * // IndexTest.pch was produced with the following command:
244  * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
245  * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
246  *
247  * // This will load all the symbols from 'IndexTest.pch'
248  * clang_visitChildren(clang_getTranslationUnitCursor(TU),
249  * TranslationUnitVisitor, 0);
250  * clang_disposeTranslationUnit(TU);
251  *
252  * // This will load all the symbols from 'IndexTest.c', excluding symbols
253  * // from 'IndexTest.pch'.
254  * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
255  * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
256  * 0, 0);
257  * clang_visitChildren(clang_getTranslationUnitCursor(TU),
258  * TranslationUnitVisitor, 0);
259  * clang_disposeTranslationUnit(TU);
260  * \endcode
261  *
262  * This process of creating the 'pch', loading it separately, and using it (via
263  * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
264  * (which gives the indexer the same performance benefit as the compiler).
265  */
266 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
267  int displayDiagnostics);
268 
269 /**
270  * Destroy the given index.
271  *
272  * The index must not be destroyed until all of the translation units created
273  * within that index have been destroyed.
274  */
276 
277 typedef enum {
278  /**
279  * Used to indicate that no special CXIndex options are needed.
280  */
282 
283  /**
284  * Used to indicate that threads that libclang creates for indexing
285  * purposes should use background priority.
286  *
287  * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
288  * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
289  */
291 
292  /**
293  * Used to indicate that threads that libclang creates for editing
294  * purposes should use background priority.
295  *
296  * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
297  * #clang_annotateTokens
298  */
300 
301  /**
302  * Used to indicate that all threads that libclang creates should use
303  * background priority.
304  */
308 
310 
311 /**
312  * Sets general options associated with a CXIndex.
313  *
314  * For example:
315  * \code
316  * CXIndex idx = ...;
317  * clang_CXIndex_setGlobalOptions(idx,
318  * clang_CXIndex_getGlobalOptions(idx) |
319  * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
320  * \endcode
321  *
322  * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
323  */
325 
326 /**
327  * Gets the general options associated with a CXIndex.
328  *
329  * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
330  * are associated with the given CXIndex object.
331  */
333 
334 /**
335  * Sets the invocation emission path option in a CXIndex.
336  *
337  * The invocation emission path specifies a path which will contain log
338  * files for certain libclang invocations. A null value (default) implies that
339  * libclang invocations are not logged..
340  */
341 CINDEX_LINKAGE void
343 
344 /**
345  * \defgroup CINDEX_FILES File manipulation routines
346  *
347  * @{
348  */
349 
350 /**
351  * A particular source file that is part of a translation unit.
352  */
353 typedef void *CXFile;
354 
355 /**
356  * Retrieve the complete file and path name of the given file.
357  */
359 
360 /**
361  * Retrieve the last modification time of the given file.
362  */
364 
365 /**
366  * Uniquely identifies a CXFile, that refers to the same underlying file,
367  * across an indexing session.
368  */
369 typedef struct {
370  unsigned long long data[3];
372 
373 /**
374  * Retrieve the unique ID for the given \c file.
375  *
376  * \param file the file to get the ID for.
377  * \param outID stores the returned CXFileUniqueID.
378  * \returns If there was a failure getting the unique ID, returns non-zero,
379  * otherwise returns 0.
380  */
382 
383 /**
384  * Determine whether the given header is guarded against
385  * multiple inclusions, either with the conventional
386  * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
387  */
389  CXFile file);
390 
391 /**
392  * Retrieve a file handle within the given translation unit.
393  *
394  * \param tu the translation unit
395  *
396  * \param file_name the name of the file.
397  *
398  * \returns the file handle for the named file in the translation unit \p tu,
399  * or a NULL file handle if the file was not a part of this translation unit.
400  */
402  const char *file_name);
403 
404 /**
405  * Retrieve the buffer associated with the given file.
406  *
407  * \param tu the translation unit
408  *
409  * \param file the file for which to retrieve the buffer.
410  *
411  * \param size [out] if non-NULL, will be set to the size of the buffer.
412  *
413  * \returns a pointer to the buffer in memory that holds the contents of
414  * \p file, or a NULL pointer when the file is not loaded.
415  */
417  CXFile file, size_t *size);
418 
419 /**
420  * Returns non-zero if the \c file1 and \c file2 point to the same file,
421  * or they are both NULL.
422  */
424 
425 /**
426  * Returns the real path name of \c file.
427  *
428  * An empty string may be returned. Use \c clang_getFileName() in that case.
429  */
431 
432 /**
433  * @}
434  */
435 
436 /**
437  * \defgroup CINDEX_LOCATIONS Physical source locations
438  *
439  * Clang represents physical source locations in its abstract syntax tree in
440  * great detail, with file, line, and column information for the majority of
441  * the tokens parsed in the source code. These data types and functions are
442  * used to represent source location information, either for a particular
443  * point in the program or for a range of points in the program, and extract
444  * specific location information from those data types.
445  *
446  * @{
447  */
448 
449 /**
450  * Identifies a specific source location within a translation
451  * unit.
452  *
453  * Use clang_getExpansionLocation() or clang_getSpellingLocation()
454  * to map a source location to a particular file, line, and column.
455  */
456 typedef struct {
457  const void *ptr_data[2];
458  unsigned int_data;
460 
461 /**
462  * Identifies a half-open character range in the source code.
463  *
464  * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
465  * starting and end locations from a source range, respectively.
466  */
467 typedef struct {
468  const void *ptr_data[2];
469  unsigned begin_int_data;
470  unsigned end_int_data;
471 } CXSourceRange;
472 
473 /**
474  * Retrieve a NULL (invalid) source location.
475  */
477 
478 /**
479  * Determine whether two source locations, which must refer into
480  * the same translation unit, refer to exactly the same point in the source
481  * code.
482  *
483  * \returns non-zero if the source locations refer to the same location, zero
484  * if they refer to different locations.
485  */
487  CXSourceLocation loc2);
488 
489 /**
490  * Retrieves the source location associated with a given file/line/column
491  * in a particular translation unit.
492  */
494  CXFile file, unsigned line,
495  unsigned column);
496 /**
497  * Retrieves the source location associated with a given character offset
498  * in a particular translation unit.
499  */
501  CXFile file,
502  unsigned offset);
503 
504 /**
505  * Returns non-zero if the given source location is in a system header.
506  */
508 
509 /**
510  * Returns non-zero if the given source location is in the main file of
511  * the corresponding translation unit.
512  */
514 
515 /**
516  * Retrieve a NULL (invalid) source range.
517  */
519 
520 /**
521  * Retrieve a source range given the beginning and ending source
522  * locations.
523  */
525  CXSourceLocation end);
526 
527 /**
528  * Determine whether two ranges are equivalent.
529  *
530  * \returns non-zero if the ranges are the same, zero if they differ.
531  */
533  CXSourceRange range2);
534 
535 /**
536  * Returns non-zero if \p range is null.
537  */
539 
540 /**
541  * Retrieve the file, line, column, and offset represented by
542  * the given source location.
543  *
544  * If the location refers into a macro expansion, retrieves the
545  * location of the macro expansion.
546  *
547  * \param location the location within a source file that will be decomposed
548  * into its parts.
549  *
550  * \param file [out] if non-NULL, will be set to the file to which the given
551  * source location points.
552  *
553  * \param line [out] if non-NULL, will be set to the line to which the given
554  * source location points.
555  *
556  * \param column [out] if non-NULL, will be set to the column to which the given
557  * source location points.
558  *
559  * \param offset [out] if non-NULL, will be set to the offset into the
560  * buffer to which the given source location points.
561  */
563  CXFile *file, unsigned *line,
564  unsigned *column,
565  unsigned *offset);
566 
567 /**
568  * Retrieve the file, line and column represented by the given source
569  * location, as specified in a # line directive.
570  *
571  * Example: given the following source code in a file somefile.c
572  *
573  * \code
574  * #123 "dummy.c" 1
575  *
576  * static int func(void)
577  * {
578  * return 0;
579  * }
580  * \endcode
581  *
582  * the location information returned by this function would be
583  *
584  * File: dummy.c Line: 124 Column: 12
585  *
586  * whereas clang_getExpansionLocation would have returned
587  *
588  * File: somefile.c Line: 3 Column: 12
589  *
590  * \param location the location within a source file that will be decomposed
591  * into its parts.
592  *
593  * \param filename [out] if non-NULL, will be set to the filename of the
594  * source location. Note that filenames returned will be for "virtual" files,
595  * which don't necessarily exist on the machine running clang - e.g. when
596  * parsing preprocessed output obtained from a different environment. If
597  * a non-NULL value is passed in, remember to dispose of the returned value
598  * using \c clang_disposeString() once you've finished with it. For an invalid
599  * source location, an empty string is returned.
600  *
601  * \param line [out] if non-NULL, will be set to the line number of the
602  * source location. For an invalid source location, zero is returned.
603  *
604  * \param column [out] if non-NULL, will be set to the column number of the
605  * source location. For an invalid source location, zero is returned.
606  */
608  CXString *filename,
609  unsigned *line, unsigned *column);
610 
611 /**
612  * Legacy API to retrieve the file, line, column, and offset represented
613  * by the given source location.
614  *
615  * This interface has been replaced by the newer interface
616  * #clang_getExpansionLocation(). See that interface's documentation for
617  * details.
618  */
620  CXFile *file, unsigned *line,
621  unsigned *column,
622  unsigned *offset);
623 
624 /**
625  * Retrieve the file, line, column, and offset represented by
626  * the given source location.
627  *
628  * If the location refers into a macro instantiation, return where the
629  * location was originally spelled in the source file.
630  *
631  * \param location the location within a source file that will be decomposed
632  * into its parts.
633  *
634  * \param file [out] if non-NULL, will be set to the file to which the given
635  * source location points.
636  *
637  * \param line [out] if non-NULL, will be set to the line to which the given
638  * source location points.
639  *
640  * \param column [out] if non-NULL, will be set to the column to which the given
641  * source location points.
642  *
643  * \param offset [out] if non-NULL, will be set to the offset into the
644  * buffer to which the given source location points.
645  */
647  CXFile *file, unsigned *line,
648  unsigned *column,
649  unsigned *offset);
650 
651 /**
652  * Retrieve the file, line, column, and offset represented by
653  * the given source location.
654  *
655  * If the location refers into a macro expansion, return where the macro was
656  * expanded or where the macro argument was written, if the location points at
657  * a macro argument.
658  *
659  * \param location the location within a source file that will be decomposed
660  * into its parts.
661  *
662  * \param file [out] if non-NULL, will be set to the file to which the given
663  * source location points.
664  *
665  * \param line [out] if non-NULL, will be set to the line to which the given
666  * source location points.
667  *
668  * \param column [out] if non-NULL, will be set to the column to which the given
669  * source location points.
670  *
671  * \param offset [out] if non-NULL, will be set to the offset into the
672  * buffer to which the given source location points.
673  */
675  CXFile *file, unsigned *line,
676  unsigned *column, unsigned *offset);
677 
678 /**
679  * Retrieve a source location representing the first character within a
680  * source range.
681  */
683 
684 /**
685  * Retrieve a source location representing the last character within a
686  * source range.
687  */
689 
690 /**
691  * Identifies an array of ranges.
692  */
693 typedef struct {
694  /** The number of ranges in the \c ranges array. */
695  unsigned count;
696  /**
697  * An array of \c CXSourceRanges.
698  */
701 
702 /**
703  * Retrieve all ranges that were skipped by the preprocessor.
704  *
705  * The preprocessor will skip lines when they are surrounded by an
706  * if/ifdef/ifndef directive whose condition does not evaluate to true.
707  */
709  CXFile file);
710 
711 /**
712  * Retrieve all ranges from all files that were skipped by the
713  * preprocessor.
714  *
715  * The preprocessor will skip lines when they are surrounded by an
716  * if/ifdef/ifndef directive whose condition does not evaluate to true.
717  */
720 
721 /**
722  * Destroy the given \c CXSourceRangeList.
723  */
725 
726 /**
727  * @}
728  */
729 
730 /**
731  * \defgroup CINDEX_DIAG Diagnostic reporting
732  *
733  * @{
734  */
735 
736 /**
737  * Describes the severity of a particular diagnostic.
738  */
740  /**
741  * A diagnostic that has been suppressed, e.g., by a command-line
742  * option.
743  */
745 
746  /**
747  * This diagnostic is a note that should be attached to the
748  * previous (non-note) diagnostic.
749  */
751 
752  /**
753  * This diagnostic indicates suspicious code that may not be
754  * wrong.
755  */
757 
758  /**
759  * This diagnostic indicates that the code is ill-formed.
760  */
762 
763  /**
764  * This diagnostic indicates that the code is ill-formed such
765  * that future parser recovery is unlikely to produce useful
766  * results.
767  */
769 };
770 
771 /**
772  * A single diagnostic, containing the diagnostic's severity,
773  * location, text, source ranges, and fix-it hints.
774  */
775 typedef void *CXDiagnostic;
776 
777 /**
778  * A group of CXDiagnostics.
779  */
780 typedef void *CXDiagnosticSet;
781 
782 /**
783  * Determine the number of diagnostics in a CXDiagnosticSet.
784  */
786 
787 /**
788  * Retrieve a diagnostic associated with the given CXDiagnosticSet.
789  *
790  * \param Diags the CXDiagnosticSet to query.
791  * \param Index the zero-based diagnostic number to retrieve.
792  *
793  * \returns the requested diagnostic. This diagnostic must be freed
794  * via a call to \c clang_disposeDiagnostic().
795  */
797  unsigned Index);
798 
799 /**
800  * Describes the kind of error that occurred (if any) in a call to
801  * \c clang_loadDiagnostics.
802  */
804  /**
805  * Indicates that no error occurred.
806  */
808 
809  /**
810  * Indicates that an unknown error occurred while attempting to
811  * deserialize diagnostics.
812  */
814 
815  /**
816  * Indicates that the file containing the serialized diagnostics
817  * could not be opened.
818  */
820 
821  /**
822  * Indicates that the serialized diagnostics file is invalid or
823  * corrupt.
824  */
826 };
827 
828 /**
829  * Deserialize a set of diagnostics from a Clang diagnostics bitcode
830  * file.
831  *
832  * \param file The name of the file to deserialize.
833  * \param error A pointer to a enum value recording if there was a problem
834  * deserializing the diagnostics.
835  * \param errorString A pointer to a CXString for recording the error string
836  * if the file was not successfully loaded.
837  *
838  * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
839  * diagnostics should be released using clang_disposeDiagnosticSet().
840  */
842  const char *file, enum CXLoadDiag_Error *error, CXString *errorString);
843 
844 /**
845  * Release a CXDiagnosticSet and all of its contained diagnostics.
846  */
848 
849 /**
850  * Retrieve the child diagnostics of a CXDiagnostic.
851  *
852  * This CXDiagnosticSet does not need to be released by
853  * clang_disposeDiagnosticSet.
854  */
856 
857 /**
858  * Determine the number of diagnostics produced for the given
859  * translation unit.
860  */
862 
863 /**
864  * Retrieve a diagnostic associated with the given translation unit.
865  *
866  * \param Unit the translation unit to query.
867  * \param Index the zero-based diagnostic number to retrieve.
868  *
869  * \returns the requested diagnostic. This diagnostic must be freed
870  * via a call to \c clang_disposeDiagnostic().
871  */
873  unsigned Index);
874 
875 /**
876  * Retrieve the complete set of diagnostics associated with a
877  * translation unit.
878  *
879  * \param Unit the translation unit to query.
880  */
883 
884 /**
885  * Destroy a diagnostic.
886  */
888 
889 /**
890  * Options to control the display of diagnostics.
891  *
892  * The values in this enum are meant to be combined to customize the
893  * behavior of \c clang_formatDiagnostic().
894  */
896  /**
897  * Display the source-location information where the
898  * diagnostic was located.
899  *
900  * When set, diagnostics will be prefixed by the file, line, and
901  * (optionally) column to which the diagnostic refers. For example,
902  *
903  * \code
904  * test.c:28: warning: extra tokens at end of #endif directive
905  * \endcode
906  *
907  * This option corresponds to the clang flag \c -fshow-source-location.
908  */
910 
911  /**
912  * If displaying the source-location information of the
913  * diagnostic, also include the column number.
914  *
915  * This option corresponds to the clang flag \c -fshow-column.
916  */
918 
919  /**
920  * If displaying the source-location information of the
921  * diagnostic, also include information about source ranges in a
922  * machine-parsable format.
923  *
924  * This option corresponds to the clang flag
925  * \c -fdiagnostics-print-source-range-info.
926  */
928 
929  /**
930  * Display the option name associated with this diagnostic, if any.
931  *
932  * The option name displayed (e.g., -Wconversion) will be placed in brackets
933  * after the diagnostic text. This option corresponds to the clang flag
934  * \c -fdiagnostics-show-option.
935  */
937 
938  /**
939  * Display the category number associated with this diagnostic, if any.
940  *
941  * The category number is displayed within brackets after the diagnostic text.
942  * This option corresponds to the clang flag
943  * \c -fdiagnostics-show-category=id.
944  */
946 
947  /**
948  * Display the category name associated with this diagnostic, if any.
949  *
950  * The category name is displayed within brackets after the diagnostic text.
951  * This option corresponds to the clang flag
952  * \c -fdiagnostics-show-category=name.
953  */
955 };
956 
957 /**
958  * Format the given diagnostic in a manner that is suitable for display.
959  *
960  * This routine will format the given diagnostic to a string, rendering
961  * the diagnostic according to the various options given. The
962  * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
963  * options that most closely mimics the behavior of the clang compiler.
964  *
965  * \param Diagnostic The diagnostic to print.
966  *
967  * \param Options A set of options that control the diagnostic display,
968  * created by combining \c CXDiagnosticDisplayOptions values.
969  *
970  * \returns A new string containing for formatted diagnostic.
971  */
973  unsigned Options);
974 
975 /**
976  * Retrieve the set of display options most similar to the
977  * default behavior of the clang compiler.
978  *
979  * \returns A set of display options suitable for use with \c
980  * clang_formatDiagnostic().
981  */
983 
984 /**
985  * Determine the severity of the given diagnostic.
986  */
989 
990 /**
991  * Retrieve the source location of the given diagnostic.
992  *
993  * This location is where Clang would print the caret ('^') when
994  * displaying the diagnostic on the command line.
995  */
997 
998 /**
999  * Retrieve the text of the given diagnostic.
1000  */
1002 
1003 /**
1004  * Retrieve the name of the command-line option that enabled this
1005  * diagnostic.
1006  *
1007  * \param Diag The diagnostic to be queried.
1008  *
1009  * \param Disable If non-NULL, will be set to the option that disables this
1010  * diagnostic (if any).
1011  *
1012  * \returns A string that contains the command-line option used to enable this
1013  * warning, such as "-Wconversion" or "-pedantic".
1014  */
1016  CXString *Disable);
1017 
1018 /**
1019  * Retrieve the category number for this diagnostic.
1020  *
1021  * Diagnostics can be categorized into groups along with other, related
1022  * diagnostics (e.g., diagnostics under the same warning flag). This routine
1023  * retrieves the category number for the given diagnostic.
1024  *
1025  * \returns The number of the category that contains this diagnostic, or zero
1026  * if this diagnostic is uncategorized.
1027  */
1029 
1030 /**
1031  * Retrieve the name of a particular diagnostic category. This
1032  * is now deprecated. Use clang_getDiagnosticCategoryText()
1033  * instead.
1034  *
1035  * \param Category A diagnostic category number, as returned by
1036  * \c clang_getDiagnosticCategory().
1037  *
1038  * \returns The name of the given diagnostic category.
1039  */
1042 
1043 /**
1044  * Retrieve the diagnostic category text for a given diagnostic.
1045  *
1046  * \returns The text of the given diagnostic category.
1047  */
1049 
1050 /**
1051  * Determine the number of source ranges associated with the given
1052  * diagnostic.
1053  */
1055 
1056 /**
1057  * Retrieve a source range associated with the diagnostic.
1058  *
1059  * A diagnostic's source ranges highlight important elements in the source
1060  * code. On the command line, Clang displays source ranges by
1061  * underlining them with '~' characters.
1062  *
1063  * \param Diagnostic the diagnostic whose range is being extracted.
1064  *
1065  * \param Range the zero-based index specifying which range to
1066  *
1067  * \returns the requested source range.
1068  */
1070  unsigned Range);
1071 
1072 /**
1073  * Determine the number of fix-it hints associated with the
1074  * given diagnostic.
1075  */
1077 
1078 /**
1079  * Retrieve the replacement information for a given fix-it.
1080  *
1081  * Fix-its are described in terms of a source range whose contents
1082  * should be replaced by a string. This approach generalizes over
1083  * three kinds of operations: removal of source code (the range covers
1084  * the code to be removed and the replacement string is empty),
1085  * replacement of source code (the range covers the code to be
1086  * replaced and the replacement string provides the new code), and
1087  * insertion (both the start and end of the range point at the
1088  * insertion location, and the replacement string provides the text to
1089  * insert).
1090  *
1091  * \param Diagnostic The diagnostic whose fix-its are being queried.
1092  *
1093  * \param FixIt The zero-based index of the fix-it.
1094  *
1095  * \param ReplacementRange The source range whose contents will be
1096  * replaced with the returned replacement string. Note that source
1097  * ranges are half-open ranges [a, b), so the source code should be
1098  * replaced from a and up to (but not including) b.
1099  *
1100  * \returns A string containing text that should be replace the source
1101  * code indicated by the \c ReplacementRange.
1102  */
1104  CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange *ReplacementRange);
1105 
1106 /**
1107  * @}
1108  */
1109 
1110 /**
1111  * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1112  *
1113  * The routines in this group provide the ability to create and destroy
1114  * translation units from files, either by parsing the contents of the files or
1115  * by reading in a serialized representation of a translation unit.
1116  *
1117  * @{
1118  */
1119 
1120 /**
1121  * Get the original translation unit source file name.
1122  */
1125 
1126 /**
1127  * Return the CXTranslationUnit for a given source file and the provided
1128  * command line arguments one would pass to the compiler.
1129  *
1130  * Note: The 'source_filename' argument is optional. If the caller provides a
1131  * NULL pointer, the name of the source file is expected to reside in the
1132  * specified command line arguments.
1133  *
1134  * Note: When encountered in 'clang_command_line_args', the following options
1135  * are ignored:
1136  *
1137  * '-c'
1138  * '-emit-ast'
1139  * '-fsyntax-only'
1140  * '-o <output file>' (both '-o' and '<output file>' are ignored)
1141  *
1142  * \param CIdx The index object with which the translation unit will be
1143  * associated.
1144  *
1145  * \param source_filename The name of the source file to load, or NULL if the
1146  * source file is included in \p clang_command_line_args.
1147  *
1148  * \param num_clang_command_line_args The number of command-line arguments in
1149  * \p clang_command_line_args.
1150  *
1151  * \param clang_command_line_args The command-line arguments that would be
1152  * passed to the \c clang executable if it were being invoked out-of-process.
1153  * These command-line options will be parsed and will affect how the translation
1154  * unit is parsed. Note that the following options are ignored: '-c',
1155  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
1156  *
1157  * \param num_unsaved_files the number of unsaved file entries in \p
1158  * unsaved_files.
1159  *
1160  * \param unsaved_files the files that have not yet been saved to disk
1161  * but may be required for code completion, including the contents of
1162  * those files. The contents and name of these files (as specified by
1163  * CXUnsavedFile) are copied when necessary, so the client only needs to
1164  * guarantee their validity until the call to this function returns.
1165  */
1167  CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
1168  const char *const *clang_command_line_args, unsigned num_unsaved_files,
1169  struct CXUnsavedFile *unsaved_files);
1170 
1171 /**
1172  * Same as \c clang_createTranslationUnit2, but returns
1173  * the \c CXTranslationUnit instead of an error code. In case of an error this
1174  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1175  * error codes.
1176  */
1178 clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
1179 
1180 /**
1181  * Create a translation unit from an AST file (\c -emit-ast).
1182  *
1183  * \param[out] out_TU A non-NULL pointer to store the created
1184  * \c CXTranslationUnit.
1185  *
1186  * \returns Zero on success, otherwise returns an error code.
1187  */
1189 clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
1190  CXTranslationUnit *out_TU);
1191 
1192 /**
1193  * Flags that control the creation of translation units.
1194  *
1195  * The enumerators in this enumeration type are meant to be bitwise
1196  * ORed together to specify which options should be used when
1197  * constructing the translation unit.
1198  */
1200  /**
1201  * Used to indicate that no special translation-unit options are
1202  * needed.
1203  */
1205 
1206  /**
1207  * Used to indicate that the parser should construct a "detailed"
1208  * preprocessing record, including all macro definitions and instantiations.
1209  *
1210  * Constructing a detailed preprocessing record requires more memory
1211  * and time to parse, since the information contained in the record
1212  * is usually not retained. However, it can be useful for
1213  * applications that require more detailed information about the
1214  * behavior of the preprocessor.
1215  */
1217 
1218  /**
1219  * Used to indicate that the translation unit is incomplete.
1220  *
1221  * When a translation unit is considered "incomplete", semantic
1222  * analysis that is typically performed at the end of the
1223  * translation unit will be suppressed. For example, this suppresses
1224  * the completion of tentative declarations in C and of
1225  * instantiation of implicitly-instantiation function templates in
1226  * C++. This option is typically used when parsing a header with the
1227  * intent of producing a precompiled header.
1228  */
1230 
1231  /**
1232  * Used to indicate that the translation unit should be built with an
1233  * implicit precompiled header for the preamble.
1234  *
1235  * An implicit precompiled header is used as an optimization when a
1236  * particular translation unit is likely to be reparsed many times
1237  * when the sources aren't changing that often. In this case, an
1238  * implicit precompiled header will be built containing all of the
1239  * initial includes at the top of the main file (what we refer to as
1240  * the "preamble" of the file). In subsequent parses, if the
1241  * preamble or the files in it have not changed, \c
1242  * clang_reparseTranslationUnit() will re-use the implicit
1243  * precompiled header to improve parsing performance.
1244  */
1246 
1247  /**
1248  * Used to indicate that the translation unit should cache some
1249  * code-completion results with each reparse of the source file.
1250  *
1251  * Caching of code-completion results is a performance optimization that
1252  * introduces some overhead to reparsing but improves the performance of
1253  * code-completion operations.
1254  */
1256 
1257  /**
1258  * Used to indicate that the translation unit will be serialized with
1259  * \c clang_saveTranslationUnit.
1260  *
1261  * This option is typically used when parsing a header with the intent of
1262  * producing a precompiled header.
1263  */
1265 
1266  /**
1267  * DEPRECATED: Enabled chained precompiled preambles in C++.
1268  *
1269  * Note: this is a *temporary* option that is available only while
1270  * we are testing C++ precompiled preamble support. It is deprecated.
1271  */
1273 
1274  /**
1275  * Used to indicate that function/method bodies should be skipped while
1276  * parsing.
1277  *
1278  * This option can be used to search for declarations/definitions while
1279  * ignoring the usages.
1280  */
1282 
1283  /**
1284  * Used to indicate that brief documentation comments should be
1285  * included into the set of code completions returned from this translation
1286  * unit.
1287  */
1289 
1290  /**
1291  * Used to indicate that the precompiled preamble should be created on
1292  * the first parse. Otherwise it will be created on the first reparse. This
1293  * trades runtime on the first parse (serializing the preamble takes time) for
1294  * reduced runtime on the second parse (can now reuse the preamble).
1295  */
1297 
1298  /**
1299  * Do not stop processing when fatal errors are encountered.
1300  *
1301  * When fatal errors are encountered while parsing a translation unit,
1302  * semantic analysis is typically stopped early when compiling code. A common
1303  * source for fatal errors are unresolvable include files. For the
1304  * purposes of an IDE, this is undesirable behavior and as much information
1305  * as possible should be reported. Use this flag to enable this behavior.
1306  */
1308 
1309  /**
1310  * Sets the preprocessor in a mode for parsing a single file only.
1311  */
1313 
1314  /**
1315  * Used in combination with CXTranslationUnit_SkipFunctionBodies to
1316  * constrain the skipping of function bodies to the preamble.
1317  *
1318  * The function bodies of the main file are not skipped.
1319  */
1321 
1322  /**
1323  * Used to indicate that attributed types should be included in CXType.
1324  */
1326 
1327  /**
1328  * Used to indicate that implicit attributes should be visited.
1329  */
1331 
1332  /**
1333  * Used to indicate that non-errors from included files should be ignored.
1334  *
1335  * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
1336  * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
1337  * the case where these warnings are not of interest, as for an IDE for
1338  * example, which typically shows only the diagnostics in the main file.
1339  */
1341 
1342  /**
1343  * Tells the preprocessor not to skip excluded conditional blocks.
1344  */
1346 };
1347 
1348 /**
1349  * Returns the set of flags that is suitable for parsing a translation
1350  * unit that is being edited.
1351  *
1352  * The set of flags returned provide options for \c clang_parseTranslationUnit()
1353  * to indicate that the translation unit is likely to be reparsed many times,
1354  * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1355  * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1356  * set contains an unspecified set of optimizations (e.g., the precompiled
1357  * preamble) geared toward improving the performance of these routines. The
1358  * set of optimizations enabled may change from one version to the next.
1359  */
1361 
1362 /**
1363  * Same as \c clang_parseTranslationUnit2, but returns
1364  * the \c CXTranslationUnit instead of an error code. In case of an error this
1365  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1366  * error codes.
1367  */
1369  CXIndex CIdx, const char *source_filename,
1370  const char *const *command_line_args, int num_command_line_args,
1371  struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1372  unsigned options);
1373 
1374 /**
1375  * Parse the given source file and the translation unit corresponding
1376  * to that file.
1377  *
1378  * This routine is the main entry point for the Clang C API, providing the
1379  * ability to parse a source file into a translation unit that can then be
1380  * queried by other functions in the API. This routine accepts a set of
1381  * command-line arguments so that the compilation can be configured in the same
1382  * way that the compiler is configured on the command line.
1383  *
1384  * \param CIdx The index object with which the translation unit will be
1385  * associated.
1386  *
1387  * \param source_filename The name of the source file to load, or NULL if the
1388  * source file is included in \c command_line_args.
1389  *
1390  * \param command_line_args The command-line arguments that would be
1391  * passed to the \c clang executable if it were being invoked out-of-process.
1392  * These command-line options will be parsed and will affect how the translation
1393  * unit is parsed. Note that the following options are ignored: '-c',
1394  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
1395  *
1396  * \param num_command_line_args The number of command-line arguments in
1397  * \c command_line_args.
1398  *
1399  * \param unsaved_files the files that have not yet been saved to disk
1400  * but may be required for parsing, including the contents of
1401  * those files. The contents and name of these files (as specified by
1402  * CXUnsavedFile) are copied when necessary, so the client only needs to
1403  * guarantee their validity until the call to this function returns.
1404  *
1405  * \param num_unsaved_files the number of unsaved file entries in \p
1406  * unsaved_files.
1407  *
1408  * \param options A bitmask of options that affects how the translation unit
1409  * is managed but not its compilation. This should be a bitwise OR of the
1410  * CXTranslationUnit_XXX flags.
1411  *
1412  * \param[out] out_TU A non-NULL pointer to store the created
1413  * \c CXTranslationUnit, describing the parsed code and containing any
1414  * diagnostics produced by the compiler.
1415  *
1416  * \returns Zero on success, otherwise returns an error code.
1417  */
1419  CXIndex CIdx, const char *source_filename,
1420  const char *const *command_line_args, int num_command_line_args,
1421  struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1422  unsigned options, CXTranslationUnit *out_TU);
1423 
1424 /**
1425  * Same as clang_parseTranslationUnit2 but requires a full command line
1426  * for \c command_line_args including argv[0]. This is useful if the standard
1427  * library paths are relative to the binary.
1428  */
1430  CXIndex CIdx, const char *source_filename,
1431  const char *const *command_line_args, int num_command_line_args,
1432  struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1433  unsigned options, CXTranslationUnit *out_TU);
1434 
1435 /**
1436  * Flags that control how translation units are saved.
1437  *
1438  * The enumerators in this enumeration type are meant to be bitwise
1439  * ORed together to specify which options should be used when
1440  * saving the translation unit.
1441  */
1443  /**
1444  * Used to indicate that no special saving options are needed.
1445  */
1447 };
1448 
1449 /**
1450  * Returns the set of flags that is suitable for saving a translation
1451  * unit.
1452  *
1453  * The set of flags returned provide options for
1454  * \c clang_saveTranslationUnit() by default. The returned flag
1455  * set contains an unspecified set of options that save translation units with
1456  * the most commonly-requested data.
1457  */
1459 
1460 /**
1461  * Describes the kind of error that occurred (if any) in a call to
1462  * \c clang_saveTranslationUnit().
1463  */
1465  /**
1466  * Indicates that no error occurred while saving a translation unit.
1467  */
1469 
1470  /**
1471  * Indicates that an unknown error occurred while attempting to save
1472  * the file.
1473  *
1474  * This error typically indicates that file I/O failed when attempting to
1475  * write the file.
1476  */
1478 
1479  /**
1480  * Indicates that errors during translation prevented this attempt
1481  * to save the translation unit.
1482  *
1483  * Errors that prevent the translation unit from being saved can be
1484  * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1485  */
1487 
1488  /**
1489  * Indicates that the translation unit to be saved was somehow
1490  * invalid (e.g., NULL).
1491  */
1493 };
1494 
1495 /**
1496  * Saves a translation unit into a serialized representation of
1497  * that translation unit on disk.
1498  *
1499  * Any translation unit that was parsed without error can be saved
1500  * into a file. The translation unit can then be deserialized into a
1501  * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1502  * if it is an incomplete translation unit that corresponds to a
1503  * header, used as a precompiled header when parsing other translation
1504  * units.
1505  *
1506  * \param TU The translation unit to save.
1507  *
1508  * \param FileName The file to which the translation unit will be saved.
1509  *
1510  * \param options A bitmask of options that affects how the translation unit
1511  * is saved. This should be a bitwise OR of the
1512  * CXSaveTranslationUnit_XXX flags.
1513  *
1514  * \returns A value that will match one of the enumerators of the CXSaveError
1515  * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1516  * saved successfully, while a non-zero value indicates that a problem occurred.
1517  */
1519  const char *FileName,
1520  unsigned options);
1521 
1522 /**
1523  * Suspend a translation unit in order to free memory associated with it.
1524  *
1525  * A suspended translation unit uses significantly less memory but on the other
1526  * side does not support any other calls than \c clang_reparseTranslationUnit
1527  * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1528  */
1530 
1531 /**
1532  * Destroy the specified CXTranslationUnit object.
1533  */
1535 
1536 /**
1537  * Flags that control the reparsing of translation units.
1538  *
1539  * The enumerators in this enumeration type are meant to be bitwise
1540  * ORed together to specify which options should be used when
1541  * reparsing the translation unit.
1542  */
1544  /**
1545  * Used to indicate that no special reparsing options are needed.
1546  */
1548 };
1549 
1550 /**
1551  * Returns the set of flags that is suitable for reparsing a translation
1552  * unit.
1553  *
1554  * The set of flags returned provide options for
1555  * \c clang_reparseTranslationUnit() by default. The returned flag
1556  * set contains an unspecified set of optimizations geared toward common uses
1557  * of reparsing. The set of optimizations enabled may change from one version
1558  * to the next.
1559  */
1561 
1562 /**
1563  * Reparse the source files that produced this translation unit.
1564  *
1565  * This routine can be used to re-parse the source files that originally
1566  * created the given translation unit, for example because those source files
1567  * have changed (either on disk or as passed via \p unsaved_files). The
1568  * source code will be reparsed with the same command-line options as it
1569  * was originally parsed.
1570  *
1571  * Reparsing a translation unit invalidates all cursors and source locations
1572  * that refer into that translation unit. This makes reparsing a translation
1573  * unit semantically equivalent to destroying the translation unit and then
1574  * creating a new translation unit with the same command-line arguments.
1575  * However, it may be more efficient to reparse a translation
1576  * unit using this routine.
1577  *
1578  * \param TU The translation unit whose contents will be re-parsed. The
1579  * translation unit must originally have been built with
1580  * \c clang_createTranslationUnitFromSourceFile().
1581  *
1582  * \param num_unsaved_files The number of unsaved file entries in \p
1583  * unsaved_files.
1584  *
1585  * \param unsaved_files The files that have not yet been saved to disk
1586  * but may be required for parsing, including the contents of
1587  * those files. The contents and name of these files (as specified by
1588  * CXUnsavedFile) are copied when necessary, so the client only needs to
1589  * guarantee their validity until the call to this function returns.
1590  *
1591  * \param options A bitset of options composed of the flags in CXReparse_Flags.
1592  * The function \c clang_defaultReparseOptions() produces a default set of
1593  * options recommended for most uses, based on the translation unit.
1594  *
1595  * \returns 0 if the sources could be reparsed. A non-zero error code will be
1596  * returned if reparsing was impossible, such that the translation unit is
1597  * invalid. In such cases, the only valid call for \c TU is
1598  * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1599  * routine are described by the \c CXErrorCode enum.
1600  */
1601 CINDEX_LINKAGE int
1602 clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
1603  struct CXUnsavedFile *unsaved_files,
1604  unsigned options);
1605 
1606 /**
1607  * Categorizes how memory is being used by a translation unit.
1608  */
1627 
1630 };
1631 
1632 /**
1633  * Returns the human-readable null-terminated C string that represents
1634  * the name of the memory category. This string should never be freed.
1635  */
1638 
1639 typedef struct CXTUResourceUsageEntry {
1640  /* The memory usage category. */
1642  /* Amount of resources used.
1643  The units will depend on the resource kind. */
1644  unsigned long amount;
1646 
1647 /**
1648  * The memory usage of a CXTranslationUnit, broken into categories.
1649  */
1650 typedef struct CXTUResourceUsage {
1651  /* Private data member, used for queries. */
1652  void *data;
1653 
1654  /* The number of entries in the 'entries' array. */
1655  unsigned numEntries;
1656 
1657  /* An array of key-value pairs, representing the breakdown of memory
1658  usage. */
1660 
1662 
1663 /**
1664  * Return the memory usage of a translation unit. This object
1665  * should be released with clang_disposeCXTUResourceUsage().
1666  */
1669 
1671 
1672 /**
1673  * Get target information for this translation unit.
1674  *
1675  * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1676  */
1679 
1680 /**
1681  * Destroy the CXTargetInfo object.
1682  */
1684 
1685 /**
1686  * Get the normalized target triple as a string.
1687  *
1688  * Returns the empty string in case of any error.
1689  */
1691 
1692 /**
1693  * Get the pointer width of the target in bits.
1694  *
1695  * Returns -1 in case of error.
1696  */
1698 
1699 /**
1700  * @}
1701  */
1702 
1703 /**
1704  * Describes the kind of entity that a cursor refers to.
1705  */
1707  /* Declarations */
1708  /**
1709  * A declaration whose specific kind is not exposed via this
1710  * interface.
1711  *
1712  * Unexposed declarations have the same operations as any other kind
1713  * of declaration; one can extract their location information,
1714  * spelling, find their definitions, etc. However, the specific kind
1715  * of the declaration is not reported.
1716  */
1718  /** A C or C++ struct. */
1720  /** A C or C++ union. */
1722  /** A C++ class. */
1724  /** An enumeration. */
1726  /**
1727  * A field (in C) or non-static data member (in C++) in a
1728  * struct, union, or C++ class.
1729  */
1731  /** An enumerator constant. */
1733  /** A function. */
1735  /** A variable. */
1737  /** A function or method parameter. */
1739  /** An Objective-C \@interface. */
1741  /** An Objective-C \@interface for a category. */
1743  /** An Objective-C \@protocol declaration. */
1745  /** An Objective-C \@property declaration. */
1747  /** An Objective-C instance variable. */
1749  /** An Objective-C instance method. */
1751  /** An Objective-C class method. */
1753  /** An Objective-C \@implementation. */
1755  /** An Objective-C \@implementation for a category. */
1757  /** A typedef. */
1759  /** A C++ class method. */
1761  /** A C++ namespace. */
1763  /** A linkage specification, e.g. 'extern "C"'. */
1765  /** A C++ constructor. */
1767  /** A C++ destructor. */
1769  /** A C++ conversion function. */
1771  /** A C++ template type parameter. */
1773  /** A C++ non-type template parameter. */
1775  /** A C++ template template parameter. */
1777  /** A C++ function template. */
1779  /** A C++ class template. */
1781  /** A C++ class template partial specialization. */
1783  /** A C++ namespace alias declaration. */
1785  /** A C++ using directive. */
1787  /** A C++ using declaration. */
1789  /** A C++ alias declaration */
1791  /** An Objective-C \@synthesize definition. */
1793  /** An Objective-C \@dynamic definition. */
1795  /** An access specifier. */
1797 
1800 
1801  /* References */
1802  CXCursor_FirstRef = 40, /* Decl references */
1806  /**
1807  * A reference to a type declaration.
1808  *
1809  * A type reference occurs anywhere where a type is named but not
1810  * declared. For example, given:
1811  *
1812  * \code
1813  * typedef unsigned size_type;
1814  * size_type size;
1815  * \endcode
1816  *
1817  * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1818  * while the type of the variable "size" is referenced. The cursor
1819  * referenced by the type of size is the typedef for size_type.
1820  */
1823  /**
1824  * A reference to a class template, function template, template
1825  * template parameter, or class template partial specialization.
1826  */
1828  /**
1829  * A reference to a namespace or namespace alias.
1830  */
1832  /**
1833  * A reference to a member of a struct, union, or class that occurs in
1834  * some non-expression context, e.g., a designated initializer.
1835  */
1837  /**
1838  * A reference to a labeled statement.
1839  *
1840  * This cursor kind is used to describe the jump to "start_over" in the
1841  * goto statement in the following example:
1842  *
1843  * \code
1844  * start_over:
1845  * ++counter;
1846  *
1847  * goto start_over;
1848  * \endcode
1849  *
1850  * A label reference cursor refers to a label statement.
1851  */
1853 
1854  /**
1855  * A reference to a set of overloaded functions or function templates
1856  * that has not yet been resolved to a specific function or function template.
1857  *
1858  * An overloaded declaration reference cursor occurs in C++ templates where
1859  * a dependent name refers to a function. For example:
1860  *
1861  * \code
1862  * template<typename T> void swap(T&, T&);
1863  *
1864  * struct X { ... };
1865  * void swap(X&, X&);
1866  *
1867  * template<typename T>
1868  * void reverse(T* first, T* last) {
1869  * while (first < last - 1) {
1870  * swap(*first, *--last);
1871  * ++first;
1872  * }
1873  * }
1874  *
1875  * struct Y { };
1876  * void swap(Y&, Y&);
1877  * \endcode
1878  *
1879  * Here, the identifier "swap" is associated with an overloaded declaration
1880  * reference. In the template definition, "swap" refers to either of the two
1881  * "swap" functions declared above, so both results will be available. At
1882  * instantiation time, "swap" may also refer to other functions found via
1883  * argument-dependent lookup (e.g., the "swap" function at the end of the
1884  * example).
1885  *
1886  * The functions \c clang_getNumOverloadedDecls() and
1887  * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1888  * referenced by this cursor.
1889  */
1891 
1892  /**
1893  * A reference to a variable that occurs in some non-expression
1894  * context, e.g., a C++ lambda capture list.
1895  */
1897 
1899 
1900  /* Error conditions */
1907 
1908  /* Expressions */
1910 
1911  /**
1912  * An expression whose specific kind is not exposed via this
1913  * interface.
1914  *
1915  * Unexposed expressions have the same operations as any other kind
1916  * of expression; one can extract their location information,
1917  * spelling, children, etc. However, the specific kind of the
1918  * expression is not reported.
1919  */
1921 
1922  /**
1923  * An expression that refers to some value declaration, such
1924  * as a function, variable, or enumerator.
1925  */
1927 
1928  /**
1929  * An expression that refers to a member of a struct, union,
1930  * class, Objective-C class, etc.
1931  */
1933 
1934  /** An expression that calls a function. */
1936 
1937  /** An expression that sends a message to an Objective-C
1938  object or class. */
1940 
1941  /** An expression that represents a block literal. */
1943 
1944  /** An integer literal.
1945  */
1947 
1948  /** A floating point number literal.
1949  */
1951 
1952  /** An imaginary number literal.
1953  */
1955 
1956  /** A string literal.
1957  */
1959 
1960  /** A character literal.
1961  */
1963 
1964  /** A parenthesized expression, e.g. "(1)".
1965  *
1966  * This AST node is only formed if full location information is requested.
1967  */
1969 
1970  /** This represents the unary-expression's (except sizeof and
1971  * alignof).
1972  */
1974 
1975  /** [C99 6.5.2.1] Array Subscripting.
1976  */
1978 
1979  /** A builtin binary operation expression such as "x + y" or
1980  * "x <= y".
1981  */
1983 
1984  /** Compound assignment such as "+=".
1985  */
1987 
1988  /** The ?: ternary operator.
1989  */
1991 
1992  /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1993  * (C++ [expr.cast]), which uses the syntax (Type)expr.
1994  *
1995  * For example: (int)f.
1996  */
1998 
1999  /** [C99 6.5.2.5]
2000  */
2002 
2003  /** Describes an C or C++ initializer list.
2004  */
2006 
2007  /** The GNU address of label extension, representing &&label.
2008  */
2010 
2011  /** This is the GNU Statement Expression extension: ({int X=4; X;})
2012  */
2014 
2015  /** Represents a C11 generic selection.
2016  */
2018 
2019  /** Implements the GNU __null extension, which is a name for a null
2020  * pointer constant that has integral type (e.g., int or long) and is the same
2021  * size and alignment as a pointer.
2022  *
2023  * The __null extension is typically only used by system headers, which define
2024  * NULL as __null in C++ rather than using 0 (which is an integer that may not
2025  * match the size of a pointer).
2026  */
2028 
2029  /** C++'s static_cast<> expression.
2030  */
2032 
2033  /** C++'s dynamic_cast<> expression.
2034  */
2036 
2037  /** C++'s reinterpret_cast<> expression.
2038  */
2040 
2041  /** C++'s const_cast<> expression.
2042  */
2044 
2045  /** Represents an explicit C++ type conversion that uses "functional"
2046  * notion (C++ [expr.type.conv]).
2047  *
2048  * Example:
2049  * \code
2050  * x = int(0.5);
2051  * \endcode
2052  */
2054 
2055  /** A C++ typeid expression (C++ [expr.typeid]).
2056  */
2058 
2059  /** [C++ 2.13.5] C++ Boolean Literal.
2060  */
2062 
2063  /** [C++0x 2.14.7] C++ Pointer Literal.
2064  */
2066 
2067  /** Represents the "this" expression in C++
2068  */
2070 
2071  /** [C++ 15] C++ Throw Expression.
2072  *
2073  * This handles 'throw' and 'throw' assignment-expression. When
2074  * assignment-expression isn't present, Op will be null.
2075  */
2077 
2078  /** A new expression for memory allocation and constructor calls, e.g:
2079  * "new CXXNewExpr(foo)".
2080  */
2082 
2083  /** A delete expression for memory deallocation and destructor calls,
2084  * e.g. "delete[] pArray".
2085  */
2087 
2088  /** A unary expression. (noexcept, sizeof, or other traits)
2089  */
2091 
2092  /** An Objective-C string literal i.e. @"foo".
2093  */
2095 
2096  /** An Objective-C \@encode expression.
2097  */
2099 
2100  /** An Objective-C \@selector expression.
2101  */
2103 
2104  /** An Objective-C \@protocol expression.
2105  */
2107 
2108  /** An Objective-C "bridged" cast expression, which casts between
2109  * Objective-C pointers and C pointers, transferring ownership in the process.
2110  *
2111  * \code
2112  * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2113  * \endcode
2114  */
2116 
2117  /** Represents a C++0x pack expansion that produces a sequence of
2118  * expressions.
2119  *
2120  * A pack expansion expression contains a pattern (which itself is an
2121  * expression) followed by an ellipsis. For example:
2122  *
2123  * \code
2124  * template<typename F, typename ...Types>
2125  * void forward(F f, Types &&...args) {
2126  * f(static_cast<Types&&>(args)...);
2127  * }
2128  * \endcode
2129  */
2131 
2132  /** Represents an expression that computes the length of a parameter
2133  * pack.
2134  *
2135  * \code
2136  * template<typename ...Types>
2137  * struct count {
2138  * static const unsigned value = sizeof...(Types);
2139  * };
2140  * \endcode
2141  */
2143 
2144  /* Represents a C++ lambda expression that produces a local function
2145  * object.
2146  *
2147  * \code
2148  * void abssort(float *x, unsigned N) {
2149  * std::sort(x, x + N,
2150  * [](float a, float b) {
2151  * return std::abs(a) < std::abs(b);
2152  * });
2153  * }
2154  * \endcode
2155  */
2157 
2158  /** Objective-c Boolean Literal.
2159  */
2161 
2162  /** Represents the "self" expression in an Objective-C method.
2163  */
2165 
2166  /** OpenMP 5.0 [2.1.5, Array Section].
2167  */
2169 
2170  /** Represents an @available(...) check.
2171  */
2173 
2174  /**
2175  * Fixed point literal
2176  */
2178 
2179  /** OpenMP 5.0 [2.1.4, Array Shaping].
2180  */
2182 
2183  /**
2184  * OpenMP 5.0 [2.1.6 Iterators]
2185  */
2187 
2188  /** OpenCL's addrspace_cast<> expression.
2189  */
2191 
2193 
2194  /* Statements */
2196  /**
2197  * A statement whose specific kind is not exposed via this
2198  * interface.
2199  *
2200  * Unexposed statements have the same operations as any other kind of
2201  * statement; one can extract their location information, spelling,
2202  * children, etc. However, the specific kind of the statement is not
2203  * reported.
2204  */
2206 
2207  /** A labelled statement in a function.
2208  *
2209  * This cursor kind is used to describe the "start_over:" label statement in
2210  * the following example:
2211  *
2212  * \code
2213  * start_over:
2214  * ++counter;
2215  * \endcode
2216  *
2217  */
2219 
2220  /** A group of statements like { stmt stmt }.
2221  *
2222  * This cursor kind is used to describe compound statements, e.g. function
2223  * bodies.
2224  */
2226 
2227  /** A case statement.
2228  */
2230 
2231  /** A default statement.
2232  */
2234 
2235  /** An if statement
2236  */
2238 
2239  /** A switch statement.
2240  */
2242 
2243  /** A while statement.
2244  */
2246 
2247  /** A do statement.
2248  */
2250 
2251  /** A for statement.
2252  */
2254 
2255  /** A goto statement.
2256  */
2258 
2259  /** An indirect goto statement.
2260  */
2262 
2263  /** A continue statement.
2264  */
2266 
2267  /** A break statement.
2268  */
2270 
2271  /** A return statement.
2272  */
2274 
2275  /** A GCC inline assembly statement extension.
2276  */
2279 
2280  /** Objective-C's overall \@try-\@catch-\@finally statement.
2281  */
2283 
2284  /** Objective-C's \@catch statement.
2285  */
2287 
2288  /** Objective-C's \@finally statement.
2289  */
2291 
2292  /** Objective-C's \@throw statement.
2293  */
2295 
2296  /** Objective-C's \@synchronized statement.
2297  */
2299 
2300  /** Objective-C's autorelease pool statement.
2301  */
2303 
2304  /** Objective-C's collection statement.
2305  */
2307 
2308  /** C++'s catch statement.
2309  */
2311 
2312  /** C++'s try statement.
2313  */
2315 
2316  /** C++'s for (* : *) statement.
2317  */
2319 
2320  /** Windows Structured Exception Handling's try statement.
2321  */
2323 
2324  /** Windows Structured Exception Handling's except statement.
2325  */
2327 
2328  /** Windows Structured Exception Handling's finally statement.
2329  */
2331 
2332  /** A MS inline assembly statement extension.
2333  */
2335 
2336  /** The null statement ";": C99 6.8.3p3.
2337  *
2338  * This cursor kind is used to describe the null statement.
2339  */
2341 
2342  /** Adaptor class for mixing declarations with statements and
2343  * expressions.
2344  */
2346 
2347  /** OpenMP parallel directive.
2348  */
2350 
2351  /** OpenMP SIMD directive.
2352  */
2354 
2355  /** OpenMP for directive.
2356  */
2358 
2359  /** OpenMP sections directive.
2360  */
2362 
2363  /** OpenMP section directive.
2364  */
2366 
2367  /** OpenMP single directive.
2368  */
2370 
2371  /** OpenMP parallel for directive.
2372  */
2374 
2375  /** OpenMP parallel sections directive.
2376  */
2378 
2379  /** OpenMP task directive.
2380  */
2382 
2383  /** OpenMP master directive.
2384  */
2386 
2387  /** OpenMP critical directive.
2388  */
2390 
2391  /** OpenMP taskyield directive.
2392  */
2394 
2395  /** OpenMP barrier directive.
2396  */
2398 
2399  /** OpenMP taskwait directive.
2400  */
2402 
2403  /** OpenMP flush directive.
2404  */
2406 
2407  /** Windows Structured Exception Handling's leave statement.
2408  */
2410 
2411  /** OpenMP ordered directive.
2412  */
2414 
2415  /** OpenMP atomic directive.
2416  */
2418 
2419  /** OpenMP for SIMD directive.
2420  */
2422 
2423  /** OpenMP parallel for SIMD directive.
2424  */
2426 
2427  /** OpenMP target directive.
2428  */
2430 
2431  /** OpenMP teams directive.
2432  */
2434 
2435  /** OpenMP taskgroup directive.
2436  */
2438 
2439  /** OpenMP cancellation point directive.
2440  */
2442 
2443  /** OpenMP cancel directive.
2444  */
2446 
2447  /** OpenMP target data directive.
2448  */
2450 
2451  /** OpenMP taskloop directive.
2452  */
2454 
2455  /** OpenMP taskloop simd directive.
2456  */
2458 
2459  /** OpenMP distribute directive.
2460  */
2462 
2463  /** OpenMP target enter data directive.
2464  */
2466 
2467  /** OpenMP target exit data directive.
2468  */
2470 
2471  /** OpenMP target parallel directive.
2472  */
2474 
2475  /** OpenMP target parallel for directive.
2476  */
2478 
2479  /** OpenMP target update directive.
2480  */
2482 
2483  /** OpenMP distribute parallel for directive.
2484  */
2486 
2487  /** OpenMP distribute parallel for simd directive.
2488  */
2490 
2491  /** OpenMP distribute simd directive.
2492  */
2494 
2495  /** OpenMP target parallel for simd directive.
2496  */
2498 
2499  /** OpenMP target simd directive.
2500  */
2502 
2503  /** OpenMP teams distribute directive.
2504  */
2506 
2507  /** OpenMP teams distribute simd directive.
2508  */
2510 
2511  /** OpenMP teams distribute parallel for simd directive.
2512  */
2514 
2515  /** OpenMP teams distribute parallel for directive.
2516  */
2518 
2519  /** OpenMP target teams directive.
2520  */
2522 
2523  /** OpenMP target teams distribute directive.
2524  */
2526 
2527  /** OpenMP target teams distribute parallel for directive.
2528  */
2530 
2531  /** OpenMP target teams distribute parallel for simd directive.
2532  */
2534 
2535  /** OpenMP target teams distribute simd directive.
2536  */
2538 
2539  /** C++2a std::bit_cast expression.
2540  */
2542 
2543  /** OpenMP master taskloop directive.
2544  */
2546 
2547  /** OpenMP parallel master taskloop directive.
2548  */
2550 
2551  /** OpenMP master taskloop simd directive.
2552  */
2554 
2555  /** OpenMP parallel master taskloop simd directive.
2556  */
2558 
2559  /** OpenMP parallel master directive.
2560  */
2562 
2563  /** OpenMP depobj directive.
2564  */
2566 
2567  /** OpenMP scan directive.
2568  */
2570 
2571  /** OpenMP tile directive.
2572  */
2574 
2575  /** OpenMP canonical loop.
2576  */
2578 
2579  /** OpenMP interop directive.
2580  */
2582 
2583  /** OpenMP dispatch directive.
2584  */
2586 
2587  /** OpenMP masked directive.
2588  */
2590 
2591  /** OpenMP unroll directive.
2592  */
2594 
2595  /** OpenMP metadirective directive.
2596  */
2598 
2600 
2601  /**
2602  * Cursor that represents the translation unit itself.
2603  *
2604  * The translation unit cursor exists primarily to act as the root
2605  * cursor for traversing the contents of a translation unit.
2606  */
2608 
2609  /* Attributes */
2611  /**
2612  * An attribute whose specific kind is not exposed via this
2613  * interface.
2614  */
2616 
2659 
2660  /* Preprocessing */
2668 
2669  /* Extra Declarations */
2670  /**
2671  * A module import declaration.
2672  */
2675  /**
2676  * A static_assert or _Static_assert node
2677  */
2679  /**
2680  * a friend declaration.
2681  */
2685 
2686  /**
2687  * A code completion overload candidate.
2688  */
2690 };
2691 
2692 /**
2693  * A cursor representing some element in the abstract syntax tree for
2694  * a translation unit.
2695  *
2696  * The cursor abstraction unifies the different kinds of entities in a
2697  * program--declaration, statements, expressions, references to declarations,
2698  * etc.--under a single "cursor" abstraction with a common set of operations.
2699  * Common operation for a cursor include: getting the physical location in
2700  * a source file where the cursor points, getting the name associated with a
2701  * cursor, and retrieving cursors for any child nodes of a particular cursor.
2702  *
2703  * Cursors can be produced in two specific ways.
2704  * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2705  * from which one can use clang_visitChildren() to explore the rest of the
2706  * translation unit. clang_getCursor() maps from a physical source location
2707  * to the entity that resides at that location, allowing one to map from the
2708  * source code into the AST.
2709  */
2710 typedef struct {
2712  int xdata;
2713  const void *data[3];
2714 } CXCursor;
2715 
2716 /**
2717  * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2718  *
2719  * @{
2720  */
2721 
2722 /**
2723  * Retrieve the NULL cursor, which represents no entity.
2724  */
2726 
2727 /**
2728  * Retrieve the cursor that represents the given translation unit.
2729  *
2730  * The translation unit cursor can be used to start traversing the
2731  * various declarations within the given translation unit.
2732  */
2734 
2735 /**
2736  * Determine whether two cursors are equivalent.
2737  */
2739 
2740 /**
2741  * Returns non-zero if \p cursor is null.
2742  */
2744 
2745 /**
2746  * Compute a hash value for the given cursor.
2747  */
2749 
2750 /**
2751  * Retrieve the kind of the given cursor.
2752  */
2754 
2755 /**
2756  * Determine whether the given cursor kind represents a declaration.
2757  */
2759 
2760 /**
2761  * Determine whether the given declaration is invalid.
2762  *
2763  * A declaration is invalid if it could not be parsed successfully.
2764  *
2765  * \returns non-zero if the cursor represents a declaration and it is
2766  * invalid, otherwise NULL.
2767  */
2769 
2770 /**
2771  * Determine whether the given cursor kind represents a simple
2772  * reference.
2773  *
2774  * Note that other kinds of cursors (such as expressions) can also refer to
2775  * other cursors. Use clang_getCursorReferenced() to determine whether a
2776  * particular cursor refers to another entity.
2777  */
2779 
2780 /**
2781  * Determine whether the given cursor kind represents an expression.
2782  */
2784 
2785 /**
2786  * Determine whether the given cursor kind represents a statement.
2787  */
2789 
2790 /**
2791  * Determine whether the given cursor kind represents an attribute.
2792  */
2794 
2795 /**
2796  * Determine whether the given cursor has any attributes.
2797  */
2799 
2800 /**
2801  * Determine whether the given cursor kind represents an invalid
2802  * cursor.
2803  */
2805 
2806 /**
2807  * Determine whether the given cursor kind represents a translation
2808  * unit.
2809  */
2811 
2812 /***
2813  * Determine whether the given cursor represents a preprocessing
2814  * element, such as a preprocessor directive or macro instantiation.
2815  */
2817 
2818 /***
2819  * Determine whether the given cursor represents a currently
2820  * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2821  */
2823 
2824 /**
2825  * Describe the linkage of the entity referred to by a cursor.
2826  */
2828  /** This value indicates that no linkage information is available
2829  * for a provided CXCursor. */
2831  /**
2832  * This is the linkage for variables, parameters, and so on that
2833  * have automatic storage. This covers normal (non-extern) local variables.
2834  */
2836  /** This is the linkage for static variables and static functions. */
2838  /** This is the linkage for entities with external linkage that live
2839  * in C++ anonymous namespaces.*/
2841  /** This is the linkage for entities with true, external linkage. */
2843 };
2844 
2845 /**
2846  * Determine the linkage of the entity referred to by a given cursor.
2847  */
2849 
2851  /** This value indicates that no visibility information is available
2852  * for a provided CXCursor. */
2854 
2855  /** Symbol not seen by the linker. */
2857  /** Symbol seen by the linker but resolves to a symbol inside this object. */
2859  /** Symbol seen by the linker and acts like a normal symbol. */
2861 };
2862 
2863 /**
2864  * Describe the visibility of the entity referred to by a cursor.
2865  *
2866  * This returns the default visibility if not explicitly specified by
2867  * a visibility attribute. The default visibility may be changed by
2868  * commandline arguments.
2869  *
2870  * \param cursor The cursor to query.
2871  *
2872  * \returns The visibility of the cursor.
2873  */
2875 
2876 /**
2877  * Determine the availability of the entity that this cursor refers to,
2878  * taking the current target platform into account.
2879  *
2880  * \param cursor The cursor to query.
2881  *
2882  * \returns The availability of the cursor.
2883  */
2886 
2887 /**
2888  * Describes the availability of a given entity on a particular platform, e.g.,
2889  * a particular class might only be available on Mac OS 10.7 or newer.
2890  */
2891 typedef struct CXPlatformAvailability {
2892  /**
2893  * A string that describes the platform for which this structure
2894  * provides availability information.
2895  *
2896  * Possible values are "ios" or "macos".
2897  */
2899  /**
2900  * The version number in which this entity was introduced.
2901  */
2903  /**
2904  * The version number in which this entity was deprecated (but is
2905  * still available).
2906  */
2908  /**
2909  * The version number in which this entity was obsoleted, and therefore
2910  * is no longer available.
2911  */
2913  /**
2914  * Whether the entity is unconditionally unavailable on this platform.
2915  */
2917  /**
2918  * An optional message to provide to a user of this API, e.g., to
2919  * suggest replacement APIs.
2920  */
2923 
2924 /**
2925  * Determine the availability of the entity that this cursor refers to
2926  * on any platforms for which availability information is known.
2927  *
2928  * \param cursor The cursor to query.
2929  *
2930  * \param always_deprecated If non-NULL, will be set to indicate whether the
2931  * entity is deprecated on all platforms.
2932  *
2933  * \param deprecated_message If non-NULL, will be set to the message text
2934  * provided along with the unconditional deprecation of this entity. The client
2935  * is responsible for deallocating this string.
2936  *
2937  * \param always_unavailable If non-NULL, will be set to indicate whether the
2938  * entity is unavailable on all platforms.
2939  *
2940  * \param unavailable_message If non-NULL, will be set to the message text
2941  * provided along with the unconditional unavailability of this entity. The
2942  * client is responsible for deallocating this string.
2943  *
2944  * \param availability If non-NULL, an array of CXPlatformAvailability instances
2945  * that will be populated with platform availability information, up to either
2946  * the number of platforms for which availability information is available (as
2947  * returned by this function) or \c availability_size, whichever is smaller.
2948  *
2949  * \param availability_size The number of elements available in the
2950  * \c availability array.
2951  *
2952  * \returns The number of platforms (N) for which availability information is
2953  * available (which is unrelated to \c availability_size).
2954  *
2955  * Note that the client is responsible for calling
2956  * \c clang_disposeCXPlatformAvailability to free each of the
2957  * platform-availability structures returned. There are
2958  * \c min(N, availability_size) such structures.
2959  */
2961  CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
2962  int *always_unavailable, CXString *unavailable_message,
2963  CXPlatformAvailability *availability, int availability_size);
2964 
2965 /**
2966  * Free the memory associated with a \c CXPlatformAvailability structure.
2967  */
2968 CINDEX_LINKAGE void
2970 
2971 /**
2972  * If cursor refers to a variable declaration and it has initializer returns
2973  * cursor referring to the initializer otherwise return null cursor.
2974  */
2976 
2977 /**
2978  * If cursor refers to a variable declaration that has global storage returns 1.
2979  * If cursor refers to a variable declaration that doesn't have global storage
2980  * returns 0. Otherwise returns -1.
2981  */
2983 
2984 /**
2985  * If cursor refers to a variable declaration that has external storage
2986  * returns 1. If cursor refers to a variable declaration that doesn't have
2987  * external storage returns 0. Otherwise returns -1.
2988  */
2990 
2991 /**
2992  * Describe the "language" of the entity referred to by a cursor.
2993  */
2999 };
3000 
3001 /**
3002  * Determine the "language" of the entity referred to by a given cursor.
3003  */
3005 
3006 /**
3007  * Describe the "thread-local storage (TLS) kind" of the declaration
3008  * referred to by a cursor.
3009  */
3011 
3012 /**
3013  * Determine the "thread-local storage (TLS) kind" of the declaration
3014  * referred to by a cursor.
3015  */
3017 
3018 /**
3019  * Returns the translation unit that a cursor originated from.
3020  */
3022 
3023 /**
3024  * A fast container representing a set of CXCursors.
3025  */
3026 typedef struct CXCursorSetImpl *CXCursorSet;
3027 
3028 /**
3029  * Creates an empty CXCursorSet.
3030  */
3032 
3033 /**
3034  * Disposes a CXCursorSet and releases its associated memory.
3035  */
3037 
3038 /**
3039  * Queries a CXCursorSet to see if it contains a specific CXCursor.
3040  *
3041  * \returns non-zero if the set contains the specified cursor.
3042  */
3044  CXCursor cursor);
3045 
3046 /**
3047  * Inserts a CXCursor into a CXCursorSet.
3048  *
3049  * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
3050  */
3052  CXCursor cursor);
3053 
3054 /**
3055  * Determine the semantic parent of the given cursor.
3056  *
3057  * The semantic parent of a cursor is the cursor that semantically contains
3058  * the given \p cursor. For many declarations, the lexical and semantic parents
3059  * are equivalent (the lexical parent is returned by
3060  * \c clang_getCursorLexicalParent()). They diverge when declarations or
3061  * definitions are provided out-of-line. For example:
3062  *
3063  * \code
3064  * class C {
3065  * void f();
3066  * };
3067  *
3068  * void C::f() { }
3069  * \endcode
3070  *
3071  * In the out-of-line definition of \c C::f, the semantic parent is
3072  * the class \c C, of which this function is a member. The lexical parent is
3073  * the place where the declaration actually occurs in the source code; in this
3074  * case, the definition occurs in the translation unit. In general, the
3075  * lexical parent for a given entity can change without affecting the semantics
3076  * of the program, and the lexical parent of different declarations of the
3077  * same entity may be different. Changing the semantic parent of a declaration,
3078  * on the other hand, can have a major impact on semantics, and redeclarations
3079  * of a particular entity should all have the same semantic context.
3080  *
3081  * In the example above, both declarations of \c C::f have \c C as their
3082  * semantic context, while the lexical context of the first \c C::f is \c C
3083  * and the lexical context of the second \c C::f is the translation unit.
3084  *
3085  * For global declarations, the semantic parent is the translation unit.
3086  */
3088 
3089 /**
3090  * Determine the lexical parent of the given cursor.
3091  *
3092  * The lexical parent of a cursor is the cursor in which the given \p cursor
3093  * was actually written. For many declarations, the lexical and semantic parents
3094  * are equivalent (the semantic parent is returned by
3095  * \c clang_getCursorSemanticParent()). They diverge when declarations or
3096  * definitions are provided out-of-line. For example:
3097  *
3098  * \code
3099  * class C {
3100  * void f();
3101  * };
3102  *
3103  * void C::f() { }
3104  * \endcode
3105  *
3106  * In the out-of-line definition of \c C::f, the semantic parent is
3107  * the class \c C, of which this function is a member. The lexical parent is
3108  * the place where the declaration actually occurs in the source code; in this
3109  * case, the definition occurs in the translation unit. In general, the
3110  * lexical parent for a given entity can change without affecting the semantics
3111  * of the program, and the lexical parent of different declarations of the
3112  * same entity may be different. Changing the semantic parent of a declaration,
3113  * on the other hand, can have a major impact on semantics, and redeclarations
3114  * of a particular entity should all have the same semantic context.
3115  *
3116  * In the example above, both declarations of \c C::f have \c C as their
3117  * semantic context, while the lexical context of the first \c C::f is \c C
3118  * and the lexical context of the second \c C::f is the translation unit.
3119  *
3120  * For declarations written in the global scope, the lexical parent is
3121  * the translation unit.
3122  */
3124 
3125 /**
3126  * Determine the set of methods that are overridden by the given
3127  * method.
3128  *
3129  * In both Objective-C and C++, a method (aka virtual member function,
3130  * in C++) can override a virtual method in a base class. For
3131  * Objective-C, a method is said to override any method in the class's
3132  * base class, its protocols, or its categories' protocols, that has the same
3133  * selector and is of the same kind (class or instance).
3134  * If no such method exists, the search continues to the class's superclass,
3135  * its protocols, and its categories, and so on. A method from an Objective-C
3136  * implementation is considered to override the same methods as its
3137  * corresponding method in the interface.
3138  *
3139  * For C++, a virtual member function overrides any virtual member
3140  * function with the same signature that occurs in its base
3141  * classes. With multiple inheritance, a virtual member function can
3142  * override several virtual member functions coming from different
3143  * base classes.
3144  *
3145  * In all cases, this function determines the immediate overridden
3146  * method, rather than all of the overridden methods. For example, if
3147  * a method is originally declared in a class A, then overridden in B
3148  * (which in inherits from A) and also in C (which inherited from B),
3149  * then the only overridden method returned from this function when
3150  * invoked on C's method will be B's method. The client may then
3151  * invoke this function again, given the previously-found overridden
3152  * methods, to map out the complete method-override set.
3153  *
3154  * \param cursor A cursor representing an Objective-C or C++
3155  * method. This routine will compute the set of methods that this
3156  * method overrides.
3157  *
3158  * \param overridden A pointer whose pointee will be replaced with a
3159  * pointer to an array of cursors, representing the set of overridden
3160  * methods. If there are no overridden methods, the pointee will be
3161  * set to NULL. The pointee must be freed via a call to
3162  * \c clang_disposeOverriddenCursors().
3163  *
3164  * \param num_overridden A pointer to the number of overridden
3165  * functions, will be set to the number of overridden functions in the
3166  * array pointed to by \p overridden.
3167  */
3169  CXCursor **overridden,
3170  unsigned *num_overridden);
3171 
3172 /**
3173  * Free the set of overridden cursors returned by \c
3174  * clang_getOverriddenCursors().
3175  */
3177 
3178 /**
3179  * Retrieve the file that is included by the given inclusion directive
3180  * cursor.
3181  */
3183 
3184 /**
3185  * @}
3186  */
3187 
3188 /**
3189  * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3190  *
3191  * Cursors represent a location within the Abstract Syntax Tree (AST). These
3192  * routines help map between cursors and the physical locations where the
3193  * described entities occur in the source code. The mapping is provided in
3194  * both directions, so one can map from source code to the AST and back.
3195  *
3196  * @{
3197  */
3198 
3199 /**
3200  * Map a source location to the cursor that describes the entity at that
3201  * location in the source code.
3202  *
3203  * clang_getCursor() maps an arbitrary source location within a translation
3204  * unit down to the most specific cursor that describes the entity at that
3205  * location. For example, given an expression \c x + y, invoking
3206  * clang_getCursor() with a source location pointing to "x" will return the
3207  * cursor for "x"; similarly for "y". If the cursor points anywhere between
3208  * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3209  * will return a cursor referring to the "+" expression.
3210  *
3211  * \returns a cursor representing the entity at the given source location, or
3212  * a NULL cursor if no such entity can be found.
3213  */
3215 
3216 /**
3217  * Retrieve the physical location of the source constructor referenced
3218  * by the given cursor.
3219  *
3220  * The location of a declaration is typically the location of the name of that
3221  * declaration, where the name of that declaration would occur if it is
3222  * unnamed, or some keyword that introduces that particular declaration.
3223  * The location of a reference is where that reference occurs within the
3224  * source code.
3225  */
3227 
3228 /**
3229  * Retrieve the physical extent of the source construct referenced by
3230  * the given cursor.
3231  *
3232  * The extent of a cursor starts with the file/line/column pointing at the
3233  * first character within the source construct that the cursor refers to and
3234  * ends with the last character within that source construct. For a
3235  * declaration, the extent covers the declaration itself. For a reference,
3236  * the extent covers the location of the reference (e.g., where the referenced
3237  * entity was actually used).
3238  */
3240 
3241 /**
3242  * @}
3243  */
3244 
3245 /**
3246  * \defgroup CINDEX_TYPES Type information for CXCursors
3247  *
3248  * @{
3249  */
3250 
3251 /**
3252  * Describes the kind of type
3253  */
3255  /**
3256  * Represents an invalid type (e.g., where no type is available).
3257  */
3259 
3260  /**
3261  * A type whose specific kind is not exposed via this
3262  * interface.
3263  */
3265 
3266  /* Builtin types */
3308 
3328 
3329  /**
3330  * Represents a type that was referred to using an elaborated type keyword.
3331  *
3332  * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3333  */
3335 
3336  /* OpenCL PipeType. */
3338 
3339  /* OpenCL builtin types. */
3380 
3384 
3396 
3398 
3401 };
3402 
3403 /**
3404  * Describes the calling convention of a function type
3405  */
3418  /* Alias for compatibility with older versions of API. */
3427 
3430 };
3431 
3432 /**
3433  * The type of an element in the abstract syntax tree.
3434  *
3435  */
3436 typedef struct {
3438  void *data[2];
3439 } CXType;
3440 
3441 /**
3442  * Retrieve the type of a CXCursor (if any).
3443  */
3445 
3446 /**
3447  * Pretty-print the underlying type using the rules of the
3448  * language of the translation unit from which it came.
3449  *
3450  * If the type is invalid, an empty string is returned.
3451  */
3453 
3454 /**
3455  * Retrieve the underlying type of a typedef declaration.
3456  *
3457  * If the cursor does not reference a typedef declaration, an invalid type is
3458  * returned.
3459  */
3461 
3462 /**
3463  * Retrieve the integer type of an enum declaration.
3464  *
3465  * If the cursor does not reference an enum declaration, an invalid type is
3466  * returned.
3467  */
3469 
3470 /**
3471  * Retrieve the integer value of an enum constant declaration as a signed
3472  * long long.
3473  *
3474  * If the cursor does not reference an enum constant declaration, LLONG_MIN is
3475  * returned. Since this is also potentially a valid constant value, the kind of
3476  * the cursor must be verified before calling this function.
3477  */
3479 
3480 /**
3481  * Retrieve the integer value of an enum constant declaration as an unsigned
3482  * long long.
3483  *
3484  * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3485  * returned. Since this is also potentially a valid constant value, the kind of
3486  * the cursor must be verified before calling this function.
3487  */
3488 CINDEX_LINKAGE unsigned long long
3490 
3491 /**
3492  * Retrieve the bit width of a bit field declaration as an integer.
3493  *
3494  * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3495  */
3497 
3498 /**
3499  * Retrieve the number of non-variadic arguments associated with a given
3500  * cursor.
3501  *
3502  * The number of arguments can be determined for calls as well as for
3503  * declarations of functions or methods. For other cursors -1 is returned.
3504  */
3506 
3507 /**
3508  * Retrieve the argument cursor of a function or method.
3509  *
3510  * The argument cursor can be determined for calls as well as for declarations
3511  * of functions or methods. For other cursors and for invalid indices, an
3512  * invalid cursor is returned.
3513  */
3515 
3516 /**
3517  * Describes the kind of a template argument.
3518  *
3519  * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3520  * element descriptions.
3521  */
3532  /* Indicates an error case, preventing the kind from being deduced. */
3534 };
3535 
3536 /**
3537  *Returns the number of template args of a function decl representing a
3538  * template specialization.
3539  *
3540  * If the argument cursor cannot be converted into a template function
3541  * declaration, -1 is returned.
3542  *
3543  * For example, for the following declaration and specialization:
3544  * template <typename T, int kInt, bool kBool>
3545  * void foo() { ... }
3546  *
3547  * template <>
3548  * void foo<float, -7, true>();
3549  *
3550  * The value 3 would be returned from this call.
3551  */
3553 
3554 /**
3555  * Retrieve the kind of the I'th template argument of the CXCursor C.
3556  *
3557  * If the argument CXCursor does not represent a FunctionDecl, an invalid
3558  * template argument kind is returned.
3559  *
3560  * For example, for the following declaration and specialization:
3561  * template <typename T, int kInt, bool kBool>
3562  * void foo() { ... }
3563  *
3564  * template <>
3565  * void foo<float, -7, true>();
3566  *
3567  * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3568  * respectively.
3569  */
3572 
3573 /**
3574  * Retrieve a CXType representing the type of a TemplateArgument of a
3575  * function decl representing a template specialization.
3576  *
3577  * If the argument CXCursor does not represent a FunctionDecl whose I'th
3578  * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3579  * is returned.
3580  *
3581  * For example, for the following declaration and specialization:
3582  * template <typename T, int kInt, bool kBool>
3583  * void foo() { ... }
3584  *
3585  * template <>
3586  * void foo<float, -7, true>();
3587  *
3588  * If called with I = 0, "float", will be returned.
3589  * Invalid types will be returned for I == 1 or 2.
3590  */
3592  unsigned I);
3593 
3594 /**
3595  * Retrieve the value of an Integral TemplateArgument (of a function
3596  * decl representing a template specialization) as a signed long long.
3597  *
3598  * It is undefined to call this function on a CXCursor that does not represent a
3599  * FunctionDecl or whose I'th template argument is not an integral value.
3600  *
3601  * For example, for the following declaration and specialization:
3602  * template <typename T, int kInt, bool kBool>
3603  * void foo() { ... }
3604  *
3605  * template <>
3606  * void foo<float, -7, true>();
3607  *
3608  * If called with I = 1 or 2, -7 or true will be returned, respectively.
3609  * For I == 0, this function's behavior is undefined.
3610  */
3612  unsigned I);
3613 
3614 /**
3615  * Retrieve the value of an Integral TemplateArgument (of a function
3616  * decl representing a template specialization) as an unsigned long long.
3617  *
3618  * It is undefined to call this function on a CXCursor that does not represent a
3619  * FunctionDecl or whose I'th template argument is not an integral value.
3620  *
3621  * For example, for the following declaration and specialization:
3622  * template <typename T, int kInt, bool kBool>
3623  * void foo() { ... }
3624  *
3625  * template <>
3626  * void foo<float, 2147483649, true>();
3627  *
3628  * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3629  * For I == 0, this function's behavior is undefined.
3630  */
3631 CINDEX_LINKAGE unsigned long long
3633 
3634 /**
3635  * Determine whether two CXTypes represent the same type.
3636  *
3637  * \returns non-zero if the CXTypes represent the same type and
3638  * zero otherwise.
3639  */
3641 
3642 /**
3643  * Return the canonical type for a CXType.
3644  *
3645  * Clang's type system explicitly models typedefs and all the ways
3646  * a specific type can be represented. The canonical type is the underlying
3647  * type with all the "sugar" removed. For example, if 'T' is a typedef
3648  * for 'int', the canonical type for 'T' would be 'int'.
3649  */
3651 
3652 /**
3653  * Determine whether a CXType has the "const" qualifier set,
3654  * without looking through typedefs that may have added "const" at a
3655  * different level.
3656  */
3658 
3659 /**
3660  * Determine whether a CXCursor that is a macro, is
3661  * function like.
3662  */
3664 
3665 /**
3666  * Determine whether a CXCursor that is a macro, is a
3667  * builtin one.
3668  */
3670 
3671 /**
3672  * Determine whether a CXCursor that is a function declaration, is an
3673  * inline declaration.
3674  */
3676 
3677 /**
3678  * Determine whether a CXType has the "volatile" qualifier set,
3679  * without looking through typedefs that may have added "volatile" at
3680  * a different level.
3681  */
3683 
3684 /**
3685  * Determine whether a CXType has the "restrict" qualifier set,
3686  * without looking through typedefs that may have added "restrict" at a
3687  * different level.
3688  */
3690 
3691 /**
3692  * Returns the address space of the given type.
3693  */
3695 
3696 /**
3697  * Returns the typedef name of the given type.
3698  */
3700 
3701 /**
3702  * For pointer types, returns the type of the pointee.
3703  */
3705 
3706 /**
3707  * Return the cursor for the declaration of the given type.
3708  */
3710 
3711 /**
3712  * Returns the Objective-C type encoding for the specified declaration.
3713  */
3715 
3716 /**
3717  * Returns the Objective-C type encoding for the specified CXType.
3718  */
3720 
3721 /**
3722  * Retrieve the spelling of a given CXTypeKind.
3723  */
3725 
3726 /**
3727  * Retrieve the calling convention associated with a function type.
3728  *
3729  * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3730  */
3732 
3733 /**
3734  * Retrieve the return type associated with a function type.
3735  *
3736  * If a non-function type is passed in, an invalid type is returned.
3737  */
3739 
3740 /**
3741  * Retrieve the exception specification type associated with a function type.
3742  * This is a value of type CXCursor_ExceptionSpecificationKind.
3743  *
3744  * If a non-function type is passed in, an error code of -1 is returned.
3745  */
3747 
3748 /**
3749  * Retrieve the number of non-variadic parameters associated with a
3750  * function type.
3751  *
3752  * If a non-function type is passed in, -1 is returned.
3753  */
3755 
3756 /**
3757  * Retrieve the type of a parameter of a function type.
3758  *
3759  * If a non-function type is passed in or the function does not have enough
3760  * parameters, an invalid type is returned.
3761  */
3763 
3764 /**
3765  * Retrieves the base type of the ObjCObjectType.
3766  *
3767  * If the type is not an ObjC object, an invalid type is returned.
3768  */
3770 
3771 /**
3772  * Retrieve the number of protocol references associated with an ObjC object/id.
3773  *
3774  * If the type is not an ObjC object, 0 is returned.
3775  */
3777 
3778 /**
3779  * Retrieve the decl for a protocol reference for an ObjC object/id.
3780  *
3781  * If the type is not an ObjC object or there are not enough protocol
3782  * references, an invalid cursor is returned.
3783  */
3785 
3786 /**
3787  * Retrieve the number of type arguments associated with an ObjC object.
3788  *
3789  * If the type is not an ObjC object, 0 is returned.
3790  */
3792 
3793 /**
3794  * Retrieve a type argument associated with an ObjC object.
3795  *
3796  * If the type is not an ObjC or the index is not valid,
3797  * an invalid type is returned.
3798  */
3800 
3801 /**
3802  * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3803  */
3805 
3806 /**
3807  * Retrieve the return type associated with a given cursor.
3808  *
3809  * This only returns a valid type if the cursor refers to a function or method.
3810  */
3812 
3813 /**
3814  * Retrieve the exception specification type associated with a given cursor.
3815  * This is a value of type CXCursor_ExceptionSpecificationKind.
3816  *
3817  * This only returns a valid result if the cursor refers to a function or
3818  * method.
3819  */
3821 
3822 /**
3823  * Return 1 if the CXType is a POD (plain old data) type, and 0
3824  * otherwise.
3825  */
3827 
3828 /**
3829  * Return the element type of an array, complex, or vector type.
3830  *
3831  * If a type is passed in that is not an array, complex, or vector type,
3832  * an invalid type is returned.
3833  */
3835 
3836 /**
3837  * Return the number of elements of an array or vector type.
3838  *
3839  * If a type is passed in that is not an array or vector type,
3840  * -1 is returned.
3841  */
3843 
3844 /**
3845  * Return the element type of an array type.
3846  *
3847  * If a non-array type is passed in, an invalid type is returned.
3848  */
3850 
3851 /**
3852  * Return the array size of a constant array.
3853  *
3854  * If a non-array type is passed in, -1 is returned.
3855  */
3857 
3858 /**
3859  * Retrieve the type named by the qualified-id.
3860  *
3861  * If a non-elaborated type is passed in, an invalid type is returned.
3862  */
3864 
3865 /**
3866  * Determine if a typedef is 'transparent' tag.
3867  *
3868  * A typedef is considered 'transparent' if it shares a name and spelling
3869  * location with its underlying tag type, as is the case with the NS_ENUM macro.
3870  *
3871  * \returns non-zero if transparent and zero otherwise.
3872  */
3874 
3876  /**
3877  * Values of this type can never be null.
3878  */
3880  /**
3881  * Values of this type can be null.
3882  */
3884  /**
3885  * Whether values of this type can be null is (explicitly)
3886  * unspecified. This captures a (fairly rare) case where we
3887  * can't conclude anything about the nullability of the type even
3888  * though it has been considered.
3889  */
3891  /**
3892  * Nullability is not applicable to this type.
3893  */
3895 
3896  /**
3897  * Generally behaves like Nullable, except when used in a block parameter that
3898  * was imported into a swift async method. There, swift will assume that the
3899  * parameter can get null even if no error occured. _Nullable parameters are
3900  * assumed to only get null on error.
3901  */
3903 };
3904 
3905 /**
3906  * Retrieve the nullability kind of a pointer type.
3907  */
3909 
3910 /**
3911  * List the possible error codes for \c clang_Type_getSizeOf,
3912  * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3913  * \c clang_Cursor_getOffsetOf.
3914  *
3915  * A value of this enumeration type can be returned if the target type is not
3916  * a valid argument to sizeof, alignof or offsetof.
3917  */
3919  /**
3920  * Type is of kind CXType_Invalid.
3921  */
3923  /**
3924  * The type is an incomplete Type.
3925  */
3927  /**
3928  * The type is a dependent Type.
3929  */
3931  /**
3932  * The type is not a constant size type.
3933  */
3935  /**
3936  * The Field name is not valid for this record.
3937  */
3939  /**
3940  * The type is undeduced.
3941  */
3943 };
3944 
3945 /**
3946  * Return the alignment of a type in bytes as per C++[expr.alignof]
3947  * standard.
3948  *
3949  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3950  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3951  * is returned.
3952  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3953  * returned.
3954  * If the type declaration is not a constant size type,
3955  * CXTypeLayoutError_NotConstantSize is returned.
3956  */
3958 
3959 /**
3960  * Return the class type of an member pointer type.
3961  *
3962  * If a non-member-pointer type is passed in, an invalid type is returned.
3963  */
3965 
3966 /**
3967  * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3968  *
3969  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3970  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3971  * is returned.
3972  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3973  * returned.
3974  */
3976 
3977 /**
3978  * Return the offset of a field named S in a record of type T in bits
3979  * as it would be returned by __offsetof__ as per C++11[18.2p4]
3980  *
3981  * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3982  * is returned.
3983  * If the field's type declaration is an incomplete type,
3984  * CXTypeLayoutError_Incomplete is returned.
3985  * If the field's type declaration is a dependent type,
3986  * CXTypeLayoutError_Dependent is returned.
3987  * If the field's name S is not found,
3988  * CXTypeLayoutError_InvalidFieldName is returned.
3989  */
3990 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3991 
3992 /**
3993  * Return the type that was modified by this attributed type.
3994  *
3995  * If the type is not an attributed type, an invalid type is returned.
3996  */
3998 
3999 /**
4000  * Gets the type contained by this atomic type.
4001  *
4002  * If a non-atomic type is passed in, an invalid type is returned.
4003  */
4005 
4006 /**
4007  * Return the offset of the field represented by the Cursor.
4008  *
4009  * If the cursor is not a field declaration, -1 is returned.
4010  * If the cursor semantic parent is not a record field declaration,
4011  * CXTypeLayoutError_Invalid is returned.
4012  * If the field's type declaration is an incomplete type,
4013  * CXTypeLayoutError_Incomplete is returned.
4014  * If the field's type declaration is a dependent type,
4015  * CXTypeLayoutError_Dependent is returned.
4016  * If the field's name S is not found,
4017  * CXTypeLayoutError_InvalidFieldName is returned.
4018  */
4020 
4021 /**
4022  * Determine whether the given cursor represents an anonymous
4023  * tag or namespace
4024  */
4026 
4027 /**
4028  * Determine whether the given cursor represents an anonymous record
4029  * declaration.
4030  */
4032 
4033 /**
4034  * Determine whether the given cursor represents an inline namespace
4035  * declaration.
4036  */
4038 
4040  /** No ref-qualifier was provided. */
4042  /** An lvalue ref-qualifier was provided (\c &). */
4044  /** An rvalue ref-qualifier was provided (\c &&). */
4046 };
4047 
4048 /**
4049  * Returns the number of template arguments for given template
4050  * specialization, or -1 if type \c T is not a template specialization.
4051  */
4053 
4054 /**
4055  * Returns the type template argument of a template class specialization
4056  * at given index.
4057  *
4058  * This function only returns template type arguments and does not handle
4059  * template template arguments or variadic packs.
4060  */
4062  unsigned i);
4063 
4064 /**
4065  * Retrieve the ref-qualifier kind of a function or method.
4066  *
4067  * The ref-qualifier is returned for C++ functions or methods. For other types
4068  * or non-C++ declarations, CXRefQualifier_None is returned.
4069  */
4071 
4072 /**
4073  * Returns non-zero if the cursor specifies a Record member that is a
4074  * bitfield.
4075  */
4077 
4078 /**
4079  * Returns 1 if the base class specified by the cursor with kind
4080  * CX_CXXBaseSpecifier is virtual.
4081  */
4083 
4084 /**
4085  * Represents the C++ access control level to a base class for a
4086  * cursor with kind CX_CXXBaseSpecifier.
4087  */
4093 };
4094 
4095 /**
4096  * Returns the access control level for the referenced object.
4097  *
4098  * If the cursor refers to a C++ declaration, its access control level within
4099  * its parent scope is returned. Otherwise, if the cursor refers to a base
4100  * specifier or access specifier, the specifier itself is returned.
4101  */
4103 
4104 /**
4105  * Represents the storage classes as declared in the source. CX_SC_Invalid
4106  * was added for the case that the passed cursor in not a declaration.
4107  */
4117 };
4118 
4119 /**
4120  * Returns the storage class for a function or variable declaration.
4121  *
4122  * If the passed in Cursor is not a function or variable declaration,
4123  * CX_SC_Invalid is returned else the storage class.
4124  */
4126 
4127 /**
4128  * Determine the number of overloaded declarations referenced by a
4129  * \c CXCursor_OverloadedDeclRef cursor.
4130  *
4131  * \param cursor The cursor whose overloaded declarations are being queried.
4132  *
4133  * \returns The number of overloaded declarations referenced by \c cursor. If it
4134  * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4135  */
4137 
4138 /**
4139  * Retrieve a cursor for one of the overloaded declarations referenced
4140  * by a \c CXCursor_OverloadedDeclRef cursor.
4141  *
4142  * \param cursor The cursor whose overloaded declarations are being queried.
4143  *
4144  * \param index The zero-based index into the set of overloaded declarations in
4145  * the cursor.
4146  *
4147  * \returns A cursor representing the declaration referenced by the given
4148  * \c cursor at the specified \c index. If the cursor does not have an
4149  * associated set of overloaded declarations, or if the index is out of bounds,
4150  * returns \c clang_getNullCursor();
4151  */
4153  unsigned index);
4154 
4155 /**
4156  * @}
4157  */
4158 
4159 /**
4160  * \defgroup CINDEX_ATTRIBUTES Information for attributes
4161  *
4162  * @{
4163  */
4164 
4165 /**
4166  * For cursors representing an iboutletcollection attribute,
4167  * this function returns the collection element type.
4168  *
4169  */
4171 
4172 /**
4173  * @}
4174  */
4175 
4176 /**
4177  * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4178  *
4179  * These routines provide the ability to traverse the abstract syntax tree
4180  * using cursors.
4181  *
4182  * @{
4183  */
4184 
4185 /**
4186  * Describes how the traversal of the children of a particular
4187  * cursor should proceed after visiting a particular child cursor.
4188  *
4189  * A value of this enumeration type should be returned by each
4190  * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4191  */
4193  /**
4194  * Terminates the cursor traversal.
4195  */
4197  /**
4198  * Continues the cursor traversal with the next sibling of
4199  * the cursor just visited, without visiting its children.
4200  */
4202  /**
4203  * Recursively traverse the children of this cursor, using
4204  * the same visitor and client data.
4205  */
4207 };
4208 
4209 /**
4210  * Visitor invoked for each cursor found by a traversal.
4211  *
4212  * This visitor function will be invoked for each cursor found by
4213  * clang_visitCursorChildren(). Its first argument is the cursor being
4214  * visited, its second argument is the parent visitor for that cursor,
4215  * and its third argument is the client data provided to
4216  * clang_visitCursorChildren().
4217  *
4218  * The visitor should return one of the \c CXChildVisitResult values
4219  * to direct clang_visitCursorChildren().
4220  */
4222  CXCursor parent,
4223  CXClientData client_data);
4224 
4225 /**
4226  * Visit the children of a particular cursor.
4227  *
4228  * This function visits all the direct children of the given cursor,
4229  * invoking the given \p visitor function with the cursors of each
4230  * visited child. The traversal may be recursive, if the visitor returns
4231  * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4232  * the visitor returns \c CXChildVisit_Break.
4233  *
4234  * \param parent the cursor whose child may be visited. All kinds of
4235  * cursors can be visited, including invalid cursors (which, by
4236  * definition, have no children).
4237  *
4238  * \param visitor the visitor function that will be invoked for each
4239  * child of \p parent.
4240  *
4241  * \param client_data pointer data supplied by the client, which will
4242  * be passed to the visitor each time it is invoked.
4243  *
4244  * \returns a non-zero value if the traversal was terminated
4245  * prematurely by the visitor returning \c CXChildVisit_Break.
4246  */
4248  CXCursorVisitor visitor,
4249  CXClientData client_data);
4250 #ifdef __has_feature
4251 #if __has_feature(blocks)
4252 /**
4253  * Visitor invoked for each cursor found by a traversal.
4254  *
4255  * This visitor block will be invoked for each cursor found by
4256  * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4257  * visited, its second argument is the parent visitor for that cursor.
4258  *
4259  * The visitor should return one of the \c CXChildVisitResult values
4260  * to direct clang_visitChildrenWithBlock().
4261  */
4262 typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
4263  CXCursor parent);
4264 
4265 /**
4266  * Visits the children of a cursor using the specified block. Behaves
4267  * identically to clang_visitChildren() in all other respects.
4268  */
4269 CINDEX_LINKAGE unsigned
4270 clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
4271 #endif
4272 #endif
4273 
4274 /**
4275  * @}
4276  */
4277 
4278 /**
4279  * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4280  *
4281  * These routines provide the ability to determine references within and
4282  * across translation units, by providing the names of the entities referenced
4283  * by cursors, follow reference cursors to the declarations they reference,
4284  * and associate declarations with their definitions.
4285  *
4286  * @{
4287  */
4288 
4289 /**
4290  * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4291  * by the given cursor.
4292  *
4293  * A Unified Symbol Resolution (USR) is a string that identifies a particular
4294  * entity (function, class, variable, etc.) within a program. USRs can be
4295  * compared across translation units to determine, e.g., when references in
4296  * one translation refer to an entity defined in another translation unit.
4297  */
4299 
4300 /**
4301  * Construct a USR for a specified Objective-C class.
4302  */
4303 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4304 
4305 /**
4306  * Construct a USR for a specified Objective-C category.
4307  */
4309  const char *class_name, const char *category_name);
4310 
4311 /**
4312  * Construct a USR for a specified Objective-C protocol.
4313  */
4315 clang_constructUSR_ObjCProtocol(const char *protocol_name);
4316 
4317 /**
4318  * Construct a USR for a specified Objective-C instance variable and
4319  * the USR for its containing class.
4320  */
4322  CXString classUSR);
4323 
4324 /**
4325  * Construct a USR for a specified Objective-C method and
4326  * the USR for its containing class.
4327  */
4329  unsigned isInstanceMethod,
4330  CXString classUSR);
4331 
4332 /**
4333  * Construct a USR for a specified Objective-C property and the USR
4334  * for its containing class.
4335  */
4337  CXString classUSR);
4338 
4339 /**
4340  * Retrieve a name for the entity referenced by this cursor.
4341  */
4343 
4344 /**
4345  * Retrieve a range for a piece that forms the cursors spelling name.
4346  * Most of the times there is only one range for the complete spelling but for
4347  * Objective-C methods and Objective-C message expressions, there are multiple
4348  * pieces for each selector identifier.
4349  *
4350  * \param pieceIndex the index of the spelling name piece. If this is greater
4351  * than the actual number of pieces, it will return a NULL (invalid) range.
4352  *
4353  * \param options Reserved.
4354  */
4356  CXCursor, unsigned pieceIndex, unsigned options);
4357 
4358 /**
4359  * Opaque pointer representing a policy that controls pretty printing
4360  * for \c clang_getCursorPrettyPrinted.
4361  */
4362 typedef void *CXPrintingPolicy;
4363 
4364 /**
4365  * Properties for the printing policy.
4366  *
4367  * See \c clang::PrintingPolicy for more information.
4368  */
4396 
4398 };
4399 
4400 /**
4401  * Get a property value for the given printing policy.
4402  */
4403 CINDEX_LINKAGE unsigned
4405  enum CXPrintingPolicyProperty Property);
4406 
4407 /**
4408  * Set a property value for the given printing policy.
4409  */
4410 CINDEX_LINKAGE void
4412  enum CXPrintingPolicyProperty Property,
4413  unsigned Value);
4414 
4415 /**
4416  * Retrieve the default policy for the cursor.
4417  *
4418  * The policy should be released after use with \c
4419  * clang_PrintingPolicy_dispose.
4420  */
4422 
4423 /**
4424  * Release a printing policy.
4425  */
4427 
4428 /**
4429  * Pretty print declarations.
4430  *
4431  * \param Cursor The cursor representing a declaration.
4432  *
4433  * \param Policy The policy to control the entities being printed. If
4434  * NULL, a default policy is used.
4435  *
4436  * \returns The pretty printed declaration or the empty string for
4437  * other cursors.
4438  */
4440  CXPrintingPolicy Policy);
4441 
4442 /**
4443  * Retrieve the display name for the entity referenced by this cursor.
4444  *
4445  * The display name contains extra information that helps identify the cursor,
4446  * such as the parameters of a function or template or the arguments of a
4447  * class template specialization.
4448  */
4450 
4451 /** For a cursor that is a reference, retrieve a cursor representing the
4452  * entity that it references.
4453  *
4454  * Reference cursors refer to other entities in the AST. For example, an
4455  * Objective-C superclass reference cursor refers to an Objective-C class.
4456  * This function produces the cursor for the Objective-C class from the
4457  * cursor for the superclass reference. If the input cursor is a declaration or
4458  * definition, it returns that declaration or definition unchanged.
4459  * Otherwise, returns the NULL cursor.
4460  */
4462 
4463 /**
4464  * For a cursor that is either a reference to or a declaration
4465  * of some entity, retrieve a cursor that describes the definition of
4466  * that entity.
4467  *
4468  * Some entities can be declared multiple times within a translation
4469  * unit, but only one of those declarations can also be a
4470  * definition. For example, given:
4471  *
4472  * \code
4473  * int f(int, int);
4474  * int g(int x, int y) { return f(x, y); }
4475  * int f(int a, int b) { return a + b; }
4476  * int f(int, int);
4477  * \endcode
4478  *
4479  * there are three declarations of the function "f", but only the
4480  * second one is a definition. The clang_getCursorDefinition()
4481  * function will take any cursor pointing to a declaration of "f"
4482  * (the first or fourth lines of the example) or a cursor referenced
4483  * that uses "f" (the call to "f' inside "g") and will return a
4484  * declaration cursor pointing to the definition (the second "f"
4485  * declaration).
4486  *
4487  * If given a cursor for which there is no corresponding definition,
4488  * e.g., because there is no definition of that entity within this
4489  * translation unit, returns a NULL cursor.
4490  */
4492 
4493 /**
4494  * Determine whether the declaration pointed to by this cursor
4495  * is also a definition of that entity.
4496  */
4498 
4499 /**
4500  * Retrieve the canonical cursor corresponding to the given cursor.
4501  *
4502  * In the C family of languages, many kinds of entities can be declared several
4503  * times within a single translation unit. For example, a structure type can
4504  * be forward-declared (possibly multiple times) and later defined:
4505  *
4506  * \code
4507  * struct X;
4508  * struct X;
4509  * struct X {
4510  * int member;
4511  * };
4512  * \endcode
4513  *
4514  * The declarations and the definition of \c X are represented by three
4515  * different cursors, all of which are declarations of the same underlying
4516  * entity. One of these cursor is considered the "canonical" cursor, which
4517  * is effectively the representative for the underlying entity. One can
4518  * determine if two cursors are declarations of the same underlying entity by
4519  * comparing their canonical cursors.
4520  *
4521  * \returns The canonical cursor for the entity referred to by the given cursor.
4522  */
4524 
4525 /**
4526  * If the cursor points to a selector identifier in an Objective-C
4527  * method or message expression, this returns the selector index.
4528  *
4529  * After getting a cursor with #clang_getCursor, this can be called to
4530  * determine if the location points to a selector identifier.
4531  *
4532  * \returns The selector index if the cursor is an Objective-C method or message
4533  * expression and the cursor is pointing to a selector identifier, or -1
4534  * otherwise.
4535  */
4537 
4538 /**
4539  * Given a cursor pointing to a C++ method call or an Objective-C
4540  * message, returns non-zero if the method/message is "dynamic", meaning:
4541  *
4542  * For a C++ method: the call is virtual.
4543  * For an Objective-C message: the receiver is an object instance, not 'super'
4544  * or a specific class.
4545  *
4546  * If the method/message is "static" or the cursor does not point to a
4547  * method/message, it will return zero.
4548  */
4550 
4551 /**
4552  * Given a cursor pointing to an Objective-C message or property
4553  * reference, or C++ method call, returns the CXType of the receiver.
4554  */
4556 
4557 /**
4558  * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4559  */
4560 typedef enum {
4576 
4577 /**
4578  * Given a cursor that represents a property declaration, return the
4579  * associated property attributes. The bits are formed from
4580  * \c CXObjCPropertyAttrKind.
4581  *
4582  * \param reserved Reserved for future use, pass 0.
4583  */
4584 CINDEX_LINKAGE unsigned
4586 
4587 /**
4588  * Given a cursor that represents a property declaration, return the
4589  * name of the method that implements the getter.
4590  */
4592 
4593 /**
4594  * Given a cursor that represents a property declaration, return the
4595  * name of the method that implements the setter, if any.
4596  */
4598 
4599 /**
4600  * 'Qualifiers' written next to the return and parameter types in
4601  * Objective-C method declarations.
4602  */
4603 typedef enum {
4612 
4613 /**
4614  * Given a cursor that represents an Objective-C method or parameter
4615  * declaration, return the associated Objective-C qualifiers for the return
4616  * type or the parameter respectively. The bits are formed from
4617  * CXObjCDeclQualifierKind.
4618  */
4620 
4621 /**
4622  * Given a cursor that represents an Objective-C method or property
4623  * declaration, return non-zero if the declaration was affected by "\@optional".
4624  * Returns zero if the cursor is not such a declaration or it is "\@required".
4625  */
4627 
4628 /**
4629  * Returns non-zero if the given cursor is a variadic function or method.
4630  */
4632 
4633 /**
4634  * Returns non-zero if the given cursor points to a symbol marked with
4635  * external_source_symbol attribute.
4636  *
4637  * \param language If non-NULL, and the attribute is present, will be set to
4638  * the 'language' string from the attribute.
4639  *
4640  * \param definedIn If non-NULL, and the attribute is present, will be set to
4641  * the 'definedIn' string from the attribute.
4642  *
4643  * \param isGenerated If non-NULL, and the attribute is present, will be set to
4644  * non-zero if the 'generated_declaration' is set in the attribute.
4645  */
4647  CXString *language,
4648  CXString *definedIn,
4649  unsigned *isGenerated);
4650 
4651 /**
4652  * Given a cursor that represents a declaration, return the associated
4653  * comment's source range. The range may include multiple consecutive comments
4654  * with whitespace in between.
4655  */
4657 
4658 /**
4659  * Given a cursor that represents a declaration, return the associated
4660  * comment text, including comment markers.
4661  */
4663 
4664 /**
4665  * Given a cursor that represents a documentable entity (e.g.,
4666  * declaration), return the associated \paragraph; otherwise return the
4667  * first paragraph.
4668  */
4670 
4671 /**
4672  * @}
4673  */
4674 
4675 /** \defgroup CINDEX_MANGLE Name Mangling API Functions
4676  *
4677  * @{
4678  */
4679 
4680 /**
4681  * Retrieve the CXString representing the mangled name of the cursor.
4682  */
4684 
4685 /**
4686  * Retrieve the CXStrings representing the mangled symbols of the C++
4687  * constructor or destructor at the cursor.
4688  */
4690 
4691 /**
4692  * Retrieve the CXStrings representing the mangled symbols of the ObjC
4693  * class interface or implementation at the cursor.
4694  */
4696 
4697 /**
4698  * @}
4699  */
4700 
4701 /**
4702  * \defgroup CINDEX_MODULE Module introspection
4703  *
4704  * The functions in this group provide access to information about modules.
4705  *
4706  * @{
4707  */
4708 
4709 typedef void *CXModule;
4710 
4711 /**
4712  * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4713  */
4715 
4716 /**
4717  * Given a CXFile header file, return the module that contains it, if one
4718  * exists.
4719  */
4721 
4722 /**
4723  * \param Module a module object.
4724  *
4725  * \returns the module file where the provided module object came from.
4726  */
4728 
4729 /**
4730  * \param Module a module object.
4731  *
4732  * \returns the parent of a sub-module or NULL if the given module is top-level,
4733  * e.g. for 'std.vector' it will return the 'std' module.
4734  */
4736 
4737 /**
4738  * \param Module a module object.
4739  *
4740  * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4741  * will return "vector".
4742  */
4744 
4745 /**
4746  * \param Module a module object.
4747  *
4748  * \returns the full name of the module, e.g. "std.vector".
4749  */
4751 
4752 /**
4753  * \param Module a module object.
4754  *
4755  * \returns non-zero if the module is a system one.
4756  */
4758 
4759 /**
4760  * \param Module a module object.
4761  *
4762  * \returns the number of top level headers associated with this module.
4763  */
4765  CXModule Module);
4766 
4767 /**
4768  * \param Module a module object.
4769  *
4770  * \param Index top level header index (zero-based).
4771  *
4772  * \returns the specified top level header associated with the module.
4773  */
4776  unsigned Index);
4777 
4778 /**
4779  * @}
4780  */
4781 
4782 /**
4783  * \defgroup CINDEX_CPP C++ AST introspection
4784  *
4785  * The routines in this group provide access information in the ASTs specific
4786  * to C++ language features.
4787  *
4788  * @{
4789  */
4790 
4791 /**
4792  * Determine if a C++ constructor is a converting constructor.
4793  */
4794 CINDEX_LINKAGE unsigned
4796 
4797 /**
4798  * Determine if a C++ constructor is a copy constructor.
4799  */
4801 
4802 /**
4803  * Determine if a C++ constructor is the default constructor.
4804  */
4806 
4807 /**
4808  * Determine if a C++ constructor is a move constructor.
4809  */
4811 
4812 /**
4813  * Determine if a C++ field is declared 'mutable'.
4814  */
4816 
4817 /**
4818  * Determine if a C++ method is declared '= default'.
4819  */
4821 
4822 /**
4823  * Determine if a C++ member function or member function template is
4824  * pure virtual.
4825  */
4827 
4828 /**
4829  * Determine if a C++ member function or member function template is
4830  * declared 'static'.
4831  */
4833 
4834 /**
4835  * Determine if a C++ member function or member function template is
4836  * explicitly declared 'virtual' or if it overrides a virtual method from
4837  * one of the base classes.
4838  */
4840 
4841 /**
4842  * Determine if a C++ record is abstract, i.e. whether a class or struct
4843  * has a pure virtual member function.
4844  */
4846 
4847 /**
4848  * Determine if an enum declaration refers to a scoped enum.
4849  */
4851 
4852 /**
4853  * Determine if a C++ member function or member function template is
4854  * declared 'const'.
4855  */
4857 
4858 /**
4859  * Given a cursor that represents a template, determine
4860  * the cursor kind of the specializations would be generated by instantiating
4861  * the template.
4862  *
4863  * This routine can be used to determine what flavor of function template,
4864  * class template, or class template partial specialization is stored in the
4865  * cursor. For example, it can describe whether a class template cursor is
4866  * declared with "struct", "class" or "union".
4867  *
4868  * \param C The cursor to query. This cursor should represent a template
4869  * declaration.
4870  *
4871  * \returns The cursor kind of the specializations that would be generated
4872  * by instantiating the template \p C. If \p C is not a template, returns
4873  * \c CXCursor_NoDeclFound.
4874  */
4876 
4877 /**
4878  * Given a cursor that may represent a specialization or instantiation
4879  * of a template, retrieve the cursor that represents the template that it
4880  * specializes or from which it was instantiated.
4881  *
4882  * This routine determines the template involved both for explicit
4883  * specializations of templates and for implicit instantiations of the template,
4884  * both of which are referred to as "specializations". For a class template
4885  * specialization (e.g., \c std::vector<bool>), this routine will return
4886  * either the primary template (\c std::vector) or, if the specialization was
4887  * instantiated from a class template partial specialization, the class template
4888  * partial specialization. For a class template partial specialization and a
4889  * function template specialization (including instantiations), this
4890  * this routine will return the specialized template.
4891  *
4892  * For members of a class template (e.g., member functions, member classes, or
4893  * static data members), returns the specialized or instantiated member.
4894  * Although not strictly "templates" in the C++ language, members of class
4895  * templates have the same notions of specializations and instantiations that
4896  * templates do, so this routine treats them similarly.
4897  *
4898  * \param C A cursor that may be a specialization of a template or a member
4899  * of a template.
4900  *
4901  * \returns If the given cursor is a specialization or instantiation of a
4902  * template or a member thereof, the template or member that it specializes or
4903  * from which it was instantiated. Otherwise, returns a NULL cursor.
4904  */
4906 
4907 /**
4908  * Given a cursor that references something else, return the source range
4909  * covering that reference.
4910  *
4911  * \param C A cursor pointing to a member reference, a declaration reference, or
4912  * an operator call.
4913  * \param NameFlags A bitset with three independent flags:
4914  * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4915  * CXNameRange_WantSinglePiece.
4916  * \param PieceIndex For contiguous names or when passing the flag
4917  * CXNameRange_WantSinglePiece, only one piece with index 0 is
4918  * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4919  * non-contiguous names, this index can be used to retrieve the individual
4920  * pieces of the name. See also CXNameRange_WantSinglePiece.
4921  *
4922  * \returns The piece of the name pointed to by the given cursor. If there is no
4923  * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4924  */
4926  CXCursor C, unsigned NameFlags, unsigned PieceIndex);
4927 
4929  /**
4930  * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4931  * range.
4932  */
4934 
4935  /**
4936  * Include the explicit template arguments, e.g. <int> in x.f<int>,
4937  * in the range.
4938  */
4940 
4941  /**
4942  * If the name is non-contiguous, return the full spanning range.
4943  *
4944  * Non-contiguous names occur in Objective-C when a selector with two or more
4945  * parameters is used, or in C++ when using an operator:
4946  * \code
4947  * [object doSomething:here withValue:there]; // Objective-C
4948  * return some_vector[1]; // C++
4949  * \endcode
4950  */
4952 };
4953 
4954 /**
4955  * @}
4956  */
4957 
4958 /**
4959  * \defgroup CINDEX_LEX Token extraction and manipulation
4960  *
4961  * The routines in this group provide access to the tokens within a
4962  * translation unit, along with a semantic mapping of those tokens to
4963  * their corresponding cursors.
4964  *
4965  * @{
4966  */
4967 
4968 /**
4969  * Describes a kind of token.
4970  */
4971 typedef enum CXTokenKind {
4972  /**
4973  * A token that contains some kind of punctuation.
4974  */
4976 
4977  /**
4978  * A language keyword.
4979  */
4981 
4982  /**
4983  * An identifier (that is not a keyword).
4984  */
4986 
4987  /**
4988  * A numeric, string, or character literal.
4989  */
4991 
4992  /**
4993  * A comment.
4994  */
4996 } CXTokenKind;
4997 
4998 /**
4999  * Describes a single preprocessing token.
5000  */
5001 typedef struct {
5002  unsigned int_data[4];
5003  void *ptr_data;
5004 } CXToken;
5005 
5006 /**
5007  * Get the raw lexical token starting with the given location.
5008  *
5009  * \param TU the translation unit whose text is being tokenized.
5010  *
5011  * \param Location the source location with which the token starts.
5012  *
5013  * \returns The token starting with the given location or NULL if no such token
5014  * exist. The returned pointer must be freed with clang_disposeTokens before the
5015  * translation unit is destroyed.
5016  */
5018  CXSourceLocation Location);
5019 
5020 /**
5021  * Determine the kind of the given token.
5022  */
5024 
5025 /**
5026  * Determine the spelling of the given token.
5027  *
5028  * The spelling of a token is the textual representation of that token, e.g.,
5029  * the text of an identifier or keyword.
5030  */
5032 
5033 /**
5034  * Retrieve the source location of the given token.
5035  */
5037  CXToken);
5038 
5039 /**
5040  * Retrieve a source range that covers the given token.
5041  */
5043 
5044 /**
5045  * Tokenize the source code described by the given range into raw
5046  * lexical tokens.
5047  *
5048  * \param TU the translation unit whose text is being tokenized.
5049  *
5050  * \param Range the source range in which text should be tokenized. All of the
5051  * tokens produced by tokenization will fall within this source range,
5052  *
5053  * \param Tokens this pointer will be set to point to the array of tokens
5054  * that occur within the given source range. The returned pointer must be
5055  * freed with clang_disposeTokens() before the translation unit is destroyed.
5056  *
5057  * \param NumTokens will be set to the number of tokens in the \c *Tokens
5058  * array.
5059  *
5060  */
5062  CXToken **Tokens, unsigned *NumTokens);
5063 
5064 /**
5065  * Annotate the given set of tokens by providing cursors for each token
5066  * that can be mapped to a specific entity within the abstract syntax tree.
5067  *
5068  * This token-annotation routine is equivalent to invoking
5069  * clang_getCursor() for the source locations of each of the
5070  * tokens. The cursors provided are filtered, so that only those
5071  * cursors that have a direct correspondence to the token are
5072  * accepted. For example, given a function call \c f(x),
5073  * clang_getCursor() would provide the following cursors:
5074  *
5075  * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
5076  * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
5077  * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
5078  *
5079  * Only the first and last of these cursors will occur within the
5080  * annotate, since the tokens "f" and "x' directly refer to a function
5081  * and a variable, respectively, but the parentheses are just a small
5082  * part of the full syntax of the function call expression, which is
5083  * not provided as an annotation.
5084  *
5085  * \param TU the translation unit that owns the given tokens.
5086  *
5087  * \param Tokens the set of tokens to annotate.
5088  *
5089  * \param NumTokens the number of tokens in \p Tokens.
5090  *
5091  * \param Cursors an array of \p NumTokens cursors, whose contents will be
5092  * replaced with the cursors corresponding to each token.
5093  */
5095  unsigned NumTokens, CXCursor *Cursors);
5096 
5097 /**
5098  * Free the given set of tokens.
5099  */
5101  unsigned NumTokens);
5102 
5103 /**
5104  * @}
5105  */
5106 
5107 /**
5108  * \defgroup CINDEX_DEBUG Debugging facilities
5109  *
5110  * These routines are used for testing and debugging, only, and should not
5111  * be relied upon.
5112  *
5113  * @{
5114  */
5115 
5116 /* for debug/testing */
5119  CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
5120  unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
5122 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
5123  unsigned stack_size);
5124 
5125 /**
5126  * @}
5127  */
5128 
5129 /**
5130  * \defgroup CINDEX_CODE_COMPLET Code completion
5131  *
5132  * Code completion involves taking an (incomplete) source file, along with
5133  * knowledge of where the user is actively editing that file, and suggesting
5134  * syntactically- and semantically-valid constructs that the user might want to
5135  * use at that particular point in the source code. These data structures and
5136  * routines provide support for code completion.
5137  *
5138  * @{
5139  */
5140 
5141 /**
5142  * A semantic string that describes a code-completion result.
5143  *
5144  * A semantic string that describes the formatting of a code-completion
5145  * result as a single "template" of text that should be inserted into the
5146  * source buffer when a particular code-completion result is selected.
5147  * Each semantic string is made up of some number of "chunks", each of which
5148  * contains some text along with a description of what that text means, e.g.,
5149  * the name of the entity being referenced, whether the text chunk is part of
5150  * the template, or whether it is a "placeholder" that the user should replace
5151  * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
5152  * description of the different kinds of chunks.
5153  */
5154 typedef void *CXCompletionString;
5155 
5156 /**
5157  * A single result of code completion.
5158  */
5159 typedef struct {
5160  /**
5161  * The kind of entity that this completion refers to.
5162  *
5163  * The cursor kind will be a macro, keyword, or a declaration (one of the
5164  * *Decl cursor kinds), describing the entity that the completion is
5165  * referring to.
5166  *
5167  * \todo In the future, we would like to provide a full cursor, to allow
5168  * the client to extract additional information from declaration.
5169  */
5170  enum CXCursorKind CursorKind;
5171 
5172  /**
5173  * The code-completion string that describes how to insert this
5174  * code-completion result into the editing buffer.
5175  */
5178 
5179 /**
5180  * Describes a single piece of text within a code-completion string.
5181  *
5182  * Each "chunk" within a code-completion string (\c CXCompletionString) is
5183  * either a piece of text with a specific "kind" that describes how that text
5184  * should be interpreted by the client or is another completion string.
5185  */
5187  /**
5188  * A code-completion string that describes "optional" text that
5189  * could be a part of the template (but is not required).
5190  *
5191  * The Optional chunk is the only kind of chunk that has a code-completion
5192  * string for its representation, which is accessible via
5193  * \c clang_getCompletionChunkCompletionString(). The code-completion string
5194  * describes an additional part of the template that is completely optional.
5195  * For example, optional chunks can be used to describe the placeholders for
5196  * arguments that match up with defaulted function parameters, e.g. given:
5197  *
5198  * \code
5199  * void f(int x, float y = 3.14, double z = 2.71828);
5200  * \endcode
5201  *
5202  * The code-completion string for this function would contain:
5203  * - a TypedText chunk for "f".
5204  * - a LeftParen chunk for "(".
5205  * - a Placeholder chunk for "int x"
5206  * - an Optional chunk containing the remaining defaulted arguments, e.g.,
5207  * - a Comma chunk for ","
5208  * - a Placeholder chunk for "float y"
5209  * - an Optional chunk containing the last defaulted argument:
5210  * - a Comma chunk for ","
5211  * - a Placeholder chunk for "double z"
5212  * - a RightParen chunk for ")"
5213  *
5214  * There are many ways to handle Optional chunks. Two simple approaches are:
5215  * - Completely ignore optional chunks, in which case the template for the
5216  * function "f" would only include the first parameter ("int x").
5217  * - Fully expand all optional chunks, in which case the template for the
5218  * function "f" would have all of the parameters.
5219  */
5221  /**
5222  * Text that a user would be expected to type to get this
5223  * code-completion result.
5224  *
5225  * There will be exactly one "typed text" chunk in a semantic string, which
5226  * will typically provide the spelling of a keyword or the name of a
5227  * declaration that could be used at the current code point. Clients are
5228  * expected to filter the code-completion results based on the text in this
5229  * chunk.
5230  */
5232  /**
5233  * Text that should be inserted as part of a code-completion result.
5234  *
5235  * A "text" chunk represents text that is part of the template to be
5236  * inserted into user code should this particular code-completion result
5237  * be selected.
5238  */
5240  /**
5241  * Placeholder text that should be replaced by the user.
5242  *
5243  * A "placeholder" chunk marks a place where the user should insert text
5244  * into the code-completion template. For example, placeholders might mark
5245  * the function parameters for a function declaration, to indicate that the
5246  * user should provide arguments for each of those parameters. The actual
5247  * text in a placeholder is a suggestion for the text to display before
5248  * the user replaces the placeholder with real code.
5249  */
5251  /**
5252  * Informative text that should be displayed but never inserted as
5253  * part of the template.
5254  *
5255  * An "informative" chunk contains annotations that can be displayed to
5256  * help the user decide whether a particular code-completion result is the
5257  * right option, but which is not part of the actual template to be inserted
5258  * by code completion.
5259  */
5261  /**
5262  * Text that describes the current parameter when code-completion is
5263  * referring to function call, message send, or template specialization.
5264  *
5265  * A "current parameter" chunk occurs when code-completion is providing
5266  * information about a parameter corresponding to the argument at the
5267  * code-completion point. For example, given a function
5268  *
5269  * \code
5270  * int add(int x, int y);
5271  * \endcode
5272  *
5273  * and the source code \c add(, where the code-completion point is after the
5274  * "(", the code-completion string will contain a "current parameter" chunk
5275  * for "int x", indicating that the current argument will initialize that
5276  * parameter. After typing further, to \c add(17, (where the code-completion
5277  * point is after the ","), the code-completion string will contain a
5278  * "current parameter" chunk to "int y".
5279  */
5281  /**
5282  * A left parenthesis ('('), used to initiate a function call or
5283  * signal the beginning of a function parameter list.
5284  */
5286  /**
5287  * A right parenthesis (')'), used to finish a function call or
5288  * signal the end of a function parameter list.
5289  */
5291  /**
5292  * A left bracket ('[').
5293  */
5295  /**
5296  * A right bracket (']').
5297  */
5299  /**
5300  * A left brace ('{').
5301  */
5303  /**
5304  * A right brace ('}').
5305  */
5307  /**
5308  * A left angle bracket ('<').
5309  */
5311  /**
5312  * A right angle bracket ('>').
5313  */
5315  /**
5316  * A comma separator (',').
5317  */
5319  /**
5320  * Text that specifies the result type of a given result.
5321  *
5322  * This special kind of informative chunk is not meant to be inserted into
5323  * the text buffer. Rather, it is meant to illustrate the type that an
5324  * expression using the given completion string would have.
5325  */
5327  /**
5328  * A colon (':').
5329  */
5331  /**
5332  * A semicolon (';').
5333  */
5335  /**
5336  * An '=' sign.
5337  */
5339  /**
5340  * Horizontal space (' ').
5341  */
5343  /**
5344  * Vertical space ('\\n'), after which it is generally a good idea to
5345  * perform indentation.
5346  */
5348 };
5349 
5350 /**
5351  * Determine the kind of a particular chunk within a completion string.
5352  *
5353  * \param completion_string the completion string to query.
5354  *
5355  * \param chunk_number the 0-based index of the chunk in the completion string.
5356  *
5357  * \returns the kind of the chunk at the index \c chunk_number.
5358  */
5361  unsigned chunk_number);
5362 
5363 /**
5364  * Retrieve the text associated with a particular chunk within a
5365  * completion string.
5366  *
5367  * \param completion_string the completion string to query.
5368  *
5369  * \param chunk_number the 0-based index of the chunk in the completion string.
5370  *
5371  * \returns the text associated with the chunk at index \c chunk_number.
5372  */
5374  CXCompletionString completion_string, unsigned chunk_number);
5375 
5376 /**
5377  * Retrieve the completion string associated with a particular chunk
5378  * within a completion string.
5379  *
5380  * \param completion_string the completion string to query.
5381  *
5382  * \param chunk_number the 0-based index of the chunk in the completion string.
5383  *
5384  * \returns the completion string associated with the chunk at index
5385  * \c chunk_number.
5386  */
5388  CXCompletionString completion_string, unsigned chunk_number);
5389 
5390 /**
5391  * Retrieve the number of chunks in the given code-completion string.
5392  */
5393 CINDEX_LINKAGE unsigned
5395 
5396 /**
5397  * Determine the priority of this code completion.
5398  *
5399  * The priority of a code completion indicates how likely it is that this
5400  * particular completion is the completion that the user will select. The
5401  * priority is selected by various internal heuristics.
5402  *
5403  * \param completion_string The completion string to query.
5404  *
5405  * \returns The priority of this completion string. Smaller values indicate
5406  * higher-priority (more likely) completions.
5407  */
5408 CINDEX_LINKAGE unsigned
5410 
5411 /**
5412  * Determine the availability of the entity that this code-completion
5413  * string refers to.
5414  *
5415  * \param completion_string The completion string to query.
5416  *
5417  * \returns The availability of the completion string.
5418  */
5421 
5422 /**
5423  * Retrieve the number of annotations associated with the given
5424  * completion string.
5425  *
5426  * \param completion_string the completion string to query.
5427  *
5428  * \returns the number of annotations associated with the given completion
5429  * string.
5430  */
5431 CINDEX_LINKAGE unsigned
5433 
5434 /**
5435  * Retrieve the annotation associated with the given completion string.
5436  *
5437  * \param completion_string the completion string to query.
5438  *
5439  * \param annotation_number the 0-based index of the annotation of the
5440  * completion string.
5441  *
5442  * \returns annotation string associated with the completion at index
5443  * \c annotation_number, or a NULL string if that annotation is not available.
5444  */
5446  CXCompletionString completion_string, unsigned annotation_number);
5447 
5448 /**
5449  * Retrieve the parent context of the given completion string.
5450  *
5451  * The parent context of a completion string is the semantic parent of
5452  * the declaration (if any) that the code completion represents. For example,
5453  * a code completion for an Objective-C method would have the method's class
5454  * or protocol as its context.
5455  *
5456  * \param completion_string The code completion string whose parent is
5457  * being queried.
5458  *
5459  * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5460  *
5461  * \returns The name of the completion parent, e.g., "NSObject" if
5462  * the completion string represents a method in the NSObject class.
5463  */
5465  CXCompletionString completion_string, enum CXCursorKind *kind);
5466 
5467 /**
5468  * Retrieve the brief documentation comment attached to the declaration
5469  * that corresponds to the given completion string.
5470  */
5473 
5474 /**
5475  * Retrieve a completion string for an arbitrary declaration or macro
5476  * definition cursor.
5477  *
5478  * \param cursor The cursor to query.
5479  *
5480  * \returns A non-context-sensitive completion string for declaration and macro
5481  * definition cursors, or NULL for other kinds of cursors.
5482  */
5485 
5486 /**
5487  * Contains the results of code-completion.
5488  *
5489  * This data structure contains the results of code completion, as
5490  * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5491  * \c clang_disposeCodeCompleteResults.
5492  */
5493 typedef struct {
5494  /**
5495  * The code-completion results.
5496  */
5498 
5499  /**
5500  * The number of code-completion results stored in the
5501  * \c Results array.
5502  */
5503  unsigned NumResults;
5505 
5506 /**
5507  * Retrieve the number of fix-its for the given completion index.
5508  *
5509  * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5510  * option was set.
5511  *
5512  * \param results The structure keeping all completion results
5513  *
5514  * \param completion_index The index of the completion
5515  *
5516  * \return The number of fix-its which must be applied before the completion at
5517  * completion_index can be applied
5518  */
5519 CINDEX_LINKAGE unsigned
5521  unsigned completion_index);
5522 
5523 /**
5524  * Fix-its that *must* be applied before inserting the text for the
5525  * corresponding completion.
5526  *
5527  * By default, clang_codeCompleteAt() only returns completions with empty
5528  * fix-its. Extra completions with non-empty fix-its should be explicitly
5529  * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5530  *
5531  * For the clients to be able to compute position of the cursor after applying
5532  * fix-its, the following conditions are guaranteed to hold for
5533  * replacement_range of the stored fix-its:
5534  * - Ranges in the fix-its are guaranteed to never contain the completion
5535  * point (or identifier under completion point, if any) inside them, except
5536  * at the start or at the end of the range.
5537  * - If a fix-it range starts or ends with completion point (or starts or
5538  * ends after the identifier under completion point), it will contain at
5539  * least one character. It allows to unambiguously recompute completion
5540  * point after applying the fix-it.
5541  *
5542  * The intuition is that provided fix-its change code around the identifier we
5543  * complete, but are not allowed to touch the identifier itself or the
5544  * completion point. One example of completions with corrections are the ones
5545  * replacing '.' with '->' and vice versa:
5546  *
5547  * std::unique_ptr<std::vector<int>> vec_ptr;
5548  * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5549  * replacing '.' with '->'.
5550  * In 'vec_ptr->^', one of the completions is 'release', it requires
5551  * replacing '->' with '.'.
5552  *
5553  * \param results The structure keeping all completion results
5554  *
5555  * \param completion_index The index of the completion
5556  *
5557  * \param fixit_index The index of the fix-it for the completion at
5558  * completion_index
5559  *
5560  * \param replacement_range The fix-it range that must be replaced before the
5561  * completion at completion_index can be applied
5562  *
5563  * \returns The fix-it string that must replace the code at replacement_range
5564  * before the completion at completion_index can be applied
5565  */
5567  CXCodeCompleteResults *results, unsigned completion_index,
5568  unsigned fixit_index, CXSourceRange *replacement_range);
5569 
5570 /**
5571  * Flags that can be passed to \c clang_codeCompleteAt() to
5572  * modify its behavior.
5573  *
5574  * The enumerators in this enumeration can be bitwise-OR'd together to
5575  * provide multiple options to \c clang_codeCompleteAt().
5576  */
5578  /**
5579  * Whether to include macros within the set of code
5580  * completions returned.