clang API Documentation

Index.h
Go to the documentation of this file.
00001 /*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
00002 |*                                                                            *|
00003 |*                     The LLVM Compiler Infrastructure                       *|
00004 |*                                                                            *|
00005 |* This file is distributed under the University of Illinois Open Source      *|
00006 |* License. See LICENSE.TXT for details.                                      *|
00007 |*                                                                            *|
00008 |*===----------------------------------------------------------------------===*|
00009 |*                                                                            *|
00010 |* This header provides a public inferface to a Clang library for extracting  *|
00011 |* high-level symbol information from source files without exposing the full  *|
00012 |* Clang C++ API.                                                             *|
00013 |*                                                                            *|
00014 \*===----------------------------------------------------------------------===*/
00015 
00016 #ifndef CLANG_C_INDEX_H
00017 #define CLANG_C_INDEX_H
00018 
00019 #include <time.h>
00020 
00021 #include "clang-c/Platform.h"
00022 #include "clang-c/CXErrorCode.h"
00023 #include "clang-c/CXString.h"
00024 #include "clang-c/BuildSystem.h"
00025 
00026 /**
00027  * \brief The version constants for the libclang API.
00028  * CINDEX_VERSION_MINOR should increase when there are API additions.
00029  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
00030  *
00031  * The policy about the libclang API was always to keep it source and ABI
00032  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
00033  */
00034 #define CINDEX_VERSION_MAJOR 0
00035 #define CINDEX_VERSION_MINOR 27
00036 
00037 #define CINDEX_VERSION_ENCODE(major, minor) ( \
00038       ((major) * 10000)                       \
00039     + ((minor) *     1))
00040 
00041 #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
00042     CINDEX_VERSION_MAJOR,                     \
00043     CINDEX_VERSION_MINOR )
00044 
00045 #define CINDEX_VERSION_STRINGIZE_(major, minor)   \
00046     #major"."#minor
00047 #define CINDEX_VERSION_STRINGIZE(major, minor)    \
00048     CINDEX_VERSION_STRINGIZE_(major, minor)
00049 
00050 #define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
00051     CINDEX_VERSION_MAJOR,                               \
00052     CINDEX_VERSION_MINOR)
00053 
00054 #ifdef __cplusplus
00055 extern "C" {
00056 #endif
00057 
00058 /** \defgroup CINDEX libclang: C Interface to Clang
00059  *
00060  * The C Interface to Clang provides a relatively small API that exposes
00061  * facilities for parsing source code into an abstract syntax tree (AST),
00062  * loading already-parsed ASTs, traversing the AST, associating
00063  * physical source locations with elements within the AST, and other
00064  * facilities that support Clang-based development tools.
00065  *
00066  * This C interface to Clang will never provide all of the information
00067  * representation stored in Clang's C++ AST, nor should it: the intent is to
00068  * maintain an API that is relatively stable from one release to the next,
00069  * providing only the basic functionality needed to support development tools.
00070  *
00071  * To avoid namespace pollution, data types are prefixed with "CX" and
00072  * functions are prefixed with "clang_".
00073  *
00074  * @{
00075  */
00076 
00077 /**
00078  * \brief An "index" that consists of a set of translation units that would
00079  * typically be linked together into an executable or library.
00080  */
00081 typedef void *CXIndex;
00082 
00083 /**
00084  * \brief A single translation unit, which resides in an index.
00085  */
00086 typedef struct CXTranslationUnitImpl *CXTranslationUnit;
00087 
00088 /**
00089  * \brief Opaque pointer representing client data that will be passed through
00090  * to various callbacks and visitors.
00091  */
00092 typedef void *CXClientData;
00093 
00094 /**
00095  * \brief Provides the contents of a file that has not yet been saved to disk.
00096  *
00097  * Each CXUnsavedFile instance provides the name of a file on the
00098  * system along with the current contents of that file that have not
00099  * yet been saved to disk.
00100  */
00101 struct CXUnsavedFile {
00102   /**
00103    * \brief The file whose contents have not yet been saved.
00104    *
00105    * This file must already exist in the file system.
00106    */
00107   const char *Filename;
00108 
00109   /**
00110    * \brief A buffer containing the unsaved contents of this file.
00111    */
00112   const char *Contents;
00113 
00114   /**
00115    * \brief The length of the unsaved contents of this buffer.
00116    */
00117   unsigned long Length;
00118 };
00119 
00120 /**
00121  * \brief Describes the availability of a particular entity, which indicates
00122  * whether the use of this entity will result in a warning or error due to
00123  * it being deprecated or unavailable.
00124  */
00125 enum CXAvailabilityKind {
00126   /**
00127    * \brief The entity is available.
00128    */
00129   CXAvailability_Available,
00130   /**
00131    * \brief The entity is available, but has been deprecated (and its use is
00132    * not recommended).
00133    */
00134   CXAvailability_Deprecated,
00135   /**
00136    * \brief The entity is not available; any use of it will be an error.
00137    */
00138   CXAvailability_NotAvailable,
00139   /**
00140    * \brief The entity is available, but not accessible; any use of it will be
00141    * an error.
00142    */
00143   CXAvailability_NotAccessible
00144 };
00145 
00146 /**
00147  * \brief Describes a version number of the form major.minor.subminor.
00148  */
00149 typedef struct CXVersion {
00150   /**
00151    * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
00152    * value indicates that there is no version number at all.
00153    */
00154   int Major;
00155   /**
00156    * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
00157    * will be negative if no minor version number was provided, e.g., for 
00158    * version '10'.
00159    */
00160   int Minor;
00161   /**
00162    * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
00163    * will be negative if no minor or subminor version number was provided,
00164    * e.g., in version '10' or '10.7'.
00165    */
00166   int Subminor;
00167 } CXVersion;
00168   
00169 /**
00170  * \brief Provides a shared context for creating translation units.
00171  *
00172  * It provides two options:
00173  *
00174  * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
00175  * declarations (when loading any new translation units). A "local" declaration
00176  * is one that belongs in the translation unit itself and not in a precompiled
00177  * header that was used by the translation unit. If zero, all declarations
00178  * will be enumerated.
00179  *
00180  * Here is an example:
00181  *
00182  * \code
00183  *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
00184  *   Idx = clang_createIndex(1, 1);
00185  *
00186  *   // IndexTest.pch was produced with the following command:
00187  *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
00188  *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
00189  *
00190  *   // This will load all the symbols from 'IndexTest.pch'
00191  *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
00192  *                       TranslationUnitVisitor, 0);
00193  *   clang_disposeTranslationUnit(TU);
00194  *
00195  *   // This will load all the symbols from 'IndexTest.c', excluding symbols
00196  *   // from 'IndexTest.pch'.
00197  *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
00198  *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
00199  *                                                  0, 0);
00200  *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
00201  *                       TranslationUnitVisitor, 0);
00202  *   clang_disposeTranslationUnit(TU);
00203  * \endcode
00204  *
00205  * This process of creating the 'pch', loading it separately, and using it (via
00206  * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
00207  * (which gives the indexer the same performance benefit as the compiler).
00208  */
00209 CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
00210                                          int displayDiagnostics);
00211 
00212 /**
00213  * \brief Destroy the given index.
00214  *
00215  * The index must not be destroyed until all of the translation units created
00216  * within that index have been destroyed.
00217  */
00218 CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
00219 
00220 typedef enum {
00221   /**
00222    * \brief Used to indicate that no special CXIndex options are needed.
00223    */
00224   CXGlobalOpt_None = 0x0,
00225 
00226   /**
00227    * \brief Used to indicate that threads that libclang creates for indexing
00228    * purposes should use background priority.
00229    *
00230    * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
00231    * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
00232    */
00233   CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
00234 
00235   /**
00236    * \brief Used to indicate that threads that libclang creates for editing
00237    * purposes should use background priority.
00238    *
00239    * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
00240    * #clang_annotateTokens
00241    */
00242   CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
00243 
00244   /**
00245    * \brief Used to indicate that all threads that libclang creates should use
00246    * background priority.
00247    */
00248   CXGlobalOpt_ThreadBackgroundPriorityForAll =
00249       CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
00250       CXGlobalOpt_ThreadBackgroundPriorityForEditing
00251 
00252 } CXGlobalOptFlags;
00253 
00254 /**
00255  * \brief Sets general options associated with a CXIndex.
00256  *
00257  * For example:
00258  * \code
00259  * CXIndex idx = ...;
00260  * clang_CXIndex_setGlobalOptions(idx,
00261  *     clang_CXIndex_getGlobalOptions(idx) |
00262  *     CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
00263  * \endcode
00264  *
00265  * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
00266  */
00267 CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
00268 
00269 /**
00270  * \brief Gets the general options associated with a CXIndex.
00271  *
00272  * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
00273  * are associated with the given CXIndex object.
00274  */
00275 CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
00276 
00277 /**
00278  * \defgroup CINDEX_FILES File manipulation routines
00279  *
00280  * @{
00281  */
00282 
00283 /**
00284  * \brief A particular source file that is part of a translation unit.
00285  */
00286 typedef void *CXFile;
00287 
00288 
00289 /**
00290  * \brief Retrieve the complete file and path name of the given file.
00291  */
00292 CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
00293 
00294 /**
00295  * \brief Retrieve the last modification time of the given file.
00296  */
00297 CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
00298 
00299 /**
00300  * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
00301  * across an indexing session.
00302  */
00303 typedef struct {
00304   unsigned long long data[3];
00305 } CXFileUniqueID;
00306 
00307 /**
00308  * \brief Retrieve the unique ID for the given \c file.
00309  *
00310  * \param file the file to get the ID for.
00311  * \param outID stores the returned CXFileUniqueID.
00312  * \returns If there was a failure getting the unique ID, returns non-zero,
00313  * otherwise returns 0.
00314 */
00315 CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
00316 
00317 /**
00318  * \brief Determine whether the given header is guarded against
00319  * multiple inclusions, either with the conventional
00320  * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
00321  */
00322 CINDEX_LINKAGE unsigned 
00323 clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
00324 
00325 /**
00326  * \brief Retrieve a file handle within the given translation unit.
00327  *
00328  * \param tu the translation unit
00329  *
00330  * \param file_name the name of the file.
00331  *
00332  * \returns the file handle for the named file in the translation unit \p tu,
00333  * or a NULL file handle if the file was not a part of this translation unit.
00334  */
00335 CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
00336                                     const char *file_name);
00337 
00338 /**
00339  * @}
00340  */
00341 
00342 /**
00343  * \defgroup CINDEX_LOCATIONS Physical source locations
00344  *
00345  * Clang represents physical source locations in its abstract syntax tree in
00346  * great detail, with file, line, and column information for the majority of
00347  * the tokens parsed in the source code. These data types and functions are
00348  * used to represent source location information, either for a particular
00349  * point in the program or for a range of points in the program, and extract
00350  * specific location information from those data types.
00351  *
00352  * @{
00353  */
00354 
00355 /**
00356  * \brief Identifies a specific source location within a translation
00357  * unit.
00358  *
00359  * Use clang_getExpansionLocation() or clang_getSpellingLocation()
00360  * to map a source location to a particular file, line, and column.
00361  */
00362 typedef struct {
00363   const void *ptr_data[2];
00364   unsigned int_data;
00365 } CXSourceLocation;
00366 
00367 /**
00368  * \brief Identifies a half-open character range in the source code.
00369  *
00370  * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
00371  * starting and end locations from a source range, respectively.
00372  */
00373 typedef struct {
00374   const void *ptr_data[2];
00375   unsigned begin_int_data;
00376   unsigned end_int_data;
00377 } CXSourceRange;
00378 
00379 /**
00380  * \brief Retrieve a NULL (invalid) source location.
00381  */
00382 CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
00383 
00384 /**
00385  * \brief Determine whether two source locations, which must refer into
00386  * the same translation unit, refer to exactly the same point in the source
00387  * code.
00388  *
00389  * \returns non-zero if the source locations refer to the same location, zero
00390  * if they refer to different locations.
00391  */
00392 CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
00393                                              CXSourceLocation loc2);
00394 
00395 /**
00396  * \brief Retrieves the source location associated with a given file/line/column
00397  * in a particular translation unit.
00398  */
00399 CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
00400                                                   CXFile file,
00401                                                   unsigned line,
00402                                                   unsigned column);
00403 /**
00404  * \brief Retrieves the source location associated with a given character offset
00405  * in a particular translation unit.
00406  */
00407 CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
00408                                                            CXFile file,
00409                                                            unsigned offset);
00410 
00411 /**
00412  * \brief Returns non-zero if the given source location is in a system header.
00413  */
00414 CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
00415 
00416 /**
00417  * \brief Returns non-zero if the given source location is in the main file of
00418  * the corresponding translation unit.
00419  */
00420 CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
00421 
00422 /**
00423  * \brief Retrieve a NULL (invalid) source range.
00424  */
00425 CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
00426 
00427 /**
00428  * \brief Retrieve a source range given the beginning and ending source
00429  * locations.
00430  */
00431 CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
00432                                             CXSourceLocation end);
00433 
00434 /**
00435  * \brief Determine whether two ranges are equivalent.
00436  *
00437  * \returns non-zero if the ranges are the same, zero if they differ.
00438  */
00439 CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
00440                                           CXSourceRange range2);
00441 
00442 /**
00443  * \brief Returns non-zero if \p range is null.
00444  */
00445 CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
00446 
00447 /**
00448  * \brief Retrieve the file, line, column, and offset represented by
00449  * the given source location.
00450  *
00451  * If the location refers into a macro expansion, retrieves the
00452  * location of the macro expansion.
00453  *
00454  * \param location the location within a source file that will be decomposed
00455  * into its parts.
00456  *
00457  * \param file [out] if non-NULL, will be set to the file to which the given
00458  * source location points.
00459  *
00460  * \param line [out] if non-NULL, will be set to the line to which the given
00461  * source location points.
00462  *
00463  * \param column [out] if non-NULL, will be set to the column to which the given
00464  * source location points.
00465  *
00466  * \param offset [out] if non-NULL, will be set to the offset into the
00467  * buffer to which the given source location points.
00468  */
00469 CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
00470                                                CXFile *file,
00471                                                unsigned *line,
00472                                                unsigned *column,
00473                                                unsigned *offset);
00474 
00475 /**
00476  * \brief Retrieve the file, line, column, and offset represented by
00477  * the given source location, as specified in a # line directive.
00478  *
00479  * Example: given the following source code in a file somefile.c
00480  *
00481  * \code
00482  * #123 "dummy.c" 1
00483  *
00484  * static int func(void)
00485  * {
00486  *     return 0;
00487  * }
00488  * \endcode
00489  *
00490  * the location information returned by this function would be
00491  *
00492  * File: dummy.c Line: 124 Column: 12
00493  *
00494  * whereas clang_getExpansionLocation would have returned
00495  *
00496  * File: somefile.c Line: 3 Column: 12
00497  *
00498  * \param location the location within a source file that will be decomposed
00499  * into its parts.
00500  *
00501  * \param filename [out] if non-NULL, will be set to the filename of the
00502  * source location. Note that filenames returned will be for "virtual" files,
00503  * which don't necessarily exist on the machine running clang - e.g. when
00504  * parsing preprocessed output obtained from a different environment. If
00505  * a non-NULL value is passed in, remember to dispose of the returned value
00506  * using \c clang_disposeString() once you've finished with it. For an invalid
00507  * source location, an empty string is returned.
00508  *
00509  * \param line [out] if non-NULL, will be set to the line number of the
00510  * source location. For an invalid source location, zero is returned.
00511  *
00512  * \param column [out] if non-NULL, will be set to the column number of the
00513  * source location. For an invalid source location, zero is returned.
00514  */
00515 CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
00516                                               CXString *filename,
00517                                               unsigned *line,
00518                                               unsigned *column);
00519 
00520 /**
00521  * \brief Legacy API to retrieve the file, line, column, and offset represented
00522  * by the given source location.
00523  *
00524  * This interface has been replaced by the newer interface
00525  * #clang_getExpansionLocation(). See that interface's documentation for
00526  * details.
00527  */
00528 CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
00529                                                    CXFile *file,
00530                                                    unsigned *line,
00531                                                    unsigned *column,
00532                                                    unsigned *offset);
00533 
00534 /**
00535  * \brief Retrieve the file, line, column, and offset represented by
00536  * the given source location.
00537  *
00538  * If the location refers into a macro instantiation, return where the
00539  * location was originally spelled in the source file.
00540  *
00541  * \param location the location within a source file that will be decomposed
00542  * into its parts.
00543  *
00544  * \param file [out] if non-NULL, will be set to the file to which the given
00545  * source location points.
00546  *
00547  * \param line [out] if non-NULL, will be set to the line to which the given
00548  * source location points.
00549  *
00550  * \param column [out] if non-NULL, will be set to the column to which the given
00551  * source location points.
00552  *
00553  * \param offset [out] if non-NULL, will be set to the offset into the
00554  * buffer to which the given source location points.
00555  */
00556 CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
00557                                               CXFile *file,
00558                                               unsigned *line,
00559                                               unsigned *column,
00560                                               unsigned *offset);
00561 
00562 /**
00563  * \brief Retrieve the file, line, column, and offset represented by
00564  * the given source location.
00565  *
00566  * If the location refers into a macro expansion, return where the macro was
00567  * expanded or where the macro argument was written, if the location points at
00568  * a macro argument.
00569  *
00570  * \param location the location within a source file that will be decomposed
00571  * into its parts.
00572  *
00573  * \param file [out] if non-NULL, will be set to the file to which the given
00574  * source location points.
00575  *
00576  * \param line [out] if non-NULL, will be set to the line to which the given
00577  * source location points.
00578  *
00579  * \param column [out] if non-NULL, will be set to the column to which the given
00580  * source location points.
00581  *
00582  * \param offset [out] if non-NULL, will be set to the offset into the
00583  * buffer to which the given source location points.
00584  */
00585 CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
00586                                           CXFile *file,
00587                                           unsigned *line,
00588                                           unsigned *column,
00589                                           unsigned *offset);
00590 
00591 /**
00592  * \brief Retrieve a source location representing the first character within a
00593  * source range.
00594  */
00595 CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
00596 
00597 /**
00598  * \brief Retrieve a source location representing the last character within a
00599  * source range.
00600  */
00601 CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
00602 
00603 /**
00604  * \brief Identifies an array of ranges.
00605  */
00606 typedef struct {
00607   /** \brief The number of ranges in the \c ranges array. */
00608   unsigned count;
00609   /**
00610    * \brief An array of \c CXSourceRanges.
00611    */
00612   CXSourceRange *ranges;
00613 } CXSourceRangeList;
00614 
00615 /**
00616  * \brief Retrieve all ranges that were skipped by the preprocessor.
00617  *
00618  * The preprocessor will skip lines when they are surrounded by an
00619  * if/ifdef/ifndef directive whose condition does not evaluate to true.
00620  */
00621 CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
00622                                                          CXFile file);
00623 
00624 /**
00625  * \brief Destroy the given \c CXSourceRangeList.
00626  */
00627 CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
00628 
00629 /**
00630  * @}
00631  */
00632 
00633 /**
00634  * \defgroup CINDEX_DIAG Diagnostic reporting
00635  *
00636  * @{
00637  */
00638 
00639 /**
00640  * \brief Describes the severity of a particular diagnostic.
00641  */
00642 enum CXDiagnosticSeverity {
00643   /**
00644    * \brief A diagnostic that has been suppressed, e.g., by a command-line
00645    * option.
00646    */
00647   CXDiagnostic_Ignored = 0,
00648 
00649   /**
00650    * \brief This diagnostic is a note that should be attached to the
00651    * previous (non-note) diagnostic.
00652    */
00653   CXDiagnostic_Note    = 1,
00654 
00655   /**
00656    * \brief This diagnostic indicates suspicious code that may not be
00657    * wrong.
00658    */
00659   CXDiagnostic_Warning = 2,
00660 
00661   /**
00662    * \brief This diagnostic indicates that the code is ill-formed.
00663    */
00664   CXDiagnostic_Error   = 3,
00665 
00666   /**
00667    * \brief This diagnostic indicates that the code is ill-formed such
00668    * that future parser recovery is unlikely to produce useful
00669    * results.
00670    */
00671   CXDiagnostic_Fatal   = 4
00672 };
00673 
00674 /**
00675  * \brief A single diagnostic, containing the diagnostic's severity,
00676  * location, text, source ranges, and fix-it hints.
00677  */
00678 typedef void *CXDiagnostic;
00679 
00680 /**
00681  * \brief A group of CXDiagnostics.
00682  */
00683 typedef void *CXDiagnosticSet;
00684   
00685 /**
00686  * \brief Determine the number of diagnostics in a CXDiagnosticSet.
00687  */
00688 CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
00689 
00690 /**
00691  * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
00692  *
00693  * \param Diags the CXDiagnosticSet to query.
00694  * \param Index the zero-based diagnostic number to retrieve.
00695  *
00696  * \returns the requested diagnostic. This diagnostic must be freed
00697  * via a call to \c clang_disposeDiagnostic().
00698  */
00699 CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
00700                                                      unsigned Index);  
00701 
00702 
00703 /**
00704  * \brief Describes the kind of error that occurred (if any) in a call to
00705  * \c clang_loadDiagnostics.
00706  */
00707 enum CXLoadDiag_Error {
00708   /**
00709    * \brief Indicates that no error occurred.
00710    */
00711   CXLoadDiag_None = 0,
00712   
00713   /**
00714    * \brief Indicates that an unknown error occurred while attempting to
00715    * deserialize diagnostics.
00716    */
00717   CXLoadDiag_Unknown = 1,
00718   
00719   /**
00720    * \brief Indicates that the file containing the serialized diagnostics
00721    * could not be opened.
00722    */
00723   CXLoadDiag_CannotLoad = 2,
00724   
00725   /**
00726    * \brief Indicates that the serialized diagnostics file is invalid or
00727    * corrupt.
00728    */
00729   CXLoadDiag_InvalidFile = 3
00730 };
00731   
00732 /**
00733  * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
00734  * file.
00735  *
00736  * \param file The name of the file to deserialize.
00737  * \param error A pointer to a enum value recording if there was a problem
00738  *        deserializing the diagnostics.
00739  * \param errorString A pointer to a CXString for recording the error string
00740  *        if the file was not successfully loaded.
00741  *
00742  * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise.  These
00743  * diagnostics should be released using clang_disposeDiagnosticSet().
00744  */
00745 CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
00746                                                   enum CXLoadDiag_Error *error,
00747                                                   CXString *errorString);
00748 
00749 /**
00750  * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
00751  */
00752 CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
00753 
00754 /**
00755  * \brief Retrieve the child diagnostics of a CXDiagnostic. 
00756  *
00757  * This CXDiagnosticSet does not need to be released by
00758  * clang_disposeDiagnosticSet.
00759  */
00760 CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
00761 
00762 /**
00763  * \brief Determine the number of diagnostics produced for the given
00764  * translation unit.
00765  */
00766 CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
00767 
00768 /**
00769  * \brief Retrieve a diagnostic associated with the given translation unit.
00770  *
00771  * \param Unit the translation unit to query.
00772  * \param Index the zero-based diagnostic number to retrieve.
00773  *
00774  * \returns the requested diagnostic. This diagnostic must be freed
00775  * via a call to \c clang_disposeDiagnostic().
00776  */
00777 CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
00778                                                 unsigned Index);
00779 
00780 /**
00781  * \brief Retrieve the complete set of diagnostics associated with a
00782  *        translation unit.
00783  *
00784  * \param Unit the translation unit to query.
00785  */
00786 CINDEX_LINKAGE CXDiagnosticSet
00787   clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);  
00788 
00789 /**
00790  * \brief Destroy a diagnostic.
00791  */
00792 CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
00793 
00794 /**
00795  * \brief Options to control the display of diagnostics.
00796  *
00797  * The values in this enum are meant to be combined to customize the
00798  * behavior of \c clang_formatDiagnostic().
00799  */
00800 enum CXDiagnosticDisplayOptions {
00801   /**
00802    * \brief Display the source-location information where the
00803    * diagnostic was located.
00804    *
00805    * When set, diagnostics will be prefixed by the file, line, and
00806    * (optionally) column to which the diagnostic refers. For example,
00807    *
00808    * \code
00809    * test.c:28: warning: extra tokens at end of #endif directive
00810    * \endcode
00811    *
00812    * This option corresponds to the clang flag \c -fshow-source-location.
00813    */
00814   CXDiagnostic_DisplaySourceLocation = 0x01,
00815 
00816   /**
00817    * \brief If displaying the source-location information of the
00818    * diagnostic, also include the column number.
00819    *
00820    * This option corresponds to the clang flag \c -fshow-column.
00821    */
00822   CXDiagnostic_DisplayColumn = 0x02,
00823 
00824   /**
00825    * \brief If displaying the source-location information of the
00826    * diagnostic, also include information about source ranges in a
00827    * machine-parsable format.
00828    *
00829    * This option corresponds to the clang flag
00830    * \c -fdiagnostics-print-source-range-info.
00831    */
00832   CXDiagnostic_DisplaySourceRanges = 0x04,
00833   
00834   /**
00835    * \brief Display the option name associated with this diagnostic, if any.
00836    *
00837    * The option name displayed (e.g., -Wconversion) will be placed in brackets
00838    * after the diagnostic text. This option corresponds to the clang flag
00839    * \c -fdiagnostics-show-option.
00840    */
00841   CXDiagnostic_DisplayOption = 0x08,
00842   
00843   /**
00844    * \brief Display the category number associated with this diagnostic, if any.
00845    *
00846    * The category number is displayed within brackets after the diagnostic text.
00847    * This option corresponds to the clang flag 
00848    * \c -fdiagnostics-show-category=id.
00849    */
00850   CXDiagnostic_DisplayCategoryId = 0x10,
00851 
00852   /**
00853    * \brief Display the category name associated with this diagnostic, if any.
00854    *
00855    * The category name is displayed within brackets after the diagnostic text.
00856    * This option corresponds to the clang flag 
00857    * \c -fdiagnostics-show-category=name.
00858    */
00859   CXDiagnostic_DisplayCategoryName = 0x20
00860 };
00861 
00862 /**
00863  * \brief Format the given diagnostic in a manner that is suitable for display.
00864  *
00865  * This routine will format the given diagnostic to a string, rendering
00866  * the diagnostic according to the various options given. The
00867  * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
00868  * options that most closely mimics the behavior of the clang compiler.
00869  *
00870  * \param Diagnostic The diagnostic to print.
00871  *
00872  * \param Options A set of options that control the diagnostic display,
00873  * created by combining \c CXDiagnosticDisplayOptions values.
00874  *
00875  * \returns A new string containing for formatted diagnostic.
00876  */
00877 CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
00878                                                unsigned Options);
00879 
00880 /**
00881  * \brief Retrieve the set of display options most similar to the
00882  * default behavior of the clang compiler.
00883  *
00884  * \returns A set of display options suitable for use with \c
00885  * clang_formatDiagnostic().
00886  */
00887 CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
00888 
00889 /**
00890  * \brief Determine the severity of the given diagnostic.
00891  */
00892 CINDEX_LINKAGE enum CXDiagnosticSeverity
00893 clang_getDiagnosticSeverity(CXDiagnostic);
00894 
00895 /**
00896  * \brief Retrieve the source location of the given diagnostic.
00897  *
00898  * This location is where Clang would print the caret ('^') when
00899  * displaying the diagnostic on the command line.
00900  */
00901 CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
00902 
00903 /**
00904  * \brief Retrieve the text of the given diagnostic.
00905  */
00906 CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
00907 
00908 /**
00909  * \brief Retrieve the name of the command-line option that enabled this
00910  * diagnostic.
00911  *
00912  * \param Diag The diagnostic to be queried.
00913  *
00914  * \param Disable If non-NULL, will be set to the option that disables this
00915  * diagnostic (if any).
00916  *
00917  * \returns A string that contains the command-line option used to enable this
00918  * warning, such as "-Wconversion" or "-pedantic". 
00919  */
00920 CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
00921                                                   CXString *Disable);
00922 
00923 /**
00924  * \brief Retrieve the category number for this diagnostic.
00925  *
00926  * Diagnostics can be categorized into groups along with other, related
00927  * diagnostics (e.g., diagnostics under the same warning flag). This routine 
00928  * retrieves the category number for the given diagnostic.
00929  *
00930  * \returns The number of the category that contains this diagnostic, or zero
00931  * if this diagnostic is uncategorized.
00932  */
00933 CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
00934 
00935 /**
00936  * \brief Retrieve the name of a particular diagnostic category.  This
00937  *  is now deprecated.  Use clang_getDiagnosticCategoryText()
00938  *  instead.
00939  *
00940  * \param Category A diagnostic category number, as returned by 
00941  * \c clang_getDiagnosticCategory().
00942  *
00943  * \returns The name of the given diagnostic category.
00944  */
00945 CINDEX_DEPRECATED CINDEX_LINKAGE
00946 CXString clang_getDiagnosticCategoryName(unsigned Category);
00947 
00948 /**
00949  * \brief Retrieve the diagnostic category text for a given diagnostic.
00950  *
00951  * \returns The text of the given diagnostic category.
00952  */
00953 CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
00954   
00955 /**
00956  * \brief Determine the number of source ranges associated with the given
00957  * diagnostic.
00958  */
00959 CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
00960 
00961 /**
00962  * \brief Retrieve a source range associated with the diagnostic.
00963  *
00964  * A diagnostic's source ranges highlight important elements in the source
00965  * code. On the command line, Clang displays source ranges by
00966  * underlining them with '~' characters.
00967  *
00968  * \param Diagnostic the diagnostic whose range is being extracted.
00969  *
00970  * \param Range the zero-based index specifying which range to
00971  *
00972  * \returns the requested source range.
00973  */
00974 CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
00975                                                       unsigned Range);
00976 
00977 /**
00978  * \brief Determine the number of fix-it hints associated with the
00979  * given diagnostic.
00980  */
00981 CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
00982 
00983 /**
00984  * \brief Retrieve the replacement information for a given fix-it.
00985  *
00986  * Fix-its are described in terms of a source range whose contents
00987  * should be replaced by a string. This approach generalizes over
00988  * three kinds of operations: removal of source code (the range covers
00989  * the code to be removed and the replacement string is empty),
00990  * replacement of source code (the range covers the code to be
00991  * replaced and the replacement string provides the new code), and
00992  * insertion (both the start and end of the range point at the
00993  * insertion location, and the replacement string provides the text to
00994  * insert).
00995  *
00996  * \param Diagnostic The diagnostic whose fix-its are being queried.
00997  *
00998  * \param FixIt The zero-based index of the fix-it.
00999  *
01000  * \param ReplacementRange The source range whose contents will be
01001  * replaced with the returned replacement string. Note that source
01002  * ranges are half-open ranges [a, b), so the source code should be
01003  * replaced from a and up to (but not including) b.
01004  *
01005  * \returns A string containing text that should be replace the source
01006  * code indicated by the \c ReplacementRange.
01007  */
01008 CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
01009                                                  unsigned FixIt,
01010                                                CXSourceRange *ReplacementRange);
01011 
01012 /**
01013  * @}
01014  */
01015 
01016 /**
01017  * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
01018  *
01019  * The routines in this group provide the ability to create and destroy
01020  * translation units from files, either by parsing the contents of the files or
01021  * by reading in a serialized representation of a translation unit.
01022  *
01023  * @{
01024  */
01025 
01026 /**
01027  * \brief Get the original translation unit source file name.
01028  */
01029 CINDEX_LINKAGE CXString
01030 clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
01031 
01032 /**
01033  * \brief Return the CXTranslationUnit for a given source file and the provided
01034  * command line arguments one would pass to the compiler.
01035  *
01036  * Note: The 'source_filename' argument is optional.  If the caller provides a
01037  * NULL pointer, the name of the source file is expected to reside in the
01038  * specified command line arguments.
01039  *
01040  * Note: When encountered in 'clang_command_line_args', the following options
01041  * are ignored:
01042  *
01043  *   '-c'
01044  *   '-emit-ast'
01045  *   '-fsyntax-only'
01046  *   '-o <output file>'  (both '-o' and '<output file>' are ignored)
01047  *
01048  * \param CIdx The index object with which the translation unit will be
01049  * associated.
01050  *
01051  * \param source_filename The name of the source file to load, or NULL if the
01052  * source file is included in \p clang_command_line_args.
01053  *
01054  * \param num_clang_command_line_args The number of command-line arguments in
01055  * \p clang_command_line_args.
01056  *
01057  * \param clang_command_line_args The command-line arguments that would be
01058  * passed to the \c clang executable if it were being invoked out-of-process.
01059  * These command-line options will be parsed and will affect how the translation
01060  * unit is parsed. Note that the following options are ignored: '-c',
01061  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
01062  *
01063  * \param num_unsaved_files the number of unsaved file entries in \p
01064  * unsaved_files.
01065  *
01066  * \param unsaved_files the files that have not yet been saved to disk
01067  * but may be required for code completion, including the contents of
01068  * those files.  The contents and name of these files (as specified by
01069  * CXUnsavedFile) are copied when necessary, so the client only needs to
01070  * guarantee their validity until the call to this function returns.
01071  */
01072 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
01073                                          CXIndex CIdx,
01074                                          const char *source_filename,
01075                                          int num_clang_command_line_args,
01076                                    const char * const *clang_command_line_args,
01077                                          unsigned num_unsaved_files,
01078                                          struct CXUnsavedFile *unsaved_files);
01079 
01080 /**
01081  * \brief Same as \c clang_createTranslationUnit2, but returns
01082  * the \c CXTranslationUnit instead of an error code.  In case of an error this
01083  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
01084  * error codes.
01085  */
01086 CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
01087     CXIndex CIdx,
01088     const char *ast_filename);
01089 
01090 /**
01091  * \brief Create a translation unit from an AST file (\c -emit-ast).
01092  *
01093  * \param[out] out_TU A non-NULL pointer to store the created
01094  * \c CXTranslationUnit.
01095  *
01096  * \returns Zero on success, otherwise returns an error code.
01097  */
01098 CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
01099     CXIndex CIdx,
01100     const char *ast_filename,
01101     CXTranslationUnit *out_TU);
01102 
01103 /**
01104  * \brief Flags that control the creation of translation units.
01105  *
01106  * The enumerators in this enumeration type are meant to be bitwise
01107  * ORed together to specify which options should be used when
01108  * constructing the translation unit.
01109  */
01110 enum CXTranslationUnit_Flags {
01111   /**
01112    * \brief Used to indicate that no special translation-unit options are
01113    * needed.
01114    */
01115   CXTranslationUnit_None = 0x0,
01116 
01117   /**
01118    * \brief Used to indicate that the parser should construct a "detailed"
01119    * preprocessing record, including all macro definitions and instantiations.
01120    *
01121    * Constructing a detailed preprocessing record requires more memory
01122    * and time to parse, since the information contained in the record
01123    * is usually not retained. However, it can be useful for
01124    * applications that require more detailed information about the
01125    * behavior of the preprocessor.
01126    */
01127   CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
01128 
01129   /**
01130    * \brief Used to indicate that the translation unit is incomplete.
01131    *
01132    * When a translation unit is considered "incomplete", semantic
01133    * analysis that is typically performed at the end of the
01134    * translation unit will be suppressed. For example, this suppresses
01135    * the completion of tentative declarations in C and of
01136    * instantiation of implicitly-instantiation function templates in
01137    * C++. This option is typically used when parsing a header with the
01138    * intent of producing a precompiled header.
01139    */
01140   CXTranslationUnit_Incomplete = 0x02,
01141   
01142   /**
01143    * \brief Used to indicate that the translation unit should be built with an 
01144    * implicit precompiled header for the preamble.
01145    *
01146    * An implicit precompiled header is used as an optimization when a
01147    * particular translation unit is likely to be reparsed many times
01148    * when the sources aren't changing that often. In this case, an
01149    * implicit precompiled header will be built containing all of the
01150    * initial includes at the top of the main file (what we refer to as
01151    * the "preamble" of the file). In subsequent parses, if the
01152    * preamble or the files in it have not changed, \c
01153    * clang_reparseTranslationUnit() will re-use the implicit
01154    * precompiled header to improve parsing performance.
01155    */
01156   CXTranslationUnit_PrecompiledPreamble = 0x04,
01157   
01158   /**
01159    * \brief Used to indicate that the translation unit should cache some
01160    * code-completion results with each reparse of the source file.
01161    *
01162    * Caching of code-completion results is a performance optimization that
01163    * introduces some overhead to reparsing but improves the performance of
01164    * code-completion operations.
01165    */
01166   CXTranslationUnit_CacheCompletionResults = 0x08,
01167 
01168   /**
01169    * \brief Used to indicate that the translation unit will be serialized with
01170    * \c clang_saveTranslationUnit.
01171    *
01172    * This option is typically used when parsing a header with the intent of
01173    * producing a precompiled header.
01174    */
01175   CXTranslationUnit_ForSerialization = 0x10,
01176 
01177   /**
01178    * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
01179    *
01180    * Note: this is a *temporary* option that is available only while
01181    * we are testing C++ precompiled preamble support. It is deprecated.
01182    */
01183   CXTranslationUnit_CXXChainedPCH = 0x20,
01184 
01185   /**
01186    * \brief Used to indicate that function/method bodies should be skipped while
01187    * parsing.
01188    *
01189    * This option can be used to search for declarations/definitions while
01190    * ignoring the usages.
01191    */
01192   CXTranslationUnit_SkipFunctionBodies = 0x40,
01193 
01194   /**
01195    * \brief Used to indicate that brief documentation comments should be
01196    * included into the set of code completions returned from this translation
01197    * unit.
01198    */
01199   CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80
01200 };
01201 
01202 /**
01203  * \brief Returns the set of flags that is suitable for parsing a translation
01204  * unit that is being edited.
01205  *
01206  * The set of flags returned provide options for \c clang_parseTranslationUnit()
01207  * to indicate that the translation unit is likely to be reparsed many times,
01208  * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
01209  * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
01210  * set contains an unspecified set of optimizations (e.g., the precompiled 
01211  * preamble) geared toward improving the performance of these routines. The
01212  * set of optimizations enabled may change from one version to the next.
01213  */
01214 CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
01215 
01216 /**
01217  * \brief Same as \c clang_parseTranslationUnit2, but returns
01218  * the \c CXTranslationUnit instead of an error code.  In case of an error this
01219  * routine returns a \c NULL \c CXTranslationUnit, without further detailed
01220  * error codes.
01221  */
01222 CINDEX_LINKAGE CXTranslationUnit
01223 clang_parseTranslationUnit(CXIndex CIdx,
01224                            const char *source_filename,
01225                            const char *const *command_line_args,
01226                            int num_command_line_args,
01227                            struct CXUnsavedFile *unsaved_files,
01228                            unsigned num_unsaved_files,
01229                            unsigned options);
01230 
01231 /**
01232  * \brief Parse the given source file and the translation unit corresponding
01233  * to that file.
01234  *
01235  * This routine is the main entry point for the Clang C API, providing the
01236  * ability to parse a source file into a translation unit that can then be
01237  * queried by other functions in the API. This routine accepts a set of
01238  * command-line arguments so that the compilation can be configured in the same
01239  * way that the compiler is configured on the command line.
01240  *
01241  * \param CIdx The index object with which the translation unit will be 
01242  * associated.
01243  *
01244  * \param source_filename The name of the source file to load, or NULL if the
01245  * source file is included in \c command_line_args.
01246  *
01247  * \param command_line_args The command-line arguments that would be
01248  * passed to the \c clang executable if it were being invoked out-of-process.
01249  * These command-line options will be parsed and will affect how the translation
01250  * unit is parsed. Note that the following options are ignored: '-c', 
01251  * '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
01252  *
01253  * \param num_command_line_args The number of command-line arguments in
01254  * \c command_line_args.
01255  *
01256  * \param unsaved_files the files that have not yet been saved to disk
01257  * but may be required for parsing, including the contents of
01258  * those files.  The contents and name of these files (as specified by
01259  * CXUnsavedFile) are copied when necessary, so the client only needs to
01260  * guarantee their validity until the call to this function returns.
01261  *
01262  * \param num_unsaved_files the number of unsaved file entries in \p
01263  * unsaved_files.
01264  *
01265  * \param options A bitmask of options that affects how the translation unit
01266  * is managed but not its compilation. This should be a bitwise OR of the
01267  * CXTranslationUnit_XXX flags.
01268  *
01269  * \param[out] out_TU A non-NULL pointer to store the created
01270  * \c CXTranslationUnit, describing the parsed code and containing any
01271  * diagnostics produced by the compiler.
01272  *
01273  * \returns Zero on success, otherwise returns an error code.
01274  */
01275 CINDEX_LINKAGE enum CXErrorCode
01276 clang_parseTranslationUnit2(CXIndex CIdx,
01277                             const char *source_filename,
01278                             const char *const *command_line_args,
01279                             int num_command_line_args,
01280                             struct CXUnsavedFile *unsaved_files,
01281                             unsigned num_unsaved_files,
01282                             unsigned options,
01283                             CXTranslationUnit *out_TU);
01284 
01285 /**
01286  * \brief Flags that control how translation units are saved.
01287  *
01288  * The enumerators in this enumeration type are meant to be bitwise
01289  * ORed together to specify which options should be used when
01290  * saving the translation unit.
01291  */
01292 enum CXSaveTranslationUnit_Flags {
01293   /**
01294    * \brief Used to indicate that no special saving options are needed.
01295    */
01296   CXSaveTranslationUnit_None = 0x0
01297 };
01298 
01299 /**
01300  * \brief Returns the set of flags that is suitable for saving a translation
01301  * unit.
01302  *
01303  * The set of flags returned provide options for
01304  * \c clang_saveTranslationUnit() by default. The returned flag
01305  * set contains an unspecified set of options that save translation units with
01306  * the most commonly-requested data.
01307  */
01308 CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
01309 
01310 /**
01311  * \brief Describes the kind of error that occurred (if any) in a call to
01312  * \c clang_saveTranslationUnit().
01313  */
01314 enum CXSaveError {
01315   /**
01316    * \brief Indicates that no error occurred while saving a translation unit.
01317    */
01318   CXSaveError_None = 0,
01319   
01320   /**
01321    * \brief Indicates that an unknown error occurred while attempting to save
01322    * the file.
01323    *
01324    * This error typically indicates that file I/O failed when attempting to 
01325    * write the file.
01326    */
01327   CXSaveError_Unknown = 1,
01328   
01329   /**
01330    * \brief Indicates that errors during translation prevented this attempt
01331    * to save the translation unit.
01332    * 
01333    * Errors that prevent the translation unit from being saved can be
01334    * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
01335    */
01336   CXSaveError_TranslationErrors = 2,
01337   
01338   /**
01339    * \brief Indicates that the translation unit to be saved was somehow
01340    * invalid (e.g., NULL).
01341    */
01342   CXSaveError_InvalidTU = 3
01343 };
01344   
01345 /**
01346  * \brief Saves a translation unit into a serialized representation of
01347  * that translation unit on disk.
01348  *
01349  * Any translation unit that was parsed without error can be saved
01350  * into a file. The translation unit can then be deserialized into a
01351  * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
01352  * if it is an incomplete translation unit that corresponds to a
01353  * header, used as a precompiled header when parsing other translation
01354  * units.
01355  *
01356  * \param TU The translation unit to save.
01357  *
01358  * \param FileName The file to which the translation unit will be saved.
01359  *
01360  * \param options A bitmask of options that affects how the translation unit
01361  * is saved. This should be a bitwise OR of the
01362  * CXSaveTranslationUnit_XXX flags.
01363  *
01364  * \returns A value that will match one of the enumerators of the CXSaveError
01365  * enumeration. Zero (CXSaveError_None) indicates that the translation unit was 
01366  * saved successfully, while a non-zero value indicates that a problem occurred.
01367  */
01368 CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
01369                                              const char *FileName,
01370                                              unsigned options);
01371 
01372 /**
01373  * \brief Destroy the specified CXTranslationUnit object.
01374  */
01375 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
01376 
01377 /**
01378  * \brief Flags that control the reparsing of translation units.
01379  *
01380  * The enumerators in this enumeration type are meant to be bitwise
01381  * ORed together to specify which options should be used when
01382  * reparsing the translation unit.
01383  */
01384 enum CXReparse_Flags {
01385   /**
01386    * \brief Used to indicate that no special reparsing options are needed.
01387    */
01388   CXReparse_None = 0x0
01389 };
01390  
01391 /**
01392  * \brief Returns the set of flags that is suitable for reparsing a translation
01393  * unit.
01394  *
01395  * The set of flags returned provide options for
01396  * \c clang_reparseTranslationUnit() by default. The returned flag
01397  * set contains an unspecified set of optimizations geared toward common uses
01398  * of reparsing. The set of optimizations enabled may change from one version 
01399  * to the next.
01400  */
01401 CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
01402 
01403 /**
01404  * \brief Reparse the source files that produced this translation unit.
01405  *
01406  * This routine can be used to re-parse the source files that originally
01407  * created the given translation unit, for example because those source files
01408  * have changed (either on disk or as passed via \p unsaved_files). The
01409  * source code will be reparsed with the same command-line options as it
01410  * was originally parsed. 
01411  *
01412  * Reparsing a translation unit invalidates all cursors and source locations
01413  * that refer into that translation unit. This makes reparsing a translation
01414  * unit semantically equivalent to destroying the translation unit and then
01415  * creating a new translation unit with the same command-line arguments.
01416  * However, it may be more efficient to reparse a translation 
01417  * unit using this routine.
01418  *
01419  * \param TU The translation unit whose contents will be re-parsed. The
01420  * translation unit must originally have been built with 
01421  * \c clang_createTranslationUnitFromSourceFile().
01422  *
01423  * \param num_unsaved_files The number of unsaved file entries in \p
01424  * unsaved_files.
01425  *
01426  * \param unsaved_files The files that have not yet been saved to disk
01427  * but may be required for parsing, including the contents of
01428  * those files.  The contents and name of these files (as specified by
01429  * CXUnsavedFile) are copied when necessary, so the client only needs to
01430  * guarantee their validity until the call to this function returns.
01431  * 
01432  * \param options A bitset of options composed of the flags in CXReparse_Flags.
01433  * The function \c clang_defaultReparseOptions() produces a default set of
01434  * options recommended for most uses, based on the translation unit.
01435  *
01436  * \returns 0 if the sources could be reparsed.  A non-zero error code will be
01437  * returned if reparsing was impossible, such that the translation unit is
01438  * invalid. In such cases, the only valid call for \c TU is
01439  * \c clang_disposeTranslationUnit(TU).  The error codes returned by this
01440  * routine are described by the \c CXErrorCode enum.
01441  */
01442 CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
01443                                                 unsigned num_unsaved_files,
01444                                           struct CXUnsavedFile *unsaved_files,
01445                                                 unsigned options);
01446 
01447 /**
01448   * \brief Categorizes how memory is being used by a translation unit.
01449   */
01450 enum CXTUResourceUsageKind {
01451   CXTUResourceUsage_AST = 1,
01452   CXTUResourceUsage_Identifiers = 2,
01453   CXTUResourceUsage_Selectors = 3,
01454   CXTUResourceUsage_GlobalCompletionResults = 4,
01455   CXTUResourceUsage_SourceManagerContentCache = 5,
01456   CXTUResourceUsage_AST_SideTables = 6,
01457   CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
01458   CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
01459   CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, 
01460   CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, 
01461   CXTUResourceUsage_Preprocessor = 11,
01462   CXTUResourceUsage_PreprocessingRecord = 12,
01463   CXTUResourceUsage_SourceManager_DataStructures = 13,
01464   CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
01465   CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
01466   CXTUResourceUsage_MEMORY_IN_BYTES_END =
01467     CXTUResourceUsage_Preprocessor_HeaderSearch,
01468 
01469   CXTUResourceUsage_First = CXTUResourceUsage_AST,
01470   CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
01471 };
01472 
01473 /**
01474   * \brief Returns the human-readable null-terminated C string that represents
01475   *  the name of the memory category.  This string should never be freed.
01476   */
01477 CINDEX_LINKAGE
01478 const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
01479 
01480 typedef struct CXTUResourceUsageEntry {
01481   /* \brief The memory usage category. */
01482   enum CXTUResourceUsageKind kind;  
01483   /* \brief Amount of resources used. 
01484       The units will depend on the resource kind. */
01485   unsigned long amount;
01486 } CXTUResourceUsageEntry;
01487 
01488 /**
01489   * \brief The memory usage of a CXTranslationUnit, broken into categories.
01490   */
01491 typedef struct CXTUResourceUsage {
01492   /* \brief Private data member, used for queries. */
01493   void *data;
01494 
01495   /* \brief The number of entries in the 'entries' array. */
01496   unsigned numEntries;
01497 
01498   /* \brief An array of key-value pairs, representing the breakdown of memory
01499             usage. */
01500   CXTUResourceUsageEntry *entries;
01501 
01502 } CXTUResourceUsage;
01503 
01504 /**
01505   * \brief Return the memory usage of a translation unit.  This object
01506   *  should be released with clang_disposeCXTUResourceUsage().
01507   */
01508 CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
01509 
01510 CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
01511 
01512 /**
01513  * @}
01514  */
01515 
01516 /**
01517  * \brief Describes the kind of entity that a cursor refers to.
01518  */
01519 enum CXCursorKind {
01520   /* Declarations */
01521   /**
01522    * \brief A declaration whose specific kind is not exposed via this
01523    * interface.
01524    *
01525    * Unexposed declarations have the same operations as any other kind
01526    * of declaration; one can extract their location information,
01527    * spelling, find their definitions, etc. However, the specific kind
01528    * of the declaration is not reported.
01529    */
01530   CXCursor_UnexposedDecl                 = 1,
01531   /** \brief A C or C++ struct. */
01532   CXCursor_StructDecl                    = 2,
01533   /** \brief A C or C++ union. */
01534   CXCursor_UnionDecl                     = 3,
01535   /** \brief A C++ class. */
01536   CXCursor_ClassDecl                     = 4,
01537   /** \brief An enumeration. */
01538   CXCursor_EnumDecl                      = 5,
01539   /**
01540    * \brief A field (in C) or non-static data member (in C++) in a
01541    * struct, union, or C++ class.
01542    */
01543   CXCursor_FieldDecl                     = 6,
01544   /** \brief An enumerator constant. */
01545   CXCursor_EnumConstantDecl              = 7,
01546   /** \brief A function. */
01547   CXCursor_FunctionDecl                  = 8,
01548   /** \brief A variable. */
01549   CXCursor_VarDecl                       = 9,
01550   /** \brief A function or method parameter. */
01551   CXCursor_ParmDecl                      = 10,
01552   /** \brief An Objective-C \@interface. */
01553   CXCursor_ObjCInterfaceDecl             = 11,
01554   /** \brief An Objective-C \@interface for a category. */
01555   CXCursor_ObjCCategoryDecl              = 12,
01556   /** \brief An Objective-C \@protocol declaration. */
01557   CXCursor_ObjCProtocolDecl              = 13,
01558   /** \brief An Objective-C \@property declaration. */
01559   CXCursor_ObjCPropertyDecl              = 14,
01560   /** \brief An Objective-C instance variable. */
01561   CXCursor_ObjCIvarDecl                  = 15,
01562   /** \brief An Objective-C instance method. */
01563   CXCursor_ObjCInstanceMethodDecl        = 16,
01564   /** \brief An Objective-C class method. */
01565   CXCursor_ObjCClassMethodDecl           = 17,
01566   /** \brief An Objective-C \@implementation. */
01567   CXCursor_ObjCImplementationDecl        = 18,
01568   /** \brief An Objective-C \@implementation for a category. */
01569   CXCursor_ObjCCategoryImplDecl          = 19,
01570   /** \brief A typedef */
01571   CXCursor_TypedefDecl                   = 20,
01572   /** \brief A C++ class method. */
01573   CXCursor_CXXMethod                     = 21,
01574   /** \brief A C++ namespace. */
01575   CXCursor_Namespace                     = 22,
01576   /** \brief A linkage specification, e.g. 'extern "C"'. */
01577   CXCursor_LinkageSpec                   = 23,
01578   /** \brief A C++ constructor. */
01579   CXCursor_Constructor                   = 24,
01580   /** \brief A C++ destructor. */
01581   CXCursor_Destructor                    = 25,
01582   /** \brief A C++ conversion function. */
01583   CXCursor_ConversionFunction            = 26,
01584   /** \brief A C++ template type parameter. */
01585   CXCursor_TemplateTypeParameter         = 27,
01586   /** \brief A C++ non-type template parameter. */
01587   CXCursor_NonTypeTemplateParameter      = 28,
01588   /** \brief A C++ template template parameter. */
01589   CXCursor_TemplateTemplateParameter     = 29,
01590   /** \brief A C++ function template. */
01591   CXCursor_FunctionTemplate              = 30,
01592   /** \brief A C++ class template. */
01593   CXCursor_ClassTemplate                 = 31,
01594   /** \brief A C++ class template partial specialization. */
01595   CXCursor_ClassTemplatePartialSpecialization = 32,
01596   /** \brief A C++ namespace alias declaration. */
01597   CXCursor_NamespaceAlias                = 33,
01598   /** \brief A C++ using directive. */
01599   CXCursor_UsingDirective                = 34,
01600   /** \brief A C++ using declaration. */
01601   CXCursor_UsingDeclaration              = 35,
01602   /** \brief A C++ alias declaration */
01603   CXCursor_TypeAliasDecl                 = 36,
01604   /** \brief An Objective-C \@synthesize definition. */
01605   CXCursor_ObjCSynthesizeDecl            = 37,
01606   /** \brief An Objective-C \@dynamic definition. */
01607   CXCursor_ObjCDynamicDecl               = 38,
01608   /** \brief An access specifier. */
01609   CXCursor_CXXAccessSpecifier            = 39,
01610 
01611   CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
01612   CXCursor_LastDecl                      = CXCursor_CXXAccessSpecifier,
01613 
01614   /* References */
01615   CXCursor_FirstRef                      = 40, /* Decl references */
01616   CXCursor_ObjCSuperClassRef             = 40,
01617   CXCursor_ObjCProtocolRef               = 41,
01618   CXCursor_ObjCClassRef                  = 42,
01619   /**
01620    * \brief A reference to a type declaration.
01621    *
01622    * A type reference occurs anywhere where a type is named but not
01623    * declared. For example, given:
01624    *
01625    * \code
01626    * typedef unsigned size_type;
01627    * size_type size;
01628    * \endcode
01629    *
01630    * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
01631    * while the type of the variable "size" is referenced. The cursor
01632    * referenced by the type of size is the typedef for size_type.
01633    */
01634   CXCursor_TypeRef                       = 43,
01635   CXCursor_CXXBaseSpecifier              = 44,
01636   /** 
01637    * \brief A reference to a class template, function template, template
01638    * template parameter, or class template partial specialization.
01639    */
01640   CXCursor_TemplateRef                   = 45,
01641   /**
01642    * \brief A reference to a namespace or namespace alias.
01643    */
01644   CXCursor_NamespaceRef                  = 46,
01645   /**
01646    * \brief A reference to a member of a struct, union, or class that occurs in 
01647    * some non-expression context, e.g., a designated initializer.
01648    */
01649   CXCursor_MemberRef                     = 47,
01650   /**
01651    * \brief A reference to a labeled statement.
01652    *
01653    * This cursor kind is used to describe the jump to "start_over" in the 
01654    * goto statement in the following example:
01655    *
01656    * \code
01657    *   start_over:
01658    *     ++counter;
01659    *
01660    *     goto start_over;
01661    * \endcode
01662    *
01663    * A label reference cursor refers to a label statement.
01664    */
01665   CXCursor_LabelRef                      = 48,
01666   
01667   /**
01668    * \brief A reference to a set of overloaded functions or function templates
01669    * that has not yet been resolved to a specific function or function template.
01670    *
01671    * An overloaded declaration reference cursor occurs in C++ templates where
01672    * a dependent name refers to a function. For example:
01673    *
01674    * \code
01675    * template<typename T> void swap(T&, T&);
01676    *
01677    * struct X { ... };
01678    * void swap(X&, X&);
01679    *
01680    * template<typename T>
01681    * void reverse(T* first, T* last) {
01682    *   while (first < last - 1) {
01683    *     swap(*first, *--last);
01684    *     ++first;
01685    *   }
01686    * }
01687    *
01688    * struct Y { };
01689    * void swap(Y&, Y&);
01690    * \endcode
01691    *
01692    * Here, the identifier "swap" is associated with an overloaded declaration
01693    * reference. In the template definition, "swap" refers to either of the two
01694    * "swap" functions declared above, so both results will be available. At
01695    * instantiation time, "swap" may also refer to other functions found via
01696    * argument-dependent lookup (e.g., the "swap" function at the end of the
01697    * example).
01698    *
01699    * The functions \c clang_getNumOverloadedDecls() and 
01700    * \c clang_getOverloadedDecl() can be used to retrieve the definitions
01701    * referenced by this cursor.
01702    */
01703   CXCursor_OverloadedDeclRef             = 49,
01704   
01705   /**
01706    * \brief A reference to a variable that occurs in some non-expression 
01707    * context, e.g., a C++ lambda capture list.
01708    */
01709   CXCursor_VariableRef                   = 50,
01710   
01711   CXCursor_LastRef                       = CXCursor_VariableRef,
01712 
01713   /* Error conditions */
01714   CXCursor_FirstInvalid                  = 70,
01715   CXCursor_InvalidFile                   = 70,
01716   CXCursor_NoDeclFound                   = 71,
01717   CXCursor_NotImplemented                = 72,
01718   CXCursor_InvalidCode                   = 73,
01719   CXCursor_LastInvalid                   = CXCursor_InvalidCode,
01720 
01721   /* Expressions */
01722   CXCursor_FirstExpr                     = 100,
01723 
01724   /**
01725    * \brief An expression whose specific kind is not exposed via this
01726    * interface.
01727    *
01728    * Unexposed expressions have the same operations as any other kind
01729    * of expression; one can extract their location information,
01730    * spelling, children, etc. However, the specific kind of the
01731    * expression is not reported.
01732    */
01733   CXCursor_UnexposedExpr                 = 100,
01734 
01735   /**
01736    * \brief An expression that refers to some value declaration, such
01737    * as a function, variable, or enumerator.
01738    */
01739   CXCursor_DeclRefExpr                   = 101,
01740 
01741   /**
01742    * \brief An expression that refers to a member of a struct, union,
01743    * class, Objective-C class, etc.
01744    */
01745   CXCursor_MemberRefExpr                 = 102,
01746 
01747   /** \brief An expression that calls a function. */
01748   CXCursor_CallExpr                      = 103,
01749 
01750   /** \brief An expression that sends a message to an Objective-C
01751    object or class. */
01752   CXCursor_ObjCMessageExpr               = 104,
01753 
01754   /** \brief An expression that represents a block literal. */
01755   CXCursor_BlockExpr                     = 105,
01756 
01757   /** \brief An integer literal.
01758    */
01759   CXCursor_IntegerLiteral                = 106,
01760 
01761   /** \brief A floating point number literal.
01762    */
01763   CXCursor_FloatingLiteral               = 107,
01764 
01765   /** \brief An imaginary number literal.
01766    */
01767   CXCursor_ImaginaryLiteral              = 108,
01768 
01769   /** \brief A string literal.
01770    */
01771   CXCursor_StringLiteral                 = 109,
01772 
01773   /** \brief A character literal.
01774    */
01775   CXCursor_CharacterLiteral              = 110,
01776 
01777   /** \brief A parenthesized expression, e.g. "(1)".
01778    *
01779    * This AST node is only formed if full location information is requested.
01780    */
01781   CXCursor_ParenExpr                     = 111,
01782 
01783   /** \brief This represents the unary-expression's (except sizeof and
01784    * alignof).
01785    */
01786   CXCursor_UnaryOperator                 = 112,
01787 
01788   /** \brief [C99 6.5.2.1] Array Subscripting.
01789    */
01790   CXCursor_ArraySubscriptExpr            = 113,
01791 
01792   /** \brief A builtin binary operation expression such as "x + y" or
01793    * "x <= y".
01794    */
01795   CXCursor_BinaryOperator                = 114,
01796 
01797   /** \brief Compound assignment such as "+=".
01798    */
01799   CXCursor_CompoundAssignOperator        = 115,
01800 
01801   /** \brief The ?: ternary operator.
01802    */
01803   CXCursor_ConditionalOperator           = 116,
01804 
01805   /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
01806    * (C++ [expr.cast]), which uses the syntax (Type)expr.
01807    *
01808    * For example: (int)f.
01809    */
01810   CXCursor_CStyleCastExpr                = 117,
01811 
01812   /** \brief [C99 6.5.2.5]
01813    */
01814   CXCursor_CompoundLiteralExpr           = 118,
01815 
01816   /** \brief Describes an C or C++ initializer list.
01817    */
01818   CXCursor_InitListExpr                  = 119,
01819 
01820   /** \brief The GNU address of label extension, representing &&label.
01821    */
01822   CXCursor_AddrLabelExpr                 = 120,
01823 
01824   /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
01825    */
01826   CXCursor_StmtExpr                      = 121,
01827 
01828   /** \brief Represents a C11 generic selection.
01829    */
01830   CXCursor_GenericSelectionExpr          = 122,
01831 
01832   /** \brief Implements the GNU __null extension, which is a name for a null
01833    * pointer constant that has integral type (e.g., int or long) and is the same
01834    * size and alignment as a pointer.
01835    *
01836    * The __null extension is typically only used by system headers, which define
01837    * NULL as __null in C++ rather than using 0 (which is an integer that may not
01838    * match the size of a pointer).
01839    */
01840   CXCursor_GNUNullExpr                   = 123,
01841 
01842   /** \brief C++'s static_cast<> expression.
01843    */
01844   CXCursor_CXXStaticCastExpr             = 124,
01845 
01846   /** \brief C++'s dynamic_cast<> expression.
01847    */
01848   CXCursor_CXXDynamicCastExpr            = 125,
01849 
01850   /** \brief C++'s reinterpret_cast<> expression.
01851    */
01852   CXCursor_CXXReinterpretCastExpr        = 126,
01853 
01854   /** \brief C++'s const_cast<> expression.
01855    */
01856   CXCursor_CXXConstCastExpr              = 127,
01857 
01858   /** \brief Represents an explicit C++ type conversion that uses "functional"
01859    * notion (C++ [expr.type.conv]).
01860    *
01861    * Example:
01862    * \code
01863    *   x = int(0.5);
01864    * \endcode
01865    */
01866   CXCursor_CXXFunctionalCastExpr         = 128,
01867 
01868   /** \brief A C++ typeid expression (C++ [expr.typeid]).
01869    */
01870   CXCursor_CXXTypeidExpr                 = 129,
01871 
01872   /** \brief [C++ 2.13.5] C++ Boolean Literal.
01873    */
01874   CXCursor_CXXBoolLiteralExpr            = 130,
01875 
01876   /** \brief [C++0x 2.14.7] C++ Pointer Literal.
01877    */
01878   CXCursor_CXXNullPtrLiteralExpr         = 131,
01879 
01880   /** \brief Represents the "this" expression in C++
01881    */
01882   CXCursor_CXXThisExpr                   = 132,
01883 
01884   /** \brief [C++ 15] C++ Throw Expression.
01885    *
01886    * This handles 'throw' and 'throw' assignment-expression. When
01887    * assignment-expression isn't present, Op will be null.
01888    */
01889   CXCursor_CXXThrowExpr                  = 133,
01890 
01891   /** \brief A new expression for memory allocation and constructor calls, e.g:
01892    * "new CXXNewExpr(foo)".
01893    */
01894   CXCursor_CXXNewExpr                    = 134,
01895 
01896   /** \brief A delete expression for memory deallocation and destructor calls,
01897    * e.g. "delete[] pArray".
01898    */
01899   CXCursor_CXXDeleteExpr                 = 135,
01900 
01901   /** \brief A unary expression.
01902    */
01903   CXCursor_UnaryExpr                     = 136,
01904 
01905   /** \brief An Objective-C string literal i.e. @"foo".
01906    */
01907   CXCursor_ObjCStringLiteral             = 137,
01908 
01909   /** \brief An Objective-C \@encode expression.
01910    */
01911   CXCursor_ObjCEncodeExpr                = 138,
01912 
01913   /** \brief An Objective-C \@selector expression.
01914    */
01915   CXCursor_ObjCSelectorExpr              = 139,
01916 
01917   /** \brief An Objective-C \@protocol expression.
01918    */
01919   CXCursor_ObjCProtocolExpr              = 140,
01920 
01921   /** \brief An Objective-C "bridged" cast expression, which casts between
01922    * Objective-C pointers and C pointers, transferring ownership in the process.
01923    *
01924    * \code
01925    *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
01926    * \endcode
01927    */
01928   CXCursor_ObjCBridgedCastExpr           = 141,
01929 
01930   /** \brief Represents a C++0x pack expansion that produces a sequence of
01931    * expressions.
01932    *
01933    * A pack expansion expression contains a pattern (which itself is an
01934    * expression) followed by an ellipsis. For example:
01935    *
01936    * \code
01937    * template<typename F, typename ...Types>
01938    * void forward(F f, Types &&...args) {
01939    *  f(static_cast<Types&&>(args)...);
01940    * }
01941    * \endcode
01942    */
01943   CXCursor_PackExpansionExpr             = 142,
01944 
01945   /** \brief Represents an expression that computes the length of a parameter
01946    * pack.
01947    *
01948    * \code
01949    * template<typename ...Types>
01950    * struct count {
01951    *   static const unsigned value = sizeof...(Types);
01952    * };
01953    * \endcode
01954    */
01955   CXCursor_SizeOfPackExpr                = 143,
01956 
01957   /* \brief Represents a C++ lambda expression that produces a local function
01958    * object.
01959    *
01960    * \code
01961    * void abssort(float *x, unsigned N) {
01962    *   std::sort(x, x + N,
01963    *             [](float a, float b) {
01964    *               return std::abs(a) < std::abs(b);
01965    *             });
01966    * }
01967    * \endcode
01968    */
01969   CXCursor_LambdaExpr                    = 144,
01970   
01971   /** \brief Objective-c Boolean Literal.
01972    */
01973   CXCursor_ObjCBoolLiteralExpr           = 145,
01974 
01975   /** \brief Represents the "self" expression in an Objective-C method.
01976    */
01977   CXCursor_ObjCSelfExpr                  = 146,
01978 
01979   CXCursor_LastExpr                      = CXCursor_ObjCSelfExpr,
01980 
01981   /* Statements */
01982   CXCursor_FirstStmt                     = 200,
01983   /**
01984    * \brief A statement whose specific kind is not exposed via this
01985    * interface.
01986    *
01987    * Unexposed statements have the same operations as any other kind of
01988    * statement; one can extract their location information, spelling,
01989    * children, etc. However, the specific kind of the statement is not
01990    * reported.
01991    */
01992   CXCursor_UnexposedStmt                 = 200,
01993   
01994   /** \brief A labelled statement in a function. 
01995    *
01996    * This cursor kind is used to describe the "start_over:" label statement in 
01997    * the following example:
01998    *
01999    * \code
02000    *   start_over:
02001    *     ++counter;
02002    * \endcode
02003    *
02004    */
02005   CXCursor_LabelStmt                     = 201,
02006 
02007   /** \brief A group of statements like { stmt stmt }.
02008    *
02009    * This cursor kind is used to describe compound statements, e.g. function
02010    * bodies.
02011    */
02012   CXCursor_CompoundStmt                  = 202,
02013 
02014   /** \brief A case statement.
02015    */
02016   CXCursor_CaseStmt                      = 203,
02017 
02018   /** \brief A default statement.
02019    */
02020   CXCursor_DefaultStmt                   = 204,
02021 
02022   /** \brief An if statement
02023    */
02024   CXCursor_IfStmt                        = 205,
02025 
02026   /** \brief A switch statement.
02027    */
02028   CXCursor_SwitchStmt                    = 206,
02029 
02030   /** \brief A while statement.
02031    */
02032   CXCursor_WhileStmt                     = 207,
02033 
02034   /** \brief A do statement.
02035    */
02036   CXCursor_DoStmt                        = 208,
02037 
02038   /** \brief A for statement.
02039    */
02040   CXCursor_ForStmt                       = 209,
02041 
02042   /** \brief A goto statement.
02043    */
02044   CXCursor_GotoStmt                      = 210,
02045 
02046   /** \brief An indirect goto statement.
02047    */
02048   CXCursor_IndirectGotoStmt              = 211,
02049 
02050   /** \brief A continue statement.
02051    */
02052   CXCursor_ContinueStmt                  = 212,
02053 
02054   /** \brief A break statement.
02055    */
02056   CXCursor_BreakStmt                     = 213,
02057 
02058   /** \brief A return statement.
02059    */
02060   CXCursor_ReturnStmt                    = 214,
02061 
02062   /** \brief A GCC inline assembly statement extension.
02063    */
02064   CXCursor_GCCAsmStmt                    = 215,
02065   CXCursor_AsmStmt                       = CXCursor_GCCAsmStmt,
02066 
02067   /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
02068    */
02069   CXCursor_ObjCAtTryStmt                 = 216,
02070 
02071   /** \brief Objective-C's \@catch statement.
02072    */
02073   CXCursor_ObjCAtCatchStmt               = 217,
02074 
02075   /** \brief Objective-C's \@finally statement.
02076    */
02077   CXCursor_ObjCAtFinallyStmt             = 218,
02078 
02079   /** \brief Objective-C's \@throw statement.
02080    */
02081   CXCursor_ObjCAtThrowStmt               = 219,
02082 
02083   /** \brief Objective-C's \@synchronized statement.
02084    */
02085   CXCursor_ObjCAtSynchronizedStmt        = 220,
02086 
02087   /** \brief Objective-C's autorelease pool statement.
02088    */
02089   CXCursor_ObjCAutoreleasePoolStmt       = 221,
02090 
02091   /** \brief Objective-C's collection statement.
02092    */
02093   CXCursor_ObjCForCollectionStmt         = 222,
02094 
02095   /** \brief C++'s catch statement.
02096    */
02097   CXCursor_CXXCatchStmt                  = 223,
02098 
02099   /** \brief C++'s try statement.
02100    */
02101   CXCursor_CXXTryStmt                    = 224,
02102 
02103   /** \brief C++'s for (* : *) statement.
02104    */
02105   CXCursor_CXXForRangeStmt               = 225,
02106 
02107   /** \brief Windows Structured Exception Handling's try statement.
02108    */
02109   CXCursor_SEHTryStmt                    = 226,
02110 
02111   /** \brief Windows Structured Exception Handling's except statement.
02112    */
02113   CXCursor_SEHExceptStmt                 = 227,
02114 
02115   /** \brief Windows Structured Exception Handling's finally statement.
02116    */
02117   CXCursor_SEHFinallyStmt                = 228,
02118 
02119   /** \brief A MS inline assembly statement extension.
02120    */
02121   CXCursor_MSAsmStmt                     = 229,
02122 
02123   /** \brief The null satement ";": C99 6.8.3p3.
02124    *
02125    * This cursor kind is used to describe the null statement.
02126    */
02127   CXCursor_NullStmt                      = 230,
02128 
02129   /** \brief Adaptor class for mixing declarations with statements and
02130    * expressions.
02131    */
02132   CXCursor_DeclStmt                      = 231,
02133 
02134   /** \brief OpenMP parallel directive.
02135    */
02136   CXCursor_OMPParallelDirective          = 232,
02137 
02138   /** \brief OpenMP simd directive.
02139    */
02140   CXCursor_OMPSimdDirective              = 233,
02141 
02142   /** \brief OpenMP for directive.
02143    */
02144   CXCursor_OMPForDirective               = 234,
02145 
02146   /** \brief OpenMP sections directive.
02147    */
02148   CXCursor_OMPSectionsDirective          = 235,
02149 
02150   /** \brief OpenMP section directive.
02151    */
02152   CXCursor_OMPSectionDirective           = 236,
02153 
02154   /** \brief OpenMP single directive.
02155    */
02156   CXCursor_OMPSingleDirective            = 237,
02157 
02158   /** \brief OpenMP parallel for directive.
02159    */
02160   CXCursor_OMPParallelForDirective       = 238,
02161 
02162   /** \brief OpenMP parallel sections directive.
02163    */
02164   CXCursor_OMPParallelSectionsDirective  = 239,
02165 
02166   /** \brief OpenMP task directive.
02167    */
02168   CXCursor_OMPTaskDirective              = 240,
02169 
02170   /** \brief OpenMP master directive.
02171    */
02172   CXCursor_OMPMasterDirective            = 241,
02173 
02174   /** \brief OpenMP critical directive.
02175    */
02176   CXCursor_OMPCriticalDirective          = 242,
02177 
02178   /** \brief OpenMP taskyield directive.
02179    */
02180   CXCursor_OMPTaskyieldDirective         = 243,
02181 
02182   /** \brief OpenMP barrier directive.
02183    */
02184   CXCursor_OMPBarrierDirective           = 244,
02185 
02186   /** \brief OpenMP taskwait directive.
02187    */
02188   CXCursor_OMPTaskwaitDirective          = 245,
02189 
02190   /** \brief OpenMP flush directive.
02191    */
02192   CXCursor_OMPFlushDirective             = 246,
02193 
02194   /** \brief Windows Structured Exception Handling's leave statement.
02195    */
02196   CXCursor_SEHLeaveStmt                  = 247,
02197 
02198   /** \brief OpenMP ordered directive.
02199    */
02200   CXCursor_OMPOrderedDirective           = 248,
02201 
02202   /** \brief OpenMP atomic directive.
02203    */
02204   CXCursor_OMPAtomicDirective            = 249,
02205 
02206   CXCursor_LastStmt                      = CXCursor_OMPAtomicDirective,
02207 
02208   /**
02209    * \brief Cursor that represents the translation unit itself.
02210    *
02211    * The translation unit cursor exists primarily to act as the root
02212    * cursor for traversing the contents of a translation unit.
02213    */
02214   CXCursor_TranslationUnit               = 300,
02215 
02216   /* Attributes */
02217   CXCursor_FirstAttr                     = 400,
02218   /**
02219    * \brief An attribute whose specific kind is not exposed via this
02220    * interface.
02221    */
02222   CXCursor_UnexposedAttr                 = 400,
02223 
02224   CXCursor_IBActionAttr                  = 401,
02225   CXCursor_IBOutletAttr                  = 402,
02226   CXCursor_IBOutletCollectionAttr        = 403,
02227   CXCursor_CXXFinalAttr                  = 404,
02228   CXCursor_CXXOverrideAttr               = 405,
02229   CXCursor_AnnotateAttr                  = 406,
02230   CXCursor_AsmLabelAttr                  = 407,
02231   CXCursor_PackedAttr                    = 408,
02232   CXCursor_PureAttr                      = 409,
02233   CXCursor_ConstAttr                     = 410,
02234   CXCursor_NoDuplicateAttr               = 411,
02235   CXCursor_CUDAConstantAttr              = 412,
02236   CXCursor_CUDADeviceAttr                = 413,
02237   CXCursor_CUDAGlobalAttr                = 414,
02238   CXCursor_CUDAHostAttr                  = 415,
02239   CXCursor_LastAttr                      = CXCursor_CUDAHostAttr,
02240 
02241   /* Preprocessing */
02242   CXCursor_PreprocessingDirective        = 500,
02243   CXCursor_MacroDefinition               = 501,
02244   CXCursor_MacroExpansion                = 502,
02245   CXCursor_MacroInstantiation            = CXCursor_MacroExpansion,
02246   CXCursor_InclusionDirective            = 503,
02247   CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
02248   CXCursor_LastPreprocessing             = CXCursor_InclusionDirective,
02249 
02250   /* Extra Declarations */
02251   /**
02252    * \brief A module import declaration.
02253    */
02254   CXCursor_ModuleImportDecl              = 600,
02255   CXCursor_FirstExtraDecl                = CXCursor_ModuleImportDecl,
02256   CXCursor_LastExtraDecl                 = CXCursor_ModuleImportDecl
02257 };
02258 
02259 /**
02260  * \brief A cursor representing some element in the abstract syntax tree for
02261  * a translation unit.
02262  *
02263  * The cursor abstraction unifies the different kinds of entities in a
02264  * program--declaration, statements, expressions, references to declarations,
02265  * etc.--under a single "cursor" abstraction with a common set of operations.
02266  * Common operation for a cursor include: getting the physical location in
02267  * a source file where the cursor points, getting the name associated with a
02268  * cursor, and retrieving cursors for any child nodes of a particular cursor.
02269  *
02270  * Cursors can be produced in two specific ways.
02271  * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
02272  * from which one can use clang_visitChildren() to explore the rest of the
02273  * translation unit. clang_getCursor() maps from a physical source location
02274  * to the entity that resides at that location, allowing one to map from the
02275  * source code into the AST.
02276  */
02277 typedef struct {
02278   enum CXCursorKind kind;
02279   int xdata;
02280   const void *data[3];
02281 } CXCursor;
02282 
02283 /**
02284  * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
02285  *
02286  * @{
02287  */
02288 
02289 /**
02290  * \brief Retrieve the NULL cursor, which represents no entity.
02291  */
02292 CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
02293 
02294 /**
02295  * \brief Retrieve the cursor that represents the given translation unit.
02296  *
02297  * The translation unit cursor can be used to start traversing the
02298  * various declarations within the given translation unit.
02299  */
02300 CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
02301 
02302 /**
02303  * \brief Determine whether two cursors are equivalent.
02304  */
02305 CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
02306 
02307 /**
02308  * \brief Returns non-zero if \p cursor is null.
02309  */
02310 CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
02311 
02312 /**
02313  * \brief Compute a hash value for the given cursor.
02314  */
02315 CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
02316   
02317 /**
02318  * \brief Retrieve the kind of the given cursor.
02319  */
02320 CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
02321 
02322 /**
02323  * \brief Determine whether the given cursor kind represents a declaration.
02324  */
02325 CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
02326 
02327 /**
02328  * \brief Determine whether the given cursor kind represents a simple
02329  * reference.
02330  *
02331  * Note that other kinds of cursors (such as expressions) can also refer to
02332  * other cursors. Use clang_getCursorReferenced() to determine whether a
02333  * particular cursor refers to another entity.
02334  */
02335 CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
02336 
02337 /**
02338  * \brief Determine whether the given cursor kind represents an expression.
02339  */
02340 CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
02341 
02342 /**
02343  * \brief Determine whether the given cursor kind represents a statement.
02344  */
02345 CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
02346 
02347 /**
02348  * \brief Determine whether the given cursor kind represents an attribute.
02349  */
02350 CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
02351 
02352 /**
02353  * \brief Determine whether the given cursor kind represents an invalid
02354  * cursor.
02355  */
02356 CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
02357 
02358 /**
02359  * \brief Determine whether the given cursor kind represents a translation
02360  * unit.
02361  */
02362 CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
02363 
02364 /***
02365  * \brief Determine whether the given cursor represents a preprocessing
02366  * element, such as a preprocessor directive or macro instantiation.
02367  */
02368 CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
02369   
02370 /***
02371  * \brief Determine whether the given cursor represents a currently
02372  *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
02373  */
02374 CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
02375 
02376 /**
02377  * \brief Describe the linkage of the entity referred to by a cursor.
02378  */
02379 enum CXLinkageKind {
02380   /** \brief This value indicates that no linkage information is available
02381    * for a provided CXCursor. */
02382   CXLinkage_Invalid,
02383   /**
02384    * \brief This is the linkage for variables, parameters, and so on that
02385    *  have automatic storage.  This covers normal (non-extern) local variables.
02386    */
02387   CXLinkage_NoLinkage,
02388   /** \brief This is the linkage for static variables and static functions. */
02389   CXLinkage_Internal,
02390   /** \brief This is the linkage for entities with external linkage that live
02391    * in C++ anonymous namespaces.*/
02392   CXLinkage_UniqueExternal,
02393   /** \brief This is the linkage for entities with true, external linkage. */
02394   CXLinkage_External
02395 };
02396 
02397 /**
02398  * \brief Determine the linkage of the entity referred to by a given cursor.
02399  */
02400 CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
02401 
02402 /**
02403  * \brief Determine the availability of the entity that this cursor refers to,
02404  * taking the current target platform into account.
02405  *
02406  * \param cursor The cursor to query.
02407  *
02408  * \returns The availability of the cursor.
02409  */
02410 CINDEX_LINKAGE enum CXAvailabilityKind 
02411 clang_getCursorAvailability(CXCursor cursor);
02412 
02413 /**
02414  * Describes the availability of a given entity on a particular platform, e.g.,
02415  * a particular class might only be available on Mac OS 10.7 or newer.
02416  */
02417 typedef struct CXPlatformAvailability {
02418   /**
02419    * \brief A string that describes the platform for which this structure
02420    * provides availability information.
02421    *
02422    * Possible values are "ios" or "macosx".
02423    */
02424   CXString Platform;
02425   /**
02426    * \brief The version number in which this entity was introduced.
02427    */
02428   CXVersion Introduced;
02429   /**
02430    * \brief The version number in which this entity was deprecated (but is
02431    * still available).
02432    */
02433   CXVersion Deprecated;
02434   /**
02435    * \brief The version number in which this entity was obsoleted, and therefore
02436    * is no longer available.
02437    */
02438   CXVersion Obsoleted;
02439   /**
02440    * \brief Whether the entity is unconditionally unavailable on this platform.
02441    */
02442   int Unavailable;
02443   /**
02444    * \brief An optional message to provide to a user of this API, e.g., to
02445    * suggest replacement APIs.
02446    */
02447   CXString Message;
02448 } CXPlatformAvailability;
02449 
02450 /**
02451  * \brief Determine the availability of the entity that this cursor refers to
02452  * on any platforms for which availability information is known.
02453  *
02454  * \param cursor The cursor to query.
02455  *
02456  * \param always_deprecated If non-NULL, will be set to indicate whether the 
02457  * entity is deprecated on all platforms.
02458  *
02459  * \param deprecated_message If non-NULL, will be set to the message text 
02460  * provided along with the unconditional deprecation of this entity. The client
02461  * is responsible for deallocating this string.
02462  *
02463  * \param always_unavailable If non-NULL, will be set to indicate whether the
02464  * entity is unavailable on all platforms.
02465  *
02466  * \param unavailable_message If non-NULL, will be set to the message text
02467  * provided along with the unconditional unavailability of this entity. The 
02468  * client is responsible for deallocating this string.
02469  *
02470  * \param availability If non-NULL, an array of CXPlatformAvailability instances
02471  * that will be populated with platform availability information, up to either
02472  * the number of platforms for which availability information is available (as
02473  * returned by this function) or \c availability_size, whichever is smaller.
02474  *
02475  * \param availability_size The number of elements available in the 
02476  * \c availability array.
02477  *
02478  * \returns The number of platforms (N) for which availability information is
02479  * available (which is unrelated to \c availability_size).
02480  *
02481  * Note that the client is responsible for calling 
02482  * \c clang_disposeCXPlatformAvailability to free each of the 
02483  * platform-availability structures returned. There are 
02484  * \c min(N, availability_size) such structures.
02485  */
02486 CINDEX_LINKAGE int
02487 clang_getCursorPlatformAvailability(CXCursor cursor,
02488                                     int *always_deprecated,
02489                                     CXString *deprecated_message,
02490                                     int *always_unavailable,
02491                                     CXString *unavailable_message,
02492                                     CXPlatformAvailability *availability,
02493                                     int availability_size);
02494 
02495 /**
02496  * \brief Free the memory associated with a \c CXPlatformAvailability structure.
02497  */
02498 CINDEX_LINKAGE void
02499 clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
02500   
02501 /**
02502  * \brief Describe the "language" of the entity referred to by a cursor.
02503  */
02504 enum CXLanguageKind {
02505   CXLanguage_Invalid = 0,
02506   CXLanguage_C,
02507   CXLanguage_ObjC,
02508   CXLanguage_CPlusPlus
02509 };
02510 
02511 /**
02512  * \brief Determine the "language" of the entity referred to by a given cursor.
02513  */
02514 CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
02515 
02516 /**
02517  * \brief Returns the translation unit that a cursor originated from.
02518  */
02519 CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
02520 
02521 
02522 /**
02523  * \brief A fast container representing a set of CXCursors.
02524  */
02525 typedef struct CXCursorSetImpl *CXCursorSet;
02526 
02527 /**
02528  * \brief Creates an empty CXCursorSet.
02529  */
02530 CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
02531 
02532 /**
02533  * \brief Disposes a CXCursorSet and releases its associated memory.
02534  */
02535 CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
02536 
02537 /**
02538  * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
02539  *
02540  * \returns non-zero if the set contains the specified cursor.
02541 */
02542 CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
02543                                                    CXCursor cursor);
02544 
02545 /**
02546  * \brief Inserts a CXCursor into a CXCursorSet.
02547  *
02548  * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
02549 */
02550 CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
02551                                                  CXCursor cursor);
02552 
02553 /**
02554  * \brief Determine the semantic parent of the given cursor.
02555  *
02556  * The semantic parent of a cursor is the cursor that semantically contains
02557  * the given \p cursor. For many declarations, the lexical and semantic parents
02558  * are equivalent (the lexical parent is returned by 
02559  * \c clang_getCursorLexicalParent()). They diverge when declarations or
02560  * definitions are provided out-of-line. For example:
02561  *
02562  * \code
02563  * class C {
02564  *  void f();
02565  * };
02566  *
02567  * void C::f() { }
02568  * \endcode
02569  *
02570  * In the out-of-line definition of \c C::f, the semantic parent is
02571  * the class \c C, of which this function is a member. The lexical parent is
02572  * the place where the declaration actually occurs in the source code; in this
02573  * case, the definition occurs in the translation unit. In general, the
02574  * lexical parent for a given entity can change without affecting the semantics
02575  * of the program, and the lexical parent of different declarations of the
02576  * same entity may be different. Changing the semantic parent of a declaration,
02577  * on the other hand, can have a major impact on semantics, and redeclarations
02578  * of a particular entity should all have the same semantic context.
02579  *
02580  * In the example above, both declarations of \c C::f have \c C as their
02581  * semantic context, while the lexical context of the first \c C::f is \c C
02582  * and the lexical context of the second \c C::f is the translation unit.
02583  *
02584  * For global declarations, the semantic parent is the translation unit.
02585  */
02586 CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
02587 
02588 /**
02589  * \brief Determine the lexical parent of the given cursor.
02590  *
02591  * The lexical parent of a cursor is the cursor in which the given \p cursor
02592  * was actually written. For many declarations, the lexical and semantic parents
02593  * are equivalent (the semantic parent is returned by 
02594  * \c clang_getCursorSemanticParent()). They diverge when declarations or
02595  * definitions are provided out-of-line. For example:
02596  *
02597  * \code
02598  * class C {
02599  *  void f();
02600  * };
02601  *
02602  * void C::f() { }
02603  * \endcode
02604  *
02605  * In the out-of-line definition of \c C::f, the semantic parent is
02606  * the class \c C, of which this function is a member. The lexical parent is
02607  * the place where the declaration actually occurs in the source code; in this
02608  * case, the definition occurs in the translation unit. In general, the
02609  * lexical parent for a given entity can change without affecting the semantics
02610  * of the program, and the lexical parent of different declarations of the
02611  * same entity may be different. Changing the semantic parent of a declaration,
02612  * on the other hand, can have a major impact on semantics, and redeclarations
02613  * of a particular entity should all have the same semantic context.
02614  *
02615  * In the example above, both declarations of \c C::f have \c C as their
02616  * semantic context, while the lexical context of the first \c C::f is \c C
02617  * and the lexical context of the second \c C::f is the translation unit.
02618  *
02619  * For declarations written in the global scope, the lexical parent is
02620  * the translation unit.
02621  */
02622 CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
02623 
02624 /**
02625  * \brief Determine the set of methods that are overridden by the given
02626  * method.
02627  *
02628  * In both Objective-C and C++, a method (aka virtual member function,
02629  * in C++) can override a virtual method in a base class. For
02630  * Objective-C, a method is said to override any method in the class's
02631  * base class, its protocols, or its categories' protocols, that has the same
02632  * selector and is of the same kind (class or instance).
02633  * If no such method exists, the search continues to the class's superclass,
02634  * its protocols, and its categories, and so on. A method from an Objective-C
02635  * implementation is considered to override the same methods as its
02636  * corresponding method in the interface.
02637  *
02638  * For C++, a virtual member function overrides any virtual member
02639  * function with the same signature that occurs in its base
02640  * classes. With multiple inheritance, a virtual member function can
02641  * override several virtual member functions coming from different
02642  * base classes.
02643  *
02644  * In all cases, this function determines the immediate overridden
02645  * method, rather than all of the overridden methods. For example, if
02646  * a method is originally declared in a class A, then overridden in B
02647  * (which in inherits from A) and also in C (which inherited from B),
02648  * then the only overridden method returned from this function when
02649  * invoked on C's method will be B's method. The client may then
02650  * invoke this function again, given the previously-found overridden
02651  * methods, to map out the complete method-override set.
02652  *
02653  * \param cursor A cursor representing an Objective-C or C++
02654  * method. This routine will compute the set of methods that this
02655  * method overrides.
02656  * 
02657  * \param overridden A pointer whose pointee will be replaced with a
02658  * pointer to an array of cursors, representing the set of overridden
02659  * methods. If there are no overridden methods, the pointee will be
02660  * set to NULL. The pointee must be freed via a call to 
02661  * \c clang_disposeOverriddenCursors().
02662  *
02663  * \param num_overridden A pointer to the number of overridden
02664  * functions, will be set to the number of overridden functions in the
02665  * array pointed to by \p overridden.
02666  */
02667 CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, 
02668                                                CXCursor **overridden,
02669                                                unsigned *num_overridden);
02670 
02671 /**
02672  * \brief Free the set of overridden cursors returned by \c
02673  * clang_getOverriddenCursors().
02674  */
02675 CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
02676 
02677 /**
02678  * \brief Retrieve the file that is included by the given inclusion directive
02679  * cursor.
02680  */
02681 CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
02682   
02683 /**
02684  * @}
02685  */
02686 
02687 /**
02688  * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
02689  *
02690  * Cursors represent a location within the Abstract Syntax Tree (AST). These
02691  * routines help map between cursors and the physical locations where the
02692  * described entities occur in the source code. The mapping is provided in
02693  * both directions, so one can map from source code to the AST and back.
02694  *
02695  * @{
02696  */
02697 
02698 /**
02699  * \brief Map a source location to the cursor that describes the entity at that
02700  * location in the source code.
02701  *
02702  * clang_getCursor() maps an arbitrary source location within a translation
02703  * unit down to the most specific cursor that describes the entity at that
02704  * location. For example, given an expression \c x + y, invoking
02705  * clang_getCursor() with a source location pointing to "x" will return the
02706  * cursor for "x"; similarly for "y". If the cursor points anywhere between
02707  * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
02708  * will return a cursor referring to the "+" expression.
02709  *
02710  * \returns a cursor representing the entity at the given source location, or
02711  * a NULL cursor if no such entity can be found.
02712  */
02713 CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
02714 
02715 /**
02716  * \brief Retrieve the physical location of the source constructor referenced
02717  * by the given cursor.
02718  *
02719  * The location of a declaration is typically the location of the name of that
02720  * declaration, where the name of that declaration would occur if it is
02721  * unnamed, or some keyword that introduces that particular declaration.
02722  * The location of a reference is where that reference occurs within the
02723  * source code.
02724  */
02725 CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
02726 
02727 /**
02728  * \brief Retrieve the physical extent of the source construct referenced by
02729  * the given cursor.
02730  *
02731  * The extent of a cursor starts with the file/line/column pointing at the
02732  * first character within the source construct that the cursor refers to and
02733  * ends with the last character within that source construct. For a
02734  * declaration, the extent covers the declaration itself. For a reference,
02735  * the extent covers the location of the reference (e.g., where the referenced
02736  * entity was actually used).
02737  */
02738 CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
02739 
02740 /**
02741  * @}
02742  */
02743     
02744 /**
02745  * \defgroup CINDEX_TYPES Type information for CXCursors
02746  *
02747  * @{
02748  */
02749 
02750 /**
02751  * \brief Describes the kind of type
02752  */
02753 enum CXTypeKind {
02754   /**
02755    * \brief Represents an invalid type (e.g., where no type is available).
02756    */
02757   CXType_Invalid = 0,
02758 
02759   /**
02760    * \brief A type whose specific kind is not exposed via this
02761    * interface.
02762    */
02763   CXType_Unexposed = 1,
02764 
02765   /* Builtin types */
02766   CXType_Void = 2,
02767   CXType_Bool = 3,
02768   CXType_Char_U = 4,
02769   CXType_UChar = 5,
02770   CXType_Char16 = 6,
02771   CXType_Char32 = 7,
02772   CXType_UShort = 8,
02773   CXType_UInt = 9,
02774   CXType_ULong = 10,
02775   CXType_ULongLong = 11,
02776   CXType_UInt128 = 12,
02777   CXType_Char_S = 13,
02778   CXType_SChar = 14,
02779   CXType_WChar = 15,
02780   CXType_Short = 16,
02781   CXType_Int = 17,
02782   CXType_Long = 18,
02783   CXType_LongLong = 19,
02784   CXType_Int128 = 20,
02785   CXType_Float = 21,
02786   CXType_Double = 22,
02787   CXType_LongDouble = 23,
02788   CXType_NullPtr = 24,
02789   CXType_Overload = 25,
02790   CXType_Dependent = 26,
02791   CXType_ObjCId = 27,
02792   CXType_ObjCClass = 28,
02793   CXType_ObjCSel = 29,
02794   CXType_FirstBuiltin = CXType_Void,
02795   CXType_LastBuiltin  = CXType_ObjCSel,
02796 
02797   CXType_Complex = 100,
02798   CXType_Pointer = 101,
02799   CXType_BlockPointer = 102,
02800   CXType_LValueReference = 103,
02801   CXType_RValueReference = 104,
02802   CXType_Record = 105,
02803   CXType_Enum = 106,
02804   CXType_Typedef = 107,
02805   CXType_ObjCInterface = 108,
02806   CXType_ObjCObjectPointer = 109,
02807   CXType_FunctionNoProto = 110,
02808   CXType_FunctionProto = 111,
02809   CXType_ConstantArray = 112,
02810   CXType_Vector = 113,
02811   CXType_IncompleteArray = 114,
02812   CXType_VariableArray = 115,
02813   CXType_DependentSizedArray = 116,
02814   CXType_MemberPointer = 117
02815 };
02816 
02817 /**
02818  * \brief Describes the calling convention of a function type
02819  */
02820 enum CXCallingConv {
02821   CXCallingConv_Default = 0,
02822   CXCallingConv_C = 1,
02823   CXCallingConv_X86StdCall = 2,
02824   CXCallingConv_X86FastCall = 3,
02825   CXCallingConv_X86ThisCall = 4,
02826   CXCallingConv_X86Pascal = 5,
02827   CXCallingConv_AAPCS = 6,
02828   CXCallingConv_AAPCS_VFP = 7,
02829   CXCallingConv_PnaclCall = 8,
02830   CXCallingConv_IntelOclBicc = 9,
02831   CXCallingConv_X86_64Win64 = 10,
02832   CXCallingConv_X86_64SysV = 11,
02833 
02834   CXCallingConv_Invalid = 100,
02835   CXCallingConv_Unexposed = 200
02836 };
02837 
02838 
02839 /**
02840  * \brief The type of an element in the abstract syntax tree.
02841  *
02842  */
02843 typedef struct {
02844   enum CXTypeKind kind;
02845   void *data[2];
02846 } CXType;
02847 
02848 /**
02849  * \brief Retrieve the type of a CXCursor (if any).
02850  */
02851 CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
02852 
02853 /**
02854  * \brief Pretty-print the underlying type using the rules of the
02855  * language of the translation unit from which it came.
02856  *
02857  * If the type is invalid, an empty string is returned.
02858  */
02859 CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
02860 
02861 /**
02862  * \brief Retrieve the underlying type of a typedef declaration.
02863  *
02864  * If the cursor does not reference a typedef declaration, an invalid type is
02865  * returned.
02866  */
02867 CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
02868 
02869 /**
02870  * \brief Retrieve the integer type of an enum declaration.
02871  *
02872  * If the cursor does not reference an enum declaration, an invalid type is
02873  * returned.
02874  */
02875 CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
02876 
02877 /**
02878  * \brief Retrieve the integer value of an enum constant declaration as a signed
02879  *  long long.
02880  *
02881  * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
02882  * Since this is also potentially a valid constant value, the kind of the cursor
02883  * must be verified before calling this function.
02884  */
02885 CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
02886 
02887 /**
02888  * \brief Retrieve the integer value of an enum constant declaration as an unsigned
02889  *  long long.
02890  *
02891  * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
02892  * Since this is also potentially a valid constant value, the kind of the cursor
02893  * must be verified before calling this function.
02894  */
02895 CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
02896 
02897 /**
02898  * \brief Retrieve the bit width of a bit field declaration as an integer.
02899  *
02900  * If a cursor that is not a bit field declaration is passed in, -1 is returned.
02901  */
02902 CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
02903 
02904 /**
02905  * \brief Retrieve the number of non-variadic arguments associated with a given
02906  * cursor.
02907  *
02908  * The number of arguments can be determined for calls as well as for
02909  * declarations of functions or methods. For other cursors -1 is returned.
02910  */
02911 CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
02912 
02913 /**
02914  * \brief Retrieve the argument cursor of a function or method.
02915  *
02916  * The argument cursor can be determined for calls as well as for declarations
02917  * of functions or methods. For other cursors and for invalid indices, an
02918  * invalid cursor is returned.
02919  */
02920 CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
02921 
02922 /**
02923  * \brief Determine whether two CXTypes represent the same type.
02924  *
02925  * \returns non-zero if the CXTypes represent the same type and
02926  *          zero otherwise.
02927  */
02928 CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
02929 
02930 /**
02931  * \brief Return the canonical type for a CXType.
02932  *
02933  * Clang's type system explicitly models typedefs and all the ways
02934  * a specific type can be represented.  The canonical type is the underlying
02935  * type with all the "sugar" removed.  For example, if 'T' is a typedef
02936  * for 'int', the canonical type for 'T' would be 'int'.
02937  */
02938 CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
02939 
02940 /**
02941  * \brief Determine whether a CXType has the "const" qualifier set,
02942  * without looking through typedefs that may have added "const" at a
02943  * different level.
02944  */
02945 CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
02946 
02947 /**
02948  * \brief Determine whether a CXType has the "volatile" qualifier set,
02949  * without looking through typedefs that may have added "volatile" at
02950  * a different level.
02951  */
02952 CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
02953 
02954 /**
02955  * \brief Determine whether a CXType has the "restrict" qualifier set,
02956  * without looking through typedefs that may have added "restrict" at a
02957  * different level.
02958  */
02959 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
02960 
02961 /**
02962  * \brief For pointer types, returns the type of the pointee.
02963  */
02964 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
02965 
02966 /**
02967  * \brief Return the cursor for the declaration of the given type.
02968  */
02969 CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
02970 
02971 /**
02972  * Returns the Objective-C type encoding for the specified declaration.
02973  */
02974 CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
02975 
02976 /**
02977  * \brief Retrieve the spelling of a given CXTypeKind.
02978  */
02979 CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
02980 
02981 /**
02982  * \brief Retrieve the calling convention associated with a function type.
02983  *
02984  * If a non-function type is passed in, CXCallingConv_Invalid is returned.
02985  */
02986 CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
02987 
02988 /**
02989  * \brief Retrieve the return type associated with a function type.
02990  *
02991  * If a non-function type is passed in, an invalid type is returned.
02992  */
02993 CINDEX_LINKAGE CXType clang_getResultType(CXType T);
02994 
02995 /**
02996  * \brief Retrieve the number of non-variadic parameters associated with a
02997  * function type.
02998  *
02999  * If a non-function type is passed in, -1 is returned.
03000  */
03001 CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
03002 
03003 /**
03004  * \brief Retrieve the type of a parameter of a function type.
03005  *
03006  * If a non-function type is passed in or the function does not have enough
03007  * parameters, an invalid type is returned.
03008  */
03009 CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
03010 
03011 /**
03012  * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
03013  */
03014 CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
03015 
03016 /**
03017  * \brief Retrieve the return type associated with a given cursor.
03018  *
03019  * This only returns a valid type if the cursor refers to a function or method.
03020  */
03021 CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
03022 
03023 /**
03024  * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
03025  *  otherwise.
03026  */
03027 CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
03028 
03029 /**
03030  * \brief Return the element type of an array, complex, or vector type.
03031  *
03032  * If a type is passed in that is not an array, complex, or vector type,
03033  * an invalid type is returned.
03034  */
03035 CINDEX_LINKAGE CXType clang_getElementType(CXType T);
03036 
03037 /**
03038  * \brief Return the number of elements of an array or vector type.
03039  *
03040  * If a type is passed in that is not an array or vector type,
03041  * -1 is returned.
03042  */
03043 CINDEX_LINKAGE long long clang_getNumElements(CXType T);
03044 
03045 /**
03046  * \brief Return the element type of an array type.
03047  *
03048  * If a non-array type is passed in, an invalid type is returned.
03049  */
03050 CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
03051 
03052 /**
03053  * \brief Return the array size of a constant array.
03054  *
03055  * If a non-array type is passed in, -1 is returned.
03056  */
03057 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
03058 
03059 /**
03060  * \brief List the possible error codes for \c clang_Type_getSizeOf,
03061  *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
03062  *   \c clang_Cursor_getOffsetOf.
03063  *
03064  * A value of this enumeration type can be returned if the target type is not
03065  * a valid argument to sizeof, alignof or offsetof.
03066  */
03067 enum CXTypeLayoutError {
03068   /**
03069    * \brief Type is of kind CXType_Invalid.
03070    */
03071   CXTypeLayoutError_Invalid = -1,
03072   /**
03073    * \brief The type is an incomplete Type.
03074    */
03075   CXTypeLayoutError_Incomplete = -2,
03076   /**
03077    * \brief The type is a dependent Type.
03078    */
03079   CXTypeLayoutError_Dependent = -3,
03080   /**
03081    * \brief The type is not a constant size type.
03082    */
03083   CXTypeLayoutError_NotConstantSize = -4,
03084   /**
03085    * \brief The Field name is not valid for this record.
03086    */
03087   CXTypeLayoutError_InvalidFieldName = -5
03088 };
03089 
03090 /**
03091  * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
03092  *   standard.
03093  *
03094  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
03095  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
03096  *   is returned.
03097  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
03098  *   returned.
03099  * If the type declaration is not a constant size type,
03100  *   CXTypeLayoutError_NotConstantSize is returned.
03101  */
03102 CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
03103 
03104 /**
03105  * \brief Return the class type of an member pointer type.
03106  *
03107  * If a non-member-pointer type is passed in, an invalid type is returned.
03108  */
03109 CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
03110 
03111 /**
03112  * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
03113  *
03114  * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
03115  * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
03116  *   is returned.
03117  * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
03118  *   returned.
03119  */
03120 CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
03121 
03122 /**
03123  * \brief Return the offset of a field named S in a record of type T in bits
03124  *   as it would be returned by __offsetof__ as per C++11[18.2p4]
03125  *
03126  * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
03127  *   is returned.
03128  * If the field's type declaration is an incomplete type,
03129  *   CXTypeLayoutError_Incomplete is returned.
03130  * If the field's type declaration is a dependent type,
03131  *   CXTypeLayoutError_Dependent is returned.
03132  * If the field's name S is not found,
03133  *   CXTypeLayoutError_InvalidFieldName is returned.
03134  */
03135 CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
03136 
03137 enum CXRefQualifierKind {
03138   /** \brief No ref-qualifier was provided. */
03139   CXRefQualifier_None = 0,
03140   /** \brief An lvalue ref-qualifier was provided (\c &). */
03141   CXRefQualifier_LValue,
03142   /** \brief An rvalue ref-qualifier was provided (\c &&). */
03143   CXRefQualifier_RValue
03144 };
03145 
03146 /**
03147  * \brief Returns the number of template arguments for given class template
03148  * specialization, or -1 if type \c T is not a class template specialization.
03149  *
03150  * Variadic argument packs count as only one argument, and can not be inspected
03151  * further.
03152  */
03153 CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
03154 
03155 /**
03156  * \brief Returns the type template argument of a template class specialization
03157  * at given index.
03158  *
03159  * This function only returns template type arguments and does not handle
03160  * template template arguments or variadic packs.
03161  */
03162 CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
03163 
03164 /**
03165  * \brief Retrieve the ref-qualifier kind of a function or method.
03166  *
03167  * The ref-qualifier is returned for C++ functions or methods. For other types
03168  * or non-C++ declarations, CXRefQualifier_None is returned.
03169  */
03170 CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
03171 
03172 /**
03173  * \brief Returns non-zero if the cursor specifies a Record member that is a
03174  *   bitfield.
03175  */
03176 CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
03177 
03178 /**
03179  * \brief Returns 1 if the base class specified by the cursor with kind
03180  *   CX_CXXBaseSpecifier is virtual.
03181  */
03182 CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
03183     
03184 /**
03185  * \brief Represents the C++ access control level to a base class for a
03186  * cursor with kind CX_CXXBaseSpecifier.
03187  */
03188 enum CX_CXXAccessSpecifier {
03189   CX_CXXInvalidAccessSpecifier,
03190   CX_CXXPublic,
03191   CX_CXXProtected,
03192   CX_CXXPrivate
03193 };
03194 
03195 /**
03196  * \brief Returns the access control level for the referenced object.
03197  *
03198  * If the cursor refers to a C++ declaration, its access control level within its
03199  * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
03200  * access specifier, the specifier itself is returned.
03201  */
03202 CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
03203 
03204 /**
03205  * \brief Determine the number of overloaded declarations referenced by a 
03206  * \c CXCursor_OverloadedDeclRef cursor.
03207  *
03208  * \param cursor The cursor whose overloaded declarations are being queried.
03209  *
03210  * \returns The number of overloaded declarations referenced by \c cursor. If it
03211  * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
03212  */
03213 CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
03214 
03215 /**
03216  * \brief Retrieve a cursor for one of the overloaded declarations referenced
03217  * by a \c CXCursor_OverloadedDeclRef cursor.
03218  *
03219  * \param cursor The cursor whose overloaded declarations are being queried.
03220  *
03221  * \param index The zero-based index into the set of overloaded declarations in
03222  * the cursor.
03223  *
03224  * \returns A cursor representing the declaration referenced by the given 
03225  * \c cursor at the specified \c index. If the cursor does not have an 
03226  * associated set of overloaded declarations, or if the index is out of bounds,
03227  * returns \c clang_getNullCursor();
03228  */
03229 CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, 
03230                                                 unsigned index);
03231   
03232 /**
03233  * @}
03234  */
03235   
03236 /**
03237  * \defgroup CINDEX_ATTRIBUTES Information for attributes
03238  *
03239  * @{
03240  */
03241 
03242 
03243 /**
03244  * \brief For cursors representing an iboutletcollection attribute,
03245  *  this function returns the collection element type.
03246  *
03247  */
03248 CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
03249 
03250 /**
03251  * @}
03252  */
03253 
03254 /**
03255  * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
03256  *
03257  * These routines provide the ability to traverse the abstract syntax tree
03258  * using cursors.
03259  *
03260  * @{
03261  */
03262 
03263 /**
03264  * \brief Describes how the traversal of the children of a particular
03265  * cursor should proceed after visiting a particular child cursor.
03266  *
03267  * A value of this enumeration type should be returned by each
03268  * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
03269  */
03270 enum CXChildVisitResult {
03271   /**
03272    * \brief Terminates the cursor traversal.
03273    */
03274   CXChildVisit_Break,
03275   /**
03276    * \brief Continues the cursor traversal with the next sibling of
03277    * the cursor just visited, without visiting its children.
03278    */
03279   CXChildVisit_Continue,
03280   /**
03281    * \brief Recursively traverse the children of this cursor, using
03282    * the same visitor and client data.
03283    */
03284   CXChildVisit_Recurse
03285 };
03286 
03287 /**
03288  * \brief Visitor invoked for each cursor found by a traversal.
03289  *
03290  * This visitor function will be invoked for each cursor found by
03291  * clang_visitCursorChildren(). Its first argument is the cursor being
03292  * visited, its second argument is the parent visitor for that cursor,
03293  * and its third argument is the client data provided to
03294  * clang_visitCursorChildren().
03295  *
03296  * The visitor should return one of the \c CXChildVisitResult values
03297  * to direct clang_visitCursorChildren().
03298  */
03299 typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
03300                                                    CXCursor parent,
03301                                                    CXClientData client_data);
03302 
03303 /**
03304  * \brief Visit the children of a particular cursor.
03305  *
03306  * This function visits all the direct children of the given cursor,
03307  * invoking the given \p visitor function with the cursors of each
03308  * visited child. The traversal may be recursive, if the visitor returns
03309  * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
03310  * the visitor returns \c CXChildVisit_Break.
03311  *
03312  * \param parent the cursor whose child may be visited. All kinds of
03313  * cursors can be visited, including invalid cursors (which, by
03314  * definition, have no children).
03315  *
03316  * \param visitor the visitor function that will be invoked for each
03317  * child of \p parent.
03318  *
03319  * \param client_data pointer data supplied by the client, which will
03320  * be passed to the visitor each time it is invoked.
03321  *
03322  * \returns a non-zero value if the traversal was terminated
03323  * prematurely by the visitor returning \c CXChildVisit_Break.
03324  */
03325 CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
03326                                             CXCursorVisitor visitor,
03327                                             CXClientData client_data);
03328 #ifdef __has_feature
03329 #  if __has_feature(blocks)
03330 /**
03331  * \brief Visitor invoked for each cursor found by a traversal.
03332  *
03333  * This visitor block will be invoked for each cursor found by
03334  * clang_visitChildrenWithBlock(). Its first argument is the cursor being
03335  * visited, its second argument is the parent visitor for that cursor.
03336  *
03337  * The visitor should return one of the \c CXChildVisitResult values
03338  * to direct clang_visitChildrenWithBlock().
03339  */
03340 typedef enum CXChildVisitResult 
03341      (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
03342 
03343 /**
03344  * Visits the children of a cursor using the specified block.  Behaves
03345  * identically to clang_visitChildren() in all other respects.
03346  */
03347 unsigned clang_visitChildrenWithBlock(CXCursor parent,
03348                                       CXCursorVisitorBlock block);
03349 #  endif
03350 #endif
03351 
03352 /**
03353  * @}
03354  */
03355 
03356 /**
03357  * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
03358  *
03359  * These routines provide the ability to determine references within and
03360  * across translation units, by providing the names of the entities referenced
03361  * by cursors, follow reference cursors to the declarations they reference,
03362  * and associate declarations with their definitions.
03363  *
03364  * @{
03365  */
03366 
03367 /**
03368  * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
03369  * by the given cursor.
03370  *
03371  * A Unified Symbol Resolution (USR) is a string that identifies a particular
03372  * entity (function, class, variable, etc.) within a program. USRs can be
03373  * compared across translation units to determine, e.g., when references in
03374  * one translation refer to an entity defined in another translation unit.
03375  */
03376 CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
03377 
03378 /**
03379  * \brief Construct a USR for a specified Objective-C class.
03380  */
03381 CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
03382 
03383 /**
03384  * \brief Construct a USR for a specified Objective-C category.
03385  */
03386 CINDEX_LINKAGE CXString
03387   clang_constructUSR_ObjCCategory(const char *class_name,
03388                                  const char *category_name);
03389 
03390 /**
03391  * \brief Construct a USR for a specified Objective-C protocol.
03392  */
03393 CINDEX_LINKAGE CXString
03394   clang_constructUSR_ObjCProtocol(const char *protocol_name);
03395 
03396 
03397 /**
03398  * \brief Construct a USR for a specified Objective-C instance variable and
03399  *   the USR for its containing class.
03400  */
03401 CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
03402                                                     CXString classUSR);
03403 
03404 /**
03405  * \brief Construct a USR for a specified Objective-C method and
03406  *   the USR for its containing class.
03407  */
03408 CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
03409                                                       unsigned isInstanceMethod,
03410                                                       CXString classUSR);
03411 
03412 /**
03413  * \brief Construct a USR for a specified Objective-C property and the USR
03414  *  for its containing class.
03415  */
03416 CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
03417                                                         CXString classUSR);
03418 
03419 /**
03420  * \brief Retrieve a name for the entity referenced by this cursor.
03421  */
03422 CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
03423 
03424 /**
03425  * \brief Retrieve a range for a piece that forms the cursors spelling name.
03426  * Most of the times there is only one range for the complete spelling but for
03427  * Objective-C methods and Objective-C message expressions, there are multiple
03428  * pieces for each selector identifier.
03429  * 
03430  * \param pieceIndex the index of the spelling name piece. If this is greater
03431  * than the actual number of pieces, it will return a NULL (invalid) range.
03432  *  
03433  * \param options Reserved.
03434  */
03435 CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
03436                                                           unsigned pieceIndex,
03437                                                           unsigned options);
03438 
03439 /**
03440  * \brief Retrieve the display name for the entity referenced by this cursor.
03441  *
03442  * The display name contains extra information that helps identify the cursor,
03443  * such as the parameters of a function or template or the arguments of a 
03444  * class template specialization.
03445  */
03446 CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
03447   
03448 /** \brief For a cursor that is a reference, retrieve a cursor representing the
03449  * entity that it references.
03450  *
03451  * Reference cursors refer to other entities in the AST. For example, an
03452  * Objective-C superclass reference cursor refers to an Objective-C class.
03453  * This function produces the cursor for the Objective-C class from the
03454  * cursor for the superclass reference. If the input cursor is a declaration or
03455  * definition, it returns that declaration or definition unchanged.
03456  * Otherwise, returns the NULL cursor.
03457  */
03458 CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
03459 
03460 /**
03461  *  \brief For a cursor that is either a reference to or a declaration
03462  *  of some entity, retrieve a cursor that describes the definition of
03463  *  that entity.
03464  *
03465  *  Some entities can be declared multiple times within a translation
03466  *  unit, but only one of those declarations can also be a
03467  *  definition. For example, given:
03468  *
03469  *  \code
03470  *  int f(int, int);
03471  *  int g(int x, int y) { return f(x, y); }
03472  *  int f(int a, int b) { return a + b; }
03473  *  int f(int, int);
03474  *  \endcode
03475  *
03476  *  there are three declarations of the function "f", but only the
03477  *  second one is a definition. The clang_getCursorDefinition()
03478  *  function will take any cursor pointing to a declaration of "f"
03479  *  (the first or fourth lines of the example) or a cursor referenced
03480  *  that uses "f" (the call to "f' inside "g") and will return a
03481  *  declaration cursor pointing to the definition (the second "f"
03482  *  declaration).
03483  *
03484  *  If given a cursor for which there is no corresponding definition,
03485  *  e.g., because there is no definition of that entity within this
03486  *  translation unit, returns a NULL cursor.
03487  */
03488 CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
03489 
03490 /**
03491  * \brief Determine whether the declaration pointed to by this cursor
03492  * is also a definition of that entity.
03493  */
03494 CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
03495 
03496 /**
03497  * \brief Retrieve the canonical cursor corresponding to the given cursor.
03498  *
03499  * In the C family of languages, many kinds of entities can be declared several
03500  * times within a single translation unit. For example, a structure type can
03501  * be forward-declared (possibly multiple times) and later defined:
03502  *
03503  * \code
03504  * struct X;
03505  * struct X;
03506  * struct X {
03507  *   int member;
03508  * };
03509  * \endcode
03510  *
03511  * The declarations and the definition of \c X are represented by three 
03512  * different cursors, all of which are declarations of the same underlying 
03513  * entity. One of these cursor is considered the "canonical" cursor, which
03514  * is effectively the representative for the underlying entity. One can 
03515  * determine if two cursors are declarations of the same underlying entity by
03516  * comparing their canonical cursors.
03517  *
03518  * \returns The canonical cursor for the entity referred to by the given cursor.
03519  */
03520 CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
03521 
03522 
03523 /**
03524  * \brief If the cursor points to a selector identifier in an Objective-C
03525  * method or message expression, this returns the selector index.
03526  *
03527  * After getting a cursor with #clang_getCursor, this can be called to
03528  * determine if the location points to a selector identifier.
03529  *
03530  * \returns The selector index if the cursor is an Objective-C method or message
03531  * expression and the cursor is pointing to a selector identifier, or -1
03532  * otherwise.
03533  */
03534 CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
03535 
03536 /**
03537  * \brief Given a cursor pointing to a C++ method call or an Objective-C
03538  * message, returns non-zero if the method/message is "dynamic", meaning:
03539  * 
03540  * For a C++ method: the call is virtual.
03541  * For an Objective-C message: the receiver is an object instance, not 'super'
03542  * or a specific class.
03543  * 
03544  * If the method/message is "static" or the cursor does not point to a
03545  * method/message, it will return zero.
03546  */
03547 CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
03548 
03549 /**
03550  * \brief Given a cursor pointing to an Objective-C message, returns the CXType
03551  * of the receiver.
03552  */
03553 CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
03554 
03555 /**
03556  * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
03557  */
03558 typedef enum {
03559   CXObjCPropertyAttr_noattr    = 0x00,
03560   CXObjCPropertyAttr_readonly  = 0x01,
03561   CXObjCPropertyAttr_getter    = 0x02,
03562   CXObjCPropertyAttr_assign    = 0x04,
03563   CXObjCPropertyAttr_readwrite = 0x08,
03564   CXObjCPropertyAttr_retain    = 0x10,
03565   CXObjCPropertyAttr_copy      = 0x20,
03566   CXObjCPropertyAttr_nonatomic = 0x40,
03567   CXObjCPropertyAttr_setter    = 0x80,
03568   CXObjCPropertyAttr_atomic    = 0x100,
03569   CXObjCPropertyAttr_weak      = 0x200,
03570   CXObjCPropertyAttr_strong    = 0x400,
03571   CXObjCPropertyAttr_unsafe_unretained = 0x800
03572 } CXObjCPropertyAttrKind;
03573 
03574 /**
03575  * \brief Given a cursor that represents a property declaration, return the
03576  * associated property attributes. The bits are formed from
03577  * \c CXObjCPropertyAttrKind.
03578  *
03579  * \param reserved Reserved for future use, pass 0.
03580  */
03581 CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
03582                                                              unsigned reserved);
03583 
03584 /**
03585  * \brief 'Qualifiers' written next to the return and parameter types in
03586  * Objective-C method declarations.
03587  */
03588 typedef enum {
03589   CXObjCDeclQualifier_None = 0x0,
03590   CXObjCDeclQualifier_In = 0x1,
03591   CXObjCDeclQualifier_Inout = 0x2,
03592   CXObjCDeclQualifier_Out = 0x4,
03593   CXObjCDeclQualifier_Bycopy = 0x8,
03594   CXObjCDeclQualifier_Byref = 0x10,
03595   CXObjCDeclQualifier_Oneway = 0x20
03596 } CXObjCDeclQualifierKind;
03597 
03598 /**
03599  * \brief Given a cursor that represents an Objective-C method or parameter
03600  * declaration, return the associated Objective-C qualifiers for the return
03601  * type or the parameter respectively. The bits are formed from
03602  * CXObjCDeclQualifierKind.
03603  */
03604 CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
03605 
03606 /**
03607  * \brief Given a cursor that represents an Objective-C method or property
03608  * declaration, return non-zero if the declaration was affected by "@optional".
03609  * Returns zero if the cursor is not such a declaration or it is "@required".
03610  */
03611 CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
03612 
03613 /**
03614  * \brief Returns non-zero if the given cursor is a variadic function or method.
03615  */
03616 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
03617 
03618 /**
03619  * \brief Given a cursor that represents a declaration, return the associated
03620  * comment's source range.  The range may include multiple consecutive comments
03621  * with whitespace in between.
03622  */
03623 CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
03624 
03625 /**
03626  * \brief Given a cursor that represents a declaration, return the associated
03627  * comment text, including comment markers.
03628  */
03629 CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
03630 
03631 /**
03632  * \brief Given a cursor that represents a documentable entity (e.g.,
03633  * declaration), return the associated \\brief paragraph; otherwise return the
03634  * first paragraph.
03635  */
03636 CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
03637 
03638 /**
03639  * @}
03640  */
03641 
03642 /**
03643  * \defgroup CINDEX_MODULE Module introspection
03644  *
03645  * The functions in this group provide access to information about modules.
03646  *
03647  * @{
03648  */
03649 
03650 typedef void *CXModule;
03651 
03652 /**
03653  * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
03654  */
03655 CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
03656 
03657 /**
03658  * \brief Given a CXFile header file, return the module that contains it, if one
03659  * exists.
03660  */
03661 CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
03662 
03663 /**
03664  * \param Module a module object.
03665  *
03666  * \returns the module file where the provided module object came from.
03667  */
03668 CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
03669 
03670 /**
03671  * \param Module a module object.
03672  *
03673  * \returns the parent of a sub-module or NULL if the given module is top-level,
03674  * e.g. for 'std.vector' it will return the 'std' module.
03675  */
03676 CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
03677 
03678 /**
03679  * \param Module a module object.
03680  *
03681  * \returns the name of the module, e.g. for the 'std.vector' sub-module it
03682  * will return "vector".
03683  */
03684 CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
03685 
03686 /**
03687  * \param Module a module object.
03688  *
03689  * \returns the full name of the module, e.g. "std.vector".
03690  */
03691 CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
03692 
03693 /**
03694  * \param Module a module object.
03695  *
03696  * \returns non-zero if the module is a system one.
03697  */
03698 CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
03699 
03700 /**
03701  * \param Module a module object.
03702  *
03703  * \returns the number of top level headers associated with this module.
03704  */
03705 CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
03706                                                            CXModule Module);
03707 
03708 /**
03709  * \param Module a module object.
03710  *
03711  * \param Index top level header index (zero-based).
03712  *
03713  * \returns the specified top level header associated with the module.
03714  */
03715 CINDEX_LINKAGE
03716 CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
03717                                       CXModule Module, unsigned Index);
03718 
03719 /**
03720  * @}
03721  */
03722 
03723 /**
03724  * \defgroup CINDEX_CPP C++ AST introspection
03725  *
03726  * The routines in this group provide access information in the ASTs specific
03727  * to C++ language features.
03728  *
03729  * @{
03730  */
03731 
03732 /**
03733  * \brief Determine if a C++ member function or member function template is
03734  * pure virtual.
03735  */
03736 CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
03737 
03738 /**
03739  * \brief Determine if a C++ member function or member function template is 
03740  * declared 'static'.
03741  */
03742 CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
03743 
03744 /**
03745  * \brief Determine if a C++ member function or member function template is
03746  * explicitly declared 'virtual' or if it overrides a virtual method from
03747  * one of the base classes.
03748  */
03749 CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
03750 
03751 /**
03752  * \brief Determine if a C++ member function or member function template is
03753  * declared 'const'.
03754  */
03755 CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
03756 
03757 /**
03758  * \brief Given a cursor that represents a template, determine
03759  * the cursor kind of the specializations would be generated by instantiating
03760  * the template.
03761  *
03762  * This routine can be used to determine what flavor of function template,
03763  * class template, or class template partial specialization is stored in the
03764  * cursor. For example, it can describe whether a class template cursor is
03765  * declared with "struct", "class" or "union".
03766  *
03767  * \param C The cursor to query. This cursor should represent a template
03768  * declaration.
03769  *
03770  * \returns The cursor kind of the specializations that would be generated
03771  * by instantiating the template \p C. If \p C is not a template, returns
03772  * \c CXCursor_NoDeclFound.
03773  */
03774 CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
03775   
03776 /**
03777  * \brief Given a cursor that may represent a specialization or instantiation
03778  * of a template, retrieve the cursor that represents the template that it
03779  * specializes or from which it was instantiated.
03780  *
03781  * This routine determines the template involved both for explicit 
03782  * specializations of templates and for implicit instantiations of the template,
03783  * both of which are referred to as "specializations". For a class template
03784  * specialization (e.g., \c std::vector<bool>), this routine will return 
03785  * either the primary template (\c std::vector) or, if the specialization was
03786  * instantiated from a class template partial specialization, the class template
03787  * partial specialization. For a class template partial specialization and a
03788  * function template specialization (including instantiations), this
03789  * this routine will return the specialized template.
03790  *
03791  * For members of a class template (e.g., member functions, member classes, or
03792  * static data members), returns the specialized or instantiated member. 
03793  * Although not strictly "templates" in the C++ language, members of class
03794  * templates have the same notions of specializations and instantiations that
03795  * templates do, so this routine treats them similarly.
03796  *
03797  * \param C A cursor that may be a specialization of a template or a member
03798  * of a template.
03799  *
03800  * \returns If the given cursor is a specialization or instantiation of a 
03801  * template or a member thereof, the template or member that it specializes or
03802  * from which it was instantiated. Otherwise, returns a NULL cursor.
03803  */
03804 CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
03805 
03806 /**
03807  * \brief Given a cursor that references something else, return the source range
03808  * covering that reference.
03809  *
03810  * \param C A cursor pointing to a member reference, a declaration reference, or
03811  * an operator call.
03812  * \param NameFlags A bitset with three independent flags: 
03813  * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
03814  * CXNameRange_WantSinglePiece.
03815  * \param PieceIndex For contiguous names or when passing the flag 
03816  * CXNameRange_WantSinglePiece, only one piece with index 0 is 
03817  * available. When the CXNameRange_WantSinglePiece flag is not passed for a
03818  * non-contiguous names, this index can be used to retrieve the individual
03819  * pieces of the name. See also CXNameRange_WantSinglePiece.
03820  *
03821  * \returns The piece of the name pointed to by the given cursor. If there is no
03822  * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
03823  */
03824 CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
03825                                                 unsigned NameFlags, 
03826                                                 unsigned PieceIndex);
03827 
03828 enum CXNameRefFlags {
03829   /**
03830    * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
03831    * range.
03832    */
03833   CXNameRange_WantQualifier = 0x1,
03834   
03835   /**
03836    * \brief Include the explicit template arguments, e.g. <int> in x.f<int>,
03837    * in the range.
03838    */
03839   CXNameRange_WantTemplateArgs = 0x2,
03840 
03841   /**
03842    * \brief If the name is non-contiguous, return the full spanning range.
03843    *
03844    * Non-contiguous names occur in Objective-C when a selector with two or more
03845    * parameters is used, or in C++ when using an operator:
03846    * \code
03847    * [object doSomething:here withValue:there]; // Objective-C
03848    * return some_vector[1]; // C++
03849    * \endcode
03850    */
03851   CXNameRange_WantSinglePiece = 0x4
03852 };
03853   
03854 /**
03855  * @}
03856  */
03857 
03858 /**
03859  * \defgroup CINDEX_LEX Token extraction and manipulation
03860  *
03861  * The routines in this group provide access to the tokens within a
03862  * translation unit, along with a semantic mapping of those tokens to
03863  * their corresponding cursors.
03864  *
03865  * @{
03866  */
03867 
03868 /**
03869  * \brief Describes a kind of token.
03870  */
03871 typedef enum CXTokenKind {
03872   /**
03873    * \brief A token that contains some kind of punctuation.
03874    */
03875   CXToken_Punctuation,
03876 
03877   /**
03878    * \brief A language keyword.
03879    */
03880   CXToken_Keyword,
03881 
03882   /**
03883    * \brief An identifier (that is not a keyword).
03884    */
03885   CXToken_Identifier,
03886 
03887   /**
03888    * \brief A numeric, string, or character literal.
03889    */
03890   CXToken_Literal,
03891 
03892   /**
03893    * \brief A comment.
03894    */
03895   CXToken_Comment
03896 } CXTokenKind;
03897 
03898 /**
03899  * \brief Describes a single preprocessing token.
03900  */
03901 typedef struct {
03902   unsigned int_data[4];
03903   void *ptr_data;
03904 } CXToken;
03905 
03906 /**
03907  * \brief Determine the kind of the given token.
03908  */
03909 CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
03910 
03911 /**
03912  * \brief Determine the spelling of the given token.
03913  *
03914  * The spelling of a token is the textual representation of that token, e.g.,
03915  * the text of an identifier or keyword.
03916  */
03917 CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
03918 
03919 /**
03920  * \brief Retrieve the source location of the given token.
03921  */
03922 CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
03923                                                        CXToken);
03924 
03925 /**
03926  * \brief Retrieve a source range that covers the given token.
03927  */
03928 CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
03929 
03930 /**
03931  * \brief Tokenize the source code described by the given range into raw
03932  * lexical tokens.
03933  *
03934  * \param TU the translation unit whose text is being tokenized.
03935  *
03936  * \param Range the source range in which text should be tokenized. All of the
03937  * tokens produced by tokenization will fall within this source range,
03938  *
03939  * \param Tokens this pointer will be set to point to the array of tokens
03940  * that occur within the given source range. The returned pointer must be
03941  * freed with clang_disposeTokens() before the translation unit is destroyed.
03942  *
03943  * \param NumTokens will be set to the number of tokens in the \c *Tokens
03944  * array.
03945  *
03946  */
03947 CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
03948                                    CXToken **Tokens, unsigned *NumTokens);
03949 
03950 /**
03951  * \brief Annotate the given set of tokens by providing cursors for each token
03952  * that can be mapped to a specific entity within the abstract syntax tree.
03953  *
03954  * This token-annotation routine is equivalent to invoking
03955  * clang_getCursor() for the source locations of each of the
03956  * tokens. The cursors provided are filtered, so that only those
03957  * cursors that have a direct correspondence to the token are
03958  * accepted. For example, given a function call \c f(x),
03959  * clang_getCursor() would provide the following cursors:
03960  *
03961  *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
03962  *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
03963  *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
03964  *
03965  * Only the first and last of these cursors will occur within the
03966  * annotate, since the tokens "f" and "x' directly refer to a function
03967  * and a variable, respectively, but the parentheses are just a small
03968  * part of the full syntax of the function call expression, which is
03969  * not provided as an annotation.
03970  *
03971  * \param TU the translation unit that owns the given tokens.
03972  *
03973  * \param Tokens the set of tokens to annotate.
03974  *
03975  * \param NumTokens the number of tokens in \p Tokens.
03976  *
03977  * \param Cursors an array of \p NumTokens cursors, whose contents will be
03978  * replaced with the cursors corresponding to each token.
03979  */
03980 CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
03981                                          CXToken *Tokens, unsigned NumTokens,
03982                                          CXCursor *Cursors);
03983 
03984 /**
03985  * \brief Free the given set of tokens.
03986  */
03987 CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
03988                                         CXToken *Tokens, unsigned NumTokens);
03989 
03990 /**
03991  * @}
03992  */
03993 
03994 /**
03995  * \defgroup CINDEX_DEBUG Debugging facilities
03996  *
03997  * These routines are used for testing and debugging, only, and should not
03998  * be relied upon.
03999  *
04000  * @{
04001  */
04002 
04003 /* for debug/testing */
04004 CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
04005 CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
04006                                           const char **startBuf,
04007                                           const char **endBuf,
04008                                           unsigned *startLine,
04009                                           unsigned *startColumn,
04010                                           unsigned *endLine,
04011                                           unsigned *endColumn);
04012 CINDEX_LINKAGE void clang_enableStackTraces(void);
04013 CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
04014                                           unsigned stack_size);
04015 
04016 /**
04017  * @}
04018  */
04019 
04020 /**
04021  * \defgroup CINDEX_CODE_COMPLET Code completion
04022  *
04023  * Code completion involves taking an (incomplete) source file, along with
04024  * knowledge of where the user is actively editing that file, and suggesting
04025  * syntactically- and semantically-valid constructs that the user might want to
04026  * use at that particular point in the source code. These data structures and
04027  * routines provide support for code completion.
04028  *
04029  * @{
04030  */
04031 
04032 /**
04033  * \brief A semantic string that describes a code-completion result.
04034  *
04035  * A semantic string that describes the formatting of a code-completion
04036  * result as a single "template" of text that should be inserted into the
04037  * source buffer when a particular code-completion result is selected.
04038  * Each semantic string is made up of some number of "chunks", each of which
04039  * contains some text along with a description of what that text means, e.g.,
04040  * the name of the entity being referenced, whether the text chunk is part of
04041  * the template, or whether it is a "placeholder" that the user should replace
04042  * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
04043  * description of the different kinds of chunks.
04044  */
04045 typedef void *CXCompletionString;
04046 
04047 /**
04048  * \brief A single result of code completion.
04049  */
04050 typedef struct {
04051   /**
04052    * \brief The kind of entity that this completion refers to.
04053    *
04054    * The cursor kind will be a macro, keyword, or a declaration (one of the
04055    * *Decl cursor kinds), describing the entity that the completion is
04056    * referring to.
04057    *
04058    * \todo In the future, we would like to provide a full cursor, to allow
04059    * the client to extract additional information from declaration.
04060    */
04061   enum CXCursorKind CursorKind;
04062 
04063   /**
04064    * \brief The code-completion string that describes how to insert this
04065    * code-completion result into the editing buffer.
04066    */
04067   CXCompletionString CompletionString;
04068 } CXCompletionResult;
04069 
04070 /**
04071  * \brief Describes a single piece of text within a code-completion string.
04072  *
04073  * Each "chunk" within a code-completion string (\c CXCompletionString) is
04074  * either a piece of text with a specific "kind" that describes how that text
04075  * should be interpreted by the client or is another completion string.
04076  */
04077 enum CXCompletionChunkKind {
04078   /**
04079    * \brief A code-completion string that describes "optional" text that
04080    * could be a part of the template (but is not required).
04081    *
04082    * The Optional chunk is the only kind of chunk that has a code-completion
04083    * string for its representation, which is accessible via
04084    * \c clang_getCompletionChunkCompletionString(). The code-completion string
04085    * describes an additional part of the template that is completely optional.
04086    * For example, optional chunks can be used to describe the placeholders for
04087    * arguments that match up with defaulted function parameters, e.g. given:
04088    *
04089    * \code
04090    * void f(int x, float y = 3.14, double z = 2.71828);
04091    * \endcode
04092    *
04093    * The code-completion string for this function would contain:
04094    *   - a TypedText chunk for "f".
04095    *   - a LeftParen chunk for "(".
04096    *   - a Placeholder chunk for "int x"
04097    *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
04098    *       - a Comma chunk for ","
04099    *       - a Placeholder chunk for "float y"
04100    *       - an Optional chunk containing the last defaulted argument:
04101    *           - a Comma chunk for ","
04102    *           - a Placeholder chunk for "double z"
04103    *   - a RightParen chunk for ")"
04104    *
04105    * There are many ways to handle Optional chunks. Two simple approaches are:
04106    *   - Completely ignore optional chunks, in which case the template for the
04107    *     function "f" would only include the first parameter ("int x").
04108    *   - Fully expand all optional chunks, in which case the template for the
04109    *     function "f" would have all of the parameters.
04110    */
04111   CXCompletionChunk_Optional,
04112   /**
04113    * \brief Text that a user would be expected to type to get this
04114    * code-completion result.
04115    *
04116    * There will be exactly one "typed text" chunk in a semantic string, which
04117    * will typically provide the spelling of a keyword or the name of a
04118    * declaration that could be used at the current code point. Clients are
04119    * expected to filter the code-completion results based on the text in this
04120    * chunk.
04121    */
04122   CXCompletionChunk_TypedText,
04123   /**
04124    * \brief Text that should be inserted as part of a code-completion result.
04125    *
04126    * A "text" chunk represents text that is part of the template to be
04127    * inserted into user code should this particular code-completion result
04128    * be selected.
04129    */
04130   CXCompletionChunk_Text,
04131   /**
04132    * \brief Placeholder text that should be replaced by the user.
04133    *
04134    * A "placeholder" chunk marks a place where the user should insert text
04135    * into the code-completion template. For example, placeholders might mark
04136    * the function parameters for a function declaration, to indicate that the
04137    * user should provide arguments for each of those parameters. The actual
04138    * text in a placeholder is a suggestion for the text to display before
04139    * the user replaces the placeholder with real code.
04140    */
04141   CXCompletionChunk_Placeholder,
04142   /**
04143    * \brief Informative text that should be displayed but never inserted as
04144    * part of the template.
04145    *
04146    * An "informative" chunk contains annotations that can be displayed to
04147    * help the user decide whether a particular code-completion result is the
04148    * right option, but which is not part of the actual template to be inserted
04149    * by code completion.
04150    */
04151   CXCompletionChunk_Informative,
04152   /**
04153    * \brief Text that describes the current parameter when code-completion is
04154    * referring to function call, message send, or template specialization.
04155    *
04156    * A "current parameter" chunk occurs when code-completion is providing
04157    * information about a parameter corresponding to the argument at the
04158    * code-completion point. For example, given a function
04159    *
04160    * \code
04161    * int add(int x, int y);
04162    * \endcode
04163    *
04164    * and the source code \c add(, where the code-completion point is after the
04165    * "(", the code-completion string will contain a "current parameter" chunk
04166    * for "int x", indicating that the current argument will initialize that
04167    * parameter. After typing further, to \c add(17, (where the code-completion
04168    * point is after the ","), the code-completion string will contain a
04169    * "current paremeter" chunk to "int y".
04170    */
04171   CXCompletionChunk_CurrentParameter,
04172   /**
04173    * \brief A left parenthesis ('('), used to initiate a function call or
04174    * signal the beginning of a function parameter list.
04175    */
04176   CXCompletionChunk_LeftParen,
04177   /**
04178    * \brief A right parenthesis (')'), used to finish a function call or
04179    * signal the end of a function parameter list.
04180    */
04181   CXCompletionChunk_RightParen,
04182   /**
04183    * \brief A left bracket ('[').
04184    */
04185   CXCompletionChunk_LeftBracket,
04186   /**
04187    * \brief A right bracket (']').
04188    */
04189   CXCompletionChunk_RightBracket,
04190   /**
04191    * \brief A left brace ('{').
04192    */
04193   CXCompletionChunk_LeftBrace,
04194   /**
04195    * \brief A right brace ('}').
04196    */
04197   CXCompletionChunk_RightBrace,
04198   /**
04199    * \brief A left angle bracket ('<').
04200    */
04201   CXCompletionChunk_LeftAngle,
04202   /**
04203    * \brief A right angle bracket ('>').
04204    */
04205   CXCompletionChunk_RightAngle,
04206   /**
04207    * \brief A comma separator (',').
04208    */
04209   CXCompletionChunk_Comma,
04210   /**
04211    * \brief Text that specifies the result type of a given result.
04212    *
04213    * This special kind of informative chunk is not meant to be inserted into
04214    * the text buffer. Rather, it is meant to illustrate the type that an
04215    * expression using the given completion string would have.
04216    */
04217   CXCompletionChunk_ResultType,
04218   /**
04219    * \brief A colon (':').
04220    */
04221   CXCompletionChunk_Colon,
04222   /**
04223    * \brief A semicolon (';').
04224    */
04225   CXCompletionChunk_SemiColon,
04226   /**
04227    * \brief An '=' sign.
04228    */
04229   CXCompletionChunk_Equal,
04230   /**
04231    * Horizontal space (' ').
04232    */
04233   CXCompletionChunk_HorizontalSpace,
04234   /**
04235    * Vertical space ('\n'), after which it is generally a good idea to
04236    * perform indentation.
04237    */
04238   CXCompletionChunk_VerticalSpace
04239 };
04240 
04241 /**
04242  * \brief Determine the kind of a particular chunk within a completion string.
04243  *
04244  * \param completion_string the completion string to query.
04245  *
04246  * \param chunk_number the 0-based index of the chunk in the completion string.
04247  *
04248  * \returns the kind of the chunk at the index \c chunk_number.
04249  */
04250 CINDEX_LINKAGE enum CXCompletionChunkKind
04251 clang_getCompletionChunkKind(CXCompletionString completion_string,
04252                              unsigned chunk_number);
04253 
04254 /**
04255  * \brief Retrieve the text associated with a particular chunk within a
04256  * completion string.
04257  *
04258  * \param completion_string the completion string to query.
04259  *
04260  * \param chunk_number the 0-based index of the chunk in the completion string.
04261  *
04262  * \returns the text associated with the chunk at index \c chunk_number.
04263  */
04264 CINDEX_LINKAGE CXString
04265 clang_getCompletionChunkText(CXCompletionString completion_string,
04266                              unsigned chunk_number);
04267 
04268 /**
04269  * \brief Retrieve the completion string associated with a particular chunk
04270  * within a completion string.
04271  *
04272  * \param completion_string the completion string to query.
04273  *
04274  * \param chunk_number the 0-based index of the chunk in the completion string.
04275  *
04276  * \returns the completion string associated with the chunk at index
04277  * \c chunk_number.
04278  */
04279 CINDEX_LINKAGE CXCompletionString
04280 clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
04281                                          unsigned chunk_number);
04282 
04283 /**
04284  * \brief Retrieve the number of chunks in the given code-completion string.
04285  */
04286 CINDEX_LINKAGE unsigned
04287 clang_getNumCompletionChunks(CXCompletionString completion_string);
04288 
04289 /**
04290  * \brief Determine the priority of this code completion.
04291  *
04292  * The priority of a code completion indicates how likely it is that this 
04293  * particular completion is the completion that the user will select. The
04294  * priority is selected by various internal heuristics.
04295  *
04296  * \param completion_string The completion string to query.
04297  *
04298  * \returns The priority of this completion string. Smaller values indicate
04299  * higher-priority (more likely) completions.
04300  */
04301 CINDEX_LINKAGE unsigned
04302 clang_getCompletionPriority(CXCompletionString completion_string);
04303   
04304 /**
04305  * \brief Determine the availability of the entity that this code-completion
04306  * string refers to.
04307  *
04308  * \param completion_string The completion string to query.
04309  *
04310  * \returns The availability of the completion string.
04311  */
04312 CINDEX_LINKAGE enum CXAvailabilityKind 
04313 clang_getCompletionAvailability(CXCompletionString completion_string);
04314 
04315 /**
04316  * \brief Retrieve the number of annotations associated with the given
04317  * completion string.
04318  *
04319  * \param completion_string the completion string to query.
04320  *
04321  * \returns the number of annotations associated with the given completion
04322  * string.
04323  */
04324 CINDEX_LINKAGE unsigned
04325 clang_getCompletionNumAnnotations(CXCompletionString completion_string);
04326 
04327 /**
04328  * \brief Retrieve the annotation associated with the given completion string.
04329  *
04330  * \param completion_string the completion string to query.
04331  *
04332  * \param annotation_number the 0-based index of the annotation of the
04333  * completion string.
04334  *
04335  * \returns annotation string associated with the completion at index
04336  * \c annotation_number, or a NULL string if that annotation is not available.
04337  */
04338 CINDEX_LINKAGE CXString
04339 clang_getCompletionAnnotation(CXCompletionString completion_string,
04340                               unsigned annotation_number);
04341 
04342 /**
04343  * \brief Retrieve the parent context of the given completion string.
04344  *
04345  * The parent context of a completion string is the semantic parent of 
04346  * the declaration (if any) that the code completion represents. For example,
04347  * a code completion for an Objective-C method would have the method's class
04348  * or protocol as its context.
04349  *
04350  * \param completion_string The code completion string whose parent is
04351  * being queried.
04352  *
04353  * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
04354  *
04355  * \returns The name of the completion parent, e.g., "NSObject" if
04356  * the completion string represents a method in the NSObject class.
04357  */
04358 CINDEX_LINKAGE CXString
04359 clang_getCompletionParent(CXCompletionString completion_string,
04360                           enum CXCursorKind *kind);
04361 
04362 /**
04363  * \brief Retrieve the brief documentation comment attached to the declaration
04364  * that corresponds to the given completion string.
04365  */
04366 CINDEX_LINKAGE CXString
04367 clang_getCompletionBriefComment(CXCompletionString completion_string);
04368 
04369 /**
04370  * \brief Retrieve a completion string for an arbitrary declaration or macro
04371  * definition cursor.
04372  *
04373  * \param cursor The cursor to query.
04374  *
04375  * \returns A non-context-sensitive completion string for declaration and macro
04376  * definition cursors, or NULL for other kinds of cursors.
04377  */
04378 CINDEX_LINKAGE CXCompletionString
04379 clang_getCursorCompletionString(CXCursor cursor);
04380   
04381 /**
04382  * \brief Contains the results of code-completion.
04383  *
04384  * This data structure contains the results of code completion, as
04385  * produced by \c clang_codeCompleteAt(). Its contents must be freed by
04386  * \c clang_disposeCodeCompleteResults.
04387  */
04388 typedef struct {
04389   /**
04390    * \brief The code-completion results.
04391    */
04392   CXCompletionResult *Results;
04393 
04394   /**
04395    * \brief The number of code-completion results stored in the
04396    * \c Results array.
04397    */
04398   unsigned NumResults;
04399 } CXCodeCompleteResults;
04400 
04401 /**
04402  * \brief Flags that can be passed to \c clang_codeCompleteAt() to
04403  * modify its behavior.
04404  *
04405  * The enumerators in this enumeration can be bitwise-OR'd together to
04406  * provide multiple options to \c clang_codeCompleteAt().
04407  */
04408 enum CXCodeComplete_Flags {
04409   /**
04410    * \brief Whether to include macros within the set of code
04411    * completions returned.
04412    */
04413   CXCodeComplete_IncludeMacros = 0x01,
04414 
04415   /**
04416    * \brief Whether to include code patterns for language constructs
04417    * within the set of code completions, e.g., for loops.
04418    */
04419   CXCodeComplete_IncludeCodePatterns = 0x02,
04420 
04421   /**
04422    * \brief Whether to include brief documentation within the set of code
04423    * completions returned.
04424    */
04425   CXCodeComplete_IncludeBriefComments = 0x04
04426 };
04427 
04428 /**
04429  * \brief Bits that represent the context under which completion is occurring.
04430  *
04431  * The enumerators in this enumeration may be bitwise-OR'd together if multiple
04432  * contexts are occurring simultaneously.
04433  */
04434 enum CXCompletionContext {
04435   /**
04436    * \brief The context for completions is unexposed, as only Clang results
04437    * should be included. (This is equivalent to having no context bits set.)
04438    */
04439   CXCompletionContext_Unexposed = 0,
04440   
04441   /**
04442    * \brief Completions for any possible type should be included in the results.
04443    */
04444   CXCompletionContext_AnyType = 1 << 0,
04445   
04446   /**
04447    * \brief Completions for any possible value (variables, function calls, etc.)
04448    * should be included in the results.
04449    */
04450   CXCompletionContext_AnyValue = 1 << 1,
04451   /**
04452    * \brief Completions for values that resolve to an Objective-C object should
04453    * be included in the results.
04454    */
04455   CXCompletionContext_ObjCObjectValue = 1 << 2,
04456   /**
04457    * \brief Completions for values that resolve to an Objective-C selector
04458    * should be included in the results.
04459    */
04460   CXCompletionContext_ObjCSelectorValue = 1 << 3,
04461   /**
04462    * \brief Completions for values that resolve to a C++ class type should be
04463    * included in the results.
04464    */
04465   CXCompletionContext_CXXClassTypeValue = 1 << 4,
04466   
04467   /**
04468    * \brief Completions for fields of the member being accessed using the dot
04469    * operator should be included in the results.
04470    */
04471   CXCompletionContext_DotMemberAccess = 1 << 5,
04472   /**
04473    * \brief Completions for fields of the member being accessed using the arrow
04474    * operator should be included in the results.
04475    */
04476   CXCompletionContext_ArrowMemberAccess = 1 << 6,
04477   /**
04478    * \brief Completions for properties of the Objective-C object being accessed
04479    * using the dot operator should be included in the results.
04480    */
04481   CXCompletionContext_ObjCPropertyAccess = 1 << 7,
04482   
04483   /**
04484    * \brief Completions for enum tags should be included in the results.
04485    */
04486   CXCompletionContext_EnumTag = 1 << 8,
04487   /**
04488    * \brief Completions for union tags should be included in the results.
04489    */
04490   CXCompletionContext_UnionTag = 1 << 9,
04491   /**
04492    * \brief Completions for struct tags should be included in the results.
04493    */
04494   CXCompletionContext_StructTag = 1 << 10,
04495   
04496   /**
04497    * \brief Completions for C++ class names should be included in the results.
04498    */
04499   CXCompletionContext_ClassTag = 1 << 11,
04500   /**
04501    * \brief Completions for C++ namespaces and namespace aliases should be
04502    * included in the results.
04503    */
04504   CXCompletionContext_Namespace = 1 << 12,
04505   /**
04506    * \brief Completions for C++ nested name specifiers should be included in
04507    * the results.
04508    */
04509   CXCompletionContext_NestedNameSpecifier = 1 << 13,
04510   
04511   /**
04512    * \brief Completions for Objective-C interfaces (classes) should be included
04513    * in the results.
04514    */
04515   CXCompletionContext_ObjCInterface = 1 << 14,
04516   /**
04517    * \brief Completions for Objective-C protocols should be included in
04518    * the results.
04519    */
04520   CXCompletionContext_ObjCProtocol = 1 << 15,
04521   /**
04522    * \brief Completions for Objective-C categories should be included in
04523    * the results.
04524    */
04525   CXCompletionContext_ObjCCategory = 1 << 16,
04526   /**
04527    * \brief Completions for Objective-C instance messages should be included
04528    * in the results.
04529    */
04530   CXCompletionContext_ObjCInstanceMessage = 1 << 17,
04531   /**
04532    * \brief Completions for Objective-C class messages should be included in
04533    * the results.
04534    */
04535   CXCompletionContext_ObjCClassMessage = 1 << 18,
04536   /**
04537    * \brief Completions for Objective-C selector names should be included in
04538    * the results.
04539    */
04540   CXCompletionContext_ObjCSelectorName = 1 << 19,
04541   
04542   /**
04543    * \brief Completions for preprocessor macro names should be included in
04544    * the results.
04545    */
04546   CXCompletionContext_MacroName = 1 << 20,
04547   
04548   /**
04549    * \brief Natural language completions should be included in the results.
04550    */
04551   CXCompletionContext_NaturalLanguage = 1 << 21,
04552   
04553   /**
04554    * \brief The current context is unknown, so set all contexts.
04555    */
04556   CXCompletionContext_Unknown = ((1 << 22) - 1)
04557 };
04558   
04559 /**
04560  * \brief Returns a default set of code-completion options that can be
04561  * passed to\c clang_codeCompleteAt(). 
04562  */
04563 CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
04564 
04565 /**
04566  * \brief Perform code completion at a given location in a translation unit.
04567  *
04568  * This function performs code completion at a particular file, line, and
04569  * column within source code, providing results that suggest potential
04570  * code snippets based on the context of the completion. The basic model
04571  * for code completion is that Clang will parse a complete source file,
04572  * performing syntax checking up to the location where code-completion has
04573  * been requested. At that point, a special code-completion token is passed
04574  * to the parser, which recognizes this token and determines, based on the
04575  * current location in the C/Objective-C/C++ grammar and the state of
04576  * semantic analysis, what completions to provide. These completions are
04577  * returned via a new \c CXCodeCompleteResults structure.
04578  *
04579  * Code completion itself is meant to be triggered by the client when the
04580  * user types punctuation characters or whitespace, at which point the
04581  * code-completion location will coincide with the cursor. For example, if \c p
04582  * is a pointer, code-completion might be triggered after the "-" and then
04583  * after the ">" in \c p->. When the code-completion location is afer the ">",
04584  * the completion results will provide, e.g., the members of the struct that
04585  * "p" points to. The client is responsible for placing the cursor at the
04586  * beginning of the token currently being typed, then filtering the results
04587  * based on the contents of the token. For example, when code-completing for
04588  * the expression \c p->get, the client should provide the location just after
04589  * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
04590  * client can filter the results based on the current token text ("get"), only
04591  * showing those results that start with "get". The intent of this interface
04592  * is to separate the relatively high-latency acquisition of code-completion
04593  * results from the filtering of results on a per-character basis, which must
04594  * have a lower latency.
04595  *
04596  * \param TU The translation unit in which code-completion should
04597  * occur. The source files for this translation unit need not be
04598  * completely up-to-date (and the contents of those source files may
04599  * be overridden via \p unsaved_files). Cursors referring into the
04600  * translation unit may be invalidated by this invocation.
04601  *
04602  * \param complete_filename The name of the source file where code
04603  * completion should be performed. This filename may be any file
04604  * included in the translation unit.
04605  *
04606  * \param complete_line The line at which code-completion should occur.
04607  *
04608  * \param complete_column The column at which code-completion should occur.
04609  * Note that the column should point just after the syntactic construct that
04610  * initiated code completion, and not in the middle of a lexical token.
04611  *
04612  * \param unsaved_files the Tiles that have not yet been saved to disk
04613  * but may be required for parsing or code completion, including the
04614  * contents of those files.  The contents and name of these files (as
04615  * specified by CXUnsavedFile) are copied when necessary, so the
04616  * client only needs to guarantee their validity until the call to
04617  * this function returns.
04618  *
04619  * \param num_unsaved_files The number of unsaved file entries in \p
04620  * unsaved_files.
04621  *
04622  * \param options Extra options that control the behavior of code
04623  * completion, expressed as a bitwise OR of the enumerators of the
04624  * CXCodeComplete_Flags enumeration. The 
04625  * \c clang_defaultCodeCompleteOptions() function returns a default set
04626  * of code-completion options.
04627  *
04628  * \returns If successful, a new \c CXCodeCompleteResults structure
04629  * containing code-completion results, which should eventually be
04630  * freed with \c clang_disposeCodeCompleteResults(). If code
04631  * completion fails, returns NULL.
04632  */
04633 CINDEX_LINKAGE
04634 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
04635                                             const char *complete_filename,
04636                                             unsigned complete_line,
04637                                             unsigned complete_column,
04638                                             struct CXUnsavedFile *unsaved_files,
04639                                             unsigned num_unsaved_files,
04640                                             unsigned options);
04641 
04642 /**
04643  * \brief Sort the code-completion results in case-insensitive alphabetical 
04644  * order.
04645  *
04646  * \param Results The set of results to sort.
04647  * \param NumResults The number of results in \p Results.
04648  */
04649 CINDEX_LINKAGE
04650 void clang_sortCodeCompletionResults(CXCompletionResult *Results,
04651                                      unsigned NumResults);
04652   
04653 /**
04654  * \brief Free the given set of code-completion results.
04655  */
04656 CINDEX_LINKAGE
04657 void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
04658   
04659 /**
04660  * \brief Determine the number of diagnostics produced prior to the
04661  * location where code completion was performed.
04662  */
04663 CINDEX_LINKAGE
04664 unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
04665 
04666 /**
04667  * \brief Retrieve a diagnostic associated with the given code completion.
04668  *
04669  * \param Results the code completion results to query.
04670  * \param Index the zero-based diagnostic number to retrieve.
04671  *
04672  * \returns the requested diagnostic. This diagnostic must be freed
04673  * via a call to \c clang_disposeDiagnostic().
04674  */
04675 CINDEX_LINKAGE
04676 CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
04677                                              unsigned Index);
04678 
04679 /**
04680  * \brief Determines what completions are appropriate for the context
04681  * the given code completion.
04682  * 
04683  * \param Results the code completion results to query
04684  *
04685  * \returns the kinds of completions that are appropriate for use
04686  * along with the given code completion results.
04687  */
04688 CINDEX_LINKAGE
04689 unsigned long long clang_codeCompleteGetContexts(
04690                                                 CXCodeCompleteResults *Results);
04691 
04692 /**
04693  * \brief Returns the cursor kind for the container for the current code
04694  * completion context. The container is only guaranteed to be set for
04695  * contexts where a container exists (i.e. member accesses or Objective-C
04696  * message sends); if there is not a container, this function will return
04697  * CXCursor_InvalidCode.
04698  *
04699  * \param Results the code completion results to query
04700  *
04701  * \param IsIncomplete on return, this value will be false if Clang has complete
04702  * information about the container. If Clang does not have complete
04703  * information, this value will be true.
04704  *
04705  * \returns the container kind, or CXCursor_InvalidCode if there is not a
04706  * container
04707  */
04708 CINDEX_LINKAGE
04709 enum CXCursorKind clang_codeCompleteGetContainerKind(
04710                                                  CXCodeCompleteResults *Results,
04711                                                      unsigned *IsIncomplete);
04712 
04713 /**
04714  * \brief Returns the USR for the container for the current code completion
04715  * context. If there is not a container for the current context, this
04716  * function will return the empty string.
04717  *
04718  * \param Results the code completion results to query
04719  *
04720  * \returns the USR for the container
04721  */
04722 CINDEX_LINKAGE
04723 CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
04724   
04725   
04726 /**
04727  * \brief Returns the currently-entered selector for an Objective-C message
04728  * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
04729  * non-empty string for CXCompletionContext_ObjCInstanceMessage and
04730  * CXCompletionContext_ObjCClassMessage.
04731  *
04732  * \param Results the code completion results to query
04733  *
04734  * \returns the selector (or partial selector) that has been entered thus far
04735  * for an Objective-C message send.
04736  */
04737 CINDEX_LINKAGE
04738 CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
04739   
04740 /**
04741  * @}
04742  */
04743 
04744 
04745 /**
04746  * \defgroup CINDEX_MISC Miscellaneous utility functions
04747  *
04748  * @{
04749  */
04750 
04751 /**
04752  * \brief Return a version string, suitable for showing to a user, but not
04753  *        intended to be parsed (the format is not guaranteed to be stable).
04754  */
04755 CINDEX_LINKAGE CXString clang_getClangVersion(void);
04756 
04757   
04758 /**
04759  * \brief Enable/disable crash recovery.
04760  *
04761  * \param isEnabled Flag to indicate if crash recovery is enabled.  A non-zero
04762  *        value enables crash recovery, while 0 disables it.
04763  */
04764 CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
04765   
04766  /**
04767   * \brief Visitor invoked for each file in a translation unit
04768   *        (used with clang_getInclusions()).
04769   *
04770   * This visitor function will be invoked by clang_getInclusions() for each
04771   * file included (either at the top-level or by \#include directives) within
04772   * a translation unit.  The first argument is the file being included, and
04773   * the second and third arguments provide the inclusion stack.  The
04774   * array is sorted in order of immediate inclusion.  For example,
04775   * the first element refers to the location that included 'included_file'.
04776   */
04777 typedef void (*CXInclusionVisitor)(CXFile included_file,
04778                                    CXSourceLocation* inclusion_stack,
04779                                    unsigned include_len,
04780                                    CXClientData client_data);
04781 
04782 /**
04783  * \brief Visit the set of preprocessor inclusions in a translation unit.
04784  *   The visitor function is called with the provided data for every included
04785  *   file.  This does not include headers included by the PCH file (unless one
04786  *   is inspecting the inclusions in the PCH file itself).
04787  */
04788 CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
04789                                         CXInclusionVisitor visitor,
04790                                         CXClientData client_data);
04791 
04792 /**
04793  * @}
04794  */
04795 
04796 /** \defgroup CINDEX_REMAPPING Remapping functions
04797  *
04798  * @{
04799  */
04800 
04801 /**
04802  * \brief A remapping of original source files and their translated files.
04803  */
04804 typedef void *CXRemapping;
04805 
04806 /**
04807  * \brief Retrieve a remapping.
04808  *
04809  * \param path the path that contains metadata about remappings.
04810  *
04811  * \returns the requested remapping. This remapping must be freed
04812  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
04813  */
04814 CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
04815 
04816 /**
04817  * \brief Retrieve a remapping.
04818  *
04819  * \param filePaths pointer to an array of file paths containing remapping info.
04820  *
04821  * \param numFiles number of file paths.
04822  *
04823  * \returns the requested remapping. This remapping must be freed
04824  * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
04825  */
04826 CINDEX_LINKAGE
04827 CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
04828                                             unsigned numFiles);
04829 
04830 /**
04831  * \brief Determine the number of remappings.
04832  */
04833 CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
04834 
04835 /**
04836  * \brief Get the original and the associated filename from the remapping.
04837  * 
04838  * \param original If non-NULL, will be set to the original filename.
04839  *
04840  * \param transformed If non-NULL, will be set to the filename that the original
04841  * is associated with.
04842  */
04843 CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
04844                                      CXString *original, CXString *transformed);
04845 
04846 /**
04847  * \brief Dispose the remapping.
04848  */
04849 CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
04850 
04851 /**
04852  * @}
04853  */
04854 
04855 /** \defgroup CINDEX_HIGH Higher level API functions
04856  *
04857  * @{
04858  */
04859 
04860 enum CXVisitorResult {
04861   CXVisit_Break,
04862   CXVisit_Continue
04863 };
04864 
04865 typedef struct {
04866   void *context;
04867   enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
04868 } CXCursorAndRangeVisitor;
04869 
04870 typedef enum {
04871   /**
04872    * \brief Function returned successfully.
04873    */
04874   CXResult_Success = 0,
04875   /**
04876    * \brief One of the parameters was invalid for the function.
04877    */
04878   CXResult_Invalid = 1,
04879   /**
04880    * \brief The function was terminated by a callback (e.g. it returned
04881    * CXVisit_Break)
04882    */
04883   CXResult_VisitBreak = 2
04884 
04885 } CXResult;
04886 
04887 /**
04888  * \brief Find references of a declaration in a specific file.
04889  * 
04890  * \param cursor pointing to a declaration or a reference of one.
04891  *
04892  * \param file to search for references.
04893  *
04894  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
04895  * each reference found.
04896  * The CXSourceRange will point inside the file; if the reference is inside
04897  * a macro (and not a macro argument) the CXSourceRange will be invalid.
04898  *
04899  * \returns one of the CXResult enumerators.
04900  */
04901 CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
04902                                                CXCursorAndRangeVisitor visitor);
04903 
04904 /**
04905  * \brief Find #import/#include directives in a specific file.
04906  *
04907  * \param TU translation unit containing the file to query.
04908  *
04909  * \param file to search for #import/#include directives.
04910  *
04911  * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
04912  * each directive found.
04913  *
04914  * \returns one of the CXResult enumerators.
04915  */
04916 CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
04917                                                  CXFile file,
04918                                               CXCursorAndRangeVisitor visitor);
04919 
04920 #ifdef __has_feature
04921 #  if __has_feature(blocks)
04922 
04923 typedef enum CXVisitorResult
04924     (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
04925 
04926 CINDEX_LINKAGE
04927 CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
04928                                              CXCursorAndRangeVisitorBlock);
04929 
04930 CINDEX_LINKAGE
04931 CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
04932                                            CXCursorAndRangeVisitorBlock);
04933 
04934 #  endif
04935 #endif
04936 
04937 /**
04938  * \brief The client's data object that is associated with a CXFile.
04939  */
04940 typedef void *CXIdxClientFile;
04941 
04942 /**
04943  * \brief The client's data object that is associated with a semantic entity.
04944  */
04945 typedef void *CXIdxClientEntity;
04946 
04947 /**
04948  * \brief The client's data object that is associated with a semantic container
04949  * of entities.
04950  */
04951 typedef void *CXIdxClientContainer;
04952 
04953 /**
04954  * \brief The client's data object that is associated with an AST file (PCH
04955  * or module).
04956  */
04957 typedef void *CXIdxClientASTFile;
04958 
04959 /**
04960  * \brief Source location passed to index callbacks.
04961  */
04962 typedef struct {
04963   void *ptr_data[2];
04964   unsigned int_data;
04965 } CXIdxLoc;
04966 
04967 /**
04968  * \brief Data for ppIncludedFile callback.
04969  */
04970 typedef struct {
04971   /**
04972    * \brief Location of '#' in the \#include/\#import directive.
04973    */
04974   CXIdxLoc hashLoc;
04975   /**
04976    * \brief Filename as written in the \#include/\#import directive.
04977    */
04978   const char *filename;
04979   /**
04980    * \brief The actual file that the \#include/\#import directive resolved to.
04981    */
04982   CXFile file;
04983   int isImport;
04984   int isAngled;
04985   /**
04986    * \brief Non-zero if the directive was automatically turned into a module
04987    * import.
04988    */
04989   int isModuleImport;
04990 } CXIdxIncludedFileInfo;
04991 
04992 /**
04993  * \brief Data for IndexerCallbacks#importedASTFile.
04994  */
04995 typedef struct {
04996   /**
04997    * \brief Top level AST file containing the imported PCH, module or submodule.
04998    */
04999   CXFile file;
05000   /**
05001    * \brief The imported module or NULL if the AST file is a PCH.
05002    */
05003   CXModule module;
05004   /**
05005    * \brief Location where the file is imported. Applicable only for modules.
05006    */
05007   CXIdxLoc loc;
05008   /**
05009    * \brief Non-zero if an inclusion directive was automatically turned into
05010    * a module import. Applicable only for modules.
05011    */
05012   int isImplicit;
05013 
05014 } CXIdxImportedASTFileInfo;
05015 
05016 typedef enum {
05017   CXIdxEntity_Unexposed     = 0,
05018   CXIdxEntity_Typedef       = 1,
05019   CXIdxEntity_Function      = 2,
05020   CXIdxEntity_Variable      = 3,
05021   CXIdxEntity_Field         = 4,
05022   CXIdxEntity_EnumConstant  = 5,
05023 
05024   CXIdxEntity_ObjCClass     = 6,
05025   CXIdxEntity_ObjCProtocol  = 7,
05026   CXIdxEntity_ObjCCategory  = 8,
05027 
05028   CXIdxEntity_ObjCInstanceMethod = 9,
05029   CXIdxEntity_ObjCClassMethod    = 10,
05030   CXIdxEntity_ObjCProperty  = 11,
05031   CXIdxEntity_ObjCIvar      = 12,
05032 
05033   CXIdxEntity_Enum          = 13,
05034   CXIdxEntity_Struct        = 14,
05035   CXIdxEntity_Union         = 15,
05036 
05037   CXIdxEntity_CXXClass              = 16,
05038   CXIdxEntity_CXXNamespace          = 17,
05039   CXIdxEntity_CXXNamespaceAlias     = 18,
05040   CXIdxEntity_CXXStaticVariable     = 19,
05041   CXIdxEntity_CXXStaticMethod       = 20,
05042   CXIdxEntity_CXXInstanceMethod     = 21,
05043   CXIdxEntity_CXXConstructor        = 22,
05044   CXIdxEntity_CXXDestructor         = 23,
05045   CXIdxEntity_CXXConversionFunction = 24,
05046   CXIdxEntity_CXXTypeAlias          = 25,
05047   CXIdxEntity_CXXInterface          = 26
05048 
05049 } CXIdxEntityKind;
05050 
05051 typedef enum {
05052   CXIdxEntityLang_None = 0,
05053   CXIdxEntityLang_C    = 1,
05054   CXIdxEntityLang_ObjC = 2,
05055   CXIdxEntityLang_CXX  = 3
05056 } CXIdxEntityLanguage;
05057 
05058 /**
05059  * \brief Extra C++ template information for an entity. This can apply to:
05060  * CXIdxEntity_Function
05061  * CXIdxEntity_CXXClass
05062  * CXIdxEntity_CXXStaticMethod
05063  * CXIdxEntity_CXXInstanceMethod
05064  * CXIdxEntity_CXXConstructor
05065  * CXIdxEntity_CXXConversionFunction
05066  * CXIdxEntity_CXXTypeAlias
05067  */
05068 typedef enum {
05069   CXIdxEntity_NonTemplate   = 0,
05070   CXIdxEntity_Template      = 1,
05071   CXIdxEntity_TemplatePartialSpecialization = 2,
05072   CXIdxEntity_TemplateSpecialization = 3
05073 } CXIdxEntityCXXTemplateKind;
05074 
05075 typedef enum {
05076   CXIdxAttr_Unexposed     = 0,
05077   CXIdxAttr_IBAction      = 1,
05078   CXIdxAttr_IBOutlet      = 2,
05079   CXIdxAttr_IBOutletCollection = 3
05080 } CXIdxAttrKind;
05081 
05082 typedef struct {
05083   CXIdxAttrKind kind;
05084   CXCursor cursor;
05085   CXIdxLoc loc;
05086 } CXIdxAttrInfo;
05087 
05088 typedef struct {
05089   CXIdxEntityKind kind;
05090   CXIdxEntityCXXTemplateKind templateKind;
05091   CXIdxEntityLanguage lang;
05092   const char *name;
05093   const char *USR;
05094   CXCursor cursor;
05095   const CXIdxAttrInfo *const *attributes;
05096   unsigned numAttributes;
05097 } CXIdxEntityInfo;
05098 
05099 typedef struct {
05100   CXCursor cursor;
05101 } CXIdxContainerInfo;
05102 
05103 typedef struct {
05104   const CXIdxAttrInfo *attrInfo;
05105   const CXIdxEntityInfo *objcClass;
05106   CXCursor classCursor;
05107   CXIdxLoc classLoc;
05108 } CXIdxIBOutletCollectionAttrInfo;
05109 
05110 typedef enum {
05111   CXIdxDeclFlag_Skipped = 0x1
05112 } CXIdxDeclInfoFlags;
05113 
05114 typedef struct {
05115   const CXIdxEntityInfo *entityInfo;
05116   CXCursor cursor;
05117   CXIdxLoc loc;
05118   const CXIdxContainerInfo *semanticContainer;
05119   /**
05120    * \brief Generally same as #semanticContainer but can be different in
05121    * cases like out-of-line C++ member functions.
05122    */
05123   const CXIdxContainerInfo *lexicalContainer;
05124   int isRedeclaration;
05125   int isDefinition;
05126   int isContainer;
05127   const CXIdxContainerInfo *declAsContainer;
05128   /**
05129    * \brief Whether the declaration exists in code or was created implicitly
05130    * by the compiler, e.g. implicit Objective-C methods for properties.
05131    */
05132   int isImplicit;
05133   const CXIdxAttrInfo *const *attributes;
05134   unsigned numAttributes;
05135 
05136   unsigned flags;
05137 
05138 } CXIdxDeclInfo;
05139 
05140 typedef enum {
05141   CXIdxObjCContainer_ForwardRef = 0,
05142   CXIdxObjCContainer_Interface = 1,
05143   CXIdxObjCContainer_Implementation = 2
05144 } CXIdxObjCContainerKind;
05145 
05146 typedef struct {
05147   const CXIdxDeclInfo *declInfo;
05148   CXIdxObjCContainerKind kind;
05149 } CXIdxObjCContainerDeclInfo;
05150 
05151 typedef struct {
05152   const CXIdxEntityInfo *base;
05153   CXCursor cursor;
05154   CXIdxLoc loc;
05155 } CXIdxBaseClassInfo;
05156 
05157 typedef struct {
05158   const CXIdxEntityInfo *protocol;
05159   CXCursor cursor;
05160   CXIdxLoc loc;
05161 } CXIdxObjCProtocolRefInfo;
05162 
05163 typedef struct {
05164   const CXIdxObjCProtocolRefInfo *const *protocols;
05165   unsigned numProtocols;
05166 } CXIdxObjCProtocolRefListInfo;
05167 
05168 typedef struct {
05169   const CXIdxObjCContainerDeclInfo *containerInfo;
05170   const CXIdxBaseClassInfo *superInfo;
05171   const CXIdxObjCProtocolRefListInfo *protocols;
05172 } CXIdxObjCInterfaceDeclInfo;
05173 
05174 typedef struct {
05175   const CXIdxObjCContainerDeclInfo *containerInfo;
05176   const CXIdxEntityInfo *objcClass;
05177   CXCursor classCursor;
05178   CXIdxLoc classLoc;
05179   const CXIdxObjCProtocolRefListInfo *protocols;
05180 } CXIdxObjCCategoryDeclInfo;
05181 
05182 typedef struct {
05183   const CXIdxDeclInfo *declInfo;
05184   const CXIdxEntityInfo *getter;
05185   const CXIdxEntityInfo *setter;
05186 } CXIdxObjCPropertyDeclInfo;
05187 
05188 typedef struct {
05189   const CXIdxDeclInfo *declInfo;
05190   const CXIdxBaseClassInfo *const *bases;
05191   unsigned numBases;
05192 } CXIdxCXXClassDeclInfo;
05193 
05194 /**
05195  * \brief Data for IndexerCallbacks#indexEntityReference.
05196  */
05197 typedef enum {
05198   /**
05199    * \brief The entity is referenced directly in user's code.
05200    */
05201   CXIdxEntityRef_Direct = 1,
05202   /**
05203    * \brief An implicit reference, e.g. a reference of an Objective-C method
05204    * via the dot syntax.
05205    */
05206   CXIdxEntityRef_Implicit = 2
05207 } CXIdxEntityRefKind;
05208 
05209 /**
05210  * \brief Data for IndexerCallbacks#indexEntityReference.
05211  */
05212 typedef struct {
05213   CXIdxEntityRefKind kind;
05214   /**
05215    * \brief Reference cursor.
05216    */
05217   CXCursor cursor;
05218   CXIdxLoc loc;
05219   /**
05220    * \brief The entity that gets referenced.
05221    */
05222   const CXIdxEntityInfo *referencedEntity;
05223   /**
05224    * \brief Immediate "parent" of the reference. For example:
05225    * 
05226    * \code
05227    * Foo *var;
05228    * \endcode
05229    * 
05230    * The parent of reference of type 'Foo' is the variable 'var'.
05231    * For references inside statement bodies of functions/methods,
05232    * the parentEntity will be the function/method.
05233    */
05234   const CXIdxEntityInfo *parentEntity;
05235   /**
05236    * \brief Lexical container context of the reference.
05237    */
05238   const CXIdxContainerInfo *container;
05239 } CXIdxEntityRefInfo;
05240 
05241 /**
05242  * \brief A group of callbacks used by #clang_indexSourceFile and
05243  * #clang_indexTranslationUnit.
05244  */
05245 typedef struct {
05246   /**
05247    * \brief Called periodically to check whether indexing should be aborted.
05248    * Should return 0 to continue, and non-zero to abort.
05249    */
05250   int (*abortQuery)(CXClientData client_data, void *reserved);
05251 
05252   /**
05253    * \brief Called at the end of indexing; passes the complete diagnostic set.
05254    */
05255   void (*diagnostic)(CXClientData client_data,
05256                      CXDiagnosticSet, void *reserved);
05257 
05258   CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
05259                                      CXFile mainFile, void *reserved);
05260   
05261   /**
05262    * \brief Called when a file gets \#included/\#imported.
05263    */
05264   CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
05265                                     const CXIdxIncludedFileInfo *);
05266   
05267   /**
05268    * \brief Called when a AST file (PCH or module) gets imported.
05269    * 
05270    * AST files will not get indexed (there will not be callbacks to index all
05271    * the entities in an AST file). The recommended action is that, if the AST
05272    * file is not already indexed, to initiate a new indexing job specific to
05273    * the AST file.
05274    */
05275   CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
05276                                         const CXIdxImportedASTFileInfo *);
05277 
05278   /**
05279    * \brief Called at the beginning of indexing a translation unit.
05280    */
05281   CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
05282                                                  void *reserved);
05283 
05284   void (*indexDeclaration)(CXClientData client_data,
05285                            const CXIdxDeclInfo *);
05286 
05287   /**
05288    * \brief Called to index a reference of an entity.
05289    */
05290   void (*indexEntityReference)(CXClientData client_data,
05291                                const CXIdxEntityRefInfo *);
05292 
05293 } IndexerCallbacks;
05294 
05295 CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
05296 CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
05297 clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
05298 
05299 CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
05300 clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
05301 
05302 CINDEX_LINKAGE
05303 const CXIdxObjCCategoryDeclInfo *
05304 clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
05305 
05306 CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
05307 clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
05308 
05309 CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
05310 clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
05311 
05312 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
05313 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
05314 
05315 CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
05316 clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
05317 
05318 /**
05319  * \brief For retrieving a custom CXIdxClientContainer attached to a
05320  * container.
05321  */
05322 CINDEX_LINKAGE CXIdxClientContainer
05323 clang_index_getClientContainer(const CXIdxContainerInfo *);
05324 
05325 /**
05326  * \brief For setting a custom CXIdxClientContainer attached to a
05327  * container.
05328  */
05329 CINDEX_LINKAGE void
05330 clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
05331 
05332 /**
05333  * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
05334  */
05335 CINDEX_LINKAGE CXIdxClientEntity
05336 clang_index_getClientEntity(const CXIdxEntityInfo *);
05337 
05338 /**
05339  * \brief For setting a custom CXIdxClientEntity attached to an entity.
05340  */
05341 CINDEX_LINKAGE void
05342 clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
05343 
05344 /**
05345  * \brief An indexing action/session, to be applied to one or multiple
05346  * translation units.
05347  */
05348 typedef void *CXIndexAction;
05349 
05350 /**
05351  * \brief An indexing action/session, to be applied to one or multiple
05352  * translation units.
05353  *
05354  * \param CIdx The index object with which the index action will be associated.
05355  */
05356 CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
05357 
05358 /**
05359  * \brief Destroy the given index action.
05360  *
05361  * The index action must not be destroyed until all of the translation units
05362  * created within that index action have been destroyed.
05363  */
05364 CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
05365 
05366 typedef enum {
05367   /**
05368    * \brief Used to indicate that no special indexing options are needed.
05369    */
05370   CXIndexOpt_None = 0x0,
05371   
05372   /**
05373    * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
05374    * be invoked for only one reference of an entity per source file that does
05375    * not also include a declaration/definition of the entity.
05376    */
05377   CXIndexOpt_SuppressRedundantRefs = 0x1,
05378 
05379   /**
05380    * \brief Function-local symbols should be indexed. If this is not set
05381    * function-local symbols will be ignored.
05382    */
05383   CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
05384 
05385   /**
05386    * \brief Implicit function/class template instantiations should be indexed.
05387    * If this is not set, implicit instantiations will be ignored.
05388    */
05389   CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
05390 
05391   /**
05392    * \brief Suppress all compiler warnings when parsing for indexing.
05393    */
05394   CXIndexOpt_SuppressWarnings = 0x8,
05395 
05396   /**
05397    * \brief Skip a function/method body that was already parsed during an
05398    * indexing session associated with a \c CXIndexAction object.
05399    * Bodies in system headers are always skipped.
05400    */
05401   CXIndexOpt_SkipParsedBodiesInSession = 0x10
05402 
05403 } CXIndexOptFlags;
05404 
05405 /**
05406  * \brief Index the given source file and the translation unit corresponding
05407  * to that file via callbacks implemented through #IndexerCallbacks.
05408  *
05409  * \param client_data pointer data supplied by the client, which will
05410  * be passed to the invoked callbacks.
05411  *
05412  * \param index_callbacks Pointer to indexing callbacks that the client
05413  * implements.
05414  *
05415  * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
05416  * passed in index_callbacks.
05417  *
05418  * \param index_options A bitmask of options that affects how indexing is
05419  * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
05420  *
05421  * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
05422  * reused after indexing is finished. Set to \c NULL if you do not require it.
05423  *
05424  * \returns 0 on success or if there were errors from which the compiler could
05425  * recover.  If there is a failure from which the there is no recovery, returns
05426  * a non-zero \c CXErrorCode.
05427  *
05428  * The rest of the parameters are the same as #clang_parseTranslationUnit.
05429  */
05430 CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
05431                                          CXClientData client_data,
05432                                          IndexerCallbacks *index_callbacks,
05433                                          unsigned index_callbacks_size,
05434                                          unsigned index_options,
05435                                          const char *source_filename,
05436                                          const char * const *command_line_args,
05437                                          int num_command_line_args,
05438                                          struct CXUnsavedFile *unsaved_files,
05439                                          unsigned num_unsaved_files,
05440                                          CXTranslationUnit *out_TU,
05441                                          unsigned TU_options);
05442 
05443 /**
05444  * \brief Index the given translation unit via callbacks implemented through
05445  * #IndexerCallbacks.
05446  * 
05447  * The order of callback invocations is not guaranteed to be the same as
05448  * when indexing a source file. The high level order will be:
05449  * 
05450  *   -Preprocessor callbacks invocations
05451  *   -Declaration/reference callbacks invocations
05452  *   -Diagnostic callback invocations
05453  *
05454  * The parameters are the same as #clang_indexSourceFile.
05455  * 
05456  * \returns If there is a failure from which the there is no recovery, returns
05457  * non-zero, otherwise returns 0.
05458  */
05459 CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
05460                                               CXClientData client_data,
05461                                               IndexerCallbacks *index_callbacks,
05462                                               unsigned index_callbacks_size,
05463                                               unsigned index_options,
05464                                               CXTranslationUnit);
05465 
05466 /**
05467  * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
05468  * the given CXIdxLoc.
05469  *
05470  * If the location refers into a macro expansion, retrieves the
05471  * location of the macro expansion and if it refers into a macro argument
05472  * retrieves the location of the argument.
05473  */
05474 CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
05475                                                    CXIdxClientFile *indexFile,
05476                                                    CXFile *file,
05477                                                    unsigned *line,
05478                                                    unsigned *column,
05479                                                    unsigned *offset);
05480 
05481 /**
05482  * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
05483  */
05484 CINDEX_LINKAGE
05485 CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
05486 
05487 /**
05488  * @}
05489  */
05490 
05491 /**
05492  * @}
05493  */
05494 
05495 /* Include the comment API for compatibility. This will eventually go away. */
05496 #include "clang-c/Documentation.h"
05497 
05498 #ifdef __cplusplus
05499 }
05500 #endif
05501 #endif
05502