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