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 49
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  * 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 */
3193 
3213 
3214  /**
3215  * Represents a type that was referred to using an elaborated type keyword.
3216  *
3217  * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3218  */
3220 
3221  /* OpenCL PipeType. */
3223 
3224  /* OpenCL builtin types. */
3265 };
3266 
3267 /**
3268  * Describes the calling convention of a function type
3269  */
3282  /* Alias for compatibility with older versions of API. */
3289 
3292 };
3293 
3294 /**
3295  * The type of an element in the abstract syntax tree.
3296  *
3297  */
3298 typedef struct {
3300  void *data[2];
3301 } CXType;
3302 
3303 /**
3304  * Retrieve the type of a CXCursor (if any).
3305  */
3307 
3308 /**
3309  * Pretty-print the underlying type using the rules of the
3310  * language of the translation unit from which it came.
3311  *
3312  * If the type is invalid, an empty string is returned.
3313  */
3315 
3316 /**
3317  * Retrieve the underlying type of a typedef declaration.
3318  *
3319  * If the cursor does not reference a typedef declaration, an invalid type is
3320  * returned.
3321  */
3323 
3324 /**
3325  * Retrieve the integer type of an enum declaration.
3326  *
3327  * If the cursor does not reference an enum declaration, an invalid type is
3328  * returned.
3329  */
3331 
3332 /**
3333  * Retrieve the integer value of an enum constant declaration as a signed
3334  * long long.
3335  *
3336  * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3337  * Since this is also potentially a valid constant value, the kind of the cursor
3338  * must be verified before calling this function.
3339  */
3341 
3342 /**
3343  * Retrieve the integer value of an enum constant declaration as an unsigned
3344  * long long.
3345  *
3346  * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3347  * Since this is also potentially a valid constant value, the kind of the cursor
3348  * must be verified before calling this function.
3349  */
3351 
3352 /**
3353  * Retrieve the bit width of a bit field declaration as an integer.
3354  *
3355  * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3356  */
3358 
3359 /**
3360  * Retrieve the number of non-variadic arguments associated with a given
3361  * cursor.
3362  *
3363  * The number of arguments can be determined for calls as well as for
3364  * declarations of functions or methods. For other cursors -1 is returned.
3365  */
3367 
3368 /**
3369  * Retrieve the argument cursor of a function or method.
3370  *
3371  * The argument cursor can be determined for calls as well as for declarations
3372  * of functions or methods. For other cursors and for invalid indices, an
3373  * invalid cursor is returned.
3374  */
3376 
3377 /**
3378  * Describes the kind of a template argument.
3379  *
3380  * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3381  * element descriptions.
3382  */
3393  /* Indicates an error case, preventing the kind from being deduced. */
3395 };
3396 
3397 /**
3398  *Returns the number of template args of a function decl representing a
3399  * template specialization.
3400  *
3401  * If the argument cursor cannot be converted into a template function
3402  * declaration, -1 is returned.
3403  *
3404  * For example, for the following declaration and specialization:
3405  * template <typename T, int kInt, bool kBool>
3406  * void foo() { ... }
3407  *
3408  * template <>
3409  * void foo<float, -7, true>();
3410  *
3411  * The value 3 would be returned from this call.
3412  */
3414 
3415 /**
3416  * Retrieve the kind of the I'th template argument of the CXCursor C.
3417  *
3418  * If the argument CXCursor does not represent a FunctionDecl, an invalid
3419  * template argument kind is returned.
3420  *
3421  * For example, for the following declaration and specialization:
3422  * template <typename T, int kInt, bool kBool>
3423  * void foo() { ... }
3424  *
3425  * template <>
3426  * void foo<float, -7, true>();
3427  *
3428  * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3429  * respectively.
3430  */
3432  CXCursor C, unsigned I);
3433 
3434 /**
3435  * Retrieve a CXType representing the type of a TemplateArgument of a
3436  * function decl representing a template specialization.
3437  *
3438  * If the argument CXCursor does not represent a FunctionDecl whose I'th
3439  * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3440  * is returned.
3441  *
3442  * For example, for the following declaration and specialization:
3443  * template <typename T, int kInt, bool kBool>
3444  * void foo() { ... }
3445  *
3446  * template <>
3447  * void foo<float, -7, true>();
3448  *
3449  * If called with I = 0, "float", will be returned.
3450  * Invalid types will be returned for I == 1 or 2.
3451  */
3453  unsigned I);
3454 
3455 /**
3456  * Retrieve the value of an Integral TemplateArgument (of a function
3457  * decl representing a template specialization) as a signed long long.
3458  *
3459  * It is undefined to call this function on a CXCursor that does not represent a
3460  * FunctionDecl or whose I'th template argument is not an integral value.
3461  *
3462  * For example, for the following declaration and specialization:
3463  * template <typename T, int kInt, bool kBool>
3464  * void foo() { ... }
3465  *
3466  * template <>
3467  * void foo<float, -7, true>();
3468  *
3469  * If called with I = 1 or 2, -7 or true will be returned, respectively.
3470  * For I == 0, this function's behavior is undefined.
3471  */
3473  unsigned I);
3474 
3475 /**
3476  * Retrieve the value of an Integral TemplateArgument (of a function
3477  * decl representing a template specialization) as an unsigned long long.
3478  *
3479  * It is undefined to call this function on a CXCursor that does not represent a
3480  * FunctionDecl or whose I'th template argument is not an integral value.
3481  *
3482  * For example, for the following declaration and specialization:
3483  * template <typename T, int kInt, bool kBool>
3484  * void foo() { ... }
3485  *
3486  * template <>
3487  * void foo<float, 2147483649, true>();
3488  *
3489  * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3490  * For I == 0, this function's behavior is undefined.
3491  */
3493  CXCursor C, unsigned I);
3494 
3495 /**
3496  * Determine whether two CXTypes represent the same type.
3497  *
3498  * \returns non-zero if the CXTypes represent the same type and
3499  * zero otherwise.
3500  */
3502 
3503 /**
3504  * Return the canonical type for a CXType.
3505  *
3506  * Clang's type system explicitly models typedefs and all the ways
3507  * a specific type can be represented. The canonical type is the underlying
3508  * type with all the "sugar" removed. For example, if 'T' is a typedef
3509  * for 'int', the canonical type for 'T' would be 'int'.
3510  */
3512 
3513 /**
3514  * Determine whether a CXType has the "const" qualifier set,
3515  * without looking through typedefs that may have added "const" at a
3516  * different level.
3517  */
3519 
3520 /**
3521  * Determine whether a CXCursor that is a macro, is
3522  * function like.
3523  */
3525 
3526 /**
3527  * Determine whether a CXCursor that is a macro, is a
3528  * builtin one.
3529  */
3531 
3532 /**
3533  * Determine whether a CXCursor that is a function declaration, is an
3534  * inline declaration.
3535  */
3537 
3538 /**
3539  * Determine whether a CXType has the "volatile" qualifier set,
3540  * without looking through typedefs that may have added "volatile" at
3541  * a different level.
3542  */
3544 
3545 /**
3546  * Determine whether a CXType has the "restrict" qualifier set,
3547  * without looking through typedefs that may have added "restrict" at a
3548  * different level.
3549  */
3551 
3552 /**
3553  * Returns the address space of the given type.
3554  */
3556 
3557 /**
3558  * Returns the typedef name of the given type.
3559  */
3561 
3562 /**
3563  * For pointer types, returns the type of the pointee.
3564  */
3566 
3567 /**
3568  * Return the cursor for the declaration of the given type.
3569  */
3571 
3572 /**
3573  * Returns the Objective-C type encoding for the specified declaration.
3574  */
3576 
3577 /**
3578  * Returns the Objective-C type encoding for the specified CXType.
3579  */
3581 
3582 /**
3583  * Retrieve the spelling of a given CXTypeKind.
3584  */
3586 
3587 /**
3588  * Retrieve the calling convention associated with a function type.
3589  *
3590  * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3591  */
3593 
3594 /**
3595  * Retrieve the return type associated with a function type.
3596  *
3597  * If a non-function type is passed in, an invalid type is returned.
3598  */
3600 
3601 /**
3602  * Retrieve the exception specification type associated with a function type.
3603  * This is a value of type CXCursor_ExceptionSpecificationKind.
3604  *
3605  * If a non-function type is passed in, an error code of -1 is returned.
3606  */
3608 
3609 /**
3610  * Retrieve the number of non-variadic parameters associated with a
3611  * function type.
3612  *
3613  * If a non-function type is passed in, -1 is returned.
3614  */
3616 
3617 /**
3618  * Retrieve the type of a parameter of a function type.
3619  *
3620  * If a non-function type is passed in or the function does not have enough
3621  * parameters, an invalid type is returned.
3622  */
3624 
3625 /**
3626  * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3627  */
3629 
3630 /**
3631  * Retrieve the return type associated with a given cursor.
3632  *
3633  * This only returns a valid type if the cursor refers to a function or method.
3634  */
3636 
3637 /**
3638  * Retrieve the exception specification type associated with a given cursor.
3639  * This is a value of type CXCursor_ExceptionSpecificationKind.
3640  *
3641  * This only returns a valid result if the cursor refers to a function or method.
3642  */
3644 
3645 /**
3646  * Return 1 if the CXType is a POD (plain old data) type, and 0
3647  * otherwise.
3648  */
3650 
3651 /**
3652  * Return the element type of an array, complex, or vector type.
3653  *
3654  * If a type is passed in that is not an array, complex, or vector type,
3655  * an invalid type is returned.
3656  */
3658 
3659 /**
3660  * Return the number of elements of an array or vector type.
3661  *
3662  * If a type is passed in that is not an array or vector type,
3663  * -1 is returned.
3664  */
3666 
3667 /**
3668  * Return the element type of an array type.
3669  *
3670  * If a non-array type is passed in, an invalid type is returned.
3671  */
3673 
3674 /**
3675  * Return the array size of a constant array.
3676  *
3677  * If a non-array type is passed in, -1 is returned.
3678  */
3680 
3681 /**
3682  * Retrieve the type named by the qualified-id.
3683  *
3684  * If a non-elaborated type is passed in, an invalid type is returned.
3685  */
3687 
3688 /**
3689  * Determine if a typedef is 'transparent' tag.
3690  *
3691  * A typedef is considered 'transparent' if it shares a name and spelling
3692  * location with its underlying tag type, as is the case with the NS_ENUM macro.
3693  *
3694  * \returns non-zero if transparent and zero otherwise.
3695  */
3697 
3698 /**
3699  * List the possible error codes for \c clang_Type_getSizeOf,
3700  * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3701  * \c clang_Cursor_getOffsetOf.
3702  *
3703  * A value of this enumeration type can be returned if the target type is not
3704  * a valid argument to sizeof, alignof or offsetof.
3705  */
3707  /**
3708  * Type is of kind CXType_Invalid.
3709  */
3711  /**
3712  * The type is an incomplete Type.
3713  */
3715  /**
3716  * The type is a dependent Type.
3717  */
3719  /**
3720  * The type is not a constant size type.
3721  */
3723  /**
3724  * The Field name is not valid for this record.
3725  */
3727 };
3728 
3729 /**
3730  * Return the alignment of a type in bytes as per C++[expr.alignof]
3731  * standard.
3732  *
3733  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3734  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3735  * is returned.
3736  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3737  * returned.
3738  * If the type declaration is not a constant size type,
3739  * CXTypeLayoutError_NotConstantSize is returned.
3740  */
3742 
3743 /**
3744  * Return the class type of an member pointer type.
3745  *
3746  * If a non-member-pointer type is passed in, an invalid type is returned.
3747  */
3749 
3750 /**
3751  * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3752  *
3753  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3754  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3755  * is returned.
3756  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3757  * returned.
3758  */
3760 
3761 /**
3762  * Return the offset of a field named S in a record of type T in bits
3763  * as it would be returned by __offsetof__ as per C++11[18.2p4]
3764  *
3765  * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3766  * is returned.
3767  * If the field's type declaration is an incomplete type,
3768  * CXTypeLayoutError_Incomplete is returned.
3769  * If the field's type declaration is a dependent type,
3770  * CXTypeLayoutError_Dependent is returned.
3771  * If the field's name S is not found,
3772  * CXTypeLayoutError_InvalidFieldName is returned.
3773  */
3774 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3775 
3776 /**
3777  * Return the offset of the field represented by the Cursor.
3778  *
3779  * If the cursor is not a field declaration, -1 is returned.
3780  * If the cursor semantic parent is not a record field declaration,
3781  * CXTypeLayoutError_Invalid is returned.
3782  * If the field's type declaration is an incomplete type,
3783  * CXTypeLayoutError_Incomplete is returned.
3784  * If the field's type declaration is a dependent type,
3785  * CXTypeLayoutError_Dependent is returned.
3786  * If the field's name S is not found,
3787  * CXTypeLayoutError_InvalidFieldName is returned.
3788  */
3790 
3791 /**
3792  * Determine whether the given cursor represents an anonymous record
3793  * declaration.
3794  */
3796 
3798  /** No ref-qualifier was provided. */
3800  /** An lvalue ref-qualifier was provided (\c &). */
3802  /** An rvalue ref-qualifier was provided (\c &&). */
3804 };
3805 
3806 /**
3807  * Returns the number of template arguments for given template
3808  * specialization, or -1 if type \c T is not a template specialization.
3809  */
3811 
3812 /**
3813  * Returns the type template argument of a template class specialization
3814  * at given index.
3815  *
3816  * This function only returns template type arguments and does not handle
3817  * template template arguments or variadic packs.
3818  */
3820 
3821 /**
3822  * Retrieve the ref-qualifier kind of a function or method.
3823  *
3824  * The ref-qualifier is returned for C++ functions or methods. For other types
3825  * or non-C++ declarations, CXRefQualifier_None is returned.
3826  */
3828 
3829 /**
3830  * Returns non-zero if the cursor specifies a Record member that is a
3831  * bitfield.
3832  */
3834 
3835 /**
3836  * Returns 1 if the base class specified by the cursor with kind
3837  * CX_CXXBaseSpecifier is virtual.
3838  */
3840 
3841 /**
3842  * Represents the C++ access control level to a base class for a
3843  * cursor with kind CX_CXXBaseSpecifier.
3844  */
3850 };
3851 
3852 /**
3853  * Returns the access control level for the referenced object.
3854  *
3855  * If the cursor refers to a C++ declaration, its access control level within its
3856  * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3857  * access specifier, the specifier itself is returned.
3858  */
3860 
3861 /**
3862  * Represents the storage classes as declared in the source. CX_SC_Invalid
3863  * was added for the case that the passed cursor in not a declaration.
3864  */
3874 };
3875 
3876 /**
3877  * Returns the storage class for a function or variable declaration.
3878  *
3879  * If the passed in Cursor is not a function or variable declaration,
3880  * CX_SC_Invalid is returned else the storage class.
3881  */
3883 
3884 /**
3885  * Determine the number of overloaded declarations referenced by a
3886  * \c CXCursor_OverloadedDeclRef cursor.
3887  *
3888  * \param cursor The cursor whose overloaded declarations are being queried.
3889  *
3890  * \returns The number of overloaded declarations referenced by \c cursor. If it
3891  * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3892  */
3894 
3895 /**
3896  * Retrieve a cursor for one of the overloaded declarations referenced
3897  * by a \c CXCursor_OverloadedDeclRef cursor.
3898  *
3899  * \param cursor The cursor whose overloaded declarations are being queried.
3900  *
3901  * \param index The zero-based index into the set of overloaded declarations in
3902  * the cursor.
3903  *
3904  * \returns A cursor representing the declaration referenced by the given
3905  * \c cursor at the specified \c index. If the cursor does not have an
3906  * associated set of overloaded declarations, or if the index is out of bounds,
3907  * returns \c clang_getNullCursor();
3908  */
3910  unsigned index);
3911 
3912 /**
3913  * @}
3914  */
3915 
3916 /**
3917  * \defgroup CINDEX_ATTRIBUTES Information for attributes
3918  *
3919  * @{
3920  */
3921 
3922 /**
3923  * For cursors representing an iboutletcollection attribute,
3924  * this function returns the collection element type.
3925  *
3926  */
3928 
3929 /**
3930  * @}
3931  */
3932 
3933 /**
3934  * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3935  *
3936  * These routines provide the ability to traverse the abstract syntax tree
3937  * using cursors.
3938  *
3939  * @{
3940  */
3941 
3942 /**
3943  * Describes how the traversal of the children of a particular
3944  * cursor should proceed after visiting a particular child cursor.
3945  *
3946  * A value of this enumeration type should be returned by each
3947  * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3948  */
3950  /**
3951  * Terminates the cursor traversal.
3952  */
3954  /**
3955  * Continues the cursor traversal with the next sibling of
3956  * the cursor just visited, without visiting its children.
3957  */
3959  /**
3960  * Recursively traverse the children of this cursor, using
3961  * the same visitor and client data.
3962  */
3964 };
3965 
3966 /**
3967  * Visitor invoked for each cursor found by a traversal.
3968  *
3969  * This visitor function will be invoked for each cursor found by
3970  * clang_visitCursorChildren(). Its first argument is the cursor being
3971  * visited, its second argument is the parent visitor for that cursor,
3972  * and its third argument is the client data provided to
3973  * clang_visitCursorChildren().
3974  *
3975  * The visitor should return one of the \c CXChildVisitResult values
3976  * to direct clang_visitCursorChildren().
3977  */
3979  CXCursor parent,
3980  CXClientData client_data);
3981 
3982 /**
3983  * Visit the children of a particular cursor.
3984  *
3985  * This function visits all the direct children of the given cursor,
3986  * invoking the given \p visitor function with the cursors of each
3987  * visited child. The traversal may be recursive, if the visitor returns
3988  * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3989  * the visitor returns \c CXChildVisit_Break.
3990  *
3991  * \param parent the cursor whose child may be visited. All kinds of
3992  * cursors can be visited, including invalid cursors (which, by
3993  * definition, have no children).
3994  *
3995  * \param visitor the visitor function that will be invoked for each
3996  * child of \p parent.
3997  *
3998  * \param client_data pointer data supplied by the client, which will
3999  * be passed to the visitor each time it is invoked.
4000  *
4001  * \returns a non-zero value if the traversal was terminated
4002  * prematurely by the visitor returning \c CXChildVisit_Break.
4003  */
4005  CXCursorVisitor visitor,
4006  CXClientData client_data);
4007 #ifdef __has_feature
4008 # if __has_feature(blocks)
4009 /**
4010  * Visitor invoked for each cursor found by a traversal.
4011  *
4012  * This visitor block will be invoked for each cursor found by
4013  * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4014  * visited, its second argument is the parent visitor for that cursor.
4015  *
4016  * The visitor should return one of the \c CXChildVisitResult values
4017  * to direct clang_visitChildrenWithBlock().
4018  */
4019 typedef enum CXChildVisitResult
4020  (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
4021 
4022 /**
4023  * Visits the children of a cursor using the specified block. Behaves
4024  * identically to clang_visitChildren() in all other respects.
4025  */
4026 CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
4027  CXCursorVisitorBlock block);
4028 # endif
4029 #endif
4030 
4031 /**
4032  * @}
4033  */
4034 
4035 /**
4036  * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4037  *
4038  * These routines provide the ability to determine references within and
4039  * across translation units, by providing the names of the entities referenced
4040  * by cursors, follow reference cursors to the declarations they reference,
4041  * and associate declarations with their definitions.
4042  *
4043  * @{
4044  */
4045 
4046 /**
4047  * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4048  * by the given cursor.
4049  *
4050  * A Unified Symbol Resolution (USR) is a string that identifies a particular
4051  * entity (function, class, variable, etc.) within a program. USRs can be
4052  * compared across translation units to determine, e.g., when references in
4053  * one translation refer to an entity defined in another translation unit.
4054  */
4056 
4057 /**
4058  * Construct a USR for a specified Objective-C class.
4059  */
4060 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4061 
4062 /**
4063  * Construct a USR for a specified Objective-C category.
4064  */
4066  clang_constructUSR_ObjCCategory(const char *class_name,
4067  const char *category_name);
4068 
4069 /**
4070  * Construct a USR for a specified Objective-C protocol.
4071  */
4073  clang_constructUSR_ObjCProtocol(const char *protocol_name);
4074 
4075 /**
4076  * Construct a USR for a specified Objective-C instance variable and
4077  * the USR for its containing class.
4078  */
4080  CXString classUSR);
4081 
4082 /**
4083  * Construct a USR for a specified Objective-C method and
4084  * the USR for its containing class.
4085  */
4087  unsigned isInstanceMethod,
4088  CXString classUSR);
4089 
4090 /**
4091  * Construct a USR for a specified Objective-C property and the USR
4092  * for its containing class.
4093  */
4095  CXString classUSR);
4096 
4097 /**
4098  * Retrieve a name for the entity referenced by this cursor.
4099  */
4101 
4102 /**
4103  * Retrieve a range for a piece that forms the cursors spelling name.
4104  * Most of the times there is only one range for the complete spelling but for
4105  * Objective-C methods and Objective-C message expressions, there are multiple
4106  * pieces for each selector identifier.
4107  *
4108  * \param pieceIndex the index of the spelling name piece. If this is greater
4109  * than the actual number of pieces, it will return a NULL (invalid) range.
4110  *
4111  * \param options Reserved.
4112  */
4114  unsigned pieceIndex,
4115  unsigned options);
4116 
4117 /**
4118  * Opaque pointer representing a policy that controls pretty printing
4119  * for \c clang_getCursorPrettyPrinted.
4120  */
4121 typedef void *CXPrintingPolicy;
4122 
4123 /**
4124  * Properties for the printing policy.
4125  *
4126  * See \c clang::PrintingPolicy for more information.
4127  */
4155 
4157 };
4158 
4159 /**
4160  * Get a property value for the given printing policy.
4161  */
4162 CINDEX_LINKAGE unsigned
4163 clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4164  enum CXPrintingPolicyProperty Property);
4165 
4166 /**
4167  * Set a property value for the given printing policy.
4168  */
4169 CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4170  enum CXPrintingPolicyProperty Property,
4171  unsigned Value);
4172 
4173 /**
4174  * Retrieve the default policy for the cursor.
4175  *
4176  * The policy should be released after use with \c
4177  * clang_PrintingPolicy_dispose.
4178  */
4180 
4181 /**
4182  * Release a printing policy.
4183  */
4184 CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4185 
4186 /**
4187  * Pretty print declarations.
4188  *
4189  * \param Cursor The cursor representing a declaration.
4190  *
4191  * \param Policy The policy to control the entities being printed. If
4192  * NULL, a default policy is used.
4193  *
4194  * \returns The pretty printed declaration or the empty string for
4195  * other cursors.
4196  */
4198  CXPrintingPolicy Policy);
4199 
4200 /**
4201  * Retrieve the display name for the entity referenced by this cursor.
4202  *
4203  * The display name contains extra information that helps identify the cursor,
4204  * such as the parameters of a function or template or the arguments of a
4205  * class template specialization.
4206  */
4208 
4209 /** For a cursor that is a reference, retrieve a cursor representing the
4210  * entity that it references.
4211  *
4212  * Reference cursors refer to other entities in the AST. For example, an
4213  * Objective-C superclass reference cursor refers to an Objective-C class.
4214  * This function produces the cursor for the Objective-C class from the
4215  * cursor for the superclass reference. If the input cursor is a declaration or
4216  * definition, it returns that declaration or definition unchanged.
4217  * Otherwise, returns the NULL cursor.
4218  */
4220 
4221 /**
4222  * For a cursor that is either a reference to or a declaration
4223  * of some entity, retrieve a cursor that describes the definition of
4224  * that entity.
4225  *
4226  * Some entities can be declared multiple times within a translation
4227  * unit, but only one of those declarations can also be a
4228  * definition. For example, given:
4229  *
4230  * \code
4231  * int f(int, int);
4232  * int g(int x, int y) { return f(x, y); }
4233  * int f(int a, int b) { return a + b; }
4234  * int f(int, int);
4235  * \endcode
4236  *
4237  * there are three declarations of the function "f", but only the
4238  * second one is a definition. The clang_getCursorDefinition()
4239  * function will take any cursor pointing to a declaration of "f"
4240  * (the first or fourth lines of the example) or a cursor referenced
4241  * that uses "f" (the call to "f' inside "g") and will return a
4242  * declaration cursor pointing to the definition (the second "f"
4243  * declaration).
4244  *
4245  * If given a cursor for which there is no corresponding definition,
4246  * e.g., because there is no definition of that entity within this
4247  * translation unit, returns a NULL cursor.
4248  */
4250 
4251 /**
4252  * Determine whether the declaration pointed to by this cursor
4253  * is also a definition of that entity.
4254  */
4256 
4257 /**
4258  * Retrieve the canonical cursor corresponding to the given cursor.
4259  *
4260  * In the C family of languages, many kinds of entities can be declared several
4261  * times within a single translation unit. For example, a structure type can
4262  * be forward-declared (possibly multiple times) and later defined:
4263  *
4264  * \code
4265  * struct X;
4266  * struct X;
4267  * struct X {
4268  * int member;
4269  * };
4270  * \endcode
4271  *
4272  * The declarations and the definition of \c X are represented by three
4273  * different cursors, all of which are declarations of the same underlying
4274  * entity. One of these cursor is considered the "canonical" cursor, which
4275  * is effectively the representative for the underlying entity. One can
4276  * determine if two cursors are declarations of the same underlying entity by
4277  * comparing their canonical cursors.
4278  *
4279  * \returns The canonical cursor for the entity referred to by the given cursor.
4280  */
4282 
4283 /**
4284  * If the cursor points to a selector identifier in an Objective-C
4285  * method or message expression, this returns the selector index.
4286  *
4287  * After getting a cursor with #clang_getCursor, this can be called to
4288  * determine if the location points to a selector identifier.
4289  *
4290  * \returns The selector index if the cursor is an Objective-C method or message
4291  * expression and the cursor is pointing to a selector identifier, or -1
4292  * otherwise.
4293  */
4295 
4296 /**
4297  * Given a cursor pointing to a C++ method call or an Objective-C
4298  * message, returns non-zero if the method/message is "dynamic", meaning:
4299  *
4300  * For a C++ method: the call is virtual.
4301  * For an Objective-C message: the receiver is an object instance, not 'super'
4302  * or a specific class.
4303  *
4304  * If the method/message is "static" or the cursor does not point to a
4305  * method/message, it will return zero.
4306  */
4308 
4309 /**
4310  * Given a cursor pointing to an Objective-C message or property
4311  * reference, or C++ method call, returns the CXType of the receiver.
4312  */
4314 
4315 /**
4316  * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4317  */
4318 typedef enum {
4334 
4335 /**
4336  * Given a cursor that represents a property declaration, return the
4337  * associated property attributes. The bits are formed from
4338  * \c CXObjCPropertyAttrKind.
4339  *
4340  * \param reserved Reserved for future use, pass 0.
4341  */
4343  unsigned reserved);
4344 
4345 /**
4346  * 'Qualifiers' written next to the return and parameter types in
4347  * Objective-C method declarations.
4348  */
4349 typedef enum {
4358 
4359 /**
4360  * Given a cursor that represents an Objective-C method or parameter
4361  * declaration, return the associated Objective-C qualifiers for the return
4362  * type or the parameter respectively. The bits are formed from
4363  * CXObjCDeclQualifierKind.
4364  */
4366 
4367 /**
4368  * Given a cursor that represents an Objective-C method or property
4369  * declaration, return non-zero if the declaration was affected by "\@optional".
4370  * Returns zero if the cursor is not such a declaration or it is "\@required".
4371  */
4373 
4374 /**
4375  * Returns non-zero if the given cursor is a variadic function or method.
4376  */
4378 
4379 /**
4380  * Returns non-zero if the given cursor points to a symbol marked with
4381  * external_source_symbol attribute.
4382  *
4383  * \param language If non-NULL, and the attribute is present, will be set to
4384  * the 'language' string from the attribute.
4385  *
4386  * \param definedIn If non-NULL, and the attribute is present, will be set to
4387  * the 'definedIn' string from the attribute.
4388  *
4389  * \param isGenerated If non-NULL, and the attribute is present, will be set to
4390  * non-zero if the 'generated_declaration' is set in the attribute.
4391  */
4393  CXString *language, CXString *definedIn,
4394  unsigned *isGenerated);
4395 
4396 /**
4397  * Given a cursor that represents a declaration, return the associated
4398  * comment's source range. The range may include multiple consecutive comments
4399  * with whitespace in between.
4400  */
4402 
4403 /**
4404  * Given a cursor that represents a declaration, return the associated
4405  * comment text, including comment markers.
4406  */
4408 
4409 /**
4410  * Given a cursor that represents a documentable entity (e.g.,
4411  * declaration), return the associated \paragraph; otherwise return the
4412  * first paragraph.
4413  */
4415 
4416 /**
4417  * @}
4418  */
4419 
4420 /** \defgroup CINDEX_MANGLE Name Mangling API Functions
4421  *
4422  * @{
4423  */
4424 
4425 /**
4426  * Retrieve the CXString representing the mangled name of the cursor.
4427  */
4429 
4430 /**
4431  * Retrieve the CXStrings representing the mangled symbols of the C++
4432  * constructor or destructor at the cursor.
4433  */
4435 
4436 /**
4437  * Retrieve the CXStrings representing the mangled symbols of the ObjC
4438  * class interface or implementation at the cursor.
4439  */
4441 
4442 /**
4443  * @}
4444  */
4445 
4446 /**
4447  * \defgroup CINDEX_MODULE Module introspection
4448  *
4449  * The functions in this group provide access to information about modules.
4450  *
4451  * @{
4452  */
4453 
4454 typedef void *CXModule;
4455 
4456 /**
4457  * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4458  */
4460 
4461 /**
4462  * Given a CXFile header file, return the module that contains it, if one
4463  * exists.
4464  */
4465 CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4466 
4467 /**
4468  * \param Module a module object.
4469  *
4470  * \returns the module file where the provided module object came from.
4471  */
4472 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4473 
4474 /**
4475  * \param Module a module object.
4476  *
4477  * \returns the parent of a sub-module or NULL if the given module is top-level,
4478  * e.g. for 'std.vector' it will return the 'std' module.
4479  */
4480 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4481 
4482 /**
4483  * \param Module a module object.
4484  *
4485  * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4486  * will return "vector".
4487  */
4489 
4490 /**
4491  * \param Module a module object.
4492  *
4493  * \returns the full name of the module, e.g. "std.vector".
4494  */
4496 
4497 /**
4498  * \param Module a module object.
4499  *
4500  * \returns non-zero if the module is a system one.
4501  */
4502 CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4503 
4504 /**
4505  * \param Module a module object.
4506  *
4507  * \returns the number of top level headers associated with this module.
4508  */
4509 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4510  CXModule Module);
4511 
4512 /**
4513  * \param Module a module object.
4514  *
4515  * \param Index top level header index (zero-based).
4516  *
4517  * \returns the specified top level header associated with the module.
4518  */
4520 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4521  CXModule Module, unsigned Index);
4522 
4523 /**
4524  * @}
4525  */
4526 
4527 /**
4528  * \defgroup CINDEX_CPP C++ AST introspection
4529  *
4530  * The routines in this group provide access information in the ASTs specific
4531  * to C++ language features.
4532  *
4533  * @{
4534  */
4535 
4536 /**
4537  * Determine if a C++ constructor is a converting constructor.
4538  */
4540 
4541 /**
4542  * Determine if a C++ constructor is a copy constructor.
4543  */
4545 
4546 /**
4547  * Determine if a C++ constructor is the default constructor.
4548  */
4550 
4551 /**
4552  * Determine if a C++ constructor is a move constructor.
4553  */
4555 
4556 /**
4557  * Determine if a C++ field is declared 'mutable'.
4558  */
4560 
4561 /**
4562  * Determine if a C++ method is declared '= default'.
4563  */
4565 
4566 /**
4567  * Determine if a C++ member function or member function template is
4568  * pure virtual.
4569  */
4571 
4572 /**
4573  * Determine if a C++ member function or member function template is
4574  * declared 'static'.
4575  */
4577 
4578 /**
4579  * Determine if a C++ member function or member function template is
4580  * explicitly declared 'virtual' or if it overrides a virtual method from
4581  * one of the base classes.
4582  */
4584 
4585 /**
4586  * Determine if a C++ record is abstract, i.e. whether a class or struct
4587  * has a pure virtual member function.
4588  */
4590 
4591 /**
4592  * Determine if an enum declaration refers to a scoped enum.
4593  */
4595 
4596 /**
4597  * Determine if a C++ member function or member function template is
4598  * declared 'const'.
4599  */
4601 
4602 /**
4603  * Given a cursor that represents a template, determine
4604  * the cursor kind of the specializations would be generated by instantiating
4605  * the template.
4606  *
4607  * This routine can be used to determine what flavor of function template,
4608  * class template, or class template partial specialization is stored in the
4609  * cursor. For example, it can describe whether a class template cursor is
4610  * declared with "struct", "class" or "union".
4611  *
4612  * \param C The cursor to query. This cursor should represent a template
4613  * declaration.
4614  *
4615  * \returns The cursor kind of the specializations that would be generated
4616  * by instantiating the template \p C. If \p C is not a template, returns
4617  * \c CXCursor_NoDeclFound.
4618  */
4620 
4621 /**
4622  * Given a cursor that may represent a specialization or instantiation
4623  * of a template, retrieve the cursor that represents the template that it
4624  * specializes or from which it was instantiated.
4625  *
4626  * This routine determines the template involved both for explicit
4627  * specializations of templates and for implicit instantiations of the template,
4628  * both of which are referred to as "specializations". For a class template
4629  * specialization (e.g., \c std::vector<bool>), this routine will return
4630  * either the primary template (\c std::vector) or, if the specialization was
4631  * instantiated from a class template partial specialization, the class template
4632  * partial specialization. For a class template partial specialization and a
4633  * function template specialization (including instantiations), this
4634  * this routine will return the specialized template.
4635  *
4636  * For members of a class template (e.g., member functions, member classes, or
4637  * static data members), returns the specialized or instantiated member.
4638  * Although not strictly "templates" in the C++ language, members of class
4639  * templates have the same notions of specializations and instantiations that
4640  * templates do, so this routine treats them similarly.
4641  *
4642  * \param C A cursor that may be a specialization of a template or a member
4643  * of a template.
4644  *
4645  * \returns If the given cursor is a specialization or instantiation of a
4646  * template or a member thereof, the template or member that it specializes or
4647  * from which it was instantiated. Otherwise, returns a NULL cursor.
4648  */
4650 
4651 /**
4652  * Given a cursor that references something else, return the source range
4653  * covering that reference.
4654  *
4655  * \param C A cursor pointing to a member reference, a declaration reference, or
4656  * an operator call.
4657  * \param NameFlags A bitset with three independent flags:
4658  * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4659  * CXNameRange_WantSinglePiece.
4660  * \param PieceIndex For contiguous names or when passing the flag
4661  * CXNameRange_WantSinglePiece, only one piece with index 0 is
4662  * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4663  * non-contiguous names, this index can be used to retrieve the individual
4664  * pieces of the name. See also CXNameRange_WantSinglePiece.
4665  *
4666  * \returns The piece of the name pointed to by the given cursor. If there is no
4667  * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4668  */
4670  unsigned NameFlags,
4671  unsigned PieceIndex);
4672 
4674  /**
4675  * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4676  * range.
4677  */
4679 
4680  /**
4681  * Include the explicit template arguments, e.g. <int> in x.f<int>,
4682  * in the range.
4683  */
4685 
4686  /**
4687  * If the name is non-contiguous, return the full spanning range.
4688  *
4689  * Non-contiguous names occur in Objective-C when a selector with two or more
4690  * parameters is used, or in C++ when using an operator:
4691  * \code
4692  * [object doSomething:here withValue:there]; // Objective-C
4693  * return some_vector[1]; // C++
4694  * \endcode
4695  */
4697 };
4698 
4699 /**
4700  * @}
4701  */
4702 
4703 /**
4704  * \defgroup CINDEX_LEX Token extraction and manipulation
4705  *
4706  * The routines in this group provide access to the tokens within a
4707  * translation unit, along with a semantic mapping of those tokens to
4708  * their corresponding cursors.
4709  *
4710  * @{
4711  */
4712 
4713 /**
4714  * Describes a kind of token.
4715  */
4716 typedef enum CXTokenKind {
4717  /**
4718  * A token that contains some kind of punctuation.
4719  */
4721 
4722  /**
4723  * A language keyword.
4724  */
4726 
4727  /**
4728  * An identifier (that is not a keyword).
4729  */
4731 
4732  /**
4733  * A numeric, string, or character literal.
4734  */
4736 
4737  /**
4738  * A comment.
4739  */
4741 } CXTokenKind;
4742 
4743 /**
4744  * Describes a single preprocessing token.
4745  */
4746 typedef struct {
4747  unsigned int_data[4];
4748  void *ptr_data;
4749 } CXToken;
4750 
4751 /**
4752  * Get the raw lexical token starting with the given location.
4753  *
4754  * \param TU the translation unit whose text is being tokenized.
4755  *
4756  * \param Location the source location with which the token starts.
4757  *
4758  * \returns The token starting with the given location or NULL if no such token
4759  * exist. The returned pointer must be freed with clang_disposeTokens before the
4760  * translation unit is destroyed.
4761  */
4762 CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4763  CXSourceLocation Location);
4764 
4765 /**
4766  * Determine the kind of the given token.
4767  */
4769 
4770 /**
4771  * Determine the spelling of the given token.
4772  *
4773  * The spelling of a token is the textual representation of that token, e.g.,
4774  * the text of an identifier or keyword.
4775  */
4777 
4778 /**
4779  * Retrieve the source location of the given token.
4780  */
4782  CXToken);
4783 
4784 /**
4785  * Retrieve a source range that covers the given token.
4786  */
4788 
4789 /**
4790  * Tokenize the source code described by the given range into raw
4791  * lexical tokens.
4792  *
4793  * \param TU the translation unit whose text is being tokenized.
4794  *
4795  * \param Range the source range in which text should be tokenized. All of the
4796  * tokens produced by tokenization will fall within this source range,
4797  *
4798  * \param Tokens this pointer will be set to point to the array of tokens
4799  * that occur within the given source range. The returned pointer must be
4800  * freed with clang_disposeTokens() before the translation unit is destroyed.
4801  *
4802  * \param NumTokens will be set to the number of tokens in the \c *Tokens
4803  * array.
4804  *
4805  */
4806 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4807  CXToken **Tokens, unsigned *NumTokens);
4808 
4809 /**
4810  * Annotate the given set of tokens by providing cursors for each token
4811  * that can be mapped to a specific entity within the abstract syntax tree.
4812  *
4813  * This token-annotation routine is equivalent to invoking
4814  * clang_getCursor() for the source locations of each of the
4815  * tokens. The cursors provided are filtered, so that only those
4816  * cursors that have a direct correspondence to the token are
4817  * accepted. For example, given a function call \c f(x),
4818  * clang_getCursor() would provide the following cursors:
4819  *
4820  * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4821  * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4822  * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4823  *
4824  * Only the first and last of these cursors will occur within the
4825  * annotate, since the tokens "f" and "x' directly refer to a function
4826  * and a variable, respectively, but the parentheses are just a small
4827  * part of the full syntax of the function call expression, which is
4828  * not provided as an annotation.
4829  *
4830  * \param TU the translation unit that owns the given tokens.
4831  *
4832  * \param Tokens the set of tokens to annotate.
4833  *
4834  * \param NumTokens the number of tokens in \p Tokens.
4835  *
4836  * \param Cursors an array of \p NumTokens cursors, whose contents will be
4837  * replaced with the cursors corresponding to each token.
4838  */
4839 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4840  CXToken *Tokens, unsigned NumTokens,
4841  CXCursor *Cursors);
4842 
4843 /**
4844  * Free the given set of tokens.
4845  */
4846 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4847  CXToken *Tokens, unsigned NumTokens);
4848 
4849 /**
4850  * @}
4851  */
4852 
4853 /**
4854  * \defgroup CINDEX_DEBUG Debugging facilities
4855  *
4856  * These routines are used for testing and debugging, only, and should not
4857  * be relied upon.
4858  *
4859  * @{
4860  */
4861 
4862 /* for debug/testing */
4865  const char **startBuf,
4866  const char **endBuf,
4867  unsigned *startLine,
4868  unsigned *startColumn,
4869  unsigned *endLine,
4870  unsigned *endColumn);
4872 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4873  unsigned stack_size);
4874 
4875 /**
4876  * @}
4877  */
4878 
4879 /**
4880  * \defgroup CINDEX_CODE_COMPLET Code completion
4881  *
4882  * Code completion involves taking an (incomplete) source file, along with
4883  * knowledge of where the user is actively editing that file, and suggesting
4884  * syntactically- and semantically-valid constructs that the user might want to
4885  * use at that particular point in the source code. These data structures and
4886  * routines provide support for code completion.
4887  *
4888  * @{
4889  */
4890 
4891 /**
4892  * A semantic string that describes a code-completion result.
4893  *
4894  * A semantic string that describes the formatting of a code-completion
4895  * result as a single "template" of text that should be inserted into the
4896  * source buffer when a particular code-completion result is selected.
4897  * Each semantic string is made up of some number of "chunks", each of which
4898  * contains some text along with a description of what that text means, e.g.,
4899  * the name of the entity being referenced, whether the text chunk is part of
4900  * the template, or whether it is a "placeholder" that the user should replace
4901  * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4902  * description of the different kinds of chunks.
4903  */
4904 typedef void *CXCompletionString;
4905 
4906 /**
4907  * A single result of code completion.
4908  */
4909 typedef struct {
4910  /**
4911  * The kind of entity that this completion refers to.
4912  *
4913  * The cursor kind will be a macro, keyword, or a declaration (one of the
4914  * *Decl cursor kinds), describing the entity that the completion is
4915  * referring to.
4916  *
4917  * \todo In the future, we would like to provide a full cursor, to allow
4918  * the client to extract additional information from declaration.
4919  */
4920  enum CXCursorKind CursorKind;
4921 
4922  /**
4923  * The code-completion string that describes how to insert this
4924  * code-completion result into the editing buffer.
4925  */
4926  CXCompletionString CompletionString;
4928 
4929 /**
4930  * Describes a single piece of text within a code-completion string.
4931  *
4932  * Each "chunk" within a code-completion string (\c CXCompletionString) is
4933  * either a piece of text with a specific "kind" that describes how that text
4934  * should be interpreted by the client or is another completion string.
4935  */
4937  /**
4938  * A code-completion string that describes "optional" text that
4939  * could be a part of the template (but is not required).
4940  *
4941  * The Optional chunk is the only kind of chunk that has a code-completion
4942  * string for its representation, which is accessible via
4943  * \c clang_getCompletionChunkCompletionString(). The code-completion string
4944  * describes an additional part of the template that is completely optional.
4945  * For example, optional chunks can be used to describe the placeholders for
4946  * arguments that match up with defaulted function parameters, e.g. given:
4947  *
4948  * \code
4949  * void f(int x, float y = 3.14, double z = 2.71828);
4950  * \endcode
4951  *
4952  * The code-completion string for this function would contain:
4953  * - a TypedText chunk for "f".
4954  * - a LeftParen chunk for "(".
4955  * - a Placeholder chunk for "int x"
4956  * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4957  * - a Comma chunk for ","
4958  * - a Placeholder chunk for "float y"
4959  * - an Optional chunk containing the last defaulted argument:
4960  * - a Comma chunk for ","
4961  * - a Placeholder chunk for "double z"
4962  * - a RightParen chunk for ")"
4963  *
4964  * There are many ways to handle Optional chunks. Two simple approaches are:
4965  * - Completely ignore optional chunks, in which case the template for the
4966  * function "f" would only include the first parameter ("int x").
4967  * - Fully expand all optional chunks, in which case the template for the
4968  * function "f" would have all of the parameters.
4969  */
4971  /**
4972  * Text that a user would be expected to type to get this
4973  * code-completion result.
4974  *
4975  * There will be exactly one "typed text" chunk in a semantic string, which
4976  * will typically provide the spelling of a keyword or the name of a
4977  * declaration that could be used at the current code point. Clients are
4978  * expected to filter the code-completion results based on the text in this
4979  * chunk.
4980  */
4982  /**
4983  * Text that should be inserted as part of a code-completion result.
4984  *
4985  * A "text" chunk represents text that is part of the template to be
4986  * inserted into user code should this particular code-completion result
4987  * be selected.
4988  */
4990  /**
4991  * Placeholder text that should be replaced by the user.
4992  *
4993  * A "placeholder" chunk marks a place where the user should insert text
4994  * into the code-completion template. For example, placeholders might mark
4995  * the function parameters for a function declaration, to indicate that the
4996  * user should provide arguments for each of those parameters. The actual
4997  * text in a placeholder is a suggestion for the text to display before
4998  * the user replaces the placeholder with real code.
4999  */
5001  /**
5002  * Informative text that should be displayed but never inserted as
5003  * part of the template.
5004  *
5005  * An "informative" chunk contains annotations that can be displayed to
5006  * help the user decide whether a particular code-completion result is the
5007  * right option, but which is not part of the actual template to be inserted
5008  * by code completion.
5009  */
5011  /**
5012  * Text that describes the current parameter when code-completion is
5013  * referring to function call, message send, or template specialization.
5014  *
5015  * A "current parameter" chunk occurs when code-completion is providing
5016  * information about a parameter corresponding to the argument at the
5017  * code-completion point. For example, given a function
5018  *
5019  * \code
5020  * int add(int x, int y);
5021  * \endcode
5022  *
5023  * and the source code \c add(, where the code-completion point is after the
5024  * "(", the code-completion string will contain a "current parameter" chunk
5025  * for "int x", indicating that the current argument will initialize that
5026  * parameter. After typing further, to \c add(17, (where the code-completion
5027  * point is after the ","), the code-completion string will contain a
5028  * "current parameter" chunk to "int y".
5029  */
5031  /**
5032  * A left parenthesis ('('), used to initiate a function call or
5033  * signal the beginning of a function parameter list.
5034  */
5036  /**
5037  * A right parenthesis (')'), used to finish a function call or
5038  * signal the end of a function parameter list.
5039  */
5041  /**
5042  * A left bracket ('[').
5043  */
5045  /**
5046  * A right bracket (']').
5047  */
5049  /**
5050  * A left brace ('{').
5051  */
5053  /**
5054  * A right brace ('}').
5055  */
5057  /**
5058  * A left angle bracket ('<').
5059  */
5061  /**
5062  * A right angle bracket ('>').
5063  */
5065  /**
5066  * A comma separator (',').
5067  */
5069  /**
5070  * Text that specifies the result type of a given result.
5071  *
5072  * This special kind of informative chunk is not meant to be inserted into
5073  * the text buffer. Rather, it is meant to illustrate the type that an
5074  * expression using the given completion string would have.
5075  */
5077  /**
5078  * A colon (':').
5079  */
5081  /**
5082  * A semicolon (';').
5083  */
5085  /**
5086  * An '=' sign.
5087  */
5089  /**
5090  * Horizontal space (' ').
5091  */
5093  /**
5094  * Vertical space ('\\n'), after which it is generally a good idea to
5095  * perform indentation.
5096  */
5098 };
5099 
5100 /**
5101  * Determine the kind of a particular chunk within a completion string.
5102  *
5103  * \param completion_string the completion string to query.
5104  *
5105  * \param chunk_number the 0-based index of the chunk in the completion string.
5106  *
5107  * \returns the kind of the chunk at the index \c chunk_number.
5108  */
5110 clang_getCompletionChunkKind(CXCompletionString completion_string,
5111  unsigned chunk_number);
5112 
5113 /**
5114  * Retrieve the text associated with a particular chunk within a
5115  * completion string.
5116  *
5117  * \param completion_string the completion string to query.
5118  *
5119  * \param chunk_number the 0-based index of the chunk in the completion string.
5120  *
5121  * \returns the text associated with the chunk at index \c chunk_number.
5122  */
5124 clang_getCompletionChunkText(CXCompletionString completion_string,
5125  unsigned chunk_number);
5126 
5127 /**
5128  * Retrieve the completion string associated with a particular chunk
5129  * within a completion string.
5130  *
5131  * \param completion_string the completion string to query.
5132  *
5133  * \param chunk_number the 0-based index of the chunk in the completion string.
5134  *
5135  * \returns the completion string associated with the chunk at index
5136  * \c chunk_number.
5137  */
5138 CINDEX_LINKAGE CXCompletionString
5139 clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
5140  unsigned chunk_number);
5141 
5142 /**
5143  * Retrieve the number of chunks in the given code-completion string.
5144  */
5145 CINDEX_LINKAGE unsigned
5146 clang_getNumCompletionChunks(CXCompletionString completion_string);
5147 
5148 /**
5149  * Determine the priority of this code completion.
5150  *
5151  * The priority of a code completion indicates how likely it is that this
5152  * particular completion is the completion that the user will select. The
5153  * priority is selected by various internal heuristics.
5154  *
5155  * \param completion_string The completion string to query.
5156  *
5157  * \returns The priority of this completion string. Smaller values indicate
5158  * higher-priority (more likely) completions.
5159  */
5160 CINDEX_LINKAGE unsigned
5161 clang_getCompletionPriority(CXCompletionString completion_string);
5162 
5163 /**
5164  * Determine the availability of the entity that this code-completion
5165  * string refers to.
5166  *
5167  * \param completion_string The completion string to query.
5168  *
5169  * \returns The availability of the completion string.
5170  */
5172 clang_getCompletionAvailability(CXCompletionString completion_string);
5173 
5174 /**
5175  * Retrieve the number of annotations associated with the given
5176  * completion string.
5177  *
5178  * \param completion_string the completion string to query.
5179  *
5180  * \returns the number of annotations associated with the given completion
5181  * string.
5182  */
5183 CINDEX_LINKAGE unsigned
5184 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5185 
5186 /**
5187  * Retrieve the annotation associated with the given completion string.
5188  *
5189  * \param completion_string the completion string to query.
5190  *
5191  * \param annotation_number the 0-based index of the annotation of the
5192  * completion string.
5193  *
5194  * \returns annotation string associated with the completion at index
5195  * \c annotation_number, or a NULL string if that annotation is not available.
5196  */
5198 clang_getCompletionAnnotation(CXCompletionString completion_string,
5199  unsigned annotation_number);
5200 
5201 /**
5202  * Retrieve the parent context of the given completion string.
5203  *
5204  * The parent context of a completion string is the semantic parent of
5205  * the declaration (if any) that the code completion represents. For example,
5206  * a code completion for an Objective-C method would have the method's class
5207  * or protocol as its context.
5208  *
5209  * \param completion_string The code completion string whose parent is
5210  * being queried.
5211  *
5212  * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5213  *
5214  * \returns The name of the completion parent, e.g., "NSObject" if
5215  * the completion string represents a method in the NSObject class.
5216  */
5218 clang_getCompletionParent(CXCompletionString completion_string,
5219  enum CXCursorKind *kind);
5220 
5221 /**
5222  * Retrieve the brief documentation comment attached to the declaration
5223  * that corresponds to the given completion string.
5224  */
5226 clang_getCompletionBriefComment(CXCompletionString completion_string);
5227 
5228 /**
5229  * Retrieve a completion string for an arbitrary declaration or macro
5230  * definition cursor.
5231  *
5232  * \param cursor The cursor to query.
5233  *
5234  * \returns A non-context-sensitive completion string for declaration and macro
5235  * definition cursors, or NULL for other kinds of cursors.
5236  */
5237 CINDEX_LINKAGE CXCompletionString
5239 
5240 /**
5241  * Contains the results of code-completion.
5242  *
5243  * This data structure contains the results of code completion, as
5244  * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5245  * \c clang_disposeCodeCompleteResults.
5246  */
5247 typedef struct {
5248  /**
5249  * The code-completion results.
5250  */
5252 
5253  /**
5254  * The number of code-completion results stored in the
5255  * \c Results array.
5256  */
5257  unsigned NumResults;
5259 
5260 /**
5261  * Retrieve the number of fix-its for the given completion index.
5262  *
5263  * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5264  * option was set.
5265  *
5266  * \param results The structure keeping all completion results
5267  *
5268  * \param completion_index The index of the completion
5269  *
5270  * \return The number of fix-its which must be applied before the completion at
5271  * completion_index can be applied
5272  */
5273 CINDEX_LINKAGE unsigned
5275  unsigned completion_index);
5276 
5277 /**
5278  * Fix-its that *must* be applied before inserting the text for the
5279  * corresponding completion.
5280  *
5281  * By default, clang_codeCompleteAt() only returns completions with empty
5282  * fix-its. Extra completions with non-empty fix-its should be explicitly
5283  * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5284  *
5285  * For the clients to be able to compute position of the cursor after applying
5286  * fix-its, the following conditions are guaranteed to hold for
5287  * replacement_range of the stored fix-its:
5288  * - Ranges in the fix-its are guaranteed to never contain the completion
5289  * point (or identifier under completion point, if any) inside them, except
5290  * at the start or at the end of the range.
5291  * - If a fix-it range starts or ends with completion point (or starts or
5292  * ends after the identifier under completion point), it will contain at
5293  * least one character. It allows to unambiguously recompute completion
5294  * point after applying the fix-it.
5295  *
5296  * The intuition is that provided fix-its change code around the identifier we
5297  * complete, but are not allowed to touch the identifier itself or the
5298  * completion point. One example of completions with corrections are the ones
5299  * replacing '.' with '->' and vice versa:
5300  *
5301  * std::unique_ptr<std::vector<int>> vec_ptr;
5302  * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5303  * replacing '.' with '->'.
5304  * In 'vec_ptr->^', one of the completions is 'release', it requires
5305  * replacing '->' with '.'.
5306  *
5307  * \param results The structure keeping all completion results
5308  *
5309  * \param completion_index The index of the completion
5310  *
5311  * \param fixit_index The index of the fix-it for the completion at
5312  * completion_index
5313  *
5314  * \param replacement_range The fix-it range that must be replaced before the
5315  * completion at completion_index can be applied
5316  *
5317  * \returns The fix-it string that must replace the code at replacement_range
5318  * before the completion at completion_index can be applied
5319  */
5321  CXCodeCompleteResults *results, unsigned completion_index,
5322  unsigned fixit_index, CXSourceRange *replacement_range);
5323 
5324 /**
5325  * Flags that can be passed to \c clang_codeCompleteAt() to
5326  * modify its behavior.
5327  *
5328  * The enumerators in this enumeration can be bitwise-OR'd together to
5329  * provide multiple options to \c clang_codeCompleteAt().
5330  */
5332  /**
5333  * Whether to include macros within the set of code
5334  * completions returned.
5335  */
5337 
5338  /**
5339  * Whether to include code patterns for language constructs
5340  * within the set of code completions, e.g., for loops.
5341  */
5343 
5344  /**
5345  * Whether to include brief documentation within the set of code
5346  * completions returned.
5347  */
5349 
5350  /**
5351  * Whether to speed up completion by omitting top- or namespace-level entities
5352  * defined in the preamble. There's no guarantee any particular entity is
5353  * omitted. This may be useful if the headers are indexed externally.
5354  */
5356 
5357  /**
5358  * Whether to include completions with small
5359  * fix-its, e.g. change '.' to '->' on member access, etc.
5360  */
5362 };
5363 
5364 /**
5365  * Bits that represent the context under which completion is occurring.
5366  *
5367  * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5368  * contexts are occurring simultaneously.
5369  */
5371  /**
5372  * The context for completions is unexposed, as only Clang results
5373  * should be included. (This is equivalent to having no context bits set.)
5374  */
5376 
5377  /**
5378  * Completions for any possible type should be included in the results.
5379  */
5381 
5382  /**
5383  * Completions for any possible value (variables, function calls, etc.)
5384  * should be included in the results.
5385  */
5387  /**
5388  * Completions for values that resolve to an Objective-C object should
5389  * be included in the results.
5390  */
5392  /**
5393  * Completions for values that resolve to an Objective-C selector
5394  * should be included in the results.
5395  */
5397  /**
5398  * Completions for values that resolve to a C++ class type should be
5399  * included in the results.
5400  */
5402 
5403  /**
5404  * Completions for fields of the member being accessed using the dot
5405  * operator should be included in the results.
5406  */
5408  /**
5409  * Completions for fields of the member being accessed using the arrow
5410  * operator should be included in the results.
5411  */
5413  /**
5414  * Completions for properties of the Objective-C object being accessed
5415  * using the dot operator should be included in the results.
5416  */
5418 
5419  /**
5420  * Completions for enum tags should be included in the results.
5421  */
5423  /**
5424  * Completions for union tags should be included in the results.
5425  */
5427  /**
5428  * Completions for struct tags should be included in the results.
5429  */
5431 
5432  /**
5433  * Completions for C++ class names should be included in the results.
5434  */
5436  /**
5437  * Completions for C++ namespaces and namespace aliases should be
5438  * included in the results.
5439  */
5441  /**
5442  * Completions for C++ nested name specifiers should be included in
5443  * the results.
5444  */
5446 
5447  /**
5448  * Completions for Objective-C interfaces (classes) should be included
5449  * in the results.
5450  */
5452  /**
5453  * Completions for Objective-C protocols should be included in
5454  * the results.
5455  */
5457  /**
5458  * Completions for Objective-C categories should be included in
5459  * the results.
5460  */
5462  /**
5463  * Completions for Objective-C instance messages should be included
5464  * in the results.
5465  */
5467  /**
5468  * Completions for Objective-C class messages should be included in
5469  * the results.
5470  */
5472  /**
5473  * Completions for Objective-C selector names should be included in
5474  * the results.
5475  */
5477 
5478  /**
5479  * Completions for preprocessor macro names should be included in
5480  * the results.
5481  */
5483 
5484  /**
5485  * Natural language completions should be included in the results.
5486  */
5488 
5489  /**
5490  * The current context is unknown, so set all contexts.
5491  */
5493 };
5494 
5495 /**
5496  * Returns a default set of code-completion options that can be
5497  * passed to\c clang_codeCompleteAt().
5498  */
5500 
5501 /**
5502  * Perform code completion at a given location in a translation unit.
5503  *
5504  * This function performs code completion at a particular file, line, and
5505  * column within source code, providing results that suggest potential
5506  * code snippets based on the context of the completion. The basic model
5507  * for code completion is that Clang will parse a complete source file,
5508  * performing syntax checking up to the location where code-completion has
5509  * been requested. At that point, a special code-completion token is passed
5510  * to the parser, which recognizes this token and determines, based on the
5511  * current location in the C/Objective-C/C++ grammar and the state of
5512  * semantic analysis, what completions to provide. These completions are
5513  * returned via a new \c CXCodeCompleteResults structure.
5514  *
5515  * Code completion itself is meant to be triggered by the client when the
5516  * user types punctuation characters or whitespace, at which point the
5517  * code-completion location will coincide with the cursor. For example, if \c p
5518  * is a pointer, code-completion might be triggered after the "-" and then
5519  * after the ">" in \c p->. When the code-completion location is after the ">",
5520  * the completion results will provide, e.g., the members of the struct that
5521  * "p" points to. The client is responsible for placing the cursor at the
5522  * beginning of the token currently being typed, then filtering the results
5523  * based on the contents of the token. For example, when code-completing for
5524  * the expression \c p->get, the client should provide the location just after
5525  * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5526  * client can filter the results based on the current token text ("get"), only
5527  * showing those results that start with "get". The intent of this interface
5528  * is to separate the relatively high-latency acquisition of code-completion
5529  * results from the filtering of results on a per-character basis, which must
5530  * have a lower latency.
5531  *
5532  * \param TU The translation unit in which code-completion should
5533  * occur. The source files for this translation unit need not be
5534  * completely up-to-date (and the contents of those source files may
5535  * be overridden via \p unsaved_files). Cursors referring into the
5536  * translation unit may be invalidated by this invocation.
5537  *
5538  * \param complete_filename The name of the source file where code
5539  * completion should be performed. This filename may be any file
5540  * included in the translation unit.
5541  *
5542  * \param complete_line The line at which code-completion should occur.
5543  *
5544  * \param complete_column The column at which code-completion should occur.
5545  * Note that the column should point just after the syntactic construct that
5546  * initiated code completion, and not in the middle of a lexical token.
5547  *
5548  * \param unsaved_files the Files that have not yet been saved to disk
5549  * but may be required for parsing or code completion, including the
5550  * contents of those files. The contents and name of these files (as
5551  * specified by CXUnsavedFile) are copied when necessary, so the
5552  * client only needs to guarantee their validity until the call to
5553  * this function returns.
5554  *
5555  * \param num_unsaved_files The number of unsaved file entries in \p
5556  * unsaved_files.
5557  *
5558  * \param options Extra options that control the behavior of code
5559  * completion, expressed as a bitwise OR of the enumerators of the
5560  * CXCodeComplete_Flags enumeration. The
5561  * \c clang_defaultCodeCompleteOptions() function returns a default set
5562  * of code-completion options.
5563  *
5564  * \returns If successful, a new \c CXCodeCompleteResults structure
5565  * containing code-completion results, which should eventually be
5566  * freed with \c clang_disposeCodeCompleteResults(). If code
5567  * completion fails, returns NULL.
5568  */
5570 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5571  const char *complete_filename,
5572  unsigned complete_line,
5573  unsigned complete_column,
5574  struct CXUnsavedFile *unsaved_files,
5575  unsigned num_unsaved_files,
5576  unsigned options);
5577 
5578 /**
5579  * Sort the code-completion results in case-insensitive alphabetical
5580  * order.
5581  *
5582  * \param Results The set of results to sort.
5583  * \param NumResults The number of results in \p Results.
5584  */
5587  unsigned NumResults);
5588 
5589 /**
5590  * Free the given set of code-completion results.
5591  */
5594 
5595 /**
5596  * Determine the number of diagnostics produced prior to the
5597  * location where code completion was performed.
5598  */
5601 
5602 /**
5603  * Retrieve a diagnostic associated with the given code completion.
5604  *
5605  * \param Results the code completion results to query.
5606  * \param Index the zero-based diagnostic number to retrieve.
5607  *
5608  * \returns the requested diagnostic. This diagnostic must be freed
5609  * via a call to \c clang_disposeDiagnostic().
5610  */
5613  unsigned Index);
5614 
5615 /**
5616  * Determines what completions are appropriate for the context
5617  * the given code completion.
5618  *
5619  * \param Results the code completion results to query
5620  *
5621  * \returns the kinds of completions that are appropriate for use
5622  * along with the given code completion results.
5623  */
5625 unsigned long long clang_codeCompleteGetContexts(
5626  CXCodeCompleteResults *Results);
5627 
5628 /**
5629  * Returns the cursor kind for the container for the current code
5630  * completion context. The container is only guaranteed to be set for
5631  * contexts where a container exists (i.e. member accesses or Objective-C
5632  * message sends); if there is not a container, this function will return
5633  * CXCursor_InvalidCode.
5634  *
5635  * \param Results the code completion results to query
5636  *
5637  * \param IsIncomplete on return, this value will be false if Clang has complete
5638  * information about the container. If Clang does not have complete
5639  * information, this value will be true.
5640  *
5641  * \returns the container kind, or CXCursor_InvalidCode if there is not a
5642  * container
5643  */
5646  CXCodeCompleteResults *Results,
5647  unsigned *IsIncomplete);
5648 
5649 /**
5650  * Returns the USR for the container for the current code completion
5651  * context. If there is not a container for the current context, this
5652  * function will return the empty string.
5653  *
5654  * \param Results the code completion results to query
5655  *
5656  * \returns the USR for the container
5657  */
5660 
5661 /**
5662  * Returns the currently-entered selector for an Objective-C message
5663  * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5664  * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5665  * CXCompletionContext_ObjCClassMessage.
5666  *
5667  * \param Results the code completion results to query
5668  *
5669  * \returns the selector (or partial selector) that has been entered thus far
5670  * for an Objective-C message send.
5671  */
5674 
5675 /**
5676  * @}
5677  */
5678 
5679 /**
5680  * \defgroup CINDEX_MISC Miscellaneous utility functions
5681  *
5682  * @{
5683  */
5684 
5685 /**
5686  * Return a version string, suitable for showing to a user, but not
5687  * intended to be parsed (the format is not guaranteed to be stable).
5688  */
5690 
5691 /**
5692  * Enable/disable crash recovery.
5693  *
5694  * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5695  * value enables crash recovery, while 0 disables it.
5696  */
5698 
5699  /**
5700  * Visitor invoked for each file in a translation unit
5701  * (used with clang_getInclusions()).
5702  *
5703  * This visitor function will be invoked by clang_getInclusions() for each
5704  * file included (either at the top-level or by \#include directives) within
5705  * a translation unit. The first argument is the file being included, and
5706  * the second and third arguments provide the inclusion stack. The
5707  * array is sorted in order of immediate inclusion. For example,
5708  * the first element refers to the location that included 'included_file'.
5709  */
5710 typedef void (*CXInclusionVisitor)(CXFile included_file,
5711  CXSourceLocation* inclusion_stack,
5712  unsigned include_len,
5713&