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