clang  5.0.0svn
Index.h
Go to the documentation of this file.
1 /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2 |* *|
3 |* The LLVM Compiler Infrastructure *|
4 |* *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* This header provides a public inferface 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/Platform.h"
22 #include "clang-c/CXErrorCode.h"
23 #include "clang-c/CXString.h"
24 #include "clang-c/BuildSystem.h"
25 
26 /**
27  * \brief The version constants for the libclang API.
28  * CINDEX_VERSION_MINOR should increase when there are API additions.
29  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
30  *
31  * The policy about the libclang API was always to keep it source and ABI
32  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
33  */
34 #define CINDEX_VERSION_MAJOR 0
35 #define CINDEX_VERSION_MINOR 40
36 
37 #define CINDEX_VERSION_ENCODE(major, minor) ( \
38  ((major) * 10000) \
39  + ((minor) * 1))
40 
41 #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
42  CINDEX_VERSION_MAJOR, \
43  CINDEX_VERSION_MINOR )
44 
45 #define CINDEX_VERSION_STRINGIZE_(major, minor) \
46  #major"."#minor
47 #define CINDEX_VERSION_STRINGIZE(major, minor) \
48  CINDEX_VERSION_STRINGIZE_(major, minor)
49 
50 #define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
51  CINDEX_VERSION_MAJOR, \
52  CINDEX_VERSION_MINOR)
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 /** \defgroup CINDEX libclang: C Interface to Clang
59  *
60  * The C Interface to Clang provides a relatively small API that exposes
61  * facilities for parsing source code into an abstract syntax tree (AST),
62  * loading already-parsed ASTs, traversing the AST, associating
63  * physical source locations with elements within the AST, and other
64  * facilities that support Clang-based development tools.
65  *
66  * This C interface to Clang will never provide all of the information
67  * representation stored in Clang's C++ AST, nor should it: the intent is to
68  * maintain an API that is relatively stable from one release to the next,
69  * providing only the basic functionality needed to support development tools.
70  *
71  * To avoid namespace pollution, data types are prefixed with "CX" and
72  * functions are prefixed with "clang_".
73  *
74  * @{
75  */
76 
77 /**
78  * \brief An "index" that consists of a set of translation units that would
79  * typically be linked together into an executable or library.
80  */
81 typedef void *CXIndex;
82 
83 /**
84  * \brief An opaque type representing target information for a given translation
85  * unit.
86  */
87 typedef struct CXTargetInfoImpl *CXTargetInfo;
88 
89 /**
90  * \brief A single translation unit, which resides in an index.
91  */
92 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
93 
94 /**
95  * \brief Opaque pointer representing client data that will be passed through
96  * to various callbacks and visitors.
97  */
98 typedef void *CXClientData;
99 
100 /**
101  * \brief Provides the contents of a file that has not yet been saved to disk.
102  *
103  * Each CXUnsavedFile instance provides the name of a file on the
104  * system along with the current contents of that file that have not
105  * yet been saved to disk.
106  */
108  /**
109  * \brief The file whose contents have not yet been saved.
110  *
111  * This file must already exist in the file system.
112  */
113  const char *Filename;
114 
115  /**
116  * \brief A buffer containing the unsaved contents of this file.
117  */
118  const char *Contents;
119 
120  /**
121  * \brief The length of the unsaved contents of this buffer.
122  */
123  unsigned long Length;
124 };
125 
126 /**
127  * \brief Describes the availability of a particular entity, which indicates
128  * whether the use of this entity will result in a warning or error due to
129  * it being deprecated or unavailable.
130  */
132  /**
133  * \brief The entity is available.
134  */
136  /**
137  * \brief The entity is available, but has been deprecated (and its use is
138  * not recommended).
139  */
141  /**
142  * \brief The entity is not available; any use of it will be an error.
143  */
145  /**
146  * \brief The entity is available, but not accessible; any use of it will be
147  * an error.
148  */
150 };
151 
152 /**
153  * \brief Describes a version number of the form major.minor.subminor.
154  */
155 typedef struct CXVersion {
156  /**
157  * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
158  * value indicates that there is no version number at all.
159  */
160  int Major;
161  /**
162  * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
163  * will be negative if no minor version number was provided, e.g., for
164  * version '10'.
165  */
166  int Minor;
167  /**
168  * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
169  * will be negative if no minor or subminor version number was provided,
170  * e.g., in version '10' or '10.7'.
171  */
172  int Subminor;
173 } CXVersion;
174 
175 /**
176  * \brief Provides a shared context for creating translation units.
177  *
178  * It provides two options:
179  *
180  * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
181  * declarations (when loading any new translation units). A "local" declaration
182  * is one that belongs in the translation unit itself and not in a precompiled
183  * header that was used by the translation unit. If zero, all declarations
184  * will be enumerated.
185  *
186  * Here is an example:
187  *
188  * \code
189  * // excludeDeclsFromPCH = 1, displayDiagnostics=1
190  * Idx = clang_createIndex(1, 1);
191  *
192  * // IndexTest.pch was produced with the following command:
193  * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
194  * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
195  *
196  * // This will load all the symbols from 'IndexTest.pch'
197  * clang_visitChildren(clang_getTranslationUnitCursor(TU),
198  * TranslationUnitVisitor, 0);
199  * clang_disposeTranslationUnit(TU);
200  *
201  * // This will load all the symbols from 'IndexTest.c', excluding symbols
202  * // from 'IndexTest.pch'.
203  * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
204  * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
205  * 0, 0);
206  * clang_visitChildren(clang_getTranslationUnitCursor(TU),
207  * TranslationUnitVisitor, 0);
208  * clang_disposeTranslationUnit(TU);
209  * \endcode
210  *
211  * This process of creating the 'pch', loading it separately, and using it (via
212  * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
213  * (which gives the indexer the same performance benefit as the compiler).
214  */
215 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
216  int displayDiagnostics);
217 
218 /**
219  * \brief Destroy the given index.
220  *
221  * The index must not be destroyed until all of the translation units created
222  * within that index have been destroyed.
223  */
224 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
225 
226 typedef enum {
227  /**
228  * \brief Used to indicate that no special CXIndex options are needed.
229  */
231 
232  /**
233  * \brief Used to indicate that threads that libclang creates for indexing
234  * purposes should use background priority.
235  *
236  * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
237  * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
238  */
240 
241  /**
242  * \brief Used to indicate that threads that libclang creates for editing
243  * purposes should use background priority.
244  *
245  * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
246  * #clang_annotateTokens
247  */
249 
250  /**
251  * \brief Used to indicate that all threads that libclang creates should use
252  * background priority.
253  */
257 
259 
260 /**
261  * \brief Sets general options associated with a CXIndex.
262  *
263  * For example:
264  * \code
265  * CXIndex idx = ...;
266  * clang_CXIndex_setGlobalOptions(idx,
267  * clang_CXIndex_getGlobalOptions(idx) |
268  * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
269  * \endcode
270  *
271  * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
272  */
273 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
274 
275 /**
276  * \brief Gets the general options associated with a CXIndex.
277  *
278  * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
279  * are associated with the given CXIndex object.
280  */
282 
283 /**
284  * \defgroup CINDEX_FILES File manipulation routines
285  *
286  * @{
287  */
288 
289 /**
290  * \brief A particular source file that is part of a translation unit.
291  */
292 typedef void *CXFile;
293 
294 /**
295  * \brief Retrieve the complete file and path name of the given file.
296  */
298 
299 /**
300  * \brief Retrieve the last modification time of the given file.
301  */
302 CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
303 
304 /**
305  * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
306  * across an indexing session.
307  */
308 typedef struct {
309  unsigned long long data[3];
311 
312 /**
313  * \brief Retrieve the unique ID for the given \c file.
314  *
315  * \param file the file to get the ID for.
316  * \param outID stores the returned CXFileUniqueID.
317  * \returns If there was a failure getting the unique ID, returns non-zero,
318  * otherwise returns 0.
319 */
320 CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
321 
322 /**
323  * \brief Determine whether the given header is guarded against
324  * multiple inclusions, either with the conventional
325  * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
326  */
327 CINDEX_LINKAGE unsigned
328 clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
329 
330 /**
331  * \brief Retrieve a file handle within the given translation unit.
332  *
333  * \param tu the translation unit
334  *
335  * \param file_name the name of the file.
336  *
337  * \returns the file handle for the named file in the translation unit \p tu,
338  * or a NULL file handle if the file was not a part of this translation unit.
339  */
340 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
341  const char *file_name);
342 
343 /**
344  * \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
345  * or they are both NULL.
346  */
347 CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
348 
349 /**
350  * @}
351  */
352 
353 /**
354  * \defgroup CINDEX_LOCATIONS Physical source locations
355  *
356  * Clang represents physical source locations in its abstract syntax tree in
357  * great detail, with file, line, and column information for the majority of
358  * the tokens parsed in the source code. These data types and functions are
359  * used to represent source location information, either for a particular
360  * point in the program or for a range of points in the program, and extract
361  * specific location information from those data types.
362  *
363  * @{
364  */
365 
366 /**
367  * \brief Identifies a specific source location within a translation
368  * unit.
369  *
370  * Use clang_getExpansionLocation() or clang_getSpellingLocation()
371  * to map a source location to a particular file, line, and column.
372  */
373 typedef struct {
374  const void *ptr_data[2];
375  unsigned int_data;
377 
378 /**
379  * \brief Identifies a half-open character range in the source code.
380  *
381  * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
382  * starting and end locations from a source range, respectively.
383  */
384 typedef struct {
385  const void *ptr_data[2];
386  unsigned begin_int_data;
387  unsigned end_int_data;
388 } CXSourceRange;
389 
390 /**
391  * \brief Retrieve a NULL (invalid) source location.
392  */
394 
395 /**
396  * \brief Determine whether two source locations, which must refer into
397  * the same translation unit, refer to exactly the same point in the source
398  * code.
399  *
400  * \returns non-zero if the source locations refer to the same location, zero
401  * if they refer to different locations.
402  */
404  CXSourceLocation loc2);
405 
406 /**
407  * \brief Retrieves the source location associated with a given file/line/column
408  * in a particular translation unit.
409  */
411  CXFile file,
412  unsigned line,
413  unsigned column);
414 /**
415  * \brief Retrieves the source location associated with a given character offset
416  * in a particular translation unit.
417  */
419  CXFile file,
420  unsigned offset);
421 
422 /**
423  * \brief Returns non-zero if the given source location is in a system header.
424  */
426 
427 /**
428  * \brief Returns non-zero if the given source location is in the main file of
429  * the corresponding translation unit.
430  */
432 
433 /**
434  * \brief Retrieve a NULL (invalid) source range.
435  */
437 
438 /**
439  * \brief Retrieve a source range given the beginning and ending source
440  * locations.
441  */
443  CXSourceLocation end);
444 
445 /**
446  * \brief Determine whether two ranges are equivalent.
447  *
448  * \returns non-zero if the ranges are the same, zero if they differ.
449  */
451  CXSourceRange range2);
452 
453 /**
454  * \brief Returns non-zero if \p range is null.
455  */
457 
458 /**
459  * \brief Retrieve the file, line, column, and offset represented by
460  * the given source location.
461  *
462  * If the location refers into a macro expansion, retrieves the
463  * location of the macro expansion.
464  *
465  * \param location the location within a source file that will be decomposed
466  * into its parts.
467  *
468  * \param file [out] if non-NULL, will be set to the file to which the given
469  * source location points.
470  *
471  * \param line [out] if non-NULL, will be set to the line to which the given
472  * source location points.
473  *
474  * \param column [out] if non-NULL, will be set to the column to which the given
475  * source location points.
476  *
477  * \param offset [out] if non-NULL, will be set to the offset into the
478  * buffer to which the given source location points.
479  */
481  CXFile *file,
482  unsigned *line,
483  unsigned *column,
484  unsigned *offset);
485 
486 /**
487  * \brief Retrieve the file, line and column represented by the given source
488  * location, as specified in a # line directive.
489  *
490  * Example: given the following source code in a file somefile.c
491  *
492  * \code
493  * #123 "dummy.c" 1
494  *
495  * static int func(void)
496  * {
497  * return 0;
498  * }
499  * \endcode
500  *
501  * the location information returned by this function would be
502  *
503  * File: dummy.c Line: 124 Column: 12
504  *
505  * whereas clang_getExpansionLocation would have returned
506  *
507  * File: somefile.c Line: 3 Column: 12
508  *
509  * \param location the location within a source file that will be decomposed
510  * into its parts.
511  *
512  * \param filename [out] if non-NULL, will be set to the filename of the
513  * source location. Note that filenames returned will be for "virtual" files,
514  * which don't necessarily exist on the machine running clang - e.g. when
515  * parsing preprocessed output obtained from a different environment. If
516  * a non-NULL value is passed in, remember to dispose of the returned value
517  * using \c clang_disposeString() once you've finished with it. For an invalid
518  * source location, an empty string is returned.
519  *
520  * \param line [out] if non-NULL, will be set to the line number of the
521  * source location. For an invalid source location, zero is returned.
522  *
523  * \param column [out] if non-NULL, will be set to the column number of the
524  * source location. For an invalid source location, zero is returned.
525  */
527  CXString *filename,
528  unsigned *line,
529  unsigned *column);
530 
531 /**
532  * \brief Legacy API to retrieve the file, line, column, and offset represented
533  * by the given source location.
534  *
535  * This interface has been replaced by the newer interface
536  * #clang_getExpansionLocation(). See that interface's documentation for
537  * details.
538  */
540  CXFile *file,
541  unsigned *line,
542  unsigned *column,
543  unsigned *offset);
544 
545 /**
546  * \brief Retrieve the file, line, column, and offset represented by
547  * the given source location.
548  *
549  * If the location refers into a macro instantiation, return where the
550  * location was originally spelled in the source file.
551  *
552  * \param location the location within a source file that will be decomposed
553  * into its parts.
554  *
555  * \param file [out] if non-NULL, will be set to the file to which the given
556  * source location points.
557  *
558  * \param line [out] if non-NULL, will be set to the line to which the given
559  * source location points.
560  *
561  * \param column [out] if non-NULL, will be set to the column to which the given
562  * source location points.
563  *
564  * \param offset [out] if non-NULL, will be set to the offset into the
565  * buffer to which the given source location points.
566  */
568  CXFile *file,
569  unsigned *line,
570  unsigned *column,
571  unsigned *offset);
572 
573 /**
574  * \brief Retrieve the file, line, column, and offset represented by
575  * the given source location.
576  *
577  * If the location refers into a macro expansion, return where the macro was
578  * expanded or where the macro argument was written, if the location points at
579  * a macro argument.
580  *
581  * \param location the location within a source file that will be decomposed
582  * into its parts.
583  *
584  * \param file [out] if non-NULL, will be set to the file to which the given
585  * source location points.
586  *
587  * \param line [out] if non-NULL, will be set to the line to which the given
588  * source location points.
589  *
590  * \param column [out] if non-NULL, will be set to the column to which the given
591  * source location points.
592  *
593  * \param offset [out] if non-NULL, will be set to the offset into the
594  * buffer to which the given source location points.
595  */
597  CXFile *file,
598  unsigned *line,
599  unsigned *column,
600  unsigned *offset);
601 
602 /**
603  * \brief Retrieve a source location representing the first character within a
604  * source range.
605  */
607 
608 /**
609  * \brief Retrieve a source location representing the last character within a
610  * source range.
611  */
613 
614 /**
615  * \brief Identifies an array of ranges.
616  */
617 typedef struct {
618  /** \brief The number of ranges in the \c ranges array. */
619  unsigned count;
620  /**
621  * \brief An array of \c CXSourceRanges.
622  */
625 
626 /**
627  * \brief Retrieve all ranges that were skipped by the preprocessor.
628  *
629  * The preprocessor will skip lines when they are surrounded by an
630  * if/ifdef/ifndef directive whose condition does not evaluate to true.
631  */
633  CXFile file);
634 
635 /**
636  * \brief Retrieve all ranges from all files that were skipped by the
637  * preprocessor.
638  *
639  * The preprocessor will skip lines when they are surrounded by an
640  * if/ifdef/ifndef directive whose condition does not evaluate to true.
641  */
643 
644 /**
645  * \brief Destroy the given \c CXSourceRangeList.
646  */
648 
649 /**
650  * @}
651  */
652 
653 /**
654  * \defgroup CINDEX_DIAG Diagnostic reporting
655  *
656  * @{
657  */
658 
659 /**
660  * \brief Describes the severity of a particular diagnostic.
661  */
663  /**
664  * \brief A diagnostic that has been suppressed, e.g., by a command-line
665  * option.
666  */
668 
669  /**
670  * \brief This diagnostic is a note that should be attached to the
671  * previous (non-note) diagnostic.
672  */
674 
675  /**
676  * \brief This diagnostic indicates suspicious code that may not be
677  * wrong.
678  */
680 
681  /**
682  * \brief This diagnostic indicates that the code is ill-formed.
683  */
685 
686  /**
687  * \brief This diagnostic indicates that the code is ill-formed such
688  * that future parser recovery is unlikely to produce useful
689  * results.
690  */
692 };
693 
694 /**
695  * \brief A single diagnostic, containing the diagnostic's severity,
696  * location, text, source ranges, and fix-it hints.
697  */
698 typedef void *CXDiagnostic;
699 
700 /**
701  * \brief A group of CXDiagnostics.
702  */
703 typedef void *CXDiagnosticSet;
704 
705 /**
706  * \brief Determine the number of diagnostics in a CXDiagnosticSet.
707  */
708 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
709 
710 /**
711  * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
712  *
713  * \param Diags the CXDiagnosticSet to query.
714  * \param Index the zero-based diagnostic number to retrieve.
715  *
716  * \returns the requested diagnostic. This diagnostic must be freed
717  * via a call to \c clang_disposeDiagnostic().
718  */
719 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
720  unsigned Index);
721 
722 /**
723  * \brief Describes the kind of error that occurred (if any) in a call to
724  * \c clang_loadDiagnostics.
725  */
727  /**
728  * \brief Indicates that no error occurred.
729  */
731 
732  /**
733  * \brief Indicates that an unknown error occurred while attempting to
734  * deserialize diagnostics.
735  */
737 
738  /**
739  * \brief Indicates that the file containing the serialized diagnostics
740  * could not be opened.
741  */
743 
744  /**
745  * \brief Indicates that the serialized diagnostics file is invalid or
746  * corrupt.
747  */
749 };
750 
751 /**
752  * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
753  * file.
754  *
755  * \param file The name of the file to deserialize.
756  * \param error A pointer to a enum value recording if there was a problem
757  * deserializing the diagnostics.
758  * \param errorString A pointer to a CXString for recording the error string
759  * if the file was not successfully loaded.
760  *
761  * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
762  * diagnostics should be released using clang_disposeDiagnosticSet().
763  */
764 CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
765  enum CXLoadDiag_Error *error,
766  CXString *errorString);
767 
768 /**
769  * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
770  */
771 CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
772 
773 /**
774  * \brief Retrieve the child diagnostics of a CXDiagnostic.
775  *
776  * This CXDiagnosticSet does not need to be released by
777  * clang_disposeDiagnosticSet.
778  */
779 CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
780 
781 /**
782  * \brief Determine the number of diagnostics produced for the given
783  * translation unit.
784  */
785 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
786 
787 /**
788  * \brief Retrieve a diagnostic associated with the given translation unit.
789  *
790  * \param Unit the translation unit 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  */
796 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
797  unsigned Index);
798 
799 /**
800  * \brief Retrieve the complete set of diagnostics associated with a
801  * translation unit.
802  *
803  * \param Unit the translation unit to query.
804  */
805 CINDEX_LINKAGE CXDiagnosticSet
806  clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
807 
808 /**
809  * \brief Destroy a diagnostic.
810  */
811 CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
812 
813 /**
814  * \brief Options to control the display of diagnostics.
815  *
816  * The values in this enum are meant to be combined to customize the
817  * behavior of \c clang_formatDiagnostic().
818  */
820  /**
821  * \brief Display the source-location information where the
822  * diagnostic was located.
823  *
824  * When set, diagnostics will be prefixed by the file, line, and
825  * (optionally) column to which the diagnostic refers. For example,
826  *
827  * \code
828  * test.c:28: warning: extra tokens at end of #endif directive
829  * \endcode
830  *
831  * This option corresponds to the clang flag \c -fshow-source-location.
832  */
834 
835  /**
836  * \brief If displaying the source-location information of the
837  * diagnostic, also include the column number.
838  *
839  * This option corresponds to the clang flag \c -fshow-column.
840  */
842 
843  /**
844  * \brief If displaying the source-location information of the
845  * diagnostic, also include information about source ranges in a
846  * machine-parsable format.
847  *
848  * This option corresponds to the clang flag
849  * \c -fdiagnostics-print-source-range-info.
850  */
852 
853  /**
854  * \brief Display the option name associated with this diagnostic, if any.
855  *
856  * The option name displayed (e.g., -Wconversion) will be placed in brackets
857  * after the diagnostic text. This option corresponds to the clang flag
858  * \c -fdiagnostics-show-option.
859  */
861 
862  /**
863  * \brief Display the category number associated with this diagnostic, if any.
864  *
865  * The category number is displayed within brackets after the diagnostic text.
866  * This option corresponds to the clang flag
867  * \c -fdiagnostics-show-category=id.
868  */
870 
871  /**
872  * \brief Display the category name associated with this diagnostic, if any.
873  *
874  * The category name is displayed within brackets after the diagnostic text.
875  * This option corresponds to the clang flag
876  * \c -fdiagnostics-show-category=name.
877  */
879 };
880 
881 /**
882  * \brief Format the given diagnostic in a manner that is suitable for display.
883  *
884  * This routine will format the given diagnostic to a string, rendering
885  * the diagnostic according to the various options given. The
886  * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
887  * options that most closely mimics the behavior of the clang compiler.
888  *
889  * \param Diagnostic The diagnostic to print.
890  *
891  * \param Options A set of options that control the diagnostic display,
892  * created by combining \c CXDiagnosticDisplayOptions values.
893  *
894  * \returns A new string containing for formatted diagnostic.
895  */
896 CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
897  unsigned Options);
898 
899 /**
900  * \brief Retrieve the set of display options most similar to the
901  * default behavior of the clang compiler.
902  *
903  * \returns A set of display options suitable for use with \c
904  * clang_formatDiagnostic().
905  */
907 
908 /**
909  * \brief Determine the severity of the given diagnostic.
910  */
912 clang_getDiagnosticSeverity(CXDiagnostic);
913 
914 /**
915  * \brief Retrieve the source location of the given diagnostic.
916  *
917  * This location is where Clang would print the caret ('^') when
918  * displaying the diagnostic on the command line.
919  */
921 
922 /**
923  * \brief Retrieve the text of the given diagnostic.
924  */
926 
927 /**
928  * \brief Retrieve the name of the command-line option that enabled this
929  * diagnostic.
930  *
931  * \param Diag The diagnostic to be queried.
932  *
933  * \param Disable If non-NULL, will be set to the option that disables this
934  * diagnostic (if any).
935  *
936  * \returns A string that contains the command-line option used to enable this
937  * warning, such as "-Wconversion" or "-pedantic".
938  */
940  CXString *Disable);
941 
942 /**
943  * \brief Retrieve the category number for this diagnostic.
944  *
945  * Diagnostics can be categorized into groups along with other, related
946  * diagnostics (e.g., diagnostics under the same warning flag). This routine
947  * retrieves the category number for the given diagnostic.
948  *
949  * \returns The number of the category that contains this diagnostic, or zero
950  * if this diagnostic is uncategorized.
951  */
952 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
953 
954 /**
955  * \brief Retrieve the name of a particular diagnostic category. This
956  * is now deprecated. Use clang_getDiagnosticCategoryText()
957  * instead.
958  *
959  * \param Category A diagnostic category number, as returned by
960  * \c clang_getDiagnosticCategory().
961  *
962  * \returns The name of the given diagnostic category.
963  */
966 
967 /**
968  * \brief Retrieve the diagnostic category text for a given diagnostic.
969  *
970  * \returns The text of the given diagnostic category.
971  */
973 
974 /**
975  * \brief Determine the number of source ranges associated with the given
976  * diagnostic.
977  */
978 CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
979 
980 /**
981  * \brief Retrieve a source range associated with the diagnostic.
982  *
983  * A diagnostic's source ranges highlight important elements in the source
984  * code. On the command line, Clang displays source ranges by
985  * underlining them with '~' characters.
986  *
987  * \param Diagnostic the diagnostic whose range is being extracted.
988  *
989  * \param Range the zero-based index specifying which range to
990  *
991  * \returns the requested source range.
992  */
994  unsigned Range);
995 
996 /**
997  * \brief Determine the number of fix-it hints associated with the
998  * given diagnostic.
999  */
1000 CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1001 
1002 /**
1003  * \brief Retrieve the replacement information for a given fix-it.
1004  *
1005  * Fix-its are described in terms of a source range whose contents
1006  * should be replaced by a string. This approach generalizes over
1007  * three kinds of operations: removal of source code (the range covers
1008  * the code to be removed and the replacement string is empty),
1009  * replacement of source code (the range covers the code to be
1010  * replaced and the replacement string provides the new code), and
1011  * insertion (both the start and end of the range point at the
1012  * insertion location, and the replacement string provides the text to
1013  * insert).
1014  *
1015  * \param Diagnostic The diagnostic whose fix-its are being queried.
1016  *
1017  * \param FixIt The zero-based index of the fix-it.
1018  *
1019  * \param ReplacementRange The source range whose contents will be
1020  * replaced with the returned replacement string. Note that source
1021  * ranges are half-open ranges [a, b), so the source code should be
1022  * replaced from a and up to (but not including) b.
1023  *
1024  * \returns A string containing text that should be replace the source
1025  * code indicated by the \c ReplacementRange.
1026  */
1027 CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
1028  unsigned FixIt,
1029  CXSourceRange *ReplacementRange);
1030 
1031 /**
1032  * @}
1033  */
1034 
1035 /**
1036  * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1037  *
1038  * The routines in this group provide the ability to create and destroy
1039  * translation units from files, either by parsing the contents of the files or
1040  * by reading in a serialized representation of a translation unit.
1041  *
1042  * @{
1043  */
1044 
1045 /**
1046  * \brief Get the original translation unit source file name.
1047  */
1049 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1050 
1051 /**
1052  * \brief Return the CXTranslationUnit for a given source file and the provided
1053  * command line arguments one would pass to the compiler.
1054  *
1055  * Note: The 'source_filename' argument is optional. If the caller provides a
1056  * NULL pointer, the name of the source file is expected to reside in the
1057  * specified command line arguments.
1058  *
1059  * Note: When encountered in 'clang_command_line_args', the following options
1060  * are ignored:
1061  *
1062  * '-c'
1063  * '-emit-ast'
1064  * '-fsyntax-only'
1065  * '-o <output file>' (both '-o' and '<output file>' are ignored)
1066  *
1067  * \param CIdx The index object with which the translation unit will be
1068  * associated.
1069  *
1070  * \param source_filename The name of the source file to load, or NULL if the
1071  * source file is included in \p clang_command_line_args.
1072  *
1073  * \param num_clang_command_line_args The number of command-line arguments in
1074  * \p clang_command_line_args.
1075  *
1076  * \param clang_command_line_args The command-line arguments that would be
1077  * passed to the \c clang executable if it were being invoked out-of-process.
1078  * These command-line options will be parsed and will affect how the translation
1079  * unit is parsed. Note that the following options are ignored: '-c',
1080  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
1081  *
1082  * \param num_unsaved_files the number of unsaved file entries in \p
1083  * unsaved_files.
1084  *
1085  * \param unsaved_files the files that have not yet been saved to disk
1086  * but may be required for code completion, including the contents of
1087  * those files. The contents and name of these files (as specified by
1088  * CXUnsavedFile) are copied when necessary, so the client only needs to
1089  * guarantee their validity until the call to this function returns.
1090  */
1092  CXIndex CIdx,
1093  const char *source_filename,
1094  int num_clang_command_line_args,
1095  const char * const *clang_command_line_args,
1096  unsigned num_unsaved_files,
1097  struct CXUnsavedFile *unsaved_files);
1098 
1099 /**
1100  * \brief Same as \c clang_createTranslationUnit2, but returns
1101  * the \c CXTranslationUnit instead of an error code. In case of an error this
1102  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1103  * error codes.
1104  */
1106  CXIndex CIdx,
1107  const char *ast_filename);
1108 
1109 /**
1110  * \brief Create a translation unit from an AST file (\c -emit-ast).
1111  *
1112  * \param[out] out_TU A non-NULL pointer to store the created
1113  * \c CXTranslationUnit.
1114  *
1115  * \returns Zero on success, otherwise returns an error code.
1116  */
1118  CXIndex CIdx,
1119  const char *ast_filename,
1120  CXTranslationUnit *out_TU);
1121 
1122 /**
1123  * \brief Flags that control the creation of translation units.
1124  *
1125  * The enumerators in this enumeration type are meant to be bitwise
1126  * ORed together to specify which options should be used when
1127  * constructing the translation unit.
1128  */
1130  /**
1131  * \brief Used to indicate that no special translation-unit options are
1132  * needed.
1133  */
1135 
1136  /**
1137  * \brief Used to indicate that the parser should construct a "detailed"
1138  * preprocessing record, including all macro definitions and instantiations.
1139  *
1140  * Constructing a detailed preprocessing record requires more memory
1141  * and time to parse, since the information contained in the record
1142  * is usually not retained. However, it can be useful for
1143  * applications that require more detailed information about the
1144  * behavior of the preprocessor.
1145  */
1147 
1148  /**
1149  * \brief Used to indicate that the translation unit is incomplete.
1150  *
1151  * When a translation unit is considered "incomplete", semantic
1152  * analysis that is typically performed at the end of the
1153  * translation unit will be suppressed. For example, this suppresses
1154  * the completion of tentative declarations in C and of
1155  * instantiation of implicitly-instantiation function templates in
1156  * C++. This option is typically used when parsing a header with the
1157  * intent of producing a precompiled header.
1158  */
1160 
1161  /**
1162  * \brief Used to indicate that the translation unit should be built with an
1163  * implicit precompiled header for the preamble.
1164  *
1165  * An implicit precompiled header is used as an optimization when a
1166  * particular translation unit is likely to be reparsed many times
1167  * when the sources aren't changing that often. In this case, an
1168  * implicit precompiled header will be built containing all of the
1169  * initial includes at the top of the main file (what we refer to as
1170  * the "preamble" of the file). In subsequent parses, if the
1171  * preamble or the files in it have not changed, \c
1172  * clang_reparseTranslationUnit() will re-use the implicit
1173  * precompiled header to improve parsing performance.
1174  */
1176 
1177  /**
1178  * \brief Used to indicate that the translation unit should cache some
1179  * code-completion results with each reparse of the source file.
1180  *
1181  * Caching of code-completion results is a performance optimization that
1182  * introduces some overhead to reparsing but improves the performance of
1183  * code-completion operations.
1184  */
1186 
1187  /**
1188  * \brief Used to indicate that the translation unit will be serialized with
1189  * \c clang_saveTranslationUnit.
1190  *
1191  * This option is typically used when parsing a header with the intent of
1192  * producing a precompiled header.
1193  */
1195 
1196  /**
1197  * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
1198  *
1199  * Note: this is a *temporary* option that is available only while
1200  * we are testing C++ precompiled preamble support. It is deprecated.
1201  */
1203 
1204  /**
1205  * \brief Used to indicate that function/method bodies should be skipped while
1206  * parsing.
1207  *
1208  * This option can be used to search for declarations/definitions while
1209  * ignoring the usages.
1210  */
1212 
1213  /**
1214  * \brief Used to indicate that brief documentation comments should be
1215  * included into the set of code completions returned from this translation
1216  * unit.
1217  */
1219 
1220  /**
1221  * \brief Used to indicate that the precompiled preamble should be created on
1222  * the first parse. Otherwise it will be created on the first reparse. This
1223  * trades runtime on the first parse (serializing the preamble takes time) for
1224  * reduced runtime on the second parse (can now reuse the preamble).
1225  */
1227 
1228  /**
1229  * \brief Do not stop processing when fatal errors are encountered.
1230  *
1231  * When fatal errors are encountered while parsing a translation unit,
1232  * semantic analysis is typically stopped early when compiling code. A common
1233  * source for fatal errors are unresolvable include files. For the
1234  * purposes of an IDE, this is undesirable behavior and as much information
1235  * as possible should be reported. Use this flag to enable this behavior.
1236  */
1238 };
1239 
1240 /**
1241  * \brief Returns the set of flags that is suitable for parsing a translation
1242  * unit that is being edited.
1243  *
1244  * The set of flags returned provide options for \c clang_parseTranslationUnit()
1245  * to indicate that the translation unit is likely to be reparsed many times,
1246  * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1247  * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1248  * set contains an unspecified set of optimizations (e.g., the precompiled
1249  * preamble) geared toward improving the performance of these routines. The
1250  * set of optimizations enabled may change from one version to the next.
1251  */
1253 
1254 /**
1255  * \brief Same as \c clang_parseTranslationUnit2, but returns
1256  * the \c CXTranslationUnit instead of an error code. In case of an error this
1257  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1258  * error codes.
1259  */
1260 CINDEX_LINKAGE CXTranslationUnit
1261 clang_parseTranslationUnit(CXIndex CIdx,
1262  const char *source_filename,
1263  const char *const *command_line_args,
1264  int num_command_line_args,
1265  struct CXUnsavedFile *unsaved_files,
1266  unsigned num_unsaved_files,
1267  unsigned options);
1268 
1269 /**
1270  * \brief Parse the given source file and the translation unit corresponding
1271  * to that file.
1272  *
1273  * This routine is the main entry point for the Clang C API, providing the
1274  * ability to parse a source file into a translation unit that can then be
1275  * queried by other functions in the API. This routine accepts a set of
1276  * command-line arguments so that the compilation can be configured in the same
1277  * way that the compiler is configured on the command line.
1278  *
1279  * \param CIdx The index object with which the translation unit will be
1280  * associated.
1281  *
1282  * \param source_filename The name of the source file to load, or NULL if the
1283  * source file is included in \c command_line_args.
1284  *
1285  * \param command_line_args The command-line arguments that would be
1286  * passed to the \c clang executable if it were being invoked out-of-process.
1287  * These command-line options will be parsed and will affect how the translation
1288  * unit is parsed. Note that the following options are ignored: '-c',
1289  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
1290  *
1291  * \param num_command_line_args The number of command-line arguments in
1292  * \c command_line_args.
1293  *
1294  * \param unsaved_files the files that have not yet been saved to disk
1295  * but may be required for parsing, including the contents of
1296  * those files. The contents and name of these files (as specified by
1297  * CXUnsavedFile) are copied when necessary, so the client only needs to
1298  * guarantee their validity until the call to this function returns.
1299  *
1300  * \param num_unsaved_files the number of unsaved file entries in \p
1301  * unsaved_files.
1302  *
1303  * \param options A bitmask of options that affects how the translation unit
1304  * is managed but not its compilation. This should be a bitwise OR of the
1305  * CXTranslationUnit_XXX flags.
1306  *
1307  * \param[out] out_TU A non-NULL pointer to store the created
1308  * \c CXTranslationUnit, describing the parsed code and containing any
1309  * diagnostics produced by the compiler.
1310  *
1311  * \returns Zero on success, otherwise returns an error code.
1312  */
1314 clang_parseTranslationUnit2(CXIndex CIdx,
1315  const char *source_filename,
1316  const char *const *command_line_args,
1317  int num_command_line_args,
1318  struct CXUnsavedFile *unsaved_files,
1319  unsigned num_unsaved_files,
1320  unsigned options,
1321  CXTranslationUnit *out_TU);
1322 
1323 /**
1324  * \brief Same as clang_parseTranslationUnit2 but requires a full command line
1325  * for \c command_line_args including argv[0]. This is useful if the standard
1326  * library paths are relative to the binary.
1327  */
1329  CXIndex CIdx, const char *source_filename,
1330  const char *const *command_line_args, int num_command_line_args,
1331  struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1332  unsigned options, CXTranslationUnit *out_TU);
1333 
1334 /**
1335  * \brief Flags that control how translation units are saved.
1336  *
1337  * The enumerators in this enumeration type are meant to be bitwise
1338  * ORed together to specify which options should be used when
1339  * saving the translation unit.
1340  */
1342  /**
1343  * \brief Used to indicate that no special saving options are needed.
1344  */
1346 };
1347 
1348 /**
1349  * \brief Returns the set of flags that is suitable for saving a translation
1350  * unit.
1351  *
1352  * The set of flags returned provide options for
1353  * \c clang_saveTranslationUnit() by default. The returned flag
1354  * set contains an unspecified set of options that save translation units with
1355  * the most commonly-requested data.
1356  */
1357 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1358 
1359 /**
1360  * \brief Describes the kind of error that occurred (if any) in a call to
1361  * \c clang_saveTranslationUnit().
1362  */
1364  /**
1365  * \brief Indicates that no error occurred while saving a translation unit.
1366  */
1368 
1369  /**
1370  * \brief Indicates that an unknown error occurred while attempting to save
1371  * the file.
1372  *
1373  * This error typically indicates that file I/O failed when attempting to
1374  * write the file.
1375  */
1377 
1378  /**
1379  * \brief Indicates that errors during translation prevented this attempt
1380  * to save the translation unit.
1381  *
1382  * Errors that prevent the translation unit from being saved can be
1383  * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1384  */
1386 
1387  /**
1388  * \brief Indicates that the translation unit to be saved was somehow
1389  * invalid (e.g., NULL).
1390  */
1392 };
1393 
1394 /**
1395  * \brief Saves a translation unit into a serialized representation of
1396  * that translation unit on disk.
1397  *
1398  * Any translation unit that was parsed without error can be saved
1399  * into a file. The translation unit can then be deserialized into a
1400  * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1401  * if it is an incomplete translation unit that corresponds to a
1402  * header, used as a precompiled header when parsing other translation
1403  * units.
1404  *
1405  * \param TU The translation unit to save.
1406  *
1407  * \param FileName The file to which the translation unit will be saved.
1408  *
1409  * \param options A bitmask of options that affects how the translation unit
1410  * is saved. This should be a bitwise OR of the
1411  * CXSaveTranslationUnit_XXX flags.
1412  *
1413  * \returns A value that will match one of the enumerators of the CXSaveError
1414  * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1415  * saved successfully, while a non-zero value indicates that a problem occurred.
1416  */
1417 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1418  const char *FileName,
1419  unsigned options);
1420 
1421 /**
1422  * \brief Destroy the specified CXTranslationUnit object.
1423  */
1424 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1425 
1426 /**
1427  * \brief Flags that control the reparsing of translation units.
1428  *
1429  * The enumerators in this enumeration type are meant to be bitwise
1430  * ORed together to specify which options should be used when
1431  * reparsing the translation unit.
1432  */
1434  /**
1435  * \brief Used to indicate that no special reparsing options are needed.
1436  */
1438 };
1439 
1440 /**
1441  * \brief Returns the set of flags that is suitable for reparsing a translation
1442  * unit.
1443  *
1444  * The set of flags returned provide options for
1445  * \c clang_reparseTranslationUnit() by default. The returned flag
1446  * set contains an unspecified set of optimizations geared toward common uses
1447  * of reparsing. The set of optimizations enabled may change from one version
1448  * to the next.
1449  */
1450 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1451 
1452 /**
1453  * \brief Reparse the source files that produced this translation unit.
1454  *
1455  * This routine can be used to re-parse the source files that originally
1456  * created the given translation unit, for example because those source files
1457  * have changed (either on disk or as passed via \p unsaved_files). The
1458  * source code will be reparsed with the same command-line options as it
1459  * was originally parsed.
1460  *
1461  * Reparsing a translation unit invalidates all cursors and source locations
1462  * that refer into that translation unit. This makes reparsing a translation
1463  * unit semantically equivalent to destroying the translation unit and then
1464  * creating a new translation unit with the same command-line arguments.
1465  * However, it may be more efficient to reparse a translation
1466  * unit using this routine.
1467  *
1468  * \param TU The translation unit whose contents will be re-parsed. The
1469  * translation unit must originally have been built with
1470  * \c clang_createTranslationUnitFromSourceFile().
1471  *
1472  * \param num_unsaved_files The number of unsaved file entries in \p
1473  * unsaved_files.
1474  *
1475  * \param unsaved_files The files that have not yet been saved to disk
1476  * but may be required for parsing, including the contents of
1477  * those files. The contents and name of these files (as specified by
1478  * CXUnsavedFile) are copied when necessary, so the client only needs to
1479  * guarantee their validity until the call to this function returns.
1480  *
1481  * \param options A bitset of options composed of the flags in CXReparse_Flags.
1482  * The function \c clang_defaultReparseOptions() produces a default set of
1483  * options recommended for most uses, based on the translation unit.
1484  *
1485  * \returns 0 if the sources could be reparsed. A non-zero error code will be
1486  * returned if reparsing was impossible, such that the translation unit is
1487  * invalid. In such cases, the only valid call for \c TU is
1488  * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1489  * routine are described by the \c CXErrorCode enum.
1490  */
1491 CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1492  unsigned num_unsaved_files,
1493  struct CXUnsavedFile *unsaved_files,
1494  unsigned options);
1495 
1496 /**
1497  * \brief Categorizes how memory is being used by a translation unit.
1498  */
1517 
1520 };
1521 
1522 /**
1523  * \brief Returns the human-readable null-terminated C string that represents
1524  * the name of the memory category. This string should never be freed.
1525  */
1528 
1529 typedef struct CXTUResourceUsageEntry {
1530  /* \brief The memory usage category. */
1532  /* \brief Amount of resources used.
1533  The units will depend on the resource kind. */
1534  unsigned long amount;
1536 
1537 /**
1538  * \brief The memory usage of a CXTranslationUnit, broken into categories.
1539  */
1540 typedef struct CXTUResourceUsage {
1541  /* \brief Private data member, used for queries. */
1542  void *data;
1543 
1544  /* \brief The number of entries in the 'entries' array. */
1545  unsigned numEntries;
1546 
1547  /* \brief An array of key-value pairs, representing the breakdown of memory
1548  usage. */
1550 
1552 
1553 /**
1554  * \brief Return the memory usage of a translation unit. This object
1555  * should be released with clang_disposeCXTUResourceUsage().
1556  */
1558 
1560 
1561 /**
1562  * \brief Get target information for this translation unit.
1563  *
1564  * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1565  */
1566 CINDEX_LINKAGE CXTargetInfo
1567 clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1568 
1569 /**
1570  * \brief Destroy the CXTargetInfo object.
1571  */
1572 CINDEX_LINKAGE void
1573 clang_TargetInfo_dispose(CXTargetInfo Info);
1574 
1575 /**
1576  * \brief Get the normalized target triple as a string.
1577  *
1578  * Returns the empty string in case of any error.
1579  */
1581 clang_TargetInfo_getTriple(CXTargetInfo Info);
1582 
1583 /**
1584  * \brief Get the pointer width of the target in bits.
1585  *
1586  * Returns -1 in case of error.
1587  */
1588 CINDEX_LINKAGE int
1589 clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1590 
1591 /**
1592  * @}
1593  */
1594 
1595 /**
1596  * \brief Describes the kind of entity that a cursor refers to.
1597  */
1599  /* Declarations */
1600  /**
1601  * \brief A declaration whose specific kind is not exposed via this
1602  * interface.
1603  *
1604  * Unexposed declarations have the same operations as any other kind
1605  * of declaration; one can extract their location information,
1606  * spelling, find their definitions, etc. However, the specific kind
1607  * of the declaration is not reported.
1608  */
1610  /** \brief A C or C++ struct. */
1612  /** \brief A C or C++ union. */
1614  /** \brief A C++ class. */
1616  /** \brief An enumeration. */
1618  /**
1619  * \brief A field (in C) or non-static data member (in C++) in a
1620  * struct, union, or C++ class.
1621  */
1623  /** \brief An enumerator constant. */
1625  /** \brief A function. */
1627  /** \brief A variable. */
1629  /** \brief A function or method parameter. */
1631  /** \brief An Objective-C \@interface. */
1633  /** \brief An Objective-C \@interface for a category. */
1635  /** \brief An Objective-C \@protocol declaration. */
1637  /** \brief An Objective-C \@property declaration. */
1639  /** \brief An Objective-C instance variable. */
1641  /** \brief An Objective-C instance method. */
1643  /** \brief An Objective-C class method. */
1645  /** \brief An Objective-C \@implementation. */
1647  /** \brief An Objective-C \@implementation for a category. */
1649  /** \brief A typedef. */
1651  /** \brief A C++ class method. */
1653  /** \brief A C++ namespace. */
1655  /** \brief A linkage specification, e.g. 'extern "C"'. */
1657  /** \brief A C++ constructor. */
1659  /** \brief A C++ destructor. */
1661  /** \brief A C++ conversion function. */
1663  /** \brief A C++ template type parameter. */
1665  /** \brief A C++ non-type template parameter. */
1667  /** \brief A C++ template template parameter. */
1669  /** \brief A C++ function template. */
1671  /** \brief A C++ class template. */
1673  /** \brief A C++ class template partial specialization. */
1675  /** \brief A C++ namespace alias declaration. */
1677  /** \brief A C++ using directive. */
1679  /** \brief A C++ using declaration. */
1681  /** \brief A C++ alias declaration */
1683  /** \brief An Objective-C \@synthesize definition. */
1685  /** \brief An Objective-C \@dynamic definition. */
1687  /** \brief An access specifier. */
1689 
1692 
1693  /* References */
1694  CXCursor_FirstRef = 40, /* Decl references */
1698  /**
1699  * \brief A reference to a type declaration.
1700  *
1701  * A type reference occurs anywhere where a type is named but not
1702  * declared. For example, given:
1703  *
1704  * \code
1705  * typedef unsigned size_type;
1706  * size_type size;
1707  * \endcode
1708  *
1709  * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1710  * while the type of the variable "size" is referenced. The cursor
1711  * referenced by the type of size is the typedef for size_type.
1712  */
1715  /**
1716  * \brief A reference to a class template, function template, template
1717  * template parameter, or class template partial specialization.
1718  */
1720  /**
1721  * \brief A reference to a namespace or namespace alias.
1722  */
1724  /**
1725  * \brief A reference to a member of a struct, union, or class that occurs in
1726  * some non-expression context, e.g., a designated initializer.
1727  */
1729  /**
1730  * \brief A reference to a labeled statement.
1731  *
1732  * This cursor kind is used to describe the jump to "start_over" in the
1733  * goto statement in the following example:
1734  *
1735  * \code
1736  * start_over:
1737  * ++counter;
1738  *
1739  * goto start_over;
1740  * \endcode
1741  *
1742  * A label reference cursor refers to a label statement.
1743  */
1745 
1746  /**
1747  * \brief A reference to a set of overloaded functions or function templates
1748  * that has not yet been resolved to a specific function or function template.
1749  *
1750  * An overloaded declaration reference cursor occurs in C++ templates where
1751  * a dependent name refers to a function. For example:
1752  *
1753  * \code
1754  * template<typename T> void swap(T&, T&);
1755  *
1756  * struct X { ... };
1757  * void swap(X&, X&);
1758  *
1759  * template<typename T>
1760  * void reverse(T* first, T* last) {
1761  * while (first < last - 1) {
1762  * swap(*first, *--last);
1763  * ++first;
1764  * }
1765  * }
1766  *
1767  * struct Y { };
1768  * void swap(Y&, Y&);
1769  * \endcode
1770  *
1771  * Here, the identifier "swap" is associated with an overloaded declaration
1772  * reference. In the template definition, "swap" refers to either of the two
1773  * "swap" functions declared above, so both results will be available. At
1774  * instantiation time, "swap" may also refer to other functions found via
1775  * argument-dependent lookup (e.g., the "swap" function at the end of the
1776  * example).
1777  *
1778  * The functions \c clang_getNumOverloadedDecls() and
1779  * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1780  * referenced by this cursor.
1781  */
1783 
1784  /**
1785  * \brief A reference to a variable that occurs in some non-expression
1786  * context, e.g., a C++ lambda capture list.
1787  */
1789 
1791 
1792  /* Error conditions */
1799 
1800  /* Expressions */
1802 
1803  /**
1804  * \brief An expression whose specific kind is not exposed via this
1805  * interface.
1806  *
1807  * Unexposed expressions have the same operations as any other kind
1808  * of expression; one can extract their location information,
1809  * spelling, children, etc. However, the specific kind of the
1810  * expression is not reported.
1811  */
1813 
1814  /**
1815  * \brief An expression that refers to some value declaration, such
1816  * as a function, variable, or enumerator.
1817  */
1819 
1820  /**
1821  * \brief An expression that refers to a member of a struct, union,
1822  * class, Objective-C class, etc.
1823  */
1825 
1826  /** \brief An expression that calls a function. */
1828 
1829  /** \brief An expression that sends a message to an Objective-C
1830  object or class. */
1832 
1833  /** \brief An expression that represents a block literal. */
1835 
1836  /** \brief An integer literal.
1837  */
1839 
1840  /** \brief A floating point number literal.
1841  */
1843 
1844  /** \brief An imaginary number literal.
1845  */
1847 
1848  /** \brief A string literal.
1849  */
1851 
1852  /** \brief A character literal.
1853  */
1855 
1856  /** \brief A parenthesized expression, e.g. "(1)".
1857  *
1858  * This AST node is only formed if full location information is requested.
1859  */
1861 
1862  /** \brief This represents the unary-expression's (except sizeof and
1863  * alignof).
1864  */
1866 
1867  /** \brief [C99 6.5.2.1] Array Subscripting.
1868  */
1870 
1871  /** \brief A builtin binary operation expression such as "x + y" or
1872  * "x <= y".
1873  */
1875 
1876  /** \brief Compound assignment such as "+=".
1877  */
1879 
1880  /** \brief The ?: ternary operator.
1881  */
1883 
1884  /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1885  * (C++ [expr.cast]), which uses the syntax (Type)expr.
1886  *
1887  * For example: (int)f.
1888  */
1890 
1891  /** \brief [C99 6.5.2.5]
1892  */
1894 
1895  /** \brief Describes an C or C++ initializer list.
1896  */
1898 
1899  /** \brief The GNU address of label extension, representing &&label.
1900  */
1902 
1903  /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1904  */
1906 
1907  /** \brief Represents a C11 generic selection.
1908  */
1910 
1911  /** \brief Implements the GNU __null extension, which is a name for a null
1912  * pointer constant that has integral type (e.g., int or long) and is the same
1913  * size and alignment as a pointer.
1914  *
1915  * The __null extension is typically only used by system headers, which define
1916  * NULL as __null in C++ rather than using 0 (which is an integer that may not
1917  * match the size of a pointer).
1918  */
1920 
1921  /** \brief C++'s static_cast<> expression.
1922  */
1924 
1925  /** \brief C++'s dynamic_cast<> expression.
1926  */
1928 
1929  /** \brief C++'s reinterpret_cast<> expression.
1930  */
1932 
1933  /** \brief C++'s const_cast<> expression.
1934  */
1936 
1937  /** \brief Represents an explicit C++ type conversion that uses "functional"
1938  * notion (C++ [expr.type.conv]).
1939  *
1940  * Example:
1941  * \code
1942  * x = int(0.5);
1943  * \endcode
1944  */
1946 
1947  /** \brief A C++ typeid expression (C++ [expr.typeid]).
1948  */
1950 
1951  /** \brief [C++ 2.13.5] C++ Boolean Literal.
1952  */
1954 
1955  /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1956  */
1958 
1959  /** \brief Represents the "this" expression in C++
1960  */
1962 
1963  /** \brief [C++ 15] C++ Throw Expression.
1964  *
1965  * This handles 'throw' and 'throw' assignment-expression. When
1966  * assignment-expression isn't present, Op will be null.
1967  */
1969 
1970  /** \brief A new expression for memory allocation and constructor calls, e.g:
1971  * "new CXXNewExpr(foo)".
1972  */
1974 
1975  /** \brief A delete expression for memory deallocation and destructor calls,
1976  * e.g. "delete[] pArray".
1977  */
1979 
1980  /** \brief A unary expression. (noexcept, sizeof, or other traits)
1981  */
1983 
1984  /** \brief An Objective-C string literal i.e. @"foo".
1985  */
1987 
1988  /** \brief An Objective-C \@encode expression.
1989  */
1991 
1992  /** \brief An Objective-C \@selector expression.
1993  */
1995 
1996  /** \brief An Objective-C \@protocol expression.
1997  */
1999 
2000  /** \brief An Objective-C "bridged" cast expression, which casts between
2001  * Objective-C pointers and C pointers, transferring ownership in the process.
2002  *
2003  * \code
2004  * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2005  * \endcode
2006  */
2008 
2009  /** \brief Represents a C++0x pack expansion that produces a sequence of
2010  * expressions.
2011  *
2012  * A pack expansion expression contains a pattern (which itself is an
2013  * expression) followed by an ellipsis. For example:
2014  *
2015  * \code
2016  * template<typename F, typename ...Types>
2017  * void forward(F f, Types &&...args) {
2018  * f(static_cast<Types&&>(args)...);
2019  * }
2020  * \endcode
2021  */
2023 
2024  /** \brief Represents an expression that computes the length of a parameter
2025  * pack.
2026  *
2027  * \code
2028  * template<typename ...Types>
2029  * struct count {
2030  * static const unsigned value = sizeof...(Types);
2031  * };
2032  * \endcode
2033  */
2035 
2036  /* \brief Represents a C++ lambda expression that produces a local function
2037  * object.
2038  *
2039  * \code
2040  * void abssort(float *x, unsigned N) {
2041  * std::sort(x, x + N,
2042  * [](float a, float b) {
2043  * return std::abs(a) < std::abs(b);
2044  * });
2045  * }
2046  * \endcode
2047  */
2049 
2050  /** \brief Objective-c Boolean Literal.
2051  */
2053 
2054  /** \brief Represents the "self" expression in an Objective-C method.
2055  */
2057 
2058  /** \brief OpenMP 4.0 [2.4, Array Section].
2059  */
2061 
2062  /** \brief Represents an @available(...) check.
2063  */
2065 
2067 
2068  /* Statements */
2070  /**
2071  * \brief A statement whose specific kind is not exposed via this
2072  * interface.
2073  *
2074  * Unexposed statements have the same operations as any other kind of
2075  * statement; one can extract their location information, spelling,
2076  * children, etc. However, the specific kind of the statement is not
2077  * reported.
2078  */
2080 
2081  /** \brief A labelled statement in a function.
2082  *
2083  * This cursor kind is used to describe the "start_over:" label statement in
2084  * the following example:
2085  *
2086  * \code
2087  * start_over:
2088  * ++counter;
2089  * \endcode
2090  *
2091  */
2093 
2094  /** \brief A group of statements like { stmt stmt }.
2095  *
2096  * This cursor kind is used to describe compound statements, e.g. function
2097  * bodies.
2098  */
2100 
2101  /** \brief A case statement.
2102  */
2104 
2105  /** \brief A default statement.
2106  */
2108 
2109  /** \brief An if statement
2110  */
2112 
2113  /** \brief A switch statement.
2114  */
2116 
2117  /** \brief A while statement.
2118  */
2120 
2121  /** \brief A do statement.
2122  */
2124 
2125  /** \brief A for statement.
2126  */
2128 
2129  /** \brief A goto statement.
2130  */
2132 
2133  /** \brief An indirect goto statement.
2134  */
2136 
2137  /** \brief A continue statement.
2138  */
2140 
2141  /** \brief A break statement.
2142  */
2144 
2145  /** \brief A return statement.
2146  */
2148 
2149  /** \brief A GCC inline assembly statement extension.
2150  */
2153 
2154  /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
2155  */
2157 
2158  /** \brief Objective-C's \@catch statement.
2159  */
2161 
2162  /** \brief Objective-C's \@finally statement.
2163  */
2165 
2166  /** \brief Objective-C's \@throw statement.
2167  */
2169 
2170  /** \brief Objective-C's \@synchronized statement.
2171  */
2173 
2174  /** \brief Objective-C's autorelease pool statement.
2175  */
2177 
2178  /** \brief Objective-C's collection statement.
2179  */
2181 
2182  /** \brief C++'s catch statement.
2183  */
2185 
2186  /** \brief C++'s try statement.
2187  */
2189 
2190  /** \brief C++'s for (* : *) statement.
2191  */
2193 
2194  /** \brief Windows Structured Exception Handling's try statement.
2195  */
2197 
2198  /** \brief Windows Structured Exception Handling's except statement.
2199  */
2201 
2202  /** \brief Windows Structured Exception Handling's finally statement.
2203  */
2205 
2206  /** \brief A MS inline assembly statement extension.
2207  */
2209 
2210  /** \brief The null statement ";": C99 6.8.3p3.
2211  *
2212  * This cursor kind is used to describe the null statement.
2213  */
2215 
2216  /** \brief Adaptor class for mixing declarations with statements and
2217  * expressions.
2218  */
2220 
2221  /** \brief OpenMP parallel directive.
2222  */
2224 
2225  /** \brief OpenMP SIMD directive.
2226  */
2228 
2229  /** \brief OpenMP for directive.
2230  */
2232 
2233  /** \brief OpenMP sections directive.
2234  */
2236 
2237  /** \brief OpenMP section directive.
2238  */
2240 
2241  /** \brief OpenMP single directive.
2242  */
2244 
2245  /** \brief OpenMP parallel for directive.
2246  */
2248 
2249  /** \brief OpenMP parallel sections directive.
2250  */
2252 
2253  /** \brief OpenMP task directive.
2254  */
2256 
2257  /** \brief OpenMP master directive.
2258  */
2260 
2261  /** \brief OpenMP critical directive.
2262  */
2264 
2265  /** \brief OpenMP taskyield directive.
2266  */
2268 
2269  /** \brief OpenMP barrier directive.
2270  */
2272 
2273  /** \brief OpenMP taskwait directive.
2274  */
2276 
2277  /** \brief OpenMP flush directive.
2278  */
2280 
2281  /** \brief Windows Structured Exception Handling's leave statement.
2282  */
2284 
2285  /** \brief OpenMP ordered directive.
2286  */
2288 
2289  /** \brief OpenMP atomic directive.
2290  */
2292 
2293  /** \brief OpenMP for SIMD directive.
2294  */
2296 
2297  /** \brief OpenMP parallel for SIMD directive.
2298  */
2300 
2301  /** \brief OpenMP target directive.
2302  */
2304 
2305  /** \brief OpenMP teams directive.
2306  */
2308 
2309  /** \brief OpenMP taskgroup directive.
2310  */
2312 
2313  /** \brief OpenMP cancellation point directive.
2314  */
2316 
2317  /** \brief OpenMP cancel directive.
2318  */
2320 
2321  /** \brief OpenMP target data directive.
2322  */
2324 
2325  /** \brief OpenMP taskloop directive.
2326  */
2328 
2329  /** \brief OpenMP taskloop simd directive.
2330  */
2332 
2333  /** \brief OpenMP distribute directive.
2334  */
2336 
2337  /** \brief OpenMP target enter data directive.
2338  */
2340 
2341  /** \brief OpenMP target exit data directive.
2342  */
2344 
2345  /** \brief OpenMP target parallel directive.
2346  */
2348 
2349  /** \brief OpenMP target parallel for directive.
2350  */
2352 
2353  /** \brief OpenMP target update directive.
2354  */
2356 
2357  /** \brief OpenMP distribute parallel for directive.
2358  */
2360 
2361  /** \brief OpenMP distribute parallel for simd directive.
2362  */
2364 
2365  /** \brief OpenMP distribute simd directive.
2366  */
2368 
2369  /** \brief OpenMP target parallel for simd directive.
2370  */
2372 
2373  /** \brief OpenMP target simd directive.
2374  */
2376 
2377  /** \brief OpenMP teams distribute directive.
2378  */
2380 
2381  /** \brief OpenMP teams distribute simd directive.
2382  */
2384 
2385  /** \brief OpenMP teams distribute parallel for simd directive.
2386  */
2388 
2389  /** \brief OpenMP teams distribute parallel for directive.
2390  */
2392 
2393  /** \brief OpenMP target teams directive.
2394  */
2396 
2397  /** \brief OpenMP target teams distribute directive.
2398  */
2400 
2401  /** \brief OpenMP target teams distribute parallel for directive.
2402  */
2404 
2405  /** \brief OpenMP target teams distribute parallel for simd directive.
2406  */
2408 
2409  /** \brief OpenMP target teams distribute simd directive.
2410  */
2412 
2414 
2415  /**
2416  * \brief Cursor that represents the translation unit itself.
2417  *
2418  * The translation unit cursor exists primarily to act as the root
2419  * cursor for traversing the contents of a translation unit.
2420  */
2422 
2423  /* Attributes */
2425  /**
2426  * \brief An attribute whose specific kind is not exposed via this
2427  * interface.
2428  */
2430 
2451 
2452  /* Preprocessing */
2460 
2461  /* Extra Declarations */
2462  /**
2463  * \brief A module import declaration.
2464  */
2467  /**
2468  * \brief A static_assert or _Static_assert node
2469  */
2471  /**
2472  * \brief a friend declaration.
2473  */
2477 
2478  /**
2479  * \brief A code completion overload candidate.
2480  */
2482 };
2483 
2484 /**
2485  * \brief A cursor representing some element in the abstract syntax tree for
2486  * a translation unit.
2487  *
2488  * The cursor abstraction unifies the different kinds of entities in a
2489  * program--declaration, statements, expressions, references to declarations,
2490  * etc.--under a single "cursor" abstraction with a common set of operations.
2491  * Common operation for a cursor include: getting the physical location in
2492  * a source file where the cursor points, getting the name associated with a
2493  * cursor, and retrieving cursors for any child nodes of a particular cursor.
2494  *
2495  * Cursors can be produced in two specific ways.
2496  * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2497  * from which one can use clang_visitChildren() to explore the rest of the
2498  * translation unit. clang_getCursor() maps from a physical source location
2499  * to the entity that resides at that location, allowing one to map from the
2500  * source code into the AST.
2501  */
2502 typedef struct {
2504  int xdata;
2505  const void *data[3];
2506 } CXCursor;
2507 
2508 /**
2509  * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2510  *
2511  * @{
2512  */
2513 
2514 /**
2515  * \brief Retrieve the NULL cursor, which represents no entity.
2516  */
2518 
2519 /**
2520  * \brief Retrieve the cursor that represents the given translation unit.
2521  *
2522  * The translation unit cursor can be used to start traversing the
2523  * various declarations within the given translation unit.
2524  */
2526 
2527 /**
2528  * \brief Determine whether two cursors are equivalent.
2529  */
2531 
2532 /**
2533  * \brief Returns non-zero if \p cursor is null.
2534  */
2536 
2537 /**
2538  * \brief Compute a hash value for the given cursor.
2539  */
2541 
2542 /**
2543  * \brief Retrieve the kind of the given cursor.
2544  */
2546 
2547 /**
2548  * \brief Determine whether the given cursor kind represents a declaration.
2549  */
2551 
2552 /**
2553  * \brief Determine whether the given cursor kind represents a simple
2554  * reference.
2555  *
2556  * Note that other kinds of cursors (such as expressions) can also refer to
2557  * other cursors. Use clang_getCursorReferenced() to determine whether a
2558  * particular cursor refers to another entity.
2559  */
2561 
2562 /**
2563  * \brief Determine whether the given cursor kind represents an expression.
2564  */
2566 
2567 /**
2568  * \brief Determine whether the given cursor kind represents a statement.
2569  */
2571 
2572 /**
2573  * \brief Determine whether the given cursor kind represents an attribute.
2574  */
2576 
2577 /**
2578  * \brief Determine whether the given cursor has any attributes.
2579  */
2581 
2582 /**
2583  * \brief Determine whether the given cursor kind represents an invalid
2584  * cursor.
2585  */
2587 
2588 /**
2589  * \brief Determine whether the given cursor kind represents a translation
2590  * unit.
2591  */
2593 
2594 /***
2595  * \brief Determine whether the given cursor represents a preprocessing
2596  * element, such as a preprocessor directive or macro instantiation.
2597  */
2599 
2600 /***
2601  * \brief Determine whether the given cursor represents a currently
2602  * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2603  */
2605 
2606 /**
2607  * \brief Describe the linkage of the entity referred to by a cursor.
2608  */
2610  /** \brief This value indicates that no linkage information is available
2611  * for a provided CXCursor. */
2613  /**
2614  * \brief This is the linkage for variables, parameters, and so on that
2615  * have automatic storage. This covers normal (non-extern) local variables.
2616  */
2618  /** \brief This is the linkage for static variables and static functions. */
2620  /** \brief This is the linkage for entities with external linkage that live
2621  * in C++ anonymous namespaces.*/
2623  /** \brief This is the linkage for entities with true, external linkage. */
2625 };
2626 
2627 /**
2628  * \brief Determine the linkage of the entity referred to by a given cursor.
2629  */
2631 
2633  /** \brief This value indicates that no visibility information is available
2634  * for a provided CXCursor. */
2636 
2637  /** \brief Symbol not seen by the linker. */
2639  /** \brief Symbol seen by the linker but resolves to a symbol inside this object. */
2641  /** \brief Symbol seen by the linker and acts like a normal symbol. */
2643 };
2644 
2645 /**
2646  * \brief Describe the visibility of the entity referred to by a cursor.
2647  *
2648  * This returns the default visibility if not explicitly specified by
2649  * a visibility attribute. The default visibility may be changed by
2650  * commandline arguments.
2651  *
2652  * \param cursor The cursor to query.
2653  *
2654  * \returns The visibility of the cursor.
2655  */
2657 
2658 /**
2659  * \brief Determine the availability of the entity that this cursor refers to,
2660  * taking the current target platform into account.
2661  *
2662  * \param cursor The cursor to query.
2663  *
2664  * \returns The availability of the cursor.
2665  */
2668 
2669 /**
2670  * Describes the availability of a given entity on a particular platform, e.g.,
2671  * a particular class might only be available on Mac OS 10.7 or newer.
2672  */
2673 typedef struct CXPlatformAvailability {
2674  /**
2675  * \brief A string that describes the platform for which this structure
2676  * provides availability information.
2677  *
2678  * Possible values are "ios" or "macos".
2679  */
2681  /**
2682  * \brief The version number in which this entity was introduced.
2683  */
2685  /**
2686  * \brief The version number in which this entity was deprecated (but is
2687  * still available).
2688  */
2690  /**
2691  * \brief The version number in which this entity was obsoleted, and therefore
2692  * is no longer available.
2693  */
2695  /**
2696  * \brief Whether the entity is unconditionally unavailable on this platform.
2697  */
2699  /**
2700  * \brief An optional message to provide to a user of this API, e.g., to
2701  * suggest replacement APIs.
2702  */
2705 
2706 /**
2707  * \brief Determine the availability of the entity that this cursor refers to
2708  * on any platforms for which availability information is known.
2709  *
2710  * \param cursor The cursor to query.
2711  *
2712  * \param always_deprecated If non-NULL, will be set to indicate whether the
2713  * entity is deprecated on all platforms.
2714  *
2715  * \param deprecated_message If non-NULL, will be set to the message text
2716  * provided along with the unconditional deprecation of this entity. The client
2717  * is responsible for deallocating this string.
2718  *
2719  * \param always_unavailable If non-NULL, will be set to indicate whether the
2720  * entity is unavailable on all platforms.
2721  *
2722  * \param unavailable_message If non-NULL, will be set to the message text
2723  * provided along with the unconditional unavailability of this entity. The
2724  * client is responsible for deallocating this string.
2725  *
2726  * \param availability If non-NULL, an array of CXPlatformAvailability instances
2727  * that will be populated with platform availability information, up to either
2728  * the number of platforms for which availability information is available (as
2729  * returned by this function) or \c availability_size, whichever is smaller.
2730  *
2731  * \param availability_size The number of elements available in the
2732  * \c availability array.
2733  *
2734  * \returns The number of platforms (N) for which availability information is
2735  * available (which is unrelated to \c availability_size).
2736  *
2737  * Note that the client is responsible for calling
2738  * \c clang_disposeCXPlatformAvailability to free each of the
2739  * platform-availability structures returned. There are
2740  * \c min(N, availability_size) such structures.
2741  */
2742 CINDEX_LINKAGE int
2744  int *always_deprecated,
2745  CXString *deprecated_message,
2746  int *always_unavailable,
2747  CXString *unavailable_message,
2748  CXPlatformAvailability *availability,
2749  int availability_size);
2750 
2751 /**
2752  * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2753  */
2754 CINDEX_LINKAGE void
2756 
2757 /**
2758  * \brief Describe the "language" of the entity referred to by a cursor.
2759  */
2765 };
2766 
2767 /**
2768  * \brief Determine the "language" of the entity referred to by a given cursor.
2769  */
2771 
2772 /**
2773  * \brief Returns the translation unit that a cursor originated from.
2774  */
2776 
2777 /**
2778  * \brief A fast container representing a set of CXCursors.
2779  */
2780 typedef struct CXCursorSetImpl *CXCursorSet;
2781 
2782 /**
2783  * \brief Creates an empty CXCursorSet.
2784  */
2785 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2786 
2787 /**
2788  * \brief Disposes a CXCursorSet and releases its associated memory.
2789  */
2790 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2791 
2792 /**
2793  * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2794  *
2795  * \returns non-zero if the set contains the specified cursor.
2796 */
2797 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2798  CXCursor cursor);
2799 
2800 /**
2801  * \brief Inserts a CXCursor into a CXCursorSet.
2802  *
2803  * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2804 */
2805 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2806  CXCursor cursor);
2807 
2808 /**
2809  * \brief Determine the semantic parent of the given cursor.
2810  *
2811  * The semantic parent of a cursor is the cursor that semantically contains
2812  * the given \p cursor. For many declarations, the lexical and semantic parents
2813  * are equivalent (the lexical parent is returned by
2814  * \c clang_getCursorLexicalParent()). They diverge when declarations or
2815  * definitions are provided out-of-line. For example:
2816  *
2817  * \code
2818  * class C {
2819  * void f();
2820  * };
2821  *
2822  * void C::f() { }
2823  * \endcode
2824  *
2825  * In the out-of-line definition of \c C::f, the semantic parent is
2826  * the class \c C, of which this function is a member. The lexical parent is
2827  * the place where the declaration actually occurs in the source code; in this
2828  * case, the definition occurs in the translation unit. In general, the
2829  * lexical parent for a given entity can change without affecting the semantics
2830  * of the program, and the lexical parent of different declarations of the
2831  * same entity may be different. Changing the semantic parent of a declaration,
2832  * on the other hand, can have a major impact on semantics, and redeclarations
2833  * of a particular entity should all have the same semantic context.
2834  *
2835  * In the example above, both declarations of \c C::f have \c C as their
2836  * semantic context, while the lexical context of the first \c C::f is \c C
2837  * and the lexical context of the second \c C::f is the translation unit.
2838  *
2839  * For global declarations, the semantic parent is the translation unit.
2840  */
2842 
2843 /**
2844  * \brief Determine the lexical parent of the given cursor.
2845  *
2846  * The lexical parent of a cursor is the cursor in which the given \p cursor
2847  * was actually written. For many declarations, the lexical and semantic parents
2848  * are equivalent (the semantic parent is returned by
2849  * \c clang_getCursorSemanticParent()). They diverge when declarations or
2850  * definitions are provided out-of-line. For example:
2851  *
2852  * \code
2853  * class C {
2854  * void f();
2855  * };
2856  *
2857  * void C::f() { }
2858  * \endcode
2859  *
2860  * In the out-of-line definition of \c C::f, the semantic parent is
2861  * the class \c C, of which this function is a member. The lexical parent is
2862  * the place where the declaration actually occurs in the source code; in this
2863  * case, the definition occurs in the translation unit. In general, the
2864  * lexical parent for a given entity can change without affecting the semantics
2865  * of the program, and the lexical parent of different declarations of the
2866  * same entity may be different. Changing the semantic parent of a declaration,
2867  * on the other hand, can have a major impact on semantics, and redeclarations
2868  * of a particular entity should all have the same semantic context.
2869  *
2870  * In the example above, both declarations of \c C::f have \c C as their
2871  * semantic context, while the lexical context of the first \c C::f is \c C
2872  * and the lexical context of the second \c C::f is the translation unit.
2873  *
2874  * For declarations written in the global scope, the lexical parent is
2875  * the translation unit.
2876  */
2878 
2879 /**
2880  * \brief Determine the set of methods that are overridden by the given
2881  * method.
2882  *
2883  * In both Objective-C and C++, a method (aka virtual member function,
2884  * in C++) can override a virtual method in a base class. For
2885  * Objective-C, a method is said to override any method in the class's
2886  * base class, its protocols, or its categories' protocols, that has the same
2887  * selector and is of the same kind (class or instance).
2888  * If no such method exists, the search continues to the class's superclass,
2889  * its protocols, and its categories, and so on. A method from an Objective-C
2890  * implementation is considered to override the same methods as its
2891  * corresponding method in the interface.
2892  *
2893  * For C++, a virtual member function overrides any virtual member
2894  * function with the same signature that occurs in its base
2895  * classes. With multiple inheritance, a virtual member function can
2896  * override several virtual member functions coming from different
2897  * base classes.
2898  *
2899  * In all cases, this function determines the immediate overridden
2900  * method, rather than all of the overridden methods. For example, if
2901  * a method is originally declared in a class A, then overridden in B
2902  * (which in inherits from A) and also in C (which inherited from B),
2903  * then the only overridden method returned from this function when
2904  * invoked on C's method will be B's method. The client may then
2905  * invoke this function again, given the previously-found overridden
2906  * methods, to map out the complete method-override set.
2907  *
2908  * \param cursor A cursor representing an Objective-C or C++
2909  * method. This routine will compute the set of methods that this
2910  * method overrides.
2911  *
2912  * \param overridden A pointer whose pointee will be replaced with a
2913  * pointer to an array of cursors, representing the set of overridden
2914  * methods. If there are no overridden methods, the pointee will be
2915  * set to NULL. The pointee must be freed via a call to
2916  * \c clang_disposeOverriddenCursors().
2917  *
2918  * \param num_overridden A pointer to the number of overridden
2919  * functions, will be set to the number of overridden functions in the
2920  * array pointed to by \p overridden.
2921  */
2923  CXCursor **overridden,
2924  unsigned *num_overridden);
2925 
2926 /**
2927  * \brief Free the set of overridden cursors returned by \c
2928  * clang_getOverriddenCursors().
2929  */
2931 
2932 /**
2933  * \brief Retrieve the file that is included by the given inclusion directive
2934  * cursor.
2935  */
2937 
2938 /**
2939  * @}
2940  */
2941 
2942 /**
2943  * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2944  *
2945  * Cursors represent a location within the Abstract Syntax Tree (AST). These
2946  * routines help map between cursors and the physical locations where the
2947  * described entities occur in the source code. The mapping is provided in
2948  * both directions, so one can map from source code to the AST and back.
2949  *
2950  * @{
2951  */
2952 
2953 /**
2954  * \brief Map a source location to the cursor that describes the entity at that
2955  * location in the source code.
2956  *
2957  * clang_getCursor() maps an arbitrary source location within a translation
2958  * unit down to the most specific cursor that describes the entity at that
2959  * location. For example, given an expression \c x + y, invoking
2960  * clang_getCursor() with a source location pointing to "x" will return the
2961  * cursor for "x"; similarly for "y". If the cursor points anywhere between
2962  * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2963  * will return a cursor referring to the "+" expression.
2964  *
2965  * \returns a cursor representing the entity at the given source location, or
2966  * a NULL cursor if no such entity can be found.
2967  */
2969 
2970 /**
2971  * \brief Retrieve the physical location of the source constructor referenced
2972  * by the given cursor.
2973  *
2974  * The location of a declaration is typically the location of the name of that
2975  * declaration, where the name of that declaration would occur if it is
2976  * unnamed, or some keyword that introduces that particular declaration.
2977  * The location of a reference is where that reference occurs within the
2978  * source code.
2979  */
2981 
2982 /**
2983  * \brief Retrieve the physical extent of the source construct referenced by
2984  * the given cursor.
2985  *
2986  * The extent of a cursor starts with the file/line/column pointing at the
2987  * first character within the source construct that the cursor refers to and
2988  * ends with the last character within that source construct. For a
2989  * declaration, the extent covers the declaration itself. For a reference,
2990  * the extent covers the location of the reference (e.g., where the referenced
2991  * entity was actually used).
2992  */
2994 
2995 /**
2996  * @}
2997  */
2998 
2999 /**
3000  * \defgroup CINDEX_TYPES Type information for CXCursors
3001  *
3002  * @{
3003  */
3004 
3005 /**
3006  * \brief Describes the kind of type
3007  */
3009  /**
3010  * \brief Represents an invalid type (e.g., where no type is available).
3011  */
3013 
3014  /**
3015  * \brief A type whose specific kind is not exposed via this
3016  * interface.
3017  */
3019 
3020  /* Builtin types */
3053 
3073 
3074  /**
3075  * \brief Represents a type that was referred to using an elaborated type keyword.
3076  *
3077  * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3078  */
3080 
3081  /* OpenCL PipeType. */
3083 
3084  /* OpenCL builtin types. */
3125 };
3126 
3127 /**
3128  * \brief Describes the calling convention of a function type
3129  */
3147 
3150 };
3151 
3152 /**
3153  * \brief The type of an element in the abstract syntax tree.
3154  *
3155  */
3156 typedef struct {
3158  void *data[2];
3159 } CXType;
3160 
3161 /**
3162  * \brief Retrieve the type of a CXCursor (if any).
3163  */
3165 
3166 /**
3167  * \brief Pretty-print the underlying type using the rules of the
3168  * language of the translation unit from which it came.
3169  *
3170  * If the type is invalid, an empty string is returned.
3171  */
3173 
3174 /**
3175  * \brief Retrieve the underlying type of a typedef declaration.
3176  *
3177  * If the cursor does not reference a typedef declaration, an invalid type is
3178  * returned.
3179  */
3181 
3182 /**
3183  * \brief Retrieve the integer type of an enum declaration.
3184  *
3185  * If the cursor does not reference an enum declaration, an invalid type is
3186  * returned.
3187  */
3189 
3190 /**
3191  * \brief Retrieve the integer value of an enum constant declaration as a signed
3192  * long long.
3193  *
3194  * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3195  * Since this is also potentially a valid constant value, the kind of the cursor
3196  * must be verified before calling this function.
3197  */
3199 
3200 /**
3201  * \brief Retrieve the integer value of an enum constant declaration as an unsigned
3202  * long long.
3203  *
3204  * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3205  * Since this is also potentially a valid constant value, the kind of the cursor
3206  * must be verified before calling this function.
3207  */
3209 
3210 /**
3211  * \brief Retrieve the bit width of a bit field declaration as an integer.
3212  *
3213  * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3214  */
3216 
3217 /**
3218  * \brief Retrieve the number of non-variadic arguments associated with a given
3219  * cursor.
3220  *
3221  * The number of arguments can be determined for calls as well as for
3222  * declarations of functions or methods. For other cursors -1 is returned.
3223  */
3225 
3226 /**
3227  * \brief Retrieve the argument cursor of a function or method.
3228  *
3229  * The argument cursor can be determined for calls as well as for declarations
3230  * of functions or methods. For other cursors and for invalid indices, an
3231  * invalid cursor is returned.
3232  */
3234 
3235 /**
3236  * \brief Describes the kind of a template argument.
3237  *
3238  * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3239  * element descriptions.
3240  */
3251  /* Indicates an error case, preventing the kind from being deduced. */
3253 };
3254 
3255 /**
3256  *\brief Returns the number of template args of a function decl representing a
3257  * template specialization.
3258  *
3259  * If the argument cursor cannot be converted into a template function
3260  * declaration, -1 is returned.
3261  *
3262  * For example, for the following declaration and specialization:
3263  * template <typename T, int kInt, bool kBool>
3264  * void foo() { ... }
3265  *
3266  * template <>
3267  * void foo<float, -7, true>();
3268  *
3269  * The value 3 would be returned from this call.
3270  */
3272 
3273 /**
3274  * \brief Retrieve the kind of the I'th template argument of the CXCursor C.
3275  *
3276  * If the argument CXCursor does not represent a FunctionDecl, an invalid
3277  * template argument kind is returned.
3278  *
3279  * For example, for the following declaration and specialization:
3280  * template <typename T, int kInt, bool kBool>
3281  * void foo() { ... }
3282  *
3283  * template <>
3284  * void foo<float, -7, true>();
3285  *
3286  * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3287  * respectively.
3288  */
3290  CXCursor C, unsigned I);
3291 
3292 /**
3293  * \brief Retrieve a CXType representing the type of a TemplateArgument of a
3294  * function decl representing a template specialization.
3295  *
3296  * If the argument CXCursor does not represent a FunctionDecl whose I'th
3297  * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3298  * is returned.
3299  *
3300  * For example, for the following declaration and specialization:
3301  * template <typename T, int kInt, bool kBool>
3302  * void foo() { ... }
3303  *
3304  * template <>
3305  * void foo<float, -7, true>();
3306  *
3307  * If called with I = 0, "float", will be returned.
3308  * Invalid types will be returned for I == 1 or 2.
3309  */
3311  unsigned I);
3312 
3313 /**
3314  * \brief Retrieve the value of an Integral TemplateArgument (of a function
3315  * decl representing a template specialization) as a signed long long.
3316  *
3317  * It is undefined to call this function on a CXCursor that does not represent a
3318  * FunctionDecl or whose I'th template argument is not an integral value.
3319  *
3320  * For example, for the following declaration and specialization:
3321  * template <typename T, int kInt, bool kBool>
3322  * void foo() { ... }
3323  *
3324  * template <>
3325  * void foo<float, -7, true>();
3326  *
3327  * If called with I = 1 or 2, -7 or true will be returned, respectively.
3328  * For I == 0, this function's behavior is undefined.
3329  */
3331  unsigned I);
3332 
3333 /**
3334  * \brief Retrieve the value of an Integral TemplateArgument (of a function
3335  * decl representing a template specialization) as an unsigned long long.
3336  *
3337  * It is undefined to call this function on a CXCursor that does not represent a
3338  * FunctionDecl or whose I'th template argument is not an integral value.
3339  *
3340  * For example, for the following declaration and specialization:
3341  * template <typename T, int kInt, bool kBool>
3342  * void foo() { ... }
3343  *
3344  * template <>
3345  * void foo<float, 2147483649, true>();
3346  *
3347  * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3348  * For I == 0, this function's behavior is undefined.
3349  */
3351  CXCursor C, unsigned I);
3352 
3353 /**
3354  * \brief Determine whether two CXTypes represent the same type.
3355  *
3356  * \returns non-zero if the CXTypes represent the same type and
3357  * zero otherwise.
3358  */
3360 
3361 /**
3362  * \brief Return the canonical type for a CXType.
3363  *
3364  * Clang's type system explicitly models typedefs and all the ways
3365  * a specific type can be represented. The canonical type is the underlying
3366  * type with all the "sugar" removed. For example, if 'T' is a typedef
3367  * for 'int', the canonical type for 'T' would be 'int'.
3368  */
3370 
3371 /**
3372  * \brief Determine whether a CXType has the "const" qualifier set,
3373  * without looking through typedefs that may have added "const" at a
3374  * different level.
3375  */
3377 
3378 /**
3379  * \brief Determine whether a CXCursor that is a macro, is
3380  * function like.
3381  */
3383 
3384 /**
3385  * \brief Determine whether a CXCursor that is a macro, is a
3386  * builtin one.
3387  */
3389 
3390 /**
3391  * \brief Determine whether a CXCursor that is a function declaration, is an
3392  * inline declaration.
3393  */
3395 
3396 /**
3397  * \brief Determine whether a CXType has the "volatile" qualifier set,
3398  * without looking through typedefs that may have added "volatile" at
3399  * a different level.
3400  */
3402 
3403 /**
3404  * \brief Determine whether a CXType has the "restrict" qualifier set,
3405  * without looking through typedefs that may have added "restrict" at a
3406  * different level.
3407  */
3409 
3410 /**
3411  * \brief For pointer types, returns the type of the pointee.
3412  */
3414 
3415 /**
3416  * \brief Return the cursor for the declaration of the given type.
3417  */
3419 
3420 /**
3421  * Returns the Objective-C type encoding for the specified declaration.
3422  */
3424 
3425 /**
3426  * Returns the Objective-C type encoding for the specified CXType.
3427  */
3429 
3430 /**
3431  * \brief Retrieve the spelling of a given CXTypeKind.
3432  */
3434 
3435 /**
3436  * \brief Retrieve the calling convention associated with a function type.
3437  *
3438  * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3439  */
3441 
3442 /**
3443  * \brief Retrieve the return type associated with a function type.
3444  *
3445  * If a non-function type is passed in, an invalid type is returned.
3446  */
3448 
3449 /**
3450  * \brief Retrieve the number of non-variadic parameters associated with a
3451  * function type.
3452  *
3453  * If a non-function type is passed in, -1 is returned.
3454  */
3456 
3457 /**
3458  * \brief Retrieve the type of a parameter of a function type.
3459  *
3460  * If a non-function type is passed in or the function does not have enough
3461  * parameters, an invalid type is returned.
3462  */
3464 
3465 /**
3466  * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
3467  */
3469 
3470 /**
3471  * \brief Retrieve the return type associated with a given cursor.
3472  *
3473  * This only returns a valid type if the cursor refers to a function or method.
3474  */
3476 
3477 /**
3478  * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
3479  * otherwise.
3480  */
3482 
3483 /**
3484  * \brief Return the element type of an array, complex, or vector type.
3485  *
3486  * If a type is passed in that is not an array, complex, or vector type,
3487  * an invalid type is returned.
3488  */
3490 
3491 /**
3492  * \brief Return the number of elements of an array or vector type.
3493  *
3494  * If a type is passed in that is not an array or vector type,
3495  * -1 is returned.
3496  */
3498 
3499 /**
3500  * \brief Return the element type of an array type.
3501  *
3502  * If a non-array type is passed in, an invalid type is returned.
3503  */
3505 
3506 /**
3507  * \brief Return the array size of a constant array.
3508  *
3509  * If a non-array type is passed in, -1 is returned.
3510  */
3512 
3513 /**
3514  * \brief Retrieve the type named by the qualified-id.
3515  *
3516  * If a non-elaborated type is passed in, an invalid type is returned.
3517  */
3519 
3520 /**
3521  * \brief Determine if a typedef is 'transparent' tag.
3522  *
3523  * A typedef is considered 'transparent' if it shares a name and spelling
3524  * location with its underlying tag type, as is the case with the NS_ENUM macro.
3525  *
3526  * \returns non-zero if transparent and zero otherwise.
3527  */
3529 
3530 /**
3531  * \brief List the possible error codes for \c clang_Type_getSizeOf,
3532  * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3533  * \c clang_Cursor_getOffsetOf.
3534  *
3535  * A value of this enumeration type can be returned if the target type is not
3536  * a valid argument to sizeof, alignof or offsetof.
3537  */
3539  /**
3540  * \brief Type is of kind CXType_Invalid.
3541  */
3543  /**
3544  * \brief The type is an incomplete Type.
3545  */
3547  /**
3548  * \brief The type is a dependent Type.
3549  */
3551  /**
3552  * \brief The type is not a constant size type.
3553  */
3555  /**
3556  * \brief The Field name is not valid for this record.
3557  */
3559 };
3560 
3561 /**
3562  * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
3563  * standard.
3564  *
3565  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3566  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3567  * is returned.
3568  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3569  * returned.
3570  * If the type declaration is not a constant size type,
3571  * CXTypeLayoutError_NotConstantSize is returned.
3572  */
3574 
3575 /**
3576  * \brief Return the class type of an member pointer type.
3577  *
3578  * If a non-member-pointer type is passed in, an invalid type is returned.
3579  */
3581 
3582 /**
3583  * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
3584  *
3585  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3586  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3587  * is returned.
3588  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3589  * returned.
3590  */
3592 
3593 /**
3594  * \brief Return the offset of a field named S in a record of type T in bits
3595  * as it would be returned by __offsetof__ as per C++11[18.2p4]
3596  *
3597  * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3598  * is returned.
3599  * If the field's type declaration is an incomplete type,
3600  * CXTypeLayoutError_Incomplete is returned.
3601  * If the field's type declaration is a dependent type,
3602  * CXTypeLayoutError_Dependent is returned.
3603  * If the field's name S is not found,
3604  * CXTypeLayoutError_InvalidFieldName is returned.
3605  */
3606 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3607 
3608 /**
3609  * \brief Return the offset of the field represented by the Cursor.
3610  *
3611  * If the cursor is not a field declaration, -1 is returned.
3612  * If the cursor semantic parent is not a record field declaration,
3613  * CXTypeLayoutError_Invalid is returned.
3614  * If the field's type declaration is an incomplete type,
3615  * CXTypeLayoutError_Incomplete is returned.
3616  * If the field's type declaration is a dependent type,
3617  * CXTypeLayoutError_Dependent is returned.
3618  * If the field's name S is not found,
3619  * CXTypeLayoutError_InvalidFieldName is returned.
3620  */
3622 
3623 /**
3624  * \brief Determine whether the given cursor represents an anonymous record
3625  * declaration.
3626  */
3628 
3630  /** \brief No ref-qualifier was provided. */
3632  /** \brief An lvalue ref-qualifier was provided (\c &). */
3634  /** \brief An rvalue ref-qualifier was provided (\c &&). */
3636 };
3637 
3638 /**
3639  * \brief Returns the number of template arguments for given template
3640  * specialization, or -1 if type \c T is not a template specialization.
3641  */
3643 
3644 /**
3645  * \brief Returns the type template argument of a template class specialization
3646  * at given index.
3647  *
3648  * This function only returns template type arguments and does not handle
3649  * template template arguments or variadic packs.
3650  */
3652 
3653 /**
3654  * \brief Retrieve the ref-qualifier kind of a function or method.
3655  *
3656  * The ref-qualifier is returned for C++ functions or methods. For other types
3657  * or non-C++ declarations, CXRefQualifier_None is returned.
3658  */
3660 
3661 /**
3662  * \brief Returns non-zero if the cursor specifies a Record member that is a
3663  * bitfield.
3664  */
3666 
3667 /**
3668  * \brief Returns 1 if the base class specified by the cursor with kind
3669  * CX_CXXBaseSpecifier is virtual.
3670  */
3672 
3673 /**
3674  * \brief Represents the C++ access control level to a base class for a
3675  * cursor with kind CX_CXXBaseSpecifier.
3676  */
3682 };
3683 
3684 /**
3685  * \brief Returns the access control level for the referenced object.
3686  *
3687  * If the cursor refers to a C++ declaration, its access control level within its
3688  * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3689  * access specifier, the specifier itself is returned.
3690  */
3692 
3693 /**
3694  * \brief Represents the storage classes as declared in the source. CX_SC_Invalid
3695  * was added for the case that the passed cursor in not a declaration.
3696  */
3706 };
3707 
3708 /**
3709  * \brief Returns the storage class for a function or variable declaration.
3710  *
3711  * If the passed in Cursor is not a function or variable declaration,
3712  * CX_SC_Invalid is returned else the storage class.
3713  */
3715 
3716 /**
3717  * \brief Determine the number of overloaded declarations referenced by a
3718  * \c CXCursor_OverloadedDeclRef cursor.
3719  *
3720  * \param cursor The cursor whose overloaded declarations are being queried.
3721  *
3722  * \returns The number of overloaded declarations referenced by \c cursor. If it
3723  * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3724  */
3726 
3727 /**
3728  * \brief Retrieve a cursor for one of the overloaded declarations referenced
3729  * by a \c CXCursor_OverloadedDeclRef cursor.
3730  *
3731  * \param cursor The cursor whose overloaded declarations are being queried.
3732  *
3733  * \param index The zero-based index into the set of overloaded declarations in
3734  * the cursor.
3735  *
3736  * \returns A cursor representing the declaration referenced by the given
3737  * \c cursor at the specified \c index. If the cursor does not have an
3738  * associated set of overloaded declarations, or if the index is out of bounds,
3739  * returns \c clang_getNullCursor();
3740  */
3742  unsigned index);
3743 
3744 /**
3745  * @}
3746  */
3747 
3748 /**
3749  * \defgroup CINDEX_ATTRIBUTES Information for attributes
3750  *
3751  * @{
3752  */
3753 
3754 /**
3755  * \brief For cursors representing an iboutletcollection attribute,
3756  * this function returns the collection element type.
3757  *
3758  */
3760 
3761 /**
3762  * @}
3763  */
3764 
3765 /**
3766  * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3767  *
3768  * These routines provide the ability to traverse the abstract syntax tree
3769  * using cursors.
3770  *
3771  * @{
3772  */
3773 
3774 /**
3775  * \brief Describes how the traversal of the children of a particular
3776  * cursor should proceed after visiting a particular child cursor.
3777  *
3778  * A value of this enumeration type should be returned by each
3779  * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3780  */
3782  /**
3783  * \brief Terminates the cursor traversal.
3784  */
3786  /**
3787  * \brief Continues the cursor traversal with the next sibling of
3788  * the cursor just visited, without visiting its children.
3789  */
3791  /**
3792  * \brief Recursively traverse the children of this cursor, using
3793  * the same visitor and client data.
3794  */
3796 };
3797 
3798 /**
3799  * \brief Visitor invoked for each cursor found by a traversal.
3800  *
3801  * This visitor function will be invoked for each cursor found by
3802  * clang_visitCursorChildren(). Its first argument is the cursor being
3803  * visited, its second argument is the parent visitor for that cursor,
3804  * and its third argument is the client data provided to
3805  * clang_visitCursorChildren().
3806  *
3807  * The visitor should return one of the \c CXChildVisitResult values
3808  * to direct clang_visitCursorChildren().
3809  */
3811  CXCursor parent,
3812  CXClientData client_data);
3813 
3814 /**
3815  * \brief Visit the children of a particular cursor.
3816  *
3817  * This function visits all the direct children of the given cursor,
3818  * invoking the given \p visitor function with the cursors of each
3819  * visited child. The traversal may be recursive, if the visitor returns
3820  * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3821  * the visitor returns \c CXChildVisit_Break.
3822  *
3823  * \param parent the cursor whose child may be visited. All kinds of
3824  * cursors can be visited, including invalid cursors (which, by
3825  * definition, have no children).
3826  *
3827  * \param visitor the visitor function that will be invoked for each
3828  * child of \p parent.
3829  *
3830  * \param client_data pointer data supplied by the client, which will
3831  * be passed to the visitor each time it is invoked.
3832  *
3833  * \returns a non-zero value if the traversal was terminated
3834  * prematurely by the visitor returning \c CXChildVisit_Break.
3835  */
3837  CXCursorVisitor visitor,
3838  CXClientData client_data);
3839 #ifdef __has_feature
3840 # if __has_feature(blocks)
3841 /**
3842  * \brief Visitor invoked for each cursor found by a traversal.
3843  *
3844  * This visitor block will be invoked for each cursor found by
3845  * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3846  * visited, its second argument is the parent visitor for that cursor.
3847  *
3848  * The visitor should return one of the \c CXChildVisitResult values
3849  * to direct clang_visitChildrenWithBlock().
3850  */
3851 typedef enum CXChildVisitResult
3852  (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3853 
3854 /**
3855  * Visits the children of a cursor using the specified block. Behaves
3856  * identically to clang_visitChildren() in all other respects.
3857  */
3858 CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
3859  CXCursorVisitorBlock block);
3860 # endif
3861 #endif
3862 
3863 /**
3864  * @}
3865  */
3866 
3867 /**
3868  * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3869  *
3870  * These routines provide the ability to determine references within and
3871  * across translation units, by providing the names of the entities referenced
3872  * by cursors, follow reference cursors to the declarations they reference,
3873  * and associate declarations with their definitions.
3874  *
3875  * @{
3876  */
3877 
3878 /**
3879  * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3880  * by the given cursor.
3881  *
3882  * A Unified Symbol Resolution (USR) is a string that identifies a particular
3883  * entity (function, class, variable, etc.) within a program. USRs can be
3884  * compared across translation units to determine, e.g., when references in
3885  * one translation refer to an entity defined in another translation unit.
3886  */
3888 
3889 /**
3890  * \brief Construct a USR for a specified Objective-C class.
3891  */
3892 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3893 
3894 /**
3895  * \brief Construct a USR for a specified Objective-C category.
3896  */
3898  clang_constructUSR_ObjCCategory(const char *class_name,
3899  const char *category_name);
3900 
3901 /**
3902  * \brief Construct a USR for a specified Objective-C protocol.
3903  */
3905  clang_constructUSR_ObjCProtocol(const char *protocol_name);
3906 
3907 /**
3908  * \brief Construct a USR for a specified Objective-C instance variable and
3909  * the USR for its containing class.
3910  */
3912  CXString classUSR);
3913 
3914 /**
3915  * \brief Construct a USR for a specified Objective-C method and
3916  * the USR for its containing class.
3917  */
3919  unsigned isInstanceMethod,
3920  CXString classUSR);
3921 
3922 /**
3923  * \brief Construct a USR for a specified Objective-C property and the USR
3924  * for its containing class.
3925  */
3927  CXString classUSR);
3928 
3929 /**
3930  * \brief Retrieve a name for the entity referenced by this cursor.
3931  */
3933 
3934 /**
3935  * \brief Retrieve a range for a piece that forms the cursors spelling name.
3936  * Most of the times there is only one range for the complete spelling but for
3937  * Objective-C methods and Objective-C message expressions, there are multiple
3938  * pieces for each selector identifier.
3939  *
3940  * \param pieceIndex the index of the spelling name piece. If this is greater
3941  * than the actual number of pieces, it will return a NULL (invalid) range.
3942  *
3943  * \param options Reserved.
3944  */
3946  unsigned pieceIndex,
3947  unsigned options);
3948 
3949 /**
3950  * \brief Retrieve the display name for the entity referenced by this cursor.
3951  *
3952  * The display name contains extra information that helps identify the cursor,
3953  * such as the parameters of a function or template or the arguments of a
3954  * class template specialization.
3955  */
3957 
3958 /** \brief For a cursor that is a reference, retrieve a cursor representing the
3959  * entity that it references.
3960  *
3961  * Reference cursors refer to other entities in the AST. For example, an
3962  * Objective-C superclass reference cursor refers to an Objective-C class.
3963  * This function produces the cursor for the Objective-C class from the
3964  * cursor for the superclass reference. If the input cursor is a declaration or
3965  * definition, it returns that declaration or definition unchanged.
3966  * Otherwise, returns the NULL cursor.
3967  */
3969 
3970 /**
3971  * \brief For a cursor that is either a reference to or a declaration
3972  * of some entity, retrieve a cursor that describes the definition of
3973  * that entity.
3974  *
3975  * Some entities can be declared multiple times within a translation
3976  * unit, but only one of those declarations can also be a
3977  * definition. For example, given:
3978  *
3979  * \code
3980  * int f(int, int);
3981  * int g(int x, int y) { return f(x, y); }
3982  * int f(int a, int b) { return a + b; }
3983  * int f(int, int);
3984  * \endcode
3985  *
3986  * there are three declarations of the function "f", but only the
3987  * second one is a definition. The clang_getCursorDefinition()
3988  * function will take any cursor pointing to a declaration of "f"
3989  * (the first or fourth lines of the example) or a cursor referenced
3990  * that uses "f" (the call to "f' inside "g") and will return a
3991  * declaration cursor pointing to the definition (the second "f"
3992  * declaration).
3993  *
3994  * If given a cursor for which there is no corresponding definition,
3995  * e.g., because there is no definition of that entity within this
3996  * translation unit, returns a NULL cursor.
3997  */
3999 
4000 /**
4001  * \brief Determine whether the declaration pointed to by this cursor
4002  * is also a definition of that entity.
4003  */
4005 
4006 /**
4007  * \brief Retrieve the canonical cursor corresponding to the given cursor.
4008  *
4009  * In the C family of languages, many kinds of entities can be declared several
4010  * times within a single translation unit. For example, a structure type can
4011  * be forward-declared (possibly multiple times) and later defined:
4012  *
4013  * \code
4014  * struct X;
4015  * struct X;
4016  * struct X {
4017  * int member;
4018  * };
4019  * \endcode
4020  *
4021  * The declarations and the definition of \c X are represented by three
4022  * different cursors, all of which are declarations of the same underlying
4023  * entity. One of these cursor is considered the "canonical" cursor, which
4024  * is effectively the representative for the underlying entity. One can
4025  * determine if two cursors are declarations of the same underlying entity by
4026  * comparing their canonical cursors.
4027  *
4028  * \returns The canonical cursor for the entity referred to by the given cursor.
4029  */
4031 
4032 /**
4033  * \brief If the cursor points to a selector identifier in an Objective-C
4034  * method or message expression, this returns the selector index.
4035  *
4036  * After getting a cursor with #clang_getCursor, this can be called to
4037  * determine if the location points to a selector identifier.
4038  *
4039  * \returns The selector index if the cursor is an Objective-C method or message
4040  * expression and the cursor is pointing to a selector identifier, or -1
4041  * otherwise.
4042  */
4044 
4045 /**
4046  * \brief Given a cursor pointing to a C++ method call or an Objective-C
4047  * message, returns non-zero if the method/message is "dynamic", meaning:
4048  *
4049  * For a C++ method: the call is virtual.
4050  * For an Objective-C message: the receiver is an object instance, not 'super'
4051  * or a specific class.
4052  *
4053  * If the method/message is "static" or the cursor does not point to a
4054  * method/message, it will return zero.
4055  */
4057 
4058 /**
4059  * \brief Given a cursor pointing to an Objective-C message or property
4060  * reference, or C++ method call, returns the CXType of the receiver.
4061  */
4063 
4064 /**
4065  * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
4066  */
4067 typedef enum {
4083 
4084 /**
4085  * \brief Given a cursor that represents a property declaration, return the
4086  * associated property attributes. The bits are formed from
4087  * \c CXObjCPropertyAttrKind.
4088  *
4089  * \param reserved Reserved for future use, pass 0.
4090  */
4092  unsigned reserved);
4093 
4094 /**
4095  * \brief 'Qualifiers' written next to the return and parameter types in
4096  * Objective-C method declarations.
4097  */
4098 typedef enum {
4107 
4108 /**
4109  * \brief Given a cursor that represents an Objective-C method or parameter
4110  * declaration, return the associated Objective-C qualifiers for the return
4111  * type or the parameter respectively. The bits are formed from
4112  * CXObjCDeclQualifierKind.
4113  */
4115 
4116 /**
4117  * \brief Given a cursor that represents an Objective-C method or property
4118  * declaration, return non-zero if the declaration was affected by "\@optional".
4119  * Returns zero if the cursor is not such a declaration or it is "\@required".
4120  */
4122 
4123 /**
4124  * \brief Returns non-zero if the given cursor is a variadic function or method.
4125  */
4127 
4128 /**
4129  * \brief Returns non-zero if the given cursor points to a symbol marked with
4130  * external_source_symbol attribute.
4131  *
4132  * \param language If non-NULL, and the attribute is present, will be set to
4133  * the 'language' string from the attribute.
4134  *
4135  * \param definedIn If non-NULL, and the attribute is present, will be set to
4136  * the 'definedIn' string from the attribute.
4137  *
4138  * \param isGenerated If non-NULL, and the attribute is present, will be set to
4139  * non-zero if the 'generated_declaration' is set in the attribute.
4140  */
4142  CXString *language, CXString *definedIn,
4143  unsigned *isGenerated);
4144 
4145 /**
4146  * \brief Given a cursor that represents a declaration, return the associated
4147  * comment's source range. The range may include multiple consecutive comments
4148  * with whitespace in between.
4149  */
4151 
4152 /**
4153  * \brief Given a cursor that represents a declaration, return the associated
4154  * comment text, including comment markers.
4155  */
4157 
4158 /**
4159  * \brief Given a cursor that represents a documentable entity (e.g.,
4160  * declaration), return the associated \\brief paragraph; otherwise return the
4161  * first paragraph.
4162  */
4164 
4165 /**
4166  * @}
4167  */
4168 
4169 /** \defgroup CINDEX_MANGLE Name Mangling API Functions
4170  *
4171  * @{
4172  */
4173 
4174 /**
4175  * \brief Retrieve the CXString representing the mangled name of the cursor.
4176  */
4178 
4179 /**
4180  * \brief Retrieve the CXStrings representing the mangled symbols of the C++
4181  * constructor or destructor at the cursor.
4182  */
4184 
4185 /**
4186  * @}
4187  */
4188 
4189 /**
4190  * \defgroup CINDEX_MODULE Module introspection
4191  *
4192  * The functions in this group provide access to information about modules.
4193  *
4194  * @{
4195  */
4196 
4197 typedef void *CXModule;
4198 
4199 /**
4200  * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4201  */
4203 
4204 /**
4205  * \brief Given a CXFile header file, return the module that contains it, if one
4206  * exists.
4207  */
4208 CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4209 
4210 /**
4211  * \param Module a module object.
4212  *
4213  * \returns the module file where the provided module object came from.
4214  */
4215 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4216 
4217 /**
4218  * \param Module a module object.
4219  *
4220  * \returns the parent of a sub-module or NULL if the given module is top-level,
4221  * e.g. for 'std.vector' it will return the 'std' module.
4222  */
4223 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4224 
4225 /**
4226  * \param Module a module object.
4227  *
4228  * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4229  * will return "vector".
4230  */
4232 
4233 /**
4234  * \param Module a module object.
4235  *
4236  * \returns the full name of the module, e.g. "std.vector".
4237  */
4239 
4240 /**
4241  * \param Module a module object.
4242  *
4243  * \returns non-zero if the module is a system one.
4244  */
4245 CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4246 
4247 /**
4248  * \param Module a module object.
4249  *
4250  * \returns the number of top level headers associated with this module.
4251  */
4252 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4253  CXModule Module);
4254 
4255 /**
4256  * \param Module a module object.
4257  *
4258  * \param Index top level header index (zero-based).
4259  *
4260  * \returns the specified top level header associated with the module.
4261  */
4263 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4264  CXModule Module, unsigned Index);
4265 
4266 /**
4267  * @}
4268  */
4269 
4270 /**
4271  * \defgroup CINDEX_CPP C++ AST introspection
4272  *
4273  * The routines in this group provide access information in the ASTs specific
4274  * to C++ language features.
4275  *
4276  * @{
4277  */
4278 
4279 /**
4280  * \brief Determine if a C++ constructor is a converting constructor.
4281  */
4283 
4284 /**
4285  * \brief Determine if a C++ constructor is a copy constructor.
4286  */
4288 
4289 /**
4290  * \brief Determine if a C++ constructor is the default constructor.
4291  */
4293 
4294 /**
4295  * \brief Determine if a C++ constructor is a move constructor.
4296  */
4298 
4299 /**
4300  * \brief Determine if a C++ field is declared 'mutable'.
4301  */
4303 
4304 /**
4305  * \brief Determine if a C++ method is declared '= default'.
4306  */
4308 
4309 /**
4310  * \brief Determine if a C++ member function or member function template is
4311  * pure virtual.
4312  */
4314 
4315 /**
4316  * \brief Determine if a C++ member function or member function template is
4317  * declared 'static'.
4318  */
4320 
4321 /**
4322  * \brief Determine if a C++ member function or member function template is
4323  * explicitly declared 'virtual' or if it overrides a virtual method from
4324  * one of the base classes.
4325  */
4327 
4328 /**
4329  * \brief Determine if a C++ member function or member function template is
4330  * declared 'const'.
4331  */
4333 
4334 /**
4335  * \brief Given a cursor that represents a template, determine
4336  * the cursor kind of the specializations would be generated by instantiating
4337  * the template.
4338  *
4339  * This routine can be used to determine what flavor of function template,
4340  * class template, or class template partial specialization is stored in the
4341  * cursor. For example, it can describe whether a class template cursor is
4342  * declared with "struct", "class" or "union".
4343  *
4344  * \param C The cursor to query. This cursor should represent a template
4345  * declaration.
4346  *
4347  * \returns The cursor kind of the specializations that would be generated
4348  * by instantiating the template \p C. If \p C is not a template, returns
4349  * \c CXCursor_NoDeclFound.
4350  */
4352 
4353 /**
4354  * \brief Given a cursor that may represent a specialization or instantiation
4355  * of a template, retrieve the cursor that represents the template that it
4356  * specializes or from which it was instantiated.
4357  *
4358  * This routine determines the template involved both for explicit
4359  * specializations of templates and for implicit instantiations of the template,
4360  * both of which are referred to as "specializations". For a class template
4361  * specialization (e.g., \c std::vector<bool>), this routine will return
4362  * either the primary template (\c std::vector) or, if the specialization was
4363  * instantiated from a class template partial specialization, the class template
4364  * partial specialization. For a class template partial specialization and a
4365  * function template specialization (including instantiations), this
4366  * this routine will return the specialized template.
4367  *
4368  * For members of a class template (e.g., member functions, member classes, or
4369  * static data members), returns the specialized or instantiated member.
4370  * Although not strictly "templates" in the C++ language, members of class
4371  * templates have the same notions of specializations and instantiations that
4372  * templates do, so this routine treats them similarly.
4373  *
4374  * \param C A cursor that may be a specialization of a template or a member
4375  * of a template.
4376  *
4377  * \returns If the given cursor is a specialization or instantiation of a
4378  * template or a member thereof, the template or member that it specializes or
4379  * from which it was instantiated. Otherwise, returns a NULL cursor.
4380  */
4382 
4383 /**
4384  * \brief Given a cursor that references something else, return the source range
4385  * covering that reference.
4386  *
4387  * \param C A cursor pointing to a member reference, a declaration reference, or
4388  * an operator call.
4389  * \param NameFlags A bitset with three independent flags:
4390  * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4391  * CXNameRange_WantSinglePiece.
4392  * \param PieceIndex For contiguous names or when passing the flag
4393  * CXNameRange_WantSinglePiece, only one piece with index 0 is
4394  * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4395  * non-contiguous names, this index can be used to retrieve the individual
4396  * pieces of the name. See also CXNameRange_WantSinglePiece.
4397  *
4398  * \returns The piece of the name pointed to by the given cursor. If there is no
4399  * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4400  */
4402  unsigned NameFlags,
4403  unsigned PieceIndex);
4404 
4406  /**
4407  * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4408  * range.
4409  */
4411 
4412  /**
4413  * \brief Include the explicit template arguments, e.g. <int> in x.f<int>,
4414  * in the range.
4415  */
4417 
4418  /**
4419  * \brief If the name is non-contiguous, return the full spanning range.
4420  *
4421  * Non-contiguous names occur in Objective-C when a selector with two or more
4422  * parameters is used, or in C++ when using an operator:
4423  * \code
4424  * [object doSomething:here withValue:there]; // Objective-C
4425  * return some_vector[1]; // C++
4426  * \endcode
4427  */
4429 };
4430 
4431 /**
4432  * @}
4433  */
4434 
4435 /**
4436  * \defgroup CINDEX_LEX Token extraction and manipulation
4437  *
4438  * The routines in this group provide access to the tokens within a
4439  * translation unit, along with a semantic mapping of those tokens to
4440  * their corresponding cursors.
4441  *
4442  * @{
4443  */
4444 
4445 /**
4446  * \brief Describes a kind of token.
4447  */
4448 typedef enum CXTokenKind {
4449  /**
4450  * \brief A token that contains some kind of punctuation.
4451  */
4453 
4454  /**
4455  * \brief A language keyword.
4456  */
4458 
4459  /**
4460  * \brief An identifier (that is not a keyword).
4461  */
4463 
4464  /**
4465  * \brief A numeric, string, or character literal.
4466  */
4468 
4469  /**
4470  * \brief A comment.
4471  */
4473 } CXTokenKind;
4474 
4475 /**
4476  * \brief Describes a single preprocessing token.
4477  */
4478 typedef struct {
4479  unsigned int_data[4];
4480  void *ptr_data;
4481 } CXToken;
4482 
4483 /**
4484  * \brief Determine the kind of the given token.
4485  */
4487 
4488 /**
4489  * \brief Determine the spelling of the given token.
4490  *
4491  * The spelling of a token is the textual representation of that token, e.g.,
4492  * the text of an identifier or keyword.
4493  */
4495 
4496 /**
4497  * \brief Retrieve the source location of the given token.
4498  */
4500  CXToken);
4501 
4502 /**
4503  * \brief Retrieve a source range that covers the given token.
4504  */
4506 
4507 /**
4508  * \brief Tokenize the source code described by the given range into raw
4509  * lexical tokens.
4510  *
4511  * \param TU the translation unit whose text is being tokenized.
4512  *
4513  * \param Range the source range in which text should be tokenized. All of the
4514  * tokens produced by tokenization will fall within this source range,
4515  *
4516  * \param Tokens this pointer will be set to point to the array of tokens
4517  * that occur within the given source range. The returned pointer must be
4518  * freed with clang_disposeTokens() before the translation unit is destroyed.
4519  *
4520  * \param NumTokens will be set to the number of tokens in the \c *Tokens
4521  * array.
4522  *
4523  */
4524 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4525  CXToken **Tokens, unsigned *NumTokens);
4526 
4527 /**
4528  * \brief Annotate the given set of tokens by providing cursors for each token
4529  * that can be mapped to a specific entity within the abstract syntax tree.
4530  *
4531  * This token-annotation routine is equivalent to invoking
4532  * clang_getCursor() for the source locations of each of the
4533  * tokens. The cursors provided are filtered, so that only those
4534  * cursors that have a direct correspondence to the token are
4535  * accepted. For example, given a function call \c f(x),
4536  * clang_getCursor() would provide the following cursors:
4537  *
4538  * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4539  * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4540  * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4541  *
4542  * Only the first and last of these cursors will occur within the
4543  * annotate, since the tokens "f" and "x' directly refer to a function
4544  * and a variable, respectively, but the parentheses are just a small
4545  * part of the full syntax of the function call expression, which is
4546  * not provided as an annotation.
4547  *
4548  * \param TU the translation unit that owns the given tokens.
4549  *
4550  * \param Tokens the set of tokens to annotate.
4551  *
4552  * \param NumTokens the number of tokens in \p Tokens.
4553  *
4554  * \param Cursors an array of \p NumTokens cursors, whose contents will be
4555  * replaced with the cursors corresponding to each token.
4556  */
4557 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4558  CXToken *Tokens, unsigned NumTokens,
4559  CXCursor *Cursors);
4560 
4561 /**
4562  * \brief Free the given set of tokens.
4563  */
4564 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4565  CXToken *Tokens, unsigned NumTokens);
4566 
4567 /**
4568  * @}
4569  */
4570 
4571 /**
4572  * \defgroup CINDEX_DEBUG Debugging facilities
4573  *
4574  * These routines are used for testing and debugging, only, and should not
4575  * be relied upon.
4576  *
4577  * @{
4578  */
4579 
4580 /* for debug/testing */
4583  const char **startBuf,
4584  const char **endBuf,
4585  unsigned *startLine,
4586  unsigned *startColumn,
4587  unsigned *endLine,
4588  unsigned *endColumn);
4590 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4591  unsigned stack_size);
4592 
4593 /**
4594  * @}
4595  */
4596 
4597 /**
4598  * \defgroup CINDEX_CODE_COMPLET Code completion
4599  *
4600  * Code completion involves taking an (incomplete) source file, along with
4601  * knowledge of where the user is actively editing that file, and suggesting
4602  * syntactically- and semantically-valid constructs that the user might want to
4603  * use at that particular point in the source code. These data structures and
4604  * routines provide support for code completion.
4605  *
4606  * @{
4607  */
4608 
4609 /**
4610  * \brief A semantic string that describes a code-completion result.
4611  *
4612  * A semantic string that describes the formatting of a code-completion
4613  * result as a single "template" of text that should be inserted into the
4614  * source buffer when a particular code-completion result is selected.
4615  * Each semantic string is made up of some number of "chunks", each of which
4616  * contains some text along with a description of what that text means, e.g.,
4617  * the name of the entity being referenced, whether the text chunk is part of
4618  * the template, or whether it is a "placeholder" that the user should replace
4619  * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4620  * description of the different kinds of chunks.
4621  */
4622 typedef void *CXCompletionString;
4623 
4624 /**
4625  * \brief A single result of code completion.
4626  */
4627 typedef struct {
4628  /**
4629  * \brief The kind of entity that this completion refers to.
4630  *
4631  * The cursor kind will be a macro, keyword, or a declaration (one of the
4632  * *Decl cursor kinds), describing the entity that the completion is
4633  * referring to.
4634  *
4635  * \todo In the future, we would like to provide a full cursor, to allow
4636  * the client to extract additional information from declaration.
4637  */
4638  enum CXCursorKind CursorKind;
4639 
4640  /**
4641  * \brief The code-completion string that describes how to insert this
4642  * code-completion result into the editing buffer.
4643  */
4644  CXCompletionString CompletionString;
4646 
4647 /**
4648  * \brief Describes a single piece of text within a code-completion string.
4649  *
4650  * Each "chunk" within a code-completion string (\c CXCompletionString) is
4651  * either a piece of text with a specific "kind" that describes how that text
4652  * should be interpreted by the client or is another completion string.
4653  */
4655  /**
4656  * \brief A code-completion string that describes "optional" text that
4657  * could be a part of the template (but is not required).
4658  *
4659  * The Optional chunk is the only kind of chunk that has a code-completion
4660  * string for its representation, which is accessible via
4661  * \c clang_getCompletionChunkCompletionString(). The code-completion string
4662  * describes an additional part of the template that is completely optional.
4663  * For example, optional chunks can be used to describe the placeholders for
4664  * arguments that match up with defaulted function parameters, e.g. given:
4665  *
4666  * \code
4667  * void f(int x, float y = 3.14, double z = 2.71828);
4668  * \endcode
4669  *
4670  * The code-completion string for this function would contain:
4671  * - a TypedText chunk for "f".
4672  * - a LeftParen chunk for "(".
4673  * - a Placeholder chunk for "int x"
4674  * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4675  * - a Comma chunk for ","
4676  * - a Placeholder chunk for "float y"
4677  * - an Optional chunk containing the last defaulted argument:
4678  * - a Comma chunk for ","
4679  * - a Placeholder chunk for "double z"
4680  * - a RightParen chunk for ")"
4681  *
4682  * There are many ways to handle Optional chunks. Two simple approaches are:
4683  * - Completely ignore optional chunks, in which case the template for the
4684  * function "f" would only include the first parameter ("int x").
4685  * - Fully expand all optional chunks, in which case the template for the
4686  * function "f" would have all of the parameters.
4687  */
4689  /**
4690  * \brief Text that a user would be expected to type to get this
4691  * code-completion result.
4692  *
4693  * There will be exactly one "typed text" chunk in a semantic string, which
4694  * will typically provide the spelling of a keyword or the name of a
4695  * declaration that could be used at the current code point. Clients are
4696  * expected to filter the code-completion results based on the text in this
4697  * chunk.
4698  */
4700  /**
4701  * \brief Text that should be inserted as part of a code-completion result.
4702  *
4703  * A "text" chunk represents text that is part of the template to be
4704  * inserted into user code should this particular code-completion result
4705  * be selected.
4706  */
4708  /**
4709  * \brief Placeholder text that should be replaced by the user.
4710  *
4711  * A "placeholder" chunk marks a place where the user should insert text
4712  * into the code-completion template. For example, placeholders might mark
4713  * the function parameters for a function declaration, to indicate that the
4714  * user should provide arguments for each of those parameters. The actual
4715  * text in a placeholder is a suggestion for the text to display before
4716  * the user replaces the placeholder with real code.
4717  */
4719  /**
4720  * \brief Informative text that should be displayed but never inserted as
4721  * part of the template.
4722  *
4723  * An "informative" chunk contains annotations that can be displayed to
4724  * help the user decide whether a particular code-completion result is the
4725  * right option, but which is not part of the actual template to be inserted
4726  * by code completion.
4727  */
4729  /**
4730  * \brief Text that describes the current parameter when code-completion is
4731  * referring to function call, message send, or template specialization.
4732  *
4733  * A "current parameter" chunk occurs when code-completion is providing
4734  * information about a parameter corresponding to the argument at the
4735  * code-completion point. For example, given a function
4736  *
4737  * \code
4738  * int add(int x, int y);
4739  * \endcode
4740  *
4741  * and the source code \c add(, where the code-completion point is after the
4742  * "(", the code-completion string will contain a "current parameter" chunk
4743  * for "int x", indicating that the current argument will initialize that
4744  * parameter. After typing further, to \c add(17, (where the code-completion
4745  * point is after the ","), the code-completion string will contain a
4746  * "current paremeter" chunk to "int y".
4747  */
4749  /**
4750  * \brief A left parenthesis ('('), used to initiate a function call or
4751  * signal the beginning of a function parameter list.
4752  */
4754  /**
4755  * \brief A right parenthesis (')'), used to finish a function call or
4756  * signal the end of a function parameter list.
4757  */
4759  /**
4760  * \brief A left bracket ('[').
4761  */
4763  /**
4764  * \brief A right bracket (']').
4765  */
4767  /**
4768  * \brief A left brace ('{').
4769  */
4771  /**
4772  * \brief A right brace ('}').
4773  */
4775  /**
4776  * \brief A left angle bracket ('<').
4777  */
4779  /**
4780  * \brief A right angle bracket ('>').
4781  */
4783  /**
4784  * \brief A comma separator (',').
4785  */
4787  /**
4788  * \brief Text that specifies the result type of a given result.
4789  *
4790  * This special kind of informative chunk is not meant to be inserted into
4791  * the text buffer. Rather, it is meant to illustrate the type that an
4792  * expression using the given completion string would have.
4793  */
4795  /**
4796  * \brief A colon (':').
4797  */
4799  /**
4800  * \brief A semicolon (';').
4801  */
4803  /**
4804  * \brief An '=' sign.
4805  */
4807  /**
4808  * Horizontal space (' ').
4809  */
4811  /**
4812  * Vertical space ('\\n'), after which it is generally a good idea to
4813  * perform indentation.
4814  */
4816 };
4817 
4818 /**
4819  * \brief Determine the kind of a particular chunk within a completion string.
4820  *
4821  * \param completion_string the completion string to query.
4822  *
4823  * \param chunk_number the 0-based index of the chunk in the completion string.
4824  *
4825  * \returns the kind of the chunk at the index \c chunk_number.
4826  */
4828 clang_getCompletionChunkKind(CXCompletionString completion_string,
4829  unsigned chunk_number);
4830 
4831 /**
4832  * \brief Retrieve the text associated with a particular chunk within a
4833  * completion string.
4834  *
4835  * \param completion_string the completion string to query.
4836  *
4837  * \param chunk_number the 0-based index of the chunk in the completion string.
4838  *
4839  * \returns the text associated with the chunk at index \c chunk_number.
4840  */
4842 clang_getCompletionChunkText(CXCompletionString completion_string,
4843  unsigned chunk_number);
4844 
4845 /**
4846  * \brief Retrieve the completion string associated with a particular chunk
4847  * within a completion string.
4848  *
4849  * \param completion_string the completion string to query.
4850  *
4851  * \param chunk_number the 0-based index of the chunk in the completion string.
4852  *
4853  * \returns the completion string associated with the chunk at index
4854  * \c chunk_number.
4855  */
4856 CINDEX_LINKAGE CXCompletionString
4857 clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4858  unsigned chunk_number);
4859 
4860 /**
4861  * \brief Retrieve the number of chunks in the given code-completion string.
4862  */
4863 CINDEX_LINKAGE unsigned
4864 clang_getNumCompletionChunks(CXCompletionString completion_string);
4865 
4866 /**
4867  * \brief Determine the priority of this code completion.
4868  *
4869  * The priority of a code completion indicates how likely it is that this
4870  * particular completion is the completion that the user will select. The
4871  * priority is selected by various internal heuristics.
4872  *
4873  * \param completion_string The completion string to query.
4874  *
4875  * \returns The priority of this completion string. Smaller values indicate
4876  * higher-priority (more likely) completions.
4877  */
4878 CINDEX_LINKAGE unsigned
4879 clang_getCompletionPriority(CXCompletionString completion_string);
4880 
4881 /**
4882  * \brief Determine the availability of the entity that this code-completion
4883  * string refers to.
4884  *
4885  * \param completion_string The completion string to query.
4886  *
4887  * \returns The availability of the completion string.
4888  */
4890 clang_getCompletionAvailability(CXCompletionString completion_string);
4891 
4892 /**
4893  * \brief Retrieve the number of annotations associated with the given
4894  * completion string.
4895  *
4896  * \param completion_string the completion string to query.
4897  *
4898  * \returns the number of annotations associated with the given completion
4899  * string.
4900  */
4901 CINDEX_LINKAGE unsigned
4902 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
4903 
4904 /**
4905  * \brief Retrieve the annotation associated with the given completion string.
4906  *
4907  * \param completion_string the completion string to query.
4908  *
4909  * \param annotation_number the 0-based index of the annotation of the
4910  * completion string.
4911  *
4912  * \returns annotation string associated with the completion at index
4913  * \c annotation_number, or a NULL string if that annotation is not available.
4914  */
4916 clang_getCompletionAnnotation(CXCompletionString completion_string,
4917  unsigned annotation_number);
4918 
4919 /**
4920  * \brief Retrieve the parent context of the given completion string.
4921  *
4922  * The parent context of a completion string is the semantic parent of
4923  * the declaration (if any) that the code completion represents. For example,
4924  * a code completion for an Objective-C method would have the method's class
4925  * or protocol as its context.
4926  *
4927  * \param completion_string The code completion string whose parent is
4928  * being queried.
4929  *
4930  * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
4931  *
4932  * \returns The name of the completion parent, e.g., "NSObject" if
4933  * the completion string represents a method in the NSObject class.
4934  */
4936 clang_getCompletionParent(CXCompletionString completion_string,
4937  enum CXCursorKind *kind);
4938 
4939 /**
4940  * \brief Retrieve the brief documentation comment attached to the declaration
4941  * that corresponds to the given completion string.
4942  */
4944 clang_getCompletionBriefComment(CXCompletionString completion_string);
4945 
4946 /**
4947  * \brief Retrieve a completion string for an arbitrary declaration or macro
4948  * definition cursor.
4949  *
4950  * \param cursor The cursor to query.
4951  *
4952  * \returns A non-context-sensitive completion string for declaration and macro
4953  * definition cursors, or NULL for other kinds of cursors.
4954  */
4955 CINDEX_LINKAGE CXCompletionString
4957 
4958 /**
4959  * \brief Contains the results of code-completion.
4960  *
4961  * This data structure contains the results of code completion, as
4962  * produced by \c clang_codeCompleteAt(). Its contents must be freed by
4963  * \c clang_disposeCodeCompleteResults.
4964  */
4965 typedef struct {
4966  /**
4967  * \brief The code-completion results.
4968  */
4970 
4971  /**
4972  * \brief The number of code-completion results stored in the
4973  * \c Results array.
4974  */
4975  unsigned NumResults;
4977 
4978 /**
4979  * \brief Flags that can be passed to \c clang_codeCompleteAt() to
4980  * modify its behavior.
4981  *
4982  * The enumerators in this enumeration can be bitwise-OR'd together to
4983  * provide multiple options to \c clang_codeCompleteAt().
4984  */
4986  /**
4987  * \brief Whether to include macros within the set of code
4988  * completions returned.
4989  */
4991 
4992  /**
4993  * \brief Whether to include code patterns for language constructs
4994  * within the set of code completions, e.g., for loops.
4995  */
4997 
4998  /**
4999  * \brief Whether to include brief documentation within the set of code
5000  * completions returned.
5001  */
5003 };
5004 
5005 /**
5006  * \brief Bits that represent the context under which completion is occurring.
5007  *
5008  * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5009  * contexts are occurring simultaneously.
5010  */
5012  /**
5013  * \brief The context for completions is unexposed, as only Clang results
5014  * should be included. (This is equivalent to having no context bits set.)
5015  */
5017 
5018  /**
5019  * \brief Completions for any possible type should be included in the results.
5020  */
5022 
5023  /**
5024  * \brief Completions for any possible value (variables, function calls, etc.)
5025  * should be included in the results.
5026  */
5028  /**
5029  * \brief Completions for values that resolve to an Objective-C object should
5030  * be included in the results.
5031  */
5033  /**
5034  * \brief Completions for values that resolve to an Objective-C selector
5035  * should be included in the results.
5036  */
5038  /**
5039  * \brief Completions for values that resolve to a C++ class type should be
5040  * included in the results.
5041  */
5043 
5044  /**
5045  * \brief Completions for fields of the member being accessed using the dot
5046  * operator should be included in the results.
5047  */
5049  /**
5050  * \brief Completions for fields of the member being accessed using the arrow
5051  * operator should be included in the results.
5052  */
5054  /**
5055  * \brief Completions for properties of the Objective-C object being accessed
5056  * using the dot operator should be included in the results.
5057  */
5059 
5060  /**
5061  * \brief Completions for enum tags should be included in the results.
5062  */
5064  /**
5065  * \brief Completions for union tags should be included in the results.
5066  */
5068  /**
5069  * \brief Completions for struct tags should be included in the results.
5070  */
5072 
5073  /**
5074  * \brief Completions for C++ class names should be included in the results.
5075  */
5077  /**
5078  * \brief Completions for C++ namespaces and namespace aliases should be
5079  * included in the results.
5080  */
5082  /**
5083  * \brief Completions for C++ nested name specifiers should be included in
5084  * the results.
5085  */
5087 
5088  /**
5089  * \brief Completions for Objective-C interfaces (classes) should be included
5090  * in the results.
5091  */
5093  /**
5094  * \brief Completions for Objective-C protocols should be included in
5095  * the results.
5096  */
5098  /**
5099  * \brief Completions for Objective-C categories should be included in
5100  * the results.
5101  */
5103  /**
5104  * \brief Completions for Objective-C instance messages should be included
5105  * in the results.
5106  */
5108  /**
5109  * \brief Completions for Objective-C class messages should be included in
5110  * the results.
5111  */
5113  /**
5114  * \brief Completions for Objective-C selector names should be included in
5115  * the results.
5116  */
5118 
5119  /**
5120  * \brief Completions for preprocessor macro names should be included in
5121  * the results.
5122  */
5124 
5125  /**
5126  * \brief Natural language completions should be included in the results.
5127  */
5129 
5130  /**
5131  * \brief The current context is unknown, so set all contexts.
5132  */
5134 };
5135 
5136 /**
5137  * \brief Returns a default set of code-completion options that can be
5138  * passed to\c clang_codeCompleteAt().
5139  */
5141 
5142 /**
5143  * \brief Perform code completion at a given location in a translation unit.
5144  *
5145  * This function performs code completion at a particular file, line, and
5146  * column within source code, providing results that suggest potential
5147  * code snippets based on the context of the completion. The basic model
5148  * for code completion is that Clang will parse a complete source file,
5149  * performing syntax checking up to the location where code-completion has
5150  * been requested. At that point, a special code-completion token is passed
5151  * to the parser, which recognizes this token and determines, based on the
5152  * current location in the C/Objective-C/C++ grammar and the state of
5153  * semantic analysis, what completions to provide. These completions are
5154  * returned via a new \c CXCodeCompleteResults structure.
5155  *
5156  * Code completion itself is meant to be triggered by the client when the
5157  * user types punctuation characters or whitespace, at which point the
5158  * code-completion location will coincide with the cursor. For example, if \c p
5159  * is a pointer, code-completion might be triggered after the "-" and then
5160  * after the ">" in \c p->. When the code-completion location is afer the ">",
5161  * the completion results will provide, e.g., the members of the struct that
5162  * "p" points to. The client is responsible for placing the cursor at the
5163  * beginning of the token currently being typed, then filtering the results
5164  * based on the contents of the token. For example, when code-completing for
5165  * the expression \c p->get, the client should provide the location just after
5166  * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5167  * client can filter the results based on the current token text ("get"), only
5168  * showing those results that start with "get". The intent of this interface
5169  * is to separate the relatively high-latency acquisition of code-completion
5170  * results from the filtering of results on a per-character basis, which must
5171  * have a lower latency.
5172  *
5173  * \param TU The translation unit in which code-completion should
5174  * occur. The source files for this translation unit need not be
5175  * completely up-to-date (and the contents of those source files may
5176  * be overridden via \p unsaved_files). Cursors referring into the
5177  * translation unit may be invalidated by this invocation.
5178  *
5179  * \param complete_filename The name of the source file where code
5180  * completion should be performed. This filename may be any file
5181  * included in the translation unit.
5182  *
5183  * \param complete_line The line at which code-completion should occur.
5184  *
5185  * \param complete_column The column at which code-completion should occur.
5186  * Note that the column should point just after the syntactic construct that
5187  * initiated code completion, and not in the middle of a lexical token.
5188  *
5189  * \param unsaved_files the Files that have not yet been saved to disk
5190  * but may be required for parsing or code completion, including the
5191  * contents of those files. The contents and name of these files (as
5192  * specified by CXUnsavedFile) are copied when necessary, so the
5193  * client only needs to guarantee their validity until the call to
5194  * this function returns.
5195  *
5196  * \param num_unsaved_files The number of unsaved file entries in \p
5197  * unsaved_files.
5198  *
5199  * \param options Extra options that control the behavior of code
5200  * completion, expressed as a bitwise OR of the enumerators of the
5201  * CXCodeComplete_Flags enumeration. The
5202  * \c clang_defaultCodeCompleteOptions() function returns a default set
5203  * of code-completion options.
5204  *
5205  * \returns If successful, a new \c CXCodeCompleteResults structure
5206  * containing code-completion results, which should eventually be
5207  * freed with \c clang_disposeCodeCompleteResults(). If code
5208  * completion fails, returns NULL.
5209  */
5211 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5212  const char *complete_filename,
5213  unsigned complete_line,
5214  unsigned complete_column,
5215  struct CXUnsavedFile *unsaved_files,
5216  unsigned num_unsaved_files,
5217  unsigned options);
5218 
5219 /**
5220  * \brief Sort the code-completion results in case-insensitive alphabetical
5221  * order.
5222  *
5223  * \param Results The set of results to sort.
5224  * \param NumResults The number of results in \p Results.
5225  */
5228  unsigned NumResults);
5229 
5230 /**
5231  * \brief Free the given set of code-completion results.
5232  */
5235 
5236 /**
5237  * \brief Determine the number of diagnostics produced prior to the
5238  * location where code completion was performed.
5239  */
5242 
5243 /**
5244  * \brief Retrieve a diagnostic associated with the given code completion.
5245  *
5246  * \param Results the code completion results to query.
5247  * \param Index the zero-based diagnostic number to retrieve.
5248  *
5249  * \returns the requested diagnostic. This diagnostic must be freed
5250  * via a call to \c clang_disposeDiagnostic().
5251  */
5254  unsigned Index);
5255 
5256 /**
5257  * \brief Determines what completions are appropriate for the context
5258  * the given code completion.
5259  *
5260  * \param Results the code completion results to query
5261  *
5262  * \returns the kinds of completions that are appropriate for use
5263  * along with the given code completion results.
5264  */
5266 unsigned long long clang_codeCompleteGetContexts(
5267  CXCodeCompleteResults *Results);
5268 
5269 /**
5270  * \brief Returns the cursor kind for the container for the current code
5271  * completion context. The container is only guaranteed to be set for
5272  * contexts where a container exists (i.e. member accesses or Objective-C
5273  * message sends); if there is not a container, this function will return
5274  * CXCursor_InvalidCode.
5275  *
5276  * \param Results the code completion results to query
5277  *
5278  * \param IsIncomplete on return, this value will be false if Clang has complete
5279  * information about the container. If Clang does not have complete
5280  * information, this value will be true.
5281  *
5282  * \returns the container kind, or CXCursor_InvalidCode if there is not a
5283  * container
5284  */
5287  CXCodeCompleteResults *Results,
5288  unsigned *IsIncomplete);
5289 
5290 /**
5291  * \brief Returns the USR for the container for the current code completion
5292  * context. If there is not a container for the current context, this
5293  * function will return the empty string.
5294  *
5295  * \param Results the code completion results to query
5296  *
5297  * \returns the USR for the container
5298  */
5301 
5302 /**
5303  * \brief Returns the currently-entered selector for an Objective-C message
5304  * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5305  * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5306  * CXCompletionContext_ObjCClassMessage.
5307  *
5308  * \param Results the code completion results to query
5309  *
5310  * \returns the selector (or partial selector) that has been entered thus far
5311  * for an Objective-C message send.
5312  */
5315 
5316 /**
5317  * @}
5318  */
5319 
5320 /**
5321  * \defgroup CINDEX_MISC Miscellaneous utility functions
5322  *
5323  * @{
5324  */
5325 
5326 /**
5327  * \brief Return a version string, suitable for showing to a user, but not
5328  * intended to be parsed (the format is not guaranteed to be stable).
5329  */
5331 
5332 /**
5333  * \brief Enable/disable crash recovery.
5334  *
5335  * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5336  * value enables crash recovery, while 0 disables it.
5337  */
5339 
5340  /**
5341  * \brief Visitor invoked for each file in a translation unit
5342  * (used with clang_getInclusions()).
5343  *
5344  * This visitor function will be invoked by clang_getInclusions() for each
5345  * file included (either at the top-level or by \#include directives) within
5346  * a translation unit. The first argument is the file being included, and
5347  * the second and third arguments provide the inclusion stack. The
5348  * array is sorted in order of immediate inclusion. For example,
5349  * the first element refers to the location that included 'included_file'.
5350  */
5351 typedef void (*CXInclusionVisitor)(CXFile included_file,
5352  CXSourceLocation* inclusion_stack,
5353  unsigned include_len,
5354  CXClientData client_data);
5355 
5356 /**
5357  * \brief Visit the set of preprocessor inclusions in a translation unit.
5358  * The visitor function is called with the provided data for every included
5359  * file. This does not include headers included by the PCH file (unless one
5360  * is inspecting the inclusions in the PCH file itself).
5361  */
5362 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5363  CXInclusionVisitor visitor,
5364  CXClientData client_data);
5365 
5366 typedef enum {
5373 
5375 
5376 } CXEvalResultKind ;
5377 
5378 /**
5379  * \brief Evaluation result of a cursor
5380  */
5381 typedef void * CXEvalResult;
5382 
5383 /**
5384  * \brief If cursor is a statement declaration tries to evaluate the
5385  * statement and if its variable, tries to evaluate its initializer,
5386  * into its corresponding type.
5387  */
5389 
5390 /**
5391  * \brief Returns the kind of the evaluated result.
5392  */
5394 
5395 /**
5396  * \brief Returns the evaluation result as integer if the
5397  * kind is Int.
5398  */
5399 CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5400 
5401 /**
5402  * \brief Returns the evaluation result as a long long integer if the
5403  * kind is Int. This prevents overflows that may happen if the result is
5404  * returned with clang_EvalResult_getAsInt.
5405  */
5406 CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5407 
5408 /**
5409  * \brief Returns a non-zero value if the kind is Int and the evaluation
5410  * result resulted in an unsigned integer.
5411  */
5412 CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5413 
5414 /**
5415  * \brief Returns the evaluation result as an unsigned integer if
5416  * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5417  */
5418 CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5419 
5420 /**
5421  * \brief Returns the evaluation result as double if the
5422  * kind is double.
5423  */
5424 CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5425 
5426 /**
5427  * \brief Returns the evaluation result as a constant string if the
5428  * kind is other than Int or float. User must not free this pointer,
5429  * instead call clang_EvalResult_dispose on the CXEvalResult returned
5430  * by clang_Cursor_Evaluate.
5431  */
5432 CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
5433 
5434 /**
5435  * \brief Disposes the created Eval memory.
5436  */
5437 CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5438 /**
5439  * @}
5440  */
5441 
5442 /** \defgroup CINDEX_REMAPPING Remapping functions
5443  *
5444  * @{
5445  */
5446 
5447 /**
5448  * \brief A remapping of original source files and their translated files.
5449  */
5450 typedef void *CXRemapping;
5451 
5452 /**
5453  * \brief Retrieve a remapping.
5454  *
5455  * \param path the path that contains metadata about remappings.
5456  *
5457  * \returns the requested remapping. This remapping must be freed
5458  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5459  */
5460 CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5461 
5462 /**
5463  * \brief Retrieve a remapping.
5464  *
5465  * \param filePaths pointer to an array of file paths containing remapping info.
5466  *
5467  * \param numFiles number of file paths.
5468  *
5469  * \returns the requested remapping. This remapping must be freed
5470  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5471  */
5473 CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5474  unsigned numFiles);
5475 
5476 /**
5477  * \brief Determine the number of remappings.
5478  */
5479 CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5480 
5481 /**
5482  * \brief Get the original and the associated filename from the remapping.
5483  *
5484  * \param original If non-NULL, will be set to the original filename.
5485  *
5486  * \param transformed If non-NULL, will be set to the filename that the original
5487  * is associated with.
5488  */
5489 CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5490  CXString *original, CXString *transformed);
5491 
5492 /**
5493  * \brief Dispose the remapping.
5494  */
5495 CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5496 
5497 /**
5498  * @}
5499  */
5500 
5501 /** \defgroup CINDEX_HIGH Higher level API functions
5502  *
5503  * @{
5504  */
5505 
5509 };
5510 
5511 typedef struct CXCursorAndRangeVisitor {
5512  void *context;
5513  enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5515 
5516 typedef enum {
5517  /**
5518  * \brief Function returned successfully.
5519  */
5521  /**
5522  * \brief One of the parameters was invalid for the function.
5523  */
5525  /**
5526  * \brief The function was terminated by a callback (e.g. it returned
5527  * CXVisit_Break)
5528  */
5530 
5531 } CXResult;
5532 
5533 /**
5534  * \brief Find references of a declaration in a specific file.
5535  *
5536  * \param cursor pointing to a declaration or a reference of one.
5537  *
5538  * \param file to search for references.
5539  *
5540  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5541  * each reference found.
5542  * The CXSourceRange will point inside the file; if the reference is inside
5543  * a macro (and not a macro argument) the CXSourceRange will be invalid.
5544  *
5545  * \returns one of the CXResult enumerators.
5546  */
5548  CXCursorAndRangeVisitor visitor);
5549 
5550 /**
5551  * \brief Find #import/#include directives in a specific file.
5552  *
5553  * \param TU translation unit containing the file to query.
5554  *
5555  * \param file to search for #import/#include directives.
5556  *
5557  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5558  * each directive found.
5559  *
5560  * \returns one of the CXResult enumerators.
5561  */
5562 CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5563  CXFile file,
5564  CXCursorAndRangeVisitor visitor);
5565 
5566 #ifdef __has_feature
5567 # if __has_feature(blocks)
5568 
5569 typedef enum CXVisitorResult
5570  (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5571 
5573 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5574  CXCursorAndRangeVisitorBlock);
5575 
5577 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5578  CXCursorAndRangeVisitorBlock);
5579 
5580 # endif
5581 #endif
5582 
5583 /**
5584  * \brief The client's data object that is associated with a CXFile.
5585  */
5586 typedef void *CXIdxClientFile;
5587 
5588 /**
5589  * \brief The client's data object that is associated with a semantic entity.
5590  */
5591 typedef void *CXIdxClientEntity;
5592 
5593 /**
5594  * \brief The client's data object that is associated with a semantic container
5595  * of entities.
5596  */
5597 typedef void *CXIdxClientContainer;
5598 
5599 /**
5600  * \brief The client's data object that is associated with an AST file (PCH
5601  * or module).
5602  */
5603 typedef void *CXIdxClientASTFile;
5604 
5605 /**
5606  * \brief Source location passed to index callbacks.
5607  */
5608 typedef struct {
5609  void *ptr_data[2];
5610  unsigned int_data;
5611 } CXIdxLoc;
5612 
5613 /**
5614  * \brief Data for ppIncludedFile callback.
5615  */
5616 typedef struct {
5617  /**
5618  * \brief Location of '#' in the \#include/\#import directive.
5619  */
5621  /**
5622  * \brief Filename as written in the \#include/\#import directive.
5623  */
5624  const char *filename;
5625  /**
5626  * \brief The actual file that the \#include/\#import directive resolved to.
5627  */
5628  CXFile file;
5631  /**
5632  * \brief Non-zero if the directive was automatically turned into a module
5633  * import.
5634  */
5637 
5638 /**
5639  * \brief Data for IndexerCallbacks#importedASTFile.
5640  */
5641 typedef struct {
5642  /**
5643  * \brief Top level AST file containing the imported PCH, module or submodule.
5644  */
5645  CXFile file;
5646  /**
5647  * \brief The imported module or NULL if the AST file is a PCH.
5648  */
5649  CXModule module;
5650  /**
5651  * \brief Location where the file is imported. Applicable only for modules.
5652  */
5654  /**
5655  * \brief Non-zero if an inclusion directive was automatically turned into
5656  * a module import. Applicable only for modules.
5657  */
5659 
5661 
5662 typedef enum {
5669 
5673 
5678 
5682 
5694 
5695 } CXIdxEntityKind;
5696 
5697 typedef enum {
5704 
5705 /**
5706  * \brief Extra C++ template information for an entity. This can apply to: