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