clang
17.0.0git
include
clang-c
Index.h
Go to the documentation of this file.
1
/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2
|* *|
3
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4
|* Exceptions. *|
5
|* See https://llvm.org/LICENSE.txt for license information. *|
6
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7
|* *|
8
|*===----------------------------------------------------------------------===*|
9
|* *|
10
|* This header provides a public interface 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
#ifndef LLVM_CLANG_C_INDEX_H
17
#define LLVM_CLANG_C_INDEX_H
18
19
#include "
clang-c/BuildSystem.h
"
20
#include "
clang-c/CXDiagnostic.h
"
21
#include "
clang-c/CXErrorCode.h
"
22
#include "
clang-c/CXFile.h
"
23
#include "
clang-c/CXSourceLocation.h
"
24
#include "
clang-c/CXString.h
"
25
#include "
clang-c/ExternC.h
"
26
#include "
clang-c/Platform.h
"
27
28
/**
29
* The version constants for the libclang API.
30
* CINDEX_VERSION_MINOR should increase when there are API additions.
31
* CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
32
*
33
* The policy about the libclang API was always to keep it source and ABI
34
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
35
*/
36
#define CINDEX_VERSION_MAJOR 0
37
#define CINDEX_VERSION_MINOR 64
38
39
#define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
40
41
#define CINDEX_VERSION \
42
CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
43
44
#define CINDEX_VERSION_STRINGIZE_(major, minor) #major "."
#minor
45
#define CINDEX_VERSION_STRINGIZE(major, minor) \
46
CINDEX_VERSION_STRINGIZE_(major, minor)
47
48
#define CINDEX_VERSION_STRING \
49
CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
50
51
LLVM_CLANG_C_EXTERN_C_BEGIN
52
53
/** \defgroup CINDEX libclang: C Interface to Clang
54
*
55
* The C Interface to Clang provides a relatively small API that exposes
56
* facilities for parsing source code into an abstract syntax tree (AST),
57
* loading already-parsed ASTs, traversing the AST, associating
58
* physical source locations with elements within the AST, and other
59
* facilities that support Clang-based development tools.
60
*
61
* This C interface to Clang will never provide all of the information
62
* representation stored in Clang's C++ AST, nor should it: the intent is to
63
* maintain an API that is relatively stable from one release to the next,
64
* providing only the basic functionality needed to support development tools.
65
*
66
* To avoid namespace pollution, data types are prefixed with "CX" and
67
* functions are prefixed with "clang_".
68
*
69
* @{
70
*/
71
72
/**
73
* An "index" that consists of a set of translation units that would
74
* typically be linked together into an executable or library.
75
*/
76
typedef
void
*
CXIndex
;
77
78
/**
79
* An opaque type representing target information for a given translation
80
* unit.
81
*/
82
typedef
struct
CXTargetInfoImpl *
CXTargetInfo
;
83
84
/**
85
* A single translation unit, which resides in an index.
86
*/
87
typedef
struct
CXTranslationUnitImpl *
CXTranslationUnit
;
88
89
/**
90
* Opaque pointer representing client data that will be passed through
91
* to various callbacks and visitors.
92
*/
93
typedef
void
*
CXClientData
;
94
95
/**
96
* Provides the contents of a file that has not yet been saved to disk.
97
*
98
* Each CXUnsavedFile instance provides the name of a file on the
99
* system along with the current contents of that file that have not
100
* yet been saved to disk.
101
*/
102
struct
CXUnsavedFile
{
103
/**
104
* The file whose contents have not yet been saved.
105
*
106
* This file must already exist in the file system.
107
*/
108
const
char
*
Filename
;
109
110
/**
111
* A buffer containing the unsaved contents of this file.
112
*/
113
const
char
*
Contents
;
114
115
/**
116
* The length of the unsaved contents of this buffer.
117
*/
118
unsigned
long
Length
;
119
};
120
121
/**
122
* Describes the availability of a particular entity, which indicates
123
* whether the use of this entity will result in a warning or error due to
124
* it being deprecated or unavailable.
125
*/
126
enum
CXAvailabilityKind
{
127
/**
128
* The entity is available.
129
*/
130
CXAvailability_Available
,
131
/**
132
* The entity is available, but has been deprecated (and its use is
133
* not recommended).
134
*/
135
CXAvailability_Deprecated
,
136
/**
137
* The entity is not available; any use of it will be an error.
138
*/
139
CXAvailability_NotAvailable
,
140
/**
141
* The entity is available, but not accessible; any use of it will be
142
* an error.
143
*/
144
CXAvailability_NotAccessible
145
};
146
147
/**
148
* Describes a version number of the form major.minor.subminor.
149
*/
150
typedef
struct
CXVersion
{
151
/**
152
* The major version number, e.g., the '10' in '10.7.3'. A negative
153
* value indicates that there is no version number at all.
154
*/
155
int
Major
;
156
/**
157
* The minor version number, e.g., the '7' in '10.7.3'. This value
158
* will be negative if no minor version number was provided, e.g., for
159
* version '10'.
160
*/
161
int
Minor
;
162
/**
163
* The subminor version number, e.g., the '3' in '10.7.3'. This value
164
* will be negative if no minor or subminor version number was provided,
165
* e.g., in version '10' or '10.7'.
166
*/
167
int
Subminor
;
168
}
CXVersion
;
169
170
/**
171
* Describes the exception specification of a cursor.
172
*
173
* A negative value indicates that the cursor is not a function declaration.
174
*/
175
enum
CXCursor_ExceptionSpecificationKind
{
176
/**
177
* The cursor has no exception specification.
178
*/
179
CXCursor_ExceptionSpecificationKind_None
,
180
181
/**
182
* The cursor has exception specification throw()
183
*/
184
CXCursor_ExceptionSpecificationKind_DynamicNone
,
185
186
/**
187
* The cursor has exception specification throw(T1, T2)
188
*/
189
CXCursor_ExceptionSpecificationKind_Dynamic
,
190
191
/**
192
* The cursor has exception specification throw(...).
193
*/
194
CXCursor_ExceptionSpecificationKind_MSAny
,
195
196
/**
197
* The cursor has exception specification basic noexcept.
198
*/
199
CXCursor_ExceptionSpecificationKind_BasicNoexcept
,
200
201
/**
202
* The cursor has exception specification computed noexcept.
203
*/
204
CXCursor_ExceptionSpecificationKind_ComputedNoexcept
,
205
206
/**
207
* The exception specification has not yet been evaluated.
208
*/
209
CXCursor_ExceptionSpecificationKind_Unevaluated
,
210
211
/**
212
* The exception specification has not yet been instantiated.
213
*/
214
CXCursor_ExceptionSpecificationKind_Uninstantiated
,
215
216
/**
217
* The exception specification has not been parsed yet.
218
*/
219
CXCursor_ExceptionSpecificationKind_Unparsed
,
220
221
/**
222
* The cursor has a __declspec(nothrow) exception specification.
223
*/
224
CXCursor_ExceptionSpecificationKind_NoThrow
225
};
226
227
/**
228
* Provides a shared context for creating translation units.
229
*
230
* It provides two options:
231
*
232
* - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
233
* declarations (when loading any new translation units). A "local" declaration
234
* is one that belongs in the translation unit itself and not in a precompiled
235
* header that was used by the translation unit. If zero, all declarations
236
* will be enumerated.
237
*
238
* Here is an example:
239
*
240
* \code
241
* // excludeDeclsFromPCH = 1, displayDiagnostics=1
242
* Idx = clang_createIndex(1, 1);
243
*
244
* // IndexTest.pch was produced with the following command:
245
* // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
246
* TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
247
*
248
* // This will load all the symbols from 'IndexTest.pch'
249
* clang_visitChildren(clang_getTranslationUnitCursor(TU),
250
* TranslationUnitVisitor, 0);
251
* clang_disposeTranslationUnit(TU);
252
*
253
* // This will load all the symbols from 'IndexTest.c', excluding symbols
254
* // from 'IndexTest.pch'.
255
* char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
256
* TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
257
* 0, 0);
258
* clang_visitChildren(clang_getTranslationUnitCursor(TU),
259
* TranslationUnitVisitor, 0);
260
* clang_disposeTranslationUnit(TU);
261
* \endcode
262
*
263
* This process of creating the 'pch', loading it separately, and using it (via
264
* -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
265
* (which gives the indexer the same performance benefit as the compiler).
266
*/
267
CINDEX_LINKAGE
CXIndex
clang_createIndex
(
int
excludeDeclarationsFromPCH,
268
int
displayDiagnostics);
269
270
/**
271
* Destroy the given index.
272
*
273
* The index must not be destroyed until all of the translation units created
274
* within that index have been destroyed.
275
*/
276
CINDEX_LINKAGE
void
clang_disposeIndex
(
CXIndex
index);
277
278
typedef
enum
{
279
/**
280
* Use the default value of an option that may depend on the process
281
* environment.
282
*/
283
CXChoice_Default
= 0,
284
/**
285
* Enable the option.
286
*/
287
CXChoice_Enabled
= 1,
288
/**
289
* Disable the option.
290
*/
291
CXChoice_Disabled
= 2
292
}
CXChoice
;
293
294
typedef
enum
{
295
/**
296
* Used to indicate that no special CXIndex options are needed.
297
*/
298
CXGlobalOpt_None
= 0x0,
299
300
/**
301
* Used to indicate that threads that libclang creates for indexing
302
* purposes should use background priority.
303
*
304
* Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
305
* #clang_parseTranslationUnit, #clang_saveTranslationUnit.
306
*/
307
CXGlobalOpt_ThreadBackgroundPriorityForIndexing
= 0x1,
308
309
/**
310
* Used to indicate that threads that libclang creates for editing
311
* purposes should use background priority.
312
*
313
* Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
314
* #clang_annotateTokens
315
*/
316
CXGlobalOpt_ThreadBackgroundPriorityForEditing
= 0x2,
317
318
/**
319
* Used to indicate that all threads that libclang creates should use
320
* background priority.
321
*/
322
CXGlobalOpt_ThreadBackgroundPriorityForAll
=
323
CXGlobalOpt_ThreadBackgroundPriorityForIndexing
|
324
CXGlobalOpt_ThreadBackgroundPriorityForEditing
325
326
}
CXGlobalOptFlags
;
327
328
/**
329
* Index initialization options.
330
*
331
* 0 is the default value of each member of this struct except for Size.
332
* Initialize the struct in one of the following three ways to avoid adapting
333
* code each time a new member is added to it:
334
* \code
335
* CXIndexOptions Opts;
336
* memset(&Opts, 0, sizeof(Opts));
337
* Opts.Size = sizeof(CXIndexOptions);
338
* \endcode
339
* or explicitly initialize the first data member and zero-initialize the rest:
340
* \code
341
* CXIndexOptions Opts = { sizeof(CXIndexOptions) };
342
* \endcode
343
* or to prevent the -Wmissing-field-initializers warning for the above version:
344
* \code
345
* CXIndexOptions Opts{};
346
* Opts.Size = sizeof(CXIndexOptions);
347
* \endcode
348
*/
349
typedef
struct
CXIndexOptions
{
350
/**
351
* The size of struct CXIndexOptions used for option versioning.
352
*
353
* Always initialize this member to sizeof(CXIndexOptions), or assign
354
* sizeof(CXIndexOptions) to it right after creating a CXIndexOptions object.
355
*/
356
unsigned
Size
;
357
/**
358
* A CXChoice enumerator that specifies the indexing priority policy.
359
* \sa CXGlobalOpt_ThreadBackgroundPriorityForIndexing
360
*/
361
unsigned
char
ThreadBackgroundPriorityForIndexing
;
362
/**
363
* A CXChoice enumerator that specifies the editing priority policy.
364
* \sa CXGlobalOpt_ThreadBackgroundPriorityForEditing
365
*/
366
unsigned
char
ThreadBackgroundPriorityForEditing
;
367
/**
368
* \see clang_createIndex()
369
*/
370
unsigned
ExcludeDeclarationsFromPCH
: 1;
371
/**
372
* \see clang_createIndex()
373
*/
374
unsigned
DisplayDiagnostics
: 1;
375
/**
376
* Store PCH in memory. If zero, PCH are stored in temporary files.
377
*/
378
unsigned
StorePreamblesInMemory
: 1;
379
unsigned
/*Reserved*/
: 13;
380
381
/**
382
* The path to a directory, in which to store temporary PCH files. If null or
383
* empty, the default system temporary directory is used. These PCH files are
384
* deleted on clean exit but stay on disk if the program crashes or is killed.
385
*
386
* This option is ignored if \a StorePreamblesInMemory is non-zero.
387
*
388
* Libclang does not create the directory at the specified path in the file
389
* system. Therefore it must exist, or storing PCH files will fail.
390
*/
391
const
char
*
PreambleStoragePath
;
392
/**
393
* Specifies a path which will contain log files for certain libclang
394
* invocations. A null value implies that libclang invocations are not logged.
395
*/
396
const
char
*
InvocationEmissionPath
;
397
}
CXIndexOptions
;
398
399
/**
400
* Provides a shared context for creating translation units.
401
*
402
* Call this function instead of clang_createIndex() if you need to configure
403
* the additional options in CXIndexOptions.
404
*
405
* \returns The created index or null in case of error, such as an unsupported
406
* value of options->Size.
407
*
408
* For example:
409
* \code
410
* CXIndex createIndex(const char *ApplicationTemporaryPath) {
411
* const int ExcludeDeclarationsFromPCH = 1;
412
* const int DisplayDiagnostics = 1;
413
* CXIndex Idx;
414
* #if CINDEX_VERSION_MINOR >= 64
415
* CXIndexOptions Opts;
416
* memset(&Opts, 0, sizeof(Opts));
417
* Opts.Size = sizeof(CXIndexOptions);
418
* Opts.ThreadBackgroundPriorityForIndexing = 1;
419
* Opts.ExcludeDeclarationsFromPCH = ExcludeDeclarationsFromPCH;
420
* Opts.DisplayDiagnostics = DisplayDiagnostics;
421
* Opts.PreambleStoragePath = ApplicationTemporaryPath;
422
* Idx = clang_createIndexWithOptions(&Opts);
423
* if (Idx)
424
* return Idx;
425
* fprintf(stderr,
426
* "clang_createIndexWithOptions() failed. "
427
* "CINDEX_VERSION_MINOR = %d, sizeof(CXIndexOptions) = %u\n",
428
* CINDEX_VERSION_MINOR, Opts.Size);
429
* #else
430
* (void)ApplicationTemporaryPath;
431
* #endif
432
* Idx = clang_createIndex(ExcludeDeclarationsFromPCH, DisplayDiagnostics);
433
* clang_CXIndex_setGlobalOptions(
434
* Idx, clang_CXIndex_getGlobalOptions(Idx) |
435
* CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
436
* return Idx;
437
* }
438
* \endcode
439
*
440
* \sa clang_createIndex()
441
*/
442
CINDEX_LINKAGE
CXIndex
443
clang_createIndexWithOptions
(
const
CXIndexOptions
*options);
444
445
/**
446
* Sets general options associated with a CXIndex.
447
*
448
* This function is DEPRECATED. Set
449
* CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
450
* CXIndexOptions::ThreadBackgroundPriorityForEditing and call
451
* clang_createIndexWithOptions() instead.
452
*
453
* For example:
454
* \code
455
* CXIndex idx = ...;
456
* clang_CXIndex_setGlobalOptions(idx,
457
* clang_CXIndex_getGlobalOptions(idx) |
458
* CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
459
* \endcode
460
*
461
* \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
462
*/
463
CINDEX_LINKAGE
void
clang_CXIndex_setGlobalOptions
(
CXIndex
,
unsigned
options);
464
465
/**
466
* Gets the general options associated with a CXIndex.
467
*
468
* This function allows to obtain the final option values used by libclang after
469
* specifying the option policies via CXChoice enumerators.
470
*
471
* \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
472
* are associated with the given CXIndex object.
473
*/
474
CINDEX_LINKAGE
unsigned
clang_CXIndex_getGlobalOptions
(
CXIndex
);
475
476
/**
477
* Sets the invocation emission path option in a CXIndex.
478
*
479
* This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and
480
* call clang_createIndexWithOptions() instead.
481
*
482
* The invocation emission path specifies a path which will contain log
483
* files for certain libclang invocations. A null value (default) implies that
484
* libclang invocations are not logged..
485
*/
486
CINDEX_LINKAGE
void
487
clang_CXIndex_setInvocationEmissionPathOption
(
CXIndex
,
const
char
*Path);
488
489
/**
490
* Determine whether the given header is guarded against
491
* multiple inclusions, either with the conventional
492
* \#ifndef/\#define/\#endif macro guards or with \#pragma once.
493
*/
494
CINDEX_LINKAGE
unsigned
clang_isFileMultipleIncludeGuarded
(
CXTranslationUnit
tu,
495
CXFile
file);
496
497
/**
498
* Retrieve a file handle within the given translation unit.
499
*
500
* \param tu the translation unit
501
*
502
* \param file_name the name of the file.
503
*
504
* \returns the file handle for the named file in the translation unit \p tu,
505
* or a NULL file handle if the file was not a part of this translation unit.
506
*/
507
CINDEX_LINKAGE
CXFile
clang_getFile
(
CXTranslationUnit
tu,
508
const
char
*file_name);
509
510
/**
511
* Retrieve the buffer associated with the given file.
512
*
513
* \param tu the translation unit
514
*
515
* \param file the file for which to retrieve the buffer.
516
*
517
* \param size [out] if non-NULL, will be set to the size of the buffer.
518
*
519
* \returns a pointer to the buffer in memory that holds the contents of
520
* \p file, or a NULL pointer when the file is not loaded.
521
*/
522
CINDEX_LINKAGE
const
char
*
clang_getFileContents
(
CXTranslationUnit
tu,
523
CXFile
file,
size_t
*size);
524
525
/**
526
* Retrieves the source location associated with a given file/line/column
527
* in a particular translation unit.
528
*/
529
CINDEX_LINKAGE
CXSourceLocation
clang_getLocation
(
CXTranslationUnit
tu,
530
CXFile
file,
unsigned
line,
531
unsigned
column);
532
/**
533
* Retrieves the source location associated with a given character offset
534
* in a particular translation unit.
535
*/
536
CINDEX_LINKAGE
CXSourceLocation
clang_getLocationForOffset
(
CXTranslationUnit
tu,
537
CXFile
file,
538
unsigned
offset);
539
540
/**
541
* Retrieve all ranges that were skipped by the preprocessor.
542
*
543
* The preprocessor will skip lines when they are surrounded by an
544
* if/ifdef/ifndef directive whose condition does not evaluate to true.
545
*/
546
CINDEX_LINKAGE
CXSourceRangeList
*
clang_getSkippedRanges
(
CXTranslationUnit
tu,
547
CXFile
file);
548
549
/**
550
* Retrieve all ranges from all files that were skipped by the
551
* preprocessor.
552
*
553
* The preprocessor will skip lines when they are surrounded by an
554
* if/ifdef/ifndef directive whose condition does not evaluate to true.
555
*/
556
CINDEX_LINKAGE
CXSourceRangeList
*
557
clang_getAllSkippedRanges
(
CXTranslationUnit
tu);
558
559
/**
560
* Determine the number of diagnostics produced for the given
561
* translation unit.
562
*/
563
CINDEX_LINKAGE
unsigned
clang_getNumDiagnostics
(
CXTranslationUnit
Unit);
564
565
/**
566
* Retrieve a diagnostic associated with the given translation unit.
567
*
568
* \param Unit the translation unit to query.
569
* \param Index the zero-based diagnostic number to retrieve.
570
*
571
* \returns the requested diagnostic. This diagnostic must be freed
572
* via a call to \c clang_disposeDiagnostic().
573
*/
574
CINDEX_LINKAGE
CXDiagnostic
clang_getDiagnostic
(
CXTranslationUnit
Unit,
575
unsigned
Index);
576
577
/**
578
* Retrieve the complete set of diagnostics associated with a
579
* translation unit.
580
*
581
* \param Unit the translation unit to query.
582
*/
583
CINDEX_LINKAGE
CXDiagnosticSet
584
clang_getDiagnosticSetFromTU
(
CXTranslationUnit
Unit);
585
586
/**
587
* \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
588
*
589
* The routines in this group provide the ability to create and destroy
590
* translation units from files, either by parsing the contents of the files or
591
* by reading in a serialized representation of a translation unit.
592
*
593
* @{
594
*/
595
596
/**
597
* Get the original translation unit source file name.
598
*/
599
CINDEX_LINKAGE
CXString
600
clang_getTranslationUnitSpelling
(
CXTranslationUnit
CTUnit);
601
602
/**
603
* Return the CXTranslationUnit for a given source file and the provided
604
* command line arguments one would pass to the compiler.
605
*
606
* Note: The 'source_filename' argument is optional. If the caller provides a
607
* NULL pointer, the name of the source file is expected to reside in the
608
* specified command line arguments.
609
*
610
* Note: When encountered in 'clang_command_line_args', the following options
611
* are ignored:
612
*
613
* '-c'
614
* '-emit-ast'
615
* '-fsyntax-only'
616
* '-o <output file>' (both '-o' and '<output file>' are ignored)
617
*
618
* \param CIdx The index object with which the translation unit will be
619
* associated.
620
*
621
* \param source_filename The name of the source file to load, or NULL if the
622
* source file is included in \p clang_command_line_args.
623
*
624
* \param num_clang_command_line_args The number of command-line arguments in
625
* \p clang_command_line_args.
626
*
627
* \param clang_command_line_args The command-line arguments that would be
628
* passed to the \c clang executable if it were being invoked out-of-process.
629
* These command-line options will be parsed and will affect how the translation
630
* unit is parsed. Note that the following options are ignored: '-c',
631
* '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
632
*
633
* \param num_unsaved_files the number of unsaved file entries in \p
634
* unsaved_files.
635
*
636
* \param unsaved_files the files that have not yet been saved to disk
637
* but may be required for code completion, including the contents of
638
* those files. The contents and name of these files (as specified by
639
* CXUnsavedFile) are copied when necessary, so the client only needs to
640
* guarantee their validity until the call to this function returns.
641
*/
642
CINDEX_LINKAGE
CXTranslationUnit
clang_createTranslationUnitFromSourceFile
(
643
CXIndex
CIdx,
const
char
*source_filename,
int
num_clang_command_line_args,
644
const
char
*
const
*clang_command_line_args,
unsigned
num_unsaved_files,
645
struct
CXUnsavedFile
*unsaved_files);
646
647
/**
648
* Same as \c clang_createTranslationUnit2, but returns
649
* the \c CXTranslationUnit instead of an error code. In case of an error this
650
* routine returns a \c NULL \c CXTranslationUnit, without further detailed
651
* error codes.
652
*/
653
CINDEX_LINKAGE
CXTranslationUnit
654
clang_createTranslationUnit
(
CXIndex
CIdx,
const
char
*ast_filename);
655
656
/**
657
* Create a translation unit from an AST file (\c -emit-ast).
658
*
659
* \param[out] out_TU A non-NULL pointer to store the created
660
* \c CXTranslationUnit.
661
*
662
* \returns Zero on success, otherwise returns an error code.
663
*/
664
CINDEX_LINKAGE
enum
CXErrorCode
665
clang_createTranslationUnit2
(
CXIndex
CIdx,
const
char
*ast_filename,
666
CXTranslationUnit
*out_TU);
667
668
/**
669
* Flags that control the creation of translation units.
670
*
671
* The enumerators in this enumeration type are meant to be bitwise
672
* ORed together to specify which options should be used when
673
* constructing the translation unit.
674
*/
675
enum
CXTranslationUnit_Flags
{
676
/**
677
* Used to indicate that no special translation-unit options are
678
* needed.
679
*/
680
CXTranslationUnit_None
= 0x0,
681
682
/**
683
* Used to indicate that the parser should construct a "detailed"
684
* preprocessing record, including all macro definitions and instantiations.
685
*
686
* Constructing a detailed preprocessing record requires more memory
687
* and time to parse, since the information contained in the record
688
* is usually not retained. However, it can be useful for
689
* applications that require more detailed information about the
690
* behavior of the preprocessor.
691
*/
692
CXTranslationUnit_DetailedPreprocessingRecord
= 0x01,
693
694
/**
695
* Used to indicate that the translation unit is incomplete.
696
*
697
* When a translation unit is considered "incomplete", semantic
698
* analysis that is typically performed at the end of the
699
* translation unit will be suppressed. For example, this suppresses
700
* the completion of tentative declarations in C and of
701
* instantiation of implicitly-instantiation function templates in
702
* C++. This option is typically used when parsing a header with the
703
* intent of producing a precompiled header.
704
*/
705
CXTranslationUnit_Incomplete
= 0x02,
706
707
/**
708
* Used to indicate that the translation unit should be built with an
709
* implicit precompiled header for the preamble.
710
*
711
* An implicit precompiled header is used as an optimization when a
712
* particular translation unit is likely to be reparsed many times
713
* when the sources aren't changing that often. In this case, an
714
* implicit precompiled header will be built containing all of the
715
* initial includes at the top of the main file (what we refer to as
716
* the "preamble" of the file). In subsequent parses, if the
717
* preamble or the files in it have not changed, \c
718
* clang_reparseTranslationUnit() will re-use the implicit
719
* precompiled header to improve parsing performance.
720
*/
721
CXTranslationUnit_PrecompiledPreamble
= 0x04,
722
723
/**
724
* Used to indicate that the translation unit should cache some
725
* code-completion results with each reparse of the source file.
726
*
727
* Caching of code-completion results is a performance optimization that
728
* introduces some overhead to reparsing but improves the performance of
729
* code-completion operations.
730
*/
731
CXTranslationUnit_CacheCompletionResults
= 0x08,
732
733
/**
734
* Used to indicate that the translation unit will be serialized with
735
* \c clang_saveTranslationUnit.
736
*
737
* This option is typically used when parsing a header with the intent of
738
* producing a precompiled header.
739
*/
740
CXTranslationUnit_ForSerialization
= 0x10,
741
742
/**
743
* DEPRECATED: Enabled chained precompiled preambles in C++.
744
*
745
* Note: this is a *temporary* option that is available only while
746
* we are testing C++ precompiled preamble support. It is deprecated.
747
*/
748
CXTranslationUnit_CXXChainedPCH
= 0x20,
749
750
/**
751
* Used to indicate that function/method bodies should be skipped while
752
* parsing.
753
*
754
* This option can be used to search for declarations/definitions while
755
* ignoring the usages.
756
*/
757
CXTranslationUnit_SkipFunctionBodies
= 0x40,
758
759
/**
760
* Used to indicate that brief documentation comments should be
761
* included into the set of code completions returned from this translation
762
* unit.
763
*/
764
CXTranslationUnit_IncludeBriefCommentsInCodeCompletion
= 0x80,
765
766
/**
767
* Used to indicate that the precompiled preamble should be created on
768
* the first parse. Otherwise it will be created on the first reparse. This
769
* trades runtime on the first parse (serializing the preamble takes time) for
770
* reduced runtime on the second parse (can now reuse the preamble).
771
*/
772
CXTranslationUnit_CreatePreambleOnFirstParse
= 0x100,
773
774
/**
775
* Do not stop processing when fatal errors are encountered.
776
*
777
* When fatal errors are encountered while parsing a translation unit,
778
* semantic analysis is typically stopped early when compiling code. A common
779
* source for fatal errors are unresolvable include files. For the
780
* purposes of an IDE, this is undesirable behavior and as much information
781
* as possible should be reported. Use this flag to enable this behavior.
782
*/
783
CXTranslationUnit_KeepGoing
= 0x200,
784
785
/**
786
* Sets the preprocessor in a mode for parsing a single file only.
787
*/
788
CXTranslationUnit_SingleFileParse
= 0x400,
789
790
/**
791
* Used in combination with CXTranslationUnit_SkipFunctionBodies to
792
* constrain the skipping of function bodies to the preamble.
793
*
794
* The function bodies of the main file are not skipped.
795
*/
796
CXTranslationUnit_LimitSkipFunctionBodiesToPreamble
= 0x800,
797
798
/**
799
* Used to indicate that attributed types should be included in CXType.
800
*/
801
CXTranslationUnit_IncludeAttributedTypes
= 0x1000,
802
803
/**
804
* Used to indicate that implicit attributes should be visited.
805
*/
806
CXTranslationUnit_VisitImplicitAttributes
= 0x2000,
807
808
/**
809
* Used to indicate that non-errors from included files should be ignored.
810
*
811
* If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
812
* included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
813
* the case where these warnings are not of interest, as for an IDE for
814
* example, which typically shows only the diagnostics in the main file.
815
*/
816
CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles
= 0x4000,
817
818
/**
819
* Tells the preprocessor not to skip excluded conditional blocks.
820
*/
821
CXTranslationUnit_RetainExcludedConditionalBlocks
= 0x8000
822
};
823
824
/**
825
* Returns the set of flags that is suitable for parsing a translation
826
* unit that is being edited.
827
*
828
* The set of flags returned provide options for \c clang_parseTranslationUnit()
829
* to indicate that the translation unit is likely to be reparsed many times,
830
* either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
831
* (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
832
* set contains an unspecified set of optimizations (e.g., the precompiled
833
* preamble) geared toward improving the performance of these routines. The
834
* set of optimizations enabled may change from one version to the next.
835
*/
836
CINDEX_LINKAGE
unsigned
clang_defaultEditingTranslationUnitOptions
(
void
);
837
838
/**
839
* Same as \c clang_parseTranslationUnit2, but returns
840
* the \c CXTranslationUnit instead of an error code. In case of an error this
841
* routine returns a \c NULL \c CXTranslationUnit, without further detailed
842
* error codes.
843
*/
844
CINDEX_LINKAGE
CXTranslationUnit
clang_parseTranslationUnit
(
845
CXIndex
CIdx,
const
char
*source_filename,
846
const
char
*
const
*command_line_args,
int
num_command_line_args,
847
struct
CXUnsavedFile
*unsaved_files,
unsigned
num_unsaved_files,
848
unsigned
options);
849
850
/**
851
* Parse the given source file and the translation unit corresponding
852
* to that file.
853
*
854
* This routine is the main entry point for the Clang C API, providing the
855
* ability to parse a source file into a translation unit that can then be
856
* queried by other functions in the API. This routine accepts a set of
857
* command-line arguments so that the compilation can be configured in the same
858
* way that the compiler is configured on the command line.
859
*
860
* \param CIdx The index object with which the translation unit will be
861
* associated.
862
*
863
* \param source_filename The name of the source file to load, or NULL if the
864
* source file is included in \c command_line_args.
865
*
866
* \param command_line_args The command-line arguments that would be
867
* passed to the \c clang executable if it were being invoked out-of-process.
868
* These command-line options will be parsed and will affect how the translation
869
* unit is parsed. Note that the following options are ignored: '-c',
870
* '-emit-ast', '-fsyntax-only' (which is the default), and '-o <output file>'.
871
*
872
* \param num_command_line_args The number of command-line arguments in
873
* \c command_line_args.
874
*
875
* \param unsaved_files the files that have not yet been saved to disk
876
* but may be required for parsing, including the contents of
877
* those files. The contents and name of these files (as specified by
878
* CXUnsavedFile) are copied when necessary, so the client only needs to
879
* guarantee their validity until the call to this function returns.
880
*
881
* \param num_unsaved_files the number of unsaved file entries in \p
882
* unsaved_files.
883
*
884
* \param options A bitmask of options that affects how the translation unit
885
* is managed but not its compilation. This should be a bitwise OR of the
886
* CXTranslationUnit_XXX flags.
887
*
888
* \param[out] out_TU A non-NULL pointer to store the created
889
* \c CXTranslationUnit, describing the parsed code and containing any
890
* diagnostics produced by the compiler.
891
*
892
* \returns Zero on success, otherwise returns an error code.
893
*/
894
CINDEX_LINKAGE
enum
CXErrorCode
clang_parseTranslationUnit2
(
895
CXIndex
CIdx,
const
char
*source_filename,
896
const
char
*
const
*command_line_args,
int
num_command_line_args,
897
struct
CXUnsavedFile
*unsaved_files,
unsigned
num_unsaved_files,
898
unsigned
options,
CXTranslationUnit
*out_TU);
899
900
/**
901
* Same as clang_parseTranslationUnit2 but requires a full command line
902
* for \c command_line_args including argv[0]. This is useful if the standard
903
* library paths are relative to the binary.
904
*/
905
CINDEX_LINKAGE
enum
CXErrorCode
clang_parseTranslationUnit2FullArgv
(
906
CXIndex
CIdx,
const
char
*source_filename,
907
const
char
*
const
*command_line_args,
int
num_command_line_args,
908
struct
CXUnsavedFile
*unsaved_files,
unsigned
num_unsaved_files,
909
unsigned
options,
CXTranslationUnit
*out_TU);
910
911
/**
912
* Flags that control how translation units are saved.
913
*
914
* The enumerators in this enumeration type are meant to be bitwise
915
* ORed together to specify which options should be used when
916
* saving the translation unit.
917
*/
918
enum
CXSaveTranslationUnit_Flags
{
919
/**
920
* Used to indicate that no special saving options are needed.
921
*/
922
CXSaveTranslationUnit_None
= 0x0
923
};
924
925
/**
926
* Returns the set of flags that is suitable for saving a translation
927
* unit.
928
*
929
* The set of flags returned provide options for
930
* \c clang_saveTranslationUnit() by default. The returned flag
931
* set contains an unspecified set of options that save translation units with
932
* the most commonly-requested data.
933
*/
934
CINDEX_LINKAGE
unsigned
clang_defaultSaveOptions
(
CXTranslationUnit
TU);
935
936
/**
937
* Describes the kind of error that occurred (if any) in a call to
938
* \c clang_saveTranslationUnit().
939
*/
940
enum
CXSaveError
{
941
/**
942
* Indicates that no error occurred while saving a translation unit.
943
*/
944
CXSaveError_None
= 0,
945
946
/**
947
* Indicates that an unknown error occurred while attempting to save
948
* the file.
949
*
950
* This error typically indicates that file I/O failed when attempting to
951
* write the file.
952
*/
953
CXSaveError_Unknown
= 1,
954
955
/**
956
* Indicates that errors during translation prevented this attempt
957
* to save the translation unit.
958
*
959
* Errors that prevent the translation unit from being saved can be
960
* extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
961
*/
962
CXSaveError_TranslationErrors
= 2,
963
964
/**
965
* Indicates that the translation unit to be saved was somehow
966
* invalid (e.g., NULL).
967
*/
968
CXSaveError_InvalidTU
= 3
969
};
970
971
/**
972
* Saves a translation unit into a serialized representation of
973
* that translation unit on disk.
974
*
975
* Any translation unit that was parsed without error can be saved
976
* into a file. The translation unit can then be deserialized into a
977
* new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
978
* if it is an incomplete translation unit that corresponds to a
979
* header, used as a precompiled header when parsing other translation
980
* units.
981
*
982
* \param TU The translation unit to save.
983
*
984
* \param FileName The file to which the translation unit will be saved.
985
*
986
* \param options A bitmask of options that affects how the translation unit
987
* is saved. This should be a bitwise OR of the
988
* CXSaveTranslationUnit_XXX flags.
989
*
990
* \returns A value that will match one of the enumerators of the CXSaveError
991
* enumeration. Zero (CXSaveError_None) indicates that the translation unit was
992
* saved successfully, while a non-zero value indicates that a problem occurred.
993
*/
994
CINDEX_LINKAGE
int
clang_saveTranslationUnit
(
CXTranslationUnit
TU,
995
const
char
*FileName,
996
unsigned
options);
997
998
/**
999
* Suspend a translation unit in order to free memory associated with it.
1000
*
1001
* A suspended translation unit uses significantly less memory but on the other
1002
* side does not support any other calls than \c clang_reparseTranslationUnit
1003
* to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1004
*/
1005
CINDEX_LINKAGE
unsigned
clang_suspendTranslationUnit
(
CXTranslationUnit
);
1006
1007
/**
1008
* Destroy the specified CXTranslationUnit object.
1009
*/
1010
CINDEX_LINKAGE
void
clang_disposeTranslationUnit
(
CXTranslationUnit
);
1011
1012
/**
1013
* Flags that control the reparsing of translation units.
1014
*
1015
* The enumerators in this enumeration type are meant to be bitwise
1016
* ORed together to specify which options should be used when
1017
* reparsing the translation unit.
1018
*/
1019
enum
CXReparse_Flags
{
1020
/**
1021
* Used to indicate that no special reparsing options are needed.
1022
*/
1023
CXReparse_None
= 0x0
1024
};
1025
1026
/**
1027
* Returns the set of flags that is suitable for reparsing a translation
1028
* unit.
1029
*
1030
* The set of flags returned provide options for
1031
* \c clang_reparseTranslationUnit() by default. The returned flag
1032
* set contains an unspecified set of optimizations geared toward common uses
1033
* of reparsing. The set of optimizations enabled may change from one version
1034
* to the next.
1035
*/
1036
CINDEX_LINKAGE
unsigned
clang_defaultReparseOptions
(
CXTranslationUnit
TU);
1037
1038
/**
1039
* Reparse the source files that produced this translation unit.
1040
*
1041
* This routine can be used to re-parse the source files that originally
1042
* created the given translation unit, for example because those source files
1043
* have changed (either on disk or as passed via \p unsaved_files). The
1044
* source code will be reparsed with the same command-line options as it
1045
* was originally parsed.
1046
*
1047
* Reparsing a translation unit invalidates all cursors and source locations
1048
* that refer into that translation unit. This makes reparsing a translation
1049
* unit semantically equivalent to destroying the translation unit and then
1050
* creating a new translation unit with the same command-line arguments.
1051
* However, it may be more efficient to reparse a translation
1052
* unit using this routine.
1053
*
1054
* \param TU The translation unit whose contents will be re-parsed. The
1055
* translation unit must originally have been built with
1056
* \c clang_createTranslationUnitFromSourceFile().
1057
*
1058
* \param num_unsaved_files The number of unsaved file entries in \p
1059
* unsaved_files.
1060
*
1061
* \param unsaved_files The files that have not yet been saved to disk
1062
* but may be required for parsing, including the contents of
1063
* those files. The contents and name of these files (as specified by
1064
* CXUnsavedFile) are copied when necessary, so the client only needs to
1065
* guarantee their validity until the call to this function returns.
1066
*
1067
* \param options A bitset of options composed of the flags in CXReparse_Flags.
1068
* The function \c clang_defaultReparseOptions() produces a default set of
1069
* options recommended for most uses, based on the translation unit.
1070
*
1071
* \returns 0 if the sources could be reparsed. A non-zero error code will be
1072
* returned if reparsing was impossible, such that the translation unit is
1073
* invalid. In such cases, the only valid call for \c TU is
1074
* \c clang_disposeTranslationUnit(TU). The error codes returned by this
1075
* routine are described by the \c CXErrorCode enum.
1076
*/
1077
CINDEX_LINKAGE
int
1078
clang_reparseTranslationUnit
(
CXTranslationUnit
TU,
unsigned
num_unsaved_files,
1079
struct
CXUnsavedFile
*unsaved_files,
1080
unsigned
options);
1081
1082
/**
1083
* Categorizes how memory is being used by a translation unit.
1084
*/
1085
enum
CXTUResourceUsageKind
{
1086
CXTUResourceUsage_AST
= 1,
1087
CXTUResourceUsage_Identifiers
= 2,
1088
CXTUResourceUsage_Selectors
= 3,
1089
CXTUResourceUsage_GlobalCompletionResults
= 4,
1090
CXTUResourceUsage_SourceManagerContentCache
= 5,
1091
CXTUResourceUsage_AST_SideTables
= 6,
1092
CXTUResourceUsage_SourceManager_Membuffer_Malloc
= 7,
1093
CXTUResourceUsage_SourceManager_Membuffer_MMap
= 8,
1094
CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc
= 9,
1095
CXTUResourceUsage_ExternalASTSource_Membuffer_MMap
= 10,
1096
CXTUResourceUsage_Preprocessor
= 11,
1097
CXTUResourceUsage_PreprocessingRecord
= 12,
1098
CXTUResourceUsage_SourceManager_DataStructures
= 13,
1099
CXTUResourceUsage_Preprocessor_HeaderSearch
= 14,
1100
CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN
=
CXTUResourceUsage_AST
,
1101
CXTUResourceUsage_MEMORY_IN_BYTES_END
=
1102
CXTUResourceUsage_Preprocessor_HeaderSearch
,
1103
1104
CXTUResourceUsage_First
=
CXTUResourceUsage_AST
,
1105
CXTUResourceUsage_Last
=
CXTUResourceUsage_Preprocessor_HeaderSearch
1106
};
1107
1108
/**
1109
* Returns the human-readable null-terminated C string that represents
1110
* the name of the memory category. This string should never be freed.
1111
*/
1112
CINDEX_LINKAGE
1113
const
char
*
clang_getTUResourceUsageName
(
enum
CXTUResourceUsageKind
kind);
1114
1115
typedef
struct
CXTUResourceUsageEntry
{
1116
/* The memory usage category. */
1117
enum
CXTUResourceUsageKind
kind
;
1118
/* Amount of resources used.
1119
The units will depend on the resource kind. */
1120
unsigned
long
amount
;
1121
}
CXTUResourceUsageEntry
;
1122
1123
/**
1124
* The memory usage of a CXTranslationUnit, broken into categories.
1125
*/
1126
typedef
struct
CXTUResourceUsage
{
1127
/* Private data member, used for queries. */
1128
void
*
data
;
1129
1130
/* The number of entries in the 'entries' array. */
1131
unsigned
numEntries
;
1132
1133
/* An array of key-value pairs, representing the breakdown of memory
1134
usage. */
1135
CXTUResourceUsageEntry
*
entries
;
1136
1137
}
CXTUResourceUsage
;
1138
1139
/**
1140
* Return the memory usage of a translation unit. This object
1141
* should be released with clang_disposeCXTUResourceUsage().
1142
*/
1143
CINDEX_LINKAGE
CXTUResourceUsage
1144
clang_getCXTUResourceUsage
(
CXTranslationUnit
TU);
1145
1146
CINDEX_LINKAGE
void
clang_disposeCXTUResourceUsage
(
CXTUResourceUsage
usage);
1147
1148
/**
1149
* Get target information for this translation unit.
1150
*
1151
* The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1152
*/
1153
CINDEX_LINKAGE
CXTargetInfo
1154
clang_getTranslationUnitTargetInfo
(
CXTranslationUnit
CTUnit);
1155
1156
/**
1157
* Destroy the CXTargetInfo object.
1158
*/
1159
CINDEX_LINKAGE
void
clang_TargetInfo_dispose
(
CXTargetInfo
Info);
1160
1161
/**
1162
* Get the normalized target triple as a string.
1163
*
1164
* Returns the empty string in case of any error.
1165
*/
1166
CINDEX_LINKAGE
CXString
clang_TargetInfo_getTriple
(
CXTargetInfo
Info);
1167
1168
/**
1169
* Get the pointer width of the target in bits.
1170
*
1171
* Returns -1 in case of error.
1172
*/
1173
CINDEX_LINKAGE
int
clang_TargetInfo_getPointerWidth
(
CXTargetInfo
Info);
1174
1175
/**
1176
* @}
1177
*/
1178
1179
/**
1180
* Describes the kind of entity that a cursor refers to.
1181
*/
1182
enum
CXCursorKind
{
1183
/* Declarations */
1184
/**
1185
* A declaration whose specific kind is not exposed via this
1186
* interface.
1187
*
1188
* Unexposed declarations have the same operations as any other kind
1189
* of declaration; one can extract their location information,
1190
* spelling, find their definitions, etc. However, the specific kind
1191
* of the declaration is not reported.
1192
*/
1193
CXCursor_UnexposedDecl
= 1,
1194
/** A C or C++ struct. */
1195
CXCursor_StructDecl
= 2,
1196
/** A C or C++ union. */
1197
CXCursor_UnionDecl
= 3,
1198
/** A C++ class. */
1199
CXCursor_ClassDecl
= 4,
1200
/** An enumeration. */
1201
CXCursor_EnumDecl
= 5,
1202
/**
1203
* A field (in C) or non-static data member (in C++) in a
1204
* struct, union, or C++ class.
1205
*/
1206
CXCursor_FieldDecl
= 6,
1207
/** An enumerator constant. */
1208
CXCursor_EnumConstantDecl
= 7,
1209
/** A function. */
1210
CXCursor_FunctionDecl
= 8,
1211
/** A variable. */
1212
CXCursor_VarDecl
= 9,
1213
/** A function or method parameter. */
1214
CXCursor_ParmDecl
= 10,
1215
/** An Objective-C \@interface. */
1216
CXCursor_ObjCInterfaceDecl
= 11,
1217
/** An Objective-C \@interface for a category. */
1218
CXCursor_ObjCCategoryDecl
= 12,
1219
/** An Objective-C \@protocol declaration. */
1220
CXCursor_ObjCProtocolDecl
= 13,
1221
/** An Objective-C \@property declaration. */
1222
CXCursor_ObjCPropertyDecl
= 14,
1223
/** An Objective-C instance variable. */
1224
CXCursor_ObjCIvarDecl
= 15,
1225
/** An Objective-C instance method. */
1226
CXCursor_ObjCInstanceMethodDecl
= 16,
1227
/** An Objective-C class method. */
1228
CXCursor_ObjCClassMethodDecl
= 17,
1229
/** An Objective-C \@implementation. */
1230
CXCursor_ObjCImplementationDecl
= 18,
1231
/** An Objective-C \@implementation for a category. */
1232
CXCursor_ObjCCategoryImplDecl
= 19,
1233
/** A typedef. */
1234
CXCursor_TypedefDecl
= 20,
1235
/** A C++ class method. */
1236
CXCursor_CXXMethod
= 21,
1237
/** A C++ namespace. */
1238
CXCursor_Namespace
= 22,
1239
/** A linkage specification, e.g. 'extern "C"'. */
1240
CXCursor_LinkageSpec
= 23,
1241
/** A C++ constructor. */
1242
CXCursor_Constructor
= 24,
1243
/** A C++ destructor. */
1244
CXCursor_Destructor
= 25,
1245
/** A C++ conversion function. */
1246
CXCursor_ConversionFunction
= 26,
1247
/** A C++ template type parameter. */
1248
CXCursor_TemplateTypeParameter
= 27,
1249
/** A C++ non-type template parameter. */
1250
CXCursor_NonTypeTemplateParameter
= 28,
1251
/** A C++ template template parameter. */
1252
CXCursor_TemplateTemplateParameter
= 29,
1253
/** A C++ function template. */
1254
CXCursor_FunctionTemplate
= 30,
1255
/** A C++ class template. */
1256
CXCursor_ClassTemplate
= 31,
1257
/** A C++ class template partial specialization. */
1258
CXCursor_ClassTemplatePartialSpecialization
= 32,
1259
/** A C++ namespace alias declaration. */
1260
CXCursor_NamespaceAlias
= 33,
1261
/** A C++ using directive. */
1262
CXCursor_UsingDirective
= 34,
1263
/** A C++ using declaration. */
1264
CXCursor_UsingDeclaration
= 35,
1265
/** A C++ alias declaration */
1266
CXCursor_TypeAliasDecl
= 36,
1267
/** An Objective-C \@synthesize definition. */
1268
CXCursor_ObjCSynthesizeDecl
= 37,
1269
/** An Objective-C \@dynamic definition. */
1270
CXCursor_ObjCDynamicDecl
= 38,
1271
/** An access specifier. */
1272
CXCursor_CXXAccessSpecifier
= 39,
1273
1274
CXCursor_FirstDecl
=
CXCursor_UnexposedDecl
,
1275
CXCursor_LastDecl
=
CXCursor_CXXAccessSpecifier
,
1276
1277
/* References */
1278
CXCursor_FirstRef
= 40,
/* Decl references */
1279
CXCursor_ObjCSuperClassRef
= 40,
1280
CXCursor_ObjCProtocolRef
= 41,
1281
CXCursor_ObjCClassRef
= 42,
1282
/**
1283
* A reference to a type declaration.
1284
*
1285
* A type reference occurs anywhere where a type is named but not
1286
* declared. For example, given:
1287
*
1288
* \code
1289
* typedef unsigned size_type;
1290
* size_type size;
1291
* \endcode
1292
*
1293
* The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1294
* while the type of the variable "size" is referenced. The cursor
1295
* referenced by the type of size is the typedef for size_type.
1296
*/
1297
CXCursor_TypeRef
= 43,
1298
CXCursor_CXXBaseSpecifier
= 44,
1299
/**
1300
* A reference to a class template, function template, template
1301
* template parameter, or class template partial specialization.
1302
*/
1303
CXCursor_TemplateRef
= 45,
1304
/**
1305
* A reference to a namespace or namespace alias.
1306
*/
1307
CXCursor_NamespaceRef
= 46,
1308
/**
1309
* A reference to a member of a struct, union, or class that occurs in
1310
* some non-expression context, e.g., a designated initializer.
1311
*/
1312
CXCursor_MemberRef
= 47,
1313
/**
1314
* A reference to a labeled statement.
1315
*
1316
* This cursor kind is used to describe the jump to "start_over" in the
1317
* goto statement in the following example:
1318
*
1319
* \code
1320
* start_over:
1321
* ++counter;
1322
*
1323
* goto start_over;
1324
* \endcode
1325
*
1326
* A label reference cursor refers to a label statement.
1327
*/
1328
CXCursor_LabelRef
= 48,
1329
1330
/**
1331
* A reference to a set of overloaded functions or function templates
1332
* that has not yet been resolved to a specific function or function template.
1333
*
1334
* An overloaded declaration reference cursor occurs in C++ templates where
1335
* a dependent name refers to a function. For example:
1336
*
1337
* \code
1338
* template<typename T> void swap(T&, T&);
1339
*
1340
* struct X { ... };
1341
* void swap(X&, X&);
1342
*
1343
* template<typename T>
1344
* void reverse(T* first, T* last) {
1345
* while (first < last - 1) {
1346
* swap(*first, *--last);
1347
* ++first;
1348
* }
1349
* }
1350
*
1351
* struct Y { };
1352
* void swap(Y&, Y&);
1353
* \endcode
1354
*
1355
* Here, the identifier "swap" is associated with an overloaded declaration
1356
* reference. In the template definition, "swap" refers to either of the two
1357
* "swap" functions declared above, so both results will be available. At
1358
* instantiation time, "swap" may also refer to other functions found via
1359
* argument-dependent lookup (e.g., the "swap" function at the end of the
1360
* example).
1361
*
1362
* The functions \c clang_getNumOverloadedDecls() and
1363
* \c clang_getOverloadedDecl() can be used to retrieve the definitions
1364
* referenced by this cursor.
1365
*/
1366
CXCursor_OverloadedDeclRef
= 49,
1367
1368
/**
1369
* A reference to a variable that occurs in some non-expression
1370
* context, e.g., a C++ lambda capture list.
1371
*/
1372
CXCursor_VariableRef
= 50,
1373
1374
CXCursor_LastRef
=
CXCursor_VariableRef
,
1375
1376
/* Error conditions */
1377
CXCursor_FirstInvalid
= 70,
1378
CXCursor_InvalidFile
= 70,
1379
CXCursor_NoDeclFound
= 71,
1380
CXCursor_NotImplemented
= 72,
1381
CXCursor_InvalidCode
= 73,
1382
CXCursor_LastInvalid
=
CXCursor_InvalidCode
,
1383
1384
/* Expressions */
1385
CXCursor_FirstExpr
= 100,
1386
1387
/**
1388
* An expression whose specific kind is not exposed via this
1389
* interface.
1390
*
1391
* Unexposed expressions have the same operations as any other kind
1392
* of expression; one can extract their location information,
1393
* spelling, children, etc. However, the specific kind of the
1394
* expression is not reported.
1395
*/
1396
CXCursor_UnexposedExpr
= 100,
1397
1398
/**
1399
* An expression that refers to some value declaration, such
1400
* as a function, variable, or enumerator.
1401
*/
1402
CXCursor_DeclRefExpr
= 101,
1403
1404
/**
1405
* An expression that refers to a member of a struct, union,
1406
* class, Objective-C class, etc.
1407
*/
1408
CXCursor_MemberRefExpr
= 102,
1409
1410
/** An expression that calls a function. */
1411
CXCursor_CallExpr
= 103,
1412
1413
/** An expression that sends a message to an Objective-C
1414
object or class. */
1415
CXCursor_ObjCMessageExpr
= 104,
1416
1417
/** An expression that represents a block literal. */
1418
CXCursor_BlockExpr
= 105,
1419
1420
/** An integer literal.
1421
*/
1422
CXCursor_IntegerLiteral
= 106,
1423
1424
/** A floating point number literal.
1425
*/
1426
CXCursor_FloatingLiteral
= 107,
1427
1428
/** An imaginary number literal.
1429
*/
1430
CXCursor_ImaginaryLiteral
= 108,
1431
1432
/** A string literal.
1433
*/
1434
CXCursor_StringLiteral
= 109,
1435
1436
/** A character literal.
1437
*/
1438
CXCursor_CharacterLiteral
= 110,
1439
1440
/** A parenthesized expression, e.g. "(1)".
1441
*
1442
* This AST node is only formed if full location information is requested.
1443
*/
1444
CXCursor_ParenExpr
= 111,
1445
1446
/** This represents the unary-expression's (except sizeof and
1447
* alignof).
1448
*/
1449
CXCursor_UnaryOperator
= 112,
1450
1451
/** [C99 6.5.2.1] Array Subscripting.
1452
*/
1453
CXCursor_ArraySubscriptExpr
= 113,
1454
1455
/** A builtin binary operation expression such as "x + y" or
1456
* "x <= y".
1457
*/
1458
CXCursor_BinaryOperator
= 114,
1459
1460
/** Compound assignment such as "+=".
1461
*/
1462
CXCursor_CompoundAssignOperator
= 115,
1463
1464
/** The ?: ternary operator.
1465
*/
1466
CXCursor_ConditionalOperator
= 116,
1467
1468
/** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1469
* (C++ [expr.cast]), which uses the syntax (Type)expr.
1470
*
1471
* For example: (int)f.
1472
*/
1473
CXCursor_CStyleCastExpr
= 117,
1474
1475
/** [C99 6.5.2.5]
1476
*/
1477
CXCursor_CompoundLiteralExpr
= 118,
1478
1479
/** Describes an C or C++ initializer list.
1480
*/
1481
CXCursor_InitListExpr
= 119,
1482
1483
/** The GNU address of label extension, representing &&label.
1484
*/
1485
CXCursor_AddrLabelExpr
= 120,
1486
1487
/** This is the GNU Statement Expression extension: ({int X=4; X;})
1488
*/
1489
CXCursor_StmtExpr
= 121,
1490
1491
/** Represents a C11 generic selection.
1492
*/
1493
CXCursor_GenericSelectionExpr
= 122,
1494
1495
/** Implements the GNU __null extension, which is a name for a null
1496
* pointer constant that has integral type (e.g., int or long) and is the same
1497
* size and alignment as a pointer.
1498
*
1499
* The __null extension is typically only used by system headers, which define
1500
* NULL as __null in C++ rather than using 0 (which is an integer that may not
1501
* match the size of a pointer).
1502
*/
1503
CXCursor_GNUNullExpr
= 123,
1504
1505
/** C++'s static_cast<> expression.
1506
*/
1507
CXCursor_CXXStaticCastExpr
= 124,
1508
1509
/** C++'s dynamic_cast<> expression.
1510
*/
1511
CXCursor_CXXDynamicCastExpr
= 125,
1512
1513
/** C++'s reinterpret_cast<> expression.
1514
*/
1515
CXCursor_CXXReinterpretCastExpr
= 126,
1516
1517
/** C++'s const_cast<> expression.
1518
*/
1519
CXCursor_CXXConstCastExpr
= 127,
1520
1521
/** Represents an explicit C++ type conversion that uses "functional"
1522
* notion (C++ [expr.type.conv]).
1523
*
1524
* Example:
1525
* \code
1526
* x = int(0.5);
1527
* \endcode
1528
*/
1529
CXCursor_CXXFunctionalCastExpr
= 128,
1530
1531
/** A C++ typeid expression (C++ [expr.typeid]).
1532
*/
1533
CXCursor_CXXTypeidExpr
= 129,
1534
1535
/** [C++ 2.13.5] C++ Boolean Literal.
1536
*/
1537
CXCursor_CXXBoolLiteralExpr
= 130,
1538
1539
/** [C++0x 2.14.7] C++ Pointer Literal.
1540
*/
1541
CXCursor_CXXNullPtrLiteralExpr
= 131,
1542
1543
/** Represents the "this" expression in C++
1544
*/
1545
CXCursor_CXXThisExpr
= 132,
1546
1547
/** [C++ 15] C++ Throw Expression.
1548
*
1549
* This handles 'throw' and 'throw' assignment-expression. When
1550
* assignment-expression isn't present, Op will be null.
1551
*/
1552
CXCursor_CXXThrowExpr
= 133,
1553
1554
/** A new expression for memory allocation and constructor calls, e.g:
1555
* "new CXXNewExpr(foo)".
1556
*/
1557
CXCursor_CXXNewExpr
= 134,
1558
1559
/** A delete expression for memory deallocation and destructor calls,
1560
* e.g. "delete[] pArray".
1561
*/
1562
CXCursor_CXXDeleteExpr
= 135,
1563
1564
/** A unary expression. (noexcept, sizeof, or other traits)
1565
*/
1566
CXCursor_UnaryExpr
= 136,
1567
1568
/** An Objective-C string literal i.e. @"foo".
1569
*/
1570
CXCursor_ObjCStringLiteral
= 137,
1571
1572
/** An Objective-C \@encode expression.
1573
*/
1574
CXCursor_ObjCEncodeExpr
= 138,
1575
1576
/** An Objective-C \@selector expression.
1577
*/
1578
CXCursor_ObjCSelectorExpr
= 139,
1579
1580
/** An Objective-C \@protocol expression.
1581
*/
1582
CXCursor_ObjCProtocolExpr
= 140,
1583
1584
/** An Objective-C "bridged" cast expression, which casts between
1585
* Objective-C pointers and C pointers, transferring ownership in the process.
1586
*
1587
* \code
1588
* NSString *str = (__bridge_transfer NSString *)CFCreateString();
1589
* \endcode
1590
*/
1591
CXCursor_ObjCBridgedCastExpr
= 141,
1592
1593
/** Represents a C++0x pack expansion that produces a sequence of
1594
* expressions.
1595
*
1596
* A pack expansion expression contains a pattern (which itself is an
1597
* expression) followed by an ellipsis. For example:
1598
*
1599
* \code
1600
* template<typename F, typename ...Types>
1601
* void forward(F f, Types &&...args) {
1602
* f(static_cast<Types&&>(args)...);
1603
* }
1604
* \endcode
1605
*/
1606
CXCursor_PackExpansionExpr
= 142,
1607
1608
/** Represents an expression that computes the length of a parameter
1609
* pack.
1610
*
1611
* \code
1612
* template<typename ...Types>
1613
* struct count {
1614
* static const unsigned value = sizeof...(Types);
1615
* };
1616
* \endcode
1617
*/
1618
CXCursor_SizeOfPackExpr
= 143,
1619
1620
/* Represents a C++ lambda expression that produces a local function
1621
* object.
1622
*
1623
* \code
1624
* void abssort(float *x, unsigned N) {
1625
* std::sort(x, x + N,
1626
* [](float a, float b) {
1627
* return std::abs(a) < std::abs(b);
1628
* });
1629
* }
1630
* \endcode
1631
*/
1632
CXCursor_LambdaExpr
= 144,
1633
1634
/** Objective-c Boolean Literal.
1635
*/
1636
CXCursor_ObjCBoolLiteralExpr
= 145,
1637
1638
/** Represents the "self" expression in an Objective-C method.
1639
*/
1640
CXCursor_ObjCSelfExpr
= 146,
1641
1642
/** OpenMP 5.0 [2.1.5, Array Section].
1643
*/
1644
CXCursor_OMPArraySectionExpr
= 147,
1645
1646
/** Represents an @available(...) check.
1647
*/
1648
CXCursor_ObjCAvailabilityCheckExpr
= 148,
1649
1650
/**
1651
* Fixed point literal
1652
*/
1653
CXCursor_FixedPointLiteral
= 149,
1654
1655
/** OpenMP 5.0 [2.1.4, Array Shaping].
1656
*/
1657
CXCursor_OMPArrayShapingExpr
= 150,
1658
1659
/**
1660
* OpenMP 5.0 [2.1.6 Iterators]
1661
*/
1662
CXCursor_OMPIteratorExpr
= 151,
1663
1664
/** OpenCL's addrspace_cast<> expression.
1665
*/
1666
CXCursor_CXXAddrspaceCastExpr
= 152,
1667
1668
/**
1669
* Expression that references a C++20 concept.
1670
*/
1671
CXCursor_ConceptSpecializationExpr
= 153,
1672
1673
/**
1674
* Expression that references a C++20 concept.
1675
*/
1676
CXCursor_RequiresExpr
= 154,
1677
1678
/**
1679
* Expression that references a C++20 parenthesized list aggregate
1680
* initializer.
1681
*/
1682
CXCursor_CXXParenListInitExpr
= 155,
1683
1684
CXCursor_LastExpr
=
CXCursor_CXXParenListInitExpr
,
1685
1686
/* Statements */
1687
CXCursor_FirstStmt
= 200,
1688
/**
1689
* A statement whose specific kind is not exposed via this
1690
* interface.
1691
*
1692
* Unexposed statements have the same operations as any other kind of
1693
* statement; one can extract their location information, spelling,
1694
* children, etc. However, the specific kind of the statement is not
1695
* reported.
1696
*/
1697
CXCursor_UnexposedStmt
= 200,
1698
1699
/** A labelled statement in a function.
1700
*
1701
* This cursor kind is used to describe the "start_over:" label statement in
1702
* the following example:
1703
*
1704
* \code
1705
* start_over:
1706
* ++counter;
1707
* \endcode
1708
*
1709
*/
1710
CXCursor_LabelStmt
= 201,
1711
1712
/** A group of statements like { stmt stmt }.
1713
*
1714
* This cursor kind is used to describe compound statements, e.g. function
1715
* bodies.
1716
*/
1717
CXCursor_CompoundStmt
= 202,
1718
1719
/** A case statement.
1720
*/
1721
CXCursor_CaseStmt
= 203,
1722
1723
/** A default statement.
1724
*/
1725
CXCursor_DefaultStmt
= 204,
1726
1727
/** An if statement
1728
*/
1729
CXCursor_IfStmt
= 205,
1730
1731
/** A switch statement.
1732
*/
1733
CXCursor_SwitchStmt
= 206,
1734
1735
/** A while statement.
1736
*/
1737
CXCursor_WhileStmt
= 207,
1738
1739
/** A do statement.
1740
*/
1741
CXCursor_DoStmt
= 208,
1742
1743
/** A for statement.
1744
*/
1745
CXCursor_ForStmt
= 209,
1746
1747
/** A goto statement.
1748
*/
1749
CXCursor_GotoStmt
= 210,
1750
1751
/** An indirect goto statement.
1752
*/
1753
CXCursor_IndirectGotoStmt
= 211,
1754
1755
/** A continue statement.
1756
*/
1757
CXCursor_ContinueStmt
= 212,
1758
1759
/** A break statement.
1760
*/
1761
CXCursor_BreakStmt
= 213,
1762
1763
/** A return statement.
1764
*/
1765
CXCursor_ReturnStmt
= 214,
1766
1767
/** A GCC inline assembly statement extension.
1768
*/
1769
CXCursor_GCCAsmStmt
= 215,
1770
CXCursor_AsmStmt
=
CXCursor_GCCAsmStmt
,
1771
1772
/** Objective-C's overall \@try-\@catch-\@finally statement.
1773
*/
1774
CXCursor_ObjCAtTryStmt
= 216,
1775
1776
/** Objective-C's \@catch statement.
1777
*/
1778
CXCursor_ObjCAtCatchStmt
= 217,
1779
1780
/** Objective-C's \@finally statement.
1781
*/
1782
CXCursor_ObjCAtFinallyStmt
= 218,
1783
1784
/** Objective-C's \@throw statement.
1785
*/
1786
CXCursor_ObjCAtThrowStmt
= 219,
1787
1788
/** Objective-C's \@synchronized statement.
1789
*/
1790
CXCursor_ObjCAtSynchronizedStmt
= 220,
1791
1792
/** Objective-C's autorelease pool statement.
1793
*/
1794
CXCursor_ObjCAutoreleasePoolStmt
= 221,
1795
1796
/** Objective-C's collection statement.
1797
*/
1798
CXCursor_ObjCForCollectionStmt
= 222,
1799
1800
/** C++'s catch statement.
1801
*/
1802
CXCursor_CXXCatchStmt
= 223,
1803
1804
/** C++'s try statement.
1805
*/
1806
CXCursor_CXXTryStmt
= 224,
1807
1808
/** C++'s for (* : *) statement.
1809
*/
1810
CXCursor_CXXForRangeStmt
= 225,
1811
1812
/** Windows Structured Exception Handling's try statement.
1813
*/
1814
CXCursor_SEHTryStmt
= 226,
1815
1816
/** Windows Structured Exception Handling's except statement.
1817
*/
1818
CXCursor_SEHExceptStmt
= 227,
1819
1820
/** Windows Structured Exception Handling's finally statement.
1821
*/
1822
CXCursor_SEHFinallyStmt
= 228,
1823
1824
/** A MS inline assembly statement extension.
1825
*/
1826
CXCursor_MSAsmStmt
= 229,
1827
1828
/** The null statement ";": C99 6.8.3p3.
1829
*
1830
* This cursor kind is used to describe the null statement.
1831
*/
1832
CXCursor_NullStmt
= 230,
1833
1834
/** Adaptor class for mixing declarations with statements and
1835
* expressions.
1836
*/
1837
CXCursor_DeclStmt
= 231,
1838
1839
/** OpenMP parallel directive.
1840
*/
1841
CXCursor_OMPParallelDirective
= 232,
1842
1843
/** OpenMP SIMD directive.
1844
*/
1845
CXCursor_OMPSimdDirective
= 233,
1846
1847
/** OpenMP for directive.
1848
*/
1849
CXCursor_OMPForDirective
= 234,
1850
1851
/** OpenMP sections directive.
1852
*/
1853
CXCursor_OMPSectionsDirective
= 235,
1854
1855
/** OpenMP section directive.
1856
*/
1857
CXCursor_OMPSectionDirective
= 236,
1858
1859
/** OpenMP single directive.
1860
*/
1861
CXCursor_OMPSingleDirective
= 237,
1862
1863
/** OpenMP parallel for directive.
1864
*/
1865
CXCursor_OMPParallelForDirective
= 238,
1866
1867
/** OpenMP parallel sections directive.
1868
*/
1869
CXCursor_OMPParallelSectionsDirective
= 239,
1870
1871
/** OpenMP task directive.
1872
*/
1873
CXCursor_OMPTaskDirective
= 240,
1874
1875
/** OpenMP master directive.
1876
*/
1877
CXCursor_OMPMasterDirective
= 241,
1878
1879
/** OpenMP critical directive.
1880
*/
1881
CXCursor_OMPCriticalDirective
= 242,
1882
1883
/** OpenMP taskyield directive.
1884
*/
1885
CXCursor_OMPTaskyieldDirective
= 243,
1886
1887
/** OpenMP barrier directive.
1888
*/
1889
CXCursor_OMPBarrierDirective
= 244,
1890
1891
/** OpenMP taskwait directive.
1892
*/
1893
CXCursor_OMPTaskwaitDirective
= 245,
1894
1895
/** OpenMP flush directive.
1896
*/
1897
CXCursor_OMPFlushDirective
= 246,
1898
1899
/** Windows Structured Exception Handling's leave statement.
1900
*/
1901
CXCursor_SEHLeaveStmt
= 247,
1902
1903
/** OpenMP ordered directive.
1904
*/
1905
CXCursor_OMPOrderedDirective
= 248,
1906
1907
/** OpenMP atomic directive.
1908
*/
1909
CXCursor_OMPAtomicDirective
= 249,
1910
1911
/** OpenMP for SIMD directive.
1912
*/
1913
CXCursor_OMPForSimdDirective
= 250,
1914
1915
/** OpenMP parallel for SIMD directive.
1916
*/
1917
CXCursor_OMPParallelForSimdDirective
= 251,
1918
1919
/** OpenMP target directive.
1920
*/
1921
CXCursor_OMPTargetDirective
= 252,
1922
1923
/** OpenMP teams directive.
1924
*/
1925
CXCursor_OMPTeamsDirective
= 253,
1926
1927
/** OpenMP taskgroup directive.
1928
*/
1929
CXCursor_OMPTaskgroupDirective
= 254,
1930
1931
/** OpenMP cancellation point directive.
1932
*/
1933
CXCursor_OMPCancellationPointDirective
= 255,
1934
1935
/** OpenMP cancel directive.
1936
*/
1937
CXCursor_OMPCancelDirective
= 256,
1938
1939
/** OpenMP target data directive.
1940
*/
1941
CXCursor_OMPTargetDataDirective
= 257,
1942
1943
/** OpenMP taskloop directive.
1944
*/
1945
CXCursor_OMPTaskLoopDirective
= 258,
1946
1947
/** OpenMP taskloop simd directive.
1948
*/
1949
CXCursor_OMPTaskLoopSimdDirective
= 259,
1950
1951
/** OpenMP distribute directive.
1952
*/
1953
CXCursor_OMPDistributeDirective
= 260,
1954
1955
/** OpenMP target enter data directive.
1956
*/
1957
CXCursor_OMPTargetEnterDataDirective
= 261,
1958
1959
/** OpenMP target exit data directive.
1960
*/
1961
CXCursor_OMPTargetExitDataDirective
= 262,
1962
1963
/** OpenMP target parallel directive.
1964
*/
1965
CXCursor_OMPTargetParallelDirective
= 263,
1966
1967
/** OpenMP target parallel for directive.
1968
*/
1969
CXCursor_OMPTargetParallelForDirective
= 264,
1970
1971
/** OpenMP target update directive.
1972
*/
1973
CXCursor_OMPTargetUpdateDirective
= 265,
1974
1975
/** OpenMP distribute parallel for directive.
1976
*/
1977
CXCursor_OMPDistributeParallelForDirective
= 266,
1978
1979
/** OpenMP distribute parallel for simd directive.
1980
*/
1981
CXCursor_OMPDistributeParallelForSimdDirective
= 267,
1982
1983
/** OpenMP distribute simd directive.
1984
*/
1985
CXCursor_OMPDistributeSimdDirective
= 268,
1986
1987
/** OpenMP target parallel for simd directive.
1988
*/
1989
CXCursor_OMPTargetParallelForSimdDirective
= 269,
1990
1991
/** OpenMP target simd directive.
1992
*/
1993
CXCursor_OMPTargetSimdDirective
= 270,
1994
1995
/** OpenMP teams distribute directive.
1996
*/
1997
CXCursor_OMPTeamsDistributeDirective
= 271,
1998
1999
/** OpenMP teams distribute simd directive.
2000
*/
2001
CXCursor_OMPTeamsDistributeSimdDirective
= 272,
2002
2003
/** OpenMP teams distribute parallel for simd directive.
2004
*/
2005
CXCursor_OMPTeamsDistributeParallelForSimdDirective
= 273,
2006
2007
/** OpenMP teams distribute parallel for directive.
2008
*/
2009
CXCursor_OMPTeamsDistributeParallelForDirective
= 274,
2010
2011
/** OpenMP target teams directive.
2012
*/
2013
CXCursor_OMPTargetTeamsDirective
= 275,
2014
2015
/** OpenMP target teams distribute directive.
2016
*/
2017
CXCursor_OMPTargetTeamsDistributeDirective
= 276,
2018
2019
/** OpenMP target teams distribute parallel for directive.
2020
*/
2021
CXCursor_OMPTargetTeamsDistributeParallelForDirective
= 277,
2022
2023
/** OpenMP target teams distribute parallel for simd directive.
2024
*/
2025
CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective
= 278,
2026
2027
/** OpenMP target teams distribute simd directive.
2028
*/
2029
CXCursor_OMPTargetTeamsDistributeSimdDirective
= 279,
2030
2031
/** C++2a std::bit_cast expression.
2032
*/
2033
CXCursor_BuiltinBitCastExpr
= 280,
2034
2035
/** OpenMP master taskloop directive.
2036
*/
2037
CXCursor_OMPMasterTaskLoopDirective
= 281,
2038
2039
/** OpenMP parallel master taskloop directive.
2040
*/
2041
CXCursor_OMPParallelMasterTaskLoopDirective
= 282,
2042
2043
/** OpenMP master taskloop simd directive.
2044
*/
2045
CXCursor_OMPMasterTaskLoopSimdDirective
= 283,
2046
2047
/** OpenMP parallel master taskloop simd directive.
2048
*/
2049
CXCursor_OMPParallelMasterTaskLoopSimdDirective
= 284,
2050
2051
/** OpenMP parallel master directive.
2052
*/
2053
CXCursor_OMPParallelMasterDirective
= 285,
2054
2055
/** OpenMP depobj directive.
2056
*/
2057
CXCursor_OMPDepobjDirective
= 286,
2058
2059
/** OpenMP scan directive.
2060
*/
2061
CXCursor_OMPScanDirective
= 287,
2062
2063
/** OpenMP tile directive.
2064
*/
2065
CXCursor_OMPTileDirective
= 288,
2066
2067
/** OpenMP canonical loop.
2068
*/
2069
CXCursor_OMPCanonicalLoop
= 289,
2070
2071
/** OpenMP interop directive.
2072
*/
2073
CXCursor_OMPInteropDirective
= 290,
2074
2075
/** OpenMP dispatch directive.
2076
*/
2077
CXCursor_OMPDispatchDirective
= 291,
2078
2079
/** OpenMP masked directive.
2080
*/
2081
CXCursor_OMPMaskedDirective
= 292,
2082
2083
/** OpenMP unroll directive.
2084
*/
2085
CXCursor_OMPUnrollDirective
= 293,
2086
2087
/** OpenMP metadirective directive.
2088
*/
2089
CXCursor_OMPMetaDirective
= 294,
2090
2091
/** OpenMP loop directive.
2092
*/
2093
CXCursor_OMPGenericLoopDirective
= 295,
2094
2095
/** OpenMP teams loop directive.
2096
*/
2097
CXCursor_OMPTeamsGenericLoopDirective
= 296,
2098
2099
/** OpenMP target teams loop directive.
2100
*/
2101
CXCursor_OMPTargetTeamsGenericLoopDirective
= 297,
2102
2103
/** OpenMP parallel loop directive.
2104
*/
2105
CXCursor_OMPParallelGenericLoopDirective
= 298,
2106
2107
/** OpenMP target parallel loop directive.
2108
*/
2109
CXCursor_OMPTargetParallelGenericLoopDirective
= 299,
2110
2111
/** OpenMP parallel masked directive.
2112
*/
2113
CXCursor_OMPParallelMaskedDirective
= 300,
2114
2115
/** OpenMP masked taskloop directive.
2116
*/
2117
CXCursor_OMPMaskedTaskLoopDirective
= 301,
2118
2119
/** OpenMP masked taskloop simd directive.
2120
*/
2121
CXCursor_OMPMaskedTaskLoopSimdDirective
= 302,
2122
2123
/** OpenMP parallel masked taskloop directive.
2124
*/
2125
CXCursor_OMPParallelMaskedTaskLoopDirective
= 303,
2126
2127
/** OpenMP parallel masked taskloop simd directive.
2128
*/
2129
CXCursor_OMPParallelMaskedTaskLoopSimdDirective
= 304,
2130
2131
/** OpenMP error directive.
2132
*/
2133
CXCursor_OMPErrorDirective
= 305,
2134
2135
CXCursor_LastStmt
=
CXCursor_OMPErrorDirective
,
2136
2137
/**
2138
* Cursor that represents the translation unit itself.
2139
*
2140
* The translation unit cursor exists primarily to act as the root
2141
* cursor for traversing the contents of a translation unit.
2142
*/
2143
CXCursor_TranslationUnit
= 350,
2144
2145
/* Attributes */
2146
CXCursor_FirstAttr
= 400,
2147
/**
2148
* An attribute whose specific kind is not exposed via this
2149
* interface.
2150
*/
2151
CXCursor_UnexposedAttr
= 400,
2152
2153
CXCursor_IBActionAttr
= 401,
2154
CXCursor_IBOutletAttr
= 402,
2155
CXCursor_IBOutletCollectionAttr
= 403,
2156
CXCursor_CXXFinalAttr
= 404,
2157
CXCursor_CXXOverrideAttr
= 405,
2158
CXCursor_AnnotateAttr
= 406,
2159
CXCursor_AsmLabelAttr
= 407,
2160
CXCursor_PackedAttr
= 408,
2161
CXCursor_PureAttr
= 409,
2162
CXCursor_ConstAttr
= 410,
2163
CXCursor_NoDuplicateAttr
= 411,
2164
CXCursor_CUDAConstantAttr
= 412,
2165
CXCursor_CUDADeviceAttr
= 413,
2166
CXCursor_CUDAGlobalAttr
= 414,
2167
CXCursor_CUDAHostAttr
= 415,
2168
CXCursor_CUDASharedAttr
= 416,
2169
CXCursor_VisibilityAttr
= 417,
2170
CXCursor_DLLExport
= 418,
2171
CXCursor_DLLImport
= 419,
2172
CXCursor_NSReturnsRetained
= 420,
2173
CXCursor_NSReturnsNotRetained
= 421,
2174
CXCursor_NSReturnsAutoreleased
= 422,
2175
CXCursor_NSConsumesSelf
= 423,
2176
CXCursor_NSConsumed
= 424,
2177
CXCursor_ObjCException
= 425,
2178
CXCursor_ObjCNSObject
= 426,
2179
CXCursor_ObjCIndependentClass
= 427,
2180
CXCursor_ObjCPreciseLifetime
= 428,
2181
CXCursor_ObjCReturnsInnerPointer
= 429,
2182
CXCursor_ObjCRequiresSuper
= 430,
2183
CXCursor_ObjCRootClass
= 431,
2184
CXCursor_ObjCSubclassingRestricted
= 432,
2185
CXCursor_ObjCExplicitProtocolImpl
= 433,
2186
CXCursor_ObjCDesignatedInitializer
= 434,
2187
CXCursor_ObjCRuntimeVisible
= 435,
2188
CXCursor_ObjCBoxable
= 436,
2189
CXCursor_FlagEnum
= 437,
2190
CXCursor_ConvergentAttr
= 438,
2191
CXCursor_WarnUnusedAttr
= 439,
2192
CXCursor_WarnUnusedResultAttr
= 440,
2193
CXCursor_AlignedAttr
= 441,
2194
CXCursor_LastAttr
=
CXCursor_AlignedAttr
,
2195
2196
/* Preprocessing */
2197
CXCursor_PreprocessingDirective
= 500,
2198
CXCursor_MacroDefinition
= 501,
2199
CXCursor_MacroExpansion
= 502,
2200
CXCursor_MacroInstantiation
=
CXCursor_MacroExpansion
,
2201
CXCursor_InclusionDirective
= 503,
2202
CXCursor_FirstPreprocessing
=
CXCursor_PreprocessingDirective
,
2203
CXCursor_LastPreprocessing
=
CXCursor_InclusionDirective
,
2204
2205
/* Extra Declarations */
2206
/**
2207
* A module import declaration.
2208
*/
2209
CXCursor_ModuleImportDecl
= 600,
2210
CXCursor_TypeAliasTemplateDecl
= 601,
2211
/**
2212
* A static_assert or _Static_assert node
2213
*/
2214
CXCursor_StaticAssert
= 602,
2215
/**
2216
* a friend declaration.
2217
*/
2218
CXCursor_FriendDecl
= 603,
2219
/**
2220
* a concept declaration.
2221
*/
2222
CXCursor_ConceptDecl
= 604,
2223
2224
CXCursor_FirstExtraDecl
=
CXCursor_ModuleImportDecl
,
2225
CXCursor_LastExtraDecl
=
CXCursor_ConceptDecl
,
2226
2227
/**
2228
* A code completion overload candidate.
2229
*/
2230
CXCursor_OverloadCandidate
= 700
2231
};
2232
2233
/**
2234
* A cursor representing some element in the abstract syntax tree for
2235
* a translation unit.
2236
*
2237
* The cursor abstraction unifies the different kinds of entities in a
2238
* program--declaration, statements, expressions, references to declarations,
2239
* etc.--under a single "cursor" abstraction with a common set of operations.
2240
* Common operation for a cursor include: getting the physical location in
2241
* a source file where the cursor points, getting the name associated with a
2242
* cursor, and retrieving cursors for any child nodes of a particular cursor.
2243
*
2244
* Cursors can be produced in two specific ways.
2245
* clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2246
* from which one can use clang_visitChildren() to explore the rest of the
2247
* translation unit. clang_getCursor() maps from a physical source location
2248
* to the entity that resides at that location, allowing one to map from the
2249
* source code into the AST.
2250
*/
2251
typedef
struct
{
2252
enum
CXCursorKind
kind
;
2253
int
xdata
;
2254
const
void
*data[3];
2255
}
CXCursor
;
2256
2257
/**
2258
* \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2259
*
2260
* @{
2261
*/
2262
2263
/**
2264
* Retrieve the NULL cursor, which represents no entity.
2265
*/
2266
CINDEX_LINKAGE
CXCursor
clang_getNullCursor
(
void
);
2267
2268
/**
2269
* Retrieve the cursor that represents the given translation unit.
2270
*
2271
* The translation unit cursor can be used to start traversing the
2272
* various declarations within the given translation unit.
2273
*/
2274
CINDEX_LINKAGE
CXCursor
clang_getTranslationUnitCursor
(
CXTranslationUnit
);
2275
2276
/**
2277
* Determine whether two cursors are equivalent.
2278
*/
2279
CINDEX_LINKAGE
unsigned
clang_equalCursors
(
CXCursor
,
CXCursor
);
2280
2281
/**
2282
* Returns non-zero if \p cursor is null.
2283
*/
2284
CINDEX_LINKAGE
int
clang_Cursor_isNull
(
CXCursor
cursor);
2285
2286
/**
2287
* Compute a hash value for the given cursor.
2288
*/
2289
CINDEX_LINKAGE
unsigned
clang_hashCursor
(
CXCursor
);
2290
2291
/**
2292
* Retrieve the kind of the given cursor.
2293
*/
2294
CINDEX_LINKAGE
enum
CXCursorKind
clang_getCursorKind
(
CXCursor
);
2295
2296
/**
2297
* Determine whether the given cursor kind represents a declaration.
2298
*/
2299
CINDEX_LINKAGE
unsigned
clang_isDeclaration
(
enum
CXCursorKind
);
2300
2301
/**
2302
* Determine whether the given declaration is invalid.
2303
*
2304
* A declaration is invalid if it could not be parsed successfully.
2305
*
2306
* \returns non-zero if the cursor represents a declaration and it is
2307
* invalid, otherwise NULL.
2308
*/
2309
CINDEX_LINKAGE
unsigned
clang_isInvalidDeclaration
(
CXCursor
);
2310
2311
/**
2312
* Determine whether the given cursor kind represents a simple
2313
* reference.
2314
*
2315
* Note that other kinds of cursors (such as expressions) can also refer to
2316
* other cursors. Use clang_getCursorReferenced() to determine whether a
2317
* particular cursor refers to another entity.
2318
*/
2319
CINDEX_LINKAGE
unsigned
clang_isReference
(
enum
CXCursorKind
);
2320
2321
/**
2322
* Determine whether the given cursor kind represents an expression.
2323
*/
2324
CINDEX_LINKAGE
unsigned
clang_isExpression
(
enum
CXCursorKind
);
2325
2326
/**
2327
* Determine whether the given cursor kind represents a statement.
2328
*/
2329
CINDEX_LINKAGE
unsigned
clang_isStatement
(
enum
CXCursorKind
);
2330
2331
/**
2332
* Determine whether the given cursor kind represents an attribute.
2333
*/
2334
CINDEX_LINKAGE
unsigned
clang_isAttribute
(
enum
CXCursorKind
);
2335
2336
/**
2337
* Determine whether the given cursor has any attributes.
2338
*/
2339
CINDEX_LINKAGE
unsigned
clang_Cursor_hasAttrs
(
CXCursor
C);
2340
2341
/**
2342
* Determine whether the given cursor kind represents an invalid
2343
* cursor.
2344
*/
2345
CINDEX_LINKAGE
unsigned
clang_isInvalid
(
enum
CXCursorKind
);
2346
2347
/**
2348
* Determine whether the given cursor kind represents a translation
2349
* unit.
2350
*/
2351
CINDEX_LINKAGE
unsigned
clang_isTranslationUnit
(
enum
CXCursorKind
);
2352
2353
/***
2354
* Determine whether the given cursor represents a preprocessing
2355
* element, such as a preprocessor directive or macro instantiation.
2356
*/
2357
CINDEX_LINKAGE
unsigned
clang_isPreprocessing
(
enum
CXCursorKind
);
2358
2359
/***
2360
* Determine whether the given cursor represents a currently
2361
* unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2362
*/
2363
CINDEX_LINKAGE
unsigned
clang_isUnexposed
(
enum
CXCursorKind
);
2364
2365
/**
2366
* Describe the linkage of the entity referred to by a cursor.
2367
*/
2368
enum
CXLinkageKind
{
2369
/** This value indicates that no linkage information is available
2370
* for a provided CXCursor. */
2371
CXLinkage_Invalid
,
2372
/**
2373
* This is the linkage for variables, parameters, and so on that
2374
* have automatic storage. This covers normal (non-extern) local variables.
2375
*/
2376
CXLinkage_NoLinkage
,
2377
/** This is the linkage for static variables and static functions. */
2378
CXLinkage_Internal
,
2379
/** This is the linkage for entities with external linkage that live
2380
* in C++ anonymous namespaces.*/
2381
CXLinkage_UniqueExternal
,
2382
/** This is the linkage for entities with true, external linkage. */
2383
CXLinkage_External
2384
};
2385
2386
/**
2387
* Determine the linkage of the entity referred to by a given cursor.
2388
*/
2389
CINDEX_LINKAGE
enum
CXLinkageKind
clang_getCursorLinkage
(
CXCursor
cursor);
2390
2391
enum
CXVisibilityKind
{
2392
/** This value indicates that no visibility information is available
2393
* for a provided CXCursor. */
2394
CXVisibility_Invalid
,
2395
2396
/** Symbol not seen by the linker. */
2397
CXVisibility_Hidden
,
2398
/** Symbol seen by the linker but resolves to a symbol inside this object. */
2399
CXVisibility_Protected
,
2400
/** Symbol seen by the linker and acts like a normal symbol. */
2401
CXVisibility_Default
2402
};
2403
2404
/**
2405
* Describe the visibility of the entity referred to by a cursor.
2406
*
2407
* This returns the default visibility if not explicitly specified by
2408
* a visibility attribute. The default visibility may be changed by
2409
* commandline arguments.
2410
*
2411
* \param cursor The cursor to query.
2412
*
2413
* \returns The visibility of the cursor.
2414
*/
2415
CINDEX_LINKAGE
enum
CXVisibilityKind
clang_getCursorVisibility
(
CXCursor
cursor);
2416
2417
/**
2418
* Determine the availability of the entity that this cursor refers to,
2419
* taking the current target platform into account.
2420
*
2421
* \param cursor The cursor to query.
2422
*
2423
* \returns The availability of the cursor.
2424
*/
2425
CINDEX_LINKAGE
enum
CXAvailabilityKind
2426
clang_getCursorAvailability
(
CXCursor
cursor);
2427
2428
/**
2429
* Describes the availability of a given entity on a particular platform, e.g.,
2430
* a particular class might only be available on Mac OS 10.7 or newer.
2431
*/
2432
typedef
struct
CXPlatformAvailability
{
2433
/**
2434
* A string that describes the platform for which this structure
2435
* provides availability information.
2436
*
2437
* Possible values are "ios" or "macos".
2438
*/
2439
CXString
Platform
;
2440
/**
2441
* The version number in which this entity was introduced.
2442
*/
2443
CXVersion
Introduced
;
2444
/**
2445
* The version number in which this entity was deprecated (but is
2446
* still available).
2447
*/
2448
CXVersion
Deprecated
;
2449
/**
2450
* The version number in which this entity was obsoleted, and therefore
2451
* is no longer available.
2452
*/
2453
CXVersion
Obsoleted
;
2454
/**
2455
* Whether the entity is unconditionally unavailable on this platform.
2456
*/
2457
int
Unavailable
;
2458
/**
2459
* An optional message to provide to a user of this API, e.g., to
2460
* suggest replacement APIs.
2461
*/
2462
CXString
Message
;
2463
}
CXPlatformAvailability
;
2464
2465
/**
2466
* Determine the availability of the entity that this cursor refers to
2467
* on any platforms for which availability information is known.
2468
*
2469
* \param cursor The cursor to query.
2470
*
2471
* \param always_deprecated If non-NULL, will be set to indicate whether the
2472
* entity is deprecated on all platforms.
2473
*
2474
* \param deprecated_message If non-NULL, will be set to the message text
2475
* provided along with the unconditional deprecation of this entity. The client
2476
* is responsible for deallocating this string.
2477
*
2478
* \param always_unavailable If non-NULL, will be set to indicate whether the
2479
* entity is unavailable on all platforms.
2480
*
2481
* \param unavailable_message If non-NULL, will be set to the message text
2482
* provided along with the unconditional unavailability of this entity. The
2483
* client is responsible for deallocating this string.
2484
*
2485
* \param availability If non-NULL, an array of CXPlatformAvailability instances
2486
* that will be populated with platform availability information, up to either
2487
* the number of platforms for which availability information is available (as
2488
* returned by this function) or \c availability_size, whichever is smaller.
2489
*
2490
* \param availability_size The number of elements available in the
2491
* \c availability array.
2492
*
2493
* \returns The number of platforms (N) for which availability information is
2494
* available (which is unrelated to \c availability_size).
2495
*
2496
* Note that the client is responsible for calling
2497
* \c clang_disposeCXPlatformAvailability to free each of the
2498
* platform-availability structures returned. There are
2499
* \c min(N, availability_size) such structures.
2500
*/
2501
CINDEX_LINKAGE
int
clang_getCursorPlatformAvailability
(
2502
CXCursor
cursor,
int
*always_deprecated,
CXString
*deprecated_message,
2503
int
*always_unavailable,
CXString
*unavailable_message,
2504
CXPlatformAvailability
*availability,
int
availability_size);
2505
2506
/**
2507
* Free the memory associated with a \c CXPlatformAvailability structure.
2508
*/
2509
CINDEX_LINKAGE
void
2510
clang_disposeCXPlatformAvailability
(
CXPlatformAvailability
*availability);
2511
2512
/**
2513
* If cursor refers to a variable declaration and it has initializer returns
2514
* cursor referring to the initializer otherwise return null cursor.
2515
*/
2516
CINDEX_LINKAGE
CXCursor
clang_Cursor_getVarDeclInitializer
(
CXCursor
cursor);
2517
2518
/**
2519
* If cursor refers to a variable declaration that has global storage returns 1.
2520
* If cursor refers to a variable declaration that doesn't have global storage
2521
* returns 0. Otherwise returns -1.
2522
*/
2523
CINDEX_LINKAGE
int
clang_Cursor_hasVarDeclGlobalStorage
(
CXCursor
cursor);
2524
2525
/**
2526
* If cursor refers to a variable declaration that has external storage
2527
* returns 1. If cursor refers to a variable declaration that doesn't have
2528
* external storage returns 0. Otherwise returns -1.
2529
*/
2530
CINDEX_LINKAGE
int
clang_Cursor_hasVarDeclExternalStorage
(
CXCursor
cursor);
2531
2532
/**
2533
* Describe the "language" of the entity referred to by a cursor.
2534
*/
2535
enum
CXLanguageKind
{
2536
CXLanguage_Invalid
= 0,
2537
CXLanguage_C
,
2538
CXLanguage_ObjC
,
2539
CXLanguage_CPlusPlus
2540
};
2541
2542
/**
2543
* Determine the "language" of the entity referred to by a given cursor.
2544
*/
2545
CINDEX_LINKAGE
enum
CXLanguageKind
clang_getCursorLanguage
(
CXCursor
cursor);
2546
2547
/**
2548
* Describe the "thread-local storage (TLS) kind" of the declaration
2549
* referred to by a cursor.
2550
*/
2551
enum
CXTLSKind
{
CXTLS_None
= 0,
CXTLS_Dynamic
,
CXTLS_Static
};
2552
2553
/**
2554
* Determine the "thread-local storage (TLS) kind" of the declaration
2555
* referred to by a cursor.
2556
*/
2557
CINDEX_LINKAGE
enum
CXTLSKind
clang_getCursorTLSKind
(
CXCursor
cursor);
2558
2559
/**
2560
* Returns the translation unit that a cursor originated from.
2561
*/
2562
CINDEX_LINKAGE
CXTranslationUnit
clang_Cursor_getTranslationUnit
(
CXCursor
);
2563
2564
/**
2565
* A fast container representing a set of CXCursors.
2566
*/
2567
typedef
struct
CXCursorSetImpl *
CXCursorSet
;
2568
2569
/**
2570
* Creates an empty CXCursorSet.
2571
*/
2572
CINDEX_LINKAGE
CXCursorSet
clang_createCXCursorSet
(
void
);
2573
2574
/**
2575
* Disposes a CXCursorSet and releases its associated memory.
2576
*/
2577
CINDEX_LINKAGE
void
clang_disposeCXCursorSet
(
CXCursorSet
cset);
2578
2579
/**
2580
* Queries a CXCursorSet to see if it contains a specific CXCursor.
2581
*
2582
* \returns non-zero if the set contains the specified cursor.
2583
*/
2584
CINDEX_LINKAGE
unsigned
clang_CXCursorSet_contains
(
CXCursorSet
cset,
2585
CXCursor
cursor);
2586
2587
/**
2588
* Inserts a CXCursor into a CXCursorSet.
2589
*
2590
* \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2591
*/
2592
CINDEX_LINKAGE
unsigned
clang_CXCursorSet_insert
(
CXCursorSet
cset,
2593
CXCursor
cursor);
2594
2595
/**
2596
* Determine the semantic parent of the given cursor.
2597
*
2598
* The semantic parent of a cursor is the cursor that semantically contains
2599
* the given \p cursor. For many declarations, the lexical and semantic parents
2600
* are equivalent (the lexical parent is returned by
2601
* \c clang_getCursorLexicalParent()). They diverge when declarations or
2602
* definitions are provided out-of-line. For example:
2603
*
2604
* \code
2605
* class C {
2606
* void f();
2607
* };
2608
*
2609
* void C::f() { }
2610
* \endcode
2611
*
2612
* In the out-of-line definition of \c C::f, the semantic parent is
2613
* the class \c C, of which this function is a member. The lexical parent is
2614
* the place where the declaration actually occurs in the source code; in this
2615
* case, the definition occurs in the translation unit. In general, the
2616
* lexical parent for a given entity can change without affecting the semantics
2617
* of the program, and the lexical parent of different declarations of the
2618
* same entity may be different. Changing the semantic parent of a declaration,
2619
* on the other hand, can have a major impact on semantics, and redeclarations
2620
* of a particular entity should all have the same semantic context.
2621
*
2622
* In the example above, both declarations of \c C::f have \c C as their
2623
* semantic context, while the lexical context of the first \c C::f is \c C
2624
* and the lexical context of the second \c C::f is the translation unit.
2625
*
2626
* For global declarations, the semantic parent is the translation unit.
2627
*/
2628
CINDEX_LINKAGE
CXCursor
clang_getCursorSemanticParent
(
CXCursor
cursor);
2629
2630
/**
2631
* Determine the lexical parent of the given cursor.
2632
*
2633
* The lexical parent of a cursor is the cursor in which the given \p cursor
2634
* was actually written. For many declarations, the lexical and semantic parents
2635
* are equivalent (the semantic parent is returned by
2636
* \c clang_getCursorSemanticParent()). They diverge when declarations or
2637
* definitions are provided out-of-line. For example:
2638
*
2639
* \code
2640
* class C {
2641
* void f();
2642
* };
2643
*
2644
* void C::f() { }
2645
* \endcode
2646
*
2647
* In the out-of-line definition of \c C::f, the semantic parent is
2648
* the class \c C, of which this function is a member. The lexical parent is
2649
* the place where the declaration actually occurs in the source code; in this
2650
* case, the definition occurs in the translation unit. In general, the
2651
* lexical parent for a given entity can change without affecting the semantics
2652
* of the program, and the lexical parent of different declarations of the
2653
* same entity may be different. Changing the semantic parent of a declaration,
2654
* on the other hand, can have a major impact on semantics, and redeclarations
2655
* of a particular entity should all have the same semantic context.
2656
*
2657
* In the example above, both declarations of \c C::f have \c C as their
2658
* semantic context, while the lexical context of the first \c C::f is \c C
2659
* and the lexical context of the second \c C::f is the translation unit.
2660
*
2661
* For declarations written in the global scope, the lexical parent is
2662
* the translation unit.
2663
*/
2664
CINDEX_LINKAGE
CXCursor
clang_getCursorLexicalParent
(
CXCursor
cursor);
2665
2666
/**
2667
* Determine the set of methods that are overridden by the given
2668
* method.
2669
*
2670
* In both Objective-C and C++, a method (aka virtual member function,
2671
* in C++) can override a virtual method in a base class. For
2672
* Objective-C, a method is said to override any method in the class's
2673
* base class, its protocols, or its categories' protocols, that has the same
2674
* selector and is of the same kind (class or instance).
2675
* If no such method exists, the search continues to the class's superclass,
2676
* its protocols, and its categories, and so on. A method from an Objective-C
2677
* implementation is considered to override the same methods as its
2678
* corresponding method in the interface.
2679
*
2680
* For C++, a virtual member function overrides any virtual member
2681
* function with the same signature that occurs in its base
2682
* classes. With multiple inheritance, a virtual member function can
2683
* override several virtual member functions coming from different
2684
* base classes.
2685
*
2686
* In all cases, this function determines the immediate overridden
2687
* method, rather than all of the overridden methods. For example, if
2688
* a method is originally declared in a class A, then overridden in B
2689
* (which in inherits from A) and also in C (which inherited from B),
2690
* then the only overridden method returned from this function when
2691
* invoked on C's method will be B's method. The client may then
2692
* invoke this function again, given the previously-found overridden
2693
* methods, to map out the complete method-override set.
2694
*
2695
* \param cursor A cursor representing an Objective-C or C++
2696
* method. This routine will compute the set of methods that this
2697
* method overrides.
2698
*
2699
* \param overridden A pointer whose pointee will be replaced with a
2700
* pointer to an array of cursors, representing the set of overridden
2701
* methods. If there are no overridden methods, the pointee will be
2702
* set to NULL. The pointee must be freed via a call to
2703
* \c clang_disposeOverriddenCursors().
2704
*
2705
* \param num_overridden A pointer to the number of overridden
2706
* functions, will be set to the number of overridden functions in the
2707
* array pointed to by \p overridden.
2708
*/
2709
CINDEX_LINKAGE
void
clang_getOverriddenCursors
(
CXCursor
cursor,
2710
CXCursor
**overridden,
2711
unsigned
*num_overridden);
2712
2713
/**
2714
* Free the set of overridden cursors returned by \c
2715
* clang_getOverriddenCursors().
2716
*/
2717
CINDEX_LINKAGE
void
clang_disposeOverriddenCursors
(
CXCursor
*overridden);
2718
2719
/**
2720
* Retrieve the file that is included by the given inclusion directive
2721
* cursor.
2722
*/
2723
CINDEX_LINKAGE
CXFile
clang_getIncludedFile
(
CXCursor
cursor);
2724
2725
/**
2726
* @}
2727
*/
2728
2729
/**
2730
* \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
2731
*
2732
* Cursors represent a location within the Abstract Syntax Tree (AST). These
2733
* routines help map between cursors and the physical locations where the
2734
* described entities occur in the source code. The mapping is provided in
2735
* both directions, so one can map from source code to the AST and back.
2736
*
2737
* @{
2738
*/
2739
2740
/**
2741
* Map a source location to the cursor that describes the entity at that
2742
* location in the source code.
2743
*
2744
* clang_getCursor() maps an arbitrary source location within a translation
2745
* unit down to the most specific cursor that describes the entity at that
2746
* location. For example, given an expression \c x + y, invoking
2747
* clang_getCursor() with a source location pointing to "x" will return the
2748
* cursor for "x"; similarly for "y". If the cursor points anywhere between
2749
* "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
2750
* will return a cursor referring to the "+" expression.
2751
*
2752
* \returns a cursor representing the entity at the given source location, or
2753
* a NULL cursor if no such entity can be found.
2754
*/
2755
CINDEX_LINKAGE
CXCursor
clang_getCursor
(
CXTranslationUnit
,
CXSourceLocation
);
2756
2757
/**
2758
* Retrieve the physical location of the source constructor referenced
2759
* by the given cursor.
2760
*
2761
* The location of a declaration is typically the location of the name of that
2762
* declaration, where the name of that declaration would occur if it is
2763
* unnamed, or some keyword that introduces that particular declaration.
2764
* The location of a reference is where that reference occurs within the
2765
* source code.
2766
*/
2767
CINDEX_LINKAGE
CXSourceLocation
clang_getCursorLocation
(
CXCursor
);
2768
2769
/**
2770
* Retrieve the physical extent of the source construct referenced by
2771
* the given cursor.
2772
*
2773
* The extent of a cursor starts with the file/line/column pointing at the
2774
* first character within the source construct that the cursor refers to and
2775
* ends with the last character within that source construct. For a
2776
* declaration, the extent covers the declaration itself. For a reference,
2777
* the extent covers the location of the reference (e.g., where the referenced
2778
* entity was actually used).
2779
*/
2780
CINDEX_LINKAGE
CXSourceRange
clang_getCursorExtent
(
CXCursor
);
2781
2782
/**
2783
* @}
2784
*/
2785
2786
/**
2787
* \defgroup CINDEX_TYPES Type information for CXCursors
2788
*
2789
* @{
2790
*/
2791
2792
/**
2793
* Describes the kind of type
2794
*/
2795
enum
CXTypeKind
{
2796
/**
2797
* Represents an invalid type (e.g., where no type is available).
2798
*/
2799
CXType_Invalid
= 0,
2800
2801
/**
2802
* A type whose specific kind is not exposed via this
2803
* interface.
2804
*/
2805
CXType_Unexposed
= 1,
2806
2807
/* Builtin types */
2808
CXType_Void
= 2,
2809
CXType_Bool
= 3,
2810
CXType_Char_U
= 4,
2811
CXType_UChar
= 5,
2812
CXType_Char16
= 6,
2813
CXType_Char32
= 7,
2814
CXType_UShort
= 8,
2815
CXType_UInt
= 9,
2816
CXType_ULong
= 10,
2817
CXType_ULongLong
= 11,
2818
CXType_UInt128
= 12,
2819
CXType_Char_S
= 13,
2820
CXType_SChar
= 14,
2821
CXType_WChar
= 15,
2822
CXType_Short
= 16,
2823
CXType_Int
= 17,
2824
CXType_Long
= 18,
2825
CXType_LongLong
= 19,
2826
CXType_Int128
= 20,
2827
CXType_Float
= 21,
2828
CXType_Double
= 22,
2829
CXType_LongDouble
= 23,
2830
CXType_NullPtr
= 24,
2831
CXType_Overload
= 25,
2832
CXType_Dependent
= 26,
2833
CXType_ObjCId
= 27,
2834
CXType_ObjCClass
= 28,
2835
CXType_ObjCSel
= 29,
2836
CXType_Float128
= 30,
2837
CXType_Half
= 31,
2838
CXType_Float16
= 32,
2839
CXType_ShortAccum
= 33,
2840
CXType_Accum
= 34,
2841
CXType_LongAccum
= 35,
2842
CXType_UShortAccum
= 36,
2843
CXType_UAccum
= 37,
2844
CXType_ULongAccum
= 38,
2845
CXType_BFloat16
= 39,
2846
CXType_Ibm128
= 40,
2847
CXType_FirstBuiltin
=
CXType_Void
,
2848
CXType_LastBuiltin
=
CXType_Ibm128
,
2849
2850
CXType_Complex
= 100,
2851
CXType_Pointer
= 101,
2852
CXType_BlockPointer
= 102,
2853
CXType_LValueReference
= 103,
2854
CXType_RValueReference
= 104,
2855
CXType_Record
= 105,
2856
CXType_Enum
= 106,
2857
CXType_Typedef
= 107,
2858
CXType_ObjCInterface
= 108,
2859
CXType_ObjCObjectPointer
= 109,
2860
CXType_FunctionNoProto
= 110,
2861
CXType_FunctionProto
= 111,
2862
CXType_ConstantArray
= 112,
2863
CXType_Vector
= 113,
2864
CXType_IncompleteArray
= 114,
2865
CXType_VariableArray
= 115,
2866
CXType_DependentSizedArray
= 116,
2867
CXType_MemberPointer
= 117,
2868
CXType_Auto
= 118,
2869
2870
/**
2871
* Represents a type that was referred to using an elaborated type keyword.
2872
*
2873
* E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
2874
*/
2875
CXType_Elaborated
= 119,
2876
2877
/* OpenCL PipeType. */
2878
CXType_Pipe
= 120,
2879
2880
/* OpenCL builtin types. */
2881
CXType_OCLImage1dRO
= 121,
2882
CXType_OCLImage1dArrayRO
= 122,
2883
CXType_OCLImage1dBufferRO
= 123,
2884
CXType_OCLImage2dRO
= 124,
2885
CXType_OCLImage2dArrayRO
= 125,
2886
CXType_OCLImage2dDepthRO
= 126,
2887
CXType_OCLImage2dArrayDepthRO
= 127,
2888
CXType_OCLImage2dMSAARO
= 128,
2889
CXType_OCLImage2dArrayMSAARO
= 129,
2890
CXType_OCLImage2dMSAADepthRO
= 130,
2891
CXType_OCLImage2dArrayMSAADepthRO
= 131,
2892
CXType_OCLImage3dRO
= 132,
2893
CXType_OCLImage1dWO
= 133,
2894
CXType_OCLImage1dArrayWO
= 134,
2895
CXType_OCLImage1dBufferWO
= 135,
2896
CXType_OCLImage2dWO
= 136,
2897
CXType_OCLImage2dArrayWO
= 137,
2898
CXType_OCLImage2dDepthWO
= 138,
2899
CXType_OCLImage2dArrayDepthWO
= 139,
2900
CXType_OCLImage2dMSAAWO
= 140,
2901
CXType_OCLImage2dArrayMSAAWO
= 141,
2902
CXType_OCLImage2dMSAADepthWO
= 142,
2903
CXType_OCLImage2dArrayMSAADepthWO
= 143,
2904
CXType_OCLImage3dWO
= 144,
2905
CXType_OCLImage1dRW
= 145,
2906
CXType_OCLImage1dArrayRW
= 146,
2907
CXType_OCLImage1dBufferRW
= 147,
2908
CXType_OCLImage2dRW
= 148,
2909
CXType_OCLImage2dArrayRW
= 149,
2910
CXType_OCLImage2dDepthRW
= 150,
2911
CXType_OCLImage2dArrayDepthRW
= 151,
2912
CXType_OCLImage2dMSAARW
= 152,
2913
CXType_OCLImage2dArrayMSAARW
= 153,
2914
CXType_OCLImage2dMSAADepthRW
= 154,
2915
CXType_OCLImage2dArrayMSAADepthRW
= 155,
2916
CXType_OCLImage3dRW
= 156,
2917
CXType_OCLSampler
= 157,
2918
CXType_OCLEvent
= 158,
2919
CXType_OCLQueue
= 159,
2920
CXType_OCLReserveID
= 160,
2921
2922
CXType_ObjCObject
= 161,
2923
CXType_ObjCTypeParam
= 162,
2924
CXType_Attributed
= 163,
2925
2926
CXType_OCLIntelSubgroupAVCMcePayload
= 164,
2927
CXType_OCLIntelSubgroupAVCImePayload
= 165,
2928
CXType_OCLIntelSubgroupAVCRefPayload
= 166,
2929
CXType_OCLIntelSubgroupAVCSicPayload
= 167,
2930
CXType_OCLIntelSubgroupAVCMceResult
= 168,
2931
CXType_OCLIntelSubgroupAVCImeResult
= 169,
2932
CXType_OCLIntelSubgroupAVCRefResult
= 170,
2933
CXType_OCLIntelSubgroupAVCSicResult
= 171,
2934
CXType_OCLIntelSubgroupAVCImeResultSingleReferenceStreamout
= 172,
2935
CXType_OCLIntelSubgroupAVCImeResultDualReferenceStreamout
= 173,
2936
CXType_OCLIntelSubgroupAVCImeSingleReferenceStreamin
= 174,
2937
CXType_OCLIntelSubgroupAVCImeDualReferenceStreamin
= 175,
2938
2939
/* Old aliases for AVC OpenCL extension types. */
2940
CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout
= 172,
2941
CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout
= 173,
2942
CXType_OCLIntelSubgroupAVCImeSingleRefStreamin
= 174,
2943
CXType_OCLIntelSubgroupAVCImeDualRefStreamin
= 175,
2944
2945
CXType_ExtVector
= 176,
2946
CXType_Atomic
= 177,
2947
CXType_BTFTagAttributed
= 178
2948
};
2949
2950
/**
2951
* Describes the calling convention of a function type
2952
*/
2953
enum
CXCallingConv
{
2954
CXCallingConv_Default
= 0,
2955
CXCallingConv_C
= 1,
2956
CXCallingConv_X86StdCall
= 2,
2957
CXCallingConv_X86FastCall
= 3,
2958
CXCallingConv_X86ThisCall
= 4,
2959
CXCallingConv_X86Pascal
= 5,
2960
CXCallingConv_AAPCS
= 6,
2961
CXCallingConv_AAPCS_VFP
= 7,
2962
CXCallingConv_X86RegCall
= 8,
2963
CXCallingConv_IntelOclBicc
= 9,
2964
CXCallingConv_Win64
= 10,
2965
/* Alias for compatibility with older versions of API. */
2966
CXCallingConv_X86_64Win64
=
CXCallingConv_Win64
,
2967
CXCallingConv_X86_64SysV
= 11,
2968
CXCallingConv_X86VectorCall
= 12,
2969
CXCallingConv_Swift
= 13,
2970
CXCallingConv_PreserveMost
= 14,
2971
CXCallingConv_PreserveAll
= 15,
2972
CXCallingConv_AArch64VectorCall
= 16,
2973
CXCallingConv_SwiftAsync
= 17,
2974
CXCallingConv_AArch64SVEPCS
= 18,
2975
2976
CXCallingConv_Invalid
= 100,
2977
CXCallingConv_Unexposed
= 200
2978
};
2979
2980
/**
2981
* The type of an element in the abstract syntax tree.
2982
*
2983
*/
2984
typedef
struct
{
2985
enum
CXTypeKind
kind
;
2986
void
*data[2];
2987
}
CXType
;
2988
2989
/**
2990
* Retrieve the type of a CXCursor (if any).
2991
*/
2992
CINDEX_LINKAGE
CXType
clang_getCursorType
(
CXCursor
C);
2993
2994
/**
2995
* Pretty-print the underlying type using the rules of the
2996
* language of the translation unit from which it came.
2997
*
2998
* If the type is invalid, an empty string is returned.
2999
*/
3000
CINDEX_LINKAGE
CXString
clang_getTypeSpelling
(
CXType
CT);
3001
3002
/**
3003
* Retrieve the underlying type of a typedef declaration.
3004
*
3005
* If the cursor does not reference a typedef declaration, an invalid type is
3006
* returned.
3007
*/
3008
CINDEX_LINKAGE
CXType
clang_getTypedefDeclUnderlyingType
(
CXCursor
C);
3009
3010
/**
3011
* Retrieve the integer type of an enum declaration.
3012
*
3013
* If the cursor does not reference an enum declaration, an invalid type is
3014
* returned.
3015
*/
3016
CINDEX_LINKAGE
CXType
clang_getEnumDeclIntegerType
(
CXCursor
C);
3017
3018
/**
3019
* Retrieve the integer value of an enum constant declaration as a signed
3020
* long long.
3021
*
3022
* If the cursor does not reference an enum constant declaration, LLONG_MIN is
3023
* returned. Since this is also potentially a valid constant value, the kind of
3024
* the cursor must be verified before calling this function.
3025
*/
3026
CINDEX_LINKAGE
long
long
clang_getEnumConstantDeclValue
(
CXCursor
C);
3027
3028
/**
3029
* Retrieve the integer value of an enum constant declaration as an unsigned
3030
* long long.
3031
*
3032
* If the cursor does not reference an enum constant declaration, ULLONG_MAX is
3033
* returned. Since this is also potentially a valid constant value, the kind of
3034
* the cursor must be verified before calling this function.
3035
*/
3036
CINDEX_LINKAGE
unsigned
long
long
3037
clang_getEnumConstantDeclUnsignedValue
(
CXCursor
C);
3038
3039
/**
3040
* Returns non-zero if the cursor specifies a Record member that is a bit-field.
3041
*/
3042
CINDEX_LINKAGE
unsigned
clang_Cursor_isBitField
(
CXCursor
C);
3043
3044
/**
3045
* Retrieve the bit width of a bit-field declaration as an integer.
3046
*
3047
* If the cursor does not reference a bit-field, or if the bit-field's width
3048
* expression cannot be evaluated, -1 is returned.
3049
*
3050
* For example:
3051
* \code
3052
* if (clang_Cursor_isBitField(Cursor)) {
3053
* int Width = clang_getFieldDeclBitWidth(Cursor);
3054
* if (Width != -1) {
3055
* // The bit-field width is not value-dependent.
3056
* }
3057
* }
3058
* \endcode
3059
*/
3060
CINDEX_LINKAGE
int
clang_getFieldDeclBitWidth
(
CXCursor
C);
3061
3062
/**
3063
* Retrieve the number of non-variadic arguments associated with a given
3064
* cursor.
3065
*
3066
* The number of arguments can be determined for calls as well as for
3067
* declarations of functions or methods. For other cursors -1 is returned.
3068
*/
3069
CINDEX_LINKAGE
int
clang_Cursor_getNumArguments
(
CXCursor
C);
3070
3071
/**
3072
* Retrieve the argument cursor of a function or method.
3073
*
3074
* The argument cursor can be determined for calls as well as for declarations
3075
* of functions or methods. For other cursors and for invalid indices, an
3076
* invalid cursor is returned.
3077
*/
3078
CINDEX_LINKAGE
CXCursor
clang_Cursor_getArgument
(
CXCursor
C,
unsigned
i);
3079
3080
/**
3081
* Describes the kind of a template argument.
3082
*
3083
* See the definition of llvm::clang::TemplateArgument::ArgKind for full
3084
* element descriptions.
3085
*/
3086
enum
CXTemplateArgumentKind
{
3087
CXTemplateArgumentKind_Null
,
3088
CXTemplateArgumentKind_Type
,
3089
CXTemplateArgumentKind_Declaration
,
3090
CXTemplateArgumentKind_NullPtr
,
3091
CXTemplateArgumentKind_Integral
,
3092
CXTemplateArgumentKind_Template
,
3093
CXTemplateArgumentKind_TemplateExpansion
,
3094
CXTemplateArgumentKind_Expression
,
3095
CXTemplateArgumentKind_Pack
,
3096
/* Indicates an error case, preventing the kind from being deduced. */
3097
CXTemplateArgumentKind_Invalid
3098
};
3099
3100
/**
3101
* Returns the number of template args of a function, struct, or class decl
3102
* representing a template specialization.
3103
*
3104
* If the argument cursor cannot be converted into a template function
3105
* declaration, -1 is returned.
3106
*
3107
* For example, for the following declaration and specialization:
3108
* template <typename T, int kInt, bool kBool>
3109
* void foo() { ... }
3110
*
3111
* template <>
3112
* void foo<float, -7, true>();
3113
*
3114
* The value 3 would be returned from this call.
3115
*/
3116
CINDEX_LINKAGE
int
clang_Cursor_getNumTemplateArguments
(
CXCursor
C);
3117
3118
/**
3119
* Retrieve the kind of the I'th template argument of the CXCursor C.
3120
*
3121
* If the argument CXCursor does not represent a FunctionDecl, StructDecl, or
3122
* ClassTemplatePartialSpecialization, an invalid template argument kind is
3123
* returned.
3124
*
3125
* For example, for the following declaration and specialization:
3126
* template <typename T, int kInt, bool kBool>
3127
* void foo() { ... }
3128
*
3129
* template <>
3130
* void foo<float, -7, true>();
3131
*
3132
* For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3133
* respectively.
3134
*/
3135
CINDEX_LINKAGE
enum
CXTemplateArgumentKind
3136
clang_Cursor_getTemplateArgumentKind
(
CXCursor
C,
unsigned
I);
3137
3138
/**
3139
* Retrieve a CXType representing the type of a TemplateArgument of a
3140
* function decl representing a template specialization.
3141
*
3142
* If the argument CXCursor does not represent a FunctionDecl, StructDecl,
3143
* ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument
3144
* has a kind of CXTemplateArgKind_Integral, an invalid type is returned.
3145
*
3146
* For example, for the following declaration and specialization:
3147
* template <typename T, int kInt, bool kBool>
3148
* void foo() { ... }
3149
*
3150
* template <>
3151
* void foo<float, -7, true>();
3152
*
3153
* If called with I = 0, "float", will be returned.
3154
* Invalid types will be returned for I == 1 or 2.
3155
*/
3156
CINDEX_LINKAGE
CXType
clang_Cursor_getTemplateArgumentType
(
CXCursor
C,
3157
unsigned
I);
3158
3159
/**
3160
* Retrieve the value of an Integral TemplateArgument (of a function
3161
* decl representing a template specialization) as a signed long long.
3162
*
3163
* It is undefined to call this function on a CXCursor that does not represent a
3164
* FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization
3165
* whose I'th template argument is not an integral value.
3166
*
3167
* For example, for the following declaration and specialization:
3168
* template <typename T, int kInt, bool kBool>
3169
* void foo() { ... }
3170
*
3171
* template <>
3172
* void foo<float, -7, true>();
3173
*
3174
* If called with I = 1 or 2, -7 or true will be returned, respectively.
3175
* For I == 0, this function's behavior is undefined.
3176
*/
3177
CINDEX_LINKAGE
long
long
clang_Cursor_getTemplateArgumentValue
(
CXCursor
C,
3178
unsigned
I);
3179
3180
/**
3181
* Retrieve the value of an Integral TemplateArgument (of a function
3182
* decl representing a template specialization) as an unsigned long long.
3183
*
3184
* It is undefined to call this function on a CXCursor that does not represent a
3185
* FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or
3186
* whose I'th template argument is not an integral value.
3187
*
3188
* For example, for the following declaration and specialization:
3189
* template <typename T, int kInt, bool kBool>
3190
* void foo() { ... }
3191
*
3192
* template <>
3193
* void foo<float, 2147483649, true>();
3194
*
3195
* If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3196
* For I == 0, this function's behavior is undefined.
3197
*/
3198
CINDEX_LINKAGE
unsigned
long
long
3199
clang_Cursor_getTemplateArgumentUnsignedValue
(
CXCursor
C,
unsigned
I);
3200
3201
/**
3202
* Determine whether two CXTypes represent the same type.
3203
*
3204
* \returns non-zero if the CXTypes represent the same type and
3205
* zero otherwise.
3206
*/
3207
CINDEX_LINKAGE
unsigned
clang_equalTypes
(
CXType
A,
CXType
B);
3208
3209
/**
3210
* Return the canonical type for a CXType.
3211
*
3212
* Clang's type system explicitly models typedefs and all the ways
3213
* a specific type can be represented. The canonical type is the underlying
3214
* type with all the "sugar" removed. For example, if 'T' is a typedef
3215
* for 'int', the canonical type for 'T' would be 'int'.
3216
*/
3217
CINDEX_LINKAGE
CXType
clang_getCanonicalType
(
CXType
T);
3218
3219
/**
3220
* Determine whether a CXType has the "const" qualifier set,
3221
* without looking through typedefs that may have added "const" at a
3222
* different level.
3223
*/
3224
CINDEX_LINKAGE
unsigned
clang_isConstQualifiedType
(
CXType
T);
3225
3226
/**
3227
* Determine whether a CXCursor that is a macro, is
3228
* function like.
3229
*/
3230
CINDEX_LINKAGE
unsigned
clang_Cursor_isMacroFunctionLike
(
CXCursor
C);
3231
3232
/**
3233
* Determine whether a CXCursor that is a macro, is a
3234
* builtin one.
3235
*/
3236
CINDEX_LINKAGE
unsigned
clang_Cursor_isMacroBuiltin
(
CXCursor
C);
3237
3238
/**
3239
* Determine whether a CXCursor that is a function declaration, is an
3240
* inline declaration.
3241
*/
3242
CINDEX_LINKAGE
unsigned
clang_Cursor_isFunctionInlined
(
CXCursor
C);
3243
3244
/**
3245
* Determine whether a CXType has the "volatile" qualifier set,
3246
* without looking through typedefs that may have added "volatile" at
3247
* a different level.
3248
*/
3249
CINDEX_LINKAGE
unsigned
clang_isVolatileQualifiedType
(
CXType
T);
3250
3251
/**
3252
* Determine whether a CXType has the "restrict" qualifier set,
3253
* without looking through typedefs that may have added "restrict" at a
3254
* different level.
3255
*/
3256
CINDEX_LINKAGE
unsigned
clang_isRestrictQualifiedType
(
CXType
T);
3257
3258
/**
3259
* Returns the address space of the given type.
3260
*/
3261
CINDEX_LINKAGE
unsigned
clang_getAddressSpace
(
CXType
T);
3262
3263
/**
3264
* Returns the typedef name of the given type.
3265
*/
3266
CINDEX_LINKAGE
CXString
clang_getTypedefName
(
CXType
CT);
3267
3268
/**
3269
* For pointer types, returns the type of the pointee.
3270
*/
3271
CINDEX_LINKAGE
CXType
clang_getPointeeType
(
CXType
T);
3272
3273
/**
3274
* Retrieve the unqualified variant of the given type, removing as
3275
* little sugar as possible.
3276
*
3277
* For example, given the following series of typedefs:
3278
*
3279
* \code
3280
* typedef int Integer;
3281
* typedef const Integer CInteger;
3282
* typedef CInteger DifferenceType;
3283
* \endcode
3284
*
3285
* Executing \c clang_getUnqualifiedType() on a \c CXType that
3286
* represents \c DifferenceType, will desugar to a type representing
3287
* \c Integer, that has no qualifiers.
3288
*
3289
* And, executing \c clang_getUnqualifiedType() on the type of the
3290
* first argument of the following function declaration:
3291
*
3292
* \code
3293
* void foo(const int);
3294
* \endcode
3295
*
3296
* Will return a type representing \c int, removing the \c const
3297
* qualifier.
3298
*
3299
* Sugar over array types is not desugared.
3300
*
3301
* A type can be checked for qualifiers with \c
3302
* clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType()
3303
* and \c clang_isRestrictQualifiedType().
3304
*
3305
* A type that resulted from a call to \c clang_getUnqualifiedType
3306
* will return \c false for all of the above calls.
3307
*/
3308
CINDEX_LINKAGE
CXType
clang_getUnqualifiedType
(
CXType
CT);
3309
3310
/**
3311
* For reference types (e.g., "const int&"), returns the type that the
3312
* reference refers to (e.g "const int").
3313
*
3314
* Otherwise, returns the type itself.
3315
*
3316
* A type that has kind \c CXType_LValueReference or
3317
* \c CXType_RValueReference is a reference type.
3318
*/
3319
CINDEX_LINKAGE
CXType
clang_getNonReferenceType
(
CXType
CT);
3320
3321
/**
3322
* Return the cursor for the declaration of the given type.
3323
*/
3324
CINDEX_LINKAGE
CXCursor
clang_getTypeDeclaration
(
CXType
T);
3325
3326
/**
3327
* Returns the Objective-C type encoding for the specified declaration.
3328
*/
3329
CINDEX_LINKAGE
CXString
clang_getDeclObjCTypeEncoding
(
CXCursor
C);
3330
3331
/**
3332
* Returns the Objective-C type encoding for the specified CXType.
3333
*/
3334
CINDEX_LINKAGE
CXString
clang_Type_getObjCEncoding
(
CXType
type);
3335
3336
/**
3337
* Retrieve the spelling of a given CXTypeKind.
3338
*/
3339
CINDEX_LINKAGE
CXString
clang_getTypeKindSpelling
(
enum
CXTypeKind
K);
3340
3341
/**
3342
* Retrieve the calling convention associated with a function type.
3343
*
3344
* If a non-function type is passed in, CXCallingConv_Invalid is returned.
3345
*/
3346
CINDEX_LINKAGE
enum
CXCallingConv
clang_getFunctionTypeCallingConv
(
CXType
T);
3347
3348
/**
3349
* Retrieve the return type associated with a function type.
3350
*
3351
* If a non-function type is passed in, an invalid type is returned.
3352
*/
3353
CINDEX_LINKAGE
CXType
clang_getResultType
(
CXType
T);
3354
3355
/**
3356
* Retrieve the exception specification type associated with a function type.
3357
* This is a value of type CXCursor_ExceptionSpecificationKind.
3358
*
3359
* If a non-function type is passed in, an error code of -1 is returned.
3360
*/
3361
CINDEX_LINKAGE
int
clang_getExceptionSpecificationType
(
CXType
T);
3362
3363
/**
3364
* Retrieve the number of non-variadic parameters associated with a
3365
* function type.
3366
*
3367
* If a non-function type is passed in, -1 is returned.
3368
*/
3369
CINDEX_LINKAGE
int
clang_getNumArgTypes
(
CXType
T);
3370
3371
/**
3372
* Retrieve the type of a parameter of a function type.
3373
*
3374
* If a non-function type is passed in or the function does not have enough
3375
* parameters, an invalid type is returned.
3376
*/
3377
CINDEX_LINKAGE
CXType
clang_getArgType
(
CXType
T,
unsigned
i);
3378
3379
/**
3380
* Retrieves the base type of the ObjCObjectType.
3381
*
3382
* If the type is not an ObjC object, an invalid type is returned.
3383
*/
3384
CINDEX_LINKAGE
CXType
clang_Type_getObjCObjectBaseType
(
CXType
T);
3385
3386
/**
3387
* Retrieve the number of protocol references associated with an ObjC object/id.
3388
*
3389
* If the type is not an ObjC object, 0 is returned.
3390
*/
3391
CINDEX_LINKAGE
unsigned
clang_Type_getNumObjCProtocolRefs
(
CXType
T);
3392
3393
/**
3394
* Retrieve the decl for a protocol reference for an ObjC object/id.
3395
*
3396
* If the type is not an ObjC object or there are not enough protocol
3397
* references, an invalid cursor is returned.
3398
*/
3399
CINDEX_LINKAGE
CXCursor
clang_Type_getObjCProtocolDecl
(
CXType
T,
unsigned
i);
3400
3401
/**
3402
* Retrieve the number of type arguments associated with an ObjC object.
3403
*
3404
* If the type is not an ObjC object, 0 is returned.
3405
*/
3406
CINDEX_LINKAGE
unsigned
clang_Type_getNumObjCTypeArgs
(
CXType
T);
3407
3408
/**
3409
* Retrieve a type argument associated with an ObjC object.
3410
*
3411
* If the type is not an ObjC or the index is not valid,
3412
* an invalid type is returned.
3413
*/
3414
CINDEX_LINKAGE
CXType
clang_Type_getObjCTypeArg
(
CXType
T,
unsigned
i);
3415
3416
/**
3417
* Return 1 if the CXType is a variadic function type, and 0 otherwise.
3418
*/
3419
CINDEX_LINKAGE
unsigned
clang_isFunctionTypeVariadic
(
CXType
T);
3420
3421
/**
3422
* Retrieve the return type associated with a given cursor.
3423
*
3424
* This only returns a valid type if the cursor refers to a function or method.
3425
*/
3426
CINDEX_LINKAGE
CXType
clang_getCursorResultType
(
CXCursor
C);
3427
3428
/**
3429
* Retrieve the exception specification type associated with a given cursor.
3430
* This is a value of type CXCursor_ExceptionSpecificationKind.
3431
*
3432
* This only returns a valid result if the cursor refers to a function or
3433
* method.
3434
*/
3435
CINDEX_LINKAGE
int
clang_getCursorExceptionSpecificationType
(
CXCursor
C);
3436
3437
/**
3438
* Return 1 if the CXType is a POD (plain old data) type, and 0
3439
* otherwise.
3440
*/
3441
CINDEX_LINKAGE
unsigned
clang_isPODType
(
CXType
T);
3442
3443
/**
3444
* Return the element type of an array, complex, or vector type.
3445
*
3446
* If a type is passed in that is not an array, complex, or vector type,
3447
* an invalid type is returned.
3448
*/
3449
CINDEX_LINKAGE
CXType
clang_getElementType
(
CXType
T);
3450
3451
/**
3452
* Return the number of elements of an array or vector type.
3453
*
3454
* If a type is passed in that is not an array or vector type,
3455
* -1 is returned.
3456
*/
3457
CINDEX_LINKAGE
long
long
clang_getNumElements
(
CXType
T);
3458
3459
/**
3460
* Return the element type of an array type.
3461
*
3462
* If a non-array type is passed in, an invalid type is returned.
3463
*/
3464
CINDEX_LINKAGE
CXType
clang_getArrayElementType
(
CXType
T);
3465
3466
/**
3467
* Return the array size of a constant array.
3468
*
3469
* If a non-array type is passed in, -1 is returned.
3470
*/
3471
CINDEX_LINKAGE
long
long
clang_getArraySize
(
CXType
T);
3472
3473
/**
3474
* Retrieve the type named by the qualified-id.
3475
*
3476
* If a non-elaborated type is passed in, an invalid type is returned.
3477
*/
3478
CINDEX_LINKAGE
CXType
clang_Type_getNamedType
(
CXType
T);
3479
3480
/**
3481
* Determine if a typedef is 'transparent' tag.
3482
*
3483
* A typedef is considered 'transparent' if it shares a name and spelling
3484
* location with its underlying tag type, as is the case with the NS_ENUM macro.
3485
*
3486
* \returns non-zero if transparent and zero otherwise.
3487
*/
3488
CINDEX_LINKAGE
unsigned
clang_Type_isTransparentTagTypedef
(
CXType
T);
3489
3490
enum
CXTypeNullabilityKind
{
3491
/**
3492
* Values of this type can never be null.
3493
*/
3494
CXTypeNullability_NonNull
= 0,
3495
/**
3496
* Values of this type can be null.
3497
*/
3498
CXTypeNullability_Nullable
= 1,
3499
/**
3500
* Whether values of this type can be null is (explicitly)
3501
* unspecified. This captures a (fairly rare) case where we
3502
* can't conclude anything about the nullability of the type even
3503
* though it has been considered.
3504
*/
3505
CXTypeNullability_Unspecified
= 2,
3506
/**
3507
* Nullability is not applicable to this type.
3508
*/
3509
CXTypeNullability_Invalid
= 3,
3510
3511
/**
3512
* Generally behaves like Nullable, except when used in a block parameter that
3513
* was imported into a swift async method. There, swift will assume that the
3514
* parameter can get null even if no error occurred. _Nullable parameters are
3515
* assumed to only get null on error.
3516
*/
3517
CXTypeNullability_NullableResult
= 4
3518
};
3519
3520
/**
3521
* Retrieve the nullability kind of a pointer type.
3522
*/
3523
CINDEX_LINKAGE
enum
CXTypeNullabilityKind
clang_Type_getNullability
(
CXType
T);
3524
3525
/**
3526
* List the possible error codes for \c clang_Type_getSizeOf,
3527
* \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3528
* \c clang_Cursor_getOffsetOf.
3529
*
3530
* A value of this enumeration type can be returned if the target type is not
3531
* a valid argument to sizeof, alignof or offsetof.
3532
*/
3533
enum
CXTypeLayoutError
{
3534
/**
3535
* Type is of kind CXType_Invalid.
3536
*/
3537
CXTypeLayoutError_Invalid
= -1,
3538
/**
3539
* The type is an incomplete Type.
3540
*/
3541
CXTypeLayoutError_Incomplete
= -2,
3542
/**
3543
* The type is a dependent Type.
3544
*/
3545
CXTypeLayoutError_Dependent
= -3,
3546
/**
3547
* The type is not a constant size type.
3548
*/
3549
CXTypeLayoutError_NotConstantSize
= -4,
3550
/**
3551
* The Field name is not valid for this record.
3552
*/
3553
CXTypeLayoutError_InvalidFieldName
= -5,
3554
/**
3555
* The type is undeduced.
3556
*/
3557
CXTypeLayoutError_Undeduced
= -6
3558
};
3559
3560
/**
3561
* Return the alignment of a type in bytes as per C++[expr.alignof]
3562
* standard.
3563
*
3564
* If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3565
* If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3566
* is returned.
3567
* If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3568
* returned.
3569
* If the type declaration is not a constant size type,
3570
* CXTypeLayoutError_NotConstantSize is returned.
3571
*/
3572
CINDEX_LINKAGE
long
long
clang_Type_getAlignOf
(
CXType
T);
3573
3574
/**
3575
* Return the class type of an member pointer type.
3576
*
3577
* If a non-member-pointer type is passed in, an invalid type is returned.
3578
*/
3579
CINDEX_LINKAGE
CXType
clang_Type_getClassType
(
CXType
T);
3580
3581
/**
3582
* Return the size of a type in bytes as per C++[expr.sizeof] standard.
3583
*
3584
* If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3585
* If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3586
* is returned.
3587
* If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3588
* returned.
3589
*/
3590
CINDEX_LINKAGE
long
long
clang_Type_getSizeOf
(
CXType
T);
3591
3592
/**
3593
* Return the offset of a field named S in a record of type T in bits
3594
* as it would be returned by __offsetof__ as per C++11[18.2p4]
3595
*
3596
* If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3597
* is returned.
3598
* If the field's type declaration is an incomplete type,
3599
* CXTypeLayoutError_Incomplete is returned.
3600
* If the field's type declaration is a dependent type,
3601
* CXTypeLayoutError_Dependent is returned.
3602
* If the field's name S is not found,
3603
* CXTypeLayoutError_InvalidFieldName is returned.
3604
*/
3605
CINDEX_LINKAGE
long
long
clang_Type_getOffsetOf
(
CXType
T,
const
char
*S);
3606
3607
/**
3608
* Return the type that was modified by this attributed type.
3609
*
3610
* If the type is not an attributed type, an invalid type is returned.
3611
*/
3612
CINDEX_LINKAGE
CXType
clang_Type_getModifiedType
(
CXType
T);
3613
3614
/**
3615
* Gets the type contained by this atomic type.
3616
*
3617
* If a non-atomic type is passed in, an invalid type is returned.
3618
*/
3619
CINDEX_LINKAGE
CXType
clang_Type_getValueType
(
CXType
CT);
3620
3621
/**
3622
* Return the offset of the field represented by the Cursor.
3623
*
3624
* If the cursor is not a field declaration, -1 is returned.
3625
* If the cursor semantic parent is not a record field declaration,
3626
* CXTypeLayoutError_Invalid is returned.
3627
* If the field's type declaration is an incomplete type,
3628
* CXTypeLayoutError_Incomplete is returned.
3629
* If the field's type declaration is a dependent type,
3630
* CXTypeLayoutError_Dependent is returned.
3631
* If the field's name S is not found,
3632
* CXTypeLayoutError_InvalidFieldName is returned.
3633
*/
3634
CINDEX_LINKAGE
long
long
clang_Cursor_getOffsetOfField
(
CXCursor
C);
3635
3636
/**
3637
* Determine whether the given cursor represents an anonymous
3638
* tag or namespace
3639
*/
3640
CINDEX_LINKAGE
unsigned
clang_Cursor_isAnonymous
(
CXCursor
C);
3641
3642
/**
3643
* Determine whether the given cursor represents an anonymous record
3644
* declaration.
3645
*/
3646
CINDEX_LINKAGE
unsigned
clang_Cursor_isAnonymousRecordDecl
(
CXCursor
C);
3647
3648
/**
3649
* Determine whether the given cursor represents an inline namespace
3650
* declaration.
3651
*/
3652
CINDEX_LINKAGE
unsigned
clang_Cursor_isInlineNamespace
(
CXCursor
C);
3653
3654
enum
CXRefQualifierKind
{
3655
/** No ref-qualifier was provided. */
3656
CXRefQualifier_None
= 0,
3657
/** An lvalue ref-qualifier was provided (\c &). */
3658
CXRefQualifier_LValue
,
3659
/** An rvalue ref-qualifier was provided (\c &&). */
3660
CXRefQualifier_RValue
3661
};
3662
3663
/**
3664
* Returns the number of template arguments for given template
3665
* specialization, or -1 if type \c T is not a template specialization.
3666
*/
3667
CINDEX_LINKAGE
int
clang_Type_getNumTemplateArguments
(
CXType
T);
3668
3669
/**
3670
* Returns the type template argument of a template class specialization
3671
* at given index.
3672
*
3673
* This function only returns template type arguments and does not handle
3674
* template template arguments or variadic packs.
3675
*/
3676
CINDEX_LINKAGE
CXType
clang_Type_getTemplateArgumentAsType
(
CXType
T,
3677
unsigned
i);
3678
3679
/**
3680
* Retrieve the ref-qualifier kind of a function or method.
3681
*
3682
* The ref-qualifier is returned for C++ functions or methods. For other types
3683
* or non-C++ declarations, CXRefQualifier_None is returned.
3684
*/
3685
CINDEX_LINKAGE
enum
CXRefQualifierKind
clang_Type_getCXXRefQualifier
(
CXType
T);
3686
3687
/**
3688
* Returns 1 if the base class specified by the cursor with kind
3689
* CX_CXXBaseSpecifier is virtual.
3690
*/
3691
CINDEX_LINKAGE
unsigned
clang_isVirtualBase
(
CXCursor
);
3692
3693
/**
3694
* Represents the C++ access control level to a base class for a
3695
* cursor with kind CX_CXXBaseSpecifier.
3696
*/
3697
enum
CX_CXXAccessSpecifier
{
3698
CX_CXXInvalidAccessSpecifier
,
3699
CX_CXXPublic
,
3700
CX_CXXProtected
,
3701
CX_CXXPrivate
3702
};
3703
3704
/**
3705
* Returns the access control level for the referenced object.
3706
*
3707
* If the cursor refers to a C++ declaration, its access control level within
3708
* its parent scope is returned. Otherwise, if the cursor refers to a base
3709
* specifier or access specifier, the specifier itself is returned.
3710
*/
3711
CINDEX_LINKAGE
enum
CX_CXXAccessSpecifier
clang_getCXXAccessSpecifier
(
CXCursor
);
3712
3713
/**
3714
* Represents the storage classes as declared in the source. CX_SC_Invalid
3715
* was added for the case that the passed cursor in not a declaration.
3716
*/
3717
enum
CX_StorageClass
{
3718
CX_SC_Invalid
,
3719
CX_SC_None
,
3720
CX_SC_Extern
,
3721
CX_SC_Static
,
3722
CX_SC_PrivateExtern
,
3723
CX_SC_OpenCLWorkGroupLocal
,
3724
CX_SC_Auto
,
3725
CX_SC_Register
3726
};
3727
3728
/**
3729
* Returns the storage class for a function or variable declaration.
3730
*
3731
* If the passed in Cursor is not a function or variable declaration,
3732
* CX_SC_Invalid is returned else the storage class.
3733
*/
3734
CINDEX_LINKAGE
enum
CX_StorageClass
clang_Cursor_getStorageClass
(
CXCursor
);
3735
3736
/**
3737
* Determine the number of overloaded declarations referenced by a
3738
* \c CXCursor_OverloadedDeclRef cursor.
3739
*
3740
* \param cursor The cursor whose overloaded declarations are being queried.
3741
*
3742
* \returns The number of overloaded declarations referenced by \c cursor. If it
3743
* is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3744
*/
3745
CINDEX_LINKAGE
unsigned
clang_getNumOverloadedDecls
(
CXCursor
cursor);
3746
3747
/**
3748
* Retrieve a cursor for one of the overloaded declarations referenced
3749
* by a \c CXCursor_OverloadedDeclRef cursor.
3750
*
3751
* \param cursor The cursor whose overloaded declarations are being queried.
3752
*
3753
* \param index The zero-based index into the set of overloaded declarations in
3754
* the cursor.
3755
*
3756
* \returns A cursor representing the declaration referenced by the given
3757
* \c cursor at the specified \c index. If the cursor does not have an
3758
* associated set of overloaded declarations, or if the index is out of bounds,
3759
* returns \c clang_getNullCursor();
3760
*/
3761
CINDEX_LINKAGE
CXCursor
clang_getOverloadedDecl
(
CXCursor
cursor,
3762
unsigned
index);
3763
3764
/**
3765
* @}
3766
*/
3767
3768
/**
3769
* \defgroup CINDEX_ATTRIBUTES Information for attributes
3770
*
3771
* @{
3772
*/
3773
3774
/**
3775
* For cursors representing an iboutletcollection attribute,
3776
* this function returns the collection element type.
3777
*
3778
*/
3779
CINDEX_LINKAGE
CXType
clang_getIBOutletCollectionType
(
CXCursor
);
3780
3781
/**
3782
* @}
3783
*/
3784
3785
/**
3786
* \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3787
*
3788
* These routines provide the ability to traverse the abstract syntax tree
3789
* using cursors.
3790
*
3791
* @{
3792
*/
3793
3794
/**
3795
* Describes how the traversal of the children of a particular
3796
* cursor should proceed after visiting a particular child cursor.
3797
*
3798
* A value of this enumeration type should be returned by each
3799
* \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3800
*/
3801
enum
CXChildVisitResult
{
3802
/**
3803
* Terminates the cursor traversal.
3804
*/
3805
CXChildVisit_Break
,
3806
/**
3807
* Continues the cursor traversal with the next sibling of
3808
* the cursor just visited, without visiting its children.
3809
*/
3810
CXChildVisit_Continue
,
3811
/**
3812
* Recursively traverse the children of this cursor, using
3813
* the same visitor and client data.
3814
*/
3815
CXChildVisit_Recurse
3816
};
3817
3818
/**
3819
* Visitor invoked for each cursor found by a traversal.
3820
*
3821
* This visitor function will be invoked for each cursor found by
3822
* clang_visitCursorChildren(). Its first argument is the cursor being
3823
* visited, its second argument is the parent visitor for that cursor,
3824
* and its third argument is the client data provided to
3825
* clang_visitCursorChildren().
3826
*
3827
* The visitor should return one of the \c CXChildVisitResult values
3828
* to direct clang_visitCursorChildren().
3829
*/
3830
typedef
enum
CXChildVisitResult
(*
CXCursorVisitor
)(
CXCursor
cursor,
3831
CXCursor
parent,
3832
CXClientData
client_data);
3833
3834
/**
3835
* Visit the children of a particular cursor.
3836
*
3837
* This function visits all the direct children of the given cursor,
3838
* invoking the given \p visitor function with the cursors of each
3839
* visited child. The traversal may be recursive, if the visitor returns
3840
* \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3841
* the visitor returns \c CXChildVisit_Break.
3842
*
3843
* \param parent the cursor whose child may be visited. All kinds of
3844
* cursors can be visited, including invalid cursors (which, by
3845
* definition, have no children).
3846
*
3847
* \param visitor the visitor function that will be invoked for each
3848
* child of \p parent.
3849
*
3850
* \param client_data pointer data supplied by the client, which will
3851
* be passed to the visitor each time it is invoked.
3852
*
3853
* \returns a non-zero value if the traversal was terminated
3854
* prematurely by the visitor returning \c CXChildVisit_Break.
3855
*/
3856
CINDEX_LINKAGE
unsigned
clang_visitChildren
(
CXCursor
parent,
3857
CXCursorVisitor
visitor,
3858
CXClientData
client_data);
3859
#ifdef __has_feature
3860
#if __has_feature(blocks)
3861
/**
3862
* Visitor invoked for each cursor found by a traversal.
3863
*
3864
* This visitor block will be invoked for each cursor found by
3865
* clang_visitChildrenWithBlock(). Its first argument is the cursor being
3866
* visited, its second argument is the parent visitor for that cursor.
3867
*
3868
* The visitor should return one of the \c CXChildVisitResult values
3869
* to direct clang_visitChildrenWithBlock().
3870
*/
3871
typedef
enum
CXChildVisitResult
(^CXCursorVisitorBlock)(
CXCursor
cursor,
3872
CXCursor
parent);
3873
3874
/**
3875
* Visits the children of a cursor using the specified block. Behaves
3876
* identically to clang_visitChildren() in all other respects.
3877
*/
3878
CINDEX_LINKAGE
unsigned
3879
clang_visitChildrenWithBlock(
CXCursor
parent, CXCursorVisitorBlock block);
3880
#endif
3881
#endif
3882
3883
/**
3884
* @}
3885
*/
3886
3887
/**
3888
* \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3889
*
3890
* These routines provide the ability to determine references within and
3891
* across translation units, by providing the names of the entities referenced
3892
* by cursors, follow reference cursors to the declarations they reference,
3893
* and associate declarations with their definitions.
3894
*
3895
* @{
3896
*/
3897
3898
/**
3899
* Retrieve a Unified Symbol Resolution (USR) for the entity referenced
3900
* by the given cursor.
3901
*
3902
* A Unified Symbol Resolution (USR) is a string that identifies a particular
3903
* entity (function, class, variable, etc.) within a program. USRs can be
3904
* compared across translation units to determine, e.g., when references in
3905
* one translation refer to an entity defined in another translation unit.
3906
*/
3907
CINDEX_LINKAGE
CXString
clang_getCursorUSR
(
CXCursor
);
3908
3909
/**
3910
* Construct a USR for a specified Objective-C class.
3911
*/
3912
CINDEX_LINKAGE
CXString
clang_constructUSR_ObjCClass
(
const
char
*class_name);
3913
3914
/**
3915
* Construct a USR for a specified Objective-C category.
3916
*/
3917
CINDEX_LINKAGE
CXString
clang_constructUSR_ObjCCategory
(
3918
const
char
*class_name,
const
char
*category_name);
3919
3920
/**
3921
* Construct a USR for a specified Objective-C protocol.
3922
*/
3923
CINDEX_LINKAGE
CXString
3924
clang_constructUSR_ObjCProtocol
(
const
char
*protocol_name);
3925
3926
/**
3927
* Construct a USR for a specified Objective-C instance variable and
3928
* the USR for its containing class.
3929
*/
3930
CINDEX_LINKAGE
CXString
clang_constructUSR_ObjCIvar
(
const
char
*name,
3931
CXString
classUSR);
3932
3933
/**
3934
* Construct a USR for a specified Objective-C method and
3935
* the USR for its containing class.
3936
*/
3937
CINDEX_LINKAGE
CXString
clang_constructUSR_ObjCMethod
(
const
char
*name,
3938
unsigned
isInstanceMethod
,
3939
CXString
classUSR);
3940
3941
/**
3942
* Construct a USR for a specified Objective-C property and the USR
3943
* for its containing class.
3944
*/
3945
CINDEX_LINKAGE
CXString
clang_constructUSR_ObjCProperty
(
const
char
*property,
3946
CXString
classUSR);
3947
3948
/**
3949
* Retrieve a name for the entity referenced by this cursor.
3950
*/
3951
CINDEX_LINKAGE
CXString
clang_getCursorSpelling
(
CXCursor
);
3952
3953
/**
3954
* Retrieve a range for a piece that forms the cursors spelling name.
3955
* Most of the times there is only one range for the complete spelling but for
3956
* Objective-C methods and Objective-C message expressions, there are multiple
3957
* pieces for each selector identifier.
3958
*
3959
* \param pieceIndex the index of the spelling name piece. If this is greater
3960
* than the actual number of pieces, it will return a NULL (invalid) range.
3961
*
3962
* \param options Reserved.
3963
*/
3964
CINDEX_LINKAGE
CXSourceRange
clang_Cursor_getSpellingNameRange
(
3965
CXCursor
,
unsigned
pieceIndex,
unsigned
options);
3966
3967
/**
3968
* Opaque pointer representing a policy that controls pretty printing
3969
* for \c clang_getCursorPrettyPrinted.
3970
*/
3971
typedef
void
*
CXPrintingPolicy
;
3972
3973
/**
3974
* Properties for the printing policy.
3975
*
3976
* See \c clang::PrintingPolicy for more information.
3977
*/
3978
enum
CXPrintingPolicyProperty
{
3979
CXPrintingPolicy_Indentation
,
3980
CXPrintingPolicy_SuppressSpecifiers
,
3981
CXPrintingPolicy_SuppressTagKeyword
,
3982
CXPrintingPolicy_IncludeTagDefinition
,
3983
CXPrintingPolicy_SuppressScope
,
3984
CXPrintingPolicy_SuppressUnwrittenScope
,
3985
CXPrintingPolicy_SuppressInitializers
,
3986
CXPrintingPolicy_ConstantArraySizeAsWritten
,
3987
CXPrintingPolicy_AnonymousTagLocations
,
3988
CXPrintingPolicy_SuppressStrongLifetime
,
3989
CXPrintingPolicy_SuppressLifetimeQualifiers
,
3990
CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors
,
3991
CXPrintingPolicy_Bool
,
3992
CXPrintingPolicy_Restrict
,
3993
CXPrintingPolicy_Alignof
,
3994
CXPrintingPolicy_UnderscoreAlignof
,
3995
CXPrintingPolicy_UseVoidForZeroParams
,
3996
CXPrintingPolicy_TerseOutput
,
3997
CXPrintingPolicy_PolishForDeclaration
,
3998
CXPrintingPolicy_Half
,
3999
CXPrintingPolicy_MSWChar
,
4000
CXPrintingPolicy_IncludeNewlines
,
4001
CXPrintingPolicy_MSVCFormatting
,
4002
CXPrintingPolicy_ConstantsAsWritten
,
4003
CXPrintingPolicy_SuppressImplicitBase
,
4004
CXPrintingPolicy_FullyQualifiedName
,
4005
4006
CXPrintingPolicy_LastProperty
=
CXPrintingPolicy_FullyQualifiedName
4007
};
4008
4009
/**
4010
* Get a property value for the given printing policy.
4011
*/
4012
CINDEX_LINKAGE
unsigned
4013
clang_PrintingPolicy_getProperty
(
CXPrintingPolicy
Policy,
4014
enum
CXPrintingPolicyProperty
Property);
4015
4016
/**
4017
* Set a property value for the given printing policy.
4018
*/
4019
CINDEX_LINKAGE
void
4020
clang_PrintingPolicy_setProperty
(
CXPrintingPolicy
Policy,
4021
enum
CXPrintingPolicyProperty
Property,
4022
unsigned
Value
);
4023
4024
/**
4025
* Retrieve the default policy for the cursor.
4026
*
4027
* The policy should be released after use with \c
4028
* clang_PrintingPolicy_dispose.
4029
*/
4030
CINDEX_LINKAGE
CXPrintingPolicy
clang_getCursorPrintingPolicy
(
CXCursor
);
4031
4032
/**
4033
* Release a printing policy.
4034
*/
4035
CINDEX_LINKAGE
void
clang_PrintingPolicy_dispose
(
CXPrintingPolicy
Policy);
4036
4037
/**
4038
* Pretty print declarations.
4039
*
4040
* \param Cursor The cursor representing a declaration.
4041
*
4042
* \param Policy The policy to control the entities being printed. If
4043
* NULL, a default policy is used.
4044
*
4045
* \returns The pretty printed declaration or the empty string for
4046
* other cursors.
4047
*/
4048
CINDEX_LINKAGE
CXString
clang_getCursorPrettyPrinted
(
CXCursor
Cursor,
4049
CXPrintingPolicy
Policy);
4050
4051
/**
4052
* Retrieve the display name for the entity referenced by this cursor.
4053
*
4054
* The display name contains extra information that helps identify the cursor,
4055
* such as the parameters of a function or template or the arguments of a
4056
* class template specialization.
4057
*/
4058
CINDEX_LINKAGE
CXString
clang_getCursorDisplayName
(
CXCursor
);
4059
4060
/** For a cursor that is a reference, retrieve a cursor representing the
4061
* entity that it references.
4062
*
4063
* Reference cursors refer to other entities in the AST. For example, an
4064
* Objective-C superclass reference cursor refers to an Objective-C class.
4065
* This function produces the cursor for the Objective-C class from the
4066
* cursor for the superclass reference. If the input cursor is a declaration or
4067
* definition, it returns that declaration or definition unchanged.
4068
* Otherwise, returns the NULL cursor.
4069
*/
4070
CINDEX_LINKAGE
CXCursor
clang_getCursorReferenced
(
CXCursor
);
4071
4072
/**
4073
* For a cursor that is either a reference to or a declaration
4074
* of some entity, retrieve a cursor that describes the definition of
4075
* that entity.
4076
*
4077
* Some entities can be declared multiple times within a translation
4078
* unit, but only one of those declarations can also be a
4079
* definition. For example, given:
4080
*
4081
* \code
4082
* int f(int, int);
4083
* int g(int x, int y) { return f(x, y); }
4084
* int f(int a, int b) { return a + b; }
4085
* int f(int, int);
4086
* \endcode
4087
*
4088
* there are three declarations of the function "f", but only the
4089
* second one is a definition. The clang_getCursorDefinition()
4090
* function will take any cursor pointing to a declaration of "f"
4091
* (the first or fourth lines of the example) or a cursor referenced
4092
* that uses "f" (the call to "f' inside "g") and will return a
4093
* declaration cursor pointing to the definition (the second "f"
4094
* declaration).
4095
*
4096
* If given a cursor for which there is no corresponding definition,
4097
* e.g., because there is no definition of that entity within this
4098
* translation unit, returns a NULL cursor.
4099
*/
4100
CINDEX_LINKAGE
CXCursor
clang_getCursorDefinition
(
CXCursor
);
4101
4102
/**
4103
* Determine whether the declaration pointed to by this cursor
4104
* is also a definition of that entity.
4105
*/
4106
CINDEX_LINKAGE
unsigned
clang_isCursorDefinition
(
CXCursor
);
4107
4108
/**
4109
* Retrieve the canonical cursor corresponding to the given cursor.
4110
*
4111
* In the C family of languages, many kinds of entities can be declared several
4112
* times within a single translation unit. For example, a structure type can
4113
* be forward-declared (possibly multiple times) and later defined:
4114
*
4115
* \code
4116
* struct X;
4117
* struct X;
4118
* struct X {
4119
* int member;
4120
* };
4121
* \endcode
4122
*
4123
* The declarations and the definition of \c X are represented by three
4124
* different cursors, all of which are declarations of the same underlying
4125
* entity. One of these cursor is considered the "canonical" cursor, which
4126
* is effectively the representative for the underlying entity. One can
4127
* determine if two cursors are declarations of the same underlying entity by
4128
* comparing their canonical cursors.
4129
*
4130
* \returns The canonical cursor for the entity referred to by the given cursor.
4131
*/
4132
CINDEX_LINKAGE
CXCursor
clang_getCanonicalCursor
(
CXCursor
);
4133
4134
/**
4135
* If the cursor points to a selector identifier in an Objective-C
4136
* method or message expression, this returns the selector index.
4137
*
4138
* After getting a cursor with #clang_getCursor, this can be called to
4139
* determine if the location points to a selector identifier.
4140
*
4141
* \returns The selector index if the cursor is an Objective-C method or message
4142
* expression and the cursor is pointing to a selector identifier, or -1
4143
* otherwise.
4144
*/
4145
CINDEX_LINKAGE
int
clang_Cursor_getObjCSelectorIndex
(
CXCursor
);
4146
4147
/**
4148
* Given a cursor pointing to a C++ method call or an Objective-C
4149
* message, returns non-zero if the method/message is "dynamic", meaning:
4150
*
4151
* For a C++ method: the call is virtual.
4152
* For an Objective-C message: the receiver is an object instance, not 'super'
4153
* or a specific class.
4154
*
4155
* If the method/message is "static" or the cursor does not point to a
4156
* method/message, it will return zero.
4157
*/
4158
CINDEX_LINKAGE
int
clang_Cursor_isDynamicCall
(
CXCursor
C);
4159
4160
/**
4161
* Given a cursor pointing to an Objective-C message or property
4162
* reference, or C++ method call, returns the CXType of the receiver.
4163
*/
4164
CINDEX_LINKAGE
CXType
clang_Cursor_getReceiverType
(
CXCursor
C);
4165
4166
/**
4167
* Property attributes for a \c CXCursor_ObjCPropertyDecl.
4168
*/
4169
typedef
enum
{
4170
CXObjCPropertyAttr_noattr
= 0x00,
4171
CXObjCPropertyAttr_readonly
= 0x01,
4172
CXObjCPropertyAttr_getter
= 0x02,
4173
CXObjCPropertyAttr_assign
= 0x04,
4174
CXObjCPropertyAttr_readwrite
= 0x08,
4175
CXObjCPropertyAttr_retain
= 0x10,
4176
CXObjCPropertyAttr_copy
= 0x20,
4177
CXObjCPropertyAttr_nonatomic
= 0x40,
4178
CXObjCPropertyAttr_setter
= 0x80,
4179
CXObjCPropertyAttr_atomic
= 0x100,
4180
CXObjCPropertyAttr_weak
= 0x200,
4181
CXObjCPropertyAttr_strong
= 0x400,
4182
CXObjCPropertyAttr_unsafe_unretained
= 0x800,
4183
CXObjCPropertyAttr_class
= 0x1000
4184
}
CXObjCPropertyAttrKind
;
4185
4186
/**
4187
* Given a cursor that represents a property declaration, return the
4188
* associated property attributes. The bits are formed from
4189
* \c CXObjCPropertyAttrKind.
4190
*
4191
* \param reserved Reserved for future use, pass 0.
4192
*/
4193
CINDEX_LINKAGE
unsigned
4194
clang_Cursor_getObjCPropertyAttributes
(
CXCursor
C,
unsigned
reserved);
4195
4196
/**
4197
* Given a cursor that represents a property declaration, return the
4198
* name of the method that implements the getter.
4199
*/
4200
CINDEX_LINKAGE
CXString
clang_Cursor_getObjCPropertyGetterName
(
CXCursor
C);
4201
4202
/**
4203
* Given a cursor that represents a property declaration, return the
4204
* name of the method that implements the setter, if any.
4205
*/
4206
CINDEX_LINKAGE
CXString
clang_Cursor_getObjCPropertySetterName
(
CXCursor
C);
4207
4208
/**
4209
* 'Qualifiers' written next to the return and parameter types in
4210
* Objective-C method declarations.
4211
*/
4212
typedef
enum
{
4213
CXObjCDeclQualifier_None
= 0x0,
4214
CXObjCDeclQualifier_In
= 0x1,
4215
CXObjCDeclQualifier_Inout
= 0x2,
4216
CXObjCDeclQualifier_Out
= 0x4,
4217
CXObjCDeclQualifier_Bycopy
= 0x8,
4218
CXObjCDeclQualifier_Byref
= 0x10,
4219
CXObjCDeclQualifier_Oneway
= 0x20
4220
}
CXObjCDeclQualifierKind
;
4221
4222
/**
4223
* Given a cursor that represents an Objective-C method or parameter
4224
* declaration, return the associated Objective-C qualifiers for the return
4225
* type or the parameter respectively. The bits are formed from
4226
* CXObjCDeclQualifierKind.
4227
*/
4228
CINDEX_LINKAGE
unsigned
clang_Cursor_getObjCDeclQualifiers
(
CXCursor
C);
4229
4230
/**
4231
* Given a cursor that represents an Objective-C method or property
4232
* declaration, return non-zero if the declaration was affected by "\@optional".
4233
* Returns zero if the cursor is not such a declaration or it is "\@required".
4234
*/
4235
CINDEX_LINKAGE
unsigned
clang_Cursor_isObjCOptional
(
CXCursor
C);
4236
4237
/**
4238
* Returns non-zero if the given cursor is a variadic function or method.
4239
*/
4240
CINDEX_LINKAGE
unsigned
clang_Cursor_isVariadic
(
CXCursor
C);
4241
4242
/**
4243
* Returns non-zero if the given cursor points to a symbol marked with
4244
* external_source_symbol attribute.
4245
*
4246
* \param language If non-NULL, and the attribute is present, will be set to
4247
* the 'language' string from the attribute.
4248
*
4249
* \param definedIn If non-NULL, and the attribute is present, will be set to
4250
* the 'definedIn' string from the attribute.
4251
*
4252
* \param isGenerated If non-NULL, and the attribute is present, will be set to
4253
* non-zero if the 'generated_declaration' is set in the attribute.
4254
*/
4255
CINDEX_LINKAGE
unsigned
clang_Cursor_isExternalSymbol
(
CXCursor
C,
4256
CXString
*language,
4257
CXString
*definedIn,
4258
unsigned
*isGenerated);
4259
4260
/**
4261
* Given a cursor that represents a declaration, return the associated
4262
* comment's source range. The range may include multiple consecutive comments
4263
* with whitespace in between.
4264
*/
4265
CINDEX_LINKAGE
CXSourceRange
clang_Cursor_getCommentRange
(
CXCursor
C);
4266
4267
/**
4268
* Given a cursor that represents a declaration, return the associated
4269
* comment text, including comment markers.
4270
*/
4271
CINDEX_LINKAGE
CXString
clang_Cursor_getRawCommentText
(
CXCursor
C);
4272
4273
/**
4274
* Given a cursor that represents a documentable entity (e.g.,
4275
* declaration), return the associated \paragraph; otherwise return the
4276
* first paragraph.
4277
*/
4278
CINDEX_LINKAGE
CXString
clang_Cursor_getBriefCommentText
(
CXCursor
C);
4279
4280
/**
4281
* @}
4282
*/
4283
4284
/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4285
*
4286
* @{
4287
*/
4288
4289
/**
4290
* Retrieve the CXString representing the mangled name of the cursor.
4291
*/
4292
CINDEX_LINKAGE
CXString
clang_Cursor_getMangling
(
CXCursor
);
4293
4294
/**
4295
* Retrieve the CXStrings representing the mangled symbols of the C++
4296
* constructor or destructor at the cursor.
4297
*/
4298
CINDEX_LINKAGE
CXStringSet
*
clang_Cursor_getCXXManglings
(
CXCursor
);
4299
4300
/**
4301
* Retrieve the CXStrings representing the mangled symbols of the ObjC
4302
* class interface or implementation at the cursor.
4303
*/
4304
CINDEX_LINKAGE
CXStringSet
*
clang_Cursor_getObjCManglings
(
CXCursor
);
4305
4306
/**
4307
* @}
4308
*/
4309
4310
/**
4311
* \defgroup CINDEX_MODULE Module introspection
4312
*
4313
* The functions in this group provide access to information about modules.
4314
*
4315
* @{
4316
*/
4317
4318
typedef
void
*
CXModule
;
4319
4320
/**
4321
* Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4322
*/
4323
CINDEX_LINKAGE
CXModule
clang_Cursor_getModule
(
CXCursor
C);
4324
4325
/**
4326
* Given a CXFile header file, return the module that contains it, if one
4327
* exists.
4328
*/
4329
CINDEX_LINKAGE
CXModule
clang_getModuleForFile
(
CXTranslationUnit
,
CXFile
);
4330
4331
/**
4332
* \param Module a module object.
4333
*
4334
* \returns the module file where the provided module object came from.
4335
*/
4336
CINDEX_LINKAGE
CXFile
clang_Module_getASTFile
(
CXModule
Module);
4337
4338
/**
4339
* \param Module a module object.
4340
*
4341
* \returns the parent of a sub-module or NULL if the given module is top-level,
4342
* e.g. for 'std.vector' it will return the 'std' module.
4343
*/
4344
CINDEX_LINKAGE
CXModule
clang_Module_getParent
(
CXModule
Module);
4345
4346
/**
4347
* \param Module a module object.
4348
*
4349
* \returns the name of the module, e.g. for the 'std.vector' sub-module it
4350
* will return "vector".
4351
*/
4352
CINDEX_LINKAGE
CXString
clang_Module_getName
(
CXModule
Module);
4353
4354
/**
4355
* \param Module a module object.
4356
*
4357
* \returns the full name of the module, e.g. "std.vector".
4358
*/
4359
CINDEX_LINKAGE
CXString
clang_Module_getFullName
(
CXModule
Module);
4360
4361
/**
4362
* \param Module a module object.
4363
*
4364
* \returns non-zero if the module is a system one.
4365
*/
4366
CINDEX_LINKAGE
int
clang_Module_isSystem
(
CXModule
Module);
4367
4368
/**
4369
* \param Module a module object.
4370
*
4371
* \returns the number of top level headers associated with this module.
4372
*/
4373
CINDEX_LINKAGE
unsigned
clang_Module_getNumTopLevelHeaders
(
CXTranslationUnit
,
4374
CXModule
Module);
4375
4376
/**
4377
* \param Module a module object.
4378
*
4379
* \param Index top level header index (zero-based).
4380
*
4381
* \returns the specified top level header associated with the module.
4382
*/
4383
CINDEX_LINKAGE
4384
CXFile
clang_Module_getTopLevelHeader
(
CXTranslationUnit
,
CXModule
Module,
4385
unsigned
Index);
4386
4387
/**
4388
* @}
4389
*/
4390
4391
/**
4392
* \defgroup CINDEX_CPP C++ AST introspection
4393
*
4394
* The routines in this group provide access information in the ASTs specific
4395
* to C++ language features.
4396
*
4397
* @{
4398
*/
4399
4400
/**
4401
* Determine if a C++ constructor is a converting constructor.
4402
*/
4403
CINDEX_LINKAGE
unsigned
4404
clang_CXXConstructor_isConvertingConstructor
(
CXCursor
C);
4405
4406
/**
4407
* Determine if a C++ constructor is a copy constructor.
4408
*/
4409
CINDEX_LINKAGE
unsigned
clang_CXXConstructor_isCopyConstructor
(
CXCursor
C);
4410
4411
/**
4412
* Determine if a C++ constructor is the default constructor.
4413
*/
4414
CINDEX_LINKAGE
unsigned
clang_CXXConstructor_isDefaultConstructor
(
CXCursor
C);
4415
4416
/**
4417
* Determine if a C++ constructor is a move constructor.
4418
*/
4419
CINDEX_LINKAGE
unsigned
clang_CXXConstructor_isMoveConstructor
(
CXCursor
C);
4420
4421
/**
4422
* Determine if a C++ field is declared 'mutable'.
4423
*/
4424
CINDEX_LINKAGE
unsigned
clang_CXXField_isMutable
(
CXCursor
C);
4425
4426
/**
4427
* Determine if a C++ method is declared '= default'.
4428
*/
4429
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isDefaulted
(
CXCursor
C);
4430
4431
/**
4432
* Determine if a C++ method is declared '= delete'.
4433
*/
4434
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isDeleted
(
CXCursor
C);
4435
4436
/**
4437
* Determine if a C++ member function or member function template is
4438
* pure virtual.
4439
*/
4440
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isPureVirtual
(
CXCursor
C);
4441
4442
/**
4443
* Determine if a C++ member function or member function template is
4444
* declared 'static'.
4445
*/
4446
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isStatic
(
CXCursor
C);
4447
4448
/**
4449
* Determine if a C++ member function or member function template is
4450
* explicitly declared 'virtual' or if it overrides a virtual method from
4451
* one of the base classes.
4452
*/
4453
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isVirtual
(
CXCursor
C);
4454
4455
/**
4456
* Determine if a C++ member function is a copy-assignment operator,
4457
* returning 1 if such is the case and 0 otherwise.
4458
*
4459
* > A copy-assignment operator `X::operator=` is a non-static,
4460
* > non-template member function of _class_ `X` with exactly one
4461
* > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const
4462
* > volatile X&`.
4463
*
4464
* That is, for example, the `operator=` in:
4465
*
4466
* class Foo {
4467
* bool operator=(const volatile Foo&);
4468
* };
4469
*
4470
* Is a copy-assignment operator, while the `operator=` in:
4471
*
4472
* class Bar {
4473
* bool operator=(const int&);
4474
* };
4475
*
4476
* Is not.
4477
*/
4478
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isCopyAssignmentOperator
(
CXCursor
C);
4479
4480
/**
4481
* Determine if a C++ member function is a move-assignment operator,
4482
* returning 1 if such is the case and 0 otherwise.
4483
*
4484
* > A move-assignment operator `X::operator=` is a non-static,
4485
* > non-template member function of _class_ `X` with exactly one
4486
* > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const
4487
* > volatile X&&`.
4488
*
4489
* That is, for example, the `operator=` in:
4490
*
4491
* class Foo {
4492
* bool operator=(const volatile Foo&&);
4493
* };
4494
*
4495
* Is a move-assignment operator, while the `operator=` in:
4496
*
4497
* class Bar {
4498
* bool operator=(const int&&);
4499
* };
4500
*
4501
* Is not.
4502
*/
4503
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isMoveAssignmentOperator
(
CXCursor
C);
4504
4505
/**
4506
* Determines if a C++ constructor or conversion function was declared
4507
* explicit, returning 1 if such is the case and 0 otherwise.
4508
*
4509
* Constructors or conversion functions are declared explicit through
4510
* the use of the explicit specifier.
4511
*
4512
* For example, the following constructor and conversion function are
4513
* not explicit as they lack the explicit specifier:
4514
*
4515
* class Foo {
4516
* Foo();
4517
* operator int();
4518
* };
4519
*
4520
* While the following constructor and conversion function are
4521
* explicit as they are declared with the explicit specifier.
4522
*
4523
* class Foo {
4524
* explicit Foo();
4525
* explicit operator int();
4526
* };
4527
*
4528
* This function will return 0 when given a cursor pointing to one of
4529
* the former declarations and it will return 1 for a cursor pointing
4530
* to the latter declarations.
4531
*
4532
* The explicit specifier allows the user to specify a
4533
* conditional compile-time expression whose value decides
4534
* whether the marked element is explicit or not.
4535
*
4536
* For example:
4537
*
4538
* constexpr bool foo(int i) { return i % 2 == 0; }
4539
*
4540
* class Foo {
4541
* explicit(foo(1)) Foo();
4542
* explicit(foo(2)) operator int();
4543
* }
4544
*
4545
* This function will return 0 for the constructor and 1 for
4546
* the conversion function.
4547
*/
4548
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isExplicit
(
CXCursor
C);
4549
4550
/**
4551
* Determine if a C++ record is abstract, i.e. whether a class or struct
4552
* has a pure virtual member function.
4553
*/
4554
CINDEX_LINKAGE
unsigned
clang_CXXRecord_isAbstract
(
CXCursor
C);
4555
4556
/**
4557
* Determine if an enum declaration refers to a scoped enum.
4558
*/
4559
CINDEX_LINKAGE
unsigned
clang_EnumDecl_isScoped
(
CXCursor
C);
4560
4561
/**
4562
* Determine if a C++ member function or member function template is
4563
* declared 'const'.
4564
*/
4565
CINDEX_LINKAGE
unsigned
clang_CXXMethod_isConst
(
CXCursor
C);
4566
4567
/**
4568
* Given a cursor that represents a template, determine
4569
* the cursor kind of the specializations would be generated by instantiating
4570
* the template.
4571
*
4572
* This routine can be used to determine what flavor of function template,
4573
* class template, or class template partial specialization is stored in the
4574
* cursor. For example, it can describe whether a class template cursor is
4575
* declared with "struct", "class" or "union".
4576
*
4577
* \param C The cursor to query. This cursor should represent a template
4578
* declaration.
4579
*
4580
* \returns The cursor kind of the specializations that would be generated
4581
* by instantiating the template \p C. If \p C is not a template, returns
4582
* \c CXCursor_NoDeclFound.
4583
*/
4584
CINDEX_LINKAGE
enum
CXCursorKind
clang_getTemplateCursorKind
(
CXCursor
C);
4585
4586
/**
4587
* Given a cursor that may represent a specialization or instantiation
4588
* of a template, retrieve the cursor that represents the template that it
4589
* specializes or from which it was instantiated.
4590
*
4591
* This routine determines the template involved both for explicit
4592
* specializations of templates and for implicit instantiations of the template,
4593
* both of which are referred to as "specializations". For a class template
4594
* specialization (e.g., \c std::vector<bool>), this routine will return
4595
* either the primary template (\c std::vector) or, if the specialization was
4596
* instantiated from a class template partial specialization, the class template
4597
* partial specialization. For a class template partial specialization and a
4598
* function template specialization (including instantiations), this
4599
* this routine will return the specialized template.
4600
*
4601
* For members of a class template (e.g., member functions, member classes, or
4602
* static data members), returns the specialized or instantiated member.
4603
* Although not strictly "templates" in the C++ language, members of class
4604
* templates have the same notions of specializations and instantiations that
4605
* templates do, so this routine treats them similarly.
4606
*
4607
* \param C A cursor that may be a specialization of a template or a member
4608
* of a template.
4609
*
4610
* \returns If the given cursor is a specialization or instantiation of a
4611
* template or a member thereof, the template or member that it specializes or
4612
* from which it was instantiated. Otherwise, returns a NULL cursor.
4613
*/
4614
CINDEX_LINKAGE
CXCursor
clang_getSpecializedCursorTemplate
(
CXCursor
C);
4615
4616
/**
4617
* Given a cursor that references something else, return the source range
4618
* covering that reference.
4619
*
4620
* \param C A cursor pointing to a member reference, a declaration reference, or
4621
* an operator call.
4622
* \param NameFlags A bitset with three independent flags:
4623
* CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4624
* CXNameRange_WantSinglePiece.
4625
* \param PieceIndex For contiguous names or when passing the flag
4626
* CXNameRange_WantSinglePiece, only one piece with index 0 is
4627
* available. When the CXNameRange_WantSinglePiece flag is not passed for a
4628
* non-contiguous names, this index can be used to retrieve the individual
4629
* pieces of the name. See also CXNameRange_WantSinglePiece.
4630
*
4631
* \returns The piece of the name pointed to by the given cursor. If there is no
4632
* name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4633
*/
4634
CINDEX_LINKAGE
CXSourceRange
clang_getCursorReferenceNameRange
(
4635
CXCursor
C,
unsigned
NameFlags,
unsigned
PieceIndex);
4636
4637
enum
CXNameRefFlags
{
4638
/**
4639
* Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4640
* range.
4641
*/
4642
CXNameRange_WantQualifier
= 0x1,
4643
4644
/**
4645
* Include the explicit template arguments, e.g. <int> in x.f<int>,
4646
* in the range.
4647
*/
4648
CXNameRange_WantTemplateArgs
= 0x2,
4649
4650
/**
4651
* If the name is non-contiguous, return the full spanning range.
4652
*
4653
* Non-contiguous names occur in Objective-C when a selector with two or more
4654
* parameters is used, or in C++ when using an operator:
4655
* \code
4656
* [object doSomething:here withValue:there]; // Objective-C
4657
* return some_vector[1]; // C++
4658
* \endcode
4659
*/
4660
CXNameRange_WantSinglePiece
= 0x4
4661
};
4662
4663
/**
4664
* @}
4665
*/
4666
4667
/**
4668
* \defgroup CINDEX_LEX Token extraction and manipulation
4669
*
4670
* The routines in this group provide access to the tokens within a
4671
* translation unit, along with a semantic mapping of those tokens to
4672
* their corresponding cursors.
4673
*
4674
* @{
4675
*/
4676
4677
/**
4678
* Describes a kind of token.
4679
*/
4680
typedef
enum
CXTokenKind
{
4681
/**
4682
* A token that contains some kind of punctuation.
4683
*/
4684
CXToken_Punctuation
,
4685
4686
/**
4687
* A language keyword.
4688
*/
4689
CXToken_Keyword
,
4690
4691
/**
4692
* An identifier (that is not a keyword).
4693
*/
4694
CXToken_Identifier
,
4695
4696
/**
4697
* A numeric, string, or character literal.
4698
*/
4699
CXToken_Literal
,
4700
4701
/**
4702
* A comment.
4703
*/
4704
CXToken_Comment
4705
}
CXTokenKind
;
4706
4707
/**
4708
* Describes a single preprocessing token.
4709
*/
4710
typedef
struct
{
4711
unsigned
int_data[4];
4712
void
*
ptr_data
;
4713
}
CXToken
;
4714
4715
/**
4716
* Get the raw lexical token starting with the given location.
4717
*
4718
* \param TU the translation unit whose text is being tokenized.
4719
*
4720
* \param Location the source location with which the token starts.
4721
*
4722
* \returns The token starting with the given location or NULL if no such token
4723
* exist. The returned pointer must be freed with clang_disposeTokens before the
4724
* translation unit is destroyed.
4725
*/
4726
CINDEX_LINKAGE
CXToken
*
clang_getToken
(
CXTranslationUnit
TU,
4727
CXSourceLocation
Location);
4728
4729
/**
4730
* Determine the kind of the given token.
4731
*/
4732
CINDEX_LINKAGE
CXTokenKind
clang_getTokenKind
(
CXToken
);
4733
4734
/**
4735
* Determine the spelling of the given token.
4736
*
4737
* The spelling of a token is the textual representation of that token, e.g.,
4738
* the text of an identifier or keyword.
4739
*/
4740
CINDEX_LINKAGE
CXString
clang_getTokenSpelling
(
CXTranslationUnit
,
CXToken
);
4741
4742
/**
4743
* Retrieve the source location of the given token.
4744
*/
4745
CINDEX_LINKAGE
CXSourceLocation
clang_getTokenLocation
(
CXTranslationUnit
,
4746
CXToken
);
4747
4748
/**
4749
* Retrieve a source range that covers the given token.
4750
*/
4751
CINDEX_LINKAGE
CXSourceRange
clang_getTokenExtent
(
CXTranslationUnit
,
CXToken
);
4752
4753
/**
4754
* Tokenize the source code described by the given range into raw
4755
* lexical tokens.
4756
*
4757
* \param TU the translation unit whose text is being tokenized.
4758
*
4759
* \param Range the source range in which text should be tokenized. All of the
4760
* tokens produced by tokenization will fall within this source range,
4761
*
4762
* \param Tokens this pointer will be set to point to the array of tokens
4763
* that occur within the given source range. The returned pointer must be
4764
* freed with clang_disposeTokens() before the translation unit is destroyed.
4765
*
4766
* \param NumTokens will be set to the number of tokens in the \c *Tokens
4767
* array.
4768
*
4769
*/
4770
CINDEX_LINKAGE
void
clang_tokenize
(
CXTranslationUnit
TU,
CXSourceRange
Range,
4771
CXToken
**Tokens,
unsigned
*NumTokens);
4772
4773
/**
4774
* Annotate the given set of tokens by providing cursors for each token
4775
* that can be mapped to a specific entity within the abstract syntax tree.
4776
*
4777
* This token-annotation routine is equivalent to invoking
4778
* clang_getCursor() for the source locations of each of the
4779
* tokens. The cursors provided are filtered, so that only those
4780
* cursors that have a direct correspondence to the token are
4781
* accepted. For example, given a function call \c f(x),
4782
* clang_getCursor() would provide the following cursors:
4783
*
4784
* * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4785
* * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4786
* * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4787
*
4788
* Only the first and last of these cursors will occur within the
4789
* annotate, since the tokens "f" and "x' directly refer to a function
4790
* and a variable, respectively, but the parentheses are just a small
4791
* part of the full syntax of the function call expression, which is
4792
* not provided as an annotation.
4793
*
4794
* \param TU the translation unit that owns the given tokens.
4795
*
4796
* \param Tokens the set of tokens to annotate.
4797
*
4798
* \param NumTokens the number of tokens in \p Tokens.
4799
*
4800
* \param Cursors an array of \p NumTokens cursors, whose contents will be
4801
* replaced with the cursors corresponding to each token.
4802
*/
4803
CINDEX_LINKAGE
void
clang_annotateTokens
(
CXTranslationUnit
TU,
CXToken
*Tokens,
4804
unsigned
NumTokens,
CXCursor
*Cursors);
4805
4806
/**
4807
* Free the given set of tokens.
4808
*/
4809
CINDEX_LINKAGE
void
clang_disposeTokens
(
CXTranslationUnit
TU,
CXToken
*Tokens,
4810
unsigned
NumTokens);
4811
4812
/**
4813
* @}
4814
*/
4815
4816
/**
4817
* \defgroup CINDEX_DEBUG Debugging facilities
4818
*
4819
* These routines are used for testing and debugging, only, and should not
4820
* be relied upon.
4821
*
4822
* @{
4823
*/
4824
4825
/* for debug/testing */
4826
CINDEX_LINKAGE
CXString
clang_getCursorKindSpelling
(
enum
CXCursorKind
Kind);
4827
CINDEX_LINKAGE
void
clang_getDefinitionSpellingAndExtent
(
4828
CXCursor
,
const
char
**startBuf,
const
char
**endBuf,
unsigned
*startLine,
4829
unsigned
*startColumn,
unsigned
*endLine,
unsigned
*endColumn);
4830
CINDEX_LINKAGE
void
clang_enableStackTraces
(
void
);
4831
CINDEX_LINKAGE
void
clang_executeOnThread
(
void
(*fn)(
void
*),
void
*user_data,
4832
unsigned
stack_size);
4833
4834
/**
4835
* @}
4836
*/
4837
4838
/**
4839
* \defgroup CINDEX_CODE_COMPLET Code completion
4840
*
4841
* Code completion involves taking an (incomplete) source file, along with
4842
* knowledge of where the user is actively editing that file, and suggesting
4843
* syntactically- and semantically-valid constructs that the user might want to
4844
* use at that particular point in the source code. These data structures and
4845
* routines provide support for code completion.
4846
*
4847
* @{
4848
*/
4849
4850
/**
4851
* A semantic string that describes a code-completion result.
4852
*
4853
* A semantic string that describes the formatting of a code-completion
4854
* result as a single "template" of text that should be inserted into the
4855
* source buffer when a particular code-completion result is selected.
4856
* Each semantic string is made up of some number of "chunks", each of which
4857
* contains some text along with a description of what that text means, e.g.,
4858
* the name of the entity being referenced, whether the text chunk is part of
4859
* the template, or whether it is a "placeholder" that the user should replace
4860
* with actual code,of a specific kind. See \c CXCompletionChunkKind for a
4861
* description of the different kinds of chunks.
4862
*/
4863
typedef
void
*
CXCompletionString
;
4864
4865
/**
4866
* A single result of code completion.
4867
*/
4868
typedef
struct
{
4869
/**
4870
* The kind of entity that this completion refers to.
4871
*
4872
* The cursor kind will be a macro, keyword, or a declaration (one of the
4873
* *Decl cursor kinds), describing the entity that the completion is
4874
* referring to.
4875
*
4876
* \todo In the future, we would like to provide a full cursor, to allow
4877
* the client to extract additional information from declaration.
4878
*/
4879
enum
CXCursorKind
CursorKind
;
4880
4881
/**
4882
* The code-completion string that describes how to insert this
4883
* code-completion result into the editing buffer.
4884
*/
4885
CXCompletionString
CompletionString
;
4886
}
CXCompletionResult
;
4887
4888
/**
4889
* Describes a single piece of text within a code-completion string.
4890
*
4891
* Each "chunk" within a code-completion string (\c CXCompletionString) is
4892
* either a piece of text with a specific "kind" that describes how that text
4893
* should be interpreted by the client or is another completion string.
4894
*/
4895
enum
CXCompletionChunkKind
{
4896
/**
4897
* A code-completion string that describes "optional" text that
4898
* could be a part of the template (but is not required).
4899
*
4900
* The Optional chunk is the only kind of chunk that has a code-completion
4901
* string for its representation, which is accessible via
4902
* \c clang_getCompletionChunkCompletionString(). The code-completion string
4903
* describes an additional part of the template that is completely optional.
4904
* For example, optional chunks can be used to describe the placeholders for
4905
* arguments that match up with defaulted function parameters, e.g. given:
4906
*
4907
* \code
4908
* void f(int x, float y = 3.14, double z = 2.71828);
4909
* \endcode
4910
*
4911
* The code-completion string for this function would contain:
4912
* - a TypedText chunk for "f".
4913
* - a LeftParen chunk for "(".
4914
* - a Placeholder chunk for "int x"
4915
* - an Optional chunk containing the remaining defaulted arguments, e.g.,
4916
* - a Comma chunk for ","
4917
* - a Placeholder chunk for "float y"
4918
* - an Optional chunk containing the last defaulted argument:
4919
* - a Comma chunk for ","
4920
* - a Placeholder chunk for "double z"
4921
* - a RightParen chunk for ")"
4922
*
4923
* There are many ways to handle Optional chunks. Two simple approaches are:
4924
* - Completely ignore optional chunks, in which case the template for the
4925
* function "f" would only include the first parameter ("int x").
4926
* - Fully expand all optional chunks, in which case the template for the
4927
* function "f" would have all of the parameters.
4928
*/
4929
CXCompletionChunk_Optional
,
4930
/**
4931
* Text that a user would be expected to type to get this
4932
* code-completion result.
4933
*
4934
* There will be exactly one "typed text" chunk in a semantic string, which
4935
* will typically provide the spelling of a keyword or the name of a
4936
* declaration that could be used at the current code point. Clients are
4937
* expected to filter the code-completion results based on the text in this
4938
* chunk.
4939
*/
4940
CXCompletionChunk_TypedText
,
4941
/**
4942
* Text that should be inserted as part of a code-completion result.
4943
*
4944
* A "text" chunk represents text that is part of the template to be
4945
* inserted into user code should this particular code-completion result
4946
* be selected.
4947
*/
4948
CXCompletionChunk_Text
,
4949
/**
4950
* Placeholder text that should be replaced by the user.
4951
*
4952
* A "placeholder" chunk marks a place where the user should insert text
4953
* into the code-completion template. For example, placeholders might mark
4954
* the function parameters for a function declaration, to indicate that the
4955
* user should provide arguments for each of those parameters. The actual
4956
* text in a placeholder is a suggestion for the text to display before
4957
* the user replaces the placeholder with real code.
4958
*/
4959
CXCompletionChunk_Placeholder
,
4960
/**
4961
* Informative text that should be displayed but never inserted as
4962
* part of the template.
4963
*
4964
* An "informative" chunk contains annotations that can be displayed to
4965
* help the user decide whether a particular code-completion result is the
4966
* right option, but which is not part of the actual template to be inserted
4967
* by code completion.
4968
*/
4969
CXCompletionChunk_Informative
,
4970
/**
4971
* Text that describes the current parameter when code-completion is
4972
* referring to function call, message send, or template specialization.
4973
*
4974
* A "current parameter" chunk occurs when code-completion is providing
4975
* information about a parameter corresponding to the argument at the
4976
* code-completion point. For example, given a function
4977
*
4978
* \code
4979
* int add(int x, int y);
4980
* \endcode
4981
*
4982
* and the source code \c add(, where the code-completion point is after the
4983
* "(", the code-completion string will contain a "current parameter" chunk
4984
* for "int x", indicating that the current argument will initialize that
4985
* parameter. After typing further, to \c add(17, (where the code-completion
4986
* point is after the ","), the code-completion string will contain a
4987
* "current parameter" chunk to "int y".
4988
*/
4989
CXCompletionChunk_CurrentParameter
,
4990
/**
4991
* A left parenthesis ('('), used to initiate a function call or
4992
* signal the beginning of a function parameter list.
4993
*/
4994
CXCompletionChunk_LeftParen
,
4995
/**
4996
* A right parenthesis (')'), used to finish a function call or
4997
* signal the end of a function parameter list.
4998
*/
4999
CXCompletionChunk_RightParen
,
5000
/**
5001
* A left bracket ('[').
5002
*/
5003
CXCompletionChunk_LeftBracket
,
5004
/**
5005
* A right bracket (']').
5006
*/
5007
CXCompletionChunk_RightBracket
,
5008
/**
5009
* A left brace ('{').
5010
*/
5011
CXCompletionChunk_LeftBrace
,
5012
/**
5013
* A right brace ('}').
5014
*/
5015
CXCompletionChunk_RightBrace
,
5016
/**
5017
* A left angle bracket ('<').
5018
*/
5019
CXCompletionChunk_LeftAngle
,
5020
/**
5021
* A right angle bracket ('>').
5022
*/
5023
CXCompletionChunk_RightAngle
,
5024
/**
5025
* A comma separator (',').
5026
*/
5027
CXCompletionChunk_Comma
,
5028
/**
5029
* Text that specifies the result type of a given result.
5030
*
5031
* This special kind of informative chunk is not meant to be inserted into
5032
* the text buffer. Rather, it is meant to illustrate the type that an
5033
* expression using the given completion string would have.
5034
*/
5035
CXCompletionChunk_ResultType
,
5036
/**
5037
* A colon (':').
5038
*/
5039
CXCompletionChunk_Colon
,
5040
/**
5041
* A semicolon (';').
5042
*/
5043
CXCompletionChunk_SemiColon
,
5044
/**
5045
* An '=' sign.
5046
*/
5047
CXCompletionChunk_Equal
,
5048
/**
5049
* Horizontal space (' ').
5050
*/
5051
CXCompletionChunk_HorizontalSpace
,
5052
/**
5053
* Vertical space ('\\n'), after which it is generally a good idea to
5054
* perform indentation.
5055
*/
5056
CXCompletionChunk_VerticalSpace
5057
};
5058
5059
/**
5060
* Determine the kind of a particular chunk within a completion string.
5061
*
5062
* \param completion_string the completion string to query.
5063
*
5064
* \param chunk_number the 0-based index of the chunk in the completion string.
5065
*
5066
* \returns the kind of the chunk at the index \c chunk_number.
5067
*/
5068
CINDEX_LINKAGE
enum
CXCompletionChunkKind
5069
clang_getCompletionChunkKind
(
CXCompletionString
completion_string,
5070
unsigned
chunk_number);
5071
5072
/**
5073
* Retrieve the text associated with a particular chunk within a
5074
* completion string.
5075
*
5076
* \param completion_string the completion string to query.
5077
*
5078
* \param chunk_number the 0-based index of the chunk in the completion string.
5079
*
5080
* \returns the text associated with the chunk at index \c chunk_number.
5081
*/
5082
CINDEX_LINKAGE
CXString
clang_getCompletionChunkText
(
5083
CXCompletionString
completion_string,
unsigned
chunk_number);
5084
5085
/**
5086
* Retrieve the completion string associated with a particular chunk
5087
* within a completion string.
5088
*
5089
* \param completion_string the completion string to query.
5090
*
5091
* \param chunk_number the 0-based index of the chunk in the completion string.
5092
*
5093
* \returns the completion string associated with the chunk at index
5094
* \c chunk_number.
5095
*/
5096
CINDEX_LINKAGE
CXCompletionString
clang_getCompletionChunkCompletionString
(
5097
CXCompletionString
completion_string,
unsigned
chunk_number);
5098
5099
/**
5100
* Retrieve the number of chunks in the given code-completion string.
5101
*/
5102
CINDEX_LINKAGE
unsigned
5103
clang_getNumCompletionChunks
(
CXCompletionString
completion_string);
5104
5105
/**
5106
* Determine the priority of this code completion.
5107
*
5108
* The priority of a code completion indicates how likely it is that this
5109
* particular completion is the completion that the user will select. The
5110
* priority is selected by various internal heuristics.
5111
*
5112
* \param completion_string The completion string to query.
5113
*
5114
* \returns The priority of this completion string. Smaller values indicate
5115
* higher-priority (more likely) completions.
5116
*/
5117
CINDEX_LINKAGE
unsigned
5118
clang_getCompletionPriority
(
CXCompletionString
completion_string);
5119
5120
/**
5121
* Determine the availability of the entity that this code-completion
5122
* string refers to.
5123
*
5124
* \param completion_string The completion string to query.
5125
*
5126
* \returns The availability of the completion string.
5127
*/
5128
CINDEX_LINKAGE
enum
CXAvailabilityKind
5129
clang_getCompletionAvailability
(
CXCompletionString
completion_string);
5130
5131
/**
5132
* Retrieve the number of annotations associated with the given
5133
* completion string.
5134
*
5135
* \param completion_string the completion string to query.
5136
*
5137
* \returns the number of annotations associated with the given completion
5138
* string.
5139
*/
5140
CINDEX_LINKAGE
unsigned
5141
clang_getCompletionNumAnnotations
(
CXCompletionString
completion_string);
5142
5143
/**
5144
* Retrieve the annotation associated with the given completion string.
5145
*
5146
* \param completion_string the completion string to query.
5147
*
5148
* \param annotation_number the 0-based index of the annotation of the
5149
* completion string.
5150
*
5151
* \returns annotation string associated with the completion at index
5152
* \c annotation_number, or a NULL string if that annotation is not available.
5153
*/
5154
CINDEX_LINKAGE
CXString
clang_getCompletionAnnotation
(
5155
CXCompletionString
completion_string,
unsigned
annotation_number);
5156
5157
/**
5158
* Retrieve the parent context of the given completion string.
5159
*
5160
* The parent context of a completion string is the semantic parent of
5161
* the declaration (if any) that the code completion represents. For example,
5162
* a code completion for an Objective-C method would have the method's class
5163
* or protocol as its context.
5164
*
5165
* \param completion_string The code completion string whose parent is
5166
* being queried.
5167
*
5168
* \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5169
*
5170
* \returns The name of the completion parent, e.g., "NSObject" if
5171
* the completion string represents a method in the NSObject class.
5172
*/
5173
CINDEX_LINKAGE
CXString
clang_getCompletionParent
(
5174
CXCompletionString
completion_string,
enum
CXCursorKind
*kind);
5175
5176
/**
5177
* Retrieve the brief documentation comment attached to the declaration
5178
* that corresponds to the given completion string.
5179
*/
5180
CINDEX_LINKAGE
CXString
5181
clang_getCompletionBriefComment
(
CXCompletionString
completion_string);
5182
5183
/**
5184
* Retrieve a completion string for an arbitrary declaration or macro
5185
* definition cursor.
5186
*
5187
* \param cursor The cursor to query.
5188
*
5189
* \returns A non-context-sensitive completion string for declaration and macro
5190
* definition cursors, or NULL for other kinds of cursors.
5191
*/
5192
CINDEX_LINKAGE
CXCompletionString
5193
clang_getCursorCompletionString
(
CXCursor
cursor);
5194
5195
/**
5196
* Contains the results of code-completion.
5197
*
5198
* This data structure contains the results of code completion, as
5199
* produced by \c clang_codeCompleteAt(). Its contents must be freed by
5200
* \c clang_disposeCodeCompleteResults.
5201
*/
5202
typedef
struct
{
5203
/**
5204
* The code-completion results.
5205
*/
5206
CXCompletionResult
*
Results<