Index.h revision 367e8fe3ef5bcf5e3c9855364560b89f7a1e9145
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 <time.h>
20
21#include "clang-c/Platform.h"
22#include "clang-c/CXString.h"
23
24/**
25 * \brief The version constants for the libclang API.
26 * CINDEX_VERSION_MINOR should increase when there are API additions.
27 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
28 *
29 * The policy about the libclang API was always to keep it source and ABI
30 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
31 */
32#define CINDEX_VERSION_MAJOR 0
33#define CINDEX_VERSION_MINOR 20
34
35#define CINDEX_VERSION_ENCODE(major, minor) ( \
36      ((major) * 10000)                       \
37    + ((minor) *     1))
38
39#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
40    CINDEX_VERSION_MAJOR,                     \
41    CINDEX_VERSION_MINOR )
42
43#define CINDEX_VERSION_STRINGIZE_(major, minor)   \
44    #major"."#minor
45#define CINDEX_VERSION_STRINGIZE(major, minor)    \
46    CINDEX_VERSION_STRINGIZE_(major, minor)
47
48#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
49    CINDEX_VERSION_MAJOR,                               \
50    CINDEX_VERSION_MINOR)
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56/** \defgroup CINDEX libclang: C Interface to Clang
57 *
58 * The C Interface to Clang provides a relatively small API that exposes
59 * facilities for parsing source code into an abstract syntax tree (AST),
60 * loading already-parsed ASTs, traversing the AST, associating
61 * physical source locations with elements within the AST, and other
62 * facilities that support Clang-based development tools.
63 *
64 * This C interface to Clang will never provide all of the information
65 * representation stored in Clang's C++ AST, nor should it: the intent is to
66 * maintain an API that is relatively stable from one release to the next,
67 * providing only the basic functionality needed to support development tools.
68 *
69 * To avoid namespace pollution, data types are prefixed with "CX" and
70 * functions are prefixed with "clang_".
71 *
72 * @{
73 */
74
75/**
76 * \brief An "index" that consists of a set of translation units that would
77 * typically be linked together into an executable or library.
78 */
79typedef void *CXIndex;
80
81/**
82 * \brief A single translation unit, which resides in an index.
83 */
84typedef struct CXTranslationUnitImpl *CXTranslationUnit;
85
86/**
87 * \brief Opaque pointer representing client data that will be passed through
88 * to various callbacks and visitors.
89 */
90typedef void *CXClientData;
91
92/**
93 * \brief Provides the contents of a file that has not yet been saved to disk.
94 *
95 * Each CXUnsavedFile instance provides the name of a file on the
96 * system along with the current contents of that file that have not
97 * yet been saved to disk.
98 */
99struct CXUnsavedFile {
100  /**
101   * \brief The file whose contents have not yet been saved.
102   *
103   * This file must already exist in the file system.
104   */
105  const char *Filename;
106
107  /**
108   * \brief A buffer containing the unsaved contents of this file.
109   */
110  const char *Contents;
111
112  /**
113   * \brief The length of the unsaved contents of this buffer.
114   */
115  unsigned long Length;
116};
117
118/**
119 * \brief Describes the availability of a particular entity, which indicates
120 * whether the use of this entity will result in a warning or error due to
121 * it being deprecated or unavailable.
122 */
123enum CXAvailabilityKind {
124  /**
125   * \brief The entity is available.
126   */
127  CXAvailability_Available,
128  /**
129   * \brief The entity is available, but has been deprecated (and its use is
130   * not recommended).
131   */
132  CXAvailability_Deprecated,
133  /**
134   * \brief The entity is not available; any use of it will be an error.
135   */
136  CXAvailability_NotAvailable,
137  /**
138   * \brief The entity is available, but not accessible; any use of it will be
139   * an error.
140   */
141  CXAvailability_NotAccessible
142};
143
144/**
145 * \brief Describes a version number of the form major.minor.subminor.
146 */
147typedef struct CXVersion {
148  /**
149   * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
150   * value indicates that there is no version number at all.
151   */
152  int Major;
153  /**
154   * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
155   * will be negative if no minor version number was provided, e.g., for
156   * version '10'.
157   */
158  int Minor;
159  /**
160   * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
161   * will be negative if no minor or subminor version number was provided,
162   * e.g., in version '10' or '10.7'.
163   */
164  int Subminor;
165} CXVersion;
166
167/**
168 * \brief Provides a shared context for creating translation units.
169 *
170 * It provides two options:
171 *
172 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
173 * declarations (when loading any new translation units). A "local" declaration
174 * is one that belongs in the translation unit itself and not in a precompiled
175 * header that was used by the translation unit. If zero, all declarations
176 * will be enumerated.
177 *
178 * Here is an example:
179 *
180 * \code
181 *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
182 *   Idx = clang_createIndex(1, 1);
183 *
184 *   // IndexTest.pch was produced with the following command:
185 *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
186 *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
187 *
188 *   // This will load all the symbols from 'IndexTest.pch'
189 *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
190 *                       TranslationUnitVisitor, 0);
191 *   clang_disposeTranslationUnit(TU);
192 *
193 *   // This will load all the symbols from 'IndexTest.c', excluding symbols
194 *   // from 'IndexTest.pch'.
195 *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
196 *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
197 *                                                  0, 0);
198 *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
199 *                       TranslationUnitVisitor, 0);
200 *   clang_disposeTranslationUnit(TU);
201 * \endcode
202 *
203 * This process of creating the 'pch', loading it separately, and using it (via
204 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
205 * (which gives the indexer the same performance benefit as the compiler).
206 */
207CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
208                                         int displayDiagnostics);
209
210/**
211 * \brief Destroy the given index.
212 *
213 * The index must not be destroyed until all of the translation units created
214 * within that index have been destroyed.
215 */
216CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
217
218typedef enum {
219  /**
220   * \brief Used to indicate that no special CXIndex options are needed.
221   */
222  CXGlobalOpt_None = 0x0,
223
224  /**
225   * \brief Used to indicate that threads that libclang creates for indexing
226   * purposes should use background priority.
227   *
228   * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
229   * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
230   */
231  CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
232
233  /**
234   * \brief Used to indicate that threads that libclang creates for editing
235   * purposes should use background priority.
236   *
237   * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
238   * #clang_annotateTokens
239   */
240  CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
241
242  /**
243   * \brief Used to indicate that all threads that libclang creates should use
244   * background priority.
245   */
246  CXGlobalOpt_ThreadBackgroundPriorityForAll =
247      CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
248      CXGlobalOpt_ThreadBackgroundPriorityForEditing
249
250} CXGlobalOptFlags;
251
252/**
253 * \brief Sets general options associated with a CXIndex.
254 *
255 * For example:
256 * \code
257 * CXIndex idx = ...;
258 * clang_CXIndex_setGlobalOptions(idx,
259 *     clang_CXIndex_getGlobalOptions(idx) |
260 *     CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
261 * \endcode
262 *
263 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
264 */
265CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
266
267/**
268 * \brief Gets the general options associated with a CXIndex.
269 *
270 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
271 * are associated with the given CXIndex object.
272 */
273CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
274
275/**
276 * \defgroup CINDEX_FILES File manipulation routines
277 *
278 * @{
279 */
280
281/**
282 * \brief A particular source file that is part of a translation unit.
283 */
284typedef void *CXFile;
285
286
287/**
288 * \brief Retrieve the complete file and path name of the given file.
289 */
290CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
291
292/**
293 * \brief Retrieve the last modification time of the given file.
294 */
295CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
296
297/**
298 * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
299 * across an indexing session.
300 */
301typedef struct {
302  unsigned long long data[3];
303} CXFileUniqueID;
304
305/**
306 * \brief Retrieve the unique ID for the given \c file.
307 *
308 * \param file the file to get the ID for.
309 * \param outID stores the returned CXFileUniqueID.
310 * \returns If there was a failure getting the unique ID, returns non-zero,
311 * otherwise returns 0.
312*/
313CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
314
315/**
316 * \brief Determine whether the given header is guarded against
317 * multiple inclusions, either with the conventional
318 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
319 */
320CINDEX_LINKAGE unsigned
321clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
322
323/**
324 * \brief Retrieve a file handle within the given translation unit.
325 *
326 * \param tu the translation unit
327 *
328 * \param file_name the name of the file.
329 *
330 * \returns the file handle for the named file in the translation unit \p tu,
331 * or a NULL file handle if the file was not a part of this translation unit.
332 */
333CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
334                                    const char *file_name);
335
336/**
337 * @}
338 */
339
340/**
341 * \defgroup CINDEX_LOCATIONS Physical source locations
342 *
343 * Clang represents physical source locations in its abstract syntax tree in
344 * great detail, with file, line, and column information for the majority of
345 * the tokens parsed in the source code. These data types and functions are
346 * used to represent source location information, either for a particular
347 * point in the program or for a range of points in the program, and extract
348 * specific location information from those data types.
349 *
350 * @{
351 */
352
353/**
354 * \brief Identifies a specific source location within a translation
355 * unit.
356 *
357 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
358 * to map a source location to a particular file, line, and column.
359 */
360typedef struct {
361  const void *ptr_data[2];
362  unsigned int_data;
363} CXSourceLocation;
364
365/**
366 * \brief Identifies a half-open character range in the source code.
367 *
368 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
369 * starting and end locations from a source range, respectively.
370 */
371typedef struct {
372  const void *ptr_data[2];
373  unsigned begin_int_data;
374  unsigned end_int_data;
375} CXSourceRange;
376
377/**
378 * \brief Retrieve a NULL (invalid) source location.
379 */
380CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
381
382/**
383 * \brief Determine whether two source locations, which must refer into
384 * the same translation unit, refer to exactly the same point in the source
385 * code.
386 *
387 * \returns non-zero if the source locations refer to the same location, zero
388 * if they refer to different locations.
389 */
390CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
391                                             CXSourceLocation loc2);
392
393/**
394 * \brief Retrieves the source location associated with a given file/line/column
395 * in a particular translation unit.
396 */
397CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
398                                                  CXFile file,
399                                                  unsigned line,
400                                                  unsigned column);
401/**
402 * \brief Retrieves the source location associated with a given character offset
403 * in a particular translation unit.
404 */
405CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
406                                                           CXFile file,
407                                                           unsigned offset);
408
409/**
410 * \brief Returns non-zero if the given source location is in a system header.
411 */
412CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
413
414/**
415 * \brief Returns non-zero if the given source location is in the main file of
416 * the corresponding translation unit.
417 */
418CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
419
420/**
421 * \brief Retrieve a NULL (invalid) source range.
422 */
423CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
424
425/**
426 * \brief Retrieve a source range given the beginning and ending source
427 * locations.
428 */
429CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
430                                            CXSourceLocation end);
431
432/**
433 * \brief Determine whether two ranges are equivalent.
434 *
435 * \returns non-zero if the ranges are the same, zero if they differ.
436 */
437CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
438                                          CXSourceRange range2);
439
440/**
441 * \brief Returns non-zero if \p range is null.
442 */
443CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
444
445/**
446 * \brief Retrieve the file, line, column, and offset represented by
447 * the given source location.
448 *
449 * If the location refers into a macro expansion, retrieves the
450 * location of the macro expansion.
451 *
452 * \param location the location within a source file that will be decomposed
453 * into its parts.
454 *
455 * \param file [out] if non-NULL, will be set to the file to which the given
456 * source location points.
457 *
458 * \param line [out] if non-NULL, will be set to the line to which the given
459 * source location points.
460 *
461 * \param column [out] if non-NULL, will be set to the column to which the given
462 * source location points.
463 *
464 * \param offset [out] if non-NULL, will be set to the offset into the
465 * buffer to which the given source location points.
466 */
467CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
468                                               CXFile *file,
469                                               unsigned *line,
470                                               unsigned *column,
471                                               unsigned *offset);
472
473/**
474 * \brief Retrieve the file, line, column, and offset represented by
475 * the given source location, as specified in a # line directive.
476 *
477 * Example: given the following source code in a file somefile.c
478 *
479 * \code
480 * #123 "dummy.c" 1
481 *
482 * static int func(void)
483 * {
484 *     return 0;
485 * }
486 * \endcode
487 *
488 * the location information returned by this function would be
489 *
490 * File: dummy.c Line: 124 Column: 12
491 *
492 * whereas clang_getExpansionLocation would have returned
493 *
494 * File: somefile.c Line: 3 Column: 12
495 *
496 * \param location the location within a source file that will be decomposed
497 * into its parts.
498 *
499 * \param filename [out] if non-NULL, will be set to the filename of the
500 * source location. Note that filenames returned will be for "virtual" files,
501 * which don't necessarily exist on the machine running clang - e.g. when
502 * parsing preprocessed output obtained from a different environment. If
503 * a non-NULL value is passed in, remember to dispose of the returned value
504 * using \c clang_disposeString() once you've finished with it. For an invalid
505 * source location, an empty string is returned.
506 *
507 * \param line [out] if non-NULL, will be set to the line number of the
508 * source location. For an invalid source location, zero is returned.
509 *
510 * \param column [out] if non-NULL, will be set to the column number of the
511 * source location. For an invalid source location, zero is returned.
512 */
513CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
514                                              CXString *filename,
515                                              unsigned *line,
516                                              unsigned *column);
517
518/**
519 * \brief Legacy API to retrieve the file, line, column, and offset represented
520 * by the given source location.
521 *
522 * This interface has been replaced by the newer interface
523 * #clang_getExpansionLocation(). See that interface's documentation for
524 * details.
525 */
526CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
527                                                   CXFile *file,
528                                                   unsigned *line,
529                                                   unsigned *column,
530                                                   unsigned *offset);
531
532/**
533 * \brief Retrieve the file, line, column, and offset represented by
534 * the given source location.
535 *
536 * If the location refers into a macro instantiation, return where the
537 * location was originally spelled in the source file.
538 *
539 * \param location the location within a source file that will be decomposed
540 * into its parts.
541 *
542 * \param file [out] if non-NULL, will be set to the file to which the given
543 * source location points.
544 *
545 * \param line [out] if non-NULL, will be set to the line to which the given
546 * source location points.
547 *
548 * \param column [out] if non-NULL, will be set to the column to which the given
549 * source location points.
550 *
551 * \param offset [out] if non-NULL, will be set to the offset into the
552 * buffer to which the given source location points.
553 */
554CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
555                                              CXFile *file,
556                                              unsigned *line,
557                                              unsigned *column,
558                                              unsigned *offset);
559
560/**
561 * \brief Retrieve the file, line, column, and offset represented by
562 * the given source location.
563 *
564 * If the location refers into a macro expansion, return where the macro was
565 * expanded or where the macro argument was written, if the location points at
566 * a macro argument.
567 *
568 * \param location the location within a source file that will be decomposed
569 * into its parts.
570 *
571 * \param file [out] if non-NULL, will be set to the file to which the given
572 * source location points.
573 *
574 * \param line [out] if non-NULL, will be set to the line to which the given
575 * source location points.
576 *
577 * \param column [out] if non-NULL, will be set to the column to which the given
578 * source location points.
579 *
580 * \param offset [out] if non-NULL, will be set to the offset into the
581 * buffer to which the given source location points.
582 */
583CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
584                                          CXFile *file,
585                                          unsigned *line,
586                                          unsigned *column,
587                                          unsigned *offset);
588
589/**
590 * \brief Retrieve a source location representing the first character within a
591 * source range.
592 */
593CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
594
595/**
596 * \brief Retrieve a source location representing the last character within a
597 * source range.
598 */
599CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
600
601/**
602 * @}
603 */
604
605/**
606 * \defgroup CINDEX_DIAG Diagnostic reporting
607 *
608 * @{
609 */
610
611/**
612 * \brief Describes the severity of a particular diagnostic.
613 */
614enum CXDiagnosticSeverity {
615  /**
616   * \brief A diagnostic that has been suppressed, e.g., by a command-line
617   * option.
618   */
619  CXDiagnostic_Ignored = 0,
620
621  /**
622   * \brief This diagnostic is a note that should be attached to the
623   * previous (non-note) diagnostic.
624   */
625  CXDiagnostic_Note    = 1,
626
627  /**
628   * \brief This diagnostic indicates suspicious code that may not be
629   * wrong.
630   */
631  CXDiagnostic_Warning = 2,
632
633  /**
634   * \brief This diagnostic indicates that the code is ill-formed.
635   */
636  CXDiagnostic_Error   = 3,
637
638  /**
639   * \brief This diagnostic indicates that the code is ill-formed such
640   * that future parser recovery is unlikely to produce useful
641   * results.
642   */
643  CXDiagnostic_Fatal   = 4
644};
645
646/**
647 * \brief A single diagnostic, containing the diagnostic's severity,
648 * location, text, source ranges, and fix-it hints.
649 */
650typedef void *CXDiagnostic;
651
652/**
653 * \brief A group of CXDiagnostics.
654 */
655typedef void *CXDiagnosticSet;
656
657/**
658 * \brief Determine the number of diagnostics in a CXDiagnosticSet.
659 */
660CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
661
662/**
663 * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
664 *
665 * \param Diags the CXDiagnosticSet to query.
666 * \param Index the zero-based diagnostic number to retrieve.
667 *
668 * \returns the requested diagnostic. This diagnostic must be freed
669 * via a call to \c clang_disposeDiagnostic().
670 */
671CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
672                                                     unsigned Index);
673
674
675/**
676 * \brief Describes the kind of error that occurred (if any) in a call to
677 * \c clang_loadDiagnostics.
678 */
679enum CXLoadDiag_Error {
680  /**
681   * \brief Indicates that no error occurred.
682   */
683  CXLoadDiag_None = 0,
684
685  /**
686   * \brief Indicates that an unknown error occurred while attempting to
687   * deserialize diagnostics.
688   */
689  CXLoadDiag_Unknown = 1,
690
691  /**
692   * \brief Indicates that the file containing the serialized diagnostics
693   * could not be opened.
694   */
695  CXLoadDiag_CannotLoad = 2,
696
697  /**
698   * \brief Indicates that the serialized diagnostics file is invalid or
699   * corrupt.
700   */
701  CXLoadDiag_InvalidFile = 3
702};
703
704/**
705 * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
706 * file.
707 *
708 * \param file The name of the file to deserialize.
709 * \param error A pointer to a enum value recording if there was a problem
710 *        deserializing the diagnostics.
711 * \param errorString A pointer to a CXString for recording the error string
712 *        if the file was not successfully loaded.
713 *
714 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise.  These
715 * diagnostics should be released using clang_disposeDiagnosticSet().
716 */
717CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
718                                                  enum CXLoadDiag_Error *error,
719                                                  CXString *errorString);
720
721/**
722 * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
723 */
724CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
725
726/**
727 * \brief Retrieve the child diagnostics of a CXDiagnostic.
728 *
729 * This CXDiagnosticSet does not need to be released by
730 * clang_diposeDiagnosticSet.
731 */
732CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
733
734/**
735 * \brief Determine the number of diagnostics produced for the given
736 * translation unit.
737 */
738CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
739
740/**
741 * \brief Retrieve a diagnostic associated with the given translation unit.
742 *
743 * \param Unit the translation unit to query.
744 * \param Index the zero-based diagnostic number to retrieve.
745 *
746 * \returns the requested diagnostic. This diagnostic must be freed
747 * via a call to \c clang_disposeDiagnostic().
748 */
749CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
750                                                unsigned Index);
751
752/**
753 * \brief Retrieve the complete set of diagnostics associated with a
754 *        translation unit.
755 *
756 * \param Unit the translation unit to query.
757 */
758CINDEX_LINKAGE CXDiagnosticSet
759  clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
760
761/**
762 * \brief Destroy a diagnostic.
763 */
764CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
765
766/**
767 * \brief Options to control the display of diagnostics.
768 *
769 * The values in this enum are meant to be combined to customize the
770 * behavior of \c clang_displayDiagnostic().
771 */
772enum CXDiagnosticDisplayOptions {
773  /**
774   * \brief Display the source-location information where the
775   * diagnostic was located.
776   *
777   * When set, diagnostics will be prefixed by the file, line, and
778   * (optionally) column to which the diagnostic refers. For example,
779   *
780   * \code
781   * test.c:28: warning: extra tokens at end of #endif directive
782   * \endcode
783   *
784   * This option corresponds to the clang flag \c -fshow-source-location.
785   */
786  CXDiagnostic_DisplaySourceLocation = 0x01,
787
788  /**
789   * \brief If displaying the source-location information of the
790   * diagnostic, also include the column number.
791   *
792   * This option corresponds to the clang flag \c -fshow-column.
793   */
794  CXDiagnostic_DisplayColumn = 0x02,
795
796  /**
797   * \brief If displaying the source-location information of the
798   * diagnostic, also include information about source ranges in a
799   * machine-parsable format.
800   *
801   * This option corresponds to the clang flag
802   * \c -fdiagnostics-print-source-range-info.
803   */
804  CXDiagnostic_DisplaySourceRanges = 0x04,
805
806  /**
807   * \brief Display the option name associated with this diagnostic, if any.
808   *
809   * The option name displayed (e.g., -Wconversion) will be placed in brackets
810   * after the diagnostic text. This option corresponds to the clang flag
811   * \c -fdiagnostics-show-option.
812   */
813  CXDiagnostic_DisplayOption = 0x08,
814
815  /**
816   * \brief Display the category number associated with this diagnostic, if any.
817   *
818   * The category number is displayed within brackets after the diagnostic text.
819   * This option corresponds to the clang flag
820   * \c -fdiagnostics-show-category=id.
821   */
822  CXDiagnostic_DisplayCategoryId = 0x10,
823
824  /**
825   * \brief Display the category name associated with this diagnostic, if any.
826   *
827   * The category name is displayed within brackets after the diagnostic text.
828   * This option corresponds to the clang flag
829   * \c -fdiagnostics-show-category=name.
830   */
831  CXDiagnostic_DisplayCategoryName = 0x20
832};
833
834/**
835 * \brief Format the given diagnostic in a manner that is suitable for display.
836 *
837 * This routine will format the given diagnostic to a string, rendering
838 * the diagnostic according to the various options given. The
839 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
840 * options that most closely mimics the behavior of the clang compiler.
841 *
842 * \param Diagnostic The diagnostic to print.
843 *
844 * \param Options A set of options that control the diagnostic display,
845 * created by combining \c CXDiagnosticDisplayOptions values.
846 *
847 * \returns A new string containing for formatted diagnostic.
848 */
849CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
850                                               unsigned Options);
851
852/**
853 * \brief Retrieve the set of display options most similar to the
854 * default behavior of the clang compiler.
855 *
856 * \returns A set of display options suitable for use with \c
857 * clang_displayDiagnostic().
858 */
859CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
860
861/**
862 * \brief Determine the severity of the given diagnostic.
863 */
864CINDEX_LINKAGE enum CXDiagnosticSeverity
865clang_getDiagnosticSeverity(CXDiagnostic);
866
867/**
868 * \brief Retrieve the source location of the given diagnostic.
869 *
870 * This location is where Clang would print the caret ('^') when
871 * displaying the diagnostic on the command line.
872 */
873CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
874
875/**
876 * \brief Retrieve the text of the given diagnostic.
877 */
878CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
879
880/**
881 * \brief Retrieve the name of the command-line option that enabled this
882 * diagnostic.
883 *
884 * \param Diag The diagnostic to be queried.
885 *
886 * \param Disable If non-NULL, will be set to the option that disables this
887 * diagnostic (if any).
888 *
889 * \returns A string that contains the command-line option used to enable this
890 * warning, such as "-Wconversion" or "-pedantic".
891 */
892CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
893                                                  CXString *Disable);
894
895/**
896 * \brief Retrieve the category number for this diagnostic.
897 *
898 * Diagnostics can be categorized into groups along with other, related
899 * diagnostics (e.g., diagnostics under the same warning flag). This routine
900 * retrieves the category number for the given diagnostic.
901 *
902 * \returns The number of the category that contains this diagnostic, or zero
903 * if this diagnostic is uncategorized.
904 */
905CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
906
907/**
908 * \brief Retrieve the name of a particular diagnostic category.  This
909 *  is now deprecated.  Use clang_getDiagnosticCategoryText()
910 *  instead.
911 *
912 * \param Category A diagnostic category number, as returned by
913 * \c clang_getDiagnosticCategory().
914 *
915 * \returns The name of the given diagnostic category.
916 */
917CINDEX_DEPRECATED CINDEX_LINKAGE
918CXString clang_getDiagnosticCategoryName(unsigned Category);
919
920/**
921 * \brief Retrieve the diagnostic category text for a given diagnostic.
922 *
923 * \returns The text of the given diagnostic category.
924 */
925CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
926
927/**
928 * \brief Determine the number of source ranges associated with the given
929 * diagnostic.
930 */
931CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
932
933/**
934 * \brief Retrieve a source range associated with the diagnostic.
935 *
936 * A diagnostic's source ranges highlight important elements in the source
937 * code. On the command line, Clang displays source ranges by
938 * underlining them with '~' characters.
939 *
940 * \param Diagnostic the diagnostic whose range is being extracted.
941 *
942 * \param Range the zero-based index specifying which range to
943 *
944 * \returns the requested source range.
945 */
946CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
947                                                      unsigned Range);
948
949/**
950 * \brief Determine the number of fix-it hints associated with the
951 * given diagnostic.
952 */
953CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
954
955/**
956 * \brief Retrieve the replacement information for a given fix-it.
957 *
958 * Fix-its are described in terms of a source range whose contents
959 * should be replaced by a string. This approach generalizes over
960 * three kinds of operations: removal of source code (the range covers
961 * the code to be removed and the replacement string is empty),
962 * replacement of source code (the range covers the code to be
963 * replaced and the replacement string provides the new code), and
964 * insertion (both the start and end of the range point at the
965 * insertion location, and the replacement string provides the text to
966 * insert).
967 *
968 * \param Diagnostic The diagnostic whose fix-its are being queried.
969 *
970 * \param FixIt The zero-based index of the fix-it.
971 *
972 * \param ReplacementRange The source range whose contents will be
973 * replaced with the returned replacement string. Note that source
974 * ranges are half-open ranges [a, b), so the source code should be
975 * replaced from a and up to (but not including) b.
976 *
977 * \returns A string containing text that should be replace the source
978 * code indicated by the \c ReplacementRange.
979 */
980CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
981                                                 unsigned FixIt,
982                                               CXSourceRange *ReplacementRange);
983
984/**
985 * @}
986 */
987
988/**
989 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
990 *
991 * The routines in this group provide the ability to create and destroy
992 * translation units from files, either by parsing the contents of the files or
993 * by reading in a serialized representation of a translation unit.
994 *
995 * @{
996 */
997
998/**
999 * \brief Get the original translation unit source file name.
1000 */
1001CINDEX_LINKAGE CXString
1002clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1003
1004/**
1005 * \brief Return the CXTranslationUnit for a given source file and the provided
1006 * command line arguments one would pass to the compiler.
1007 *
1008 * Note: The 'source_filename' argument is optional.  If the caller provides a
1009 * NULL pointer, the name of the source file is expected to reside in the
1010 * specified command line arguments.
1011 *
1012 * Note: When encountered in 'clang_command_line_args', the following options
1013 * are ignored:
1014 *
1015 *   '-c'
1016 *   '-emit-ast'
1017 *   '-fsyntax-only'
1018 *   '-o \<output file>'  (both '-o' and '\<output file>' are ignored)
1019 *
1020 * \param CIdx The index object with which the translation unit will be
1021 * associated.
1022 *
1023 * \param source_filename The name of the source file to load, or NULL if the
1024 * source file is included in \p clang_command_line_args.
1025 *
1026 * \param num_clang_command_line_args The number of command-line arguments in
1027 * \p clang_command_line_args.
1028 *
1029 * \param clang_command_line_args The command-line arguments that would be
1030 * passed to the \c clang executable if it were being invoked out-of-process.
1031 * These command-line options will be parsed and will affect how the translation
1032 * unit is parsed. Note that the following options are ignored: '-c',
1033 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1034 *
1035 * \param num_unsaved_files the number of unsaved file entries in \p
1036 * unsaved_files.
1037 *
1038 * \param unsaved_files the files that have not yet been saved to disk
1039 * but may be required for code completion, including the contents of
1040 * those files.  The contents and name of these files (as specified by
1041 * CXUnsavedFile) are copied when necessary, so the client only needs to
1042 * guarantee their validity until the call to this function returns.
1043 */
1044CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1045                                         CXIndex CIdx,
1046                                         const char *source_filename,
1047                                         int num_clang_command_line_args,
1048                                   const char * const *clang_command_line_args,
1049                                         unsigned num_unsaved_files,
1050                                         struct CXUnsavedFile *unsaved_files);
1051
1052/**
1053 * \brief Create a translation unit from an AST file (-emit-ast).
1054 */
1055CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
1056                                             const char *ast_filename);
1057
1058/**
1059 * \brief Flags that control the creation of translation units.
1060 *
1061 * The enumerators in this enumeration type are meant to be bitwise
1062 * ORed together to specify which options should be used when
1063 * constructing the translation unit.
1064 */
1065enum CXTranslationUnit_Flags {
1066  /**
1067   * \brief Used to indicate that no special translation-unit options are
1068   * needed.
1069   */
1070  CXTranslationUnit_None = 0x0,
1071
1072  /**
1073   * \brief Used to indicate that the parser should construct a "detailed"
1074   * preprocessing record, including all macro definitions and instantiations.
1075   *
1076   * Constructing a detailed preprocessing record requires more memory
1077   * and time to parse, since the information contained in the record
1078   * is usually not retained. However, it can be useful for
1079   * applications that require more detailed information about the
1080   * behavior of the preprocessor.
1081   */
1082  CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1083
1084  /**
1085   * \brief Used to indicate that the translation unit is incomplete.
1086   *
1087   * When a translation unit is considered "incomplete", semantic
1088   * analysis that is typically performed at the end of the
1089   * translation unit will be suppressed. For example, this suppresses
1090   * the completion of tentative declarations in C and of
1091   * instantiation of implicitly-instantiation function templates in
1092   * C++. This option is typically used when parsing a header with the
1093   * intent of producing a precompiled header.
1094   */
1095  CXTranslationUnit_Incomplete = 0x02,
1096
1097  /**
1098   * \brief Used to indicate that the translation unit should be built with an
1099   * implicit precompiled header for the preamble.
1100   *
1101   * An implicit precompiled header is used as an optimization when a
1102   * particular translation unit is likely to be reparsed many times
1103   * when the sources aren't changing that often. In this case, an
1104   * implicit precompiled header will be built containing all of the
1105   * initial includes at the top of the main file (what we refer to as
1106   * the "preamble" of the file). In subsequent parses, if the
1107   * preamble or the files in it have not changed, \c
1108   * clang_reparseTranslationUnit() will re-use the implicit
1109   * precompiled header to improve parsing performance.
1110   */
1111  CXTranslationUnit_PrecompiledPreamble = 0x04,
1112
1113  /**
1114   * \brief Used to indicate that the translation unit should cache some
1115   * code-completion results with each reparse of the source file.
1116   *
1117   * Caching of code-completion results is a performance optimization that
1118   * introduces some overhead to reparsing but improves the performance of
1119   * code-completion operations.
1120   */
1121  CXTranslationUnit_CacheCompletionResults = 0x08,
1122
1123  /**
1124   * \brief Used to indicate that the translation unit will be serialized with
1125   * \c clang_saveTranslationUnit.
1126   *
1127   * This option is typically used when parsing a header with the intent of
1128   * producing a precompiled header.
1129   */
1130  CXTranslationUnit_ForSerialization = 0x10,
1131
1132  /**
1133   * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
1134   *
1135   * Note: this is a *temporary* option that is available only while
1136   * we are testing C++ precompiled preamble support. It is deprecated.
1137   */
1138  CXTranslationUnit_CXXChainedPCH = 0x20,
1139
1140  /**
1141   * \brief Used to indicate that function/method bodies should be skipped while
1142   * parsing.
1143   *
1144   * This option can be used to search for declarations/definitions while
1145   * ignoring the usages.
1146   */
1147  CXTranslationUnit_SkipFunctionBodies = 0x40,
1148
1149  /**
1150   * \brief Used to indicate that brief documentation comments should be
1151   * included into the set of code completions returned from this translation
1152   * unit.
1153   */
1154  CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
1155};
1156
1157/**
1158 * \brief Returns the set of flags that is suitable for parsing a translation
1159 * unit that is being edited.
1160 *
1161 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1162 * to indicate that the translation unit is likely to be reparsed many times,
1163 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1164 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1165 * set contains an unspecified set of optimizations (e.g., the precompiled
1166 * preamble) geared toward improving the performance of these routines. The
1167 * set of optimizations enabled may change from one version to the next.
1168 */
1169CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1170
1171/**
1172 * \brief Parse the given source file and the translation unit corresponding
1173 * to that file.
1174 *
1175 * This routine is the main entry point for the Clang C API, providing the
1176 * ability to parse a source file into a translation unit that can then be
1177 * queried by other functions in the API. This routine accepts a set of
1178 * command-line arguments so that the compilation can be configured in the same
1179 * way that the compiler is configured on the command line.
1180 *
1181 * \param CIdx The index object with which the translation unit will be
1182 * associated.
1183 *
1184 * \param source_filename The name of the source file to load, or NULL if the
1185 * source file is included in \p command_line_args.
1186 *
1187 * \param command_line_args The command-line arguments that would be
1188 * passed to the \c clang executable if it were being invoked out-of-process.
1189 * These command-line options will be parsed and will affect how the translation
1190 * unit is parsed. Note that the following options are ignored: '-c',
1191 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1192 *
1193 * \param num_command_line_args The number of command-line arguments in
1194 * \p command_line_args.
1195 *
1196 * \param unsaved_files the files that have not yet been saved to disk
1197 * but may be required for parsing, including the contents of
1198 * those files.  The contents and name of these files (as specified by
1199 * CXUnsavedFile) are copied when necessary, so the client only needs to
1200 * guarantee their validity until the call to this function returns.
1201 *
1202 * \param num_unsaved_files the number of unsaved file entries in \p
1203 * unsaved_files.
1204 *
1205 * \param options A bitmask of options that affects how the translation unit
1206 * is managed but not its compilation. This should be a bitwise OR of the
1207 * CXTranslationUnit_XXX flags.
1208 *
1209 * \returns A new translation unit describing the parsed code and containing
1210 * any diagnostics produced by the compiler. If there is a failure from which
1211 * the compiler cannot recover, returns NULL.
1212 */
1213CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
1214                                                    const char *source_filename,
1215                                         const char * const *command_line_args,
1216                                                      int num_command_line_args,
1217                                            struct CXUnsavedFile *unsaved_files,
1218                                                     unsigned num_unsaved_files,
1219                                                            unsigned options);
1220
1221/**
1222 * \brief Flags that control how translation units are saved.
1223 *
1224 * The enumerators in this enumeration type are meant to be bitwise
1225 * ORed together to specify which options should be used when
1226 * saving the translation unit.
1227 */
1228enum CXSaveTranslationUnit_Flags {
1229  /**
1230   * \brief Used to indicate that no special saving options are needed.
1231   */
1232  CXSaveTranslationUnit_None = 0x0
1233};
1234
1235/**
1236 * \brief Returns the set of flags that is suitable for saving a translation
1237 * unit.
1238 *
1239 * The set of flags returned provide options for
1240 * \c clang_saveTranslationUnit() by default. The returned flag
1241 * set contains an unspecified set of options that save translation units with
1242 * the most commonly-requested data.
1243 */
1244CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1245
1246/**
1247 * \brief Describes the kind of error that occurred (if any) in a call to
1248 * \c clang_saveTranslationUnit().
1249 */
1250enum CXSaveError {
1251  /**
1252   * \brief Indicates that no error occurred while saving a translation unit.
1253   */
1254  CXSaveError_None = 0,
1255
1256  /**
1257   * \brief Indicates that an unknown error occurred while attempting to save
1258   * the file.
1259   *
1260   * This error typically indicates that file I/O failed when attempting to
1261   * write the file.
1262   */
1263  CXSaveError_Unknown = 1,
1264
1265  /**
1266   * \brief Indicates that errors during translation prevented this attempt
1267   * to save the translation unit.
1268   *
1269   * Errors that prevent the translation unit from being saved can be
1270   * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1271   */
1272  CXSaveError_TranslationErrors = 2,
1273
1274  /**
1275   * \brief Indicates that the translation unit to be saved was somehow
1276   * invalid (e.g., NULL).
1277   */
1278  CXSaveError_InvalidTU = 3
1279};
1280
1281/**
1282 * \brief Saves a translation unit into a serialized representation of
1283 * that translation unit on disk.
1284 *
1285 * Any translation unit that was parsed without error can be saved
1286 * into a file. The translation unit can then be deserialized into a
1287 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1288 * if it is an incomplete translation unit that corresponds to a
1289 * header, used as a precompiled header when parsing other translation
1290 * units.
1291 *
1292 * \param TU The translation unit to save.
1293 *
1294 * \param FileName The file to which the translation unit will be saved.
1295 *
1296 * \param options A bitmask of options that affects how the translation unit
1297 * is saved. This should be a bitwise OR of the
1298 * CXSaveTranslationUnit_XXX flags.
1299 *
1300 * \returns A value that will match one of the enumerators of the CXSaveError
1301 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1302 * saved successfully, while a non-zero value indicates that a problem occurred.
1303 */
1304CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1305                                             const char *FileName,
1306                                             unsigned options);
1307
1308/**
1309 * \brief Destroy the specified CXTranslationUnit object.
1310 */
1311CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1312
1313/**
1314 * \brief Flags that control the reparsing of translation units.
1315 *
1316 * The enumerators in this enumeration type are meant to be bitwise
1317 * ORed together to specify which options should be used when
1318 * reparsing the translation unit.
1319 */
1320enum CXReparse_Flags {
1321  /**
1322   * \brief Used to indicate that no special reparsing options are needed.
1323   */
1324  CXReparse_None = 0x0
1325};
1326
1327/**
1328 * \brief Returns the set of flags that is suitable for reparsing a translation
1329 * unit.
1330 *
1331 * The set of flags returned provide options for
1332 * \c clang_reparseTranslationUnit() by default. The returned flag
1333 * set contains an unspecified set of optimizations geared toward common uses
1334 * of reparsing. The set of optimizations enabled may change from one version
1335 * to the next.
1336 */
1337CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1338
1339/**
1340 * \brief Reparse the source files that produced this translation unit.
1341 *
1342 * This routine can be used to re-parse the source files that originally
1343 * created the given translation unit, for example because those source files
1344 * have changed (either on disk or as passed via \p unsaved_files). The
1345 * source code will be reparsed with the same command-line options as it
1346 * was originally parsed.
1347 *
1348 * Reparsing a translation unit invalidates all cursors and source locations
1349 * that refer into that translation unit. This makes reparsing a translation
1350 * unit semantically equivalent to destroying the translation unit and then
1351 * creating a new translation unit with the same command-line arguments.
1352 * However, it may be more efficient to reparse a translation
1353 * unit using this routine.
1354 *
1355 * \param TU The translation unit whose contents will be re-parsed. The
1356 * translation unit must originally have been built with
1357 * \c clang_createTranslationUnitFromSourceFile().
1358 *
1359 * \param num_unsaved_files The number of unsaved file entries in \p
1360 * unsaved_files.
1361 *
1362 * \param unsaved_files The files that have not yet been saved to disk
1363 * but may be required for parsing, including the contents of
1364 * those files.  The contents and name of these files (as specified by
1365 * CXUnsavedFile) are copied when necessary, so the client only needs to
1366 * guarantee their validity until the call to this function returns.
1367 *
1368 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1369 * The function \c clang_defaultReparseOptions() produces a default set of
1370 * options recommended for most uses, based on the translation unit.
1371 *
1372 * \returns 0 if the sources could be reparsed. A non-zero value will be
1373 * returned if reparsing was impossible, such that the translation unit is
1374 * invalid. In such cases, the only valid call for \p TU is
1375 * \c clang_disposeTranslationUnit(TU).
1376 */
1377CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1378                                                unsigned num_unsaved_files,
1379                                          struct CXUnsavedFile *unsaved_files,
1380                                                unsigned options);
1381
1382/**
1383  * \brief Categorizes how memory is being used by a translation unit.
1384  */
1385enum CXTUResourceUsageKind {
1386  CXTUResourceUsage_AST = 1,
1387  CXTUResourceUsage_Identifiers = 2,
1388  CXTUResourceUsage_Selectors = 3,
1389  CXTUResourceUsage_GlobalCompletionResults = 4,
1390  CXTUResourceUsage_SourceManagerContentCache = 5,
1391  CXTUResourceUsage_AST_SideTables = 6,
1392  CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1393  CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1394  CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1395  CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1396  CXTUResourceUsage_Preprocessor = 11,
1397  CXTUResourceUsage_PreprocessingRecord = 12,
1398  CXTUResourceUsage_SourceManager_DataStructures = 13,
1399  CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1400  CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1401  CXTUResourceUsage_MEMORY_IN_BYTES_END =
1402    CXTUResourceUsage_Preprocessor_HeaderSearch,
1403
1404  CXTUResourceUsage_First = CXTUResourceUsage_AST,
1405  CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1406};
1407
1408/**
1409  * \brief Returns the human-readable null-terminated C string that represents
1410  *  the name of the memory category.  This string should never be freed.
1411  */
1412CINDEX_LINKAGE
1413const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1414
1415typedef struct CXTUResourceUsageEntry {
1416  /* \brief The memory usage category. */
1417  enum CXTUResourceUsageKind kind;
1418  /* \brief Amount of resources used.
1419      The units will depend on the resource kind. */
1420  unsigned long amount;
1421} CXTUResourceUsageEntry;
1422
1423/**
1424  * \brief The memory usage of a CXTranslationUnit, broken into categories.
1425  */
1426typedef struct CXTUResourceUsage {
1427  /* \brief Private data member, used for queries. */
1428  void *data;
1429
1430  /* \brief The number of entries in the 'entries' array. */
1431  unsigned numEntries;
1432
1433  /* \brief An array of key-value pairs, representing the breakdown of memory
1434            usage. */
1435  CXTUResourceUsageEntry *entries;
1436
1437} CXTUResourceUsage;
1438
1439/**
1440  * \brief Return the memory usage of a translation unit.  This object
1441  *  should be released with clang_disposeCXTUResourceUsage().
1442  */
1443CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1444
1445CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1446
1447/**
1448 * @}
1449 */
1450
1451/**
1452 * \brief Describes the kind of entity that a cursor refers to.
1453 */
1454enum CXCursorKind {
1455  /* Declarations */
1456  /**
1457   * \brief A declaration whose specific kind is not exposed via this
1458   * interface.
1459   *
1460   * Unexposed declarations have the same operations as any other kind
1461   * of declaration; one can extract their location information,
1462   * spelling, find their definitions, etc. However, the specific kind
1463   * of the declaration is not reported.
1464   */
1465  CXCursor_UnexposedDecl                 = 1,
1466  /** \brief A C or C++ struct. */
1467  CXCursor_StructDecl                    = 2,
1468  /** \brief A C or C++ union. */
1469  CXCursor_UnionDecl                     = 3,
1470  /** \brief A C++ class. */
1471  CXCursor_ClassDecl                     = 4,
1472  /** \brief An enumeration. */
1473  CXCursor_EnumDecl                      = 5,
1474  /**
1475   * \brief A field (in C) or non-static data member (in C++) in a
1476   * struct, union, or C++ class.
1477   */
1478  CXCursor_FieldDecl                     = 6,
1479  /** \brief An enumerator constant. */
1480  CXCursor_EnumConstantDecl              = 7,
1481  /** \brief A function. */
1482  CXCursor_FunctionDecl                  = 8,
1483  /** \brief A variable. */
1484  CXCursor_VarDecl                       = 9,
1485  /** \brief A function or method parameter. */
1486  CXCursor_ParmDecl                      = 10,
1487  /** \brief An Objective-C \@interface. */
1488  CXCursor_ObjCInterfaceDecl             = 11,
1489  /** \brief An Objective-C \@interface for a category. */
1490  CXCursor_ObjCCategoryDecl              = 12,
1491  /** \brief An Objective-C \@protocol declaration. */
1492  CXCursor_ObjCProtocolDecl              = 13,
1493  /** \brief An Objective-C \@property declaration. */
1494  CXCursor_ObjCPropertyDecl              = 14,
1495  /** \brief An Objective-C instance variable. */
1496  CXCursor_ObjCIvarDecl                  = 15,
1497  /** \brief An Objective-C instance method. */
1498  CXCursor_ObjCInstanceMethodDecl        = 16,
1499  /** \brief An Objective-C class method. */
1500  CXCursor_ObjCClassMethodDecl           = 17,
1501  /** \brief An Objective-C \@implementation. */
1502  CXCursor_ObjCImplementationDecl        = 18,
1503  /** \brief An Objective-C \@implementation for a category. */
1504  CXCursor_ObjCCategoryImplDecl          = 19,
1505  /** \brief A typedef */
1506  CXCursor_TypedefDecl                   = 20,
1507  /** \brief A C++ class method. */
1508  CXCursor_CXXMethod                     = 21,
1509  /** \brief A C++ namespace. */
1510  CXCursor_Namespace                     = 22,
1511  /** \brief A linkage specification, e.g. 'extern "C"'. */
1512  CXCursor_LinkageSpec                   = 23,
1513  /** \brief A C++ constructor. */
1514  CXCursor_Constructor                   = 24,
1515  /** \brief A C++ destructor. */
1516  CXCursor_Destructor                    = 25,
1517  /** \brief A C++ conversion function. */
1518  CXCursor_ConversionFunction            = 26,
1519  /** \brief A C++ template type parameter. */
1520  CXCursor_TemplateTypeParameter         = 27,
1521  /** \brief A C++ non-type template parameter. */
1522  CXCursor_NonTypeTemplateParameter      = 28,
1523  /** \brief A C++ template template parameter. */
1524  CXCursor_TemplateTemplateParameter     = 29,
1525  /** \brief A C++ function template. */
1526  CXCursor_FunctionTemplate              = 30,
1527  /** \brief A C++ class template. */
1528  CXCursor_ClassTemplate                 = 31,
1529  /** \brief A C++ class template partial specialization. */
1530  CXCursor_ClassTemplatePartialSpecialization = 32,
1531  /** \brief A C++ namespace alias declaration. */
1532  CXCursor_NamespaceAlias                = 33,
1533  /** \brief A C++ using directive. */
1534  CXCursor_UsingDirective                = 34,
1535  /** \brief A C++ using declaration. */
1536  CXCursor_UsingDeclaration              = 35,
1537  /** \brief A C++ alias declaration */
1538  CXCursor_TypeAliasDecl                 = 36,
1539  /** \brief An Objective-C \@synthesize definition. */
1540  CXCursor_ObjCSynthesizeDecl            = 37,
1541  /** \brief An Objective-C \@dynamic definition. */
1542  CXCursor_ObjCDynamicDecl               = 38,
1543  /** \brief An access specifier. */
1544  CXCursor_CXXAccessSpecifier            = 39,
1545
1546  CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
1547  CXCursor_LastDecl                      = CXCursor_CXXAccessSpecifier,
1548
1549  /* References */
1550  CXCursor_FirstRef                      = 40, /* Decl references */
1551  CXCursor_ObjCSuperClassRef             = 40,
1552  CXCursor_ObjCProtocolRef               = 41,
1553  CXCursor_ObjCClassRef                  = 42,
1554  /**
1555   * \brief A reference to a type declaration.
1556   *
1557   * A type reference occurs anywhere where a type is named but not
1558   * declared. For example, given:
1559   *
1560   * \code
1561   * typedef unsigned size_type;
1562   * size_type size;
1563   * \endcode
1564   *
1565   * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1566   * while the type of the variable "size" is referenced. The cursor
1567   * referenced by the type of size is the typedef for size_type.
1568   */
1569  CXCursor_TypeRef                       = 43,
1570  CXCursor_CXXBaseSpecifier              = 44,
1571  /**
1572   * \brief A reference to a class template, function template, template
1573   * template parameter, or class template partial specialization.
1574   */
1575  CXCursor_TemplateRef                   = 45,
1576  /**
1577   * \brief A reference to a namespace or namespace alias.
1578   */
1579  CXCursor_NamespaceRef                  = 46,
1580  /**
1581   * \brief A reference to a member of a struct, union, or class that occurs in
1582   * some non-expression context, e.g., a designated initializer.
1583   */
1584  CXCursor_MemberRef                     = 47,
1585  /**
1586   * \brief A reference to a labeled statement.
1587   *
1588   * This cursor kind is used to describe the jump to "start_over" in the
1589   * goto statement in the following example:
1590   *
1591   * \code
1592   *   start_over:
1593   *     ++counter;
1594   *
1595   *     goto start_over;
1596   * \endcode
1597   *
1598   * A label reference cursor refers to a label statement.
1599   */
1600  CXCursor_LabelRef                      = 48,
1601
1602  /**
1603   * \brief A reference to a set of overloaded functions or function templates
1604   * that has not yet been resolved to a specific function or function template.
1605   *
1606   * An overloaded declaration reference cursor occurs in C++ templates where
1607   * a dependent name refers to a function. For example:
1608   *
1609   * \code
1610   * template<typename T> void swap(T&, T&);
1611   *
1612   * struct X { ... };
1613   * void swap(X&, X&);
1614   *
1615   * template<typename T>
1616   * void reverse(T* first, T* last) {
1617   *   while (first < last - 1) {
1618   *     swap(*first, *--last);
1619   *     ++first;
1620   *   }
1621   * }
1622   *
1623   * struct Y { };
1624   * void swap(Y&, Y&);
1625   * \endcode
1626   *
1627   * Here, the identifier "swap" is associated with an overloaded declaration
1628   * reference. In the template definition, "swap" refers to either of the two
1629   * "swap" functions declared above, so both results will be available. At
1630   * instantiation time, "swap" may also refer to other functions found via
1631   * argument-dependent lookup (e.g., the "swap" function at the end of the
1632   * example).
1633   *
1634   * The functions \c clang_getNumOverloadedDecls() and
1635   * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1636   * referenced by this cursor.
1637   */
1638  CXCursor_OverloadedDeclRef             = 49,
1639
1640  /**
1641   * \brief A reference to a variable that occurs in some non-expression
1642   * context, e.g., a C++ lambda capture list.
1643   */
1644  CXCursor_VariableRef                   = 50,
1645
1646  CXCursor_LastRef                       = CXCursor_VariableRef,
1647
1648  /* Error conditions */
1649  CXCursor_FirstInvalid                  = 70,
1650  CXCursor_InvalidFile                   = 70,
1651  CXCursor_NoDeclFound                   = 71,
1652  CXCursor_NotImplemented                = 72,
1653  CXCursor_InvalidCode                   = 73,
1654  CXCursor_LastInvalid                   = CXCursor_InvalidCode,
1655
1656  /* Expressions */
1657  CXCursor_FirstExpr                     = 100,
1658
1659  /**
1660   * \brief An expression whose specific kind is not exposed via this
1661   * interface.
1662   *
1663   * Unexposed expressions have the same operations as any other kind
1664   * of expression; one can extract their location information,
1665   * spelling, children, etc. However, the specific kind of the
1666   * expression is not reported.
1667   */
1668  CXCursor_UnexposedExpr                 = 100,
1669
1670  /**
1671   * \brief An expression that refers to some value declaration, such
1672   * as a function, varible, or enumerator.
1673   */
1674  CXCursor_DeclRefExpr                   = 101,
1675
1676  /**
1677   * \brief An expression that refers to a member of a struct, union,
1678   * class, Objective-C class, etc.
1679   */
1680  CXCursor_MemberRefExpr                 = 102,
1681
1682  /** \brief An expression that calls a function. */
1683  CXCursor_CallExpr                      = 103,
1684
1685  /** \brief An expression that sends a message to an Objective-C
1686   object or class. */
1687  CXCursor_ObjCMessageExpr               = 104,
1688
1689  /** \brief An expression that represents a block literal. */
1690  CXCursor_BlockExpr                     = 105,
1691
1692  /** \brief An integer literal.
1693   */
1694  CXCursor_IntegerLiteral                = 106,
1695
1696  /** \brief A floating point number literal.
1697   */
1698  CXCursor_FloatingLiteral               = 107,
1699
1700  /** \brief An imaginary number literal.
1701   */
1702  CXCursor_ImaginaryLiteral              = 108,
1703
1704  /** \brief A string literal.
1705   */
1706  CXCursor_StringLiteral                 = 109,
1707
1708  /** \brief A character literal.
1709   */
1710  CXCursor_CharacterLiteral              = 110,
1711
1712  /** \brief A parenthesized expression, e.g. "(1)".
1713   *
1714   * This AST node is only formed if full location information is requested.
1715   */
1716  CXCursor_ParenExpr                     = 111,
1717
1718  /** \brief This represents the unary-expression's (except sizeof and
1719   * alignof).
1720   */
1721  CXCursor_UnaryOperator                 = 112,
1722
1723  /** \brief [C99 6.5.2.1] Array Subscripting.
1724   */
1725  CXCursor_ArraySubscriptExpr            = 113,
1726
1727  /** \brief A builtin binary operation expression such as "x + y" or
1728   * "x <= y".
1729   */
1730  CXCursor_BinaryOperator                = 114,
1731
1732  /** \brief Compound assignment such as "+=".
1733   */
1734  CXCursor_CompoundAssignOperator        = 115,
1735
1736  /** \brief The ?: ternary operator.
1737   */
1738  CXCursor_ConditionalOperator           = 116,
1739
1740  /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1741   * (C++ [expr.cast]), which uses the syntax (Type)expr.
1742   *
1743   * For example: (int)f.
1744   */
1745  CXCursor_CStyleCastExpr                = 117,
1746
1747  /** \brief [C99 6.5.2.5]
1748   */
1749  CXCursor_CompoundLiteralExpr           = 118,
1750
1751  /** \brief Describes an C or C++ initializer list.
1752   */
1753  CXCursor_InitListExpr                  = 119,
1754
1755  /** \brief The GNU address of label extension, representing &&label.
1756   */
1757  CXCursor_AddrLabelExpr                 = 120,
1758
1759  /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1760   */
1761  CXCursor_StmtExpr                      = 121,
1762
1763  /** \brief Represents a C11 generic selection.
1764   */
1765  CXCursor_GenericSelectionExpr          = 122,
1766
1767  /** \brief Implements the GNU __null extension, which is a name for a null
1768   * pointer constant that has integral type (e.g., int or long) and is the same
1769   * size and alignment as a pointer.
1770   *
1771   * The __null extension is typically only used by system headers, which define
1772   * NULL as __null in C++ rather than using 0 (which is an integer that may not
1773   * match the size of a pointer).
1774   */
1775  CXCursor_GNUNullExpr                   = 123,
1776
1777  /** \brief C++'s static_cast<> expression.
1778   */
1779  CXCursor_CXXStaticCastExpr             = 124,
1780
1781  /** \brief C++'s dynamic_cast<> expression.
1782   */
1783  CXCursor_CXXDynamicCastExpr            = 125,
1784
1785  /** \brief C++'s reinterpret_cast<> expression.
1786   */
1787  CXCursor_CXXReinterpretCastExpr        = 126,
1788
1789  /** \brief C++'s const_cast<> expression.
1790   */
1791  CXCursor_CXXConstCastExpr              = 127,
1792
1793  /** \brief Represents an explicit C++ type conversion that uses "functional"
1794   * notion (C++ [expr.type.conv]).
1795   *
1796   * Example:
1797   * \code
1798   *   x = int(0.5);
1799   * \endcode
1800   */
1801  CXCursor_CXXFunctionalCastExpr         = 128,
1802
1803  /** \brief A C++ typeid expression (C++ [expr.typeid]).
1804   */
1805  CXCursor_CXXTypeidExpr                 = 129,
1806
1807  /** \brief [C++ 2.13.5] C++ Boolean Literal.
1808   */
1809  CXCursor_CXXBoolLiteralExpr            = 130,
1810
1811  /** \brief [C++0x 2.14.7] C++ Pointer Literal.
1812   */
1813  CXCursor_CXXNullPtrLiteralExpr         = 131,
1814
1815  /** \brief Represents the "this" expression in C++
1816   */
1817  CXCursor_CXXThisExpr                   = 132,
1818
1819  /** \brief [C++ 15] C++ Throw Expression.
1820   *
1821   * This handles 'throw' and 'throw' assignment-expression. When
1822   * assignment-expression isn't present, Op will be null.
1823   */
1824  CXCursor_CXXThrowExpr                  = 133,
1825
1826  /** \brief A new expression for memory allocation and constructor calls, e.g:
1827   * "new CXXNewExpr(foo)".
1828   */
1829  CXCursor_CXXNewExpr                    = 134,
1830
1831  /** \brief A delete expression for memory deallocation and destructor calls,
1832   * e.g. "delete[] pArray".
1833   */
1834  CXCursor_CXXDeleteExpr                 = 135,
1835
1836  /** \brief A unary expression.
1837   */
1838  CXCursor_UnaryExpr                     = 136,
1839
1840  /** \brief An Objective-C string literal i.e. @"foo".
1841   */
1842  CXCursor_ObjCStringLiteral             = 137,
1843
1844  /** \brief An Objective-C \@encode expression.
1845   */
1846  CXCursor_ObjCEncodeExpr                = 138,
1847
1848  /** \brief An Objective-C \@selector expression.
1849   */
1850  CXCursor_ObjCSelectorExpr              = 139,
1851
1852  /** \brief An Objective-C \@protocol expression.
1853   */
1854  CXCursor_ObjCProtocolExpr              = 140,
1855
1856  /** \brief An Objective-C "bridged" cast expression, which casts between
1857   * Objective-C pointers and C pointers, transferring ownership in the process.
1858   *
1859   * \code
1860   *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
1861   * \endcode
1862   */
1863  CXCursor_ObjCBridgedCastExpr           = 141,
1864
1865  /** \brief Represents a C++0x pack expansion that produces a sequence of
1866   * expressions.
1867   *
1868   * A pack expansion expression contains a pattern (which itself is an
1869   * expression) followed by an ellipsis. For example:
1870   *
1871   * \code
1872   * template<typename F, typename ...Types>
1873   * void forward(F f, Types &&...args) {
1874   *  f(static_cast<Types&&>(args)...);
1875   * }
1876   * \endcode
1877   */
1878  CXCursor_PackExpansionExpr             = 142,
1879
1880  /** \brief Represents an expression that computes the length of a parameter
1881   * pack.
1882   *
1883   * \code
1884   * template<typename ...Types>
1885   * struct count {
1886   *   static const unsigned value = sizeof...(Types);
1887   * };
1888   * \endcode
1889   */
1890  CXCursor_SizeOfPackExpr                = 143,
1891
1892  /* \brief Represents a C++ lambda expression that produces a local function
1893   * object.
1894   *
1895   * \code
1896   * void abssort(float *x, unsigned N) {
1897   *   std::sort(x, x + N,
1898   *             [](float a, float b) {
1899   *               return std::abs(a) < std::abs(b);
1900   *             });
1901   * }
1902   * \endcode
1903   */
1904  CXCursor_LambdaExpr                    = 144,
1905
1906  /** \brief Objective-c Boolean Literal.
1907   */
1908  CXCursor_ObjCBoolLiteralExpr           = 145,
1909
1910  /** \brief Represents the "self" expression in a ObjC method.
1911   */
1912  CXCursor_ObjCSelfExpr                  = 146,
1913
1914  CXCursor_LastExpr                      = CXCursor_ObjCSelfExpr,
1915
1916  /* Statements */
1917  CXCursor_FirstStmt                     = 200,
1918  /**
1919   * \brief A statement whose specific kind is not exposed via this
1920   * interface.
1921   *
1922   * Unexposed statements have the same operations as any other kind of
1923   * statement; one can extract their location information, spelling,
1924   * children, etc. However, the specific kind of the statement is not
1925   * reported.
1926   */
1927  CXCursor_UnexposedStmt                 = 200,
1928
1929  /** \brief A labelled statement in a function.
1930   *
1931   * This cursor kind is used to describe the "start_over:" label statement in
1932   * the following example:
1933   *
1934   * \code
1935   *   start_over:
1936   *     ++counter;
1937   * \endcode
1938   *
1939   */
1940  CXCursor_LabelStmt                     = 201,
1941
1942  /** \brief A group of statements like { stmt stmt }.
1943   *
1944   * This cursor kind is used to describe compound statements, e.g. function
1945   * bodies.
1946   */
1947  CXCursor_CompoundStmt                  = 202,
1948
1949  /** \brief A case statment.
1950   */
1951  CXCursor_CaseStmt                      = 203,
1952
1953  /** \brief A default statement.
1954   */
1955  CXCursor_DefaultStmt                   = 204,
1956
1957  /** \brief An if statement
1958   */
1959  CXCursor_IfStmt                        = 205,
1960
1961  /** \brief A switch statement.
1962   */
1963  CXCursor_SwitchStmt                    = 206,
1964
1965  /** \brief A while statement.
1966   */
1967  CXCursor_WhileStmt                     = 207,
1968
1969  /** \brief A do statement.
1970   */
1971  CXCursor_DoStmt                        = 208,
1972
1973  /** \brief A for statement.
1974   */
1975  CXCursor_ForStmt                       = 209,
1976
1977  /** \brief A goto statement.
1978   */
1979  CXCursor_GotoStmt                      = 210,
1980
1981  /** \brief An indirect goto statement.
1982   */
1983  CXCursor_IndirectGotoStmt              = 211,
1984
1985  /** \brief A continue statement.
1986   */
1987  CXCursor_ContinueStmt                  = 212,
1988
1989  /** \brief A break statement.
1990   */
1991  CXCursor_BreakStmt                     = 213,
1992
1993  /** \brief A return statement.
1994   */
1995  CXCursor_ReturnStmt                    = 214,
1996
1997  /** \brief A GCC inline assembly statement extension.
1998   */
1999  CXCursor_GCCAsmStmt                    = 215,
2000  CXCursor_AsmStmt                       = CXCursor_GCCAsmStmt,
2001
2002  /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
2003   */
2004  CXCursor_ObjCAtTryStmt                 = 216,
2005
2006  /** \brief Objective-C's \@catch statement.
2007   */
2008  CXCursor_ObjCAtCatchStmt               = 217,
2009
2010  /** \brief Objective-C's \@finally statement.
2011   */
2012  CXCursor_ObjCAtFinallyStmt             = 218,
2013
2014  /** \brief Objective-C's \@throw statement.
2015   */
2016  CXCursor_ObjCAtThrowStmt               = 219,
2017
2018  /** \brief Objective-C's \@synchronized statement.
2019   */
2020  CXCursor_ObjCAtSynchronizedStmt        = 220,
2021
2022  /** \brief Objective-C's autorelease pool statement.
2023   */
2024  CXCursor_ObjCAutoreleasePoolStmt       = 221,
2025
2026  /** \brief Objective-C's collection statement.
2027   */
2028  CXCursor_ObjCForCollectionStmt         = 222,
2029
2030  /** \brief C++'s catch statement.
2031   */
2032  CXCursor_CXXCatchStmt                  = 223,
2033
2034  /** \brief C++'s try statement.
2035   */
2036  CXCursor_CXXTryStmt                    = 224,
2037
2038  /** \brief C++'s for (* : *) statement.
2039   */
2040  CXCursor_CXXForRangeStmt               = 225,
2041
2042  /** \brief Windows Structured Exception Handling's try statement.
2043   */
2044  CXCursor_SEHTryStmt                    = 226,
2045
2046  /** \brief Windows Structured Exception Handling's except statement.
2047   */
2048  CXCursor_SEHExceptStmt                 = 227,
2049
2050  /** \brief Windows Structured Exception Handling's finally statement.
2051   */
2052  CXCursor_SEHFinallyStmt                = 228,
2053
2054  /** \brief A MS inline assembly statement extension.
2055   */
2056  CXCursor_MSAsmStmt                     = 229,
2057
2058  /** \brief The null satement ";": C99 6.8.3p3.
2059   *
2060   * This cursor kind is used to describe the null statement.
2061   */
2062  CXCursor_NullStmt                      = 230,
2063
2064  /** \brief Adaptor class for mixing declarations with statements and
2065   * expressions.
2066   */
2067  CXCursor_DeclStmt                      = 231,
2068
2069  /** \brief OpenMP parallel directive.
2070   */
2071  CXCursor_OMPParallelDirective          = 232,
2072
2073  CXCursor_LastStmt                      = CXCursor_OMPParallelDirective,
2074
2075  /**
2076   * \brief Cursor that represents the translation unit itself.
2077   *
2078   * The translation unit cursor exists primarily to act as the root
2079   * cursor for traversing the contents of a translation unit.
2080   */
2081  CXCursor_TranslationUnit               = 300,
2082
2083  /* Attributes */
2084  CXCursor_FirstAttr                     = 400,
2085  /**
2086   * \brief An attribute whose specific kind is not exposed via this
2087   * interface.
2088   */
2089  CXCursor_UnexposedAttr                 = 400,
2090
2091  CXCursor_IBActionAttr                  = 401,
2092  CXCursor_IBOutletAttr                  = 402,
2093  CXCursor_IBOutletCollectionAttr        = 403,
2094  CXCursor_CXXFinalAttr                  = 404,
2095  CXCursor_CXXOverrideAttr               = 405,
2096  CXCursor_AnnotateAttr                  = 406,
2097  CXCursor_AsmLabelAttr                  = 407,
2098  CXCursor_PackedAttr                    = 408,
2099  CXCursor_LastAttr                      = CXCursor_PackedAttr,
2100
2101  /* Preprocessing */
2102  CXCursor_PreprocessingDirective        = 500,
2103  CXCursor_MacroDefinition               = 501,
2104  CXCursor_MacroExpansion                = 502,
2105  CXCursor_MacroInstantiation            = CXCursor_MacroExpansion,
2106  CXCursor_InclusionDirective            = 503,
2107  CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
2108  CXCursor_LastPreprocessing             = CXCursor_InclusionDirective,
2109
2110  /* Extra Declarations */
2111  /**
2112   * \brief A module import declaration.
2113   */
2114  CXCursor_ModuleImportDecl              = 600,
2115  CXCursor_FirstExtraDecl                = CXCursor_ModuleImportDecl,
2116  CXCursor_LastExtraDecl                 = CXCursor_ModuleImportDecl
2117};
2118
2119/**
2120 * \brief A cursor representing some element in the abstract syntax tree for
2121 * a translation unit.
2122 *
2123 * The cursor abstraction unifies the different kinds of entities in a
2124 * program--declaration, statements, expressions, references to declarations,
2125 * etc.--under a single "cursor" abstraction with a common set of operations.
2126 * Common operation for a cursor include: getting the physical location in
2127 * a source file where the cursor points, getting the name associated with a
2128 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2129 *
2130 * Cursors can be produced in two specific ways.
2131 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2132 * from which one can use clang_visitChildren() to explore the rest of the
2133 * translation unit. clang_getCursor() maps from a physical source location
2134 * to the entity that resides at that location, allowing one to map from the
2135 * source code into the AST.
2136 */
2137typedef struct {
2138  enum CXCursorKind kind;
2139  int xdata;
2140  const void *data[3];
2141} CXCursor;
2142
2143/**
2144 * \brief A comment AST node.
2145 */
2146typedef struct {
2147  const void *ASTNode;
2148  CXTranslationUnit TranslationUnit;
2149} CXComment;
2150
2151/**
2152 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2153 *
2154 * @{
2155 */
2156
2157/**
2158 * \brief Retrieve the NULL cursor, which represents no entity.
2159 */
2160CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2161
2162/**
2163 * \brief Retrieve the cursor that represents the given translation unit.
2164 *
2165 * The translation unit cursor can be used to start traversing the
2166 * various declarations within the given translation unit.
2167 */
2168CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2169
2170/**
2171 * \brief Determine whether two cursors are equivalent.
2172 */
2173CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2174
2175/**
2176 * \brief Returns non-zero if \p cursor is null.
2177 */
2178CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2179
2180/**
2181 * \brief Compute a hash value for the given cursor.
2182 */
2183CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2184
2185/**
2186 * \brief Retrieve the kind of the given cursor.
2187 */
2188CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2189
2190/**
2191 * \brief Determine whether the given cursor kind represents a declaration.
2192 */
2193CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2194
2195/**
2196 * \brief Determine whether the given cursor kind represents a simple
2197 * reference.
2198 *
2199 * Note that other kinds of cursors (such as expressions) can also refer to
2200 * other cursors. Use clang_getCursorReferenced() to determine whether a
2201 * particular cursor refers to another entity.
2202 */
2203CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2204
2205/**
2206 * \brief Determine whether the given cursor kind represents an expression.
2207 */
2208CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2209
2210/**
2211 * \brief Determine whether the given cursor kind represents a statement.
2212 */
2213CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2214
2215/**
2216 * \brief Determine whether the given cursor kind represents an attribute.
2217 */
2218CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2219
2220/**
2221 * \brief Determine whether the given cursor kind represents an invalid
2222 * cursor.
2223 */
2224CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2225
2226/**
2227 * \brief Determine whether the given cursor kind represents a translation
2228 * unit.
2229 */
2230CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2231
2232/***
2233 * \brief Determine whether the given cursor represents a preprocessing
2234 * element, such as a preprocessor directive or macro instantiation.
2235 */
2236CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2237
2238/***
2239 * \brief Determine whether the given cursor represents a currently
2240 *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2241 */
2242CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2243
2244/**
2245 * \brief Describe the linkage of the entity referred to by a cursor.
2246 */
2247enum CXLinkageKind {
2248  /** \brief This value indicates that no linkage information is available
2249   * for a provided CXCursor. */
2250  CXLinkage_Invalid,
2251  /**
2252   * \brief This is the linkage for variables, parameters, and so on that
2253   *  have automatic storage.  This covers normal (non-extern) local variables.
2254   */
2255  CXLinkage_NoLinkage,
2256  /** \brief This is the linkage for static variables and static functions. */
2257  CXLinkage_Internal,
2258  /** \brief This is the linkage for entities with external linkage that live
2259   * in C++ anonymous namespaces.*/
2260  CXLinkage_UniqueExternal,
2261  /** \brief This is the linkage for entities with true, external linkage. */
2262  CXLinkage_External
2263};
2264
2265/**
2266 * \brief Determine the linkage of the entity referred to by a given cursor.
2267 */
2268CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2269
2270/**
2271 * \brief Determine the availability of the entity that this cursor refers to,
2272 * taking the current target platform into account.
2273 *
2274 * \param cursor The cursor to query.
2275 *
2276 * \returns The availability of the cursor.
2277 */
2278CINDEX_LINKAGE enum CXAvailabilityKind
2279clang_getCursorAvailability(CXCursor cursor);
2280
2281/**
2282 * Describes the availability of a given entity on a particular platform, e.g.,
2283 * a particular class might only be available on Mac OS 10.7 or newer.
2284 */
2285typedef struct CXPlatformAvailability {
2286  /**
2287   * \brief A string that describes the platform for which this structure
2288   * provides availability information.
2289   *
2290   * Possible values are "ios" or "macosx".
2291   */
2292  CXString Platform;
2293  /**
2294   * \brief The version number in which this entity was introduced.
2295   */
2296  CXVersion Introduced;
2297  /**
2298   * \brief The version number in which this entity was deprecated (but is
2299   * still available).
2300   */
2301  CXVersion Deprecated;
2302  /**
2303   * \brief The version number in which this entity was obsoleted, and therefore
2304   * is no longer available.
2305   */
2306  CXVersion Obsoleted;
2307  /**
2308   * \brief Whether the entity is unconditionally unavailable on this platform.
2309   */
2310  int Unavailable;
2311  /**
2312   * \brief An optional message to provide to a user of this API, e.g., to
2313   * suggest replacement APIs.
2314   */
2315  CXString Message;
2316} CXPlatformAvailability;
2317
2318/**
2319 * \brief Determine the availability of the entity that this cursor refers to
2320 * on any platforms for which availability information is known.
2321 *
2322 * \param cursor The cursor to query.
2323 *
2324 * \param always_deprecated If non-NULL, will be set to indicate whether the
2325 * entity is deprecated on all platforms.
2326 *
2327 * \param deprecated_message If non-NULL, will be set to the message text
2328 * provided along with the unconditional deprecation of this entity. The client
2329 * is responsible for deallocating this string.
2330 *
2331 * \param always_unavailable If non-NULL, will be set to indicate whether the
2332 * entity is unavailable on all platforms.
2333 *
2334 * \param unavailable_message If non-NULL, will be set to the message text
2335 * provided along with the unconditional unavailability of this entity. The
2336 * client is responsible for deallocating this string.
2337 *
2338 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2339 * that will be populated with platform availability information, up to either
2340 * the number of platforms for which availability information is available (as
2341 * returned by this function) or \c availability_size, whichever is smaller.
2342 *
2343 * \param availability_size The number of elements available in the
2344 * \c availability array.
2345 *
2346 * \returns The number of platforms (N) for which availability information is
2347 * available (which is unrelated to \c availability_size).
2348 *
2349 * Note that the client is responsible for calling
2350 * \c clang_disposeCXPlatformAvailability to free each of the
2351 * platform-availability structures returned. There are
2352 * \c min(N, availability_size) such structures.
2353 */
2354CINDEX_LINKAGE int
2355clang_getCursorPlatformAvailability(CXCursor cursor,
2356                                    int *always_deprecated,
2357                                    CXString *deprecated_message,
2358                                    int *always_unavailable,
2359                                    CXString *unavailable_message,
2360                                    CXPlatformAvailability *availability,
2361                                    int availability_size);
2362
2363/**
2364 * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2365 */
2366CINDEX_LINKAGE void
2367clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2368
2369/**
2370 * \brief Describe the "language" of the entity referred to by a cursor.
2371 */
2372CINDEX_LINKAGE enum CXLanguageKind {
2373  CXLanguage_Invalid = 0,
2374  CXLanguage_C,
2375  CXLanguage_ObjC,
2376  CXLanguage_CPlusPlus
2377};
2378
2379/**
2380 * \brief Determine the "language" of the entity referred to by a given cursor.
2381 */
2382CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2383
2384/**
2385 * \brief Returns the translation unit that a cursor originated from.
2386 */
2387CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2388
2389
2390/**
2391 * \brief A fast container representing a set of CXCursors.
2392 */
2393typedef struct CXCursorSetImpl *CXCursorSet;
2394
2395/**
2396 * \brief Creates an empty CXCursorSet.
2397 */
2398CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2399
2400/**
2401 * \brief Disposes a CXCursorSet and releases its associated memory.
2402 */
2403CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2404
2405/**
2406 * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2407 *
2408 * \returns non-zero if the set contains the specified cursor.
2409*/
2410CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2411                                                   CXCursor cursor);
2412
2413/**
2414 * \brief Inserts a CXCursor into a CXCursorSet.
2415 *
2416 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2417*/
2418CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2419                                                 CXCursor cursor);
2420
2421/**
2422 * \brief Determine the semantic parent of the given cursor.
2423 *
2424 * The semantic parent of a cursor is the cursor that semantically contains
2425 * the given \p cursor. For many declarations, the lexical and semantic parents
2426 * are equivalent (the lexical parent is returned by
2427 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2428 * definitions are provided out-of-line. For example:
2429 *
2430 * \code
2431 * class C {
2432 *  void f();
2433 * };
2434 *
2435 * void C::f() { }
2436 * \endcode
2437 *
2438 * In the out-of-line definition of \c C::f, the semantic parent is the
2439 * the class \c C, of which this function is a member. The lexical parent is
2440 * the place where the declaration actually occurs in the source code; in this
2441 * case, the definition occurs in the translation unit. In general, the
2442 * lexical parent for a given entity can change without affecting the semantics
2443 * of the program, and the lexical parent of different declarations of the
2444 * same entity may be different. Changing the semantic parent of a declaration,
2445 * on the other hand, can have a major impact on semantics, and redeclarations
2446 * of a particular entity should all have the same semantic context.
2447 *
2448 * In the example above, both declarations of \c C::f have \c C as their
2449 * semantic context, while the lexical context of the first \c C::f is \c C
2450 * and the lexical context of the second \c C::f is the translation unit.
2451 *
2452 * For global declarations, the semantic parent is the translation unit.
2453 */
2454CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2455
2456/**
2457 * \brief Determine the lexical parent of the given cursor.
2458 *
2459 * The lexical parent of a cursor is the cursor in which the given \p cursor
2460 * was actually written. For many declarations, the lexical and semantic parents
2461 * are equivalent (the semantic parent is returned by
2462 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2463 * definitions are provided out-of-line. For example:
2464 *
2465 * \code
2466 * class C {
2467 *  void f();
2468 * };
2469 *
2470 * void C::f() { }
2471 * \endcode
2472 *
2473 * In the out-of-line definition of \c C::f, the semantic parent is the
2474 * the class \c C, of which this function is a member. The lexical parent is
2475 * the place where the declaration actually occurs in the source code; in this
2476 * case, the definition occurs in the translation unit. In general, the
2477 * lexical parent for a given entity can change without affecting the semantics
2478 * of the program, and the lexical parent of different declarations of the
2479 * same entity may be different. Changing the semantic parent of a declaration,
2480 * on the other hand, can have a major impact on semantics, and redeclarations
2481 * of a particular entity should all have the same semantic context.
2482 *
2483 * In the example above, both declarations of \c C::f have \c C as their
2484 * semantic context, while the lexical context of the first \c C::f is \c C
2485 * and the lexical context of the second \c C::f is the translation unit.
2486 *
2487 * For declarations written in the global scope, the lexical parent is
2488 * the translation unit.
2489 */
2490CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
2491
2492/**
2493 * \brief Determine the set of methods that are overridden by the given
2494 * method.
2495 *
2496 * In both Objective-C and C++, a method (aka virtual member function,
2497 * in C++) can override a virtual method in a base class. For
2498 * Objective-C, a method is said to override any method in the class's
2499 * base class, its protocols, or its categories' protocols, that has the same
2500 * selector and is of the same kind (class or instance).
2501 * If no such method exists, the search continues to the class's superclass,
2502 * its protocols, and its categories, and so on. A method from an Objective-C
2503 * implementation is considered to override the same methods as its
2504 * corresponding method in the interface.
2505 *
2506 * For C++, a virtual member function overrides any virtual member
2507 * function with the same signature that occurs in its base
2508 * classes. With multiple inheritance, a virtual member function can
2509 * override several virtual member functions coming from different
2510 * base classes.
2511 *
2512 * In all cases, this function determines the immediate overridden
2513 * method, rather than all of the overridden methods. For example, if
2514 * a method is originally declared in a class A, then overridden in B
2515 * (which in inherits from A) and also in C (which inherited from B),
2516 * then the only overridden method returned from this function when
2517 * invoked on C's method will be B's method. The client may then
2518 * invoke this function again, given the previously-found overridden
2519 * methods, to map out the complete method-override set.
2520 *
2521 * \param cursor A cursor representing an Objective-C or C++
2522 * method. This routine will compute the set of methods that this
2523 * method overrides.
2524 *
2525 * \param overridden A pointer whose pointee will be replaced with a
2526 * pointer to an array of cursors, representing the set of overridden
2527 * methods. If there are no overridden methods, the pointee will be
2528 * set to NULL. The pointee must be freed via a call to
2529 * \c clang_disposeOverriddenCursors().
2530 *
2531 * \param num_overridden A pointer to the number of overridden
2532 * functions, will be set to the number of overridden functions in the
2533 * array pointed to by \p overridden.
2534 */
2535CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
2536                                               CXCursor **overridden,
2537                                               unsigned *num_overridden);
2538
2539/**
2540 * \brief Free the set of overridden cursors returned by \c
2541 * clang_getOverriddenCursors().
2542 */
2543CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
2544
2545/**
2546 * \brief Retrieve the file that is included by the given inclusion directive
2547 * cursor.
2548 */
2549CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
2550
2551/**
2552 * @}
2553 */
2554
2555/**
2556 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2557 *
2558 * Cursors represent a location within the Abstract Syntax Tree (AST). These
2559 * routines help map between cursors and the physical locations where the
2560 * described entities occur in the source code. The mapping is provided in
2561 * both directions, so one can map from source code to the AST and back.
2562 *
2563 * @{
2564 */
2565
2566/**
2567 * \brief Map a source location to the cursor that describes the entity at that
2568 * location in the source code.
2569 *
2570 * clang_getCursor() maps an arbitrary source location within a translation
2571 * unit down to the most specific cursor that describes the entity at that
2572 * location. For example, given an expression \c x + y, invoking
2573 * clang_getCursor() with a source location pointing to "x" will return the
2574 * cursor for "x"; similarly for "y". If the cursor points anywhere between
2575 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2576 * will return a cursor referring to the "+" expression.
2577 *
2578 * \returns a cursor representing the entity at the given source location, or
2579 * a NULL cursor if no such entity can be found.
2580 */
2581CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
2582
2583/**
2584 * \brief Retrieve the physical location of the source constructor referenced
2585 * by the given cursor.
2586 *
2587 * The location of a declaration is typically the location of the name of that
2588 * declaration, where the name of that declaration would occur if it is
2589 * unnamed, or some keyword that introduces that particular declaration.
2590 * The location of a reference is where that reference occurs within the
2591 * source code.
2592 */
2593CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
2594
2595/**
2596 * \brief Retrieve the physical extent of the source construct referenced by
2597 * the given cursor.
2598 *
2599 * The extent of a cursor starts with the file/line/column pointing at the
2600 * first character within the source construct that the cursor refers to and
2601 * ends with the last character withinin that source construct. For a
2602 * declaration, the extent covers the declaration itself. For a reference,
2603 * the extent covers the location of the reference (e.g., where the referenced
2604 * entity was actually used).
2605 */
2606CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
2607
2608/**
2609 * @}
2610 */
2611
2612/**
2613 * \defgroup CINDEX_TYPES Type information for CXCursors
2614 *
2615 * @{
2616 */
2617
2618/**
2619 * \brief Describes the kind of type
2620 */
2621enum CXTypeKind {
2622  /**
2623   * \brief Reprents an invalid type (e.g., where no type is available).
2624   */
2625  CXType_Invalid = 0,
2626
2627  /**
2628   * \brief A type whose specific kind is not exposed via this
2629   * interface.
2630   */
2631  CXType_Unexposed = 1,
2632
2633  /* Builtin types */
2634  CXType_Void = 2,
2635  CXType_Bool = 3,
2636  CXType_Char_U = 4,
2637  CXType_UChar = 5,
2638  CXType_Char16 = 6,
2639  CXType_Char32 = 7,
2640  CXType_UShort = 8,
2641  CXType_UInt = 9,
2642  CXType_ULong = 10,
2643  CXType_ULongLong = 11,
2644  CXType_UInt128 = 12,
2645  CXType_Char_S = 13,
2646  CXType_SChar = 14,
2647  CXType_WChar = 15,
2648  CXType_Short = 16,
2649  CXType_Int = 17,
2650  CXType_Long = 18,
2651  CXType_LongLong = 19,
2652  CXType_Int128 = 20,
2653  CXType_Float = 21,
2654  CXType_Double = 22,
2655  CXType_LongDouble = 23,
2656  CXType_NullPtr = 24,
2657  CXType_Overload = 25,
2658  CXType_Dependent = 26,
2659  CXType_ObjCId = 27,
2660  CXType_ObjCClass = 28,
2661  CXType_ObjCSel = 29,
2662  CXType_FirstBuiltin = CXType_Void,
2663  CXType_LastBuiltin  = CXType_ObjCSel,
2664
2665  CXType_Complex = 100,
2666  CXType_Pointer = 101,
2667  CXType_BlockPointer = 102,
2668  CXType_LValueReference = 103,
2669  CXType_RValueReference = 104,
2670  CXType_Record = 105,
2671  CXType_Enum = 106,
2672  CXType_Typedef = 107,
2673  CXType_ObjCInterface = 108,
2674  CXType_ObjCObjectPointer = 109,
2675  CXType_FunctionNoProto = 110,
2676  CXType_FunctionProto = 111,
2677  CXType_ConstantArray = 112,
2678  CXType_Vector = 113,
2679  CXType_IncompleteArray = 114,
2680  CXType_VariableArray = 115,
2681  CXType_DependentSizedArray = 116,
2682  CXType_MemberPointer = 117
2683};
2684
2685/**
2686 * \brief Describes the calling convention of a function type
2687 */
2688enum CXCallingConv {
2689  CXCallingConv_Default = 0,
2690  CXCallingConv_C = 1,
2691  CXCallingConv_X86StdCall = 2,
2692  CXCallingConv_X86FastCall = 3,
2693  CXCallingConv_X86ThisCall = 4,
2694  CXCallingConv_X86Pascal = 5,
2695  CXCallingConv_AAPCS = 6,
2696  CXCallingConv_AAPCS_VFP = 7,
2697  CXCallingConv_PnaclCall = 8,
2698  CXCallingConv_IntelOclBicc = 9,
2699  CXCallingConv_X86_64Win64 = 10,
2700  CXCallingConv_X86_64SysV = 11,
2701
2702  CXCallingConv_Invalid = 100,
2703  CXCallingConv_Unexposed = 200
2704};
2705
2706
2707/**
2708 * \brief The type of an element in the abstract syntax tree.
2709 *
2710 */
2711typedef struct {
2712  enum CXTypeKind kind;
2713  void *data[2];
2714} CXType;
2715
2716/**
2717 * \brief Retrieve the type of a CXCursor (if any).
2718 */
2719CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
2720
2721/**
2722 * \brief Pretty-print the underlying type using the rules of the
2723 * language of the translation unit from which it came.
2724 *
2725 * If the type is invalid, an empty string is returned.
2726 */
2727CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
2728
2729/**
2730 * \brief Retrieve the underlying type of a typedef declaration.
2731 *
2732 * If the cursor does not reference a typedef declaration, an invalid type is
2733 * returned.
2734 */
2735CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
2736
2737/**
2738 * \brief Retrieve the integer type of an enum declaration.
2739 *
2740 * If the cursor does not reference an enum declaration, an invalid type is
2741 * returned.
2742 */
2743CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
2744
2745/**
2746 * \brief Retrieve the integer value of an enum constant declaration as a signed
2747 *  long long.
2748 *
2749 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
2750 * Since this is also potentially a valid constant value, the kind of the cursor
2751 * must be verified before calling this function.
2752 */
2753CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
2754
2755/**
2756 * \brief Retrieve the integer value of an enum constant declaration as an unsigned
2757 *  long long.
2758 *
2759 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
2760 * Since this is also potentially a valid constant value, the kind of the cursor
2761 * must be verified before calling this function.
2762 */
2763CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
2764
2765/**
2766 * \brief Retrieve the bit width of a bit field declaration as an integer.
2767 *
2768 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
2769 */
2770CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
2771
2772/**
2773 * \brief Retrieve the number of non-variadic arguments associated with a given
2774 * cursor.
2775 *
2776 * The number of arguments can be determined for calls as well as for
2777 * declarations of functions or methods. For other cursors -1 is returned.
2778 */
2779CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
2780
2781/**
2782 * \brief Retrieve the argument cursor of a function or method.
2783 *
2784 * The argument cursor can be determined for calls as well as for declarations
2785 * of functions or methods. For other cursors and for invalid indices, an
2786 * invalid cursor is returned.
2787 */
2788CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
2789
2790/**
2791 * \brief Determine whether two CXTypes represent the same type.
2792 *
2793 * \returns non-zero if the CXTypes represent the same type and
2794 *          zero otherwise.
2795 */
2796CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
2797
2798/**
2799 * \brief Return the canonical type for a CXType.
2800 *
2801 * Clang's type system explicitly models typedefs and all the ways
2802 * a specific type can be represented.  The canonical type is the underlying
2803 * type with all the "sugar" removed.  For example, if 'T' is a typedef
2804 * for 'int', the canonical type for 'T' would be 'int'.
2805 */
2806CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
2807
2808/**
2809 * \brief Determine whether a CXType has the "const" qualifier set,
2810 * without looking through typedefs that may have added "const" at a
2811 * different level.
2812 */
2813CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
2814
2815/**
2816 * \brief Determine whether a CXType has the "volatile" qualifier set,
2817 * without looking through typedefs that may have added "volatile" at
2818 * a different level.
2819 */
2820CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
2821
2822/**
2823 * \brief Determine whether a CXType has the "restrict" qualifier set,
2824 * without looking through typedefs that may have added "restrict" at a
2825 * different level.
2826 */
2827CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
2828
2829/**
2830 * \brief For pointer types, returns the type of the pointee.
2831 */
2832CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
2833
2834/**
2835 * \brief Return the cursor for the declaration of the given type.
2836 */
2837CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
2838
2839/**
2840 * Returns the Objective-C type encoding for the specified declaration.
2841 */
2842CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
2843
2844/**
2845 * \brief Retrieve the spelling of a given CXTypeKind.
2846 */
2847CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
2848
2849/**
2850 * \brief Retrieve the calling convention associated with a function type.
2851 *
2852 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
2853 */
2854CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
2855
2856/**
2857 * \brief Retrieve the result type associated with a function type.
2858 *
2859 * If a non-function type is passed in, an invalid type is returned.
2860 */
2861CINDEX_LINKAGE CXType clang_getResultType(CXType T);
2862
2863/**
2864 * \brief Retrieve the number of non-variadic arguments associated with a
2865 * function type.
2866 *
2867 * If a non-function type is passed in, -1 is returned.
2868 */
2869CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
2870
2871/**
2872 * \brief Retrieve the type of an argument of a function type.
2873 *
2874 * If a non-function type is passed in or the function does not have enough
2875 * parameters, an invalid type is returned.
2876 */
2877CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
2878
2879/**
2880 * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
2881 */
2882CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
2883
2884/**
2885 * \brief Retrieve the result type associated with a given cursor.
2886 *
2887 * This only returns a valid type if the cursor refers to a function or method.
2888 */
2889CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
2890
2891/**
2892 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
2893 *  otherwise.
2894 */
2895CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
2896
2897/**
2898 * \brief Return the element type of an array, complex, or vector type.
2899 *
2900 * If a type is passed in that is not an array, complex, or vector type,
2901 * an invalid type is returned.
2902 */
2903CINDEX_LINKAGE CXType clang_getElementType(CXType T);
2904
2905/**
2906 * \brief Return the number of elements of an array or vector type.
2907 *
2908 * If a type is passed in that is not an array or vector type,
2909 * -1 is returned.
2910 */
2911CINDEX_LINKAGE long long clang_getNumElements(CXType T);
2912
2913/**
2914 * \brief Return the element type of an array type.
2915 *
2916 * If a non-array type is passed in, an invalid type is returned.
2917 */
2918CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
2919
2920/**
2921 * \brief Return the array size of a constant array.
2922 *
2923 * If a non-array type is passed in, -1 is returned.
2924 */
2925CINDEX_LINKAGE long long clang_getArraySize(CXType T);
2926
2927/**
2928 * \brief List the possible error codes for \c clang_Type_getSizeOf,
2929 *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
2930 *   \c clang_Cursor_getOffsetOf.
2931 *
2932 * A value of this enumeration type can be returned if the target type is not
2933 * a valid argument to sizeof, alignof or offsetof.
2934 */
2935enum CXTypeLayoutError {
2936  /**
2937   * \brief Type is of kind CXType_Invalid.
2938   */
2939  CXTypeLayoutError_Invalid = -1,
2940  /**
2941   * \brief The type is an incomplete Type.
2942   */
2943  CXTypeLayoutError_Incomplete = -2,
2944  /**
2945   * \brief The type is a dependent Type.
2946   */
2947  CXTypeLayoutError_Dependent = -3,
2948  /**
2949   * \brief The type is not a constant size type.
2950   */
2951  CXTypeLayoutError_NotConstantSize = -4,
2952  /**
2953   * \brief The Field name is not valid for this record.
2954   */
2955  CXTypeLayoutError_InvalidFieldName = -5
2956};
2957
2958/**
2959 * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
2960 *   standard.
2961 *
2962 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
2963 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
2964 *   is returned.
2965 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
2966 *   returned.
2967 * If the type declaration is not a constant size type,
2968 *   CXTypeLayoutError_NotConstantSize is returned.
2969 */
2970CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
2971
2972/**
2973 * \brief Return the class type of an member pointer type.
2974 *
2975 * If a non-member-pointer type is passed in, an invalid type is returned.
2976 */
2977CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
2978
2979/**
2980 * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
2981 *
2982 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
2983 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
2984 *   is returned.
2985 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
2986 *   returned.
2987 */
2988CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
2989
2990/**
2991 * \brief Return the offset of a field named S in a record of type T in bits
2992 *   as it would be returned by __offsetof__ as per C++11[18.2p4]
2993 *
2994 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
2995 *   is returned.
2996 * If the field's type declaration is an incomplete type,
2997 *   CXTypeLayoutError_Incomplete is returned.
2998 * If the field's type declaration is a dependent type,
2999 *   CXTypeLayoutError_Dependent is returned.
3000 * If the field's name S is not found,
3001 *   CXTypeLayoutError_InvalidFieldName is returned.
3002 */
3003CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3004
3005/**
3006 * \brief Returns non-zero if the cursor specifies a Record member that is a
3007 *   bitfield.
3008 */
3009CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3010
3011/**
3012 * \brief Returns 1 if the base class specified by the cursor with kind
3013 *   CX_CXXBaseSpecifier is virtual.
3014 */
3015CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3016
3017/**
3018 * \brief Represents the C++ access control level to a base class for a
3019 * cursor with kind CX_CXXBaseSpecifier.
3020 */
3021enum CX_CXXAccessSpecifier {
3022  CX_CXXInvalidAccessSpecifier,
3023  CX_CXXPublic,
3024  CX_CXXProtected,
3025  CX_CXXPrivate
3026};
3027
3028/**
3029 * \brief Returns the access control level for the referenced object.
3030 *
3031 * If the cursor refers to a C++ declaration, its access control level within its
3032 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3033 * access specifier, the specifier itself is returned.
3034 */
3035CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3036
3037/**
3038 * \brief Determine the number of overloaded declarations referenced by a
3039 * \c CXCursor_OverloadedDeclRef cursor.
3040 *
3041 * \param cursor The cursor whose overloaded declarations are being queried.
3042 *
3043 * \returns The number of overloaded declarations referenced by \c cursor. If it
3044 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3045 */
3046CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3047
3048/**
3049 * \brief Retrieve a cursor for one of the overloaded declarations referenced
3050 * by a \c CXCursor_OverloadedDeclRef cursor.
3051 *
3052 * \param cursor The cursor whose overloaded declarations are being queried.
3053 *
3054 * \param index The zero-based index into the set of overloaded declarations in
3055 * the cursor.
3056 *
3057 * \returns A cursor representing the declaration referenced by the given
3058 * \c cursor at the specified \c index. If the cursor does not have an
3059 * associated set of overloaded declarations, or if the index is out of bounds,
3060 * returns \c clang_getNullCursor();
3061 */
3062CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3063                                                unsigned index);
3064
3065/**
3066 * @}
3067 */
3068
3069/**
3070 * \defgroup CINDEX_ATTRIBUTES Information for attributes
3071 *
3072 * @{
3073 */
3074
3075
3076/**
3077 * \brief For cursors representing an iboutletcollection attribute,
3078 *  this function returns the collection element type.
3079 *
3080 */
3081CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3082
3083/**
3084 * @}
3085 */
3086
3087/**
3088 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3089 *
3090 * These routines provide the ability to traverse the abstract syntax tree
3091 * using cursors.
3092 *
3093 * @{
3094 */
3095
3096/**
3097 * \brief Describes how the traversal of the children of a particular
3098 * cursor should proceed after visiting a particular child cursor.
3099 *
3100 * A value of this enumeration type should be returned by each
3101 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3102 */
3103enum CXChildVisitResult {
3104  /**
3105   * \brief Terminates the cursor traversal.
3106   */
3107  CXChildVisit_Break,
3108  /**
3109   * \brief Continues the cursor traversal with the next sibling of
3110   * the cursor just visited, without visiting its children.
3111   */
3112  CXChildVisit_Continue,
3113  /**
3114   * \brief Recursively traverse the children of this cursor, using
3115   * the same visitor and client data.
3116   */
3117  CXChildVisit_Recurse
3118};
3119
3120/**
3121 * \brief Visitor invoked for each cursor found by a traversal.
3122 *
3123 * This visitor function will be invoked for each cursor found by
3124 * clang_visitCursorChildren(). Its first argument is the cursor being
3125 * visited, its second argument is the parent visitor for that cursor,
3126 * and its third argument is the client data provided to
3127 * clang_visitCursorChildren().
3128 *
3129 * The visitor should return one of the \c CXChildVisitResult values
3130 * to direct clang_visitCursorChildren().
3131 */
3132typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3133                                                   CXCursor parent,
3134                                                   CXClientData client_data);
3135
3136/**
3137 * \brief Visit the children of a particular cursor.
3138 *
3139 * This function visits all the direct children of the given cursor,
3140 * invoking the given \p visitor function with the cursors of each
3141 * visited child. The traversal may be recursive, if the visitor returns
3142 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3143 * the visitor returns \c CXChildVisit_Break.
3144 *
3145 * \param parent the cursor whose child may be visited. All kinds of
3146 * cursors can be visited, including invalid cursors (which, by
3147 * definition, have no children).
3148 *
3149 * \param visitor the visitor function that will be invoked for each
3150 * child of \p parent.
3151 *
3152 * \param client_data pointer data supplied by the client, which will
3153 * be passed to the visitor each time it is invoked.
3154 *
3155 * \returns a non-zero value if the traversal was terminated
3156 * prematurely by the visitor returning \c CXChildVisit_Break.
3157 */
3158CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
3159                                            CXCursorVisitor visitor,
3160                                            CXClientData client_data);
3161#ifdef __has_feature
3162#  if __has_feature(blocks)
3163/**
3164 * \brief Visitor invoked for each cursor found by a traversal.
3165 *
3166 * This visitor block will be invoked for each cursor found by
3167 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3168 * visited, its second argument is the parent visitor for that cursor.
3169 *
3170 * The visitor should return one of the \c CXChildVisitResult values
3171 * to direct clang_visitChildrenWithBlock().
3172 */
3173typedef enum CXChildVisitResult
3174     (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3175
3176/**
3177 * Visits the children of a cursor using the specified block.  Behaves
3178 * identically to clang_visitChildren() in all other respects.
3179 */
3180unsigned clang_visitChildrenWithBlock(CXCursor parent,
3181                                      CXCursorVisitorBlock block);
3182#  endif
3183#endif
3184
3185/**
3186 * @}
3187 */
3188
3189/**
3190 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3191 *
3192 * These routines provide the ability to determine references within and
3193 * across translation units, by providing the names of the entities referenced
3194 * by cursors, follow reference cursors to the declarations they reference,
3195 * and associate declarations with their definitions.
3196 *
3197 * @{
3198 */
3199
3200/**
3201 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3202 * by the given cursor.
3203 *
3204 * A Unified Symbol Resolution (USR) is a string that identifies a particular
3205 * entity (function, class, variable, etc.) within a program. USRs can be
3206 * compared across translation units to determine, e.g., when references in
3207 * one translation refer to an entity defined in another translation unit.
3208 */
3209CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
3210
3211/**
3212 * \brief Construct a USR for a specified Objective-C class.
3213 */
3214CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
3215
3216/**
3217 * \brief Construct a USR for a specified Objective-C category.
3218 */
3219CINDEX_LINKAGE CXString
3220  clang_constructUSR_ObjCCategory(const char *class_name,
3221                                 const char *category_name);
3222
3223/**
3224 * \brief Construct a USR for a specified Objective-C protocol.
3225 */
3226CINDEX_LINKAGE CXString
3227  clang_constructUSR_ObjCProtocol(const char *protocol_name);
3228
3229
3230/**
3231 * \brief Construct a USR for a specified Objective-C instance variable and
3232 *   the USR for its containing class.
3233 */
3234CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
3235                                                    CXString classUSR);
3236
3237/**
3238 * \brief Construct a USR for a specified Objective-C method and
3239 *   the USR for its containing class.
3240 */
3241CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
3242                                                      unsigned isInstanceMethod,
3243                                                      CXString classUSR);
3244
3245/**
3246 * \brief Construct a USR for a specified Objective-C property and the USR
3247 *  for its containing class.
3248 */
3249CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
3250                                                        CXString classUSR);
3251
3252/**
3253 * \brief Retrieve a name for the entity referenced by this cursor.
3254 */
3255CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
3256
3257/**
3258 * \brief Retrieve a range for a piece that forms the cursors spelling name.
3259 * Most of the times there is only one range for the complete spelling but for
3260 * objc methods and objc message expressions, there are multiple pieces for each
3261 * selector identifier.
3262 *
3263 * \param pieceIndex the index of the spelling name piece. If this is greater
3264 * than the actual number of pieces, it will return a NULL (invalid) range.
3265 *
3266 * \param options Reserved.
3267 */
3268CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
3269                                                          unsigned pieceIndex,
3270                                                          unsigned options);
3271
3272/**
3273 * \brief Retrieve the display name for the entity referenced by this cursor.
3274 *
3275 * The display name contains extra information that helps identify the cursor,
3276 * such as the parameters of a function or template or the arguments of a
3277 * class template specialization.
3278 */
3279CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
3280
3281/** \brief For a cursor that is a reference, retrieve a cursor representing the
3282 * entity that it references.
3283 *
3284 * Reference cursors refer to other entities in the AST. For example, an
3285 * Objective-C superclass reference cursor refers to an Objective-C class.
3286 * This function produces the cursor for the Objective-C class from the
3287 * cursor for the superclass reference. If the input cursor is a declaration or
3288 * definition, it returns that declaration or definition unchanged.
3289 * Otherwise, returns the NULL cursor.
3290 */
3291CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
3292
3293/**
3294 *  \brief For a cursor that is either a reference to or a declaration
3295 *  of some entity, retrieve a cursor that describes the definition of
3296 *  that entity.
3297 *
3298 *  Some entities can be declared multiple times within a translation
3299 *  unit, but only one of those declarations can also be a
3300 *  definition. For example, given:
3301 *
3302 *  \code
3303 *  int f(int, int);
3304 *  int g(int x, int y) { return f(x, y); }
3305 *  int f(int a, int b) { return a + b; }
3306 *  int f(int, int);
3307 *  \endcode
3308 *
3309 *  there are three declarations of the function "f", but only the
3310 *  second one is a definition. The clang_getCursorDefinition()
3311 *  function will take any cursor pointing to a declaration of "f"
3312 *  (the first or fourth lines of the example) or a cursor referenced
3313 *  that uses "f" (the call to "f' inside "g") and will return a
3314 *  declaration cursor pointing to the definition (the second "f"
3315 *  declaration).
3316 *
3317 *  If given a cursor for which there is no corresponding definition,
3318 *  e.g., because there is no definition of that entity within this
3319 *  translation unit, returns a NULL cursor.
3320 */
3321CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
3322
3323/**
3324 * \brief Determine whether the declaration pointed to by this cursor
3325 * is also a definition of that entity.
3326 */
3327CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
3328
3329/**
3330 * \brief Retrieve the canonical cursor corresponding to the given cursor.
3331 *
3332 * In the C family of languages, many kinds of entities can be declared several
3333 * times within a single translation unit. For example, a structure type can
3334 * be forward-declared (possibly multiple times) and later defined:
3335 *
3336 * \code
3337 * struct X;
3338 * struct X;
3339 * struct X {
3340 *   int member;
3341 * };
3342 * \endcode
3343 *
3344 * The declarations and the definition of \c X are represented by three
3345 * different cursors, all of which are declarations of the same underlying
3346 * entity. One of these cursor is considered the "canonical" cursor, which
3347 * is effectively the representative for the underlying entity. One can
3348 * determine if two cursors are declarations of the same underlying entity by
3349 * comparing their canonical cursors.
3350 *
3351 * \returns The canonical cursor for the entity referred to by the given cursor.
3352 */
3353CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
3354
3355
3356/**
3357 * \brief If the cursor points to a selector identifier in a objc method or
3358 * message expression, this returns the selector index.
3359 *
3360 * After getting a cursor with #clang_getCursor, this can be called to
3361 * determine if the location points to a selector identifier.
3362 *
3363 * \returns The selector index if the cursor is an objc method or message
3364 * expression and the cursor is pointing to a selector identifier, or -1
3365 * otherwise.
3366 */
3367CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
3368
3369/**
3370 * \brief Given a cursor pointing to a C++ method call or an ObjC message,
3371 * returns non-zero if the method/message is "dynamic", meaning:
3372 *
3373 * For a C++ method: the call is virtual.
3374 * For an ObjC message: the receiver is an object instance, not 'super' or a
3375 * specific class.
3376 *
3377 * If the method/message is "static" or the cursor does not point to a
3378 * method/message, it will return zero.
3379 */
3380CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
3381
3382/**
3383 * \brief Given a cursor pointing to an ObjC message, returns the CXType of the
3384 * receiver.
3385 */
3386CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
3387
3388/**
3389 * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
3390 */
3391typedef enum {
3392  CXObjCPropertyAttr_noattr    = 0x00,
3393  CXObjCPropertyAttr_readonly  = 0x01,
3394  CXObjCPropertyAttr_getter    = 0x02,
3395  CXObjCPropertyAttr_assign    = 0x04,
3396  CXObjCPropertyAttr_readwrite = 0x08,
3397  CXObjCPropertyAttr_retain    = 0x10,
3398  CXObjCPropertyAttr_copy      = 0x20,
3399  CXObjCPropertyAttr_nonatomic = 0x40,
3400  CXObjCPropertyAttr_setter    = 0x80,
3401  CXObjCPropertyAttr_atomic    = 0x100,
3402  CXObjCPropertyAttr_weak      = 0x200,
3403  CXObjCPropertyAttr_strong    = 0x400,
3404  CXObjCPropertyAttr_unsafe_unretained = 0x800
3405} CXObjCPropertyAttrKind;
3406
3407/**
3408 * \brief Given a cursor that represents a property declaration, return the
3409 * associated property attributes. The bits are formed from
3410 * \c CXObjCPropertyAttrKind.
3411 *
3412 * \param reserved Reserved for future use, pass 0.
3413 */
3414CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
3415                                                             unsigned reserved);
3416
3417/**
3418 * \brief 'Qualifiers' written next to the return and parameter types in
3419 * ObjC method declarations.
3420 */
3421typedef enum {
3422  CXObjCDeclQualifier_None = 0x0,
3423  CXObjCDeclQualifier_In = 0x1,
3424  CXObjCDeclQualifier_Inout = 0x2,
3425  CXObjCDeclQualifier_Out = 0x4,
3426  CXObjCDeclQualifier_Bycopy = 0x8,
3427  CXObjCDeclQualifier_Byref = 0x10,
3428  CXObjCDeclQualifier_Oneway = 0x20
3429} CXObjCDeclQualifierKind;
3430
3431/**
3432 * \brief Given a cursor that represents an ObjC method or parameter
3433 * declaration, return the associated ObjC qualifiers for the return type or the
3434 * parameter respectively. The bits are formed from CXObjCDeclQualifierKind.
3435 */
3436CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
3437
3438/**
3439 * \brief Given a cursor that represents an ObjC method or property declaration,
3440 * return non-zero if the declaration was affected by "@optional".
3441 * Returns zero if the cursor is not such a declaration or it is "@required".
3442 */
3443CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
3444
3445/**
3446 * \brief Returns non-zero if the given cursor is a variadic function or method.
3447 */
3448CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
3449
3450/**
3451 * \brief Given a cursor that represents a declaration, return the associated
3452 * comment's source range.  The range may include multiple consecutive comments
3453 * with whitespace in between.
3454 */
3455CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
3456
3457/**
3458 * \brief Given a cursor that represents a declaration, return the associated
3459 * comment text, including comment markers.
3460 */
3461CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
3462
3463/**
3464 * \brief Given a cursor that represents a documentable entity (e.g.,
3465 * declaration), return the associated \\brief paragraph; otherwise return the
3466 * first paragraph.
3467 */
3468CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
3469
3470/**
3471 * \brief Given a cursor that represents a documentable entity (e.g.,
3472 * declaration), return the associated parsed comment as a
3473 * \c CXComment_FullComment AST node.
3474 */
3475CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C);
3476
3477/**
3478 * @}
3479 */
3480
3481/**
3482 * \defgroup CINDEX_MODULE Module introspection
3483 *
3484 * The functions in this group provide access to information about modules.
3485 *
3486 * @{
3487 */
3488
3489typedef void *CXModule;
3490
3491/**
3492 * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
3493 */
3494CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
3495
3496/**
3497 * \param Module a module object.
3498 *
3499 * \returns the module file where the provided module object came from.
3500 */
3501CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
3502
3503/**
3504 * \param Module a module object.
3505 *
3506 * \returns the parent of a sub-module or NULL if the given module is top-level,
3507 * e.g. for 'std.vector' it will return the 'std' module.
3508 */
3509CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
3510
3511/**
3512 * \param Module a module object.
3513 *
3514 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
3515 * will return "vector".
3516 */
3517CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
3518
3519/**
3520 * \param Module a module object.
3521 *
3522 * \returns the full name of the module, e.g. "std.vector".
3523 */
3524CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
3525
3526/**
3527 * \param Module a module object.
3528 *
3529 * \returns the number of top level headers associated with this module.
3530 */
3531CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
3532                                                           CXModule Module);
3533
3534/**
3535 * \param Module a module object.
3536 *
3537 * \param Index top level header index (zero-based).
3538 *
3539 * \returns the specified top level header associated with the module.
3540 */
3541CINDEX_LINKAGE
3542CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
3543                                      CXModule Module, unsigned Index);
3544
3545/**
3546 * @}
3547 */
3548
3549/**
3550 * \defgroup CINDEX_COMMENT Comment AST introspection
3551 *
3552 * The routines in this group provide access to information in the
3553 * documentation comment ASTs.
3554 *
3555 * @{
3556 */
3557
3558/**
3559 * \brief Describes the type of the comment AST node (\c CXComment).  A comment
3560 * node can be considered block content (e. g., paragraph), inline content
3561 * (plain text) or neither (the root AST node).
3562 */
3563enum CXCommentKind {
3564  /**
3565   * \brief Null comment.  No AST node is constructed at the requested location
3566   * because there is no text or a syntax error.
3567   */
3568  CXComment_Null = 0,
3569
3570  /**
3571   * \brief Plain text.  Inline content.
3572   */
3573  CXComment_Text = 1,
3574
3575  /**
3576   * \brief A command with word-like arguments that is considered inline content.
3577   *
3578   * For example: \\c command.
3579   */
3580  CXComment_InlineCommand = 2,
3581
3582  /**
3583   * \brief HTML start tag with attributes (name-value pairs).  Considered
3584   * inline content.
3585   *
3586   * For example:
3587   * \verbatim
3588   * <br> <br /> <a href="http://example.org/">
3589   * \endverbatim
3590   */
3591  CXComment_HTMLStartTag = 3,
3592
3593  /**
3594   * \brief HTML end tag.  Considered inline content.
3595   *
3596   * For example:
3597   * \verbatim
3598   * </a>
3599   * \endverbatim
3600   */
3601  CXComment_HTMLEndTag = 4,
3602
3603  /**
3604   * \brief A paragraph, contains inline comment.  The paragraph itself is
3605   * block content.
3606   */
3607  CXComment_Paragraph = 5,
3608
3609  /**
3610   * \brief A command that has zero or more word-like arguments (number of
3611   * word-like arguments depends on command name) and a paragraph as an
3612   * argument.  Block command is block content.
3613   *
3614   * Paragraph argument is also a child of the block command.
3615   *
3616   * For example: \\brief has 0 word-like arguments and a paragraph argument.
3617   *
3618   * AST nodes of special kinds that parser knows about (e. g., \\param
3619   * command) have their own node kinds.
3620   */
3621  CXComment_BlockCommand = 6,
3622
3623  /**
3624   * \brief A \\param or \\arg command that describes the function parameter
3625   * (name, passing direction, description).
3626   *
3627   * For example: \\param [in] ParamName description.
3628   */
3629  CXComment_ParamCommand = 7,
3630
3631  /**
3632   * \brief A \\tparam command that describes a template parameter (name and
3633   * description).
3634   *
3635   * For example: \\tparam T description.
3636   */
3637  CXComment_TParamCommand = 8,
3638
3639  /**
3640   * \brief A verbatim block command (e. g., preformatted code).  Verbatim
3641   * block has an opening and a closing command and contains multiple lines of
3642   * text (\c CXComment_VerbatimBlockLine child nodes).
3643   *
3644   * For example:
3645   * \\verbatim
3646   * aaa
3647   * \\endverbatim
3648   */
3649  CXComment_VerbatimBlockCommand = 9,
3650
3651  /**
3652   * \brief A line of text that is contained within a
3653   * CXComment_VerbatimBlockCommand node.
3654   */
3655  CXComment_VerbatimBlockLine = 10,
3656
3657  /**
3658   * \brief A verbatim line command.  Verbatim line has an opening command,
3659   * a single line of text (up to the newline after the opening command) and
3660   * has no closing command.
3661   */
3662  CXComment_VerbatimLine = 11,
3663
3664  /**
3665   * \brief A full comment attached to a declaration, contains block content.
3666   */
3667  CXComment_FullComment = 12
3668};
3669
3670/**
3671 * \brief The most appropriate rendering mode for an inline command, chosen on
3672 * command semantics in Doxygen.
3673 */
3674enum CXCommentInlineCommandRenderKind {
3675  /**
3676   * \brief Command argument should be rendered in a normal font.
3677   */
3678  CXCommentInlineCommandRenderKind_Normal,
3679
3680  /**
3681   * \brief Command argument should be rendered in a bold font.
3682   */
3683  CXCommentInlineCommandRenderKind_Bold,
3684
3685  /**
3686   * \brief Command argument should be rendered in a monospaced font.
3687   */
3688  CXCommentInlineCommandRenderKind_Monospaced,
3689
3690  /**
3691   * \brief Command argument should be rendered emphasized (typically italic
3692   * font).
3693   */
3694  CXCommentInlineCommandRenderKind_Emphasized
3695};
3696
3697/**
3698 * \brief Describes parameter passing direction for \\param or \\arg command.
3699 */
3700enum CXCommentParamPassDirection {
3701  /**
3702   * \brief The parameter is an input parameter.
3703   */
3704  CXCommentParamPassDirection_In,
3705
3706  /**
3707   * \brief The parameter is an output parameter.
3708   */
3709  CXCommentParamPassDirection_Out,
3710
3711  /**
3712   * \brief The parameter is an input and output parameter.
3713   */
3714  CXCommentParamPassDirection_InOut
3715};
3716
3717/**
3718 * \param Comment AST node of any kind.
3719 *
3720 * \returns the type of the AST node.
3721 */
3722CINDEX_LINKAGE enum CXCommentKind clang_Comment_getKind(CXComment Comment);
3723
3724/**
3725 * \param Comment AST node of any kind.
3726 *
3727 * \returns number of children of the AST node.
3728 */
3729CINDEX_LINKAGE unsigned clang_Comment_getNumChildren(CXComment Comment);
3730
3731/**
3732 * \param Comment AST node of any kind.
3733 *
3734 * \param ChildIdx child index (zero-based).
3735 *
3736 * \returns the specified child of the AST node.
3737 */
3738CINDEX_LINKAGE
3739CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx);
3740
3741/**
3742 * \brief A \c CXComment_Paragraph node is considered whitespace if it contains
3743 * only \c CXComment_Text nodes that are empty or whitespace.
3744 *
3745 * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are
3746 * never considered whitespace.
3747 *
3748 * \returns non-zero if \c Comment is whitespace.
3749 */
3750CINDEX_LINKAGE unsigned clang_Comment_isWhitespace(CXComment Comment);
3751
3752/**
3753 * \returns non-zero if \c Comment is inline content and has a newline
3754 * immediately following it in the comment text.  Newlines between paragraphs
3755 * do not count.
3756 */
3757CINDEX_LINKAGE
3758unsigned clang_InlineContentComment_hasTrailingNewline(CXComment Comment);
3759
3760/**
3761 * \param Comment a \c CXComment_Text AST node.
3762 *
3763 * \returns text contained in the AST node.
3764 */
3765CINDEX_LINKAGE CXString clang_TextComment_getText(CXComment Comment);
3766
3767/**
3768 * \param Comment a \c CXComment_InlineCommand AST node.
3769 *
3770 * \returns name of the inline command.
3771 */
3772CINDEX_LINKAGE
3773CXString clang_InlineCommandComment_getCommandName(CXComment Comment);
3774
3775/**
3776 * \param Comment a \c CXComment_InlineCommand AST node.
3777 *
3778 * \returns the most appropriate rendering mode, chosen on command
3779 * semantics in Doxygen.
3780 */
3781CINDEX_LINKAGE enum CXCommentInlineCommandRenderKind
3782clang_InlineCommandComment_getRenderKind(CXComment Comment);
3783
3784/**
3785 * \param Comment a \c CXComment_InlineCommand AST node.
3786 *
3787 * \returns number of command arguments.
3788 */
3789CINDEX_LINKAGE
3790unsigned clang_InlineCommandComment_getNumArgs(CXComment Comment);
3791
3792/**
3793 * \param Comment a \c CXComment_InlineCommand AST node.
3794 *
3795 * \param ArgIdx argument index (zero-based).
3796 *
3797 * \returns text of the specified argument.
3798 */
3799CINDEX_LINKAGE
3800CXString clang_InlineCommandComment_getArgText(CXComment Comment,
3801                                               unsigned ArgIdx);
3802
3803/**
3804 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
3805 * node.
3806 *
3807 * \returns HTML tag name.
3808 */
3809CINDEX_LINKAGE CXString clang_HTMLTagComment_getTagName(CXComment Comment);
3810
3811/**
3812 * \param Comment a \c CXComment_HTMLStartTag AST node.
3813 *
3814 * \returns non-zero if tag is self-closing (for example, &lt;br /&gt;).
3815 */
3816CINDEX_LINKAGE
3817unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment Comment);
3818
3819/**
3820 * \param Comment a \c CXComment_HTMLStartTag AST node.
3821 *
3822 * \returns number of attributes (name-value pairs) attached to the start tag.
3823 */
3824CINDEX_LINKAGE unsigned clang_HTMLStartTag_getNumAttrs(CXComment Comment);
3825
3826/**
3827 * \param Comment a \c CXComment_HTMLStartTag AST node.
3828 *
3829 * \param AttrIdx attribute index (zero-based).
3830 *
3831 * \returns name of the specified attribute.
3832 */
3833CINDEX_LINKAGE
3834CXString clang_HTMLStartTag_getAttrName(CXComment Comment, unsigned AttrIdx);
3835
3836/**
3837 * \param Comment a \c CXComment_HTMLStartTag AST node.
3838 *
3839 * \param AttrIdx attribute index (zero-based).
3840 *
3841 * \returns value of the specified attribute.
3842 */
3843CINDEX_LINKAGE
3844CXString clang_HTMLStartTag_getAttrValue(CXComment Comment, unsigned AttrIdx);
3845
3846/**
3847 * \param Comment a \c CXComment_BlockCommand AST node.
3848 *
3849 * \returns name of the block command.
3850 */
3851CINDEX_LINKAGE
3852CXString clang_BlockCommandComment_getCommandName(CXComment Comment);
3853
3854/**
3855 * \param Comment a \c CXComment_BlockCommand AST node.
3856 *
3857 * \returns number of word-like arguments.
3858 */
3859CINDEX_LINKAGE
3860unsigned clang_BlockCommandComment_getNumArgs(CXComment Comment);
3861
3862/**
3863 * \param Comment a \c CXComment_BlockCommand AST node.
3864 *
3865 * \param ArgIdx argument index (zero-based).
3866 *
3867 * \returns text of the specified word-like argument.
3868 */
3869CINDEX_LINKAGE
3870CXString clang_BlockCommandComment_getArgText(CXComment Comment,
3871                                              unsigned ArgIdx);
3872
3873/**
3874 * \param Comment a \c CXComment_BlockCommand or
3875 * \c CXComment_VerbatimBlockCommand AST node.
3876 *
3877 * \returns paragraph argument of the block command.
3878 */
3879CINDEX_LINKAGE
3880CXComment clang_BlockCommandComment_getParagraph(CXComment Comment);
3881
3882/**
3883 * \param Comment a \c CXComment_ParamCommand AST node.
3884 *
3885 * \returns parameter name.
3886 */
3887CINDEX_LINKAGE
3888CXString clang_ParamCommandComment_getParamName(CXComment Comment);
3889
3890/**
3891 * \param Comment a \c CXComment_ParamCommand AST node.
3892 *
3893 * \returns non-zero if the parameter that this AST node represents was found
3894 * in the function prototype and \c clang_ParamCommandComment_getParamIndex
3895 * function will return a meaningful value.
3896 */
3897CINDEX_LINKAGE
3898unsigned clang_ParamCommandComment_isParamIndexValid(CXComment Comment);
3899
3900/**
3901 * \param Comment a \c CXComment_ParamCommand AST node.
3902 *
3903 * \returns zero-based parameter index in function prototype.
3904 */
3905CINDEX_LINKAGE
3906unsigned clang_ParamCommandComment_getParamIndex(CXComment Comment);
3907
3908/**
3909 * \param Comment a \c CXComment_ParamCommand AST node.
3910 *
3911 * \returns non-zero if parameter passing direction was specified explicitly in
3912 * the comment.
3913 */
3914CINDEX_LINKAGE
3915unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment Comment);
3916
3917/**
3918 * \param Comment a \c CXComment_ParamCommand AST node.
3919 *
3920 * \returns parameter passing direction.
3921 */
3922CINDEX_LINKAGE
3923enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection(
3924                                                            CXComment Comment);
3925
3926/**
3927 * \param Comment a \c CXComment_TParamCommand AST node.
3928 *
3929 * \returns template parameter name.
3930 */
3931CINDEX_LINKAGE
3932CXString clang_TParamCommandComment_getParamName(CXComment Comment);
3933
3934/**
3935 * \param Comment a \c CXComment_TParamCommand AST node.
3936 *
3937 * \returns non-zero if the parameter that this AST node represents was found
3938 * in the template parameter list and
3939 * \c clang_TParamCommandComment_getDepth and
3940 * \c clang_TParamCommandComment_getIndex functions will return a meaningful
3941 * value.
3942 */
3943CINDEX_LINKAGE
3944unsigned clang_TParamCommandComment_isParamPositionValid(CXComment Comment);
3945
3946/**
3947 * \param Comment a \c CXComment_TParamCommand AST node.
3948 *
3949 * \returns zero-based nesting depth of this parameter in the template parameter list.
3950 *
3951 * For example,
3952 * \verbatim
3953 *     template<typename C, template<typename T> class TT>
3954 *     void test(TT<int> aaa);
3955 * \endverbatim
3956 * for C and TT nesting depth is 0,
3957 * for T nesting depth is 1.
3958 */
3959CINDEX_LINKAGE
3960unsigned clang_TParamCommandComment_getDepth(CXComment Comment);
3961
3962/**
3963 * \param Comment a \c CXComment_TParamCommand AST node.
3964 *
3965 * \returns zero-based parameter index in the template parameter list at a
3966 * given nesting depth.
3967 *
3968 * For example,
3969 * \verbatim
3970 *     template<typename C, template<typename T> class TT>
3971 *     void test(TT<int> aaa);
3972 * \endverbatim
3973 * for C and TT nesting depth is 0, so we can ask for index at depth 0:
3974 * at depth 0 C's index is 0, TT's index is 1.
3975 *
3976 * For T nesting depth is 1, so we can ask for index at depth 0 and 1:
3977 * at depth 0 T's index is 1 (same as TT's),
3978 * at depth 1 T's index is 0.
3979 */
3980CINDEX_LINKAGE
3981unsigned clang_TParamCommandComment_getIndex(CXComment Comment, unsigned Depth);
3982
3983/**
3984 * \param Comment a \c CXComment_VerbatimBlockLine AST node.
3985 *
3986 * \returns text contained in the AST node.
3987 */
3988CINDEX_LINKAGE
3989CXString clang_VerbatimBlockLineComment_getText(CXComment Comment);
3990
3991/**
3992 * \param Comment a \c CXComment_VerbatimLine AST node.
3993 *
3994 * \returns text contained in the AST node.
3995 */
3996CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment);
3997
3998/**
3999 * \brief Convert an HTML tag AST node to string.
4000 *
4001 * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
4002 * node.
4003 *
4004 * \returns string containing an HTML tag.
4005 */
4006CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment);
4007
4008/**
4009 * \brief Convert a given full parsed comment to an HTML fragment.
4010 *
4011 * Specific details of HTML layout are subject to change.  Don't try to parse
4012 * this HTML back into an AST, use other APIs instead.
4013 *
4014 * Currently the following CSS classes are used:
4015 * \li "para-brief" for \\brief paragraph and equivalent commands;
4016 * \li "para-returns" for \\returns paragraph and equivalent commands;
4017 * \li "word-returns" for the "Returns" word in \\returns paragraph.
4018 *
4019 * Function argument documentation is rendered as a \<dl\> list with arguments
4020 * sorted in function prototype order.  CSS classes used:
4021 * \li "param-name-index-NUMBER" for parameter name (\<dt\>);
4022 * \li "param-descr-index-NUMBER" for parameter description (\<dd\>);
4023 * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if
4024 * parameter index is invalid.
4025 *
4026 * Template parameter documentation is rendered as a \<dl\> list with
4027 * parameters sorted in template parameter list order.  CSS classes used:
4028 * \li "tparam-name-index-NUMBER" for parameter name (\<dt\>);
4029 * \li "tparam-descr-index-NUMBER" for parameter description (\<dd\>);
4030 * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for
4031 * names inside template template parameters;
4032 * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if
4033 * parameter position is invalid.
4034 *
4035 * \param Comment a \c CXComment_FullComment AST node.
4036 *
4037 * \returns string containing an HTML fragment.
4038 */
4039CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment);
4040
4041/**
4042 * \brief Convert a given full parsed comment to an XML document.
4043 *
4044 * A Relax NG schema for the XML can be found in comment-xml-schema.rng file
4045 * inside clang source tree.
4046 *
4047 * \param Comment a \c CXComment_FullComment AST node.
4048 *
4049 * \returns string containing an XML document.
4050 */
4051CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment);
4052
4053/**
4054 * @}
4055 */
4056
4057/**
4058 * \defgroup CINDEX_CPP C++ AST introspection
4059 *
4060 * The routines in this group provide access information in the ASTs specific
4061 * to C++ language features.
4062 *
4063 * @{
4064 */
4065
4066/**
4067 * \brief Determine if a C++ member function or member function template is
4068 * pure virtual.
4069 */
4070CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4071
4072/**
4073 * \brief Determine if a C++ member function or member function template is
4074 * declared 'static'.
4075 */
4076CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4077
4078/**
4079 * \brief Determine if a C++ member function or member function template is
4080 * explicitly declared 'virtual' or if it overrides a virtual method from
4081 * one of the base classes.
4082 */
4083CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4084
4085/**
4086 * \brief Given a cursor that represents a template, determine
4087 * the cursor kind of the specializations would be generated by instantiating
4088 * the template.
4089 *
4090 * This routine can be used to determine what flavor of function template,
4091 * class template, or class template partial specialization is stored in the
4092 * cursor. For example, it can describe whether a class template cursor is
4093 * declared with "struct", "class" or "union".
4094 *
4095 * \param C The cursor to query. This cursor should represent a template
4096 * declaration.
4097 *
4098 * \returns The cursor kind of the specializations that would be generated
4099 * by instantiating the template \p C. If \p C is not a template, returns
4100 * \c CXCursor_NoDeclFound.
4101 */
4102CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4103
4104/**
4105 * \brief Given a cursor that may represent a specialization or instantiation
4106 * of a template, retrieve the cursor that represents the template that it
4107 * specializes or from which it was instantiated.
4108 *
4109 * This routine determines the template involved both for explicit
4110 * specializations of templates and for implicit instantiations of the template,
4111 * both of which are referred to as "specializations". For a class template
4112 * specialization (e.g., \c std::vector<bool>), this routine will return
4113 * either the primary template (\c std::vector) or, if the specialization was
4114 * instantiated from a class template partial specialization, the class template
4115 * partial specialization. For a class template partial specialization and a
4116 * function template specialization (including instantiations), this
4117 * this routine will return the specialized template.
4118 *
4119 * For members of a class template (e.g., member functions, member classes, or
4120 * static data members), returns the specialized or instantiated member.
4121 * Although not strictly "templates" in the C++ language, members of class
4122 * templates have the same notions of specializations and instantiations that
4123 * templates do, so this routine treats them similarly.
4124 *
4125 * \param C A cursor that may be a specialization of a template or a member
4126 * of a template.
4127 *
4128 * \returns If the given cursor is a specialization or instantiation of a
4129 * template or a member thereof, the template or member that it specializes or
4130 * from which it was instantiated. Otherwise, returns a NULL cursor.
4131 */
4132CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4133
4134/**
4135 * \brief Given a cursor that references something else, return the source range
4136 * covering that reference.
4137 *
4138 * \param C A cursor pointing to a member reference, a declaration reference, or
4139 * an operator call.
4140 * \param NameFlags A bitset with three independent flags:
4141 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4142 * CXNameRange_WantSinglePiece.
4143 * \param PieceIndex For contiguous names or when passing the flag
4144 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4145 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4146 * non-contiguous names, this index can be used to retrieve the individual
4147 * pieces of the name. See also CXNameRange_WantSinglePiece.
4148 *
4149 * \returns The piece of the name pointed to by the given cursor. If there is no
4150 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4151 */
4152CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4153                                                unsigned NameFlags,
4154                                                unsigned PieceIndex);
4155
4156enum CXNameRefFlags {
4157  /**
4158   * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4159   * range.
4160   */
4161  CXNameRange_WantQualifier = 0x1,
4162
4163  /**
4164   * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
4165   * in the range.
4166   */
4167  CXNameRange_WantTemplateArgs = 0x2,
4168
4169  /**
4170   * \brief If the name is non-contiguous, return the full spanning range.
4171   *
4172   * Non-contiguous names occur in Objective-C when a selector with two or more
4173   * parameters is used, or in C++ when using an operator:
4174   * \code
4175   * [object doSomething:here withValue:there]; // ObjC
4176   * return some_vector[1]; // C++
4177   * \endcode
4178   */
4179  CXNameRange_WantSinglePiece = 0x4
4180};
4181
4182/**
4183 * @}
4184 */
4185
4186/**
4187 * \defgroup CINDEX_LEX Token extraction and manipulation
4188 *
4189 * The routines in this group provide access to the tokens within a
4190 * translation unit, along with a semantic mapping of those tokens to
4191 * their corresponding cursors.
4192 *
4193 * @{
4194 */
4195
4196/**
4197 * \brief Describes a kind of token.
4198 */
4199typedef enum CXTokenKind {
4200  /**
4201   * \brief A token that contains some kind of punctuation.
4202   */
4203  CXToken_Punctuation,
4204
4205  /**
4206   * \brief A language keyword.
4207   */
4208  CXToken_Keyword,
4209
4210  /**
4211   * \brief An identifier (that is not a keyword).
4212   */
4213  CXToken_Identifier,
4214
4215  /**
4216   * \brief A numeric, string, or character literal.
4217   */
4218  CXToken_Literal,
4219
4220  /**
4221   * \brief A comment.
4222   */
4223  CXToken_Comment
4224} CXTokenKind;
4225
4226/**
4227 * \brief Describes a single preprocessing token.
4228 */
4229typedef struct {
4230  unsigned int_data[4];
4231  void *ptr_data;
4232} CXToken;
4233
4234/**
4235 * \brief Determine the kind of the given token.
4236 */
4237CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4238
4239/**
4240 * \brief Determine the spelling of the given token.
4241 *
4242 * The spelling of a token is the textual representation of that token, e.g.,
4243 * the text of an identifier or keyword.
4244 */
4245CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4246
4247/**
4248 * \brief Retrieve the source location of the given token.
4249 */
4250CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4251                                                       CXToken);
4252
4253/**
4254 * \brief Retrieve a source range that covers the given token.
4255 */
4256CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4257
4258/**
4259 * \brief Tokenize the source code described by the given range into raw
4260 * lexical tokens.
4261 *
4262 * \param TU the translation unit whose text is being tokenized.
4263 *
4264 * \param Range the source range in which text should be tokenized. All of the
4265 * tokens produced by tokenization will fall within this source range,
4266 *
4267 * \param Tokens this pointer will be set to point to the array of tokens
4268 * that occur within the given source range. The returned pointer must be
4269 * freed with clang_disposeTokens() before the translation unit is destroyed.
4270 *
4271 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4272 * array.
4273 *
4274 */
4275CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4276                                   CXToken **Tokens, unsigned *NumTokens);
4277
4278/**
4279 * \brief Annotate the given set of tokens by providing cursors for each token
4280 * that can be mapped to a specific entity within the abstract syntax tree.
4281 *
4282 * This token-annotation routine is equivalent to invoking
4283 * clang_getCursor() for the source locations of each of the
4284 * tokens. The cursors provided are filtered, so that only those
4285 * cursors that have a direct correspondence to the token are
4286 * accepted. For example, given a function call \c f(x),
4287 * clang_getCursor() would provide the following cursors:
4288 *
4289 *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4290 *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4291 *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4292 *
4293 * Only the first and last of these cursors will occur within the
4294 * annotate, since the tokens "f" and "x' directly refer to a function
4295 * and a variable, respectively, but the parentheses are just a small
4296 * part of the full syntax of the function call expression, which is
4297 * not provided as an annotation.
4298 *
4299 * \param TU the translation unit that owns the given tokens.
4300 *
4301 * \param Tokens the set of tokens to annotate.
4302 *
4303 * \param NumTokens the number of tokens in \p Tokens.
4304 *
4305 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4306 * replaced with the cursors corresponding to each token.
4307 */
4308CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4309                                         CXToken *Tokens, unsigned NumTokens,
4310                                         CXCursor *Cursors);
4311
4312/**
4313 * \brief Free the given set of tokens.
4314 */
4315CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4316                                        CXToken *Tokens, unsigned NumTokens);
4317
4318/**
4319 * @}
4320 */
4321
4322/**
4323 * \defgroup CINDEX_DEBUG Debugging facilities
4324 *
4325 * These routines are used for testing and debugging, only, and should not
4326 * be relied upon.
4327 *
4328 * @{
4329 */
4330
4331/* for debug/testing */
4332CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4333CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4334                                          const char **startBuf,
4335                                          const char **endBuf,
4336                                          unsigned *startLine,
4337                                          unsigned *startColumn,
4338                                          unsigned *endLine,
4339                                          unsigned *endColumn);
4340CINDEX_LINKAGE void clang_enableStackTraces(void);
4341CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4342                                          unsigned stack_size);
4343
4344/**
4345 * @}
4346 */
4347
4348/**
4349 * \defgroup CINDEX_CODE_COMPLET Code completion
4350 *
4351 * Code completion involves taking an (incomplete) source file, along with
4352 * knowledge of where the user is actively editing that file, and suggesting
4353 * syntactically- and semantically-valid constructs that the user might want to
4354 * use at that particular point in the source code. These data structures and
4355 * routines provide support for code completion.
4356 *
4357 * @{
4358 */
4359
4360/**
4361 * \brief A semantic string that describes a code-completion result.
4362 *
4363 * A semantic string that describes the formatting of a code-completion
4364 * result as a single "template" of text that should be inserted into the
4365 * source buffer when a particular code-completion result is selected.
4366 * Each semantic string is made up of some number of "chunks", each of which
4367 * contains some text along with a description of what that text means, e.g.,
4368 * the name of the entity being referenced, whether the text chunk is part of
4369 * the template, or whether it is a "placeholder" that the user should replace
4370 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4371 * description of the different kinds of chunks.
4372 */
4373typedef void *CXCompletionString;
4374
4375/**
4376 * \brief A single result of code completion.
4377 */
4378typedef struct {
4379  /**
4380   * \brief The kind of entity that this completion refers to.
4381   *
4382   * The cursor kind will be a macro, keyword, or a declaration (one of the
4383   * *Decl cursor kinds), describing the entity that the completion is
4384   * referring to.
4385   *
4386   * \todo In the future, we would like to provide a full cursor, to allow
4387   * the client to extract additional information from declaration.
4388   */
4389  enum CXCursorKind CursorKind;
4390
4391  /**
4392   * \brief The code-completion string that describes how to insert this
4393   * code-completion result into the editing buffer.
4394   */
4395  CXCompletionString CompletionString;
4396} CXCompletionResult;
4397
4398/**
4399 * \brief Describes a single piece of text within a code-completion string.
4400 *
4401 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4402 * either a piece of text with a specific "kind" that describes how that text
4403 * should be interpreted by the client or is another completion string.
4404 */
4405enum CXCompletionChunkKind {
4406  /**
4407   * \brief A code-completion string that describes "optional" text that
4408   * could be a part of the template (but is not required).
4409   *
4410   * The Optional chunk is the only kind of chunk that has a code-completion
4411   * string for its representation, which is accessible via
4412   * \c clang_getCompletionChunkCompletionString(). The code-completion string
4413   * describes an additional part of the template that is completely optional.
4414   * For example, optional chunks can be used to describe the placeholders for
4415   * arguments that match up with defaulted function parameters, e.g. given:
4416   *
4417   * \code
4418   * void f(int x, float y = 3.14, double z = 2.71828);
4419   * \endcode
4420   *
4421   * The code-completion string for this function would contain:
4422   *   - a TypedText chunk for "f".
4423   *   - a LeftParen chunk for "(".
4424   *   - a Placeholder chunk for "int x"
4425   *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
4426   *       - a Comma chunk for ","
4427   *       - a Placeholder chunk for "float y"
4428   *       - an Optional chunk containing the last defaulted argument:
4429   *           - a Comma chunk for ","
4430   *           - a Placeholder chunk for "double z"
4431   *   - a RightParen chunk for ")"
4432   *
4433   * There are many ways to handle Optional chunks. Two simple approaches are:
4434   *   - Completely ignore optional chunks, in which case the template for the
4435   *     function "f" would only include the first parameter ("int x").
4436   *   - Fully expand all optional chunks, in which case the template for the
4437   *     function "f" would have all of the parameters.
4438   */
4439  CXCompletionChunk_Optional,
4440  /**
4441   * \brief Text that a user would be expected to type to get this
4442   * code-completion result.
4443   *
4444   * There will be exactly one "typed text" chunk in a semantic string, which
4445   * will typically provide the spelling of a keyword or the name of a
4446   * declaration that could be used at the current code point. Clients are
4447   * expected to filter the code-completion results based on the text in this
4448   * chunk.
4449   */
4450  CXCompletionChunk_TypedText,
4451  /**
4452   * \brief Text that should be inserted as part of a code-completion result.
4453   *
4454   * A "text" chunk represents text that is part of the template to be
4455   * inserted into user code should this particular code-completion result
4456   * be selected.
4457   */
4458  CXCompletionChunk_Text,
4459  /**
4460   * \brief Placeholder text that should be replaced by the user.
4461   *
4462   * A "placeholder" chunk marks a place where the user should insert text
4463   * into the code-completion template. For example, placeholders might mark
4464   * the function parameters for a function declaration, to indicate that the
4465   * user should provide arguments for each of those parameters. The actual
4466   * text in a placeholder is a suggestion for the text to display before
4467   * the user replaces the placeholder with real code.
4468   */
4469  CXCompletionChunk_Placeholder,
4470  /**
4471   * \brief Informative text that should be displayed but never inserted as
4472   * part of the template.
4473   *
4474   * An "informative" chunk contains annotations that can be displayed to
4475   * help the user decide whether a particular code-completion result is the
4476   * right option, but which is not part of the actual template to be inserted
4477   * by code completion.
4478   */
4479  CXCompletionChunk_Informative,
4480  /**
4481   * \brief Text that describes the current parameter when code-completion is
4482   * referring to function call, message send, or template specialization.
4483   *
4484   * A "current parameter" chunk occurs when code-completion is providing
4485   * information about a parameter corresponding to the argument at the
4486   * code-completion point. For example, given a function
4487   *
4488   * \code
4489   * int add(int x, int y);
4490   * \endcode
4491   *
4492   * and the source code \c add(, where the code-completion point is after the
4493   * "(", the code-completion string will contain a "current parameter" chunk
4494   * for "int x", indicating that the current argument will initialize that
4495   * parameter. After typing further, to \c add(17, (where the code-completion
4496   * point is after the ","), the code-completion string will contain a
4497   * "current paremeter" chunk to "int y".
4498   */
4499  CXCompletionChunk_CurrentParameter,
4500  /**
4501   * \brief A left parenthesis ('('), used to initiate a function call or
4502   * signal the beginning of a function parameter list.
4503   */
4504  CXCompletionChunk_LeftParen,
4505  /**
4506   * \brief A right parenthesis (')'), used to finish a function call or
4507   * signal the end of a function parameter list.
4508   */
4509  CXCompletionChunk_RightParen,
4510  /**
4511   * \brief A left bracket ('[').
4512   */
4513  CXCompletionChunk_LeftBracket,
4514  /**
4515   * \brief A right bracket (']').
4516   */
4517  CXCompletionChunk_RightBracket,
4518  /**
4519   * \brief A left brace ('{').
4520   */
4521  CXCompletionChunk_LeftBrace,
4522  /**
4523   * \brief A right brace ('}').
4524   */
4525  CXCompletionChunk_RightBrace,
4526  /**
4527   * \brief A left angle bracket ('<').
4528   */
4529  CXCompletionChunk_LeftAngle,
4530  /**
4531   * \brief A right angle bracket ('>').
4532   */
4533  CXCompletionChunk_RightAngle,
4534  /**
4535   * \brief A comma separator (',').
4536   */
4537  CXCompletionChunk_Comma,
4538  /**
4539   * \brief Text that specifies the result type of a given result.
4540   *
4541   * This special kind of informative chunk is not meant to be inserted into
4542   * the text buffer. Rather, it is meant to illustrate the type that an
4543   * expression using the given completion string would have.
4544   */
4545  CXCompletionChunk_ResultType,
4546  /**
4547   * \brief A colon (':').
4548   */
4549  CXCompletionChunk_Colon,
4550  /**
4551   * \brief A semicolon (';').
4552   */
4553  CXCompletionChunk_SemiColon,
4554  /**
4555   * \brief An '=' sign.
4556   */
4557  CXCompletionChunk_Equal,
4558  /**
4559   * Horizontal space (' ').
4560   */
4561  CXCompletionChunk_HorizontalSpace,
4562  /**
4563   * Vertical space ('\n'), after which it is generally a good idea to
4564   * perform indentation.
4565   */
4566  CXCompletionChunk_VerticalSpace
4567};
4568
4569/**
4570 * \brief Determine the kind of a particular chunk within a completion string.
4571 *
4572 * \param completion_string the completion string to query.
4573 *
4574 * \param chunk_number the 0-based index of the chunk in the completion string.
4575 *
4576 * \returns the kind of the chunk at the index \c chunk_number.
4577 */
4578CINDEX_LINKAGE enum CXCompletionChunkKind
4579clang_getCompletionChunkKind(CXCompletionString completion_string,
4580                             unsigned chunk_number);
4581
4582/**
4583 * \brief Retrieve the text associated with a particular chunk within a
4584 * completion string.
4585 *
4586 * \param completion_string the completion string to query.
4587 *
4588 * \param chunk_number the 0-based index of the chunk in the completion string.
4589 *
4590 * \returns the text associated with the chunk at index \c chunk_number.
4591 */
4592CINDEX_LINKAGE CXString
4593clang_getCompletionChunkText(CXCompletionString completion_string,
4594                             unsigned chunk_number);
4595
4596/**
4597 * \brief Retrieve the completion string associated with a particular chunk
4598 * within a completion string.
4599 *
4600 * \param completion_string the completion string to query.
4601 *
4602 * \param chunk_number the 0-based index of the chunk in the completion string.
4603 *
4604 * \returns the completion string associated with the chunk at index
4605 * \c chunk_number.
4606 */
4607CINDEX_LINKAGE CXCompletionString
4608clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4609                                         unsigned chunk_number);
4610
4611/**
4612 * \brief Retrieve the number of chunks in the given code-completion string.
4613 */
4614CINDEX_LINKAGE unsigned
4615clang_getNumCompletionChunks(CXCompletionString completion_string);
4616
4617/**
4618 * \brief Determine the priority of this code completion.
4619 *
4620 * The priority of a code completion indicates how likely it is that this
4621 * particular completion is the completion that the user will select. The
4622 * priority is selected by various internal heuristics.
4623 *
4624 * \param completion_string The completion string to query.
4625 *
4626 * \returns The priority of this completion string. Smaller values indicate
4627 * higher-priority (more likely) completions.
4628 */
4629CINDEX_LINKAGE unsigned
4630clang_getCompletionPriority(CXCompletionString completion_string);
4631
4632/**
4633 * \brief Determine the availability of the entity that this code-completion
4634 * string refers to.
4635 *
4636 * \param completion_string The completion string to query.
4637 *
4638 * \returns The availability of the completion string.
4639 */
4640CINDEX_LINKAGE enum CXAvailabilityKind
4641clang_getCompletionAvailability(CXCompletionString completion_string);
4642
4643/**
4644 * \brief Retrieve the number of annotations associated with the given
4645 * completion string.
4646 *
4647 * \param completion_string the completion string to query.
4648 *
4649 * \returns the number of annotations associated with the given completion
4650 * string.
4651 */
4652CINDEX_LINKAGE unsigned
4653clang_getCompletionNumAnnotations(CXCompletionString completion_string);
4654
4655/**
4656 * \brief Retrieve the annotation associated with the given completion string.
4657 *
4658 * \param completion_string the completion string to query.
4659 *
4660 * \param annotation_number the 0-based index of the annotation of the
4661 * completion string.
4662 *
4663 * \returns annotation string associated with the completion at index
4664 * \c annotation_number, or a NULL string if that annotation is not available.
4665 */
4666CINDEX_LINKAGE CXString
4667clang_getCompletionAnnotation(CXCompletionString completion_string,
4668                              unsigned annotation_number);
4669
4670/**
4671 * \brief Retrieve the parent context of the given completion string.
4672 *
4673 * The parent context of a completion string is the semantic parent of
4674 * the declaration (if any) that the code completion represents. For example,
4675 * a code completion for an Objective-C method would have the method's class
4676 * or protocol as its context.
4677 *
4678 * \param completion_string The code completion string whose parent is
4679 * being queried.
4680 *
4681 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
4682 *
4683 * \returns The name of the completion parent, e.g., "NSObject" if
4684 * the completion string represents a method in the NSObject class.
4685 */
4686CINDEX_LINKAGE CXString
4687clang_getCompletionParent(CXCompletionString completion_string,
4688                          enum CXCursorKind *kind);
4689
4690/**
4691 * \brief Retrieve the brief documentation comment attached to the declaration
4692 * that corresponds to the given completion string.
4693 */
4694CINDEX_LINKAGE CXString
4695clang_getCompletionBriefComment(CXCompletionString completion_string);
4696
4697/**
4698 * \brief Retrieve a completion string for an arbitrary declaration or macro
4699 * definition cursor.
4700 *
4701 * \param cursor The cursor to query.
4702 *
4703 * \returns A non-context-sensitive completion string for declaration and macro
4704 * definition cursors, or NULL for other kinds of cursors.
4705 */
4706CINDEX_LINKAGE CXCompletionString
4707clang_getCursorCompletionString(CXCursor cursor);
4708
4709/**
4710 * \brief Contains the results of code-completion.
4711 *
4712 * This data structure contains the results of code completion, as
4713 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
4714 * \c clang_disposeCodeCompleteResults.
4715 */
4716typedef struct {
4717  /**
4718   * \brief The code-completion results.
4719   */
4720  CXCompletionResult *Results;
4721
4722  /**
4723   * \brief The number of code-completion results stored in the
4724   * \c Results array.
4725   */
4726  unsigned NumResults;
4727} CXCodeCompleteResults;
4728
4729/**
4730 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
4731 * modify its behavior.
4732 *
4733 * The enumerators in this enumeration can be bitwise-OR'd together to
4734 * provide multiple options to \c clang_codeCompleteAt().
4735 */
4736enum CXCodeComplete_Flags {
4737  /**
4738   * \brief Whether to include macros within the set of code
4739   * completions returned.
4740   */
4741  CXCodeComplete_IncludeMacros = 0x01,
4742
4743  /**
4744   * \brief Whether to include code patterns for language constructs
4745   * within the set of code completions, e.g., for loops.
4746   */
4747  CXCodeComplete_IncludeCodePatterns = 0x02,
4748
4749  /**
4750   * \brief Whether to include brief documentation within the set of code
4751   * completions returned.
4752   */
4753  CXCodeComplete_IncludeBriefComments = 0x04
4754};
4755
4756/**
4757 * \brief Bits that represent the context under which completion is occurring.
4758 *
4759 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
4760 * contexts are occurring simultaneously.
4761 */
4762enum CXCompletionContext {
4763  /**
4764   * \brief The context for completions is unexposed, as only Clang results
4765   * should be included. (This is equivalent to having no context bits set.)
4766   */
4767  CXCompletionContext_Unexposed = 0,
4768
4769  /**
4770   * \brief Completions for any possible type should be included in the results.
4771   */
4772  CXCompletionContext_AnyType = 1 << 0,
4773
4774  /**
4775   * \brief Completions for any possible value (variables, function calls, etc.)
4776   * should be included in the results.
4777   */
4778  CXCompletionContext_AnyValue = 1 << 1,
4779  /**
4780   * \brief Completions for values that resolve to an Objective-C object should
4781   * be included in the results.
4782   */
4783  CXCompletionContext_ObjCObjectValue = 1 << 2,
4784  /**
4785   * \brief Completions for values that resolve to an Objective-C selector
4786   * should be included in the results.
4787   */
4788  CXCompletionContext_ObjCSelectorValue = 1 << 3,
4789  /**
4790   * \brief Completions for values that resolve to a C++ class type should be
4791   * included in the results.
4792   */
4793  CXCompletionContext_CXXClassTypeValue = 1 << 4,
4794
4795  /**
4796   * \brief Completions for fields of the member being accessed using the dot
4797   * operator should be included in the results.
4798   */
4799  CXCompletionContext_DotMemberAccess = 1 << 5,
4800  /**
4801   * \brief Completions for fields of the member being accessed using the arrow
4802   * operator should be included in the results.
4803   */
4804  CXCompletionContext_ArrowMemberAccess = 1 << 6,
4805  /**
4806   * \brief Completions for properties of the Objective-C object being accessed
4807   * using the dot operator should be included in the results.
4808   */
4809  CXCompletionContext_ObjCPropertyAccess = 1 << 7,
4810
4811  /**
4812   * \brief Completions for enum tags should be included in the results.
4813   */
4814  CXCompletionContext_EnumTag = 1 << 8,
4815  /**
4816   * \brief Completions for union tags should be included in the results.
4817   */
4818  CXCompletionContext_UnionTag = 1 << 9,
4819  /**
4820   * \brief Completions for struct tags should be included in the results.
4821   */
4822  CXCompletionContext_StructTag = 1 << 10,
4823
4824  /**
4825   * \brief Completions for C++ class names should be included in the results.
4826   */
4827  CXCompletionContext_ClassTag = 1 << 11,
4828  /**
4829   * \brief Completions for C++ namespaces and namespace aliases should be
4830   * included in the results.
4831   */
4832  CXCompletionContext_Namespace = 1 << 12,
4833  /**
4834   * \brief Completions for C++ nested name specifiers should be included in
4835   * the results.
4836   */
4837  CXCompletionContext_NestedNameSpecifier = 1 << 13,
4838
4839  /**
4840   * \brief Completions for Objective-C interfaces (classes) should be included
4841   * in the results.
4842   */
4843  CXCompletionContext_ObjCInterface = 1 << 14,
4844  /**
4845   * \brief Completions for Objective-C protocols should be included in
4846   * the results.
4847   */
4848  CXCompletionContext_ObjCProtocol = 1 << 15,
4849  /**
4850   * \brief Completions for Objective-C categories should be included in
4851   * the results.
4852   */
4853  CXCompletionContext_ObjCCategory = 1 << 16,
4854  /**
4855   * \brief Completions for Objective-C instance messages should be included
4856   * in the results.
4857   */
4858  CXCompletionContext_ObjCInstanceMessage = 1 << 17,
4859  /**
4860   * \brief Completions for Objective-C class messages should be included in
4861   * the results.
4862   */
4863  CXCompletionContext_ObjCClassMessage = 1 << 18,
4864  /**
4865   * \brief Completions for Objective-C selector names should be included in
4866   * the results.
4867   */
4868  CXCompletionContext_ObjCSelectorName = 1 << 19,
4869
4870  /**
4871   * \brief Completions for preprocessor macro names should be included in
4872   * the results.
4873   */
4874  CXCompletionContext_MacroName = 1 << 20,
4875
4876  /**
4877   * \brief Natural language completions should be included in the results.
4878   */
4879  CXCompletionContext_NaturalLanguage = 1 << 21,
4880
4881  /**
4882   * \brief The current context is unknown, so set all contexts.
4883   */
4884  CXCompletionContext_Unknown = ((1 << 22) - 1)
4885};
4886
4887/**
4888 * \brief Returns a default set of code-completion options that can be
4889 * passed to\c clang_codeCompleteAt().
4890 */
4891CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
4892
4893/**
4894 * \brief Perform code completion at a given location in a translation unit.
4895 *
4896 * This function performs code completion at a particular file, line, and
4897 * column within source code, providing results that suggest potential
4898 * code snippets based on the context of the completion. The basic model
4899 * for code completion is that Clang will parse a complete source file,
4900 * performing syntax checking up to the location where code-completion has
4901 * been requested. At that point, a special code-completion token is passed
4902 * to the parser, which recognizes this token and determines, based on the
4903 * current location in the C/Objective-C/C++ grammar and the state of
4904 * semantic analysis, what completions to provide. These completions are
4905 * returned via a new \c CXCodeCompleteResults structure.
4906 *
4907 * Code completion itself is meant to be triggered by the client when the
4908 * user types punctuation characters or whitespace, at which point the
4909 * code-completion location will coincide with the cursor. For example, if \c p
4910 * is a pointer, code-completion might be triggered after the "-" and then
4911 * after the ">" in \c p->. When the code-completion location is afer the ">",
4912 * the completion results will provide, e.g., the members of the struct that
4913 * "p" points to. The client is responsible for placing the cursor at the
4914 * beginning of the token currently being typed, then filtering the results
4915 * based on the contents of the token. For example, when code-completing for
4916 * the expression \c p->get, the client should provide the location just after
4917 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
4918 * client can filter the results based on the current token text ("get"), only
4919 * showing those results that start with "get". The intent of this interface
4920 * is to separate the relatively high-latency acquisition of code-completion
4921 * results from the filtering of results on a per-character basis, which must
4922 * have a lower latency.
4923 *
4924 * \param TU The translation unit in which code-completion should
4925 * occur. The source files for this translation unit need not be
4926 * completely up-to-date (and the contents of those source files may
4927 * be overridden via \p unsaved_files). Cursors referring into the
4928 * translation unit may be invalidated by this invocation.
4929 *
4930 * \param complete_filename The name of the source file where code
4931 * completion should be performed. This filename may be any file
4932 * included in the translation unit.
4933 *
4934 * \param complete_line The line at which code-completion should occur.
4935 *
4936 * \param complete_column The column at which code-completion should occur.
4937 * Note that the column should point just after the syntactic construct that
4938 * initiated code completion, and not in the middle of a lexical token.
4939 *
4940 * \param unsaved_files the Tiles that have not yet been saved to disk
4941 * but may be required for parsing or code completion, including the
4942 * contents of those files.  The contents and name of these files (as
4943 * specified by CXUnsavedFile) are copied when necessary, so the
4944 * client only needs to guarantee their validity until the call to
4945 * this function returns.
4946 *
4947 * \param num_unsaved_files The number of unsaved file entries in \p
4948 * unsaved_files.
4949 *
4950 * \param options Extra options that control the behavior of code
4951 * completion, expressed as a bitwise OR of the enumerators of the
4952 * CXCodeComplete_Flags enumeration. The
4953 * \c clang_defaultCodeCompleteOptions() function returns a default set
4954 * of code-completion options.
4955 *
4956 * \returns If successful, a new \c CXCodeCompleteResults structure
4957 * containing code-completion results, which should eventually be
4958 * freed with \c clang_disposeCodeCompleteResults(). If code
4959 * completion fails, returns NULL.
4960 */
4961CINDEX_LINKAGE
4962CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
4963                                            const char *complete_filename,
4964                                            unsigned complete_line,
4965                                            unsigned complete_column,
4966                                            struct CXUnsavedFile *unsaved_files,
4967                                            unsigned num_unsaved_files,
4968                                            unsigned options);
4969
4970/**
4971 * \brief Sort the code-completion results in case-insensitive alphabetical
4972 * order.
4973 *
4974 * \param Results The set of results to sort.
4975 * \param NumResults The number of results in \p Results.
4976 */
4977CINDEX_LINKAGE
4978void clang_sortCodeCompletionResults(CXCompletionResult *Results,
4979                                     unsigned NumResults);
4980
4981/**
4982 * \brief Free the given set of code-completion results.
4983 */
4984CINDEX_LINKAGE
4985void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
4986
4987/**
4988 * \brief Determine the number of diagnostics produced prior to the
4989 * location where code completion was performed.
4990 */
4991CINDEX_LINKAGE
4992unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
4993
4994/**
4995 * \brief Retrieve a diagnostic associated with the given code completion.
4996 *
4997 * \param Results the code completion results to query.
4998 * \param Index the zero-based diagnostic number to retrieve.
4999 *
5000 * \returns the requested diagnostic. This diagnostic must be freed
5001 * via a call to \c clang_disposeDiagnostic().
5002 */
5003CINDEX_LINKAGE
5004CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5005                                             unsigned Index);
5006
5007/**
5008 * \brief Determines what compeltions are appropriate for the context
5009 * the given code completion.
5010 *
5011 * \param Results the code completion results to query
5012 *
5013 * \returns the kinds of completions that are appropriate for use
5014 * along with the given code completion results.
5015 */
5016CINDEX_LINKAGE
5017unsigned long long clang_codeCompleteGetContexts(
5018                                                CXCodeCompleteResults *Results);
5019
5020/**
5021 * \brief Returns the cursor kind for the container for the current code
5022 * completion context. The container is only guaranteed to be set for
5023 * contexts where a container exists (i.e. member accesses or Objective-C
5024 * message sends); if there is not a container, this function will return
5025 * CXCursor_InvalidCode.
5026 *
5027 * \param Results the code completion results to query
5028 *
5029 * \param IsIncomplete on return, this value will be false if Clang has complete
5030 * information about the container. If Clang does not have complete
5031 * information, this value will be true.
5032 *
5033 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5034 * container
5035 */
5036CINDEX_LINKAGE
5037enum CXCursorKind clang_codeCompleteGetContainerKind(
5038                                                 CXCodeCompleteResults *Results,
5039                                                     unsigned *IsIncomplete);
5040
5041/**
5042 * \brief Returns the USR for the container for the current code completion
5043 * context. If there is not a container for the current context, this
5044 * function will return the empty string.
5045 *
5046 * \param Results the code completion results to query
5047 *
5048 * \returns the USR for the container
5049 */
5050CINDEX_LINKAGE
5051CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5052
5053
5054/**
5055 * \brief Returns the currently-entered selector for an Objective-C message
5056 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5057 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5058 * CXCompletionContext_ObjCClassMessage.
5059 *
5060 * \param Results the code completion results to query
5061 *
5062 * \returns the selector (or partial selector) that has been entered thus far
5063 * for an Objective-C message send.
5064 */
5065CINDEX_LINKAGE
5066CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5067
5068/**
5069 * @}
5070 */
5071
5072
5073/**
5074 * \defgroup CINDEX_MISC Miscellaneous utility functions
5075 *
5076 * @{
5077 */
5078
5079/**
5080 * \brief Return a version string, suitable for showing to a user, but not
5081 *        intended to be parsed (the format is not guaranteed to be stable).
5082 */
5083CINDEX_LINKAGE CXString clang_getClangVersion(void);
5084
5085
5086/**
5087 * \brief Enable/disable crash recovery.
5088 *
5089 * \param isEnabled Flag to indicate if crash recovery is enabled.  A non-zero
5090 *        value enables crash recovery, while 0 disables it.
5091 */
5092CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5093
5094 /**
5095  * \brief Visitor invoked for each file in a translation unit
5096  *        (used with clang_getInclusions()).
5097  *
5098  * This visitor function will be invoked by clang_getInclusions() for each
5099  * file included (either at the top-level or by \#include directives) within
5100  * a translation unit.  The first argument is the file being included, and
5101  * the second and third arguments provide the inclusion stack.  The
5102  * array is sorted in order of immediate inclusion.  For example,
5103  * the first element refers to the location that included 'included_file'.
5104  */
5105typedef void (*CXInclusionVisitor)(CXFile included_file,
5106                                   CXSourceLocation* inclusion_stack,
5107                                   unsigned include_len,
5108                                   CXClientData client_data);
5109
5110/**
5111 * \brief Visit the set of preprocessor inclusions in a translation unit.
5112 *   The visitor function is called with the provided data for every included
5113 *   file.  This does not include headers included by the PCH file (unless one
5114 *   is inspecting the inclusions in the PCH file itself).
5115 */
5116CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5117                                        CXInclusionVisitor visitor,
5118                                        CXClientData client_data);
5119
5120/**
5121 * @}
5122 */
5123
5124/** \defgroup CINDEX_REMAPPING Remapping functions
5125 *
5126 * @{
5127 */
5128
5129/**
5130 * \brief A remapping of original source files and their translated files.
5131 */
5132typedef void *CXRemapping;
5133
5134/**
5135 * \brief Retrieve a remapping.
5136 *
5137 * \param path the path that contains metadata about remappings.
5138 *
5139 * \returns the requested remapping. This remapping must be freed
5140 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5141 */
5142CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5143
5144/**
5145 * \brief Retrieve a remapping.
5146 *
5147 * \param filePaths pointer to an array of file paths containing remapping info.
5148 *
5149 * \param numFiles number of file paths.
5150 *
5151 * \returns the requested remapping. This remapping must be freed
5152 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5153 */
5154CINDEX_LINKAGE
5155CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5156                                            unsigned numFiles);
5157
5158/**
5159 * \brief Determine the number of remappings.
5160 */
5161CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5162
5163/**
5164 * \brief Get the original and the associated filename from the remapping.
5165 *
5166 * \param original If non-NULL, will be set to the original filename.
5167 *
5168 * \param transformed If non-NULL, will be set to the filename that the original
5169 * is associated with.
5170 */
5171CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5172                                     CXString *original, CXString *transformed);
5173
5174/**
5175 * \brief Dispose the remapping.
5176 */
5177CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5178
5179/**
5180 * @}
5181 */
5182
5183/** \defgroup CINDEX_HIGH Higher level API functions
5184 *
5185 * @{
5186 */
5187
5188enum CXVisitorResult {
5189  CXVisit_Break,
5190  CXVisit_Continue
5191};
5192
5193typedef struct {
5194  void *context;
5195  enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5196} CXCursorAndRangeVisitor;
5197
5198typedef enum {
5199  /**
5200   * \brief Function returned successfully.
5201   */
5202  CXResult_Success = 0,
5203  /**
5204   * \brief One of the parameters was invalid for the function.
5205   */
5206  CXResult_Invalid = 1,
5207  /**
5208   * \brief The function was terminated by a callback (e.g. it returned
5209   * CXVisit_Break)
5210   */
5211  CXResult_VisitBreak = 2
5212
5213} CXResult;
5214
5215/**
5216 * \brief Find references of a declaration in a specific file.
5217 *
5218 * \param cursor pointing to a declaration or a reference of one.
5219 *
5220 * \param file to search for references.
5221 *
5222 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5223 * each reference found.
5224 * The CXSourceRange will point inside the file; if the reference is inside
5225 * a macro (and not a macro argument) the CXSourceRange will be invalid.
5226 *
5227 * \returns one of the CXResult enumerators.
5228 */
5229CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5230                                               CXCursorAndRangeVisitor visitor);
5231
5232/**
5233 * \brief Find #import/#include directives in a specific file.
5234 *
5235 * \param TU translation unit containing the file to query.
5236 *
5237 * \param file to search for #import/#include directives.
5238 *
5239 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5240 * each directive found.
5241 *
5242 * \returns one of the CXResult enumerators.
5243 */
5244CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5245                                                 CXFile file,
5246                                              CXCursorAndRangeVisitor visitor);
5247
5248#ifdef __has_feature
5249#  if __has_feature(blocks)
5250
5251typedef enum CXVisitorResult
5252    (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5253
5254CINDEX_LINKAGE
5255CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5256                                             CXCursorAndRangeVisitorBlock);
5257
5258CINDEX_LINKAGE
5259CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5260                                           CXCursorAndRangeVisitorBlock);
5261
5262#  endif
5263#endif
5264
5265/**
5266 * \brief The client's data object that is associated with a CXFile.
5267 */
5268typedef void *CXIdxClientFile;
5269
5270/**
5271 * \brief The client's data object that is associated with a semantic entity.
5272 */
5273typedef void *CXIdxClientEntity;
5274
5275/**
5276 * \brief The client's data object that is associated with a semantic container
5277 * of entities.
5278 */
5279typedef void *CXIdxClientContainer;
5280
5281/**
5282 * \brief The client's data object that is associated with an AST file (PCH
5283 * or module).
5284 */
5285typedef void *CXIdxClientASTFile;
5286
5287/**
5288 * \brief Source location passed to index callbacks.
5289 */
5290typedef struct {
5291  void *ptr_data[2];
5292  unsigned int_data;
5293} CXIdxLoc;
5294
5295/**
5296 * \brief Data for ppIncludedFile callback.
5297 */
5298typedef struct {
5299  /**
5300   * \brief Location of '#' in the \#include/\#import directive.
5301   */
5302  CXIdxLoc hashLoc;
5303  /**
5304   * \brief Filename as written in the \#include/\#import directive.
5305   */
5306  const char *filename;
5307  /**
5308   * \brief The actual file that the \#include/\#import directive resolved to.
5309   */
5310  CXFile file;
5311  int isImport;
5312  int isAngled;
5313  /**
5314   * \brief Non-zero if the directive was automatically turned into a module
5315   * import.
5316   */
5317  int isModuleImport;
5318} CXIdxIncludedFileInfo;
5319
5320/**
5321 * \brief Data for IndexerCallbacks#importedASTFile.
5322 */
5323typedef struct {
5324  /**
5325   * \brief Top level AST file containing the imported PCH, module or submodule.
5326   */
5327  CXFile file;
5328  /**
5329   * \brief The imported module or NULL if the AST file is a PCH.
5330   */
5331  CXModule module;
5332  /**
5333   * \brief Location where the file is imported. Applicable only for modules.
5334   */
5335  CXIdxLoc loc;
5336  /**
5337   * \brief Non-zero if an inclusion directive was automatically turned into
5338   * a module import. Applicable only for modules.
5339   */
5340  int isImplicit;
5341
5342} CXIdxImportedASTFileInfo;
5343
5344typedef enum {
5345  CXIdxEntity_Unexposed     = 0,
5346  CXIdxEntity_Typedef       = 1,
5347  CXIdxEntity_Function      = 2,
5348  CXIdxEntity_Variable      = 3,
5349  CXIdxEntity_Field         = 4,
5350  CXIdxEntity_EnumConstant  = 5,
5351
5352  CXIdxEntity_ObjCClass     = 6,
5353  CXIdxEntity_ObjCProtocol  = 7,
5354  CXIdxEntity_ObjCCategory  = 8,
5355
5356  CXIdxEntity_ObjCInstanceMethod = 9,
5357  CXIdxEntity_ObjCClassMethod    = 10,
5358  CXIdxEntity_ObjCProperty  = 11,
5359  CXIdxEntity_ObjCIvar      = 12,
5360
5361  CXIdxEntity_Enum          = 13,
5362  CXIdxEntity_Struct        = 14,
5363  CXIdxEntity_Union         = 15,
5364
5365  CXIdxEntity_CXXClass              = 16,
5366  CXIdxEntity_CXXNamespace          = 17,
5367  CXIdxEntity_CXXNamespaceAlias     = 18,
5368  CXIdxEntity_CXXStaticVariable     = 19,
5369  CXIdxEntity_CXXStaticMethod       = 20,
5370  CXIdxEntity_CXXInstanceMethod     = 21,
5371  CXIdxEntity_CXXConstructor        = 22,
5372  CXIdxEntity_CXXDestructor         = 23,
5373  CXIdxEntity_CXXConversionFunction = 24,
5374  CXIdxEntity_CXXTypeAlias          = 25,
5375  CXIdxEntity_CXXInterface          = 26
5376
5377} CXIdxEntityKind;
5378
5379typedef enum {
5380  CXIdxEntityLang_None = 0,
5381  CXIdxEntityLang_C    = 1,
5382  CXIdxEntityLang_ObjC = 2,
5383  CXIdxEntityLang_CXX  = 3
5384} CXIdxEntityLanguage;
5385
5386/**
5387 * \brief Extra C++ template information for an entity. This can apply to:
5388 * CXIdxEntity_Function
5389 * CXIdxEntity_CXXClass
5390 * CXIdxEntity_CXXStaticMethod
5391 * CXIdxEntity_CXXInstanceMethod
5392 * CXIdxEntity_CXXConstructor
5393 * CXIdxEntity_CXXConversionFunction
5394 * CXIdxEntity_CXXTypeAlias
5395 */
5396typedef enum {
5397  CXIdxEntity_NonTemplate   = 0,
5398  CXIdxEntity_Template      = 1,
5399  CXIdxEntity_TemplatePartialSpecialization = 2,
5400  CXIdxEntity_TemplateSpecialization = 3
5401} CXIdxEntityCXXTemplateKind;
5402
5403typedef enum {
5404  CXIdxAttr_Unexposed     = 0,
5405  CXIdxAttr_IBAction      = 1,
5406  CXIdxAttr_IBOutlet      = 2,
5407  CXIdxAttr_IBOutletCollection = 3
5408} CXIdxAttrKind;
5409
5410typedef struct {
5411  CXIdxAttrKind kind;
5412  CXCursor cursor;
5413  CXIdxLoc loc;
5414} CXIdxAttrInfo;
5415
5416typedef struct {
5417  CXIdxEntityKind kind;
5418  CXIdxEntityCXXTemplateKind templateKind;
5419  CXIdxEntityLanguage lang;
5420  const char *name;
5421  const char *USR;
5422  CXCursor cursor;
5423  const CXIdxAttrInfo *const *attributes;
5424  unsigned numAttributes;
5425} CXIdxEntityInfo;
5426
5427typedef struct {
5428  CXCursor cursor;
5429} CXIdxContainerInfo;
5430
5431typedef struct {
5432  const CXIdxAttrInfo *attrInfo;
5433  const CXIdxEntityInfo *objcClass;
5434  CXCursor classCursor;
5435  CXIdxLoc classLoc;
5436} CXIdxIBOutletCollectionAttrInfo;
5437
5438typedef enum {
5439  CXIdxDeclFlag_Skipped = 0x1
5440} CXIdxDeclInfoFlags;
5441
5442typedef struct {
5443  const CXIdxEntityInfo *entityInfo;
5444  CXCursor cursor;
5445  CXIdxLoc loc;
5446  const CXIdxContainerInfo *semanticContainer;
5447  /**
5448   * \brief Generally same as #semanticContainer but can be different in
5449   * cases like out-of-line C++ member functions.
5450   */
5451  const CXIdxContainerInfo *lexicalContainer;
5452  int isRedeclaration;
5453  int isDefinition;
5454  int isContainer;
5455  const CXIdxContainerInfo *declAsContainer;
5456  /**
5457   * \brief Whether the declaration exists in code or was created implicitly
5458   * by the compiler, e.g. implicit objc methods for properties.
5459   */
5460  int isImplicit;
5461  const CXIdxAttrInfo *const *attributes;
5462  unsigned numAttributes;
5463
5464  unsigned flags;
5465
5466} CXIdxDeclInfo;
5467
5468typedef enum {
5469  CXIdxObjCContainer_ForwardRef = 0,
5470  CXIdxObjCContainer_Interface = 1,
5471  CXIdxObjCContainer_Implementation = 2
5472} CXIdxObjCContainerKind;
5473
5474typedef struct {
5475  const CXIdxDeclInfo *declInfo;
5476  CXIdxObjCContainerKind kind;
5477} CXIdxObjCContainerDeclInfo;
5478
5479typedef struct {
5480  const CXIdxEntityInfo *base;
5481  CXCursor cursor;
5482  CXIdxLoc loc;
5483} CXIdxBaseClassInfo;
5484
5485typedef struct {
5486  const CXIdxEntityInfo *protocol;
5487  CXCursor cursor;
5488  CXIdxLoc loc;
5489} CXIdxObjCProtocolRefInfo;
5490
5491typedef struct {
5492  const CXIdxObjCProtocolRefInfo *const *protocols;
5493  unsigned numProtocols;
5494} CXIdxObjCProtocolRefListInfo;
5495
5496typedef struct {
5497  const CXIdxObjCContainerDeclInfo *containerInfo;
5498  const CXIdxBaseClassInfo *superInfo;
5499  const CXIdxObjCProtocolRefListInfo *protocols;
5500} CXIdxObjCInterfaceDeclInfo;
5501
5502typedef struct {
5503  const CXIdxObjCContainerDeclInfo *containerInfo;
5504  const CXIdxEntityInfo *objcClass;
5505  CXCursor classCursor;
5506  CXIdxLoc classLoc;
5507  const CXIdxObjCProtocolRefListInfo *protocols;
5508} CXIdxObjCCategoryDeclInfo;
5509
5510typedef struct {
5511  const CXIdxDeclInfo *declInfo;
5512  const CXIdxEntityInfo *getter;
5513  const CXIdxEntityInfo *setter;
5514} CXIdxObjCPropertyDeclInfo;
5515
5516typedef struct {
5517  const CXIdxDeclInfo *declInfo;
5518  const CXIdxBaseClassInfo *const *bases;
5519  unsigned numBases;
5520} CXIdxCXXClassDeclInfo;
5521
5522/**
5523 * \brief Data for IndexerCallbacks#indexEntityReference.
5524 */
5525typedef enum {
5526  /**
5527   * \brief The entity is referenced directly in user's code.
5528   */
5529  CXIdxEntityRef_Direct = 1,
5530  /**
5531   * \brief An implicit reference, e.g. a reference of an ObjC method via the
5532   * dot syntax.
5533   */
5534  CXIdxEntityRef_Implicit = 2
5535} CXIdxEntityRefKind;
5536
5537/**
5538 * \brief Data for IndexerCallbacks#indexEntityReference.
5539 */
5540typedef struct {
5541  CXIdxEntityRefKind kind;
5542  /**
5543   * \brief Reference cursor.
5544   */
5545  CXCursor cursor;
5546  CXIdxLoc loc;
5547  /**
5548   * \brief The entity that gets referenced.
5549   */
5550  const CXIdxEntityInfo *referencedEntity;
5551  /**
5552   * \brief Immediate "parent" of the reference. For example:
5553   *
5554   * \code
5555   * Foo *var;
5556   * \endcode
5557   *
5558   * The parent of reference of type 'Foo' is the variable 'var'.
5559   * For references inside statement bodies of functions/methods,
5560   * the parentEntity will be the function/method.
5561   */
5562  const CXIdxEntityInfo *parentEntity;
5563  /**
5564   * \brief Lexical container context of the reference.
5565   */
5566  const CXIdxContainerInfo *container;
5567} CXIdxEntityRefInfo;
5568
5569/**
5570 * \brief A group of callbacks used by #clang_indexSourceFile and
5571 * #clang_indexTranslationUnit.
5572 */
5573typedef struct {
5574  /**
5575   * \brief Called periodically to check whether indexing should be aborted.
5576   * Should return 0 to continue, and non-zero to abort.
5577   */
5578  int (*abortQuery)(CXClientData client_data, void *reserved);
5579
5580  /**
5581   * \brief Called at the end of indexing; passes the complete diagnostic set.
5582   */
5583  void (*diagnostic)(CXClientData client_data,
5584                     CXDiagnosticSet, void *reserved);
5585
5586  CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
5587                                     CXFile mainFile, void *reserved);
5588
5589  /**
5590   * \brief Called when a file gets \#included/\#imported.
5591   */
5592  CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
5593                                    const CXIdxIncludedFileInfo *);
5594
5595  /**
5596   * \brief Called when a AST file (PCH or module) gets imported.
5597   *
5598   * AST files will not get indexed (there will not be callbacks to index all
5599   * the entities in an AST file). The recommended action is that, if the AST
5600   * file is not already indexed, to initiate a new indexing job specific to
5601   * the AST file.
5602   */
5603  CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
5604                                        const CXIdxImportedASTFileInfo *);
5605
5606  /**
5607   * \brief Called at the beginning of indexing a translation unit.
5608   */
5609  CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
5610                                                 void *reserved);
5611
5612  void (*indexDeclaration)(CXClientData client_data,
5613                           const CXIdxDeclInfo *);
5614
5615  /**
5616   * \brief Called to index a reference of an entity.
5617   */
5618  void (*indexEntityReference)(CXClientData client_data,
5619                               const CXIdxEntityRefInfo *);
5620
5621} IndexerCallbacks;
5622
5623CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
5624CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
5625clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
5626
5627CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
5628clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
5629
5630CINDEX_LINKAGE
5631const CXIdxObjCCategoryDeclInfo *
5632clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
5633
5634CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
5635clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
5636
5637CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
5638clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
5639
5640CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
5641clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
5642
5643CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
5644clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
5645
5646/**
5647 * \brief For retrieving a custom CXIdxClientContainer attached to a
5648 * container.
5649 */
5650CINDEX_LINKAGE CXIdxClientContainer
5651clang_index_getClientContainer(const CXIdxContainerInfo *);
5652
5653/**
5654 * \brief For setting a custom CXIdxClientContainer attached to a
5655 * container.
5656 */
5657CINDEX_LINKAGE void
5658clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
5659
5660/**
5661 * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
5662 */
5663CINDEX_LINKAGE CXIdxClientEntity
5664clang_index_getClientEntity(const CXIdxEntityInfo *);
5665
5666/**
5667 * \brief For setting a custom CXIdxClientEntity attached to an entity.
5668 */
5669CINDEX_LINKAGE void
5670clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
5671
5672/**
5673 * \brief An indexing action/session, to be applied to one or multiple
5674 * translation units.
5675 */
5676typedef void *CXIndexAction;
5677
5678/**
5679 * \brief An indexing action/session, to be applied to one or multiple
5680 * translation units.
5681 *
5682 * \param CIdx The index object with which the index action will be associated.
5683 */
5684CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
5685
5686/**
5687 * \brief Destroy the given index action.
5688 *
5689 * The index action must not be destroyed until all of the translation units
5690 * created within that index action have been destroyed.
5691 */
5692CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
5693
5694typedef enum {
5695  /**
5696   * \brief Used to indicate that no special indexing options are needed.
5697   */
5698  CXIndexOpt_None = 0x0,
5699
5700  /**
5701   * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
5702   * be invoked for only one reference of an entity per source file that does
5703   * not also include a declaration/definition of the entity.
5704   */
5705  CXIndexOpt_SuppressRedundantRefs = 0x1,
5706
5707  /**
5708   * \brief Function-local symbols should be indexed. If this is not set
5709   * function-local symbols will be ignored.
5710   */
5711  CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
5712
5713  /**
5714   * \brief Implicit function/class template instantiations should be indexed.
5715   * If this is not set, implicit instantiations will be ignored.
5716   */
5717  CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
5718
5719  /**
5720   * \brief Suppress all compiler warnings when parsing for indexing.
5721   */
5722  CXIndexOpt_SuppressWarnings = 0x8,
5723
5724  /**
5725   * \brief Skip a function/method body that was already parsed during an
5726   * indexing session assosiated with a \c CXIndexAction object.
5727   * Bodies in system headers are always skipped.
5728   */
5729  CXIndexOpt_SkipParsedBodiesInSession = 0x10
5730
5731} CXIndexOptFlags;
5732
5733/**
5734 * \brief Index the given source file and the translation unit corresponding
5735 * to that file via callbacks implemented through #IndexerCallbacks.
5736 *
5737 * \param client_data pointer data supplied by the client, which will
5738 * be passed to the invoked callbacks.
5739 *
5740 * \param index_callbacks Pointer to indexing callbacks that the client
5741 * implements.
5742 *
5743 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
5744 * passed in index_callbacks.
5745 *
5746 * \param index_options A bitmask of options that affects how indexing is
5747 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
5748 *
5749 * \param out_TU [out] pointer to store a CXTranslationUnit that can be reused
5750 * after indexing is finished. Set to NULL if you do not require it.
5751 *
5752 * \returns If there is a failure from which the there is no recovery, returns
5753 * non-zero, otherwise returns 0.
5754 *
5755 * The rest of the parameters are the same as #clang_parseTranslationUnit.
5756 */
5757CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
5758                                         CXClientData client_data,
5759                                         IndexerCallbacks *index_callbacks,
5760                                         unsigned index_callbacks_size,
5761                                         unsigned index_options,
5762                                         const char *source_filename,
5763                                         const char * const *command_line_args,
5764                                         int num_command_line_args,
5765                                         struct CXUnsavedFile *unsaved_files,
5766                                         unsigned num_unsaved_files,
5767                                         CXTranslationUnit *out_TU,
5768                                         unsigned TU_options);
5769
5770/**
5771 * \brief Index the given translation unit via callbacks implemented through
5772 * #IndexerCallbacks.
5773 *
5774 * The order of callback invocations is not guaranteed to be the same as
5775 * when indexing a source file. The high level order will be:
5776 *
5777 *   -Preprocessor callbacks invocations
5778 *   -Declaration/reference callbacks invocations
5779 *   -Diagnostic callback invocations
5780 *
5781 * The parameters are the same as #clang_indexSourceFile.
5782 *
5783 * \returns If there is a failure from which the there is no recovery, returns
5784 * non-zero, otherwise returns 0.
5785 */
5786CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
5787                                              CXClientData client_data,
5788                                              IndexerCallbacks *index_callbacks,
5789                                              unsigned index_callbacks_size,
5790                                              unsigned index_options,
5791                                              CXTranslationUnit);
5792
5793/**
5794 * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
5795 * the given CXIdxLoc.
5796 *
5797 * If the location refers into a macro expansion, retrieves the
5798 * location of the macro expansion and if it refers into a macro argument
5799 * retrieves the location of the argument.
5800 */
5801CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
5802                                                   CXIdxClientFile *indexFile,
5803                                                   CXFile *file,
5804                                                   unsigned *line,
5805                                                   unsigned *column,
5806                                                   unsigned *offset);
5807
5808/**
5809 * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
5810 */
5811CINDEX_LINKAGE
5812CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
5813
5814/**
5815 * @}
5816 */
5817
5818/**
5819 * @}
5820 */
5821
5822#ifdef __cplusplus
5823}
5824#endif
5825#endif
5826
5827