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