Index.h revision a9b06d4c246d6c301e3dd1844f5dba669ed9c631
1/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2|*                                                                            *|
3|*                     The LLVM Compiler Infrastructure                       *|
4|*                                                                            *|
5|* This file is distributed under the University of Illinois Open Source      *|
6|* License. See LICENSE.TXT for details.                                      *|
7|*                                                                            *|
8|*===----------------------------------------------------------------------===*|
9|*                                                                            *|
10|* This header provides a public inferface to a Clang library for extracting  *|
11|* high-level symbol information from source files without exposing the full  *|
12|* Clang C++ API.                                                             *|
13|*                                                                            *|
14\*===----------------------------------------------------------------------===*/
15
16#ifndef CLANG_C_INDEX_H
17#define CLANG_C_INDEX_H
18
19#include <sys/stat.h>
20#include <time.h>
21#include <stdio.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* MSVC DLL import/export. */
28#ifdef _MSC_VER
29  #ifdef _CINDEX_LIB_
30    #define CINDEX_LINKAGE __declspec(dllexport)
31  #else
32    #define CINDEX_LINKAGE __declspec(dllimport)
33  #endif
34#else
35  #define CINDEX_LINKAGE
36#endif
37
38/** \defgroup CINDEX C Interface to Clang
39 *
40 * The C Interface to Clang provides a relatively small API that exposes
41 * facilities for parsing source code into an abstract syntax tree (AST),
42 * loading already-parsed ASTs, traversing the AST, associating
43 * physical source locations with elements within the AST, and other
44 * facilities that support Clang-based development tools.
45 *
46 * This C interface to Clang will never provide all of the information
47 * representation stored in Clang's C++ AST, nor should it: the intent is to
48 * maintain an API that is relatively stable from one release to the next,
49 * providing only the basic functionality needed to support development tools.
50 *
51 * To avoid namespace pollution, data types are prefixed with "CX" and
52 * functions are prefixed with "clang_".
53 *
54 * @{
55 */
56
57/**
58 * \brief An "index" that consists of a set of translation units that would
59 * typically be linked together into an executable or library.
60 */
61typedef void *CXIndex;
62
63/**
64 * \brief A single translation unit, which resides in an index.
65 */
66typedef void *CXTranslationUnit;  /* A translation unit instance. */
67
68/**
69 * \brief Opaque pointer representing client data that will be passed through
70 * to various callbacks and visitors.
71 */
72typedef void *CXClientData;
73
74/**
75 * \brief Provides the contents of a file that has not yet been saved to disk.
76 *
77 * Each CXUnsavedFile instance provides the name of a file on the
78 * system along with the current contents of that file that have not
79 * yet been saved to disk.
80 */
81struct CXUnsavedFile {
82  /**
83   * \brief The file whose contents have not yet been saved.
84   *
85   * This file must already exist in the file system.
86   */
87  const char *Filename;
88
89  /**
90   * \brief A buffer containing the unsaved contents of this file.
91   */
92  const char *Contents;
93
94  /**
95   * \brief The length of the unsaved contents of this buffer.
96   */
97  unsigned long Length;
98};
99
100/**
101 * \brief Describes the availability of a particular entity, which indicates
102 * whether the use of this entity will result in a warning or error due to
103 * it being deprecated or unavailable.
104 */
105enum CXAvailabilityKind {
106  /**
107   * \brief The entity is available.
108   */
109  CXAvailability_Available,
110  /**
111   * \brief The entity is available, but has been deprecated (and its use is
112   * not recommended).
113   */
114  CXAvailability_Deprecated,
115  /**
116   * \brief The entity is not available; any use of it will be an error.
117   */
118  CXAvailability_NotAvailable
119};
120
121/**
122 * \defgroup CINDEX_STRING String manipulation routines
123 *
124 * @{
125 */
126
127/**
128 * \brief A character string.
129 *
130 * The \c CXString type is used to return strings from the interface when
131 * the ownership of that string might different from one call to the next.
132 * Use \c clang_getCString() to retrieve the string data and, once finished
133 * with the string data, call \c clang_disposeString() to free the string.
134 */
135typedef struct {
136  const char *Spelling;
137  /* A 1 value indicates the clang_ indexing API needed to allocate the string
138     (and it must be freed by clang_disposeString()). */
139  int MustFreeString;
140} CXString;
141
142/**
143 * \brief Retrieve the character data associated with the given string.
144 */
145CINDEX_LINKAGE const char *clang_getCString(CXString string);
146
147/**
148 * \brief Free the given string,
149 */
150CINDEX_LINKAGE void clang_disposeString(CXString string);
151
152/**
153 * @}
154 */
155
156/**
157 * \brief clang_createIndex() provides a shared context for creating
158 * translation units. It provides two options:
159 *
160 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
161 * declarations (when loading any new translation units). A "local" declaration
162 * is one that belongs in the translation unit itself and not in a precompiled
163 * header that was used by the translation unit. If zero, all declarations
164 * will be enumerated.
165 *
166 * Here is an example:
167 *
168 *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
169 *   Idx = clang_createIndex(1, 1);
170 *
171 *   // IndexTest.pch was produced with the following command:
172 *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
173 *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
174 *
175 *   // This will load all the symbols from 'IndexTest.pch'
176 *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
177 *                       TranslationUnitVisitor, 0);
178 *   clang_disposeTranslationUnit(TU);
179 *
180 *   // This will load all the symbols from 'IndexTest.c', excluding symbols
181 *   // from 'IndexTest.pch'.
182 *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
183 *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
184 *                                                  0, 0);
185 *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
186 *                       TranslationUnitVisitor, 0);
187 *   clang_disposeTranslationUnit(TU);
188 *
189 * This process of creating the 'pch', loading it separately, and using it (via
190 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
191 * (which gives the indexer the same performance benefit as the compiler).
192 */
193CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
194                                         int displayDiagnostics);
195
196/**
197 * \brief Destroy the given index.
198 *
199 * The index must not be destroyed until all of the translation units created
200 * within that index have been destroyed.
201 */
202CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
203
204/**
205 * \defgroup CINDEX_FILES File manipulation routines
206 *
207 * @{
208 */
209
210/**
211 * \brief A particular source file that is part of a translation unit.
212 */
213typedef void *CXFile;
214
215
216/**
217 * \brief Retrieve the complete file and path name of the given file.
218 */
219CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
220
221/**
222 * \brief Retrieve the last modification time of the given file.
223 */
224CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
225
226/**
227 * \brief Retrieve a file handle within the given translation unit.
228 *
229 * \param tu the translation unit
230 *
231 * \param file_name the name of the file.
232 *
233 * \returns the file handle for the named file in the translation unit \p tu,
234 * or a NULL file handle if the file was not a part of this translation unit.
235 */
236CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
237                                    const char *file_name);
238
239/**
240 * @}
241 */
242
243/**
244 * \defgroup CINDEX_LOCATIONS Physical source locations
245 *
246 * Clang represents physical source locations in its abstract syntax tree in
247 * great detail, with file, line, and column information for the majority of
248 * the tokens parsed in the source code. These data types and functions are
249 * used to represent source location information, either for a particular
250 * point in the program or for a range of points in the program, and extract
251 * specific location information from those data types.
252 *
253 * @{
254 */
255
256/**
257 * \brief Identifies a specific source location within a translation
258 * unit.
259 *
260 * Use clang_getInstantiationLocation() or clang_getSpellingLocation()
261 * to map a source location to a particular file, line, and column.
262 */
263typedef struct {
264  void *ptr_data[2];
265  unsigned int_data;
266} CXSourceLocation;
267
268/**
269 * \brief Identifies a half-open character range in the source code.
270 *
271 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
272 * starting and end locations from a source range, respectively.
273 */
274typedef struct {
275  void *ptr_data[2];
276  unsigned begin_int_data;
277  unsigned end_int_data;
278} CXSourceRange;
279
280/**
281 * \brief Retrieve a NULL (invalid) source location.
282 */
283CINDEX_LINKAGE CXSourceLocation clang_getNullLocation();
284
285/**
286 * \determine Determine whether two source locations, which must refer into
287 * the same translation unit, refer to exactly the same point in the source
288 * code.
289 *
290 * \returns non-zero if the source locations refer to the same location, zero
291 * if they refer to different locations.
292 */
293CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
294                                             CXSourceLocation loc2);
295
296/**
297 * \brief Retrieves the source location associated with a given file/line/column
298 * in a particular translation unit.
299 */
300CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
301                                                  CXFile file,
302                                                  unsigned line,
303                                                  unsigned column);
304/**
305 * \brief Retrieves the source location associated with a given character offset
306 * in a particular translation unit.
307 */
308CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
309                                                           CXFile file,
310                                                           unsigned offset);
311
312/**
313 * \brief Retrieve a NULL (invalid) source range.
314 */
315CINDEX_LINKAGE CXSourceRange clang_getNullRange();
316
317/**
318 * \brief Retrieve a source range given the beginning and ending source
319 * locations.
320 */
321CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
322                                            CXSourceLocation end);
323
324/**
325 * \brief Retrieve the file, line, column, and offset represented by
326 * the given source location.
327 *
328 * If the location refers into a macro instantiation, retrieves the
329 * location of the macro instantiation.
330 *
331 * \param location the location within a source file that will be decomposed
332 * into its parts.
333 *
334 * \param file [out] if non-NULL, will be set to the file to which the given
335 * source location points.
336 *
337 * \param line [out] if non-NULL, will be set to the line to which the given
338 * source location points.
339 *
340 * \param column [out] if non-NULL, will be set to the column to which the given
341 * source location points.
342 *
343 * \param offset [out] if non-NULL, will be set to the offset into the
344 * buffer to which the given source location points.
345 */
346CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
347                                                   CXFile *file,
348                                                   unsigned *line,
349                                                   unsigned *column,
350                                                   unsigned *offset);
351
352/**
353 * \brief Retrieve the file, line, column, and offset represented by
354 * the given source location.
355 *
356 * If the location refers into a macro instantiation, return where the
357 * location was originally spelled in the source file.
358 *
359 * \param location the location within a source file that will be decomposed
360 * into its parts.
361 *
362 * \param file [out] if non-NULL, will be set to the file to which the given
363 * source location points.
364 *
365 * \param line [out] if non-NULL, will be set to the line to which the given
366 * source location points.
367 *
368 * \param column [out] if non-NULL, will be set to the column to which the given
369 * source location points.
370 *
371 * \param offset [out] if non-NULL, will be set to the offset into the
372 * buffer to which the given source location points.
373 */
374CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
375                                              CXFile *file,
376                                              unsigned *line,
377                                              unsigned *column,
378                                              unsigned *offset);
379
380/**
381 * \brief Retrieve a source location representing the first character within a
382 * source range.
383 */
384CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
385
386/**
387 * \brief Retrieve a source location representing the last character within a
388 * source range.
389 */
390CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
391
392/**
393 * @}
394 */
395
396/**
397 * \defgroup CINDEX_DIAG Diagnostic reporting
398 *
399 * @{
400 */
401
402/**
403 * \brief Describes the severity of a particular diagnostic.
404 */
405enum CXDiagnosticSeverity {
406  /**
407   * \brief A diagnostic that has been suppressed, e.g., by a command-line
408   * option.
409   */
410  CXDiagnostic_Ignored = 0,
411
412  /**
413   * \brief This diagnostic is a note that should be attached to the
414   * previous (non-note) diagnostic.
415   */
416  CXDiagnostic_Note    = 1,
417
418  /**
419   * \brief This diagnostic indicates suspicious code that may not be
420   * wrong.
421   */
422  CXDiagnostic_Warning = 2,
423
424  /**
425   * \brief This diagnostic indicates that the code is ill-formed.
426   */
427  CXDiagnostic_Error   = 3,
428
429  /**
430   * \brief This diagnostic indicates that the code is ill-formed such
431   * that future parser recovery is unlikely to produce useful
432   * results.
433   */
434  CXDiagnostic_Fatal   = 4
435};
436
437/**
438 * \brief A single diagnostic, containing the diagnostic's severity,
439 * location, text, source ranges, and fix-it hints.
440 */
441typedef void *CXDiagnostic;
442
443/**
444 * \brief Determine the number of diagnostics produced for the given
445 * translation unit.
446 */
447CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
448
449/**
450 * \brief Retrieve a diagnostic associated with the given translation unit.
451 *
452 * \param Unit the translation unit to query.
453 * \param Index the zero-based diagnostic number to retrieve.
454 *
455 * \returns the requested diagnostic. This diagnostic must be freed
456 * via a call to \c clang_disposeDiagnostic().
457 */
458CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
459                                                unsigned Index);
460
461/**
462 * \brief Destroy a diagnostic.
463 */
464CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
465
466/**
467 * \brief Options to control the display of diagnostics.
468 *
469 * The values in this enum are meant to be combined to customize the
470 * behavior of \c clang_displayDiagnostic().
471 */
472enum CXDiagnosticDisplayOptions {
473  /**
474   * \brief Display the source-location information where the
475   * diagnostic was located.
476   *
477   * When set, diagnostics will be prefixed by the file, line, and
478   * (optionally) column to which the diagnostic refers. For example,
479   *
480   * \code
481   * test.c:28: warning: extra tokens at end of #endif directive
482   * \endcode
483   *
484   * This option corresponds to the clang flag \c -fshow-source-location.
485   */
486  CXDiagnostic_DisplaySourceLocation = 0x01,
487
488  /**
489   * \brief If displaying the source-location information of the
490   * diagnostic, also include the column number.
491   *
492   * This option corresponds to the clang flag \c -fshow-column.
493   */
494  CXDiagnostic_DisplayColumn = 0x02,
495
496  /**
497   * \brief If displaying the source-location information of the
498   * diagnostic, also include information about source ranges in a
499   * machine-parsable format.
500   *
501   * This option corresponds to the clang flag
502   * \c -fdiagnostics-print-source-range-info.
503   */
504  CXDiagnostic_DisplaySourceRanges = 0x04
505};
506
507/**
508 * \brief Format the given diagnostic in a manner that is suitable for display.
509 *
510 * This routine will format the given diagnostic to a string, rendering
511 * the diagnostic according to the various options given. The
512 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
513 * options that most closely mimics the behavior of the clang compiler.
514 *
515 * \param Diagnostic The diagnostic to print.
516 *
517 * \param Options A set of options that control the diagnostic display,
518 * created by combining \c CXDiagnosticDisplayOptions values.
519 *
520 * \returns A new string containing for formatted diagnostic.
521 */
522CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
523                                               unsigned Options);
524
525/**
526 * \brief Retrieve the set of display options most similar to the
527 * default behavior of the clang compiler.
528 *
529 * \returns A set of display options suitable for use with \c
530 * clang_displayDiagnostic().
531 */
532CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
533
534/**
535 * \brief Print a diagnostic to the given file.
536 */
537
538/**
539 * \brief Determine the severity of the given diagnostic.
540 */
541CINDEX_LINKAGE enum CXDiagnosticSeverity
542clang_getDiagnosticSeverity(CXDiagnostic);
543
544/**
545 * \brief Retrieve the source location of the given diagnostic.
546 *
547 * This location is where Clang would print the caret ('^') when
548 * displaying the diagnostic on the command line.
549 */
550CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
551
552/**
553 * \brief Retrieve the text of the given diagnostic.
554 */
555CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
556
557/**
558 * \brief Determine the number of source ranges associated with the given
559 * diagnostic.
560 */
561CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
562
563/**
564 * \brief Retrieve a source range associated with the diagnostic.
565 *
566 * A diagnostic's source ranges highlight important elements in the source
567 * code. On the command line, Clang displays source ranges by
568 * underlining them with '~' characters.
569 *
570 * \param Diagnostic the diagnostic whose range is being extracted.
571 *
572 * \param Range the zero-based index specifying which range to
573 *
574 * \returns the requested source range.
575 */
576CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
577                                                      unsigned Range);
578
579/**
580 * \brief Determine the number of fix-it hints associated with the
581 * given diagnostic.
582 */
583CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
584
585/**
586 * \brief Retrieve the replacement information for a given fix-it.
587 *
588 * Fix-its are described in terms of a source range whose contents
589 * should be replaced by a string. This approach generalizes over
590 * three kinds of operations: removal of source code (the range covers
591 * the code to be removed and the replacement string is empty),
592 * replacement of source code (the range covers the code to be
593 * replaced and the replacement string provides the new code), and
594 * insertion (both the start and end of the range point at the
595 * insertion location, and the replacement string provides the text to
596 * insert).
597 *
598 * \param Diagnostic The diagnostic whose fix-its are being queried.
599 *
600 * \param FixIt The zero-based index of the fix-it.
601 *
602 * \param ReplacementRange The source range whose contents will be
603 * replaced with the returned replacement string. Note that source
604 * ranges are half-open ranges [a, b), so the source code should be
605 * replaced from a and up to (but not including) b.
606 *
607 * \returns A string containing text that should be replace the source
608 * code indicated by the \c ReplacementRange.
609 */
610CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
611                                                 unsigned FixIt,
612                                               CXSourceRange *ReplacementRange);
613
614/**
615 * @}
616 */
617
618/**
619 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
620 *
621 * The routines in this group provide the ability to create and destroy
622 * translation units from files, either by parsing the contents of the files or
623 * by reading in a serialized representation of a translation unit.
624 *
625 * @{
626 */
627
628/**
629 * \brief Get the original translation unit source file name.
630 */
631CINDEX_LINKAGE CXString
632clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
633
634/**
635 * \brief Return the CXTranslationUnit for a given source file and the provided
636 * command line arguments one would pass to the compiler.
637 *
638 * Note: The 'source_filename' argument is optional.  If the caller provides a
639 * NULL pointer, the name of the source file is expected to reside in the
640 * specified command line arguments.
641 *
642 * Note: When encountered in 'clang_command_line_args', the following options
643 * are ignored:
644 *
645 *   '-c'
646 *   '-emit-ast'
647 *   '-fsyntax-only'
648 *   '-o <output file>'  (both '-o' and '<output file>' are ignored)
649 *
650 * \param CIdx The index object with which the translation unit will be
651 * associated.
652 *
653 * \param source_filename - The name of the source file to load, or NULL if the
654 * source file is included in \p clang_command_line_args.
655 *
656 * \param num_clang_command_line_args The number of command-line arguments in
657 * \p clang_command_line_args.
658 *
659 * \param clang_command_line_args The command-line arguments that would be
660 * passed to the \c clang executable if it were being invoked out-of-process.
661 * These command-line options will be parsed and will affect how the translation
662 * unit is parsed. Note that the following options are ignored: '-c',
663 * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
664 *
665 * \param num_unsaved_files the number of unsaved file entries in \p
666 * unsaved_files.
667 *
668 * \param unsaved_files the files that have not yet been saved to disk
669 * but may be required for code completion, including the contents of
670 * those files.  The contents and name of these files (as specified by
671 * CXUnsavedFile) are copied when necessary, so the client only needs to
672 * guarantee their validity until the call to this function returns.
673 */
674CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
675                                         CXIndex CIdx,
676                                         const char *source_filename,
677                                         int num_clang_command_line_args,
678                                   const char * const *clang_command_line_args,
679                                         unsigned num_unsaved_files,
680                                         struct CXUnsavedFile *unsaved_files);
681
682/**
683 * \brief Create a translation unit from an AST file (-emit-ast).
684 */
685CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
686                                             const char *ast_filename);
687
688/**
689 * \brief Flags that control the creation of translation units.
690 *
691 * The enumerators in this enumeration type are meant to be bitwise
692 * ORed together to specify which options should be used when
693 * constructing the translation unit.
694 */
695enum CXTranslationUnit_Flags {
696  /**
697   * \brief Used to indicate that no special translation-unit options are
698   * needed.
699   */
700  CXTranslationUnit_None = 0x0,
701
702  /**
703   * \brief Used to indicate that the parser should construct a "detailed"
704   * preprocessing record, including all macro definitions and instantiations.
705   *
706   * Constructing a detailed preprocessing record requires more memory
707   * and time to parse, since the information contained in the record
708   * is usually not retained. However, it can be useful for
709   * applications that require more detailed information about the
710   * behavior of the preprocessor.
711   */
712  CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
713
714  /**
715   * \brief Used to indicate that the translation unit is incomplete.
716   *
717   * When a translation unit is considered "incomplete", semantic
718   * analysis that is typically performed at the end of the
719   * translation unit will be suppressed. For example, this suppresses
720   * the completion of tentative declarations in C and of
721   * instantiation of implicitly-instantiation function templates in
722   * C++. This option is typically used when parsing a header with the
723   * intent of producing a precompiled header.
724   */
725  CXTranslationUnit_Incomplete = 0x02,
726
727  /**
728   * \brief Used to indicate that the translation unit should be built with an
729   * implicit precompiled header for the preamble.
730   *
731   * An implicit precompiled header is used as an optimization when a
732   * particular translation unit is likely to be reparsed many times
733   * when the sources aren't changing that often. In this case, an
734   * implicit precompiled header will be built containing all of the
735   * initial includes at the top of the main file (what we refer to as
736   * the "preamble" of the file). In subsequent parses, if the
737   * preamble or the files in it have not changed, \c
738   * clang_reparseTranslationUnit() will re-use the implicit
739   * precompiled header to improve parsing performance.
740   */
741  CXTranslationUnit_PrecompiledPreamble = 0x04,
742
743  /**
744   * \brief Used to indicate that the translation unit should cache some
745   * code-completion results with each reparse of the source file.
746   *
747   * Caching of code-completion results is a performance optimization that
748   * introduces some overhead to reparsing but improves the performance of
749   * code-completion operations.
750   */
751  CXTranslationUnit_CacheCompletionResults = 0x08,
752  /**
753   * \brief Enable precompiled preambles in C++.
754   *
755   * Note: this is a *temporary* option that is available only while
756   * we are testing C++ precompiled preamble support.
757   */
758  CXTranslationUnit_CXXPrecompiledPreamble = 0x10,
759
760  /**
761   * \brief Enabled chained precompiled preambles in C++.
762   *
763   * Note: this is a *temporary* option that is available only while
764   * we are testing C++ precompiled preamble support.
765   */
766  CXTranslationUnit_CXXChainedPCH = 0x20
767};
768
769/**
770 * \brief Returns the set of flags that is suitable for parsing a translation
771 * unit that is being edited.
772 *
773 * The set of flags returned provide options for \c clang_parseTranslationUnit()
774 * to indicate that the translation unit is likely to be reparsed many times,
775 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
776 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
777 * set contains an unspecified set of optimizations (e.g., the precompiled
778 * preamble) geared toward improving the performance of these routines. The
779 * set of optimizations enabled may change from one version to the next.
780 */
781CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
782
783/**
784 * \brief Parse the given source file and the translation unit corresponding
785 * to that file.
786 *
787 * This routine is the main entry point for the Clang C API, providing the
788 * ability to parse a source file into a translation unit that can then be
789 * queried by other functions in the API. This routine accepts a set of
790 * command-line arguments so that the compilation can be configured in the same
791 * way that the compiler is configured on the command line.
792 *
793 * \param CIdx The index object with which the translation unit will be
794 * associated.
795 *
796 * \param source_filename The name of the source file to load, or NULL if the
797 * source file is included in \p command_line_args.
798 *
799 * \param command_line_args The command-line arguments that would be
800 * passed to the \c clang executable if it were being invoked out-of-process.
801 * These command-line options will be parsed and will affect how the translation
802 * unit is parsed. Note that the following options are ignored: '-c',
803 * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
804 *
805 * \param num_command_line_args The number of command-line arguments in
806 * \p command_line_args.
807 *
808 * \param unsaved_files the files that have not yet been saved to disk
809 * but may be required for parsing, including the contents of
810 * those files.  The contents and name of these files (as specified by
811 * CXUnsavedFile) are copied when necessary, so the client only needs to
812 * guarantee their validity until the call to this function returns.
813 *
814 * \param num_unsaved_files the number of unsaved file entries in \p
815 * unsaved_files.
816 *
817 * \param options A bitmask of options that affects how the translation unit
818 * is managed but not its compilation. This should be a bitwise OR of the
819 * CXTranslationUnit_XXX flags.
820 *
821 * \returns A new translation unit describing the parsed code and containing
822 * any diagnostics produced by the compiler. If there is a failure from which
823 * the compiler cannot recover, returns NULL.
824 */
825CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
826                                                    const char *source_filename,
827                                         const char * const *command_line_args,
828                                                      int num_command_line_args,
829                                            struct CXUnsavedFile *unsaved_files,
830                                                     unsigned num_unsaved_files,
831                                                            unsigned options);
832
833/**
834 * \brief Flags that control how translation units are saved.
835 *
836 * The enumerators in this enumeration type are meant to be bitwise
837 * ORed together to specify which options should be used when
838 * saving the translation unit.
839 */
840enum CXSaveTranslationUnit_Flags {
841  /**
842   * \brief Used to indicate that no special saving options are needed.
843   */
844  CXSaveTranslationUnit_None = 0x0
845};
846
847/**
848 * \brief Returns the set of flags that is suitable for saving a translation
849 * unit.
850 *
851 * The set of flags returned provide options for
852 * \c clang_saveTranslationUnit() by default. The returned flag
853 * set contains an unspecified set of options that save translation units with
854 * the most commonly-requested data.
855 */
856CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
857
858/**
859 * \brief Saves a translation unit into a serialized representation of
860 * that translation unit on disk.
861 *
862 * Any translation unit that was parsed without error can be saved
863 * into a file. The translation unit can then be deserialized into a
864 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
865 * if it is an incomplete translation unit that corresponds to a
866 * header, used as a precompiled header when parsing other translation
867 * units.
868 *
869 * \param TU The translation unit to save.
870 *
871 * \param FileName The file to which the translation unit will be saved.
872 *
873 * \param options A bitmask of options that affects how the translation unit
874 * is saved. This should be a bitwise OR of the
875 * CXSaveTranslationUnit_XXX flags.
876 *
877 * \returns Zero if the translation unit was saved successfully, a
878 * non-zero value otherwise.
879 */
880CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
881                                             const char *FileName,
882                                             unsigned options);
883
884/**
885 * \brief Destroy the specified CXTranslationUnit object.
886 */
887CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
888
889/**
890 * \brief Flags that control the reparsing of translation units.
891 *
892 * The enumerators in this enumeration type are meant to be bitwise
893 * ORed together to specify which options should be used when
894 * reparsing the translation unit.
895 */
896enum CXReparse_Flags {
897  /**
898   * \brief Used to indicate that no special reparsing options are needed.
899   */
900  CXReparse_None = 0x0
901};
902
903/**
904 * \brief Returns the set of flags that is suitable for reparsing a translation
905 * unit.
906 *
907 * The set of flags returned provide options for
908 * \c clang_reparseTranslationUnit() by default. The returned flag
909 * set contains an unspecified set of optimizations geared toward common uses
910 * of reparsing. The set of optimizations enabled may change from one version
911 * to the next.
912 */
913CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
914
915/**
916 * \brief Reparse the source files that produced this translation unit.
917 *
918 * This routine can be used to re-parse the source files that originally
919 * created the given translation unit, for example because those source files
920 * have changed (either on disk or as passed via \p unsaved_files). The
921 * source code will be reparsed with the same command-line options as it
922 * was originally parsed.
923 *
924 * Reparsing a translation unit invalidates all cursors and source locations
925 * that refer into that translation unit. This makes reparsing a translation
926 * unit semantically equivalent to destroying the translation unit and then
927 * creating a new translation unit with the same command-line arguments.
928 * However, it may be more efficient to reparse a translation
929 * unit using this routine.
930 *
931 * \param TU The translation unit whose contents will be re-parsed. The
932 * translation unit must originally have been built with
933 * \c clang_createTranslationUnitFromSourceFile().
934 *
935 * \param num_unsaved_files The number of unsaved file entries in \p
936 * unsaved_files.
937 *
938 * \param unsaved_files The files that have not yet been saved to disk
939 * but may be required for parsing, including the contents of
940 * those files.  The contents and name of these files (as specified by
941 * CXUnsavedFile) are copied when necessary, so the client only needs to
942 * guarantee their validity until the call to this function returns.
943 *
944 * \param options A bitset of options composed of the flags in CXReparse_Flags.
945 * The function \c clang_defaultReparseOptions() produces a default set of
946 * options recommended for most uses, based on the translation unit.
947 *
948 * \returns 0 if the sources could be reparsed. A non-zero value will be
949 * returned if reparsing was impossible, such that the translation unit is
950 * invalid. In such cases, the only valid call for \p TU is
951 * \c clang_disposeTranslationUnit(TU).
952 */
953CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
954                                                unsigned num_unsaved_files,
955                                          struct CXUnsavedFile *unsaved_files,
956                                                unsigned options);
957
958/**
959 * @}
960 */
961
962/**
963 * \brief Describes the kind of entity that a cursor refers to.
964 */
965enum CXCursorKind {
966  /* Declarations */
967  /**
968   * \brief A declaration whose specific kind is not exposed via this
969   * interface.
970   *
971   * Unexposed declarations have the same operations as any other kind
972   * of declaration; one can extract their location information,
973   * spelling, find their definitions, etc. However, the specific kind
974   * of the declaration is not reported.
975   */
976  CXCursor_UnexposedDecl                 = 1,
977  /** \brief A C or C++ struct. */
978  CXCursor_StructDecl                    = 2,
979  /** \brief A C or C++ union. */
980  CXCursor_UnionDecl                     = 3,
981  /** \brief A C++ class. */
982  CXCursor_ClassDecl                     = 4,
983  /** \brief An enumeration. */
984  CXCursor_EnumDecl                      = 5,
985  /**
986   * \brief A field (in C) or non-static data member (in C++) in a
987   * struct, union, or C++ class.
988   */
989  CXCursor_FieldDecl                     = 6,
990  /** \brief An enumerator constant. */
991  CXCursor_EnumConstantDecl              = 7,
992  /** \brief A function. */
993  CXCursor_FunctionDecl                  = 8,
994  /** \brief A variable. */
995  CXCursor_VarDecl                       = 9,
996  /** \brief A function or method parameter. */
997  CXCursor_ParmDecl                      = 10,
998  /** \brief An Objective-C @interface. */
999  CXCursor_ObjCInterfaceDecl             = 11,
1000  /** \brief An Objective-C @interface for a category. */
1001  CXCursor_ObjCCategoryDecl              = 12,
1002  /** \brief An Objective-C @protocol declaration. */
1003  CXCursor_ObjCProtocolDecl              = 13,
1004  /** \brief An Objective-C @property declaration. */
1005  CXCursor_ObjCPropertyDecl              = 14,
1006  /** \brief An Objective-C instance variable. */
1007  CXCursor_ObjCIvarDecl                  = 15,
1008  /** \brief An Objective-C instance method. */
1009  CXCursor_ObjCInstanceMethodDecl        = 16,
1010  /** \brief An Objective-C class method. */
1011  CXCursor_ObjCClassMethodDecl           = 17,
1012  /** \brief An Objective-C @implementation. */
1013  CXCursor_ObjCImplementationDecl        = 18,
1014  /** \brief An Objective-C @implementation for a category. */
1015  CXCursor_ObjCCategoryImplDecl          = 19,
1016  /** \brief A typedef */
1017  CXCursor_TypedefDecl                   = 20,
1018  /** \brief A C++ class method. */
1019  CXCursor_CXXMethod                     = 21,
1020  /** \brief A C++ namespace. */
1021  CXCursor_Namespace                     = 22,
1022  /** \brief A linkage specification, e.g. 'extern "C"'. */
1023  CXCursor_LinkageSpec                   = 23,
1024  /** \brief A C++ constructor. */
1025  CXCursor_Constructor                   = 24,
1026  /** \brief A C++ destructor. */
1027  CXCursor_Destructor                    = 25,
1028  /** \brief A C++ conversion function. */
1029  CXCursor_ConversionFunction            = 26,
1030  /** \brief A C++ template type parameter. */
1031  CXCursor_TemplateTypeParameter         = 27,
1032  /** \brief A C++ non-type template parameter. */
1033  CXCursor_NonTypeTemplateParameter      = 28,
1034  /** \brief A C++ template template parameter. */
1035  CXCursor_TemplateTemplateParameter     = 29,
1036  /** \brief A C++ function template. */
1037  CXCursor_FunctionTemplate              = 30,
1038  /** \brief A C++ class template. */
1039  CXCursor_ClassTemplate                 = 31,
1040  /** \brief A C++ class template partial specialization. */
1041  CXCursor_ClassTemplatePartialSpecialization = 32,
1042  /** \brief A C++ namespace alias declaration. */
1043  CXCursor_NamespaceAlias                = 33,
1044  /** \brief A C++ using directive. */
1045  CXCursor_UsingDirective                = 34,
1046  /** \brief A using declaration. */
1047  CXCursor_UsingDeclaration              = 35,
1048  CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
1049  CXCursor_LastDecl                      = CXCursor_UsingDeclaration,
1050
1051  /* References */
1052  CXCursor_FirstRef                      = 40, /* Decl references */
1053  CXCursor_ObjCSuperClassRef             = 40,
1054  CXCursor_ObjCProtocolRef               = 41,
1055  CXCursor_ObjCClassRef                  = 42,
1056  /**
1057   * \brief A reference to a type declaration.
1058   *
1059   * A type reference occurs anywhere where a type is named but not
1060   * declared. For example, given:
1061   *
1062   * \code
1063   * typedef unsigned size_type;
1064   * size_type size;
1065   * \endcode
1066   *
1067   * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1068   * while the type of the variable "size" is referenced. The cursor
1069   * referenced by the type of size is the typedef for size_type.
1070   */
1071  CXCursor_TypeRef                       = 43,
1072  CXCursor_CXXBaseSpecifier              = 44,
1073  /**
1074   * \brief A reference to a class template, function template, template
1075   * template parameter, or class template partial specialization.
1076   */
1077  CXCursor_TemplateRef                   = 45,
1078  /**
1079   * \brief A reference to a namespace or namespace alias.
1080   */
1081  CXCursor_NamespaceRef                  = 46,
1082  /**
1083   * \brief A reference to a member of a struct, union, or class that occurs in
1084   * some non-expression context, e.g., a designated initializer.
1085   */
1086  CXCursor_MemberRef                     = 47,
1087  /**
1088   * \brief A reference to a labeled statement.
1089   *
1090   * This cursor kind is used to describe the jump to "start_over" in the
1091   * goto statement in the following example:
1092   *
1093   * \code
1094   *   start_over:
1095   *     ++counter;
1096   *
1097   *     goto start_over;
1098   * \endcode
1099   *
1100   * A label reference cursor refers to a label statement.
1101   */
1102  CXCursor_LabelRef                      = 48,
1103
1104  /**
1105   * \brief A reference to a set of overloaded functions or function templates
1106   * that has not yet been resolved to a specific function or function template.
1107   *
1108   * An overloaded declaration reference cursor occurs in C++ templates where
1109   * a dependent name refers to a function. For example:
1110   *
1111   * \code
1112   * template<typename T> void swap(T&, T&);
1113   *
1114   * struct X { ... };
1115   * void swap(X&, X&);
1116   *
1117   * template<typename T>
1118   * void reverse(T* first, T* last) {
1119   *   while (first < last - 1) {
1120   *     swap(*first, *--last);
1121   *     ++first;
1122   *   }
1123   * }
1124   *
1125   * struct Y { };
1126   * void swap(Y&, Y&);
1127   * \endcode
1128   *
1129   * Here, the identifier "swap" is associated with an overloaded declaration
1130   * reference. In the template definition, "swap" refers to either of the two
1131   * "swap" functions declared above, so both results will be available. At
1132   * instantiation time, "swap" may also refer to other functions found via
1133   * argument-dependent lookup (e.g., the "swap" function at the end of the
1134   * example).
1135   *
1136   * The functions \c clang_getNumOverloadedDecls() and
1137   * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1138   * referenced by this cursor.
1139   */
1140  CXCursor_OverloadedDeclRef             = 49,
1141
1142  CXCursor_LastRef                       = CXCursor_OverloadedDeclRef,
1143
1144  /* Error conditions */
1145  CXCursor_FirstInvalid                  = 70,
1146  CXCursor_InvalidFile                   = 70,
1147  CXCursor_NoDeclFound                   = 71,
1148  CXCursor_NotImplemented                = 72,
1149  CXCursor_InvalidCode                   = 73,
1150  CXCursor_LastInvalid                   = CXCursor_InvalidCode,
1151
1152  /* Expressions */
1153  CXCursor_FirstExpr                     = 100,
1154
1155  /**
1156   * \brief An expression whose specific kind is not exposed via this
1157   * interface.
1158   *
1159   * Unexposed expressions have the same operations as any other kind
1160   * of expression; one can extract their location information,
1161   * spelling, children, etc. However, the specific kind of the
1162   * expression is not reported.
1163   */
1164  CXCursor_UnexposedExpr                 = 100,
1165
1166  /**
1167   * \brief An expression that refers to some value declaration, such
1168   * as a function, varible, or enumerator.
1169   */
1170  CXCursor_DeclRefExpr                   = 101,
1171
1172  /**
1173   * \brief An expression that refers to a member of a struct, union,
1174   * class, Objective-C class, etc.
1175   */
1176  CXCursor_MemberRefExpr                 = 102,
1177
1178  /** \brief An expression that calls a function. */
1179  CXCursor_CallExpr                      = 103,
1180
1181  /** \brief An expression that sends a message to an Objective-C
1182   object or class. */
1183  CXCursor_ObjCMessageExpr               = 104,
1184
1185  /** \brief An expression that represents a block literal. */
1186  CXCursor_BlockExpr                     = 105,
1187
1188  CXCursor_LastExpr                      = 105,
1189
1190  /* Statements */
1191  CXCursor_FirstStmt                     = 200,
1192  /**
1193   * \brief A statement whose specific kind is not exposed via this
1194   * interface.
1195   *
1196   * Unexposed statements have the same operations as any other kind of
1197   * statement; one can extract their location information, spelling,
1198   * children, etc. However, the specific kind of the statement is not
1199   * reported.
1200   */
1201  CXCursor_UnexposedStmt                 = 200,
1202
1203  /** \brief A labelled statement in a function.
1204   *
1205   * This cursor kind is used to describe the "start_over:" label statement in
1206   * the following example:
1207   *
1208   * \code
1209   *   start_over:
1210   *     ++counter;
1211   * \endcode
1212   *
1213   */
1214  CXCursor_LabelStmt                     = 201,
1215
1216  CXCursor_LastStmt                      = CXCursor_LabelStmt,
1217
1218  /**
1219   * \brief Cursor that represents the translation unit itself.
1220   *
1221   * The translation unit cursor exists primarily to act as the root
1222   * cursor for traversing the contents of a translation unit.
1223   */
1224  CXCursor_TranslationUnit               = 300,
1225
1226  /* Attributes */
1227  CXCursor_FirstAttr                     = 400,
1228  /**
1229   * \brief An attribute whose specific kind is not exposed via this
1230   * interface.
1231   */
1232  CXCursor_UnexposedAttr                 = 400,
1233
1234  CXCursor_IBActionAttr                  = 401,
1235  CXCursor_IBOutletAttr                  = 402,
1236  CXCursor_IBOutletCollectionAttr        = 403,
1237  CXCursor_LastAttr                      = CXCursor_IBOutletCollectionAttr,
1238
1239  /* Preprocessing */
1240  CXCursor_PreprocessingDirective        = 500,
1241  CXCursor_MacroDefinition               = 501,
1242  CXCursor_MacroInstantiation            = 502,
1243  CXCursor_InclusionDirective            = 503,
1244  CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
1245  CXCursor_LastPreprocessing             = CXCursor_InclusionDirective
1246};
1247
1248/**
1249 * \brief A cursor representing some element in the abstract syntax tree for
1250 * a translation unit.
1251 *
1252 * The cursor abstraction unifies the different kinds of entities in a
1253 * program--declaration, statements, expressions, references to declarations,
1254 * etc.--under a single "cursor" abstraction with a common set of operations.
1255 * Common operation for a cursor include: getting the physical location in
1256 * a source file where the cursor points, getting the name associated with a
1257 * cursor, and retrieving cursors for any child nodes of a particular cursor.
1258 *
1259 * Cursors can be produced in two specific ways.
1260 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
1261 * from which one can use clang_visitChildren() to explore the rest of the
1262 * translation unit. clang_getCursor() maps from a physical source location
1263 * to the entity that resides at that location, allowing one to map from the
1264 * source code into the AST.
1265 */
1266typedef struct {
1267  enum CXCursorKind kind;
1268  void *data[3];
1269} CXCursor;
1270
1271/**
1272 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
1273 *
1274 * @{
1275 */
1276
1277/**
1278 * \brief Retrieve the NULL cursor, which represents no entity.
1279 */
1280CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
1281
1282/**
1283 * \brief Retrieve the cursor that represents the given translation unit.
1284 *
1285 * The translation unit cursor can be used to start traversing the
1286 * various declarations within the given translation unit.
1287 */
1288CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
1289
1290/**
1291 * \brief Determine whether two cursors are equivalent.
1292 */
1293CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
1294
1295/**
1296 * \brief Retrieve the kind of the given cursor.
1297 */
1298CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
1299
1300/**
1301 * \brief Determine whether the given cursor kind represents a declaration.
1302 */
1303CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
1304
1305/**
1306 * \brief Determine whether the given cursor kind represents a simple
1307 * reference.
1308 *
1309 * Note that other kinds of cursors (such as expressions) can also refer to
1310 * other cursors. Use clang_getCursorReferenced() to determine whether a
1311 * particular cursor refers to another entity.
1312 */
1313CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
1314
1315/**
1316 * \brief Determine whether the given cursor kind represents an expression.
1317 */
1318CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
1319
1320/**
1321 * \brief Determine whether the given cursor kind represents a statement.
1322 */
1323CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
1324
1325/**
1326 * \brief Determine whether the given cursor kind represents an invalid
1327 * cursor.
1328 */
1329CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
1330
1331/**
1332 * \brief Determine whether the given cursor kind represents a translation
1333 * unit.
1334 */
1335CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
1336
1337/***
1338 * \brief Determine whether the given cursor represents a preprocessing
1339 * element, such as a preprocessor directive or macro instantiation.
1340 */
1341CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
1342
1343/***
1344 * \brief Determine whether the given cursor represents a currently
1345 *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
1346 */
1347CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
1348
1349/**
1350 * \brief Describe the linkage of the entity referred to by a cursor.
1351 */
1352enum CXLinkageKind {
1353  /** \brief This value indicates that no linkage information is available
1354   * for a provided CXCursor. */
1355  CXLinkage_Invalid,
1356  /**
1357   * \brief This is the linkage for variables, parameters, and so on that
1358   *  have automatic storage.  This covers normal (non-extern) local variables.
1359   */
1360  CXLinkage_NoLinkage,
1361  /** \brief This is the linkage for static variables and static functions. */
1362  CXLinkage_Internal,
1363  /** \brief This is the linkage for entities with external linkage that live
1364   * in C++ anonymous namespaces.*/
1365  CXLinkage_UniqueExternal,
1366  /** \brief This is the linkage for entities with true, external linkage. */
1367  CXLinkage_External
1368};
1369
1370/**
1371 * \brief Determine the linkage of the entity referred to by a given cursor.
1372 */
1373CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
1374
1375/**
1376 * \brief Determine the availability of the entity that this cursor refers to.
1377 *
1378 * \param cursor The cursor to query.
1379 *
1380 * \returns The availability of the cursor.
1381 */
1382CINDEX_LINKAGE enum CXAvailabilityKind
1383clang_getCursorAvailability(CXCursor cursor);
1384
1385/**
1386 * \brief Describe the "language" of the entity referred to by a cursor.
1387 */
1388CINDEX_LINKAGE enum CXLanguageKind {
1389  CXLanguage_Invalid = 0,
1390  CXLanguage_C,
1391  CXLanguage_ObjC,
1392  CXLanguage_CPlusPlus
1393};
1394
1395/**
1396 * \brief Determine the "language" of the entity referred to by a given cursor.
1397 */
1398CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
1399
1400
1401/**
1402 * \brief Determine the semantic parent of the given cursor.
1403 *
1404 * The semantic parent of a cursor is the cursor that semantically contains
1405 * the given \p cursor. For many declarations, the lexical and semantic parents
1406 * are equivalent (the lexical parent is returned by
1407 * \c clang_getCursorLexicalParent()). They diverge when declarations or
1408 * definitions are provided out-of-line. For example:
1409 *
1410 * \code
1411 * class C {
1412 *  void f();
1413 * };
1414 *
1415 * void C::f() { }
1416 * \endcode
1417 *
1418 * In the out-of-line definition of \c C::f, the semantic parent is the
1419 * the class \c C, of which this function is a member. The lexical parent is
1420 * the place where the declaration actually occurs in the source code; in this
1421 * case, the definition occurs in the translation unit. In general, the
1422 * lexical parent for a given entity can change without affecting the semantics
1423 * of the program, and the lexical parent of different declarations of the
1424 * same entity may be different. Changing the semantic parent of a declaration,
1425 * on the other hand, can have a major impact on semantics, and redeclarations
1426 * of a particular entity should all have the same semantic context.
1427 *
1428 * In the example above, both declarations of \c C::f have \c C as their
1429 * semantic context, while the lexical context of the first \c C::f is \c C
1430 * and the lexical context of the second \c C::f is the translation unit.
1431 */
1432CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
1433
1434/**
1435 * \brief Determine the lexical parent of the given cursor.
1436 *
1437 * The lexical parent of a cursor is the cursor in which the given \p cursor
1438 * was actually written. For many declarations, the lexical and semantic parents
1439 * are equivalent (the semantic parent is returned by
1440 * \c clang_getCursorSemanticParent()). They diverge when declarations or
1441 * definitions are provided out-of-line. For example:
1442 *
1443 * \code
1444 * class C {
1445 *  void f();
1446 * };
1447 *
1448 * void C::f() { }
1449 * \endcode
1450 *
1451 * In the out-of-line definition of \c C::f, the semantic parent is the
1452 * the class \c C, of which this function is a member. The lexical parent is
1453 * the place where the declaration actually occurs in the source code; in this
1454 * case, the definition occurs in the translation unit. In general, the
1455 * lexical parent for a given entity can change without affecting the semantics
1456 * of the program, and the lexical parent of different declarations of the
1457 * same entity may be different. Changing the semantic parent of a declaration,
1458 * on the other hand, can have a major impact on semantics, and redeclarations
1459 * of a particular entity should all have the same semantic context.
1460 *
1461 * In the example above, both declarations of \c C::f have \c C as their
1462 * semantic context, while the lexical context of the first \c C::f is \c C
1463 * and the lexical context of the second \c C::f is the translation unit.
1464 */
1465CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
1466
1467/**
1468 * \brief Determine the set of methods that are overridden by the given
1469 * method.
1470 *
1471 * In both Objective-C and C++, a method (aka virtual member function,
1472 * in C++) can override a virtual method in a base class. For
1473 * Objective-C, a method is said to override any method in the class's
1474 * interface (if we're coming from an implementation), its protocols,
1475 * or its categories, that has the same selector and is of the same
1476 * kind (class or instance). If no such method exists, the search
1477 * continues to the class's superclass, its protocols, and its
1478 * categories, and so on.
1479 *
1480 * For C++, a virtual member function overrides any virtual member
1481 * function with the same signature that occurs in its base
1482 * classes. With multiple inheritance, a virtual member function can
1483 * override several virtual member functions coming from different
1484 * base classes.
1485 *
1486 * In all cases, this function determines the immediate overridden
1487 * method, rather than all of the overridden methods. For example, if
1488 * a method is originally declared in a class A, then overridden in B
1489 * (which in inherits from A) and also in C (which inherited from B),
1490 * then the only overridden method returned from this function when
1491 * invoked on C's method will be B's method. The client may then
1492 * invoke this function again, given the previously-found overridden
1493 * methods, to map out the complete method-override set.
1494 *
1495 * \param cursor A cursor representing an Objective-C or C++
1496 * method. This routine will compute the set of methods that this
1497 * method overrides.
1498 *
1499 * \param overridden A pointer whose pointee will be replaced with a
1500 * pointer to an array of cursors, representing the set of overridden
1501 * methods. If there are no overridden methods, the pointee will be
1502 * set to NULL. The pointee must be freed via a call to
1503 * \c clang_disposeOverriddenCursors().
1504 *
1505 * \param num_overridden A pointer to the number of overridden
1506 * functions, will be set to the number of overridden functions in the
1507 * array pointed to by \p overridden.
1508 */
1509CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
1510                                               CXCursor **overridden,
1511                                               unsigned *num_overridden);
1512
1513/**
1514 * \brief Free the set of overridden cursors returned by \c
1515 * clang_getOverriddenCursors().
1516 */
1517CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
1518
1519/**
1520 * \brief Retrieve the file that is included by the given inclusion directive
1521 * cursor.
1522 */
1523CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
1524
1525/**
1526 * @}
1527 */
1528
1529/**
1530 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
1531 *
1532 * Cursors represent a location within the Abstract Syntax Tree (AST). These
1533 * routines help map between cursors and the physical locations where the
1534 * described entities occur in the source code. The mapping is provided in
1535 * both directions, so one can map from source code to the AST and back.
1536 *
1537 * @{
1538 */
1539
1540/**
1541 * \brief Map a source location to the cursor that describes the entity at that
1542 * location in the source code.
1543 *
1544 * clang_getCursor() maps an arbitrary source location within a translation
1545 * unit down to the most specific cursor that describes the entity at that
1546 * location. For example, given an expression \c x + y, invoking
1547 * clang_getCursor() with a source location pointing to "x" will return the
1548 * cursor for "x"; similarly for "y". If the cursor points anywhere between
1549 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
1550 * will return a cursor referring to the "+" expression.
1551 *
1552 * \returns a cursor representing the entity at the given source location, or
1553 * a NULL cursor if no such entity can be found.
1554 */
1555CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
1556
1557/**
1558 * \brief Retrieve the physical location of the source constructor referenced
1559 * by the given cursor.
1560 *
1561 * The location of a declaration is typically the location of the name of that
1562 * declaration, where the name of that declaration would occur if it is
1563 * unnamed, or some keyword that introduces that particular declaration.
1564 * The location of a reference is where that reference occurs within the
1565 * source code.
1566 */
1567CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
1568
1569/**
1570 * \brief Retrieve the physical extent of the source construct referenced by
1571 * the given cursor.
1572 *
1573 * The extent of a cursor starts with the file/line/column pointing at the
1574 * first character within the source construct that the cursor refers to and
1575 * ends with the last character withinin that source construct. For a
1576 * declaration, the extent covers the declaration itself. For a reference,
1577 * the extent covers the location of the reference (e.g., where the referenced
1578 * entity was actually used).
1579 */
1580CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
1581
1582/**
1583 * @}
1584 */
1585
1586/**
1587 * \defgroup CINDEX_TYPES Type information for CXCursors
1588 *
1589 * @{
1590 */
1591
1592/**
1593 * \brief Describes the kind of type
1594 */
1595enum CXTypeKind {
1596  /**
1597   * \brief Reprents an invalid type (e.g., where no type is available).
1598   */
1599  CXType_Invalid = 0,
1600
1601  /**
1602   * \brief A type whose specific kind is not exposed via this
1603   * interface.
1604   */
1605  CXType_Unexposed = 1,
1606
1607  /* Builtin types */
1608  CXType_Void = 2,
1609  CXType_Bool = 3,
1610  CXType_Char_U = 4,
1611  CXType_UChar = 5,
1612  CXType_Char16 = 6,
1613  CXType_Char32 = 7,
1614  CXType_UShort = 8,
1615  CXType_UInt = 9,
1616  CXType_ULong = 10,
1617  CXType_ULongLong = 11,
1618  CXType_UInt128 = 12,
1619  CXType_Char_S = 13,
1620  CXType_SChar = 14,
1621  CXType_WChar = 15,
1622  CXType_Short = 16,
1623  CXType_Int = 17,
1624  CXType_Long = 18,
1625  CXType_LongLong = 19,
1626  CXType_Int128 = 20,
1627  CXType_Float = 21,
1628  CXType_Double = 22,
1629  CXType_LongDouble = 23,
1630  CXType_NullPtr = 24,
1631  CXType_Overload = 25,
1632  CXType_Dependent = 26,
1633  CXType_ObjCId = 27,
1634  CXType_ObjCClass = 28,
1635  CXType_ObjCSel = 29,
1636  CXType_FirstBuiltin = CXType_Void,
1637  CXType_LastBuiltin  = CXType_ObjCSel,
1638
1639  CXType_Complex = 100,
1640  CXType_Pointer = 101,
1641  CXType_BlockPointer = 102,
1642  CXType_LValueReference = 103,
1643  CXType_RValueReference = 104,
1644  CXType_Record = 105,
1645  CXType_Enum = 106,
1646  CXType_Typedef = 107,
1647  CXType_ObjCInterface = 108,
1648  CXType_ObjCObjectPointer = 109,
1649  CXType_FunctionNoProto = 110,
1650  CXType_FunctionProto = 111
1651};
1652
1653/**
1654 * \brief The type of an element in the abstract syntax tree.
1655 *
1656 */
1657typedef struct {
1658  enum CXTypeKind kind;
1659  void *data[2];
1660} CXType;
1661
1662/**
1663 * \brief Retrieve the type of a CXCursor (if any).
1664 */
1665CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
1666
1667/**
1668 * \determine Determine whether two CXTypes represent the same type.
1669 *
1670 * \returns non-zero if the CXTypes represent the same type and
1671            zero otherwise.
1672 */
1673CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
1674
1675/**
1676 * \brief Return the canonical type for a CXType.
1677 *
1678 * Clang's type system explicitly models typedefs and all the ways
1679 * a specific type can be represented.  The canonical type is the underlying
1680 * type with all the "sugar" removed.  For example, if 'T' is a typedef
1681 * for 'int', the canonical type for 'T' would be 'int'.
1682 */
1683CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
1684
1685/**
1686 * \brief For pointer types, returns the type of the pointee.
1687 *
1688 */
1689CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
1690
1691/**
1692 * \brief Return the cursor for the declaration of the given type.
1693 */
1694CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
1695
1696
1697/**
1698 * \brief Retrieve the spelling of a given CXTypeKind.
1699 */
1700CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
1701
1702/**
1703 * \brief Retrieve the result type associated with a function type.
1704 */
1705CINDEX_LINKAGE CXType clang_getResultType(CXType T);
1706
1707/**
1708 * \brief Retrieve the result type associated with a given cursor.  This only
1709 *  returns a valid type of the cursor refers to a function or method.
1710 */
1711CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
1712
1713/**
1714 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
1715 *  otherwise.
1716 */
1717CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
1718
1719/**
1720 * \brief Returns 1 if the base class specified by the cursor with kind
1721 *   CX_CXXBaseSpecifier is virtual.
1722 */
1723CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
1724
1725/**
1726 * \brief Represents the C++ access control level to a base class for a
1727 * cursor with kind CX_CXXBaseSpecifier.
1728 */
1729enum CX_CXXAccessSpecifier {
1730  CX_CXXInvalidAccessSpecifier,
1731  CX_CXXPublic,
1732  CX_CXXProtected,
1733  CX_CXXPrivate
1734};
1735
1736/**
1737 * \brief Returns the access control level for the C++ base specifier
1738 *  represented by a cursor with kind CX_CXXBaseSpecifier.
1739 */
1740CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
1741
1742/**
1743 * \brief Determine the number of overloaded declarations referenced by a
1744 * \c CXCursor_OverloadedDeclRef cursor.
1745 *
1746 * \param cursor The cursor whose overloaded declarations are being queried.
1747 *
1748 * \returns The number of overloaded declarations referenced by \c cursor. If it
1749 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
1750 */
1751CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
1752
1753/**
1754 * \brief Retrieve a cursor for one of the overloaded declarations referenced
1755 * by a \c CXCursor_OverloadedDeclRef cursor.
1756 *
1757 * \param cursor The cursor whose overloaded declarations are being queried.
1758 *
1759 * \param index The zero-based index into the set of overloaded declarations in
1760 * the cursor.
1761 *
1762 * \returns A cursor representing the declaration referenced by the given
1763 * \c cursor at the specified \c index. If the cursor does not have an
1764 * associated set of overloaded declarations, or if the index is out of bounds,
1765 * returns \c clang_getNullCursor();
1766 */
1767CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
1768                                                unsigned index);
1769
1770/**
1771 * @}
1772 */
1773
1774/**
1775 * \defgroup CINDEX_ATTRIBUTES Information for attributes
1776 *
1777 * @{
1778 */
1779
1780
1781/**
1782 * \brief For cursors representing an iboutletcollection attribute,
1783 *  this function returns the collection element type.
1784 *
1785 */
1786CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
1787
1788/**
1789 * @}
1790 */
1791
1792/**
1793 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
1794 *
1795 * These routines provide the ability to traverse the abstract syntax tree
1796 * using cursors.
1797 *
1798 * @{
1799 */
1800
1801/**
1802 * \brief Describes how the traversal of the children of a particular
1803 * cursor should proceed after visiting a particular child cursor.
1804 *
1805 * A value of this enumeration type should be returned by each
1806 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
1807 */
1808enum CXChildVisitResult {
1809  /**
1810   * \brief Terminates the cursor traversal.
1811   */
1812  CXChildVisit_Break,
1813  /**
1814   * \brief Continues the cursor traversal with the next sibling of
1815   * the cursor just visited, without visiting its children.
1816   */
1817  CXChildVisit_Continue,
1818  /**
1819   * \brief Recursively traverse the children of this cursor, using
1820   * the same visitor and client data.
1821   */
1822  CXChildVisit_Recurse
1823};
1824
1825/**
1826 * \brief Visitor invoked for each cursor found by a traversal.
1827 *
1828 * This visitor function will be invoked for each cursor found by
1829 * clang_visitCursorChildren(). Its first argument is the cursor being
1830 * visited, its second argument is the parent visitor for that cursor,
1831 * and its third argument is the client data provided to
1832 * clang_visitCursorChildren().
1833 *
1834 * The visitor should return one of the \c CXChildVisitResult values
1835 * to direct clang_visitCursorChildren().
1836 */
1837typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
1838                                                   CXCursor parent,
1839                                                   CXClientData client_data);
1840
1841/**
1842 * \brief Visit the children of a particular cursor.
1843 *
1844 * This function visits all the direct children of the given cursor,
1845 * invoking the given \p visitor function with the cursors of each
1846 * visited child. The traversal may be recursive, if the visitor returns
1847 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
1848 * the visitor returns \c CXChildVisit_Break.
1849 *
1850 * \param parent the cursor whose child may be visited. All kinds of
1851 * cursors can be visited, including invalid cursors (which, by
1852 * definition, have no children).
1853 *
1854 * \param visitor the visitor function that will be invoked for each
1855 * child of \p parent.
1856 *
1857 * \param client_data pointer data supplied by the client, which will
1858 * be passed to the visitor each time it is invoked.
1859 *
1860 * \returns a non-zero value if the traversal was terminated
1861 * prematurely by the visitor returning \c CXChildVisit_Break.
1862 */
1863CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
1864                                            CXCursorVisitor visitor,
1865                                            CXClientData client_data);
1866#ifdef __has_feature
1867#  if __has_feature(blocks)
1868/**
1869 * \brief Visitor invoked for each cursor found by a traversal.
1870 *
1871 * This visitor block will be invoked for each cursor found by
1872 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
1873 * visited, its second argument is the parent visitor for that cursor.
1874 *
1875 * The visitor should return one of the \c CXChildVisitResult values
1876 * to direct clang_visitChildrenWithBlock().
1877 */
1878typedef enum CXChildVisitResult
1879     (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
1880
1881/**
1882 * Visits the children of a cursor using the specified block.  Behaves
1883 * identically to clang_visitChildren() in all other respects.
1884 */
1885unsigned clang_visitChildrenWithBlock(CXCursor parent,
1886                                      CXCursorVisitorBlock block);
1887#  endif
1888#endif
1889
1890/**
1891 * @}
1892 */
1893
1894/**
1895 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
1896 *
1897 * These routines provide the ability to determine references within and
1898 * across translation units, by providing the names of the entities referenced
1899 * by cursors, follow reference cursors to the declarations they reference,
1900 * and associate declarations with their definitions.
1901 *
1902 * @{
1903 */
1904
1905/**
1906 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
1907 * by the given cursor.
1908 *
1909 * A Unified Symbol Resolution (USR) is a string that identifies a particular
1910 * entity (function, class, variable, etc.) within a program. USRs can be
1911 * compared across translation units to determine, e.g., when references in
1912 * one translation refer to an entity defined in another translation unit.
1913 */
1914CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
1915
1916/**
1917 * \brief Construct a USR for a specified Objective-C class.
1918 */
1919CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
1920
1921/**
1922 * \brief Construct a USR for a specified Objective-C category.
1923 */
1924CINDEX_LINKAGE CXString
1925  clang_constructUSR_ObjCCategory(const char *class_name,
1926                                 const char *category_name);
1927
1928/**
1929 * \brief Construct a USR for a specified Objective-C protocol.
1930 */
1931CINDEX_LINKAGE CXString
1932  clang_constructUSR_ObjCProtocol(const char *protocol_name);
1933
1934
1935/**
1936 * \brief Construct a USR for a specified Objective-C instance variable and
1937 *   the USR for its containing class.
1938 */
1939CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
1940                                                    CXString classUSR);
1941
1942/**
1943 * \brief Construct a USR for a specified Objective-C method and
1944 *   the USR for its containing class.
1945 */
1946CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
1947                                                      unsigned isInstanceMethod,
1948                                                      CXString classUSR);
1949
1950/**
1951 * \brief Construct a USR for a specified Objective-C property and the USR
1952 *  for its containing class.
1953 */
1954CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
1955                                                        CXString classUSR);
1956
1957/**
1958 * \brief Retrieve a name for the entity referenced by this cursor.
1959 */
1960CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
1961
1962/**
1963 * \brief Retrieve the display name for the entity referenced by this cursor.
1964 *
1965 * The display name contains extra information that helps identify the cursor,
1966 * such as the parameters of a function or template or the arguments of a
1967 * class template specialization.
1968 */
1969CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
1970
1971/** \brief For a cursor that is a reference, retrieve a cursor representing the
1972 * entity that it references.
1973 *
1974 * Reference cursors refer to other entities in the AST. For example, an
1975 * Objective-C superclass reference cursor refers to an Objective-C class.
1976 * This function produces the cursor for the Objective-C class from the
1977 * cursor for the superclass reference. If the input cursor is a declaration or
1978 * definition, it returns that declaration or definition unchanged.
1979 * Otherwise, returns the NULL cursor.
1980 */
1981CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
1982
1983/**
1984 *  \brief For a cursor that is either a reference to or a declaration
1985 *  of some entity, retrieve a cursor that describes the definition of
1986 *  that entity.
1987 *
1988 *  Some entities can be declared multiple times within a translation
1989 *  unit, but only one of those declarations can also be a
1990 *  definition. For example, given:
1991 *
1992 *  \code
1993 *  int f(int, int);
1994 *  int g(int x, int y) { return f(x, y); }
1995 *  int f(int a, int b) { return a + b; }
1996 *  int f(int, int);
1997 *  \endcode
1998 *
1999 *  there are three declarations of the function "f", but only the
2000 *  second one is a definition. The clang_getCursorDefinition()
2001 *  function will take any cursor pointing to a declaration of "f"
2002 *  (the first or fourth lines of the example) or a cursor referenced
2003 *  that uses "f" (the call to "f' inside "g") and will return a
2004 *  declaration cursor pointing to the definition (the second "f"
2005 *  declaration).
2006 *
2007 *  If given a cursor for which there is no corresponding definition,
2008 *  e.g., because there is no definition of that entity within this
2009 *  translation unit, returns a NULL cursor.
2010 */
2011CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
2012
2013/**
2014 * \brief Determine whether the declaration pointed to by this cursor
2015 * is also a definition of that entity.
2016 */
2017CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
2018
2019/**
2020 * @}
2021 */
2022
2023/**
2024 * \defgroup CINDEX_CPP C++ AST introspection
2025 *
2026 * The routines in this group provide access information in the ASTs specific
2027 * to C++ language features.
2028 *
2029 * @{
2030 */
2031
2032/**
2033 * \brief Determine if a C++ member function or member function template is
2034 * declared 'static'.
2035 */
2036CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
2037
2038/**
2039 * \brief Given a cursor that represents a template, determine
2040 * the cursor kind of the specializations would be generated by instantiating
2041 * the template.
2042 *
2043 * This routine can be used to determine what flavor of function template,
2044 * class template, or class template partial specialization is stored in the
2045 * cursor. For example, it can describe whether a class template cursor is
2046 * declared with "struct", "class" or "union".
2047 *
2048 * \param C The cursor to query. This cursor should represent a template
2049 * declaration.
2050 *
2051 * \returns The cursor kind of the specializations that would be generated
2052 * by instantiating the template \p C. If \p C is not a template, returns
2053 * \c CXCursor_NoDeclFound.
2054 */
2055CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
2056
2057/**
2058 * \brief Given a cursor that may represent a specialization or instantiation
2059 * of a template, retrieve the cursor that represents the template that it
2060 * specializes or from which it was instantiated.
2061 *
2062 * This routine determines the template involved both for explicit
2063 * specializations of templates and for implicit instantiations of the template,
2064 * both of which are referred to as "specializations". For a class template
2065 * specialization (e.g., \c std::vector<bool>), this routine will return
2066 * either the primary template (\c std::vector) or, if the specialization was
2067 * instantiated from a class template partial specialization, the class template
2068 * partial specialization. For a class template partial specialization and a
2069 * function template specialization (including instantiations), this
2070 * this routine will return the specialized template.
2071 *
2072 * For members of a class template (e.g., member functions, member classes, or
2073 * static data members), returns the specialized or instantiated member.
2074 * Although not strictly "templates" in the C++ language, members of class
2075 * templates have the same notions of specializations and instantiations that
2076 * templates do, so this routine treats them similarly.
2077 *
2078 * \param C A cursor that may be a specialization of a template or a member
2079 * of a template.
2080 *
2081 * \returns If the given cursor is a specialization or instantiation of a
2082 * template or a member thereof, the template or member that it specializes or
2083 * from which it was instantiated. Otherwise, returns a NULL cursor.
2084 */
2085CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
2086
2087/**
2088 * @}
2089 */
2090
2091/**
2092 * \defgroup CINDEX_LEX Token extraction and manipulation
2093 *
2094 * The routines in this group provide access to the tokens within a
2095 * translation unit, along with a semantic mapping of those tokens to
2096 * their corresponding cursors.
2097 *
2098 * @{
2099 */
2100
2101/**
2102 * \brief Describes a kind of token.
2103 */
2104typedef enum CXTokenKind {
2105  /**
2106   * \brief A token that contains some kind of punctuation.
2107   */
2108  CXToken_Punctuation,
2109
2110  /**
2111   * \brief A language keyword.
2112   */
2113  CXToken_Keyword,
2114
2115  /**
2116   * \brief An identifier (that is not a keyword).
2117   */
2118  CXToken_Identifier,
2119
2120  /**
2121   * \brief A numeric, string, or character literal.
2122   */
2123  CXToken_Literal,
2124
2125  /**
2126   * \brief A comment.
2127   */
2128  CXToken_Comment
2129} CXTokenKind;
2130
2131/**
2132 * \brief Describes a single preprocessing token.
2133 */
2134typedef struct {
2135  unsigned int_data[4];
2136  void *ptr_data;
2137} CXToken;
2138
2139/**
2140 * \brief Determine the kind of the given token.
2141 */
2142CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
2143
2144/**
2145 * \brief Determine the spelling of the given token.
2146 *
2147 * The spelling of a token is the textual representation of that token, e.g.,
2148 * the text of an identifier or keyword.
2149 */
2150CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
2151
2152/**
2153 * \brief Retrieve the source location of the given token.
2154 */
2155CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
2156                                                       CXToken);
2157
2158/**
2159 * \brief Retrieve a source range that covers the given token.
2160 */
2161CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
2162
2163/**
2164 * \brief Tokenize the source code described by the given range into raw
2165 * lexical tokens.
2166 *
2167 * \param TU the translation unit whose text is being tokenized.
2168 *
2169 * \param Range the source range in which text should be tokenized. All of the
2170 * tokens produced by tokenization will fall within this source range,
2171 *
2172 * \param Tokens this pointer will be set to point to the array of tokens
2173 * that occur within the given source range. The returned pointer must be
2174 * freed with clang_disposeTokens() before the translation unit is destroyed.
2175 *
2176 * \param NumTokens will be set to the number of tokens in the \c *Tokens
2177 * array.
2178 *
2179 */
2180CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
2181                                   CXToken **Tokens, unsigned *NumTokens);
2182
2183/**
2184 * \brief Annotate the given set of tokens by providing cursors for each token
2185 * that can be mapped to a specific entity within the abstract syntax tree.
2186 *
2187 * This token-annotation routine is equivalent to invoking
2188 * clang_getCursor() for the source locations of each of the
2189 * tokens. The cursors provided are filtered, so that only those
2190 * cursors that have a direct correspondence to the token are
2191 * accepted. For example, given a function call \c f(x),
2192 * clang_getCursor() would provide the following cursors:
2193 *
2194 *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
2195 *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
2196 *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
2197 *
2198 * Only the first and last of these cursors will occur within the
2199 * annotate, since the tokens "f" and "x' directly refer to a function
2200 * and a variable, respectively, but the parentheses are just a small
2201 * part of the full syntax of the function call expression, which is
2202 * not provided as an annotation.
2203 *
2204 * \param TU the translation unit that owns the given tokens.
2205 *
2206 * \param Tokens the set of tokens to annotate.
2207 *
2208 * \param NumTokens the number of tokens in \p Tokens.
2209 *
2210 * \param Cursors an array of \p NumTokens cursors, whose contents will be
2211 * replaced with the cursors corresponding to each token.
2212 */
2213CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
2214                                         CXToken *Tokens, unsigned NumTokens,
2215                                         CXCursor *Cursors);
2216
2217/**
2218 * \brief Free the given set of tokens.
2219 */
2220CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
2221                                        CXToken *Tokens, unsigned NumTokens);
2222
2223/**
2224 * @}
2225 */
2226
2227/**
2228 * \defgroup CINDEX_DEBUG Debugging facilities
2229 *
2230 * These routines are used for testing and debugging, only, and should not
2231 * be relied upon.
2232 *
2233 * @{
2234 */
2235
2236/* for debug/testing */
2237CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
2238CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
2239                                          const char **startBuf,
2240                                          const char **endBuf,
2241                                          unsigned *startLine,
2242                                          unsigned *startColumn,
2243                                          unsigned *endLine,
2244                                          unsigned *endColumn);
2245CINDEX_LINKAGE void clang_enableStackTraces(void);
2246CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
2247                                          unsigned stack_size);
2248
2249/**
2250 * @}
2251 */
2252
2253/**
2254 * \defgroup CINDEX_CODE_COMPLET Code completion
2255 *
2256 * Code completion involves taking an (incomplete) source file, along with
2257 * knowledge of where the user is actively editing that file, and suggesting
2258 * syntactically- and semantically-valid constructs that the user might want to
2259 * use at that particular point in the source code. These data structures and
2260 * routines provide support for code completion.
2261 *
2262 * @{
2263 */
2264
2265/**
2266 * \brief A semantic string that describes a code-completion result.
2267 *
2268 * A semantic string that describes the formatting of a code-completion
2269 * result as a single "template" of text that should be inserted into the
2270 * source buffer when a particular code-completion result is selected.
2271 * Each semantic string is made up of some number of "chunks", each of which
2272 * contains some text along with a description of what that text means, e.g.,
2273 * the name of the entity being referenced, whether the text chunk is part of
2274 * the template, or whether it is a "placeholder" that the user should replace
2275 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
2276 * description of the different kinds of chunks.
2277 */
2278typedef void *CXCompletionString;
2279
2280/**
2281 * \brief A single result of code completion.
2282 */
2283typedef struct {
2284  /**
2285   * \brief The kind of entity that this completion refers to.
2286   *
2287   * The cursor kind will be a macro, keyword, or a declaration (one of the
2288   * *Decl cursor kinds), describing the entity that the completion is
2289   * referring to.
2290   *
2291   * \todo In the future, we would like to provide a full cursor, to allow
2292   * the client to extract additional information from declaration.
2293   */
2294  enum CXCursorKind CursorKind;
2295
2296  /**
2297   * \brief The code-completion string that describes how to insert this
2298   * code-completion result into the editing buffer.
2299   */
2300  CXCompletionString CompletionString;
2301} CXCompletionResult;
2302
2303/**
2304 * \brief Describes a single piece of text within a code-completion string.
2305 *
2306 * Each "chunk" within a code-completion string (\c CXCompletionString) is
2307 * either a piece of text with a specific "kind" that describes how that text
2308 * should be interpreted by the client or is another completion string.
2309 */
2310enum CXCompletionChunkKind {
2311  /**
2312   * \brief A code-completion string that describes "optional" text that
2313   * could be a part of the template (but is not required).
2314   *
2315   * The Optional chunk is the only kind of chunk that has a code-completion
2316   * string for its representation, which is accessible via
2317   * \c clang_getCompletionChunkCompletionString(). The code-completion string
2318   * describes an additional part of the template that is completely optional.
2319   * For example, optional chunks can be used to describe the placeholders for
2320   * arguments that match up with defaulted function parameters, e.g. given:
2321   *
2322   * \code
2323   * void f(int x, float y = 3.14, double z = 2.71828);
2324   * \endcode
2325   *
2326   * The code-completion string for this function would contain:
2327   *   - a TypedText chunk for "f".
2328   *   - a LeftParen chunk for "(".
2329   *   - a Placeholder chunk for "int x"
2330   *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
2331   *       - a Comma chunk for ","
2332   *       - a Placeholder chunk for "float y"
2333   *       - an Optional chunk containing the last defaulted argument:
2334   *           - a Comma chunk for ","
2335   *           - a Placeholder chunk for "double z"
2336   *   - a RightParen chunk for ")"
2337   *
2338   * There are many ways to handle Optional chunks. Two simple approaches are:
2339   *   - Completely ignore optional chunks, in which case the template for the
2340   *     function "f" would only include the first parameter ("int x").
2341   *   - Fully expand all optional chunks, in which case the template for the
2342   *     function "f" would have all of the parameters.
2343   */
2344  CXCompletionChunk_Optional,
2345  /**
2346   * \brief Text that a user would be expected to type to get this
2347   * code-completion result.
2348   *
2349   * There will be exactly one "typed text" chunk in a semantic string, which
2350   * will typically provide the spelling of a keyword or the name of a
2351   * declaration that could be used at the current code point. Clients are
2352   * expected to filter the code-completion results based on the text in this
2353   * chunk.
2354   */
2355  CXCompletionChunk_TypedText,
2356  /**
2357   * \brief Text that should be inserted as part of a code-completion result.
2358   *
2359   * A "text" chunk represents text that is part of the template to be
2360   * inserted into user code should this particular code-completion result
2361   * be selected.
2362   */
2363  CXCompletionChunk_Text,
2364  /**
2365   * \brief Placeholder text that should be replaced by the user.
2366   *
2367   * A "placeholder" chunk marks a place where the user should insert text
2368   * into the code-completion template. For example, placeholders might mark
2369   * the function parameters for a function declaration, to indicate that the
2370   * user should provide arguments for each of those parameters. The actual
2371   * text in a placeholder is a suggestion for the text to display before
2372   * the user replaces the placeholder with real code.
2373   */
2374  CXCompletionChunk_Placeholder,
2375  /**
2376   * \brief Informative text that should be displayed but never inserted as
2377   * part of the template.
2378   *
2379   * An "informative" chunk contains annotations that can be displayed to
2380   * help the user decide whether a particular code-completion result is the
2381   * right option, but which is not part of the actual template to be inserted
2382   * by code completion.
2383   */
2384  CXCompletionChunk_Informative,
2385  /**
2386   * \brief Text that describes the current parameter when code-completion is
2387   * referring to function call, message send, or template specialization.
2388   *
2389   * A "current parameter" chunk occurs when code-completion is providing
2390   * information about a parameter corresponding to the argument at the
2391   * code-completion point. For example, given a function
2392   *
2393   * \code
2394   * int add(int x, int y);
2395   * \endcode
2396   *
2397   * and the source code \c add(, where the code-completion point is after the
2398   * "(", the code-completion string will contain a "current parameter" chunk
2399   * for "int x", indicating that the current argument will initialize that
2400   * parameter. After typing further, to \c add(17, (where the code-completion
2401   * point is after the ","), the code-completion string will contain a
2402   * "current paremeter" chunk to "int y".
2403   */
2404  CXCompletionChunk_CurrentParameter,
2405  /**
2406   * \brief A left parenthesis ('('), used to initiate a function call or
2407   * signal the beginning of a function parameter list.
2408   */
2409  CXCompletionChunk_LeftParen,
2410  /**
2411   * \brief A right parenthesis (')'), used to finish a function call or
2412   * signal the end of a function parameter list.
2413   */
2414  CXCompletionChunk_RightParen,
2415  /**
2416   * \brief A left bracket ('[').
2417   */
2418  CXCompletionChunk_LeftBracket,
2419  /**
2420   * \brief A right bracket (']').
2421   */
2422  CXCompletionChunk_RightBracket,
2423  /**
2424   * \brief A left brace ('{').
2425   */
2426  CXCompletionChunk_LeftBrace,
2427  /**
2428   * \brief A right brace ('}').
2429   */
2430  CXCompletionChunk_RightBrace,
2431  /**
2432   * \brief A left angle bracket ('<').
2433   */
2434  CXCompletionChunk_LeftAngle,
2435  /**
2436   * \brief A right angle bracket ('>').
2437   */
2438  CXCompletionChunk_RightAngle,
2439  /**
2440   * \brief A comma separator (',').
2441   */
2442  CXCompletionChunk_Comma,
2443  /**
2444   * \brief Text that specifies the result type of a given result.
2445   *
2446   * This special kind of informative chunk is not meant to be inserted into
2447   * the text buffer. Rather, it is meant to illustrate the type that an
2448   * expression using the given completion string would have.
2449   */
2450  CXCompletionChunk_ResultType,
2451  /**
2452   * \brief A colon (':').
2453   */
2454  CXCompletionChunk_Colon,
2455  /**
2456   * \brief A semicolon (';').
2457   */
2458  CXCompletionChunk_SemiColon,
2459  /**
2460   * \brief An '=' sign.
2461   */
2462  CXCompletionChunk_Equal,
2463  /**
2464   * Horizontal space (' ').
2465   */
2466  CXCompletionChunk_HorizontalSpace,
2467  /**
2468   * Vertical space ('\n'), after which it is generally a good idea to
2469   * perform indentation.
2470   */
2471  CXCompletionChunk_VerticalSpace
2472};
2473
2474/**
2475 * \brief Determine the kind of a particular chunk within a completion string.
2476 *
2477 * \param completion_string the completion string to query.
2478 *
2479 * \param chunk_number the 0-based index of the chunk in the completion string.
2480 *
2481 * \returns the kind of the chunk at the index \c chunk_number.
2482 */
2483CINDEX_LINKAGE enum CXCompletionChunkKind
2484clang_getCompletionChunkKind(CXCompletionString completion_string,
2485                             unsigned chunk_number);
2486
2487/**
2488 * \brief Retrieve the text associated with a particular chunk within a
2489 * completion string.
2490 *
2491 * \param completion_string the completion string to query.
2492 *
2493 * \param chunk_number the 0-based index of the chunk in the completion string.
2494 *
2495 * \returns the text associated with the chunk at index \c chunk_number.
2496 */
2497CINDEX_LINKAGE CXString
2498clang_getCompletionChunkText(CXCompletionString completion_string,
2499                             unsigned chunk_number);
2500
2501/**
2502 * \brief Retrieve the completion string associated with a particular chunk
2503 * within a completion string.
2504 *
2505 * \param completion_string the completion string to query.
2506 *
2507 * \param chunk_number the 0-based index of the chunk in the completion string.
2508 *
2509 * \returns the completion string associated with the chunk at index
2510 * \c chunk_number, or NULL if that chunk is not represented by a completion
2511 * string.
2512 */
2513CINDEX_LINKAGE CXCompletionString
2514clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
2515                                         unsigned chunk_number);
2516
2517/**
2518 * \brief Retrieve the number of chunks in the given code-completion string.
2519 */
2520CINDEX_LINKAGE unsigned
2521clang_getNumCompletionChunks(CXCompletionString completion_string);
2522
2523/**
2524 * \brief Determine the priority of this code completion.
2525 *
2526 * The priority of a code completion indicates how likely it is that this
2527 * particular completion is the completion that the user will select. The
2528 * priority is selected by various internal heuristics.
2529 *
2530 * \param completion_string The completion string to query.
2531 *
2532 * \returns The priority of this completion string. Smaller values indicate
2533 * higher-priority (more likely) completions.
2534 */
2535CINDEX_LINKAGE unsigned
2536clang_getCompletionPriority(CXCompletionString completion_string);
2537
2538/**
2539 * \brief Determine the availability of the entity that this code-completion
2540 * string refers to.
2541 *
2542 * \param completion_string The completion string to query.
2543 *
2544 * \returns The availability of the completion string.
2545 */
2546CINDEX_LINKAGE enum CXAvailabilityKind
2547clang_getCompletionAvailability(CXCompletionString completion_string);
2548
2549/**
2550 * \brief Contains the results of code-completion.
2551 *
2552 * This data structure contains the results of code completion, as
2553 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
2554 * \c clang_disposeCodeCompleteResults.
2555 */
2556typedef struct {
2557  /**
2558   * \brief The code-completion results.
2559   */
2560  CXCompletionResult *Results;
2561
2562  /**
2563   * \brief The number of code-completion results stored in the
2564   * \c Results array.
2565   */
2566  unsigned NumResults;
2567} CXCodeCompleteResults;
2568
2569/**
2570 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
2571 * modify its behavior.
2572 *
2573 * The enumerators in this enumeration can be bitwise-OR'd together to
2574 * provide multiple options to \c clang_codeCompleteAt().
2575 */
2576enum CXCodeComplete_Flags {
2577  /**
2578   * \brief Whether to include macros within the set of code
2579   * completions returned.
2580   */
2581  CXCodeComplete_IncludeMacros = 0x01,
2582
2583  /**
2584   * \brief Whether to include code patterns for language constructs
2585   * within the set of code completions, e.g., for loops.
2586   */
2587  CXCodeComplete_IncludeCodePatterns = 0x02
2588};
2589
2590/**
2591 * \brief Returns a default set of code-completion options that can be
2592 * passed to\c clang_codeCompleteAt().
2593 */
2594CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
2595
2596/**
2597 * \brief Perform code completion at a given location in a translation unit.
2598 *
2599 * This function performs code completion at a particular file, line, and
2600 * column within source code, providing results that suggest potential
2601 * code snippets based on the context of the completion. The basic model
2602 * for code completion is that Clang will parse a complete source file,
2603 * performing syntax checking up to the location where code-completion has
2604 * been requested. At that point, a special code-completion token is passed
2605 * to the parser, which recognizes this token and determines, based on the
2606 * current location in the C/Objective-C/C++ grammar and the state of
2607 * semantic analysis, what completions to provide. These completions are
2608 * returned via a new \c CXCodeCompleteResults structure.
2609 *
2610 * Code completion itself is meant to be triggered by the client when the
2611 * user types punctuation characters or whitespace, at which point the
2612 * code-completion location will coincide with the cursor. For example, if \c p
2613 * is a pointer, code-completion might be triggered after the "-" and then
2614 * after the ">" in \c p->. When the code-completion location is afer the ">",
2615 * the completion results will provide, e.g., the members of the struct that
2616 * "p" points to. The client is responsible for placing the cursor at the
2617 * beginning of the token currently being typed, then filtering the results
2618 * based on the contents of the token. For example, when code-completing for
2619 * the expression \c p->get, the client should provide the location just after
2620 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
2621 * client can filter the results based on the current token text ("get"), only
2622 * showing those results that start with "get". The intent of this interface
2623 * is to separate the relatively high-latency acquisition of code-completion
2624 * results from the filtering of results on a per-character basis, which must
2625 * have a lower latency.
2626 *
2627 * \param TU The translation unit in which code-completion should
2628 * occur. The source files for this translation unit need not be
2629 * completely up-to-date (and the contents of those source files may
2630 * be overridden via \p unsaved_files). Cursors referring into the
2631 * translation unit may be invalidated by this invocation.
2632 *
2633 * \param complete_filename The name of the source file where code
2634 * completion should be performed. This filename may be any file
2635 * included in the translation unit.
2636 *
2637 * \param complete_line The line at which code-completion should occur.
2638 *
2639 * \param complete_column The column at which code-completion should occur.
2640 * Note that the column should point just after the syntactic construct that
2641 * initiated code completion, and not in the middle of a lexical token.
2642 *
2643 * \param unsaved_files the Tiles that have not yet been saved to disk
2644 * but may be required for parsing or code completion, including the
2645 * contents of those files.  The contents and name of these files (as
2646 * specified by CXUnsavedFile) are copied when necessary, so the
2647 * client only needs to guarantee their validity until the call to
2648 * this function returns.
2649 *
2650 * \param num_unsaved_files The number of unsaved file entries in \p
2651 * unsaved_files.
2652 *
2653 * \param options Extra options that control the behavior of code
2654 * completion, expressed as a bitwise OR of the enumerators of the
2655 * CXCodeComplete_Flags enumeration. The
2656 * \c clang_defaultCodeCompleteOptions() function returns a default set
2657 * of code-completion options.
2658 *
2659 * \returns If successful, a new \c CXCodeCompleteResults structure
2660 * containing code-completion results, which should eventually be
2661 * freed with \c clang_disposeCodeCompleteResults(). If code
2662 * completion fails, returns NULL.
2663 */
2664CINDEX_LINKAGE
2665CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
2666                                            const char *complete_filename,
2667                                            unsigned complete_line,
2668                                            unsigned complete_column,
2669                                            struct CXUnsavedFile *unsaved_files,
2670                                            unsigned num_unsaved_files,
2671                                            unsigned options);
2672
2673/**
2674 * \brief Sort the code-completion results in case-insensitive alphabetical
2675 * order.
2676 *
2677 * \param Results The set of results to sort.
2678 * \param NumResults The number of results in \p Results.
2679 */
2680CINDEX_LINKAGE
2681void clang_sortCodeCompletionResults(CXCompletionResult *Results,
2682                                     unsigned NumResults);
2683
2684/**
2685 * \brief Free the given set of code-completion results.
2686 */
2687CINDEX_LINKAGE
2688void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
2689
2690/**
2691 * \brief Determine the number of diagnostics produced prior to the
2692 * location where code completion was performed.
2693 */
2694CINDEX_LINKAGE
2695unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
2696
2697/**
2698 * \brief Retrieve a diagnostic associated with the given code completion.
2699 *
2700 * \param Result the code completion results to query.
2701 * \param Index the zero-based diagnostic number to retrieve.
2702 *
2703 * \returns the requested diagnostic. This diagnostic must be freed
2704 * via a call to \c clang_disposeDiagnostic().
2705 */
2706CINDEX_LINKAGE
2707CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
2708                                             unsigned Index);
2709
2710/**
2711 * @}
2712 */
2713
2714
2715/**
2716 * \defgroup CINDEX_MISC Miscellaneous utility functions
2717 *
2718 * @{
2719 */
2720
2721/**
2722 * \brief Return a version string, suitable for showing to a user, but not
2723 *        intended to be parsed (the format is not guaranteed to be stable).
2724 */
2725CINDEX_LINKAGE CXString clang_getClangVersion();
2726
2727 /**
2728  * \brief Visitor invoked for each file in a translation unit
2729  *        (used with clang_getInclusions()).
2730  *
2731  * This visitor function will be invoked by clang_getInclusions() for each
2732  * file included (either at the top-level or by #include directives) within
2733  * a translation unit.  The first argument is the file being included, and
2734  * the second and third arguments provide the inclusion stack.  The
2735  * array is sorted in order of immediate inclusion.  For example,
2736  * the first element refers to the location that included 'included_file'.
2737  */
2738typedef void (*CXInclusionVisitor)(CXFile included_file,
2739                                   CXSourceLocation* inclusion_stack,
2740                                   unsigned include_len,
2741                                   CXClientData client_data);
2742
2743/**
2744 * \brief Visit the set of preprocessor inclusions in a translation unit.
2745 *   The visitor function is called with the provided data for every included
2746 *   file.  This does not include headers included by the PCH file (unless one
2747 *   is inspecting the inclusions in the PCH file itself).
2748 */
2749CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
2750                                        CXInclusionVisitor visitor,
2751                                        CXClientData client_data);
2752
2753/**
2754 * @}
2755 */
2756
2757/**
2758 * @}
2759 */
2760
2761#ifdef __cplusplus
2762}
2763#endif
2764#endif
2765
2766