clang  7.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 interface to a Clang library for extracting *|
11 |* high-level symbol information from source files without exposing the full *|
12 |* Clang C++ API. *|
13 |* *|
14 \*===----------------------------------------------------------------------===*/
15 
16 #ifndef LLVM_CLANG_C_INDEX_H
17 #define LLVM_CLANG_C_INDEX_H
18 
19 #include <time.h>
20 
21 #include "clang-c/Platform.h"
22 #include "clang-c/CXErrorCode.h"
23 #include "clang-c/CXString.h"
24 #include "clang-c/BuildSystem.h"
25 
26 /**
27  * 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 48
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  * 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  * An opaque type representing target information for a given translation
85  * unit.
86  */
87 typedef struct CXTargetInfoImpl *CXTargetInfo;
88 
89 /**
90  * A single translation unit, which resides in an index.
91  */
92 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
93 
94 /**
95  * Opaque pointer representing client data that will be passed through
96  * to various callbacks and visitors.
97  */
98 typedef void *CXClientData;
99 
100 /**
101  * 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  * 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  * A buffer containing the unsaved contents of this file.
117  */
118  const char *Contents;
119 
120  /**
121  * The length of the unsaved contents of this buffer.
122  */
123  unsigned long Length;
124 };
125 
126 /**
127  * 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  * The entity is available.
134  */
136  /**
137  * The entity is available, but has been deprecated (and its use is
138  * not recommended).
139  */
141  /**
142  * The entity is not available; any use of it will be an error.
143  */
145  /**
146  * The entity is available, but not accessible; any use of it will be
147  * an error.
148  */
150 };
151 
152 /**
153  * Describes a version number of the form major.minor.subminor.
154  */
155 typedef struct CXVersion {
156  /**
157  * 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  * 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  * 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  * Describes the exception specification of a cursor.
177  *
178  * A negative value indicates that the cursor is not a function declaration.
179  */
181 
182  /**
183  * The cursor has no exception specification.
184  */
186 
187  /**
188  * The cursor has exception specification throw()
189  */
191 
192  /**
193  * The cursor has exception specification throw(T1, T2)
194  */
196 
197  /**
198  * The cursor has exception specification throw(...).
199  */
201 
202  /**
203  * The cursor has exception specification basic noexcept.
204  */
206 
207  /**
208  * The cursor has exception specification computed noexcept.
209  */
211 
212  /**
213  * The exception specification has not yet been evaluated.
214  */
216 
217  /**
218  * The exception specification has not yet been instantiated.
219  */
221 
222  /**
223  * The exception specification has not been parsed yet.
224  */
226 };
227 
228 /**
229  * Provides a shared context for creating translation units.
230  *
231  * It provides two options:
232  *
233  * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
234  * declarations (when loading any new translation units). A "local" declaration
235  * is one that belongs in the translation unit itself and not in a precompiled
236  * header that was used by the translation unit. If zero, all declarations
237  * will be enumerated.
238  *
239  * Here is an example:
240  *
241  * \code
242  * // excludeDeclsFromPCH = 1, displayDiagnostics=1
243  * Idx = clang_createIndex(1, 1);
244  *
245  * // IndexTest.pch was produced with the following command:
246  * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
247  * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
248  *
249  * // This will load all the symbols from 'IndexTest.pch'
250  * clang_visitChildren(clang_getTranslationUnitCursor(TU),
251  * TranslationUnitVisitor, 0);
252  * clang_disposeTranslationUnit(TU);
253  *
254  * // This will load all the symbols from 'IndexTest.c', excluding symbols
255  * // from 'IndexTest.pch'.
256  * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
257  * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
258  * 0, 0);
259  * clang_visitChildren(clang_getTranslationUnitCursor(TU),
260  * TranslationUnitVisitor, 0);
261  * clang_disposeTranslationUnit(TU);
262  * \endcode
263  *
264  * This process of creating the 'pch', loading it separately, and using it (via
265  * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
266  * (which gives the indexer the same performance benefit as the compiler).
267  */
268 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
269  int displayDiagnostics);
270 
271 /**
272  * Destroy the given index.
273  *
274  * The index must not be destroyed until all of the translation units created
275  * within that index have been destroyed.
276  */
277 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
278 
279 typedef enum {
280  /**
281  * Used to indicate that no special CXIndex options are needed.
282  */
284 
285  /**
286  * Used to indicate that threads that libclang creates for indexing
287  * purposes should use background priority.
288  *
289  * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
290  * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
291  */
293 
294  /**
295  * Used to indicate that threads that libclang creates for editing
296  * purposes should use background priority.
297  *
298  * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
299  * #clang_annotateTokens
300  */
302 
303  /**
304  * Used to indicate that all threads that libclang creates should use
305  * background priority.
306  */
310 
312 
313 /**
314  * Sets general options associated with a CXIndex.
315  *
316  * For example:
317  * \code
318  * CXIndex idx = ...;
319  * clang_CXIndex_setGlobalOptions(idx,
320  * clang_CXIndex_getGlobalOptions(idx) |
321  * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
322  * \endcode
323  *
324  * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
325  */
326 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
327 
328 /**
329  * Gets the general options associated with a CXIndex.
330  *
331  * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
332  * are associated with the given CXIndex object.
333  */
335 
336 /**
337  * Sets the invocation emission path option in a CXIndex.
338  *
339  * The invocation emission path specifies a path which will contain log
340  * files for certain libclang invocations. A null value (default) implies that
341  * libclang invocations are not logged..
342  */
343 CINDEX_LINKAGE void
344 clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
345 
346 /**
347  * \defgroup CINDEX_FILES File manipulation routines
348  *
349  * @{
350  */
351 
352 /**
353  * A particular source file that is part of a translation unit.
354  */
355 typedef void *CXFile;
356 
357 /**
358  * Retrieve the complete file and path name of the given file.
359  */
361 
362 /**
363  * Retrieve the last modification time of the given file.
364  */
365 CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
366 
367 /**
368  * Uniquely identifies a CXFile, that refers to the same underlying file,
369  * across an indexing session.
370  */
371 typedef struct {
372  unsigned long long data[3];
374 
375 /**
376  * Retrieve the unique ID for the given \c file.
377  *
378  * \param file the file to get the ID for.
379  * \param outID stores the returned CXFileUniqueID.
380  * \returns If there was a failure getting the unique ID, returns non-zero,
381  * otherwise returns 0.
382 */
383 CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
384 
385 /**
386  * Determine whether the given header is guarded against
387  * multiple inclusions, either with the conventional
388  * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
389  */
390 CINDEX_LINKAGE unsigned
391 clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
392 
393 /**
394  * Retrieve a file handle within the given translation unit.
395  *
396  * \param tu the translation unit
397  *
398  * \param file_name the name of the file.
399  *
400  * \returns the file handle for the named file in the translation unit \p tu,
401  * or a NULL file handle if the file was not a part of this translation unit.
402  */
403 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
404  const char *file_name);
405 
406 /**
407  * Retrieve the buffer associated with the given file.
408  *
409  * \param tu the translation unit
410  *
411  * \param file the file for which to retrieve the buffer.
412  *
413  * \param size [out] if non-NULL, will be set to the size of the buffer.
414  *
415  * \returns a pointer to the buffer in memory that holds the contents of
416  * \p file, or a NULL pointer when the file is not loaded.
417  */
418 CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
419  CXFile file, size_t *size);
420 
421 /**
422  * Returns non-zero if the \c file1 and \c file2 point to the same file,
423  * or they are both NULL.
424  */
425 CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
426 
427 /**
428  * Returns the real path name of \c file.
429  *
430  * An empty string may be returned. Use \c clang_getFileName() in that case.
431  */
433 
434 /**
435  * @}
436  */
437 
438 /**
439  * \defgroup CINDEX_LOCATIONS Physical source locations
440  *
441  * Clang represents physical source locations in its abstract syntax tree in
442  * great detail, with file, line, and column information for the majority of
443  * the tokens parsed in the source code. These data types and functions are
444  * used to represent source location information, either for a particular
445  * point in the program or for a range of points in the program, and extract
446  * specific location information from those data types.
447  *
448  * @{
449  */
450 
451 /**
452  * Identifies a specific source location within a translation
453  * unit.
454  *
455  * Use clang_getExpansionLocation() or clang_getSpellingLocation()
456  * to map a source location to a particular file, line, and column.
457  */
458 typedef struct {
459  const void *ptr_data[2];
460  unsigned int_data;
462 
463 /**
464  * Identifies a half-open character range in the source code.
465  *
466  * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
467  * starting and end locations from a source range, respectively.
468  */
469 typedef struct {
470  const void *ptr_data[2];
471  unsigned begin_int_data;
472  unsigned end_int_data;
473 } CXSourceRange;
474 
475 /**
476  * Retrieve a NULL (invalid) source location.
477  */
479 
480 /**
481  * Determine whether two source locations, which must refer into
482  * the same translation unit, refer to exactly the same point in the source
483  * code.
484  *
485  * \returns non-zero if the source locations refer to the same location, zero
486  * if they refer to different locations.
487  */
489  CXSourceLocation loc2);
490 
491 /**
492  * Retrieves the source location associated with a given file/line/column
493  * in a particular translation unit.
494  */
496  CXFile file,
497  unsigned line,
498  unsigned column);
499 /**
500  * Retrieves the source location associated with a given character offset
501  * in a particular translation unit.
502  */
504  CXFile file,
505  unsigned offset);
506 
507 /**
508  * Returns non-zero if the given source location is in a system header.
509  */
511 
512 /**
513  * Returns non-zero if the given source location is in the main file of
514  * the corresponding translation unit.
515  */
517 
518 /**
519  * Retrieve a NULL (invalid) source range.
520  */
522 
523 /**
524  * Retrieve a source range given the beginning and ending source
525  * locations.
526  */
528  CXSourceLocation end);
529 
530 /**
531  * Determine whether two ranges are equivalent.
532  *
533  * \returns non-zero if the ranges are the same, zero if they differ.
534  */
536  CXSourceRange range2);
537 
538 /**
539  * Returns non-zero if \p range is null.
540  */
542 
543 /**
544  * Retrieve the file, line, column, and offset represented by
545  * the given source location.
546  *
547  * If the location refers into a macro expansion, retrieves the
548  * location of the macro expansion.
549  *
550  * \param location the location within a source file that will be decomposed
551  * into its parts.
552  *
553  * \param file [out] if non-NULL, will be set to the file to which the given
554  * source location points.
555  *
556  * \param line [out] if non-NULL, will be set to the line to which the given
557  * source location points.
558  *
559  * \param column [out] if non-NULL, will be set to the column to which the given
560  * source location points.
561  *
562  * \param offset [out] if non-NULL, will be set to the offset into the
563  * buffer to which the given source location points.
564  */
566  CXFile *file,
567  unsigned *line,
568  unsigned *column,
569  unsigned *offset);
570 
571 /**
572  * Retrieve the file, line and column represented by the given source
573  * location, as specified in a # line directive.
574  *
575  * Example: given the following source code in a file somefile.c
576  *
577  * \code
578  * #123 "dummy.c" 1
579  *
580  * static int func(void)
581  * {
582  * return 0;
583  * }
584  * \endcode
585  *
586  * the location information returned by this function would be
587  *
588  * File: dummy.c Line: 124 Column: 12
589  *
590  * whereas clang_getExpansionLocation would have returned
591  *
592  * File: somefile.c Line: 3 Column: 12
593  *
594  * \param location the location within a source file that will be decomposed
595  * into its parts.
596  *
597  * \param filename [out] if non-NULL, will be set to the filename of the
598  * source location. Note that filenames returned will be for "virtual" files,
599  * which don't necessarily exist on the machine running clang - e.g. when
600  * parsing preprocessed output obtained from a different environment. If
601  * a non-NULL value is passed in, remember to dispose of the returned value
602  * using \c clang_disposeString() once you've finished with it. For an invalid
603  * source location, an empty string is returned.
604  *
605  * \param line [out] if non-NULL, will be set to the line number of the
606  * source location. For an invalid source location, zero is returned.
607  *
608  * \param column [out] if non-NULL, will be set to the column number of the
609  * source location. For an invalid source location, zero is returned.
610  */
612  CXString *filename,
613  unsigned *line,
614  unsigned *column);
615 
616 /**
617  * Legacy API to retrieve the file, line, column, and offset represented
618  * by the given source location.
619  *
620  * This interface has been replaced by the newer interface
621  * #clang_getExpansionLocation(). See that interface's documentation for
622  * details.
623  */
625  CXFile *file,
626  unsigned *line,
627  unsigned *column,
628  unsigned *offset);
629 
630 /**
631  * Retrieve the file, line, column, and offset represented by
632  * the given source location.
633  *
634  * If the location refers into a macro instantiation, return where the
635  * location was originally spelled in the source file.
636  *
637  * \param location the location within a source file that will be decomposed
638  * into its parts.
639  *
640  * \param file [out] if non-NULL, will be set to the file to which the given
641  * source location points.
642  *
643  * \param line [out] if non-NULL, will be set to the line to which the given
644  * source location points.
645  *
646  * \param column [out] if non-NULL, will be set to the column to which the given
647  * source location points.
648  *
649  * \param offset [out] if non-NULL, will be set to the offset into the
650  * buffer to which the given source location points.
651  */
653  CXFile *file,
654  unsigned *line,
655  unsigned *column,
656  unsigned *offset);
657 
658 /**
659  * Retrieve the file, line, column, and offset represented by
660  * the given source location.
661  *
662  * If the location refers into a macro expansion, return where the macro was
663  * expanded or where the macro argument was written, if the location points at
664  * a macro argument.
665  *
666  * \param location the location within a source file that will be decomposed
667  * into its parts.
668  *
669  * \param file [out] if non-NULL, will be set to the file to which the given
670  * source location points.
671  *
672  * \param line [out] if non-NULL, will be set to the line to which the given
673  * source location points.
674  *
675  * \param column [out] if non-NULL, will be set to the column to which the given
676  * source location points.
677  *
678  * \param offset [out] if non-NULL, will be set to the offset into the
679  * buffer to which the given source location points.
680  */
682  CXFile *file,
683  unsigned *line,
684  unsigned *column,
685  unsigned *offset);
686 
687 /**
688  * Retrieve a source location representing the first character within a
689  * source range.
690  */
692 
693 /**
694  * Retrieve a source location representing the last character within a
695  * source range.
696  */
698 
699 /**
700  * Identifies an array of ranges.
701  */
702 typedef struct {
703  /** The number of ranges in the \c ranges array. */
704  unsigned count;
705  /**
706  * An array of \c CXSourceRanges.
707  */
710 
711 /**
712  * Retrieve all ranges that were skipped by the preprocessor.
713  *
714  * The preprocessor will skip lines when they are surrounded by an
715  * if/ifdef/ifndef directive whose condition does not evaluate to true.
716  */
718  CXFile file);
719 
720 /**
721  * Retrieve all ranges from all files that were skipped by the
722  * preprocessor.
723  *
724  * The preprocessor will skip lines when they are surrounded by an
725  * if/ifdef/ifndef directive whose condition does not evaluate to true.
726  */
728 
729 /**
730  * Destroy the given \c CXSourceRangeList.
731  */
733 
734 /**
735  * @}
736  */
737 
738 /**
739  * \defgroup CINDEX_DIAG Diagnostic reporting
740  *
741  * @{
742  */
743 
744 /**
745  * Describes the severity of a particular diagnostic.
746  */
748  /**
749  * A diagnostic that has been suppressed, e.g., by a command-line
750  * option.
751  */
753 
754  /**
755  * This diagnostic is a note that should be attached to the
756  * previous (non-note) diagnostic.
757  */
759 
760  /**
761  * This diagnostic indicates suspicious code that may not be
762  * wrong.
763  */
765 
766  /**
767  * This diagnostic indicates that the code is ill-formed.
768  */
770 
771  /**
772  * This diagnostic indicates that the code is ill-formed such
773  * that future parser recovery is unlikely to produce useful
774  * results.
775  */
777 };
778 
779 /**
780  * A single diagnostic, containing the diagnostic's severity,
781  * location, text, source ranges, and fix-it hints.
782  */
783 typedef void *CXDiagnostic;
784 
785 /**
786  * A group of CXDiagnostics.
787  */
788 typedef void *CXDiagnosticSet;
789 
790 /**
791  * Determine the number of diagnostics in a CXDiagnosticSet.
792  */
793 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
794 
795 /**
796  * Retrieve a diagnostic associated with the given CXDiagnosticSet.
797  *
798  * \param Diags the CXDiagnosticSet to query.
799  * \param Index the zero-based diagnostic number to retrieve.
800  *
801  * \returns the requested diagnostic. This diagnostic must be freed
802  * via a call to \c clang_disposeDiagnostic().
803  */
804 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
805  unsigned Index);
806 
807 /**
808  * Describes the kind of error that occurred (if any) in a call to
809  * \c clang_loadDiagnostics.
810  */
812  /**
813  * Indicates that no error occurred.
814  */
816 
817  /**
818  * Indicates that an unknown error occurred while attempting to
819  * deserialize diagnostics.
820  */
822 
823  /**
824  * Indicates that the file containing the serialized diagnostics
825  * could not be opened.
826  */
828 
829  /**
830  * Indicates that the serialized diagnostics file is invalid or
831  * corrupt.
832  */
834 };
835 
836 /**
837  * Deserialize a set of diagnostics from a Clang diagnostics bitcode
838  * file.
839  *
840  * \param file The name of the file to deserialize.
841  * \param error A pointer to a enum value recording if there was a problem
842  * deserializing the diagnostics.
843  * \param errorString A pointer to a CXString for recording the error string
844  * if the file was not successfully loaded.
845  *
846  * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
847  * diagnostics should be released using clang_disposeDiagnosticSet().
848  */
849 CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
850  enum CXLoadDiag_Error *error,
851  CXString *errorString);
852 
853 /**
854  * Release a CXDiagnosticSet and all of its contained diagnostics.
855  */
856 CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
857 
858 /**
859  * Retrieve the child diagnostics of a CXDiagnostic.
860  *
861  * This CXDiagnosticSet does not need to be released by
862  * clang_disposeDiagnosticSet.
863  */
864 CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
865 
866 /**
867  * Determine the number of diagnostics produced for the given
868  * translation unit.
869  */
870 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
871 
872 /**
873  * Retrieve a diagnostic associated with the given translation unit.
874  *
875  * \param Unit the translation unit to query.
876  * \param Index the zero-based diagnostic number to retrieve.
877  *
878  * \returns the requested diagnostic. This diagnostic must be freed
879  * via a call to \c clang_disposeDiagnostic().
880  */
881 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
882  unsigned Index);
883 
884 /**
885  * Retrieve the complete set of diagnostics associated with a
886  * translation unit.
887  *
888  * \param Unit the translation unit to query.
889  */
890 CINDEX_LINKAGE CXDiagnosticSet
891  clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
892 
893 /**
894  * Destroy a diagnostic.
895  */
896 CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
897 
898 /**
899  * Options to control the display of diagnostics.
900  *
901  * The values in this enum are meant to be combined to customize the
902  * behavior of \c clang_formatDiagnostic().
903  */
905  /**
906  * Display the source-location information where the
907  * diagnostic was located.
908  *
909  * When set, diagnostics will be prefixed by the file, line, and
910  * (optionally) column to which the diagnostic refers. For example,
911  *
912  * \code
913  * test.c:28: warning: extra tokens at end of #endif directive
914  * \endcode
915  *
916  * This option corresponds to the clang flag \c -fshow-source-location.
917  */
919 
920  /**
921  * If displaying the source-location information of the
922  * diagnostic, also include the column number.
923  *
924  * This option corresponds to the clang flag \c -fshow-column.
925  */
927 
928  /**
929  * If displaying the source-location information of the
930  * diagnostic, also include information about source ranges in a
931  * machine-parsable format.
932  *
933  * This option corresponds to the clang flag
934  * \c -fdiagnostics-print-source-range-info.
935  */
937 
938  /**
939  * Display the option name associated with this diagnostic, if any.
940  *
941  * The option name displayed (e.g., -Wconversion) will be placed in brackets
942  * after the diagnostic text. This option corresponds to the clang flag
943  * \c -fdiagnostics-show-option.
944  */
946 
947  /**
948  * Display the category number associated with this diagnostic, if any.
949  *
950  * The category number is displayed within brackets after the diagnostic text.
951  * This option corresponds to the clang flag
952  * \c -fdiagnostics-show-category=id.
953  */
955 
956  /**
957  * Display the category name associated with this diagnostic, if any.
958  *
959  * The category name is displayed within brackets after the diagnostic text.
960  * This option corresponds to the clang flag
961  * \c -fdiagnostics-show-category=name.
962  */
964 };
965 
966 /**
967  * Format the given diagnostic in a manner that is suitable for display.
968  *
969  * This routine will format the given diagnostic to a string, rendering
970  * the diagnostic according to the various options given. The
971  * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
972  * options that most closely mimics the behavior of the clang compiler.
973  *
974  * \param Diagnostic The diagnostic to print.
975  *
976  * \param Options A set of options that control the diagnostic display,
977  * created by combining \c CXDiagnosticDisplayOptions values.
978  *
979  * \returns A new string containing for formatted diagnostic.
980  */
981 CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
982  unsigned Options);
983 
984 /**
985  * Retrieve the set of display options most similar to the
986  * default behavior of the clang compiler.
987  *
988  * \returns A set of display options suitable for use with \c
989  * clang_formatDiagnostic().
990  */
992 
993 /**
994  * Determine the severity of the given diagnostic.
995  */
997 clang_getDiagnosticSeverity(CXDiagnostic);
998 
999 /**
1000  * Retrieve the source location of the given diagnostic.
1001  *
1002  * This location is where Clang would print the caret ('^') when
1003  * displaying the diagnostic on the command line.
1004  */
1006 
1007 /**
1008  * Retrieve the text of the given diagnostic.
1009  */
1011 
1012 /**
1013  * Retrieve the name of the command-line option that enabled this
1014  * diagnostic.
1015  *
1016  * \param Diag The diagnostic to be queried.
1017  *
1018  * \param Disable If non-NULL, will be set to the option that disables this
1019  * diagnostic (if any).
1020  *
1021  * \returns A string that contains the command-line option used to enable this
1022  * warning, such as "-Wconversion" or "-pedantic".
1023  */
1025  CXString *Disable);
1026 
1027 /**
1028  * Retrieve the category number for this diagnostic.
1029  *
1030  * Diagnostics can be categorized into groups along with other, related
1031  * diagnostics (e.g., diagnostics under the same warning flag). This routine
1032  * retrieves the category number for the given diagnostic.
1033  *
1034  * \returns The number of the category that contains this diagnostic, or zero
1035  * if this diagnostic is uncategorized.
1036  */
1037 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1038 
1039 /**
1040  * Retrieve the name of a particular diagnostic category. This
1041  * is now deprecated. Use clang_getDiagnosticCategoryText()
1042  * instead.
1043  *
1044  * \param Category A diagnostic category number, as returned by
1045  * \c clang_getDiagnosticCategory().
1046  *
1047  * \returns The name of the given diagnostic category.
1048  */
1051 
1052 /**
1053  * Retrieve the diagnostic category text for a given diagnostic.
1054  *
1055  * \returns The text of the given diagnostic category.
1056  */
1058 
1059 /**
1060  * Determine the number of source ranges associated with the given
1061  * diagnostic.
1062  */
1063 CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
1064 
1065 /**
1066  * Retrieve a source range associated with the diagnostic.
1067  *
1068  * A diagnostic's source ranges highlight important elements in the source
1069  * code. On the command line, Clang displays source ranges by
1070  * underlining them with '~' characters.
1071  *
1072  * \param Diagnostic the diagnostic whose range is being extracted.
1073  *
1074  * \param Range the zero-based index specifying which range to
1075  *
1076  * \returns the requested source range.
1077  */
1078 CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
1079  unsigned Range);
1080 
1081 /**
1082  * Determine the number of fix-it hints associated with the
1083  * given diagnostic.
1084  */
1085 CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1086 
1087 /**
1088  * Retrieve the replacement information for a given fix-it.
1089  *
1090  * Fix-its are described in terms of a source range whose contents
1091  * should be replaced by a string. This approach generalizes over
1092  * three kinds of operations: removal of source code (the range covers
1093  * the code to be removed and the replacement string is empty),
1094  * replacement of source code (the range covers the code to be
1095  * replaced and the replacement string provides the new code), and
1096  * insertion (both the start and end of the range point at the
1097  * insertion location, and the replacement string provides the text to
1098  * insert).
1099  *
1100  * \param Diagnostic The diagnostic whose fix-its are being queried.
1101  *
1102  * \param FixIt The zero-based index of the fix-it.
1103  *
1104  * \param ReplacementRange The source range whose contents will be
1105  * replaced with the returned replacement string. Note that source
1106  * ranges are half-open ranges [a, b), so the source code should be
1107  * replaced from a and up to (but not including) b.
1108  *
1109  * \returns A string containing text that should be replace the source
1110  * code indicated by the \c ReplacementRange.
1111  */
1112 CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
1113  unsigned FixIt,
1114  CXSourceRange *ReplacementRange);
1115 
1116 /**
1117  * @}
1118  */
1119 
1120 /**
1121  * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1122  *
1123  * The routines in this group provide the ability to create and destroy
1124  * translation units from files, either by parsing the contents of the files or
1125  * by reading in a serialized representation of a translation unit.
1126  *
1127  * @{
1128  */
1129 
1130 /**
1131  * Get the original translation unit source file name.
1132  */
1134 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1135 
1136 /**
1137  * Return the CXTranslationUnit for a given source file and the provided
1138  * command line arguments one would pass to the compiler.
1139  *
1140  * Note: The 'source_filename' argument is optional. If the caller provides a
1141  * NULL pointer, the name of the source file is expected to reside in the
1142  * specified command line arguments.
1143  *
1144  * Note: When encountered in 'clang_command_line_args', the following options
1145  * are ignored:
1146  *
1147  * '-c'
1148  * '-emit-ast'
1149  * '-fsyntax-only'
1150  * '-o <output file>' (both '-o' and '<output file>' are ignored)
1151  *
1152  * \param CIdx The index object with which the translation unit will be
1153  * associated.
1154  *
1155  * \param source_filename The name of the source file to load, or NULL if the
1156  * source file is included in \p clang_command_line_args.
1157  *
1158  * \param num_clang_command_line_args The number of command-line arguments in
1159  * \p clang_command_line_args.
1160  *
1161  * \param clang_command_line_args The command-line arguments that would be
1162  * passed to the \c clang executable if it were being invoked out-of-process.
1163  * These command-line options will be parsed and will affect how the translation
1164  * unit is parsed. Note that the following options are ignored: '-c',
1165  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
1166  *
1167  * \param num_unsaved_files the number of unsaved file entries in \p
1168  * unsaved_files.
1169  *
1170  * \param unsaved_files the files that have not yet been saved to disk
1171  * but may be required for code completion, including the contents of
1172  * those files. The contents and name of these files (as specified by
1173  * CXUnsavedFile) are copied when necessary, so the client only needs to
1174  * guarantee their validity until the call to this function returns.
1175  */
1177  CXIndex CIdx,
1178  const char *source_filename,
1179  int num_clang_command_line_args,
1180  const char * const *clang_command_line_args,
1181  unsigned num_unsaved_files,
1182  struct CXUnsavedFile *unsaved_files);
1183 
1184 /**
1185  * Same as \c clang_createTranslationUnit2, but returns
1186  * the \c CXTranslationUnit instead of an error code. In case of an error this
1187  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1188  * error codes.
1189  */
1191  CXIndex CIdx,
1192  const char *ast_filename);
1193 
1194 /**
1195  * Create a translation unit from an AST file (\c -emit-ast).
1196  *
1197  * \param[out] out_TU A non-NULL pointer to store the created
1198  * \c CXTranslationUnit.
1199  *
1200  * \returns Zero on success, otherwise returns an error code.
1201  */
1203  CXIndex CIdx,
1204  const char *ast_filename,
1205  CXTranslationUnit *out_TU);
1206 
1207 /**
1208  * Flags that control the creation of translation units.
1209  *
1210  * The enumerators in this enumeration type are meant to be bitwise
1211  * ORed together to specify which options should be used when
1212  * constructing the translation unit.
1213  */
1215  /**
1216  * Used to indicate that no special translation-unit options are
1217  * needed.
1218  */
1220 
1221  /**
1222  * Used to indicate that the parser should construct a "detailed"
1223  * preprocessing record, including all macro definitions and instantiations.
1224  *
1225  * Constructing a detailed preprocessing record requires more memory
1226  * and time to parse, since the information contained in the record
1227  * is usually not retained. However, it can be useful for
1228  * applications that require more detailed information about the
1229  * behavior of the preprocessor.
1230  */
1232 
1233  /**
1234  * Used to indicate that the translation unit is incomplete.
1235  *
1236  * When a translation unit is considered "incomplete", semantic
1237  * analysis that is typically performed at the end of the
1238  * translation unit will be suppressed. For example, this suppresses
1239  * the completion of tentative declarations in C and of
1240  * instantiation of implicitly-instantiation function templates in
1241  * C++. This option is typically used when parsing a header with the
1242  * intent of producing a precompiled header.
1243  */
1245 
1246  /**
1247  * Used to indicate that the translation unit should be built with an
1248  * implicit precompiled header for the preamble.
1249  *
1250  * An implicit precompiled header is used as an optimization when a
1251  * particular translation unit is likely to be reparsed many times
1252  * when the sources aren't changing that often. In this case, an
1253  * implicit precompiled header will be built containing all of the
1254  * initial includes at the top of the main file (what we refer to as
1255  * the "preamble" of the file). In subsequent parses, if the
1256  * preamble or the files in it have not changed, \c
1257  * clang_reparseTranslationUnit() will re-use the implicit
1258  * precompiled header to improve parsing performance.
1259  */
1261 
1262  /**
1263  * Used to indicate that the translation unit should cache some
1264  * code-completion results with each reparse of the source file.
1265  *
1266  * Caching of code-completion results is a performance optimization that
1267  * introduces some overhead to reparsing but improves the performance of
1268  * code-completion operations.
1269  */
1271 
1272  /**
1273  * Used to indicate that the translation unit will be serialized with
1274  * \c clang_saveTranslationUnit.
1275  *
1276  * This option is typically used when parsing a header with the intent of
1277  * producing a precompiled header.
1278  */
1280 
1281  /**
1282  * DEPRECATED: Enabled chained precompiled preambles in C++.
1283  *
1284  * Note: this is a *temporary* option that is available only while
1285  * we are testing C++ precompiled preamble support. It is deprecated.
1286  */
1288 
1289  /**
1290  * Used to indicate that function/method bodies should be skipped while
1291  * parsing.
1292  *
1293  * This option can be used to search for declarations/definitions while
1294  * ignoring the usages.
1295  */
1297 
1298  /**
1299  * Used to indicate that brief documentation comments should be
1300  * included into the set of code completions returned from this translation
1301  * unit.
1302  */
1304 
1305  /**
1306  * Used to indicate that the precompiled preamble should be created on
1307  * the first parse. Otherwise it will be created on the first reparse. This
1308  * trades runtime on the first parse (serializing the preamble takes time) for
1309  * reduced runtime on the second parse (can now reuse the preamble).
1310  */
1312 
1313  /**
1314  * Do not stop processing when fatal errors are encountered.
1315  *
1316  * When fatal errors are encountered while parsing a translation unit,
1317  * semantic analysis is typically stopped early when compiling code. A common
1318  * source for fatal errors are unresolvable include files. For the
1319  * purposes of an IDE, this is undesirable behavior and as much information
1320  * as possible should be reported. Use this flag to enable this behavior.
1321  */
1323 
1324  /**
1325  * Sets the preprocessor in a mode for parsing a single file only.
1326  */
1328 
1329  /**
1330  * \brief Used in combination with CXTranslationUnit_SkipFunctionBodies to
1331  * constrain the skipping of function bodies to the preamble.
1332  *
1333  * The function bodies of the main file are not skipped.
1334  */
1336 };
1337 
1338 /**
1339  * Returns the set of flags that is suitable for parsing a translation
1340  * unit that is being edited.
1341  *
1342  * The set of flags returned provide options for \c clang_parseTranslationUnit()
1343  * to indicate that the translation unit is likely to be reparsed many times,
1344  * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1345  * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1346  * set contains an unspecified set of optimizations (e.g., the precompiled
1347  * preamble) geared toward improving the performance of these routines. The
1348  * set of optimizations enabled may change from one version to the next.
1349  */
1351 
1352 /**
1353  * Same as \c clang_parseTranslationUnit2, but returns
1354  * the \c CXTranslationUnit instead of an error code. In case of an error this
1355  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1356  * error codes.
1357  */
1358 CINDEX_LINKAGE CXTranslationUnit
1359 clang_parseTranslationUnit(CXIndex CIdx,
1360  const char *source_filename,
1361  const char *const *command_line_args,
1362  int num_command_line_args,
1363  struct CXUnsavedFile *unsaved_files,
1364  unsigned num_unsaved_files,
1365  unsigned options);
1366 
1367 /**
1368  * Parse the given source file and the translation unit corresponding
1369  * to that file.
1370  *
1371  * This routine is the main entry point for the Clang C API, providing the
1372  * ability to parse a source file into a translation unit that can then be
1373  * queried by other functions in the API. This routine accepts a set of
1374  * command-line arguments so that the compilation can be configured in the same
1375  * way that the compiler is configured on the command line.
1376  *
1377  * \param CIdx The index object with which the translation unit will be
1378  * associated.
1379  *
1380  * \param source_filename The name of the source file to load, or NULL if the
1381  * source file is included in \c command_line_args.
1382  *
1383  * \param command_line_args The command-line arguments that would be
1384  * passed to the \c clang executable if it were being invoked out-of-process.
1385  * These command-line options will be parsed and will affect how the translation
1386  * unit is parsed. Note that the following options are ignored: '-c',
1387  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
1388  *
1389  * \param num_command_line_args The number of command-line arguments in
1390  * \c command_line_args.
1391  *
1392  * \param unsaved_files the files that have not yet been saved to disk
1393  * but may be required for parsing, including the contents of
1394  * those files. The contents and name of these files (as specified by
1395  * CXUnsavedFile) are copied when necessary, so the client only needs to
1396  * guarantee their validity until the call to this function returns.
1397  *
1398  * \param num_unsaved_files the number of unsaved file entries in \p
1399  * unsaved_files.
1400  *
1401  * \param options A bitmask of options that affects how the translation unit
1402  * is managed but not its compilation. This should be a bitwise OR of the
1403  * CXTranslationUnit_XXX flags.
1404  *
1405  * \param[out] out_TU A non-NULL pointer to store the created
1406  * \c CXTranslationUnit, describing the parsed code and containing any
1407  * diagnostics produced by the compiler.
1408  *
1409  * \returns Zero on success, otherwise returns an error code.
1410  */
1412 clang_parseTranslationUnit2(CXIndex CIdx,
1413  const char *source_filename,
1414  const char *const *command_line_args,
1415  int num_command_line_args,
1416  struct CXUnsavedFile *unsaved_files,
1417  unsigned num_unsaved_files,
1418  unsigned options,
1419  CXTranslationUnit *out_TU);
1420 
1421 /**
1422  * Same as clang_parseTranslationUnit2 but requires a full command line
1423  * for \c command_line_args including argv[0]. This is useful if the standard
1424  * library paths are relative to the binary.
1425  */
1427  CXIndex CIdx, const char *source_filename,
1428  const char *const *command_line_args, int num_command_line_args,
1429  struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1430  unsigned options, CXTranslationUnit *out_TU);
1431 
1432 /**
1433  * Flags that control how translation units are saved.
1434  *
1435  * The enumerators in this enumeration type are meant to be bitwise
1436  * ORed together to specify which options should be used when
1437  * saving the translation unit.
1438  */
1440  /**
1441  * Used to indicate that no special saving options are needed.
1442  */
1444 };
1445 
1446 /**
1447  * Returns the set of flags that is suitable for saving a translation
1448  * unit.
1449  *
1450  * The set of flags returned provide options for
1451  * \c clang_saveTranslationUnit() by default. The returned flag
1452  * set contains an unspecified set of options that save translation units with
1453  * the most commonly-requested data.
1454  */
1455 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1456 
1457 /**
1458  * Describes the kind of error that occurred (if any) in a call to
1459  * \c clang_saveTranslationUnit().
1460  */
1462  /**
1463  * Indicates that no error occurred while saving a translation unit.
1464  */
1466 
1467  /**
1468  * Indicates that an unknown error occurred while attempting to save
1469  * the file.
1470  *
1471  * This error typically indicates that file I/O failed when attempting to
1472  * write the file.
1473  */
1475 
1476  /**
1477  * Indicates that errors during translation prevented this attempt
1478  * to save the translation unit.
1479  *
1480  * Errors that prevent the translation unit from being saved can be
1481  * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1482  */
1484 
1485  /**
1486  * Indicates that the translation unit to be saved was somehow
1487  * invalid (e.g., NULL).
1488  */
1490 };
1491 
1492 /**
1493  * Saves a translation unit into a serialized representation of
1494  * that translation unit on disk.
1495  *
1496  * Any translation unit that was parsed without error can be saved
1497  * into a file. The translation unit can then be deserialized into a
1498  * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1499  * if it is an incomplete translation unit that corresponds to a
1500  * header, used as a precompiled header when parsing other translation
1501  * units.
1502  *
1503  * \param TU The translation unit to save.
1504  *
1505  * \param FileName The file to which the translation unit will be saved.
1506  *
1507  * \param options A bitmask of options that affects how the translation unit
1508  * is saved. This should be a bitwise OR of the
1509  * CXSaveTranslationUnit_XXX flags.
1510  *
1511  * \returns A value that will match one of the enumerators of the CXSaveError
1512  * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1513  * saved successfully, while a non-zero value indicates that a problem occurred.
1514  */
1515 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1516  const char *FileName,
1517  unsigned options);
1518 
1519 /**
1520  * Suspend a translation unit in order to free memory associated with it.
1521  *
1522  * A suspended translation unit uses significantly less memory but on the other
1523  * side does not support any other calls than \c clang_reparseTranslationUnit
1524  * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1525  */
1526 CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1527 
1528 /**
1529  * Destroy the specified CXTranslationUnit object.
1530  */
1531 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1532 
1533 /**
1534  * Flags that control the reparsing of translation units.
1535  *
1536  * The enumerators in this enumeration type are meant to be bitwise
1537  * ORed together to specify which options should be used when
1538  * reparsing the translation unit.
1539  */
1541  /**
1542  * Used to indicate that no special reparsing options are needed.
1543  */
1545 };
1546 
1547 /**
1548  * Returns the set of flags that is suitable for reparsing a translation
1549  * unit.
1550  *
1551  * The set of flags returned provide options for
1552  * \c clang_reparseTranslationUnit() by default. The returned flag
1553  * set contains an unspecified set of optimizations geared toward common uses
1554  * of reparsing. The set of optimizations enabled may change from one version
1555  * to the next.
1556  */
1557 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1558 
1559 /**
1560  * Reparse the source files that produced this translation unit.
1561  *
1562  * This routine can be used to re-parse the source files that originally
1563  * created the given translation unit, for example because those source files
1564  * have changed (either on disk or as passed via \p unsaved_files). The
1565  * source code will be reparsed with the same command-line options as it
1566  * was originally parsed.
1567  *
1568  * Reparsing a translation unit invalidates all cursors and source locations
1569  * that refer into that translation unit. This makes reparsing a translation
1570  * unit semantically equivalent to destroying the translation unit and then
1571  * creating a new translation unit with the same command-line arguments.
1572  * However, it may be more efficient to reparse a translation
1573  * unit using this routine.
1574  *
1575  * \param TU The translation unit whose contents will be re-parsed. The
1576  * translation unit must originally have been built with
1577  * \c clang_createTranslationUnitFromSourceFile().
1578  *
1579  * \param num_unsaved_files The number of unsaved file entries in \p
1580  * unsaved_files.
1581  *
1582  * \param unsaved_files The files that have not yet been saved to disk
1583  * but may be required for parsing, including the contents of
1584  * those files. The contents and name of these files (as specified by
1585  * CXUnsavedFile) are copied when necessary, so the client only needs to
1586  * guarantee their validity until the call to this function returns.
1587  *
1588  * \param options A bitset of options composed of the flags in CXReparse_Flags.
1589  * The function \c clang_defaultReparseOptions() produces a default set of
1590  * options recommended for most uses, based on the translation unit.
1591  *
1592  * \returns 0 if the sources could be reparsed. A non-zero error code will be
1593  * returned if reparsing was impossible, such that the translation unit is
1594  * invalid. In such cases, the only valid call for \c TU is
1595  * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1596  * routine are described by the \c CXErrorCode enum.
1597  */
1598 CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1599  unsigned num_unsaved_files,
1600  struct CXUnsavedFile *unsaved_files,
1601  unsigned options);
1602 
1603 /**
1604  * Categorizes how memory is being used by a translation unit.
1605  */
1624 
1627 };
1628 
1629 /**
1630  * Returns the human-readable null-terminated C string that represents
1631  * the name of the memory category. This string should never be freed.
1632  */
1635 
1636 typedef struct CXTUResourceUsageEntry {
1637  /* The memory usage category. */
1639  /* Amount of resources used.
1640  The units will depend on the resource kind. */
1641  unsigned long amount;
1643 
1644 /**
1645  * The memory usage of a CXTranslationUnit, broken into categories.
1646  */
1647 typedef struct CXTUResourceUsage {
1648  /* Private data member, used for queries. */
1649  void *data;
1650 
1651  /* The number of entries in the 'entries' array. */
1652  unsigned numEntries;
1653 
1654  /* An array of key-value pairs, representing the breakdown of memory
1655  usage. */
1657 
1659 
1660 /**
1661  * Return the memory usage of a translation unit. This object
1662  * should be released with clang_disposeCXTUResourceUsage().
1663  */
1665 
1667 
1668 /**
1669  * Get target information for this translation unit.
1670  *
1671  * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1672  */
1673 CINDEX_LINKAGE CXTargetInfo
1674 clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1675 
1676 /**
1677  * Destroy the CXTargetInfo object.
1678  */
1679 CINDEX_LINKAGE void
1680 clang_TargetInfo_dispose(CXTargetInfo Info);
1681 
1682 /**
1683  * Get the normalized target triple as a string.
1684  *
1685  * Returns the empty string in case of any error.
1686  */
1688 clang_TargetInfo_getTriple(CXTargetInfo Info);
1689 
1690 /**
1691  * Get the pointer width of the target in bits.
1692  *
1693  * Returns -1 in case of error.
1694  */
1695 CINDEX_LINKAGE int
1696 clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1697 
1698 /**
1699  * @}
1700  */
1701 
1702 /**
1703  * Describes the kind of entity that a cursor refers to.
1704  */
1706  /* Declarations */
1707  /**
1708  * A declaration whose specific kind is not exposed via this
1709  * interface.
1710  *
1711  * Unexposed declarations have the same operations as any other kind
1712  * of declaration; one can extract their location information,
1713  * spelling, find their definitions, etc. However, the specific kind
1714  * of the declaration is not reported.
1715  */
1717  /** A C or C++ struct. */
1719  /** A C or C++ union. */
1721  /** A C++ class. */
1723  /** An enumeration. */
1725  /**
1726  * A field (in C) or non-static data member (in C++) in a
1727  * struct, union, or C++ class.
1728  */
1730  /** An enumerator constant. */
1732  /** A function. */
1734  /** A variable. */
1736  /** A function or method parameter. */
1738  /** An Objective-C \@interface. */
1740  /** An Objective-C \@interface for a category. */
1742  /** An Objective-C \@protocol declaration. */
1744  /** An Objective-C \@property declaration. */
1746  /** An Objective-C instance variable. */
1748  /** An Objective-C instance method. */
1750  /** An Objective-C class method. */
1752  /** An Objective-C \@implementation. */
1754  /** An Objective-C \@implementation for a category. */
1756  /** A typedef. */
1758  /** A C++ class method. */
1760  /** A C++ namespace. */
1762  /** A linkage specification, e.g. 'extern "C"'. */
1764  /** A C++ constructor. */
1766  /** A C++ destructor. */
1768  /** A C++ conversion function. */
1770  /** A C++ template type parameter. */
1772  /** A C++ non-type template parameter. */
1774  /** A C++ template template parameter. */
1776  /** A C++ function template. */
1778  /** A C++ class template. */
1780  /** A C++ class template partial specialization. */
1782  /** A C++ namespace alias declaration. */
1784  /** A C++ using directive. */
1786  /** A C++ using declaration. */
1788  /** A C++ alias declaration */
1790  /** An Objective-C \@synthesize definition. */
1792  /** An Objective-C \@dynamic definition. */
1794  /** An access specifier. */
1796 
1799 
1800  /* References */
1801  CXCursor_FirstRef = 40, /* Decl references */
1805  /**
1806  * A reference to a type declaration.
1807  *
1808  * A type reference occurs anywhere where a type is named but not
1809  * declared. For example, given:
1810  *
1811  * \code
1812  * typedef unsigned size_type;
1813  * size_type size;
1814  * \endcode
1815  *
1816  * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1817  * while the type of the variable "size" is referenced. The cursor
1818  * referenced by the type of size is the typedef for size_type.
1819  */
1822  /**
1823  * A reference to a class template, function template, template
1824  * template parameter, or class template partial specialization.
1825  */
1827  /**
1828  * A reference to a namespace or namespace alias.
1829  */
1831  /**
1832  * A reference to a member of a struct, union, or class that occurs in
1833  * some non-expression context, e.g., a designated initializer.
1834  */
1836  /**
1837  * A reference to a labeled statement.
1838  *
1839  * This cursor kind is used to describe the jump to "start_over" in the
1840  * goto statement in the following example:
1841  *
1842  * \code
1843  * start_over:
1844  * ++counter;
1845  *
1846  * goto start_over;
1847  * \endcode
1848  *
1849  * A label reference cursor refers to a label statement.
1850  */
1852 
1853  /**
1854  * A reference to a set of overloaded functions or function templates
1855  * that has not yet been resolved to a specific function or function template.
1856  *
1857  * An overloaded declaration reference cursor occurs in C++ templates where
1858  * a dependent name refers to a function. For example:
1859  *
1860  * \code
1861  * template<typename T> void swap(T&, T&);
1862  *
1863  * struct X { ... };
1864  * void swap(X&, X&);
1865  *
1866  * template<typename T>
1867  * void reverse(T* first, T* last) {
1868  * while (first < last - 1) {
1869  * swap(*first, *--last);
1870  * ++first;
1871  * }
1872  * }
1873  *
1874  * struct Y { };
1875  * void swap(Y&, Y&);
1876  * \endcode
1877  *
1878  * Here, the identifier "swap" is associated with an overloaded declaration
1879  * reference. In the template definition, "swap" refers to either of the two
1880  * "swap" functions declared above, so both results will be available. At
1881  * instantiation time, "swap" may also refer to other functions found via
1882  * argument-dependent lookup (e.g., the "swap" function at the end of the
1883  * example).
1884  *
1885  * The functions \c clang_getNumOverloadedDecls() and
1886  * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1887  * referenced by this cursor.
1888  */
1890 
1891  /**
1892  * A reference to a variable that occurs in some non-expression
1893  * context, e.g., a C++ lambda capture list.
1894  */
1896 
1898 
1899  /* Error conditions */
1906 
1907  /* Expressions */
1909 
1910  /**
1911  * An expression whose specific kind is not exposed via this
1912  * interface.
1913  *
1914  * Unexposed expressions have the same operations as any other kind
1915  * of expression; one can extract their location information,
1916  * spelling, children, etc. However, the specific kind of the
1917  * expression is not reported.
1918  */
1920 
1921  /**
1922  * An expression that refers to some value declaration, such
1923  * as a function, variable, or enumerator.
1924  */
1926 
1927  /**
1928  * An expression that refers to a member of a struct, union,
1929  * class, Objective-C class, etc.
1930  */
1932 
1933  /** An expression that calls a function. */
1935 
1936  /** An expression that sends a message to an Objective-C
1937  object or class. */
1939 
1940  /** An expression that represents a block literal. */
1942 
1943  /** An integer literal.
1944  */
1946 
1947  /** A floating point number literal.
1948  */
1950 
1951  /** An imaginary number literal.
1952  */
1954 
1955  /** A string literal.
1956  */
1958 
1959  /** A character literal.
1960  */
1962 
1963  /** A parenthesized expression, e.g. "(1)".
1964  *
1965  * This AST node is only formed if full location information is requested.
1966  */
1968 
1969  /** This represents the unary-expression's (except sizeof and
1970  * alignof).
1971  */
1973 
1974  /** [C99 6.5.2.1] Array Subscripting.
1975  */
1977 
1978  /** A builtin binary operation expression such as "x + y" or
1979  * "x <= y".
1980  */
1982 
1983  /** Compound assignment such as "+=".
1984  */
1986 
1987  /** The ?: ternary operator.
1988  */
1990 
1991  /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1992  * (C++ [expr.cast]), which uses the syntax (Type)expr.
1993  *
1994  * For example: (int)f.
1995  */
1997 
1998  /** [C99 6.5.2.5]
1999  */
2001 
2002  /** Describes an C or C++ initializer list.
2003  */
2005 
2006  /** The GNU address of label extension, representing &&label.
2007  */
2009 
2010  /** This is the GNU Statement Expression extension: ({int X=4; X;})
2011  */
2013 
2014  /** Represents a C11 generic selection.
2015  */
2017 
2018  /** Implements the GNU __null extension, which is a name for a null
2019  * pointer constant that has integral type (e.g., int or long) and is the same
2020  * size and alignment as a pointer.
2021  *
2022  * The __null extension is typically only used by system headers, which define
2023  * NULL as __null in C++ rather than using 0 (which is an integer that may not
2024  * match the size of a pointer).
2025  */
2027 
2028  /** C++'s static_cast<> expression.
2029  */
2031 
2032  /** C++'s dynamic_cast<> expression.
2033  */
2035 
2036  /** C++'s reinterpret_cast<> expression.
2037  */
2039 
2040  /** C++'s const_cast<> expression.
2041  */
2043 
2044  /** Represents an explicit C++ type conversion that uses "functional"
2045  * notion (C++ [expr.type.conv]).
2046  *
2047  * Example:
2048  * \code
2049  * x = int(0.5);
2050  * \endcode
2051  */
2053 
2054  /** A C++ typeid expression (C++ [expr.typeid]).
2055  */
2057 
2058  /** [C++ 2.13.5] C++ Boolean Literal.
2059  */
2061 
2062  /** [C++0x 2.14.7] C++ Pointer Literal.
2063  */
2065 
2066  /** Represents the "this" expression in C++
2067  */
2069 
2070  /** [C++ 15] C++ Throw Expression.
2071  *
2072  * This handles 'throw' and 'throw' assignment-expression. When
2073  * assignment-expression isn't present, Op will be null.
2074  */
2076 
2077  /** A new expression for memory allocation and constructor calls, e.g:
2078  * "new CXXNewExpr(foo)".
2079  */
2081 
2082  /** A delete expression for memory deallocation and destructor calls,
2083  * e.g. "delete[] pArray".
2084  */
2086 
2087  /** A unary expression. (noexcept, sizeof, or other traits)
2088  */
2090 
2091  /** An Objective-C string literal i.e. @"foo".
2092  */
2094 
2095  /** An Objective-C \@encode expression.
2096  */
2098 
2099  /** An Objective-C \@selector expression.
2100  */
2102 
2103  /** An Objective-C \@protocol expression.
2104  */
2106 
2107  /** An Objective-C "bridged" cast expression, which casts between
2108  * Objective-C pointers and C pointers, transferring ownership in the process.
2109  *
2110  * \code
2111  * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2112  * \endcode
2113  */
2115 
2116  /** Represents a C++0x pack expansion that produces a sequence of
2117  * expressions.
2118  *
2119  * A pack expansion expression contains a pattern (which itself is an
2120  * expression) followed by an ellipsis. For example:
2121  *
2122  * \code
2123  * template<typename F, typename ...Types>
2124  * void forward(F f, Types &&...args) {
2125  * f(static_cast<Types&&>(args)...);
2126  * }
2127  * \endcode
2128  */
2130 
2131  /** Represents an expression that computes the length of a parameter
2132  * pack.
2133  *
2134  * \code
2135  * template<typename ...Types>
2136  * struct count {
2137  * static const unsigned value = sizeof...(Types);
2138  * };
2139  * \endcode
2140  */
2142 
2143  /* Represents a C++ lambda expression that produces a local function
2144  * object.
2145  *
2146  * \code
2147  * void abssort(float *x, unsigned N) {
2148  * std::sort(x, x + N,
2149  * [](float a, float b) {
2150  * return std::abs(a) < std::abs(b);
2151  * });
2152  * }
2153  * \endcode
2154  */
2156 
2157  /** Objective-c Boolean Literal.
2158  */
2160 
2161  /** Represents the "self" expression in an Objective-C method.
2162  */
2164 
2165  /** OpenMP 4.0 [2.4, Array Section].
2166  */
2168 
2169  /** Represents an @available(...) check.
2170  */
2172 
2174 
2175  /* Statements */
2177  /**
2178  * A statement whose specific kind is not exposed via this
2179  * interface.
2180  *
2181  * Unexposed statements have the same operations as any other kind of
2182  * statement; one can extract their location information, spelling,
2183  * children, etc. However, the specific kind of the statement is not
2184  * reported.
2185  */
2187 
2188  /** A labelled statement in a function.
2189  *
2190  * This cursor kind is used to describe the "start_over:" label statement in
2191  * the following example:
2192  *
2193  * \code
2194  * start_over:
2195  * ++counter;
2196  * \endcode
2197  *
2198  */
2200 
2201  /** A group of statements like { stmt stmt }.
2202  *
2203  * This cursor kind is used to describe compound statements, e.g. function
2204  * bodies.
2205  */
2207 
2208  /** A case statement.
2209  */
2211 
2212  /** A default statement.
2213  */
2215 
2216  /** An if statement
2217  */
2219 
2220  /** A switch statement.
2221  */
2223 
2224  /** A while statement.
2225  */
2227 
2228  /** A do statement.
2229  */
2231 
2232  /** A for statement.
2233  */
2235 
2236  /** A goto statement.
2237  */
2239 
2240  /** An indirect goto statement.
2241  */
2243 
2244  /** A continue statement.
2245  */
2247 
2248  /** A break statement.
2249  */
2251 
2252  /** A return statement.
2253  */
2255 
2256  /** A GCC inline assembly statement extension.
2257  */
2260 
2261  /** Objective-C's overall \@try-\@catch-\@finally statement.
2262  */
2264 
2265  /** Objective-C's \@catch statement.
2266  */
2268 
2269  /** Objective-C's \@finally statement.
2270  */
2272 
2273  /** Objective-C's \@throw statement.
2274  */
2276 
2277  /** Objective-C's \@synchronized statement.
2278  */
2280 
2281  /** Objective-C's autorelease pool statement.
2282  */
2284 
2285  /** Objective-C's collection statement.
2286  */
2288 
2289  /** C++'s catch statement.
2290  */
2292 
2293  /** C++'s try statement.
2294  */
2296 
2297  /** C++'s for (* : *) statement.
2298  */
2300 
2301  /** Windows Structured Exception Handling's try statement.
2302  */
2304 
2305  /** Windows Structured Exception Handling's except statement.
2306  */
2308 
2309  /** Windows Structured Exception Handling's finally statement.
2310  */
2312 
2313  /** A MS inline assembly statement extension.
2314  */
2316 
2317  /** The null statement ";": C99 6.8.3p3.
2318  *
2319  * This cursor kind is used to describe the null statement.
2320  */
2322 
2323  /** Adaptor class for mixing declarations with statements and
2324  * expressions.
2325  */
2327 
2328  /** OpenMP parallel directive.
2329  */
2331 
2332  /** OpenMP SIMD directive.
2333  */
2335 
2336  /** OpenMP for directive.
2337  */
2339 
2340  /** OpenMP sections directive.
2341  */
2343 
2344  /** OpenMP section directive.
2345  */
2347 
2348  /** OpenMP single directive.
2349  */
2351 
2352  /** OpenMP parallel for directive.
2353  */
2355 
2356  /** OpenMP parallel sections directive.
2357  */
2359 
2360  /** OpenMP task directive.
2361  */
2363 
2364  /** OpenMP master directive.
2365  */
2367 
2368  /** OpenMP critical directive.
2369  */
2371 
2372  /** OpenMP taskyield directive.
2373  */
2375 
2376  /** OpenMP barrier directive.
2377  */
2379 
2380  /** OpenMP taskwait directive.
2381  */
2383 
2384  /** OpenMP flush directive.
2385  */
2387 
2388  /** Windows Structured Exception Handling's leave statement.
2389  */
2391 
2392  /** OpenMP ordered directive.
2393  */
2395 
2396  /** OpenMP atomic directive.
2397  */
2399 
2400  /** OpenMP for SIMD directive.
2401  */
2403 
2404  /** OpenMP parallel for SIMD directive.
2405  */
2407 
2408  /** OpenMP target directive.
2409  */
2411 
2412  /** OpenMP teams directive.
2413  */
2415 
2416  /** OpenMP taskgroup directive.
2417  */
2419 
2420  /** OpenMP cancellation point directive.
2421  */
2423 
2424  /** OpenMP cancel directive.
2425  */
2427 
2428  /** OpenMP target data directive.
2429  */
2431 
2432  /** OpenMP taskloop directive.
2433  */
2435 
2436  /** OpenMP taskloop simd directive.
2437  */
2439 
2440  /** OpenMP distribute directive.
2441  */
2443 
2444  /** OpenMP target enter data directive.
2445  */
2447 
2448  /** OpenMP target exit data directive.
2449  */
2451 
2452  /** OpenMP target parallel directive.
2453  */
2455 
2456  /** OpenMP target parallel for directive.
2457  */
2459 
2460  /** OpenMP target update directive.
2461  */
2463 
2464  /** OpenMP distribute parallel for directive.
2465  */
2467 
2468  /** OpenMP distribute parallel for simd directive.
2469  */
2471 
2472  /** OpenMP distribute simd directive.
2473  */
2475 
2476  /** OpenMP target parallel for simd directive.
2477  */
2479 
2480  /** OpenMP target simd directive.
2481  */
2483 
2484  /** OpenMP teams distribute directive.
2485  */
2487 
2488  /** OpenMP teams distribute simd directive.
2489  */
2491 
2492  /** OpenMP teams distribute parallel for simd directive.
2493  */
2495 
2496  /** OpenMP teams distribute parallel for directive.
2497  */
2499 
2500  /** OpenMP target teams directive.
2501  */
2503 
2504  /** OpenMP target teams distribute directive.
2505  */
2507 
2508  /** OpenMP target teams distribute parallel for directive.
2509  */
2511 
2512  /** OpenMP target teams distribute parallel for simd directive.
2513  */
2515 
2516  /** OpenMP target teams distribute simd directive.
2517  */
2519 
2521 
2522  /**
2523  * Cursor that represents the translation unit itself.
2524  *
2525  * The translation unit cursor exists primarily to act as the root
2526  * cursor for traversing the contents of a translation unit.
2527  */
2529 
2530  /* Attributes */
2532  /**
2533  * An attribute whose specific kind is not exposed via this
2534  * interface.
2535  */
2537 
2558 
2559  /* Preprocessing */
2567 
2568  /* Extra Declarations */
2569  /**
2570  * A module import declaration.
2571  */
2574  /**
2575  * A static_assert or _Static_assert node
2576  */
2578  /**
2579  * a friend declaration.
2580  */
2584 
2585  /**
2586  * A code completion overload candidate.
2587  */
2589 };
2590 
2591 /**
2592  * A cursor representing some element in the abstract syntax tree for
2593  * a translation unit.
2594  *
2595  * The cursor abstraction unifies the different kinds of entities in a
2596  * program--declaration, statements, expressions, references to declarations,
2597  * etc.--under a single "cursor" abstraction with a common set of operations.
2598  * Common operation for a cursor include: getting the physical location in
2599  * a source file where the cursor points, getting the name associated with a
2600  * cursor, and retrieving cursors for any child nodes of a particular cursor.
2601  *
2602  * Cursors can be produced in two specific ways.
2603  * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2604  * from which one can use clang_visitChildren() to explore the rest of the
2605  * translation unit. clang_getCursor() maps from a physical source location
2606  * to the entity that resides at that location, allowing one to map from the
2607  * source code into the AST.
2608  */
2609 typedef struct {
2611  int xdata;
2612  const void *data[3];
2613 } CXCursor;
2614 
2615 /**
2616  * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2617  *
2618  * @{
2619  */
2620 
2621 /**
2622  * Retrieve the NULL cursor, which represents no entity.
2623  */
2625 
2626 /**
2627  * Retrieve the cursor that represents the given translation unit.
2628  *
2629  * The translation unit cursor can be used to start traversing the
2630  * various declarations within the given translation unit.
2631  */
2633 
2634 /**
2635  * Determine whether two cursors are equivalent.
2636  */
2638 
2639 /**
2640  * Returns non-zero if \p cursor is null.
2641  */
2643 
2644 /**
2645  * Compute a hash value for the given cursor.
2646  */
2648 
2649 /**
2650  * Retrieve the kind of the given cursor.
2651  */
2653 
2654 /**
2655  * Determine whether the given cursor kind represents a declaration.
2656  */
2658 
2659 /**
2660  * Determine whether the given declaration is invalid.
2661  *
2662  * A declaration is invalid if it could not be parsed successfully.
2663  *
2664  * \returns non-zero if the cursor represents a declaration and it is
2665  * invalid, otherwise NULL.
2666  */
2668 
2669 /**
2670  * Determine whether the given cursor kind represents a simple
2671  * reference.
2672  *
2673  * Note that other kinds of cursors (such as expressions) can also refer to
2674  * other cursors. Use clang_getCursorReferenced() to determine whether a
2675  * particular cursor refers to another entity.
2676  */
2678 
2679 /**
2680  * Determine whether the given cursor kind represents an expression.
2681  */
2683 
2684 /**
2685  * Determine whether the given cursor kind represents a statement.
2686  */
2688 
2689 /**
2690  * Determine whether the given cursor kind represents an attribute.
2691  */
2693 
2694 /**
2695  * Determine whether the given cursor has any attributes.
2696  */
2698 
2699 /**
2700  * Determine whether the given cursor kind represents an invalid
2701  * cursor.
2702  */
2704 
2705 /**
2706  * Determine whether the given cursor kind represents a translation
2707  * unit.
2708  */
2710 
2711 /***
2712  * Determine whether the given cursor represents a preprocessing
2713  * element, such as a preprocessor directive or macro instantiation.
2714  */
2716 
2717 /***
2718  * Determine whether the given cursor represents a currently
2719  * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2720  */
2722 
2723 /**
2724  * Describe the linkage of the entity referred to by a cursor.
2725  */
2727  /** This value indicates that no linkage information is available
2728  * for a provided CXCursor. */
2730  /**
2731  * This is the linkage for variables, parameters, and so on that
2732  * have automatic storage. This covers normal (non-extern) local variables.
2733  */
2735  /** This is the linkage for static variables and static functions. */
2737  /** This is the linkage for entities with external linkage that live
2738  * in C++ anonymous namespaces.*/
2740  /** This is the linkage for entities with true, external linkage. */
2742 };
2743 
2744 /**
2745  * Determine the linkage of the entity referred to by a given cursor.
2746  */
2748 
2750  /** This value indicates that no visibility information is available
2751  * for a provided CXCursor. */
2753 
2754  /** Symbol not seen by the linker. */
2756  /** Symbol seen by the linker but resolves to a symbol inside this object. */
2758  /** Symbol seen by the linker and acts like a normal symbol. */
2760 };
2761 
2762 /**
2763  * Describe the visibility of the entity referred to by a cursor.
2764  *
2765  * This returns the default visibility if not explicitly specified by
2766  * a visibility attribute. The default visibility may be changed by
2767  * commandline arguments.
2768  *
2769  * \param cursor The cursor to query.
2770  *
2771  * \returns The visibility of the cursor.
2772  */
2774 
2775 /**
2776  * Determine the availability of the entity that this cursor refers to,
2777  * taking the current target platform into account.
2778  *
2779  * \param cursor The cursor to query.
2780  *
2781  * \returns The availability of the cursor.
2782  */
2785 
2786 /**
2787  * Describes the availability of a given entity on a particular platform, e.g.,
2788  * a particular class might only be available on Mac OS 10.7 or newer.
2789  */
2790 typedef struct CXPlatformAvailability {
2791  /**
2792  * A string that describes the platform for which this structure
2793  * provides availability information.
2794  *
2795  * Possible values are "ios" or "macos".
2796  */
2798  /**
2799  * The version number in which this entity was introduced.
2800  */
2802  /**
2803  * The version number in which this entity was deprecated (but is
2804  * still available).
2805  */
2807  /**
2808  * The version number in which this entity was obsoleted, and therefore
2809  * is no longer available.
2810  */
2812  /**
2813  * Whether the entity is unconditionally unavailable on this platform.
2814  */
2816  /**
2817  * An optional message to provide to a user of this API, e.g., to
2818  * suggest replacement APIs.
2819  */
2822 
2823 /**
2824  * Determine the availability of the entity that this cursor refers to
2825  * on any platforms for which availability information is known.
2826  *
2827  * \param cursor The cursor to query.
2828  *
2829  * \param always_deprecated If non-NULL, will be set to indicate whether the
2830  * entity is deprecated on all platforms.
2831  *
2832  * \param deprecated_message If non-NULL, will be set to the message text
2833  * provided along with the unconditional deprecation of this entity. The client
2834  * is responsible for deallocating this string.
2835  *
2836  * \param always_unavailable If non-NULL, will be set to indicate whether the
2837  * entity is unavailable on all platforms.
2838  *
2839  * \param unavailable_message If non-NULL, will be set to the message text
2840  * provided along with the unconditional unavailability of this entity. The
2841  * client is responsible for deallocating this string.
2842  *
2843  * \param availability If non-NULL, an array of CXPlatformAvailability instances
2844  * that will be populated with platform availability information, up to either
2845  * the number of platforms for which availability information is available (as
2846  * returned by this function) or \c availability_size, whichever is smaller.
2847  *
2848  * \param availability_size The number of elements available in the
2849  * \c availability array.
2850  *
2851  * \returns The number of platforms (N) for which availability information is
2852  * available (which is unrelated to \c availability_size).
2853  *
2854  * Note that the client is responsible for calling
2855  * \c clang_disposeCXPlatformAvailability to free each of the
2856  * platform-availability structures returned. There are
2857  * \c min(N, availability_size) such structures.
2858  */
2859 CINDEX_LINKAGE int
2861  int *always_deprecated,
2862  CXString *deprecated_message,
2863  int *always_unavailable,
2864  CXString *unavailable_message,
2865  CXPlatformAvailability *availability,
2866  int availability_size);
2867 
2868 /**
2869  * Free the memory associated with a \c CXPlatformAvailability structure.
2870  */
2871 CINDEX_LINKAGE void
2873 
2874 /**
2875  * Describe the "language" of the entity referred to by a cursor.
2876  */
2882 };
2883 
2884 /**
2885  * Determine the "language" of the entity referred to by a given cursor.
2886  */
2888 
2889 /**
2890  * Describe the "thread-local storage (TLS) kind" of the declaration
2891  * referred to by a cursor.
2892  */
2897 };
2898 
2899 /**
2900  * Determine the "thread-local storage (TLS) kind" of the declaration
2901  * referred to by a cursor.
2902  */
2904 
2905 /**
2906  * Returns the translation unit that a cursor originated from.
2907  */
2909 
2910 /**
2911  * A fast container representing a set of CXCursors.
2912  */
2913 typedef struct CXCursorSetImpl *CXCursorSet;
2914 
2915 /**
2916  * Creates an empty CXCursorSet.
2917  */
2918 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2919 
2920 /**
2921  * Disposes a CXCursorSet and releases its associated memory.
2922  */
2923 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2924 
2925 /**
2926  * Queries a CXCursorSet to see if it contains a specific CXCursor.
2927  *
2928  * \returns non-zero if the set contains the specified cursor.
2929 */
2930 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2931  CXCursor cursor);
2932 
2933 /**
2934  * Inserts a CXCursor into a CXCursorSet.
2935  *
2936  * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2937 */
2938 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2939  CXCursor cursor);
2940 
2941 /**
2942  * Determine the semantic parent of the given cursor.
2943  *
2944  * The semantic parent of a cursor is the cursor that semantically contains
2945  * the given \p cursor. For many declarations, the lexical and semantic parents
2946  * are equivalent (the lexical parent is returned by
2947  * \c clang_getCursorLexicalParent()). They diverge when declarations or
2948  * definitions are provided out-of-line. For example:
2949  *
2950  * \code
2951  * class C {
2952  * void f();
2953  * };
2954  *
2955  * void C::f() { }
2956  * \endcode
2957  *
2958  * In the out-of-line definition of \c C::f, the semantic parent is
2959  * the class \c C, of which this function is a member. The lexical parent is
2960  * the place where the declaration actually occurs in the source code; in this
2961  * case, the definition occurs in the translation unit. In general, the
2962  * lexical parent for a given entity can change without affecting the semantics
2963  * of the program, and the lexical parent of different declarations of the
2964  * same entity may be different. Changing the semantic parent of a declaration,
2965  * on the other hand, can have a major impact on semantics, and redeclarations
2966  * of a particular entity should all have the same semantic context.
2967  *
2968  * In the example above, both declarations of \c C::f have \c C as their
2969  * semantic context, while the lexical context of the first \c C::f is \c C
2970  * and the lexical context of the second \c C::f is the translation unit.
2971  *
2972  * For global declarations, the semantic parent is the translation unit.
2973  */
2975 
2976 /**
2977  * Determine the lexical parent of the given cursor.
2978  *
2979  * The lexical parent of a cursor is the cursor in which the given \p cursor
2980  * was actually written. For many declarations, the lexical and semantic parents
2981  * are equivalent (the semantic parent is returned by
2982  * \c clang_getCursorSemanticParent()). They diverge when declarations or
2983  * definitions are provided out-of-line. For example:
2984  *
2985  * \code
2986  * class C {
2987  * void f();
2988  * };
2989  *
2990  * void C::f() { }
2991  * \endcode
2992  *
2993  * In the out-of-line definition of \c C::f, the semantic parent is
2994  * the class \c C, of which this function is a member. The lexical parent is
2995  * the place where the declaration actually occurs in the source code; in this
2996  * case, the definition occurs in the translation unit. In general, the
2997  * lexical parent for a given entity can change without affecting the semantics
2998  * of the program, and the lexical parent of different declarations of the
2999  * same entity may be different. Changing the semantic parent of a declaration,
3000  * on the other hand, can have a major impact on semantics, and redeclarations
3001  * of a particular entity should all have the same semantic context.
3002  *
3003  * In the example above, both declarations of \c C::f have \c C as their
3004  * semantic context, while the lexical context of the first \c C::f is \c C
3005  * and the lexical context of the second \c C::f is the translation unit.
3006  *
3007  * For declarations written in the global scope, the lexical parent is
3008  * the translation unit.
3009  */
3011 
3012 /**
3013  * Determine the set of methods that are overridden by the given
3014  * method.
3015  *
3016  * In both Objective-C and C++, a method (aka virtual member function,
3017  * in C++) can override a virtual method in a base class. For
3018  * Objective-C, a method is said to override any method in the class's
3019  * base class, its protocols, or its categories' protocols, that has the same
3020  * selector and is of the same kind (class or instance).
3021  * If no such method exists, the search continues to the class's superclass,
3022  * its protocols, and its categories, and so on. A method from an Objective-C
3023  * implementation is considered to override the same methods as its
3024  * corresponding method in the interface.
3025  *
3026  * For C++, a virtual member function overrides any virtual member
3027  * function with the same signature that occurs in its base
3028  * classes. With multiple inheritance, a virtual member function can
3029  * override several virtual member functions coming from different
3030  * base classes.
3031  *
3032  * In all cases, this function determines the immediate overridden
3033  * method, rather than all of the overridden methods. For example, if
3034  * a method is originally declared in a class A, then overridden in B
3035  * (which in inherits from A) and also in C (which inherited from B),
3036  * then the only overridden method returned from this function when
3037  * invoked on C's method will be B's method. The client may then
3038  * invoke this function again, given the previously-found overridden
3039  * methods, to map out the complete method-override set.
3040  *
3041  * \param cursor A cursor representing an Objective-C or C++
3042  * method. This routine will compute the set of methods that this
3043  * method overrides.
3044  *
3045  * \param overridden A pointer whose pointee will be replaced with a
3046  * pointer to an array of cursors, representing the set of overridden
3047  * methods. If there are no overridden methods, the pointee will be
3048  * set to NULL. The pointee must be freed via a call to
3049  * \c clang_disposeOverriddenCursors().
3050  *
3051  * \param num_overridden A pointer to the number of overridden
3052  * functions, will be set to the number of overridden functions in the
3053  * array pointed to by \p overridden.
3054  */
3056  CXCursor **overridden,
3057  unsigned *num_overridden);
3058 
3059 /**
3060  * Free the set of overridden cursors returned by \c
3061  * clang_getOverriddenCursors().
3062  */
3064 
3065 /**
3066  * Retrieve the file that is included by the given inclusion directive
3067  * cursor.
3068  */
3070 
3071 /**
3072  * @}
3073  */
3074 
3075 /**
3076  * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3077  *
3078  * Cursors represent a location within the Abstract Syntax Tree (AST). These
3079  * routines help map between cursors and the physical locations where the
3080  * described entities occur in the source code. The mapping is provided in
3081  * both directions, so one can map from source code to the AST and back.
3082  *
3083  * @{
3084  */
3085 
3086 /**
3087  * Map a source location to the cursor that describes the entity at that
3088  * location in the source code.
3089  *
3090  * clang_getCursor() maps an arbitrary source location within a translation
3091  * unit down to the most specific cursor that describes the entity at that
3092  * location. For example, given an expression \c x + y, invoking
3093  * clang_getCursor() with a source location pointing to "x" will return the
3094  * cursor for "x"; similarly for "y". If the cursor points anywhere between
3095  * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3096  * will return a cursor referring to the "+" expression.
3097  *
3098  * \returns a cursor representing the entity at the given source location, or
3099  * a NULL cursor if no such entity can be found.
3100  */
3102 
3103 /**
3104  * Retrieve the physical location of the source constructor referenced
3105  * by the given cursor.
3106  *
3107  * The location of a declaration is typically the location of the name of that
3108  * declaration, where the name of that declaration would occur if it is
3109  * unnamed, or some keyword that introduces that particular declaration.
3110  * The location of a reference is where that reference occurs within the
3111  * source code.
3112  */
3114 
3115 /**
3116  * Retrieve the physical extent of the source construct referenced by
3117  * the given cursor.
3118  *
3119  * The extent of a cursor starts with the file/line/column pointing at the
3120  * first character within the source construct that the cursor refers to and
3121  * ends with the last character within that source construct. For a
3122  * declaration, the extent covers the declaration itself. For a reference,
3123  * the extent covers the location of the reference (e.g., where the referenced
3124  * entity was actually used).
3125  */
3127 
3128 /**
3129  * @}
3130  */
3131 
3132 /**
3133  * \defgroup CINDEX_TYPES Type information for CXCursors
3134  *
3135  * @{
3136  */
3137 
3138 /**
3139  * Describes the kind of type
3140  */
3142  /**
3143  * Represents an invalid type (e.g., where no type is available).
3144  */
3146 
3147  /**
3148  * A type whose specific kind is not exposed via this
3149  * interface.
3150  */
3152 
3153  /* Builtin types */
3187 
3207 
3208  /**
3209  * Represents a type that was referred to using an elaborated type keyword.
3210  *
3211  * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3212  */
3214 
3215  /* OpenCL PipeType. */
3217 
3218  /* OpenCL builtin types. */
3259 };
3260 
3261 /**
3262  * Describes the calling convention of a function type
3263  */
3276  /* Alias for compatibility with older versions of API. */
3283 
3286 };
3287 
3288 /**
3289  * The type of an element in the abstract syntax tree.
3290  *
3291  */
3292 typedef struct {
3294  void *data[2];
3295 } CXType;
3296 
3297 /**
3298  * Retrieve the type of a CXCursor (if any).
3299  */
3301 
3302 /**
3303  * Pretty-print the underlying type using the rules of the
3304  * language of the translation unit from which it came.
3305  *
3306  * If the type is invalid, an empty string is returned.
3307  */
3309 
3310 /**
3311  * Retrieve the underlying type of a typedef declaration.
3312  *
3313  * If the cursor does not reference a typedef declaration, an invalid type is
3314  * returned.
3315  */
3317 
3318 /**
3319  * Retrieve the integer type of an enum declaration.
3320  *
3321  * If the cursor does not reference an enum declaration, an invalid type is
3322  * returned.
3323  */
3325 
3326 /**
3327  * Retrieve the integer value of an enum constant declaration as a signed
3328  * long long.
3329  *
3330  * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3331  * Since this is also potentially a valid constant value, the kind of the cursor
3332  * must be verified before calling this function.
3333  */
3335 
3336 /**
3337  * Retrieve the integer value of an enum constant declaration as an unsigned
3338  * long long.
3339  *
3340  * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3341  * Since this is also potentially a valid constant value, the kind of the cursor
3342  * must be verified before calling this function.
3343  */
3345 
3346 /**
3347  * Retrieve the bit width of a bit field declaration as an integer.
3348  *
3349  * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3350  */
3352 
3353 /**
3354  * Retrieve the number of non-variadic arguments associated with a given
3355  * cursor.
3356  *
3357  * The number of arguments can be determined for calls as well as for
3358  * declarations of functions or methods. For other cursors -1 is returned.
3359  */
3361 
3362 /**
3363  * Retrieve the argument cursor of a function or method.
3364  *
3365  * The argument cursor can be determined for calls as well as for declarations
3366  * of functions or methods. For other cursors and for invalid indices, an
3367  * invalid cursor is returned.
3368  */
3370 
3371 /**
3372  * Describes the kind of a template argument.
3373  *
3374  * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3375  * element descriptions.
3376  */
3387  /* Indicates an error case, preventing the kind from being deduced. */
3389 };
3390 
3391 /**
3392  *Returns the number of template args of a function decl representing a
3393  * template specialization.
3394  *
3395  * If the argument cursor cannot be converted into a template function
3396  * declaration, -1 is returned.
3397  *
3398  * For example, for the following declaration and specialization:
3399  * template <typename T, int kInt, bool kBool>
3400  * void foo() { ... }
3401  *
3402  * template <>
3403  * void foo<float, -7, true>();
3404  *
3405  * The value 3 would be returned from this call.
3406  */
3408 
3409 /**
3410  * Retrieve the kind of the I'th template argument of the CXCursor C.
3411  *
3412  * If the argument CXCursor does not represent a FunctionDecl, an invalid
3413  * template argument kind is returned.
3414  *
3415  * For example, for the following declaration and specialization:
3416  * template <typename T, int kInt, bool kBool>
3417  * void foo() { ... }
3418  *
3419  * template <>
3420  * void foo<float, -7, true>();
3421  *
3422  * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3423  * respectively.
3424  */
3426  CXCursor C, unsigned I);
3427 
3428 /**
3429  * Retrieve a CXType representing the type of a TemplateArgument of a
3430  * function decl representing a template specialization.
3431  *
3432  * If the argument CXCursor does not represent a FunctionDecl whose I'th
3433  * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3434  * is returned.
3435  *
3436  * For example, for the following declaration and specialization:
3437  * template <typename T, int kInt, bool kBool>
3438  * void foo() { ... }
3439  *
3440  * template <>
3441  * void foo<float, -7, true>();
3442  *
3443  * If called with I = 0, "float", will be returned.
3444  * Invalid types will be returned for I == 1 or 2.
3445  */
3447  unsigned I);
3448 
3449 /**
3450  * Retrieve the value of an Integral TemplateArgument (of a function
3451  * decl representing a template specialization) as a signed long long.
3452  *
3453  * It is undefined to call this function on a CXCursor that does not represent a
3454  * FunctionDecl or whose I'th template argument is not an integral value.
3455  *
3456  * For example, for the following declaration and specialization:
3457  * template <typename T, int kInt, bool kBool>
3458  * void foo() { ... }
3459  *
3460  * template <>
3461  * void foo<float, -7, true>();
3462  *
3463  * If called with I = 1 or 2, -7 or true will be returned, respectively.
3464  * For I == 0, this function's behavior is undefined.
3465  */
3467  unsigned I);
3468 
3469 /**
3470  * Retrieve the value of an Integral TemplateArgument (of a function
3471  * decl representing a template specialization) as an unsigned long long.
3472  *
3473  * It is undefined to call this function on a CXCursor that does not represent a
3474  * FunctionDecl or whose I'th template argument is not an integral value.
3475  *
3476  * For example, for the following declaration and specialization:
3477  * template <typename T, int kInt, bool kBool>
3478  * void foo() { ... }
3479  *
3480  * template <>
3481  * void foo<float, 2147483649, true>();
3482  *
3483  * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3484  * For I == 0, this function's behavior is undefined.
3485  */
3487  CXCursor C, unsigned I);
3488 
3489 /**
3490  * Determine whether two CXTypes represent the same type.
3491  *
3492  * \returns non-zero if the CXTypes represent the same type and
3493  * zero otherwise.
3494  */
3496 
3497 /**
3498  * Return the canonical type for a CXType.
3499  *
3500  * Clang's type system explicitly models typedefs and all the ways
3501  * a specific type can be represented. The canonical type is the underlying
3502  * type with all the "sugar" removed. For example, if 'T' is a typedef
3503  * for 'int', the canonical type for 'T' would be 'int'.
3504  */
3506 
3507 /**
3508  * Determine whether a CXType has the "const" qualifier set,
3509  * without looking through typedefs that may have added "const" at a
3510  * different level.
3511  */
3513 
3514 /**
3515  * Determine whether a CXCursor that is a macro, is
3516  * function like.
3517  */
3519 
3520 /**
3521  * Determine whether a CXCursor that is a macro, is a
3522  * builtin one.
3523  */
3525 
3526 /**
3527  * Determine whether a CXCursor that is a function declaration, is an
3528  * inline declaration.
3529  */
3531 
3532 /**
3533  * Determine whether a CXType has the "volatile" qualifier set,
3534  * without looking through typedefs that may have added "volatile" at
3535  * a different level.
3536  */
3538 
3539 /**
3540  * Determine whether a CXType has the "restrict" qualifier set,
3541  * without looking through typedefs that may have added "restrict" at a
3542  * different level.
3543  */
3545 
3546 /**
3547  * Returns the address space of the given type.
3548  */
3550 
3551 /**
3552  * Returns the typedef name of the given type.
3553  */
3555 
3556 /**
3557  * For pointer types, returns the type of the pointee.
3558  */
3560 
3561 /**
3562  * Return the cursor for the declaration of the given type.
3563  */
3565 
3566 /**
3567  * Returns the Objective-C type encoding for the specified declaration.
3568  */
3570 
3571 /**
3572  * Returns the Objective-C type encoding for the specified CXType.
3573  */
3575 
3576 /**
3577  * Retrieve the spelling of a given CXTypeKind.
3578  */
3580 
3581 /**
3582  * Retrieve the calling convention associated with a function type.
3583  *
3584  * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3585  */
3587 
3588 /**
3589  * Retrieve the return type associated with a function type.
3590  *
3591  * If a non-function type is passed in, an invalid type is returned.
3592  */
3594 
3595 /**
3596  * Retrieve the exception specification type associated with a function type.
3597  * This is a value of type CXCursor_ExceptionSpecificationKind.
3598  *
3599  * If a non-function type is passed in, an error code of -1 is returned.
3600  */
3602 
3603 /**
3604  * Retrieve the number of non-variadic parameters associated with a
3605  * function type.
3606  *
3607  * If a non-function type is passed in, -1 is returned.
3608  */
3610 
3611 /**
3612  * Retrieve the type of a parameter of a function type.
3613  *
3614  * If a non-function type is passed in or the function does not have enough
3615  * parameters, an invalid type is returned.
3616  */
3618 
3619 /**
3620  * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3621  */
3623 
3624 /**
3625  * Retrieve the return type associated with a given cursor.
3626  *
3627  * This only returns a valid type if the cursor refers to a function or method.
3628  */
3630 
3631 /**
3632  * Retrieve the exception specification type associated with a given cursor.
3633  * This is a value of type CXCursor_ExceptionSpecificationKind.
3634  *
3635  * This only returns a valid result if the cursor refers to a function or method.
3636  */
3638 
3639 /**
3640  * Return 1 if the CXType is a POD (plain old data) type, and 0
3641  * otherwise.
3642  */
3644 
3645 /**
3646  * Return the element type of an array, complex, or vector type.
3647  *
3648  * If a type is passed in that is not an array, complex, or vector type,
3649  * an invalid type is returned.
3650  */
3652 
3653 /**
3654  * Return the number of elements of an array or vector type.
3655  *
3656  * If a type is passed in that is not an array or vector type,
3657  * -1 is returned.
3658  */
3660 
3661 /**
3662  * Return the element type of an array type.
3663  *
3664  * If a non-array type is passed in, an invalid type is returned.
3665  */
3667 
3668 /**
3669  * Return the array size of a constant array.
3670  *
3671  * If a non-array type is passed in, -1 is returned.
3672  */
3674 
3675 /**
3676  * Retrieve the type named by the qualified-id.
3677  *
3678  * If a non-elaborated type is passed in, an invalid type is returned.
3679  */
3681 
3682 /**
3683  * Determine if a typedef is 'transparent' tag.
3684  *
3685  * A typedef is considered 'transparent' if it shares a name and spelling
3686  * location with its underlying tag type, as is the case with the NS_ENUM macro.
3687  *
3688  * \returns non-zero if transparent and zero otherwise.
3689  */
3691 
3692 /**
3693  * List the possible error codes for \c clang_Type_getSizeOf,
3694  * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3695  * \c clang_Cursor_getOffsetOf.
3696  *
3697  * A value of this enumeration type can be returned if the target type is not
3698  * a valid argument to sizeof, alignof or offsetof.
3699  */
3701  /**
3702  * Type is of kind CXType_Invalid.
3703  */
3705  /**
3706  * The type is an incomplete Type.
3707  */
3709  /**
3710  * The type is a dependent Type.
3711  */
3713  /**
3714  * The type is not a constant size type.
3715  */
3717  /**
3718  * The Field name is not valid for this record.
3719  */
3721 };
3722 
3723 /**
3724  * Return the alignment of a type in bytes as per C++[expr.alignof]
3725  * standard.
3726  *
3727  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3728  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3729  * is returned.
3730  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3731  * returned.
3732  * If the type declaration is not a constant size type,
3733  * CXTypeLayoutError_NotConstantSize is returned.
3734  */
3736 
3737 /**
3738  * Return the class type of an member pointer type.
3739  *
3740  * If a non-member-pointer type is passed in, an invalid type is returned.
3741  */
3743 
3744 /**
3745  * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3746  *
3747  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3748  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3749  * is returned.
3750  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3751  * returned.
3752  */
3754 
3755 /**
3756  * Return the offset of a field named S in a record of type T in bits
3757  * as it would be returned by __offsetof__ as per C++11[18.2p4]
3758  *
3759  * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3760  * is returned.
3761  * If the field's type declaration is an incomplete type,
3762  * CXTypeLayoutError_Incomplete is returned.
3763  * If the field's type declaration is a dependent type,
3764  * CXTypeLayoutError_Dependent is returned.
3765  * If the field's name S is not found,
3766  * CXTypeLayoutError_InvalidFieldName is returned.
3767  */
3768 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3769 
3770 /**
3771  * Return the offset of the field represented by the Cursor.
3772  *
3773  * If the cursor is not a field declaration, -1 is returned.
3774  * If the cursor semantic parent is not a record field declaration,
3775  * CXTypeLayoutError_Invalid is returned.
3776  * If the field's type declaration is an incomplete type,
3777  * CXTypeLayoutError_Incomplete is returned.
3778  * If the field's type declaration is a dependent type,
3779  * CXTypeLayoutError_Dependent is returned.
3780  * If the field's name S is not found,
3781  * CXTypeLayoutError_InvalidFieldName is returned.
3782  */
3784 
3785 /**
3786  * Determine whether the given cursor represents an anonymous record
3787  * declaration.
3788  */
3790 
3792  /** No ref-qualifier was provided. */
3794  /** An lvalue ref-qualifier was provided (\c &). */
3796  /** An rvalue ref-qualifier was provided (\c &&). */
3798 };
3799 
3800 /**
3801  * Returns the number of template arguments for given template
3802  * specialization, or -1 if type \c T is not a template specialization.
3803  */
3805 
3806 /**
3807  * Returns the type template argument of a template class specialization
3808  * at given index.
3809  *
3810  * This function only returns template type arguments and does not handle
3811  * template template arguments or variadic packs.
3812  */
3814 
3815 /**
3816  * Retrieve the ref-qualifier kind of a function or method.
3817  *
3818  * The ref-qualifier is returned for C++ functions or methods. For other types
3819  * or non-C++ declarations, CXRefQualifier_None is returned.
3820  */
3822 
3823 /**
3824  * Returns non-zero if the cursor specifies a Record member that is a
3825  * bitfield.
3826  */
3828 
3829 /**
3830  * Returns 1 if the base class specified by the cursor with kind
3831  * CX_CXXBaseSpecifier is virtual.
3832  */
3834 
3835 /**
3836  * Represents the C++ access control level to a base class for a
3837  * cursor with kind CX_CXXBaseSpecifier.
3838  */
3844 };
3845 
3846 /**
3847  * Returns the access control level for the referenced object.
3848  *
3849  * If the cursor refers to a C++ declaration, its access control level within its
3850  * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3851  * access specifier, the specifier itself is returned.
3852  */
3854 
3855 /**
3856  * Represents the storage classes as declared in the source. CX_SC_Invalid
3857  * was added for the case that the passed cursor in not a declaration.
3858  */
3868 };
3869 
3870 /**
3871  * Returns the storage class for a function or variable declaration.
3872  *
3873  * If the passed in Cursor is not a function or variable declaration,
3874  * CX_SC_Invalid is returned else the storage class.
3875  */
3877 
3878 /**
3879  * Determine the number of overloaded declarations referenced by a
3880  * \c CXCursor_OverloadedDeclRef cursor.
3881  *
3882  * \param cursor The cursor whose overloaded declarations are being queried.
3883  *
3884  * \returns The number of overloaded declarations referenced by \c cursor. If it
3885  * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3886  */
3888 
3889 /**
3890  * Retrieve a cursor for one of the overloaded declarations referenced
3891  * by a \c CXCursor_OverloadedDeclRef cursor.
3892  *
3893  * \param cursor The cursor whose overloaded declarations are being queried.
3894  *
3895  * \param index The zero-based index into the set of overloaded declarations in
3896  * the cursor.
3897  *
3898  * \returns A cursor representing the declaration referenced by the given
3899  * \c cursor at the specified \c index. If the cursor does not have an
3900  * associated set of overloaded declarations, or if the index is out of bounds,
3901  * returns \c clang_getNullCursor();
3902  */
3904  unsigned index);
3905 
3906 /**
3907  * @}
3908  */
3909 
3910 /**
3911  * \defgroup CINDEX_ATTRIBUTES Information for attributes
3912  *
3913  * @{
3914  */
3915 
3916 /**
3917  * For cursors representing an iboutletcollection attribute,
3918  * this function returns the collection element type.
3919  *
3920  */
3922 
3923 /**
3924  * @}
3925  */
3926 
3927 /**
3928  * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3929  *
3930  * These routines provide the ability to traverse the abstract syntax tree
3931  * using cursors.
3932  *
3933  * @{
3934  */
3935 
3936 /**
3937  * Describes how the traversal of the children of a particular
3938  * cursor should proceed after visiting a particular child cursor.
3939  *
3940  * A value of this enumeration type should be returned by each
3941  * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3942  */
3944  /**
3945  * Terminates the cursor traversal.
3946  */
3948  /**
3949  * Continues the cursor traversal with the next sibling of
3950  * the cursor just visited, without visiting its children.
3951  */
3953  /**
3954  * Recursively traverse the children of this cursor, using
3955  * the same visitor and client data.
3956  */
3958 };
3959 
3960 /**
3961  * Visitor invoked for each cursor found by a traversal.
3962  *
3963  * This visitor function will be invoked for each cursor found by
3964  * clang_visitCursorChildren(). Its first argument is the cursor being
3965  * visited, its second argument is the parent visitor for that cursor,
3966  * and its third argument is the client data provided to
3967  * clang_visitCursorChildren().
3968  *
3969  * The visitor should return one of the \c CXChildVisitResult values
3970  * to direct clang_visitCursorChildren().
3971  */
3973  CXCursor parent,
3974  CXClientData client_data);
3975 
3976 /**
3977  * Visit the children of a particular cursor.
3978  *
3979  * This function visits all the direct children of the given cursor,
3980  * invoking the given \p visitor function with the cursors of each
3981  * visited child. The traversal may be recursive, if the visitor returns
3982  * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3983  * the visitor returns \c CXChildVisit_Break.
3984  *
3985  * \param parent the cursor whose child may be visited. All kinds of
3986  * cursors can be visited, including invalid cursors (which, by
3987  * definition, have no children).
3988  *
3989  * \param visitor the visitor function that will be invoked for each
3990  * child of \p parent.
3991  *
3992  * \param client_data pointer data supplied by the client, which will
3993  * be passed to the visitor each time it is invoked.
3994  *
3995  * \returns a non-zero value if the traversal was terminated
3996  * prematurely by the visitor returning \c CXChildVisit_Break.
3997  */
3999  CXCursorVisitor visitor,
4000  CXClientData client_data);
4001 #ifdef __has_feature
4002 # if __has_feature(blocks)
4003 /**
4004  * Visitor invoked for each cursor found by a traversal.
4005  *
4006  * This visitor block will be invoked for each cursor found by
4007  * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4008  * visited, its second argument is the parent visitor for that cursor.
4009  *
4010  * The visitor should return one of the \c CXChildVisitResult values
4011  * to direct clang_visitChildrenWithBlock().
4012  */
4013 typedef enum CXChildVisitResult
4014  (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
4015 
4016 /**
4017  * Visits the children of a cursor using the specified block. Behaves
4018  * identically to clang_visitChildren() in all other respects.
4019  */
4020 CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
4021  CXCursorVisitorBlock block);
4022 # endif
4023 #endif
4024 
4025 /**
4026  * @}
4027  */
4028 
4029 /**
4030  * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4031  *
4032  * These routines provide the ability to determine references within and
4033  * across translation units, by providing the names of the entities referenced
4034  * by cursors, follow reference cursors to the declarations they reference,
4035  * and associate declarations with their definitions.
4036  *
4037  * @{
4038  */
4039 
4040 /**
4041  * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4042  * by the given cursor.
4043  *
4044  * A Unified Symbol Resolution (USR) is a string that identifies a particular
4045  * entity (function, class, variable, etc.) within a program. USRs can be
4046  * compared across translation units to determine, e.g., when references in
4047  * one translation refer to an entity defined in another translation unit.
4048  */
4050 
4051 /**
4052  * Construct a USR for a specified Objective-C class.
4053  */
4054 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4055 
4056 /**
4057  * Construct a USR for a specified Objective-C category.
4058  */
4060  clang_constructUSR_ObjCCategory(const char *class_name,
4061  const char *category_name);
4062 
4063 /**
4064  * Construct a USR for a specified Objective-C protocol.
4065  */
4067  clang_constructUSR_ObjCProtocol(const char *protocol_name);
4068 
4069 /**
4070  * Construct a USR for a specified Objective-C instance variable and
4071  * the USR for its containing class.
4072  */
4074  CXString classUSR);
4075 
4076 /**
4077  * Construct a USR for a specified Objective-C method and
4078  * the USR for its containing class.
4079  */
4081  unsigned isInstanceMethod,
4082  CXString classUSR);
4083 
4084 /**
4085  * Construct a USR for a specified Objective-C property and the USR
4086  * for its containing class.
4087  */
4089  CXString classUSR);
4090 
4091 /**
4092  * Retrieve a name for the entity referenced by this cursor.
4093  */
4095 
4096 /**
4097  * Retrieve a range for a piece that forms the cursors spelling name.
4098  * Most of the times there is only one range for the complete spelling but for
4099  * Objective-C methods and Objective-C message expressions, there are multiple
4100  * pieces for each selector identifier.
4101  *
4102  * \param pieceIndex the index of the spelling name piece. If this is greater
4103  * than the actual number of pieces, it will return a NULL (invalid) range.
4104  *
4105  * \param options Reserved.
4106  */
4108  unsigned pieceIndex,
4109  unsigned options);
4110 
4111 /**
4112  * Opaque pointer representing a policy that controls pretty printing
4113  * for \c clang_getCursorPrettyPrinted.
4114  */
4115 typedef void *CXPrintingPolicy;
4116 
4117 /**
4118  * Properties for the printing policy.
4119  *
4120  * See \c clang::PrintingPolicy for more information.
4121  */
4149 
4151 };
4152 
4153 /**
4154  * Get a property value for the given printing policy.
4155  */
4156 CINDEX_LINKAGE unsigned
4157 clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4158  enum CXPrintingPolicyProperty Property);
4159 
4160 /**
4161  * Set a property value for the given printing policy.
4162  */
4163 CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4164  enum CXPrintingPolicyProperty Property,
4165  unsigned Value);
4166 
4167 /**
4168  * Retrieve the default policy for the cursor.
4169  *
4170  * The policy should be released after use with \c
4171  * clang_PrintingPolicy_dispose.
4172  */
4174 
4175 /**
4176  * Release a printing policy.
4177  */
4178 CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4179 
4180 /**
4181  * Pretty print declarations.
4182  *
4183  * \param Cursor The cursor representing a declaration.
4184  *
4185  * \param Policy The policy to control the entities being printed. If
4186  * NULL, a default policy is used.
4187  *
4188  * \returns The pretty printed declaration or the empty string for
4189  * other cursors.
4190  */
4192  CXPrintingPolicy Policy);
4193 
4194 /**
4195  * Retrieve the display name for the entity referenced by this cursor.
4196  *
4197  * The display name contains extra information that helps identify the cursor,
4198  * such as the parameters of a function or template or the arguments of a
4199  * class template specialization.
4200  */
4202 
4203 /** For a cursor that is a reference, retrieve a cursor representing the
4204  * entity that it references.
4205  *
4206  * Reference cursors refer to other entities in the AST. For example, an
4207  * Objective-C superclass reference cursor refers to an Objective-C class.
4208  * This function produces the cursor for the Objective-C class from the
4209  * cursor for the superclass reference. If the input cursor is a declaration or
4210  * definition, it returns that declaration or definition unchanged.
4211  * Otherwise, returns the NULL cursor.
4212  */
4214 
4215 /**
4216  * For a cursor that is either a reference to or a declaration
4217  * of some entity, retrieve a cursor that describes the definition of
4218  * that entity.
4219  *
4220  * Some entities can be declared multiple times within a translation
4221  * unit, but only one of those declarations can also be a
4222  * definition. For example, given:
4223  *
4224  * \code
4225  * int f(int, int);
4226  * int g(int x, int y) { return f(x, y); }
4227  * int f(int a, int b) { return a + b; }
4228  * int f(int, int);
4229  * \endcode
4230  *
4231  * there are three declarations of the function "f", but only the
4232  * second one is a definition. The clang_getCursorDefinition()
4233  * function will take any cursor pointing to a declaration of "f"
4234  * (the first or fourth lines of the example) or a cursor referenced
4235  * that uses "f" (the call to "f' inside "g") and will return a
4236  * declaration cursor pointing to the definition (the second "f"
4237  * declaration).
4238  *
4239  * If given a cursor for which there is no corresponding definition,
4240  * e.g., because there is no definition of that entity within this
4241  * translation unit, returns a NULL cursor.
4242  */
4244 
4245 /**
4246  * Determine whether the declaration pointed to by this cursor
4247  * is also a definition of that entity.
4248  */
4250 
4251 /**
4252  * Retrieve the canonical cursor corresponding to the given cursor.
4253  *
4254  * In the C family of languages, many kinds of entities can be declared several
4255  * times within a single translation unit. For example, a structure type can
4256  * be forward-declared (possibly multiple times) and later defined:
4257  *
4258  * \code
4259  * struct X;
4260  * struct X;
4261  * struct X {
4262  * int member;
4263  * };
4264  * \endcode
4265  *
4266  * The declarations and the definition of \c X are represented by three
4267  * different cursors, all of which are declarations of the same underlying
4268  * entity. One of these cursor is considered the "canonical" cursor, which
4269  * is effectively the representative for the underlying entity. One can
4270  * determine if two cursors are declarations of the same underlying entity by
4271  * comparing their canonical cursors.
4272  *
4273  * \returns The canonical cursor for the entity referred to by the given cursor.
4274  */
4276 
4277 /**
4278  * If the cursor points to a selector identifier in an Objective-C
4279  * method or message expression, this returns the selector index.
4280  *
4281  * After getting a cursor with #clang_getCursor, this can be called to
4282  * determine if the location points to a selector identifier.
4283  *
4284  * \returns The selector index if the cursor is an Objective-C method or message
4285  * expression and the cursor is pointing to a selector identifier, or -1
4286  * otherwise.
4287  */
4289 
4290 /**
4291  * Given a cursor pointing to a C++ method call or an Objective-C
4292  * message, returns non-zero if the method/message is "dynamic", meaning:
4293  *
4294  * For a C++ method: the call is virtual.
4295  * For an Objective-C message: the receiver is an object instance, not 'super'
4296  * or a specific class.
4297  *
4298  * If the method/message is "static" or the cursor does not point to a
4299  * method/message, it will return zero.
4300  */
4302 
4303 /**
4304  * Given a cursor pointing to an Objective-C message or property
4305  * reference, or C++ method call, returns the CXType of the receiver.
4306  */
4308 
4309 /**
4310  * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4311  */
4312 typedef enum {
4328 
4329 /**
4330  * Given a cursor that represents a property declaration, return the
4331  * associated property attributes. The bits are formed from
4332  * \c CXObjCPropertyAttrKind.
4333  *
4334  * \param reserved Reserved for future use, pass 0.
4335  */
4337  unsigned reserved);
4338 
4339 /**
4340  * 'Qualifiers' written next to the return and parameter types in
4341  * Objective-C method declarations.
4342  */
4343 typedef enum {
4352 
4353 /**
4354  * Given a cursor that represents an Objective-C method or parameter
4355  * declaration, return the associated Objective-C qualifiers for the return
4356  * type or the parameter respectively. The bits are formed from
4357  * CXObjCDeclQualifierKind.
4358  */
4360 
4361 /**
4362  * Given a cursor that represents an Objective-C method or property
4363  * declaration, return non-zero if the declaration was affected by "\@optional".
4364  * Returns zero if the cursor is not such a declaration or it is "\@required".
4365  */
4367 
4368 /**
4369  * Returns non-zero if the given cursor is a variadic function or method.
4370  */
4372 
4373 /**
4374  * Returns non-zero if the given cursor points to a symbol marked with
4375  * external_source_symbol attribute.
4376  *
4377  * \param language If non-NULL, and the attribute is present, will be set to
4378  * the 'language' string from the attribute.
4379  *
4380  * \param definedIn If non-NULL, and the attribute is present, will be set to
4381  * the 'definedIn' string from the attribute.
4382  *
4383  * \param isGenerated If non-NULL, and the attribute is present, will be set to
4384  * non-zero if the 'generated_declaration' is set in the attribute.
4385  */
4387  CXString *language, CXString *definedIn,
4388  unsigned *isGenerated);
4389 
4390 /**
4391  * Given a cursor that represents a declaration, return the associated
4392  * comment's source range. The range may include multiple consecutive comments
4393  * with whitespace in between.
4394  */
4396 
4397 /**
4398  * Given a cursor that represents a declaration, return the associated
4399  * comment text, including comment markers.
4400  */
4402 
4403 /**
4404  * Given a cursor that represents a documentable entity (e.g.,
4405  * declaration), return the associated \paragraph; otherwise return the
4406  * first paragraph.
4407  */
4409 
4410 /**
4411  * @}
4412  */
4413 
4414 /** \defgroup CINDEX_MANGLE Name Mangling API Functions
4415  *
4416  * @{
4417  */
4418 
4419 /**
4420  * Retrieve the CXString representing the mangled name of the cursor.
4421  */
4423 
4424 /**
4425  * Retrieve the CXStrings representing the mangled symbols of the C++
4426  * constructor or destructor at the cursor.
4427  */
4429 
4430 /**
4431  * Retrieve the CXStrings representing the mangled symbols of the ObjC
4432  * class interface or implementation at the cursor.
4433  */
4435 
4436 /**
4437  * @}
4438  */
4439 
4440 /**
4441  * \defgroup CINDEX_MODULE Module introspection
4442  *
4443  * The functions in this group provide access to information about modules.
4444  *
4445  * @{
4446  */
4447 
4448 typedef void *CXModule;
4449 
4450 /**
4451  * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4452  */
4454 
4455 /**
4456  * Given a CXFile header file, return the module that contains it, if one
4457  * exists.
4458  */
4459 CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4460 
4461 /**
4462  * \param Module a module object.
4463  *
4464  * \returns the module file where the provided module object came from.
4465  */
4466 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4467 
4468 /**
4469  * \param Module a module object.
4470  *
4471  * \returns the parent of a sub-module or NULL if the given module is top-level,
4472  * e.g. for 'std.vector' it will return the 'std' module.
4473  */
4474 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4475 
4476 /**
4477  * \param Module a module object.
4478  *
4479  * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4480  * will return "vector".
4481  */
4483 
4484 /**
4485  * \param Module a module object.
4486  *
4487  * \returns the full name of the module, e.g. "std.vector".
4488  */
4490 
4491 /**
4492  * \param Module a module object.
4493  *
4494  * \returns non-zero if the module is a system one.
4495  */
4496 CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4497 
4498 /**
4499  * \param Module a module object.
4500  *
4501  * \returns the number of top level headers associated with this module.
4502  */
4503 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4504  CXModule Module);
4505 
4506 /**
4507  * \param Module a module object.
4508  *
4509  * \param Index top level header index (zero-based).
4510  *
4511  * \returns the specified top level header associated with the module.
4512  */
4514 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4515  CXModule Module, unsigned Index);
4516 
4517 /**
4518  * @}
4519  */
4520 
4521 /**
4522  * \defgroup CINDEX_CPP C++ AST introspection
4523  *
4524  * The routines in this group provide access information in the ASTs specific
4525  * to C++ language features.
4526  *
4527  * @{
4528  */
4529 
4530 /**
4531  * Determine if a C++ constructor is a converting constructor.
4532  */
4534 
4535 /**
4536  * Determine if a C++ constructor is a copy constructor.
4537  */
4539 
4540 /**
4541  * Determine if a C++ constructor is the default constructor.
4542  */
4544 
4545 /**
4546  * Determine if a C++ constructor is a move constructor.
4547  */
4549 
4550 /**
4551  * Determine if a C++ field is declared 'mutable'.
4552  */
4554 
4555 /**
4556  * Determine if a C++ method is declared '= default'.
4557  */
4559 
4560 /**
4561  * Determine if a C++ member function or member function template is
4562  * pure virtual.
4563  */
4565 
4566 /**
4567  * Determine if a C++ member function or member function template is
4568  * declared 'static'.
4569  */
4571 
4572 /**
4573  * Determine if a C++ member function or member function template is
4574  * explicitly declared 'virtual' or if it overrides a virtual method from
4575  * one of the base classes.
4576  */
4578 
4579 /**
4580  * Determine if a C++ record is abstract, i.e. whether a class or struct
4581  * has a pure virtual member function.
4582  */
4584 
4585 /**
4586  * Determine if an enum declaration refers to a scoped enum.
4587  */
4589 
4590 /**
4591  * Determine if a C++ member function or member function template is
4592  * declared 'const'.
4593  */
4595 
4596 /**
4597  * Given a cursor that represents a template, determine
4598  * the cursor kind of the specializations would be generated by instantiating
4599  * the template.
4600  *
4601  * This routine can be used to determine what flavor of function template,
4602  * class template, or class template partial specialization is stored in the
4603  * cursor. For example, it can describe whether a class template cursor is
4604  * declared with "struct", "class" or "union".
4605  *
4606  * \param C The cursor to query. This cursor should represent a template
4607  * declaration.
4608  *
4609  * \returns The cursor kind of the specializations that would be generated
4610  * by instantiating the template \p C. If \p C is not a template, returns
4611  * \c CXCursor_NoDeclFound.
4612  */
4614 
4615 /**
4616  * Given a cursor that may represent a specialization or instantiation
4617  * of a template, retrieve the cursor that represents the template that it
4618  * specializes or from which it was instantiated.
4619  *
4620  * This routine determines the template involved both for explicit
4621  * specializations of templates and for implicit instantiations of the template,
4622  * both of which are referred to as "specializations". For a class template
4623  * specialization (e.g., \c std::vector<bool>), this routine will return
4624  * either the primary template (\c std::vector) or, if the specialization was
4625  * instantiated from a class template partial specialization, the class template
4626  * partial specialization. For a class template partial specialization and a
4627  * function template specialization (including instantiations), this
4628  * this routine will return the specialized template.
4629  *
4630  * For members of a class template (e.g., member functions, member classes, or
4631  * static data members), returns the specialized or instantiated member.
4632  * Although not strictly "templates" in the C++ language, members of class
4633  * templates have the same notions of specializations and instantiations that
4634  * templates do, so this routine treats them similarly.
4635  *
4636  * \param C A cursor that may be a specialization of a template or a member
4637  * of a template.
4638  *
4639  * \returns If the given cursor is a specialization or instantiation of a
4640  * template or a member thereof, the template or member that it specializes or
4641  * from which it was instantiated. Otherwise, returns a NULL cursor.
4642  */
4644 
4645 /**
4646  * Given a cursor that references something else, return the source range
4647  * covering that reference.
4648  *
4649  * \param C A cursor pointing to a member reference, a declaration reference, or
4650  * an operator call.
4651  * \param NameFlags A bitset with three independent flags:
4652  * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4653  * CXNameRange_WantSinglePiece.
4654  * \param PieceIndex For contiguous names or when passing the flag
4655  * CXNameRange_WantSinglePiece, only one piece with index 0 is
4656  * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4657  * non-contiguous names, this index can be used to retrieve the individual
4658  * pieces of the name. See also CXNameRange_WantSinglePiece.
4659  *
4660  * \returns The piece of the name pointed to by the given cursor. If there is no
4661  * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4662  */
4664  unsigned NameFlags,
4665  unsigned PieceIndex);
4666 
4668  /**
4669  * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4670  * range.
4671  */
4673 
4674  /**
4675  * Include the explicit template arguments, e.g. <int> in x.f<int>,
4676  * in the range.
4677  */
4679 
4680  /**
4681  * If the name is non-contiguous, return the full spanning range.
4682  *
4683  * Non-contiguous names occur in Objective-C when a selector with two or more
4684  * parameters is used, or in C++ when using an operator:
4685  * \code
4686  * [object doSomething:here withValue:there]; // Objective-C
4687  * return some_vector[1]; // C++
4688  * \endcode
4689  */
4691 };
4692 
4693 /**
4694  * @}
4695  */
4696 
4697 /**
4698  * \defgroup CINDEX_LEX Token extraction and manipulation
4699  *
4700  * The routines in this group provide access to the tokens within a
4701  * translation unit, along with a semantic mapping of those tokens to
4702  * their corresponding cursors.
4703  *
4704  * @{
4705  */
4706 
4707 /**
4708  * Describes a kind of token.
4709  */
4710 typedef enum CXTokenKind {
4711  /**
4712  * A token that contains some kind of punctuation.
4713  */
4715 
4716  /**
4717  * A language keyword.
4718  */
4720 
4721  /**
4722  * An identifier (that is not a keyword).
4723  */
4725 
4726  /**
4727  * A numeric, string, or character literal.
4728  */
4730 
4731  /**
4732  * A comment.
4733  */
4735 } CXTokenKind;
4736 
4737 /**
4738  * Describes a single preprocessing token.
4739  */
4740 typedef struct {
4741  unsigned int_data[4];
4742  void *ptr_data;
4743 } CXToken;
4744 
4745 /**
4746  * Determine the kind of the given token.
4747  */
4749 
4750 /**
4751  * Determine the spelling of the given token.
4752  *
4753  * The spelling of a token is the textual representation of that token, e.g.,
4754  * the text of an identifier or keyword.
4755  */
4757 
4758 /**
4759  * Retrieve the source location of the given token.
4760  */
4762  CXToken);
4763 
4764 /**
4765  * Retrieve a source range that covers the given token.
4766  */
4768 
4769 /**
4770  * Tokenize the source code described by the given range into raw
4771  * lexical tokens.
4772  *
4773  * \param TU the translation unit whose text is being tokenized.
4774  *
4775  * \param Range the source range in which text should be tokenized. All of the
4776  * tokens produced by tokenization will fall within this source range,
4777  *
4778  * \param Tokens this pointer will be set to point to the array of tokens
4779  * that occur within the given source range. The returned pointer must be
4780  * freed with clang_disposeTokens() before the translation unit is destroyed.
4781  *
4782  * \param NumTokens will be set to the number of tokens in the \c *Tokens
4783  * array.
4784  *
4785  */
4786 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4787  CXToken **Tokens, unsigned *NumTokens);
4788 
4789 /**
4790  * Annotate the given set of tokens by providing cursors for each token
4791  * that can be mapped to a specific entity within the abstract syntax tree.
4792  *
4793  * This token-annotation routine is equivalent to invoking
4794  * clang_getCursor() for the source locations of each of the
4795  * tokens. The cursors provided are filtered, so that only those
4796  * cursors that have a direct correspondence to the token are
4797  * accepted. For example, given a function call \c f(x),
4798  * clang_getCursor() would provide the following cursors:
4799  *
4800  * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4801  * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4802  * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4803  *
4804  * Only the first and last of these cursors will occur within the
4805  * annotate, since the tokens "f" and "x' directly refer to a function
4806  * and a variable, respectively, but the parentheses are just a small
4807  * part of the full syntax of the function call expression, which is
4808  * not provided as an annotation.
4809  *
4810  * \param TU the translation unit that owns the given tokens.
4811  *
4812  * \param Tokens the set of tokens to annotate.
4813  *
4814  * \param NumTokens the number of tokens in \p Tokens.
4815  *
4816  * \param Cursors an array of \p NumTokens cursors, whose contents will be
4817  * replaced with the cursors corresponding to each token.
4818  */
4819 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4820  CXToken *Tokens, unsigned NumTokens,
4821  CXCursor *Cursors);
4822 
4823 /**
4824  * Free the given set of tokens.
4825  */
4826 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4827  CXToken *Tokens, unsigned NumTokens);
4828 
4829 /**
4830  * @}
4831  */
4832 
4833 /**
4834  * \defgroup CINDEX_DEBUG Debugging facilities
4835  *
4836  * These routines are used for testing and debugging, only, and should not
4837  * be relied upon.
4838  *
4839  * @{
4840  */
4841 
4842 /* for debug/testing */
4845  const char **startBuf,
4846  const char **endBuf,
4847  unsigned *startLine,
4848  unsigned *startColumn,
4849  unsigned *endLine,
4850  unsigned *endColumn);
4852 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4853  unsigned stack_size);
4854 
4855 /**
4856  * @}
4857  */
4858 
4859 /**
4860  * \defgroup CINDEX_CODE_COMPLET Code completion
4861  *
4862  * Code completion involves taking an (incomplete) source file, along with
4863  * knowledge of where the user is actively editing that file, and suggesting
4864  * syntactically- and semantically-valid constructs that the user might want to
4865  * use at that particular point in the source code. These data structures and
4866  * routines provide support for code completion.
4867  *
4868  * @{
4869  */
4870 
4871 /**
4872  * A semantic string that describes a code-completion result.
4873  *
4874  * A semantic string that describes the formatting of a code-completion
4875  * result as a single "template" of text that should be inserted into the
4876  * source buffer when a particular code-completion result is selected.
4877  * Each semantic string is made up of some number of "chunks", each of which
4878  * contains some text along with a description of what that text means, e.g.,
4879  * the name of the entity being referenced, whether the text chunk is part of
4880  * the template, or whether it is a "placeholder" that the user should replace
4881  * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4882  * description of the different kinds of chunks.
4883  */
4884 typedef void *CXCompletionString;
4885 
4886 /**
4887  * A single result of code completion.
4888  */
4889 typedef struct {
4890  /**
4891  * The kind of entity that this completion refers to.
4892  *
4893  * The cursor kind will be a macro, keyword, or a declaration (one of the
4894  * *Decl cursor kinds), describing the entity that the completion is
4895  * referring to.
4896  *
4897  * \todo In the future, we would like to provide a full cursor, to allow
4898  * the client to extract additional information from declaration.
4899  */
4900  enum CXCursorKind CursorKind;
4901 
4902  /**
4903  * The code-completion string that describes how to insert this
4904  * code-completion result into the editing buffer.
4905  */
4906  CXCompletionString CompletionString;
4908 
4909 /**
4910  * Describes a single piece of text within a code-completion string.
4911  *
4912  * Each "chunk" within a code-completion string (\c CXCompletionString) is
4913  * either a piece of text with a specific "kind" that describes how that text
4914  * should be interpreted by the client or is another completion string.
4915  */
4917  /**
4918  * A code-completion string that describes "optional" text that
4919  * could be a part of the template (but is not required).
4920  *
4921  * The Optional chunk is the only kind of chunk that has a code-completion
4922  * string for its representation, which is accessible via
4923  * \c clang_getCompletionChunkCompletionString(). The code-completion string
4924  * describes an additional part of the template that is completely optional.
4925  * For example, optional chunks can be used to describe the placeholders for
4926  * arguments that match up with defaulted function parameters, e.g. given:
4927  *
4928  * \code
4929  * void f(int x, float y = 3.14, double z = 2.71828);
4930  * \endcode
4931  *
4932  * The code-completion string for this function would contain:
4933  * - a TypedText chunk for "f".
4934  * - a LeftParen chunk for "(".
4935  * - a Placeholder chunk for "int x"
4936  * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4937  * - a Comma chunk for ","
4938  * - a Placeholder chunk for "float y"
4939  * - an Optional chunk containing the last defaulted argument:
4940  * - a Comma chunk for ","
4941  * - a Placeholder chunk for "double z"
4942  * - a RightParen chunk for ")"
4943  *
4944  * There are many ways to handle Optional chunks. Two simple approaches are:
4945  * - Completely ignore optional chunks, in which case the template for the
4946  * function "f" would only include the first parameter ("int x").
4947  * - Fully expand all optional chunks, in which case the template for the
4948  * function "f" would have all of the parameters.
4949  */
4951  /**
4952  * Text that a user would be expected to type to get this
4953  * code-completion result.
4954  *
4955  * There will be exactly one "typed text" chunk in a semantic string, which
4956  * will typically provide the spelling of a keyword or the name of a
4957  * declaration that could be used at the current code point. Clients are
4958  * expected to filter the code-completion results based on the text in this
4959  * chunk.
4960  */
4962  /**
4963  * Text that should be inserted as part of a code-completion result.
4964  *
4965  * A "text" chunk represents text that is part of the template to be
4966  * inserted into user code should this particular code-completion result
4967  * be selected.
4968  */
4970  /**
4971  * Placeholder text that should be replaced by the user.
4972  *
4973  * A "placeholder" chunk marks a place where the user should insert text
4974  * into the code-completion template. For example, placeholders might mark
4975  * the function parameters for a function declaration, to indicate that the
4976  * user should provide arguments for each of those parameters. The actual
4977  * text in a placeholder is a suggestion for the text to display before
4978  * the user replaces the placeholder with real code.
4979  */
4981  /**
4982  * Informative text that should be displayed but never inserted as
4983  * part of the template.
4984  *
4985  * An "informative" chunk contains annotations that can be displayed to
4986  * help the user decide whether a particular code-completion result is the
4987  * right option, but which is not part of the actual template to be inserted
4988  * by code completion.
4989  */
4991  /**
4992  * Text that describes the current parameter when code-completion is
4993  * referring to function call, message send, or template specialization.
4994  *
4995  * A "current parameter" chunk occurs when code-completion is providing
4996  * information about a parameter corresponding to the argument at the
4997  * code-completion point. For example, given a function
4998  *
4999  * \code
5000  * int add(int x, int y);
5001  * \endcode
5002  *
5003  * and the source code \c add(, where the code-completion point is after the
5004  * "(", the code-completion string will contain a "current parameter" chunk
5005  * for "int x", indicating that the current argument will initialize that
5006  * parameter. After typing further, to \c add(17, (where the code-completion
5007  * point is after the ","), the code-completion string will contain a
5008  * "current parameter" chunk to "int y".
5009  */
5011  /**
5012  * A left parenthesis ('('), used to initiate a function call or
5013  * signal the beginning of a function parameter list.
5014  */
5016  /**
5017  * A right parenthesis (')'), used to finish a function call or
5018  * signal the end of a function parameter list.
5019  */
5021  /**
5022  * A left bracket ('[').
5023  */
5025  /**
5026  * A right bracket (']').
5027  */
5029  /**
5030  * A left brace ('{').
5031  */
5033  /**
5034  * A right brace ('}').
5035  */
5037  /**
5038  * A left angle bracket ('<').
5039  */
5041  /**
5042  * A right angle bracket ('>').
5043  */
5045  /**
5046  * A comma separator (',').
5047  */
5049  /**
5050  * Text that specifies the result type of a given result.
5051  *
5052  * This special kind of informative chunk is not meant to be inserted into
5053  * the text buffer. Rather, it is meant to illustrate the type that an
5054  * expression using the given completion string would have.
5055  */
5057  /**
5058  * A colon (':').
5059  */
5061  /**
5062  * A semicolon (';').
5063  */
5065  /**
5066  * An '=' sign.
5067  */
5069  /**
5070  * Horizontal space (' ').
5071  */
5073  /**
5074  * Vertical space ('\\n'), after which it is generally a good idea to
5075  * perform indentation.
5076  */
5078 };
5079 
5080 /**
5081  * Determine the kind of a particular chunk within a completion string.
5082  *
5083  * \param completion_string the completion string to query.
5084  *
5085  * \param chunk_number the 0-based index of the chunk in the completion string.
5086  *
5087  * \returns the kind of the chunk at the index \c chunk_number.
5088  */
5090 clang_getCompletionChunkKind(CXCompletionString completion_string,
5091  unsigned chunk_number);
5092 
5093 /**
5094  * Retrieve the text associated with a particular chunk within a
5095  * completion string.
5096  *
5097  * \param completion_string the completion string to query.
5098  *
5099  * \param chunk_number the 0-based index of the chunk in the completion string.
5100  *
5101  * \returns the text associated with the chunk at index \c chunk_number.
5102  */
5104 clang_getCompletionChunkText(CXCompletionString completion_string,
5105  unsigned chunk_number);
5106 
5107 /**
5108  * Retrieve the completion string associated with a particular chunk
5109  * within a completion string.
5110  *
5111  * \param completion_string the completion string to query.
5112  *
5113  * \param chunk_number the 0-based index of the chunk in the completion string.
5114  *
5115  * \returns the completion string associated with the chunk at index
5116  * \c chunk_number.
5117  */
5118 CINDEX_LINKAGE CXCompletionString
5119 clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
5120  unsigned chunk_number);
5121 
5122 /**
5123  * Retrieve the number of chunks in the given code-completion string.
5124  */
5125 CINDEX_LINKAGE unsigned
5126 clang_getNumCompletionChunks(CXCompletionString completion_string);
5127 
5128 /**
5129  * Determine the priority of this code completion.
5130  *
5131  * The priority of a code completion indicates how likely it is that this
5132  * particular completion is the completion that the user will select. The
5133  * priority is selected by various internal heuristics.
5134  *
5135  * \param completion_string The completion string to query.
5136  *
5137  * \returns The priority of this completion string. Smaller values indicate
5138  * higher-priority (more likely) completions.
5139  */
5140 CINDEX_LINKAGE unsigned
5141 clang_getCompletionPriority(CXCompletionString completion_string);
5142 
5143 /**
5144  * Determine the availability of the entity that this code-completion
5145  * string refers to.
5146  *
5147  * \param completion_string The completion string to query.
5148  *
5149  * \returns The availability of the completion string.
5150  */
5152 clang_getCompletionAvailability(CXCompletionString completion_string);
5153 
5154 /**
5155  * Retrieve the number of annotations associated with the given
5156  * completion string.
5157  *
5158  * \param completion_string the completion string to query.
5159  *
5160  * \returns the number of annotations associated with the given completion
5161  * string.
5162  */
5163 CINDEX_LINKAGE unsigned
5164 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5165 
5166 /**
5167  * Retrieve the annotation associated with the given completion string.
5168  *
5169  * \param completion_string the completion string to query.
5170  *
5171  * \param annotation_number the 0-based index of the annotation of the
5172  * completion string.
5173  *
5174  * \returns annotation string associated with the completion at index
5175  * \c annotation_number, or a NULL string if that annotation is not available.
5176  */
5178 clang_getCompletionAnnotation(CXCompletionString completion_string,
5179  unsigned annotation_number);
5180 
5181 /**
5182  * Retrieve the parent context of the given completion string.
5183  *
5184  * The parent context of a completion string is the semantic parent of
5185  * the declaration (if any) that the code completion represents. For example,
5186  * a code completion for an Objective-C method would have the method's class
5187  * or protocol as its context.
5188  *
5189  * \param completion_string The code completion string whose parent is
5190  * being queried.
5191  *
5192  * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5193  *
5194  * \returns The name of the completion parent, e.g., "NSObject" if
5195  * the completion string represents a method in the NSObject class.
5196  */
5198 clang_getCompletionParent(CXCompletionString completion_string,
5199  enum CXCursorKind *kind);
5200 
5201 /**
5202  * Retrieve the brief documentation comment attached to the declaration
5203  * that corresponds to the given completion string.
5204  */
5206 clang_getCompletionBriefComment(CXCompletionString completion_string);
5207 
5208 /**
5209  * Retrieve a completion string for an arbitrary declaration or macro
5210  * definition cursor.
5211  *
5212  * \param cursor The cursor to query.
5213  *
5214  * \returns A non-context-sensitive completion string for declaration and macro
5215  * definition cursors, or NULL for other kinds of cursors.
5216  */
5217 CINDEX_LINKAGE CXCompletionString
5219 
5220 /**
5221  * Contains the results of code-completion.
5222  *
5223  * This data structure contains the results of code completion, as
5224  * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5225  * \c clang_disposeCodeCompleteResults.
5226  */
5227 typedef struct {
5228  /**
5229  * The code-completion results.
5230  */
5232 
5233  /**
5234  * The number of code-completion results stored in the
5235  * \c Results array.
5236  */
5237  unsigned NumResults;
5239 
5240 /**
5241  * Flags that can be passed to \c clang_codeCompleteAt() to
5242  * modify its behavior.
5243  *
5244  * The enumerators in this enumeration can be bitwise-OR'd together to
5245  * provide multiple options to \c clang_codeCompleteAt().
5246  */
5248  /**
5249  * Whether to include macros within the set of code
5250  * completions returned.
5251  */
5253 
5254  /**
5255  * Whether to include code patterns for language constructs
5256  * within the set of code completions, e.g., for loops.
5257  */
5259 
5260  /**
5261  * Whether to include brief documentation within the set of code
5262  * completions returned.
5263  */
5265 
5266  /**
5267  * Whether to speed up completion by omitting top- or namespace-level entities
5268  * defined in the preamble. There's no guarantee any particular entity is
5269  * omitted. This may be useful if the headers are indexed externally.
5270  */
5272 };
5273 
5274 /**
5275  * Bits that represent the context under which completion is occurring.
5276  *
5277  * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5278  * contexts are occurring simultaneously.
5279  */
5281  /**
5282  * The context for completions is unexposed, as only Clang results
5283  * should be included. (This is equivalent to having no context bits set.)
5284  */
5286 
5287  /**
5288  * Completions for any possible type should be included in the results.
5289  */
5291 
5292  /**
5293  * Completions for any possible value (variables, function calls, etc.)
5294  * should be included in the results.
5295  */
5297  /**
5298  * Completions for values that resolve to an Objective-C object should
5299  * be included in the results.
5300  */
5302  /**
5303  * Completions for values that resolve to an Objective-C selector
5304  * should be included in the results.
5305  */
5307  /**
5308  * Completions for values that resolve to a C++ class type should be
5309  * included in the results.
5310  */
5312 
5313  /**
5314  * Completions for fields of the member being accessed using the dot
5315  * operator should be included in the results.
5316  */
5318  /**
5319  * Completions for fields of the member being accessed using the arrow
5320  * operator should be included in the results.
5321  */
5323  /**
5324  * Completions for properties of the Objective-C object being accessed
5325  * using the dot operator should be included in the results.
5326  */
5328 
5329  /**
5330  * Completions for enum tags should be included in the results.
5331  */
5333  /**
5334  * Completions for union tags should be included in the results.
5335  */
5337  /**
5338  * Completions for struct tags should be included in the results.
5339  */
5341 
5342  /**
5343  * Completions for C++ class names should be included in the results.
5344  */
5346  /**
5347  * Completions for C++ namespaces and namespace aliases should be
5348  * included in the results.
5349  */
5351  /**
5352  * Completions for C++ nested name specifiers should be included in
5353  * the results.
5354  */
5356 
5357  /**
5358  * Completions for Objective-C interfaces (classes) should be included
5359  * in the results.
5360  */
5362  /**
5363  * Completions for Objective-C protocols should be included in
5364  * the results.
5365  */
5367  /**
5368  * Completions for Objective-C categories should be included in
5369  * the results.
5370  */
5372  /**
5373  * Completions for Objective-C instance messages should be included
5374  * in the results.
5375  */
5377  /**
5378  * Completions for Objective-C class messages should be included in
5379  * the results.
5380  */
5382  /**
5383  * Completions for Objective-C selector names should be included in
5384  * the results.
5385  */
5387 
5388  /**
5389  * Completions for preprocessor macro names should be included in
5390  * the results.
5391  */
5393 
5394  /**
5395  * Natural language completions should be included in the results.
5396  */
5398 
5399  /**
5400  * The current context is unknown, so set all contexts.
5401  */
5403 };
5404 
5405 /**
5406  * Returns a default set of code-completion options that can be
5407  * passed to\c clang_codeCompleteAt().
5408  */
5410 
5411 /**
5412  * Perform code completion at a given location in a translation unit.
5413  *
5414  * This function performs code completion at a particular file, line, and
5415  * column within source code, providing results that suggest potential
5416  * code snippets based on the context of the completion. The basic model
5417  * for code completion is that Clang will parse a complete source file,
5418  * performing syntax checking up to the location where code-completion has
5419  * been requested. At that point, a special code-completion token is passed
5420  * to the parser, which recognizes this token and determines, based on the
5421  * current location in the C/Objective-C/C++ grammar and the state of
5422  * semantic analysis, what completions to provide. These completions are
5423  * returned via a new \c CXCodeCompleteResults structure.
5424  *
5425  * Code completion itself is meant to be triggered by the client when the
5426  * user types punctuation characters or whitespace, at which point the
5427  * code-completion location will coincide with the cursor. For example, if \c p
5428  * is a pointer, code-completion might be triggered after the "-" and then
5429  * after the ">" in \c p->. When the code-completion location is after the ">",
5430  * the completion results will provide, e.g., the members of the struct that
5431  * "p" points to. The client is responsible for placing the cursor at the
5432  * beginning of the token currently being typed, then filtering the results
5433  * based on the contents of the token. For example, when code-completing for
5434  * the expression \c p->get, the client should provide the location just after
5435  * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5436  * client can filter the results based on the current token text ("get"), only
5437  * showing those results that start with "get". The intent of this interface
5438  * is to separate the relatively high-latency acquisition of code-completion
5439  * results from the filtering of results on a per-character basis, which must
5440  * have a lower latency.
5441  *
5442  * \param TU The translation unit in which code-completion should
5443  * occur. The source files for this translation unit need not be
5444  * completely up-to-date (and the contents of those source files may
5445  * be overridden via \p unsaved_files). Cursors referring into the
5446  * translation unit may be invalidated by this invocation.
5447  *
5448  * \param complete_filename The name of the source file where code
5449  * completion should be performed. This filename may be any file
5450  * included in the translation unit.
5451  *
5452  * \param complete_line The line at which code-completion should occur.
5453  *
5454  * \param complete_column The column at which code-completion should occur.
5455  * Note that the column should point just after the syntactic construct that
5456  * initiated code completion, and not in the middle of a lexical token.
5457  *
5458  * \param unsaved_files the Files that have not yet been saved to disk
5459  * but may be required for parsing or code completion, including the
5460  * contents of those files. The contents and name of these files (as
5461  * specified by CXUnsavedFile) are copied when necessary, so the
5462  * client only needs to guarantee their validity until the call to
5463  * this function returns.
5464  *
5465  * \param num_unsaved_files The number of unsaved file entries in \p
5466  * unsaved_files.
5467  *
5468  * \param options Extra options that control the behavior of code
5469  * completion, expressed as a bitwise OR of the enumerators of the
5470  * CXCodeComplete_Flags enumeration. The
5471  * \c clang_defaultCodeCompleteOptions() function returns a default set
5472  * of code-completion options.
5473  *
5474  * \returns If successful, a new \c CXCodeCompleteResults structure
5475  * containing code-completion results, which should eventually be
5476  * freed with \c clang_disposeCodeCompleteResults(). If code
5477  * completion fails, returns NULL.
5478  */
5480 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5481  const char *complete_filename,
5482  unsigned complete_line,
5483  unsigned complete_column,
5484  struct CXUnsavedFile *unsaved_files,
5485  unsigned num_unsaved_files,
5486  unsigned options);
5487 
5488 /**
5489  * Sort the code-completion results in case-insensitive alphabetical
5490  * order.
5491  *
5492  * \param Results The set of results to sort.
5493  * \param NumResults The number of results in \p Results.
5494  */
5497  unsigned NumResults);
5498 
5499 /**
5500  * Free the given set of code-completion results.
5501  */
5504 
5505 /**
5506  * Determine the number of diagnostics produced prior to the
5507  * location where code completion was performed.
5508  */
5511 
5512 /**
5513  * Retrieve a diagnostic associated with the given code completion.
5514  *
5515  * \param Results the code completion results to query.
5516  * \param Index the zero-based diagnostic number to retrieve.
5517  *
5518  * \returns the requested diagnostic. This diagnostic must be freed
5519  * via a call to \c clang_disposeDiagnostic().
5520  */
5523  unsigned Index);
5524 
5525 /**
5526  * Determines what completions are appropriate for the context
5527  * the given code completion.
5528  *
5529  * \param Results the code completion results to query
5530  *
5531  * \returns the kinds of completions that are appropriate for use
5532  * along with the given code completion results.
5533  */
5535 unsigned long long clang_codeCompleteGetContexts(
5536  CXCodeCompleteResults *Results);
5537 
5538 /**
5539  * Returns the cursor kind for the container for the current code
5540  * completion context. The container is only guaranteed to be set for
5541  * contexts where a container exists (i.e. member accesses or Objective-C
5542  * message sends); if there is not a container, this function will return
5543  * CXCursor_InvalidCode.
5544  *
5545  * \param Results the code completion results to query
5546  *
5547  * \param IsIncomplete on return, this value will be false if Clang has complete
5548  * information about the container. If Clang does not have complete
5549  * information, this value will be true.
5550  *
5551  * \returns the container kind, or CXCursor_InvalidCode if there is not a
5552  * container
5553  */
5556  CXCodeCompleteResults *Results,
5557  unsigned *IsIncomplete);
5558 
5559 /**
5560  * Returns the USR for the container for the current code completion
5561  * context. If there is not a container for the current context, this
5562  * function will return the empty string.
5563  *
5564  * \param Results the code completion results to query
5565  *
5566  * \returns the USR for the container
5567  */
5570 
5571 /**
5572  * Returns the currently-entered selector for an Objective-C message
5573  * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5574  * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5575  * CXCompletionContext_ObjCClassMessage.
5576  *
5577  * \param Results the code completion results to query
5578  *
5579  * \returns the selector (or partial selector) that has been entered thus far
5580  * for an Objective-C message send.
5581  */
5584 
5585 /**
5586  * @}
5587  */
5588 
5589 /**
5590  * \defgroup CINDEX_MISC Miscellaneous utility functions
5591  *
5592  * @{
5593  */
5594 
5595 /**
5596  * Return a version string, suitable for showing to a user, but not
5597  * intended to be parsed (the format is not guaranteed to be stable).
5598  */
5600 
5601 /**
5602  * Enable/disable crash recovery.
5603  *
5604  * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5605  * value enables crash recovery, while 0 disables it.
5606  */
5608 
5609  /**
5610  * Visitor invoked for each file in a translation unit
5611  * (used with clang_getInclusions()).
5612  *
5613  * This visitor function will be invoked by clang_getInclusions() for each
5614  * file included (either at the top-level or by \#include directives) within
5615  * a translation unit. The first argument is the file being included, and
5616  * the second and third arguments provide the inclusion stack. The
5617  * array is sorted in order of immediate inclusion. For example,
5618  * the first element refers to the location that included 'included_file'.
5619  */
5620 typedef void (*CXInclusionVisitor)(CXFile included_file,
5621  CXSourceLocation* inclusion_stack,
5622  unsigned include_len,
5623  CXClientData client_data);
5624 
5625 /**
5626  * Visit the set of preprocessor inclusions in a translation unit.
5627  * The visitor function is called with the provided data for every included
5628  * file. This does not include headers included by the PCH file (unless one
5629  * is inspecting the inclusions in the PCH file itself).
5630  */
5631 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5632  CXInclusionVisitor visitor,
5633  CXClientData client_data);
5634 
5635 typedef enum {
5642 
5644 
5645 } CXEvalResultKind ;
5646 
5647 /**
5648  * Evaluation result of a cursor
5649  */
5650 typedef void * CXEvalResult;
5651 
5652 /**
5653  * If cursor is a statement declaration tries to evaluate the
5654  * statement and if its variable, tries to evaluate its initializer,
5655  * into its corresponding type.
5656  */
5658 
5659 /**
5660  * Returns the kind of the evaluated result.
5661  */
5663 
5664 /**
5665  * Returns the evaluation result as integer if the
5666  * kind is Int.
5667  */
5668 CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5669 
5670 /**
5671  * Returns the evaluation result as a long long integer if the
5672  * kind is Int. This prevents overflows that may happen if the result is
5673  * returned with clang_EvalResult_getAsInt.
5674  */
5675 CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5676 
5677 /**
5678  * Returns a non-zero value if the kind is Int and the evaluation
5679  * result resulted in an unsigned integer.
5680  */
5681 CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5682 
5683 /**
5684  * Returns the evaluation result as an unsigned integer if
5685  * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5686  */
5687 CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5688 
5689 /**
5690  * Returns the evaluation result as double if the
5691  * kind is double.
5692  */
5693 CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5694 
5695 /**
5696  * Returns the evaluation result as a constant string if the
5697  * kind is other than Int or float. User must not free this pointer,
5698  * instead call clang_EvalResult_dispose on the CXEvalResult returned
5699  * by clang_Cursor_Evaluate.
5700  */
5701 CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
5702 
5703 /**
5704  * Disposes the created Eval memory.
5705  */
5706 CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5707 /**
5708  * @}
5709&