blob: fe0e70b4f41295f9aee9dc7551ca8bf799581e4d [file] [log] [blame]
Ted Kremenekb60d87c2009-08-26 22:36:44 +00001/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2|* *|
3|* The LLVM Compiler Infrastructure *|
4|* *|
5|* This file is distributed under the University of Illinois Open Source *|
6|* License. See LICENSE.TXT for details. *|
7|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
Marc-Andre Laperlef9abd402017-06-16 20:58:26 +000010|* This header provides a public interface to a Clang library for extracting *|
Ted Kremenekb60d87c2009-08-26 22:36:44 +000011|* high-level symbol information from source files without exposing the full *|
12|* Clang C++ API. *|
13|* *|
14\*===----------------------------------------------------------------------===*/
15
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000016#ifndef LLVM_CLANG_C_INDEX_H
17#define LLVM_CLANG_C_INDEX_H
Ted Kremenekb60d87c2009-08-26 22:36:44 +000018
Chandler Carruthaacafe52009-12-17 09:27:29 +000019#include <time.h>
Steve Naroff6231f182009-10-27 14:35:18 +000020
Arnaud A. de Grandmaison0271b322012-06-28 22:01:06 +000021#include "clang-c/Platform.h"
Argyrios Kyrtzidis0b9682e2014-02-25 03:59:23 +000022#include "clang-c/CXErrorCode.h"
Arnaud A. de Grandmaison0271b322012-06-28 22:01:06 +000023#include "clang-c/CXString.h"
Argyrios Kyrtzidis09a439d2014-02-25 03:59:16 +000024#include "clang-c/BuildSystem.h"
Arnaud A. de Grandmaison0271b322012-06-28 22:01:06 +000025
Argyrios Kyrtzidis1c4db8d2012-11-06 21:21:49 +000026/**
27 * \brief The version constants for the libclang API.
28 * CINDEX_VERSION_MINOR should increase when there are API additions.
29 * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
30 *
31 * The policy about the libclang API was always to keep it source and ABI
32 * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
33 */
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000034#define CINDEX_VERSION_MAJOR 0
Argyrios Kyrtzidis735e92c2017-06-09 01:20:48 +000035#define CINDEX_VERSION_MINOR 43
Argyrios Kyrtzidis5b216ed2012-10-29 23:24:44 +000036
37#define CINDEX_VERSION_ENCODE(major, minor) ( \
38 ((major) * 10000) \
39 + ((minor) * 1))
40
41#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
42 CINDEX_VERSION_MAJOR, \
43 CINDEX_VERSION_MINOR )
44
45#define CINDEX_VERSION_STRINGIZE_(major, minor) \
46 #major"."#minor
47#define CINDEX_VERSION_STRINGIZE(major, minor) \
48 CINDEX_VERSION_STRINGIZE_(major, minor)
49
50#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
51 CINDEX_VERSION_MAJOR, \
52 CINDEX_VERSION_MINOR)
53
Ted Kremenekb60d87c2009-08-26 22:36:44 +000054#ifdef __cplusplus
55extern "C" {
56#endif
57
Douglas Gregor4a4e0eb2011-02-23 17:45:25 +000058/** \defgroup CINDEX libclang: C Interface to Clang
Douglas Gregor52606ff2010-01-20 01:10:47 +000059 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000060 * The C Interface to Clang provides a relatively small API that exposes
Douglas Gregorc8e390c2010-01-20 22:45:41 +000061 * facilities for parsing source code into an abstract syntax tree (AST),
62 * loading already-parsed ASTs, traversing the AST, associating
63 * physical source locations with elements within the AST, and other
64 * facilities that support Clang-based development tools.
Douglas Gregor52606ff2010-01-20 01:10:47 +000065 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +000066 * This C interface to Clang will never provide all of the information
Douglas Gregorc8e390c2010-01-20 22:45:41 +000067 * representation stored in Clang's C++ AST, nor should it: the intent is to
68 * maintain an API that is relatively stable from one release to the next,
69 * providing only the basic functionality needed to support development tools.
Daniel Dunbar62ebf252010-01-24 02:54:26 +000070 *
71 * To avoid namespace pollution, data types are prefixed with "CX" and
Douglas Gregorc8e390c2010-01-20 22:45:41 +000072 * functions are prefixed with "clang_".
Douglas Gregor52606ff2010-01-20 01:10:47 +000073 *
74 * @{
75 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +000076
Douglas Gregor802f12f2010-01-20 22:28:27 +000077/**
78 * \brief An "index" that consists of a set of translation units that would
79 * typically be linked together into an executable or library.
80 */
81typedef void *CXIndex;
Steve Naroffd5e8e862009-08-27 19:51:58 +000082
Douglas Gregor802f12f2010-01-20 22:28:27 +000083/**
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +000084 * \brief An opaque type representing target information for a given translation
85 * unit.
86 */
87typedef struct CXTargetInfoImpl *CXTargetInfo;
88
89/**
Douglas Gregor802f12f2010-01-20 22:28:27 +000090 * \brief A single translation unit, which resides in an index.
91 */
Ted Kremenek7df92ae2010-11-17 23:24:11 +000092typedef struct CXTranslationUnitImpl *CXTranslationUnit;
Steve Naroffd5e8e862009-08-27 19:51:58 +000093
Douglas Gregor802f12f2010-01-20 22:28:27 +000094/**
Douglas Gregor6007cf22010-01-22 22:29:16 +000095 * \brief Opaque pointer representing client data that will be passed through
96 * to various callbacks and visitors.
Douglas Gregor802f12f2010-01-20 22:28:27 +000097 */
Douglas Gregor6007cf22010-01-22 22:29:16 +000098typedef void *CXClientData;
Daniel Dunbar62ebf252010-01-24 02:54:26 +000099
Douglas Gregor9485bf92009-12-02 09:21:34 +0000100/**
101 * \brief Provides the contents of a file that has not yet been saved to disk.
102 *
103 * Each CXUnsavedFile instance provides the name of a file on the
104 * system along with the current contents of that file that have not
105 * yet been saved to disk.
106 */
107struct CXUnsavedFile {
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000108 /**
109 * \brief The file whose contents have not yet been saved.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000110 *
111 * This file must already exist in the file system.
112 */
113 const char *Filename;
114
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000115 /**
Douglas Gregor89a56c52010-02-27 01:32:48 +0000116 * \brief A buffer containing the unsaved contents of this file.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000117 */
118 const char *Contents;
119
120 /**
Douglas Gregor89a56c52010-02-27 01:32:48 +0000121 * \brief The length of the unsaved contents of this buffer.
Douglas Gregor9485bf92009-12-02 09:21:34 +0000122 */
123 unsigned long Length;
124};
125
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000126/**
127 * \brief Describes the availability of a particular entity, which indicates
128 * whether the use of this entity will result in a warning or error due to
129 * it being deprecated or unavailable.
130 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000131enum CXAvailabilityKind {
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000132 /**
133 * \brief The entity is available.
134 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000135 CXAvailability_Available,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000136 /**
137 * \brief The entity is available, but has been deprecated (and its use is
138 * not recommended).
139 */
Douglas Gregorf757a122010-08-23 23:00:57 +0000140 CXAvailability_Deprecated,
Peter Collingbourne5caf5af2010-08-24 00:31:37 +0000141 /**
142 * \brief The entity is not available; any use of it will be an error.
143 */
Erik Verbruggen2e657ff2011-10-06 07:27:49 +0000144 CXAvailability_NotAvailable,
145 /**
146 * \brief The entity is available, but not accessible; any use of it will be
147 * an error.
148 */
149 CXAvailability_NotAccessible
Douglas Gregorf757a122010-08-23 23:00:57 +0000150};
Douglas Gregord6225d32012-05-08 00:14:45 +0000151
152/**
153 * \brief Describes a version number of the form major.minor.subminor.
154 */
155typedef struct CXVersion {
156 /**
157 * \brief The major version number, e.g., the '10' in '10.7.3'. A negative
158 * value indicates that there is no version number at all.
159 */
160 int Major;
161 /**
162 * \brief The minor version number, e.g., the '7' in '10.7.3'. This value
163 * will be negative if no minor version number was provided, e.g., for
164 * version '10'.
165 */
166 int Minor;
167 /**
168 * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value
169 * will be negative if no minor or subminor version number was provided,
170 * e.g., in version '10' or '10.7'.
171 */
172 int Subminor;
173} CXVersion;
Jonathan Coe0a5b03b2017-06-27 22:54:56 +0000174
175/**
176 * \brief Describes the exception specification of a cursor.
177 *
178 * A negative value indicates that the cursor is not a function declaration.
179 */
180enum CXCursor_ExceptionSpecificationKind {
181
182 /**
183 * \brief The cursor has no exception specification.
184 */
185 CXCursor_ExceptionSpecificationKind_None,
186
187 /**
188 * \brief The cursor has exception specification throw()
189 */
190 CXCursor_ExceptionSpecificationKind_DynamicNone,
191
192 /**
193 * \brief The cursor has exception specification throw(T1, T2)
194 */
195 CXCursor_ExceptionSpecificationKind_Dynamic,
196
197 /**
198 * \brief The cursor has exception specification throw(...).
199 */
200 CXCursor_ExceptionSpecificationKind_MSAny,
201
202 /**
203 * \brief The cursor has exception specification basic noexcept.
204 */
205 CXCursor_ExceptionSpecificationKind_BasicNoexcept,
206
207 /**
208 * \brief The cursor has exception specification computed noexcept.
209 */
210 CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
211
212 /**
213 * \brief The exception specification has not yet been evaluated.
214 */
215 CXCursor_ExceptionSpecificationKind_Unevaluated,
216
217 /**
218 * \brief The exception specification has not yet been instantiated.
219 */
220 CXCursor_ExceptionSpecificationKind_Uninstantiated,
221
222 /**
223 * \brief The exception specification has not been parsed yet.
224 */
225 CXCursor_ExceptionSpecificationKind_Unparsed
226};
227
Douglas Gregor802f12f2010-01-20 22:28:27 +0000228/**
James Dennett574cb4c2012-06-15 05:41:51 +0000229 * \brief Provides a shared context for creating translation units.
230 *
231 * It provides two options:
Steve Naroff531e2842009-10-20 14:46:24 +0000232 *
233 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
234 * declarations (when loading any new translation units). A "local" declaration
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000235 * is one that belongs in the translation unit itself and not in a precompiled
Steve Naroff531e2842009-10-20 14:46:24 +0000236 * header that was used by the translation unit. If zero, all declarations
237 * will be enumerated.
238 *
Steve Naroffbb4568a2009-10-20 16:36:34 +0000239 * Here is an example:
240 *
James Dennett574cb4c2012-06-15 05:41:51 +0000241 * \code
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000242 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
243 * Idx = clang_createIndex(1, 1);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000244 *
245 * // IndexTest.pch was produced with the following command:
246 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
247 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
248 *
249 * // This will load all the symbols from 'IndexTest.pch'
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000250 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
Douglas Gregor990b5762010-01-20 21:37:00 +0000251 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000252 * clang_disposeTranslationUnit(TU);
253 *
254 * // This will load all the symbols from 'IndexTest.c', excluding symbols
255 * // from 'IndexTest.pch'.
Daniel Dunbard0159262010-01-25 00:43:14 +0000256 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
257 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
258 * 0, 0);
Douglas Gregorfed36b12010-01-20 23:57:43 +0000259 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
260 * TranslationUnitVisitor, 0);
Steve Naroffbb4568a2009-10-20 16:36:34 +0000261 * clang_disposeTranslationUnit(TU);
James Dennett574cb4c2012-06-15 05:41:51 +0000262 * \endcode
Steve Naroffbb4568a2009-10-20 16:36:34 +0000263 *
264 * This process of creating the 'pch', loading it separately, and using it (via
265 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
266 * (which gives the indexer the same performance benefit as the compiler).
Steve Naroff531e2842009-10-20 14:46:24 +0000267 */
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000268CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
269 int displayDiagnostics);
Ted Kremenekd071c602010-03-13 02:50:34 +0000270
Douglas Gregor408bb742010-02-08 23:03:06 +0000271/**
272 * \brief Destroy the given index.
273 *
274 * The index must not be destroyed until all of the translation units created
275 * within that index have been destroyed.
276 */
Daniel Dunbar11089662009-12-03 01:54:28 +0000277CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000278
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000279typedef enum {
280 /**
281 * \brief Used to indicate that no special CXIndex options are needed.
282 */
283 CXGlobalOpt_None = 0x0,
284
285 /**
286 * \brief Used to indicate that threads that libclang creates for indexing
287 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000288 *
289 * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
290 * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000291 */
292 CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
293
294 /**
295 * \brief Used to indicate that threads that libclang creates for editing
296 * purposes should use background priority.
James Dennett574cb4c2012-06-15 05:41:51 +0000297 *
298 * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
299 * #clang_annotateTokens
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000300 */
301 CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
302
303 /**
304 * \brief Used to indicate that all threads that libclang creates should use
305 * background priority.
306 */
307 CXGlobalOpt_ThreadBackgroundPriorityForAll =
308 CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
309 CXGlobalOpt_ThreadBackgroundPriorityForEditing
310
311} CXGlobalOptFlags;
312
313/**
James Dennett574cb4c2012-06-15 05:41:51 +0000314 * \brief Sets general options associated with a CXIndex.
Argyrios Kyrtzidis7317a5c2012-03-28 02:18:05 +0000315 *
316 * For example:
317 * \code
318 * CXIndex idx = ...;
319 * clang_CXIndex_setGlobalOptions(idx,
320 * clang_CXIndex_getGlobalOptions(idx) |
321 * CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
322 * \endcode
323 *
324 * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
325 */
326CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
327
328/**
329 * \brief Gets the general options associated with a CXIndex.
330 *
331 * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
332 * are associated with the given CXIndex object.
333 */
334CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
335
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000336/**
Alex Lorenz08615792017-12-04 21:56:36 +0000337 * \brief Sets the invocation emission path option in a CXIndex.
338 *
339 * The invocation emission path specifies a path which will contain log
340 * files for certain libclang invocations. A null value (default) implies that
341 * libclang invocations are not logged..
342 */
343CINDEX_LINKAGE void
344clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
345
346/**
Douglas Gregor6007cf22010-01-22 22:29:16 +0000347 * \defgroup CINDEX_FILES File manipulation routines
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000348 *
349 * @{
350 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000351
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000352/**
353 * \brief A particular source file that is part of a translation unit.
354 */
355typedef void *CXFile;
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000356
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000357/**
358 * \brief Retrieve the complete file and path name of the given file.
Steve Naroff6231f182009-10-27 14:35:18 +0000359 */
Ted Kremenekc560b682010-02-17 00:41:20 +0000360CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000361
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000362/**
363 * \brief Retrieve the last modification time of the given file.
364 */
Douglas Gregor249c1212009-10-31 15:48:08 +0000365CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
Steve Naroff6231f182009-10-27 14:35:18 +0000366
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000367/**
Argyrios Kyrtzidisac08b262013-01-26 04:52:52 +0000368 * \brief Uniquely identifies a CXFile, that refers to the same underlying file,
369 * across an indexing session.
370 */
371typedef struct {
372 unsigned long long data[3];
373} CXFileUniqueID;
374
375/**
376 * \brief Retrieve the unique ID for the given \c file.
377 *
378 * \param file the file to get the ID for.
379 * \param outID stores the returned CXFileUniqueID.
380 * \returns If there was a failure getting the unique ID, returns non-zero,
381 * otherwise returns 0.
382*/
383CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
384
385/**
Douglas Gregor37aa4932011-05-04 00:14:37 +0000386 * \brief Determine whether the given header is guarded against
387 * multiple inclusions, either with the conventional
James Dennett574cb4c2012-06-15 05:41:51 +0000388 * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
Douglas Gregor37aa4932011-05-04 00:14:37 +0000389 */
390CINDEX_LINKAGE unsigned
391clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
392
393/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000394 * \brief Retrieve a file handle within the given translation unit.
395 *
396 * \param tu the translation unit
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000397 *
Samuel Antao4c8035b2016-12-12 18:00:20 +0000398 * \param file_name the name of the file.
Douglas Gregor816fd362010-01-22 21:44:22 +0000399 *
400 * \returns the file handle for the named file in the translation unit \p tu,
401 * or a NULL file handle if the file was not a part of this translation unit.
402 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000403CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
Douglas Gregor816fd362010-01-22 21:44:22 +0000404 const char *file_name);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000405
Douglas Gregor816fd362010-01-22 21:44:22 +0000406/**
Argyrios Kyrtzidisac3997e2014-08-16 00:26:19 +0000407 * \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
408 * or they are both NULL.
409 */
410CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
411
412/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000413 * @}
414 */
415
416/**
417 * \defgroup CINDEX_LOCATIONS Physical source locations
418 *
419 * Clang represents physical source locations in its abstract syntax tree in
420 * great detail, with file, line, and column information for the majority of
421 * the tokens parsed in the source code. These data types and functions are
422 * used to represent source location information, either for a particular
423 * point in the program or for a range of points in the program, and extract
424 * specific location information from those data types.
425 *
426 * @{
427 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000428
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000429/**
Douglas Gregor4f46e782010-01-19 21:36:55 +0000430 * \brief Identifies a specific source location within a translation
431 * unit.
432 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000433 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
Douglas Gregor229bebd2010-11-09 06:24:54 +0000434 * to map a source location to a particular file, line, and column.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000435 */
436typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000437 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000438 unsigned int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000439} CXSourceLocation;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000440
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000441/**
Daniel Dunbar02968e52010-02-14 10:02:57 +0000442 * \brief Identifies a half-open character range in the source code.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000443 *
Douglas Gregor4f46e782010-01-19 21:36:55 +0000444 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
445 * starting and end locations from a source range, respectively.
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000446 */
447typedef struct {
Argyrios Kyrtzidis49d9d0292013-01-11 22:29:47 +0000448 const void *ptr_data[2];
Douglas Gregor4f46e782010-01-19 21:36:55 +0000449 unsigned begin_int_data;
450 unsigned end_int_data;
Douglas Gregor49c4baf2010-01-18 22:13:09 +0000451} CXSourceRange;
Ted Kremeneka44d99c2010-01-05 23:18:49 +0000452
Douglas Gregor4f46e782010-01-19 21:36:55 +0000453/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000454 * \brief Retrieve a NULL (invalid) source location.
455 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000456CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000457
Douglas Gregor816fd362010-01-22 21:44:22 +0000458/**
James Dennett574cb4c2012-06-15 05:41:51 +0000459 * \brief Determine whether two source locations, which must refer into
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000460 * the same translation unit, refer to exactly the same point in the source
Douglas Gregor816fd362010-01-22 21:44:22 +0000461 * code.
462 *
463 * \returns non-zero if the source locations refer to the same location, zero
464 * if they refer to different locations.
465 */
466CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
467 CXSourceLocation loc2);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000468
Douglas Gregor816fd362010-01-22 21:44:22 +0000469/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000470 * \brief Retrieves the source location associated with a given file/line/column
471 * in a particular translation unit.
Douglas Gregor816fd362010-01-22 21:44:22 +0000472 */
473CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
474 CXFile file,
475 unsigned line,
476 unsigned column);
David Chisnall2e16ac52010-10-15 17:07:39 +0000477/**
478 * \brief Retrieves the source location associated with a given character offset
479 * in a particular translation unit.
480 */
481CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
482 CXFile file,
483 unsigned offset);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000484
Douglas Gregor816fd362010-01-22 21:44:22 +0000485/**
Argyrios Kyrtzidis25f7af12013-04-12 17:06:51 +0000486 * \brief Returns non-zero if the given source location is in a system header.
487 */
488CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
489
490/**
Stefanus Du Toitdb51c632013-08-08 17:48:14 +0000491 * \brief Returns non-zero if the given source location is in the main file of
492 * the corresponding translation unit.
493 */
494CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
495
496/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000497 * \brief Retrieve a NULL (invalid) source range.
498 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +0000499CINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
Ted Kremenekd071c602010-03-13 02:50:34 +0000500
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000501/**
Douglas Gregor816fd362010-01-22 21:44:22 +0000502 * \brief Retrieve a source range given the beginning and ending source
503 * locations.
504 */
505CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
506 CXSourceLocation end);
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000507
Douglas Gregor816fd362010-01-22 21:44:22 +0000508/**
Douglas Gregor757e38b2011-07-23 19:35:14 +0000509 * \brief Determine whether two ranges are equivalent.
510 *
511 * \returns non-zero if the ranges are the same, zero if they differ.
512 */
513CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
514 CXSourceRange range2);
515
516/**
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +0000517 * \brief Returns non-zero if \p range is null.
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000518 */
Erik Verbruggend610b0f2011-10-06 12:11:57 +0000519CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
Argyrios Kyrtzidise7e42912011-09-28 18:14:21 +0000520
521/**
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000522 * \brief Retrieve the file, line, column, and offset represented by
523 * the given source location.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000524 *
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000525 * If the location refers into a macro expansion, retrieves the
526 * location of the macro expansion.
Douglas Gregor229bebd2010-11-09 06:24:54 +0000527 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000528 * \param location the location within a source file that will be decomposed
529 * into its parts.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000530 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000531 * \param file [out] if non-NULL, will be set to the file to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000532 * source location points.
533 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000534 * \param line [out] if non-NULL, will be set to the line to which the given
Douglas Gregor4f46e782010-01-19 21:36:55 +0000535 * source location points.
536 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000537 * \param column [out] if non-NULL, will be set to the column to which the given
538 * source location points.
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000539 *
540 * \param offset [out] if non-NULL, will be set to the offset into the
541 * buffer to which the given source location points.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000542 */
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000543CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
544 CXFile *file,
545 unsigned *line,
546 unsigned *column,
547 unsigned *offset);
548
549/**
Vassil Vassilev4b8e29d2017-04-06 10:05:46 +0000550 * \brief Retrieve the file, line and column represented by the given source
551 * location, as specified in a # line directive.
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000552 *
553 * Example: given the following source code in a file somefile.c
554 *
James Dennett574cb4c2012-06-15 05:41:51 +0000555 * \code
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000556 * #123 "dummy.c" 1
557 *
558 * static int func(void)
559 * {
560 * return 0;
561 * }
James Dennett574cb4c2012-06-15 05:41:51 +0000562 * \endcode
Argyrios Kyrtzidis91672b32011-09-13 21:49:08 +0000563 *
564 * the location information returned by this function would be
565 *
566 * File: dummy.c Line: 124 Column: 12
567 *
568 * whereas clang_getExpansionLocation would have returned
569 *
570 * File: somefile.c Line: 3 Column: 12
571 *
572 * \param location the location within a source file that will be decomposed
573 * into its parts.
574 *
575 * \param filename [out] if non-NULL, will be set to the filename of the
576 * source location. Note that filenames returned will be for "virtual" files,
577 * which don't necessarily exist on the machine running clang - e.g. when
578 * parsing preprocessed output obtained from a different environment. If
579 * a non-NULL value is passed in, remember to dispose of the returned value
580 * using \c clang_disposeString() once you've finished with it. For an invalid
581 * source location, an empty string is returned.
582 *
583 * \param line [out] if non-NULL, will be set to the line number of the
584 * source location. For an invalid source location, zero is returned.
585 *
586 * \param column [out] if non-NULL, will be set to the column number of the
587 * source location. For an invalid source location, zero is returned.
588 */
589CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
590 CXString *filename,
591 unsigned *line,
592 unsigned *column);
593
594/**
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000595 * \brief Legacy API to retrieve the file, line, column, and offset represented
596 * by the given source location.
597 *
598 * This interface has been replaced by the newer interface
James Dennett574cb4c2012-06-15 05:41:51 +0000599 * #clang_getExpansionLocation(). See that interface's documentation for
Chandler Carruth4aa01ef2011-08-31 16:53:37 +0000600 * details.
601 */
Douglas Gregor4f46e782010-01-19 21:36:55 +0000602CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
603 CXFile *file,
604 unsigned *line,
Douglas Gregor9bd6db52010-01-26 19:19:08 +0000605 unsigned *column,
606 unsigned *offset);
Douglas Gregor47751d62010-01-26 03:07:15 +0000607
608/**
Douglas Gregor229bebd2010-11-09 06:24:54 +0000609 * \brief Retrieve the file, line, column, and offset represented by
610 * the given source location.
611 *
612 * If the location refers into a macro instantiation, return where the
613 * location was originally spelled in the source file.
614 *
615 * \param location the location within a source file that will be decomposed
616 * into its parts.
617 *
618 * \param file [out] if non-NULL, will be set to the file to which the given
619 * source location points.
620 *
621 * \param line [out] if non-NULL, will be set to the line to which the given
622 * source location points.
623 *
624 * \param column [out] if non-NULL, will be set to the column to which the given
625 * source location points.
626 *
627 * \param offset [out] if non-NULL, will be set to the offset into the
628 * buffer to which the given source location points.
629 */
630CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
631 CXFile *file,
632 unsigned *line,
633 unsigned *column,
634 unsigned *offset);
635
636/**
Argyrios Kyrtzidis56be7162013-01-04 18:30:13 +0000637 * \brief Retrieve the file, line, column, and offset represented by
638 * the given source location.
639 *
640 * If the location refers into a macro expansion, return where the macro was
641 * expanded or where the macro argument was written, if the location points at
642 * a macro argument.
643 *
644 * \param location the location within a source file that will be decomposed
645 * into its parts.
646 *
647 * \param file [out] if non-NULL, will be set to the file to which the given
648 * source location points.
649 *
650 * \param line [out] if non-NULL, will be set to the line to which the given
651 * source location points.
652 *
653 * \param column [out] if non-NULL, will be set to the column to which the given
654 * source location points.
655 *
656 * \param offset [out] if non-NULL, will be set to the offset into the
657 * buffer to which the given source location points.
658 */
659CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
660 CXFile *file,
661 unsigned *line,
662 unsigned *column,
663 unsigned *offset);
664
665/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000666 * \brief Retrieve a source location representing the first character within a
667 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000668 */
669CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
670
671/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +0000672 * \brief Retrieve a source location representing the last character within a
673 * source range.
Douglas Gregor4f46e782010-01-19 21:36:55 +0000674 */
675CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
676
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000677/**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000678 * \brief Identifies an array of ranges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000679 */
680typedef struct {
681 /** \brief The number of ranges in the \c ranges array. */
682 unsigned count;
683 /**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000684 * \brief An array of \c CXSourceRanges.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000685 */
686 CXSourceRange *ranges;
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000687} CXSourceRangeList;
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000688
689/**
690 * \brief Retrieve all ranges that were skipped by the preprocessor.
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000691 *
692 * The preprocessor will skip lines when they are surrounded by an
693 * if/ifdef/ifndef directive whose condition does not evaluate to true.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000694 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000695CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
696 CXFile file);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000697
698/**
Cameron Desrochersd8091282016-08-18 15:43:55 +0000699 * \brief Retrieve all ranges from all files that were skipped by the
700 * preprocessor.
701 *
702 * The preprocessor will skip lines when they are surrounded by an
703 * if/ifdef/ifndef directive whose condition does not evaluate to true.
704 */
705CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
706
707/**
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000708 * \brief Destroy the given \c CXSourceRangeList.
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000709 */
Argyrios Kyrtzidis0e282ef2013-12-06 18:55:45 +0000710CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
Argyrios Kyrtzidis9ef57752013-12-05 08:19:32 +0000711
712/**
Douglas Gregorc8e390c2010-01-20 22:45:41 +0000713 * @}
714 */
Douglas Gregor6007cf22010-01-22 22:29:16 +0000715
716/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000717 * \defgroup CINDEX_DIAG Diagnostic reporting
718 *
719 * @{
720 */
721
722/**
723 * \brief Describes the severity of a particular diagnostic.
724 */
725enum CXDiagnosticSeverity {
726 /**
Ted Kremenekd071c602010-03-13 02:50:34 +0000727 * \brief A diagnostic that has been suppressed, e.g., by a command-line
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000728 * option.
729 */
730 CXDiagnostic_Ignored = 0,
Ted Kremenekd071c602010-03-13 02:50:34 +0000731
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000732 /**
733 * \brief This diagnostic is a note that should be attached to the
734 * previous (non-note) diagnostic.
735 */
736 CXDiagnostic_Note = 1,
737
738 /**
739 * \brief This diagnostic indicates suspicious code that may not be
740 * wrong.
741 */
742 CXDiagnostic_Warning = 2,
743
744 /**
745 * \brief This diagnostic indicates that the code is ill-formed.
746 */
747 CXDiagnostic_Error = 3,
748
749 /**
750 * \brief This diagnostic indicates that the code is ill-formed such
751 * that future parser recovery is unlikely to produce useful
752 * results.
753 */
754 CXDiagnostic_Fatal = 4
755};
756
757/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000758 * \brief A single diagnostic, containing the diagnostic's severity,
759 * location, text, source ranges, and fix-it hints.
760 */
761typedef void *CXDiagnostic;
762
763/**
Ted Kremenekd010ba42011-11-10 08:43:12 +0000764 * \brief A group of CXDiagnostics.
765 */
766typedef void *CXDiagnosticSet;
767
768/**
769 * \brief Determine the number of diagnostics in a CXDiagnosticSet.
770 */
771CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
772
773/**
774 * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet.
775 *
James Dennett574cb4c2012-06-15 05:41:51 +0000776 * \param Diags the CXDiagnosticSet to query.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000777 * \param Index the zero-based diagnostic number to retrieve.
778 *
779 * \returns the requested diagnostic. This diagnostic must be freed
780 * via a call to \c clang_disposeDiagnostic().
781 */
782CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
783 unsigned Index);
784
Ted Kremenekd010ba42011-11-10 08:43:12 +0000785/**
786 * \brief Describes the kind of error that occurred (if any) in a call to
787 * \c clang_loadDiagnostics.
788 */
789enum CXLoadDiag_Error {
790 /**
791 * \brief Indicates that no error occurred.
792 */
793 CXLoadDiag_None = 0,
794
795 /**
796 * \brief Indicates that an unknown error occurred while attempting to
797 * deserialize diagnostics.
798 */
799 CXLoadDiag_Unknown = 1,
800
801 /**
802 * \brief Indicates that the file containing the serialized diagnostics
803 * could not be opened.
804 */
805 CXLoadDiag_CannotLoad = 2,
806
807 /**
808 * \brief Indicates that the serialized diagnostics file is invalid or
James Dennett574cb4c2012-06-15 05:41:51 +0000809 * corrupt.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000810 */
811 CXLoadDiag_InvalidFile = 3
812};
813
814/**
815 * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode
James Dennett574cb4c2012-06-15 05:41:51 +0000816 * file.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000817 *
James Dennett574cb4c2012-06-15 05:41:51 +0000818 * \param file The name of the file to deserialize.
819 * \param error A pointer to a enum value recording if there was a problem
Ted Kremenekd010ba42011-11-10 08:43:12 +0000820 * deserializing the diagnostics.
James Dennett574cb4c2012-06-15 05:41:51 +0000821 * \param errorString A pointer to a CXString for recording the error string
Ted Kremenekd010ba42011-11-10 08:43:12 +0000822 * if the file was not successfully loaded.
823 *
824 * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
James Dennett574cb4c2012-06-15 05:41:51 +0000825 * diagnostics should be released using clang_disposeDiagnosticSet().
Ted Kremenekd010ba42011-11-10 08:43:12 +0000826 */
827CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
828 enum CXLoadDiag_Error *error,
829 CXString *errorString);
830
831/**
832 * \brief Release a CXDiagnosticSet and all of its contained diagnostics.
833 */
834CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
835
836/**
James Dennett574cb4c2012-06-15 05:41:51 +0000837 * \brief Retrieve the child diagnostics of a CXDiagnostic.
838 *
839 * This CXDiagnosticSet does not need to be released by
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000840 * clang_disposeDiagnosticSet.
Ted Kremenekd010ba42011-11-10 08:43:12 +0000841 */
842CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
843
844/**
Douglas Gregor33cdd812010-02-18 18:08:43 +0000845 * \brief Determine the number of diagnostics produced for the given
846 * translation unit.
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000847 */
Douglas Gregor33cdd812010-02-18 18:08:43 +0000848CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
849
850/**
851 * \brief Retrieve a diagnostic associated with the given translation unit.
852 *
853 * \param Unit the translation unit to query.
854 * \param Index the zero-based diagnostic number to retrieve.
855 *
856 * \returns the requested diagnostic. This diagnostic must be freed
857 * via a call to \c clang_disposeDiagnostic().
858 */
859CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
860 unsigned Index);
861
862/**
Ted Kremenekb4a8b052011-12-09 22:28:32 +0000863 * \brief Retrieve the complete set of diagnostics associated with a
864 * translation unit.
865 *
866 * \param Unit the translation unit to query.
867 */
868CINDEX_LINKAGE CXDiagnosticSet
869 clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
870
871/**
Douglas Gregor33cdd812010-02-18 18:08:43 +0000872 * \brief Destroy a diagnostic.
873 */
874CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000875
876/**
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000877 * \brief Options to control the display of diagnostics.
878 *
879 * The values in this enum are meant to be combined to customize the
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000880 * behavior of \c clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000881 */
882enum CXDiagnosticDisplayOptions {
883 /**
884 * \brief Display the source-location information where the
885 * diagnostic was located.
886 *
887 * When set, diagnostics will be prefixed by the file, line, and
888 * (optionally) column to which the diagnostic refers. For example,
889 *
890 * \code
891 * test.c:28: warning: extra tokens at end of #endif directive
892 * \endcode
893 *
894 * This option corresponds to the clang flag \c -fshow-source-location.
895 */
896 CXDiagnostic_DisplaySourceLocation = 0x01,
897
898 /**
899 * \brief If displaying the source-location information of the
900 * diagnostic, also include the column number.
901 *
902 * This option corresponds to the clang flag \c -fshow-column.
903 */
904 CXDiagnostic_DisplayColumn = 0x02,
905
906 /**
907 * \brief If displaying the source-location information of the
908 * diagnostic, also include information about source ranges in a
909 * machine-parsable format.
910 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000911 * This option corresponds to the clang flag
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000912 * \c -fdiagnostics-print-source-range-info.
913 */
Douglas Gregora750e8e2010-11-19 16:18:16 +0000914 CXDiagnostic_DisplaySourceRanges = 0x04,
915
916 /**
917 * \brief Display the option name associated with this diagnostic, if any.
918 *
919 * The option name displayed (e.g., -Wconversion) will be placed in brackets
920 * after the diagnostic text. This option corresponds to the clang flag
921 * \c -fdiagnostics-show-option.
922 */
923 CXDiagnostic_DisplayOption = 0x08,
924
925 /**
926 * \brief Display the category number associated with this diagnostic, if any.
927 *
928 * The category number is displayed within brackets after the diagnostic text.
929 * This option corresponds to the clang flag
930 * \c -fdiagnostics-show-category=id.
931 */
932 CXDiagnostic_DisplayCategoryId = 0x10,
933
934 /**
935 * \brief Display the category name associated with this diagnostic, if any.
936 *
937 * The category name is displayed within brackets after the diagnostic text.
938 * This option corresponds to the clang flag
939 * \c -fdiagnostics-show-category=name.
940 */
941 CXDiagnostic_DisplayCategoryName = 0x20
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000942};
943
944/**
Douglas Gregord770f732010-02-22 23:17:23 +0000945 * \brief Format the given diagnostic in a manner that is suitable for display.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000946 *
Douglas Gregord770f732010-02-22 23:17:23 +0000947 * This routine will format the given diagnostic to a string, rendering
Ted Kremenekd071c602010-03-13 02:50:34 +0000948 * the diagnostic according to the various options given. The
949 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000950 * options that most closely mimics the behavior of the clang compiler.
951 *
952 * \param Diagnostic The diagnostic to print.
953 *
Ted Kremenekd071c602010-03-13 02:50:34 +0000954 * \param Options A set of options that control the diagnostic display,
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000955 * created by combining \c CXDiagnosticDisplayOptions values.
Douglas Gregord770f732010-02-22 23:17:23 +0000956 *
957 * \returns A new string containing for formatted diagnostic.
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000958 */
Douglas Gregord770f732010-02-22 23:17:23 +0000959CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
960 unsigned Options);
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000961
962/**
963 * \brief Retrieve the set of display options most similar to the
964 * default behavior of the clang compiler.
965 *
966 * \returns A set of display options suitable for use with \c
Sylvestre Ledrud29d97c2013-11-17 09:46:45 +0000967 * clang_formatDiagnostic().
Douglas Gregor1e21cc72010-02-18 23:07:20 +0000968 */
969CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
970
971/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000972 * \brief Determine the severity of the given diagnostic.
973 */
Ted Kremenekd071c602010-03-13 02:50:34 +0000974CINDEX_LINKAGE enum CXDiagnosticSeverity
Douglas Gregor4f9c3762010-01-28 00:27:43 +0000975clang_getDiagnosticSeverity(CXDiagnostic);
976
977/**
978 * \brief Retrieve the source location of the given diagnostic.
979 *
980 * This location is where Clang would print the caret ('^') when
981 * displaying the diagnostic on the command line.
982 */
983CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
984
985/**
986 * \brief Retrieve the text of the given diagnostic.
987 */
988CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +0000989
990/**
Douglas Gregora750e8e2010-11-19 16:18:16 +0000991 * \brief Retrieve the name of the command-line option that enabled this
992 * diagnostic.
993 *
994 * \param Diag The diagnostic to be queried.
995 *
996 * \param Disable If non-NULL, will be set to the option that disables this
997 * diagnostic (if any).
998 *
999 * \returns A string that contains the command-line option used to enable this
1000 * warning, such as "-Wconversion" or "-pedantic".
1001 */
1002CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1003 CXString *Disable);
1004
1005/**
1006 * \brief Retrieve the category number for this diagnostic.
1007 *
1008 * Diagnostics can be categorized into groups along with other, related
1009 * diagnostics (e.g., diagnostics under the same warning flag). This routine
1010 * retrieves the category number for the given diagnostic.
1011 *
1012 * \returns The number of the category that contains this diagnostic, or zero
1013 * if this diagnostic is uncategorized.
1014 */
1015CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1016
1017/**
Ted Kremenek26a6d492012-04-12 00:03:31 +00001018 * \brief Retrieve the name of a particular diagnostic category. This
1019 * is now deprecated. Use clang_getDiagnosticCategoryText()
1020 * instead.
Douglas Gregora750e8e2010-11-19 16:18:16 +00001021 *
1022 * \param Category A diagnostic category number, as returned by
1023 * \c clang_getDiagnosticCategory().
1024 *
1025 * \returns The name of the given diagnostic category.
1026 */
Ted Kremenek26a6d492012-04-12 00:03:31 +00001027CINDEX_DEPRECATED CINDEX_LINKAGE
1028CXString clang_getDiagnosticCategoryName(unsigned Category);
1029
1030/**
1031 * \brief Retrieve the diagnostic category text for a given diagnostic.
1032 *
Ted Kremenek26a6d492012-04-12 00:03:31 +00001033 * \returns The text of the given diagnostic category.
1034 */
1035CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
Douglas Gregora750e8e2010-11-19 16:18:16 +00001036
1037/**
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001038 * \brief Determine the number of source ranges associated with the given
1039 * diagnostic.
1040 */
1041CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
Ted Kremenekd071c602010-03-13 02:50:34 +00001042
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001043/**
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001044 * \brief Retrieve a source range associated with the diagnostic.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001045 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001046 * A diagnostic's source ranges highlight important elements in the source
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001047 * code. On the command line, Clang displays source ranges by
Ted Kremenekd071c602010-03-13 02:50:34 +00001048 * underlining them with '~' characters.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001049 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001050 * \param Diagnostic the diagnostic whose range is being extracted.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001051 *
Ted Kremenekd071c602010-03-13 02:50:34 +00001052 * \param Range the zero-based index specifying which range to
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001053 *
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001054 * \returns the requested source range.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001055 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001056CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
Douglas Gregor4b8fd6d2010-02-08 23:11:56 +00001057 unsigned Range);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001058
1059/**
1060 * \brief Determine the number of fix-it hints associated with the
1061 * given diagnostic.
1062 */
1063CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1064
1065/**
Douglas Gregor836ec942010-02-19 18:16:06 +00001066 * \brief Retrieve the replacement information for a given fix-it.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001067 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001068 * Fix-its are described in terms of a source range whose contents
1069 * should be replaced by a string. This approach generalizes over
1070 * three kinds of operations: removal of source code (the range covers
1071 * the code to be removed and the replacement string is empty),
1072 * replacement of source code (the range covers the code to be
1073 * replaced and the replacement string provides the new code), and
1074 * insertion (both the start and end of the range point at the
1075 * insertion location, and the replacement string provides the text to
1076 * insert).
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001077 *
Douglas Gregor836ec942010-02-19 18:16:06 +00001078 * \param Diagnostic The diagnostic whose fix-its are being queried.
1079 *
1080 * \param FixIt The zero-based index of the fix-it.
1081 *
1082 * \param ReplacementRange The source range whose contents will be
1083 * replaced with the returned replacement string. Note that source
1084 * ranges are half-open ranges [a, b), so the source code should be
1085 * replaced from a and up to (but not including) b.
1086 *
1087 * \returns A string containing text that should be replace the source
1088 * code indicated by the \c ReplacementRange.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001089 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001090CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
Douglas Gregor836ec942010-02-19 18:16:06 +00001091 unsigned FixIt,
1092 CXSourceRange *ReplacementRange);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001093
1094/**
1095 * @}
1096 */
1097
1098/**
1099 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1100 *
1101 * The routines in this group provide the ability to create and destroy
1102 * translation units from files, either by parsing the contents of the files or
1103 * by reading in a serialized representation of a translation unit.
1104 *
1105 * @{
1106 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001107
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001108/**
1109 * \brief Get the original translation unit source file name.
1110 */
1111CINDEX_LINKAGE CXString
1112clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1113
1114/**
1115 * \brief Return the CXTranslationUnit for a given source file and the provided
1116 * command line arguments one would pass to the compiler.
1117 *
1118 * Note: The 'source_filename' argument is optional. If the caller provides a
1119 * NULL pointer, the name of the source file is expected to reside in the
1120 * specified command line arguments.
1121 *
1122 * Note: When encountered in 'clang_command_line_args', the following options
1123 * are ignored:
1124 *
1125 * '-c'
1126 * '-emit-ast'
1127 * '-fsyntax-only'
James Dennett574cb4c2012-06-15 05:41:51 +00001128 * '-o \<output file>' (both '-o' and '\<output file>' are ignored)
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001129 *
Ted Kremenekbd4972442010-11-08 04:28:51 +00001130 * \param CIdx The index object with which the translation unit will be
1131 * associated.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001132 *
James Dennett574cb4c2012-06-15 05:41:51 +00001133 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenekbd4972442010-11-08 04:28:51 +00001134 * source file is included in \p clang_command_line_args.
1135 *
1136 * \param num_clang_command_line_args The number of command-line arguments in
1137 * \p clang_command_line_args.
1138 *
1139 * \param clang_command_line_args The command-line arguments that would be
1140 * passed to the \c clang executable if it were being invoked out-of-process.
1141 * These command-line options will be parsed and will affect how the translation
1142 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001143 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001144 *
1145 * \param num_unsaved_files the number of unsaved file entries in \p
1146 * unsaved_files.
1147 *
1148 * \param unsaved_files the files that have not yet been saved to disk
1149 * but may be required for code completion, including the contents of
Ted Kremenekde24a942010-04-12 18:47:26 +00001150 * those files. The contents and name of these files (as specified by
1151 * CXUnsavedFile) are copied when necessary, so the client only needs to
1152 * guarantee their validity until the call to this function returns.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001153 */
1154CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1155 CXIndex CIdx,
1156 const char *source_filename,
1157 int num_clang_command_line_args,
Douglas Gregor57879fa2010-09-01 16:43:19 +00001158 const char * const *clang_command_line_args,
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001159 unsigned num_unsaved_files,
Douglas Gregor33cdd812010-02-18 18:08:43 +00001160 struct CXUnsavedFile *unsaved_files);
Ted Kremenekd071c602010-03-13 02:50:34 +00001161
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001162/**
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001163 * \brief Same as \c clang_createTranslationUnit2, but returns
1164 * the \c CXTranslationUnit instead of an error code. In case of an error this
1165 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1166 * error codes.
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001167 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001168CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1169 CXIndex CIdx,
1170 const char *ast_filename);
1171
1172/**
1173 * \brief Create a translation unit from an AST file (\c -emit-ast).
1174 *
1175 * \param[out] out_TU A non-NULL pointer to store the created
1176 * \c CXTranslationUnit.
1177 *
1178 * \returns Zero on success, otherwise returns an error code.
1179 */
1180CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1181 CXIndex CIdx,
1182 const char *ast_filename,
1183 CXTranslationUnit *out_TU);
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001184
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001185/**
1186 * \brief Flags that control the creation of translation units.
1187 *
1188 * The enumerators in this enumeration type are meant to be bitwise
1189 * ORed together to specify which options should be used when
1190 * constructing the translation unit.
1191 */
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001192enum CXTranslationUnit_Flags {
1193 /**
1194 * \brief Used to indicate that no special translation-unit options are
1195 * needed.
1196 */
1197 CXTranslationUnit_None = 0x0,
1198
1199 /**
1200 * \brief Used to indicate that the parser should construct a "detailed"
1201 * preprocessing record, including all macro definitions and instantiations.
1202 *
1203 * Constructing a detailed preprocessing record requires more memory
1204 * and time to parse, since the information contained in the record
1205 * is usually not retained. However, it can be useful for
1206 * applications that require more detailed information about the
1207 * behavior of the preprocessor.
1208 */
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001209 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1210
1211 /**
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001212 * \brief Used to indicate that the translation unit is incomplete.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001213 *
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001214 * When a translation unit is considered "incomplete", semantic
1215 * analysis that is typically performed at the end of the
1216 * translation unit will be suppressed. For example, this suppresses
1217 * the completion of tentative declarations in C and of
1218 * instantiation of implicitly-instantiation function templates in
1219 * C++. This option is typically used when parsing a header with the
1220 * intent of producing a precompiled header.
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001221 */
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001222 CXTranslationUnit_Incomplete = 0x02,
Douglas Gregorbe2d8c62010-07-23 00:33:23 +00001223
1224 /**
1225 * \brief Used to indicate that the translation unit should be built with an
1226 * implicit precompiled header for the preamble.
1227 *
1228 * An implicit precompiled header is used as an optimization when a
1229 * particular translation unit is likely to be reparsed many times
1230 * when the sources aren't changing that often. In this case, an
1231 * implicit precompiled header will be built containing all of the
1232 * initial includes at the top of the main file (what we refer to as
1233 * the "preamble" of the file). In subsequent parses, if the
1234 * preamble or the files in it have not changed, \c
1235 * clang_reparseTranslationUnit() will re-use the implicit
1236 * precompiled header to improve parsing performance.
1237 */
Douglas Gregorde051182010-08-11 15:58:42 +00001238 CXTranslationUnit_PrecompiledPreamble = 0x04,
1239
1240 /**
1241 * \brief Used to indicate that the translation unit should cache some
1242 * code-completion results with each reparse of the source file.
1243 *
1244 * Caching of code-completion results is a performance optimization that
1245 * introduces some overhead to reparsing but improves the performance of
1246 * code-completion operations.
1247 */
Douglas Gregorf5a18542010-10-27 17:24:53 +00001248 CXTranslationUnit_CacheCompletionResults = 0x08,
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001249
Douglas Gregorf5a18542010-10-27 17:24:53 +00001250 /**
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001251 * \brief Used to indicate that the translation unit will be serialized with
1252 * \c clang_saveTranslationUnit.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001253 *
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001254 * This option is typically used when parsing a header with the intent of
1255 * producing a precompiled header.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001256 */
Argyrios Kyrtzidis0db720f2012-10-11 16:05:00 +00001257 CXTranslationUnit_ForSerialization = 0x10,
Douglas Gregorf5a18542010-10-27 17:24:53 +00001258
1259 /**
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001260 * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001261 *
1262 * Note: this is a *temporary* option that is available only while
Douglas Gregor2ed0ee12011-08-25 22:54:01 +00001263 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregorf5a18542010-10-27 17:24:53 +00001264 */
Erik Verbruggen6e922512012-04-12 10:11:59 +00001265 CXTranslationUnit_CXXChainedPCH = 0x20,
1266
1267 /**
1268 * \brief Used to indicate that function/method bodies should be skipped while
1269 * parsing.
1270 *
1271 * This option can be used to search for declarations/definitions while
1272 * ignoring the usages.
1273 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00001274 CXTranslationUnit_SkipFunctionBodies = 0x40,
1275
1276 /**
1277 * \brief Used to indicate that brief documentation comments should be
1278 * included into the set of code completions returned from this translation
1279 * unit.
1280 */
Benjamin Kramer5c248d82015-12-15 09:30:31 +00001281 CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1282
1283 /**
1284 * \brief Used to indicate that the precompiled preamble should be created on
1285 * the first parse. Otherwise it will be created on the first reparse. This
1286 * trades runtime on the first parse (serializing the preamble takes time) for
1287 * reduced runtime on the second parse (can now reuse the preamble).
1288 */
Manuel Klimek016c0242016-03-01 10:56:19 +00001289 CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1290
1291 /**
1292 * \brief Do not stop processing when fatal errors are encountered.
1293 *
1294 * When fatal errors are encountered while parsing a translation unit,
1295 * semantic analysis is typically stopped early when compiling code. A common
1296 * source for fatal errors are unresolvable include files. For the
1297 * purposes of an IDE, this is undesirable behavior and as much information
1298 * as possible should be reported. Use this flag to enable this behavior.
1299 */
Argyrios Kyrtzidis735e92c2017-06-09 01:20:48 +00001300 CXTranslationUnit_KeepGoing = 0x200,
1301
1302 /**
1303 * \brief Sets the preprocessor in a mode for parsing a single file only.
1304 */
1305 CXTranslationUnit_SingleFileParse = 0x400
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001306};
1307
1308/**
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001309 * \brief Returns the set of flags that is suitable for parsing a translation
1310 * unit that is being edited.
1311 *
1312 * The set of flags returned provide options for \c clang_parseTranslationUnit()
1313 * to indicate that the translation unit is likely to be reparsed many times,
1314 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1315 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1316 * set contains an unspecified set of optimizations (e.g., the precompiled
1317 * preamble) geared toward improving the performance of these routines. The
1318 * set of optimizations enabled may change from one version to the next.
1319 */
Douglas Gregorde051182010-08-11 15:58:42 +00001320CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001321
1322/**
1323 * \brief Same as \c clang_parseTranslationUnit2, but returns
1324 * the \c CXTranslationUnit instead of an error code. In case of an error this
1325 * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1326 * error codes.
1327 */
1328CINDEX_LINKAGE CXTranslationUnit
1329clang_parseTranslationUnit(CXIndex CIdx,
1330 const char *source_filename,
1331 const char *const *command_line_args,
1332 int num_command_line_args,
1333 struct CXUnsavedFile *unsaved_files,
1334 unsigned num_unsaved_files,
1335 unsigned options);
1336
Douglas Gregor4a47bca2010-08-09 22:28:58 +00001337/**
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001338 * \brief Parse the given source file and the translation unit corresponding
1339 * to that file.
1340 *
1341 * This routine is the main entry point for the Clang C API, providing the
1342 * ability to parse a source file into a translation unit that can then be
1343 * queried by other functions in the API. This routine accepts a set of
1344 * command-line arguments so that the compilation can be configured in the same
1345 * way that the compiler is configured on the command line.
1346 *
1347 * \param CIdx The index object with which the translation unit will be
1348 * associated.
1349 *
1350 * \param source_filename The name of the source file to load, or NULL if the
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001351 * source file is included in \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001352 *
1353 * \param command_line_args The command-line arguments that would be
1354 * passed to the \c clang executable if it were being invoked out-of-process.
1355 * These command-line options will be parsed and will affect how the translation
1356 * unit is parsed. Note that the following options are ignored: '-c',
James Dennett574cb4c2012-06-15 05:41:51 +00001357 * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001358 *
1359 * \param num_command_line_args The number of command-line arguments in
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001360 * \c command_line_args.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001361 *
1362 * \param unsaved_files the files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00001363 * but may be required for parsing, including the contents of
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001364 * those files. The contents and name of these files (as specified by
1365 * CXUnsavedFile) are copied when necessary, so the client only needs to
1366 * guarantee their validity until the call to this function returns.
1367 *
1368 * \param num_unsaved_files the number of unsaved file entries in \p
1369 * unsaved_files.
1370 *
1371 * \param options A bitmask of options that affects how the translation unit
1372 * is managed but not its compilation. This should be a bitwise OR of the
1373 * CXTranslationUnit_XXX flags.
1374 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001375 * \param[out] out_TU A non-NULL pointer to store the created
1376 * \c CXTranslationUnit, describing the parsed code and containing any
1377 * diagnostics produced by the compiler.
1378 *
1379 * \returns Zero on success, otherwise returns an error code.
Douglas Gregor99d2cf42010-07-21 18:52:53 +00001380 */
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001381CINDEX_LINKAGE enum CXErrorCode
1382clang_parseTranslationUnit2(CXIndex CIdx,
1383 const char *source_filename,
1384 const char *const *command_line_args,
1385 int num_command_line_args,
1386 struct CXUnsavedFile *unsaved_files,
1387 unsigned num_unsaved_files,
1388 unsigned options,
1389 CXTranslationUnit *out_TU);
1390
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001391/**
Benjamin Kramerc02670e2015-11-18 16:14:27 +00001392 * \brief Same as clang_parseTranslationUnit2 but requires a full command line
1393 * for \c command_line_args including argv[0]. This is useful if the standard
1394 * library paths are relative to the binary.
1395 */
1396CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1397 CXIndex CIdx, const char *source_filename,
1398 const char *const *command_line_args, int num_command_line_args,
1399 struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1400 unsigned options, CXTranslationUnit *out_TU);
1401
1402/**
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001403 * \brief Flags that control how translation units are saved.
1404 *
1405 * The enumerators in this enumeration type are meant to be bitwise
1406 * ORed together to specify which options should be used when
1407 * saving the translation unit.
1408 */
1409enum CXSaveTranslationUnit_Flags {
1410 /**
1411 * \brief Used to indicate that no special saving options are needed.
1412 */
1413 CXSaveTranslationUnit_None = 0x0
1414};
1415
1416/**
1417 * \brief Returns the set of flags that is suitable for saving a translation
1418 * unit.
1419 *
1420 * The set of flags returned provide options for
1421 * \c clang_saveTranslationUnit() by default. The returned flag
1422 * set contains an unspecified set of options that save translation units with
1423 * the most commonly-requested data.
1424 */
1425CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1426
1427/**
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001428 * \brief Describes the kind of error that occurred (if any) in a call to
1429 * \c clang_saveTranslationUnit().
1430 */
1431enum CXSaveError {
1432 /**
1433 * \brief Indicates that no error occurred while saving a translation unit.
1434 */
1435 CXSaveError_None = 0,
1436
1437 /**
1438 * \brief Indicates that an unknown error occurred while attempting to save
1439 * the file.
1440 *
1441 * This error typically indicates that file I/O failed when attempting to
1442 * write the file.
1443 */
1444 CXSaveError_Unknown = 1,
1445
1446 /**
1447 * \brief Indicates that errors during translation prevented this attempt
1448 * to save the translation unit.
1449 *
1450 * Errors that prevent the translation unit from being saved can be
1451 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1452 */
1453 CXSaveError_TranslationErrors = 2,
1454
1455 /**
1456 * \brief Indicates that the translation unit to be saved was somehow
1457 * invalid (e.g., NULL).
1458 */
1459 CXSaveError_InvalidTU = 3
1460};
1461
1462/**
Douglas Gregore9386682010-08-13 05:36:37 +00001463 * \brief Saves a translation unit into a serialized representation of
1464 * that translation unit on disk.
1465 *
1466 * Any translation unit that was parsed without error can be saved
1467 * into a file. The translation unit can then be deserialized into a
1468 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1469 * if it is an incomplete translation unit that corresponds to a
1470 * header, used as a precompiled header when parsing other translation
1471 * units.
1472 *
1473 * \param TU The translation unit to save.
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001474 *
Douglas Gregore9386682010-08-13 05:36:37 +00001475 * \param FileName The file to which the translation unit will be saved.
1476 *
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001477 * \param options A bitmask of options that affects how the translation unit
1478 * is saved. This should be a bitwise OR of the
1479 * CXSaveTranslationUnit_XXX flags.
1480 *
Douglas Gregor30c80fa2011-07-06 16:43:36 +00001481 * \returns A value that will match one of the enumerators of the CXSaveError
1482 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1483 * saved successfully, while a non-zero value indicates that a problem occurred.
Douglas Gregore9386682010-08-13 05:36:37 +00001484 */
1485CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
Douglas Gregor6bb92ec2010-08-13 15:35:05 +00001486 const char *FileName,
1487 unsigned options);
Douglas Gregore9386682010-08-13 05:36:37 +00001488
1489/**
Erik Verbruggen346066b2017-05-30 14:25:54 +00001490 * \brief Suspend a translation unit in order to free memory associated with it.
1491 *
1492 * A suspended translation unit uses significantly less memory but on the other
1493 * side does not support any other calls than \c clang_reparseTranslationUnit
1494 * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1495 */
1496CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1497
1498/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001499 * \brief Destroy the specified CXTranslationUnit object.
1500 */
1501CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
Ted Kremenekd071c602010-03-13 02:50:34 +00001502
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001503/**
Douglas Gregorde051182010-08-11 15:58:42 +00001504 * \brief Flags that control the reparsing of translation units.
1505 *
1506 * The enumerators in this enumeration type are meant to be bitwise
1507 * ORed together to specify which options should be used when
1508 * reparsing the translation unit.
1509 */
1510enum CXReparse_Flags {
1511 /**
1512 * \brief Used to indicate that no special reparsing options are needed.
1513 */
1514 CXReparse_None = 0x0
1515};
1516
1517/**
1518 * \brief Returns the set of flags that is suitable for reparsing a translation
1519 * unit.
1520 *
1521 * The set of flags returned provide options for
1522 * \c clang_reparseTranslationUnit() by default. The returned flag
1523 * set contains an unspecified set of optimizations geared toward common uses
1524 * of reparsing. The set of optimizations enabled may change from one version
1525 * to the next.
1526 */
1527CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1528
1529/**
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001530 * \brief Reparse the source files that produced this translation unit.
1531 *
1532 * This routine can be used to re-parse the source files that originally
1533 * created the given translation unit, for example because those source files
1534 * have changed (either on disk or as passed via \p unsaved_files). The
1535 * source code will be reparsed with the same command-line options as it
1536 * was originally parsed.
1537 *
1538 * Reparsing a translation unit invalidates all cursors and source locations
1539 * that refer into that translation unit. This makes reparsing a translation
1540 * unit semantically equivalent to destroying the translation unit and then
1541 * creating a new translation unit with the same command-line arguments.
1542 * However, it may be more efficient to reparse a translation
1543 * unit using this routine.
1544 *
1545 * \param TU The translation unit whose contents will be re-parsed. The
1546 * translation unit must originally have been built with
1547 * \c clang_createTranslationUnitFromSourceFile().
1548 *
1549 * \param num_unsaved_files The number of unsaved file entries in \p
1550 * unsaved_files.
1551 *
1552 * \param unsaved_files The files that have not yet been saved to disk
1553 * but may be required for parsing, including the contents of
1554 * those files. The contents and name of these files (as specified by
1555 * CXUnsavedFile) are copied when necessary, so the client only needs to
1556 * guarantee their validity until the call to this function returns.
1557 *
Douglas Gregorde051182010-08-11 15:58:42 +00001558 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1559 * The function \c clang_defaultReparseOptions() produces a default set of
1560 * options recommended for most uses, based on the translation unit.
1561 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001562 * \returns 0 if the sources could be reparsed. A non-zero error code will be
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001563 * returned if reparsing was impossible, such that the translation unit is
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00001564 * invalid. In such cases, the only valid call for \c TU is
1565 * \c clang_disposeTranslationUnit(TU). The error codes returned by this
1566 * routine are described by the \c CXErrorCode enum.
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001567 */
1568CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1569 unsigned num_unsaved_files,
Douglas Gregorde051182010-08-11 15:58:42 +00001570 struct CXUnsavedFile *unsaved_files,
1571 unsigned options);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001572
1573/**
1574 * \brief Categorizes how memory is being used by a translation unit.
1575 */
Ted Kremenek23324122011-04-20 16:41:07 +00001576enum CXTUResourceUsageKind {
1577 CXTUResourceUsage_AST = 1,
1578 CXTUResourceUsage_Identifiers = 2,
1579 CXTUResourceUsage_Selectors = 3,
1580 CXTUResourceUsage_GlobalCompletionResults = 4,
Ted Kremenek21735e62011-04-28 04:10:31 +00001581 CXTUResourceUsage_SourceManagerContentCache = 5,
Ted Kremenekf5df0ce2011-04-28 04:53:38 +00001582 CXTUResourceUsage_AST_SideTables = 6,
Ted Kremenek8d587902011-04-28 20:36:42 +00001583 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
Ted Kremenek5e1ed7b2011-04-28 23:46:20 +00001584 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1585 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1586 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Ted Kremenek2160a0d2011-05-04 01:38:46 +00001587 CXTUResourceUsage_Preprocessor = 11,
1588 CXTUResourceUsage_PreprocessingRecord = 12,
Ted Kremenek120992a2011-07-26 23:46:06 +00001589 CXTUResourceUsage_SourceManager_DataStructures = 13,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001590 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
Ted Kremenek23324122011-04-20 16:41:07 +00001591 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1592 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001593 CXTUResourceUsage_Preprocessor_HeaderSearch,
Ted Kremenek23324122011-04-20 16:41:07 +00001594
1595 CXTUResourceUsage_First = CXTUResourceUsage_AST,
Ted Kremenekfbcce6f2011-07-26 23:46:11 +00001596 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
Ted Kremenek83f642e2011-04-18 22:47:10 +00001597};
1598
1599/**
1600 * \brief Returns the human-readable null-terminated C string that represents
Ted Kremenek23324122011-04-20 16:41:07 +00001601 * the name of the memory category. This string should never be freed.
Ted Kremenek83f642e2011-04-18 22:47:10 +00001602 */
1603CINDEX_LINKAGE
Ted Kremenek23324122011-04-20 16:41:07 +00001604const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001605
Ted Kremenek23324122011-04-20 16:41:07 +00001606typedef struct CXTUResourceUsageEntry {
Ted Kremenek83f642e2011-04-18 22:47:10 +00001607 /* \brief The memory usage category. */
Ted Kremenek23324122011-04-20 16:41:07 +00001608 enum CXTUResourceUsageKind kind;
1609 /* \brief Amount of resources used.
1610 The units will depend on the resource kind. */
Ted Kremenek83f642e2011-04-18 22:47:10 +00001611 unsigned long amount;
Ted Kremenek23324122011-04-20 16:41:07 +00001612} CXTUResourceUsageEntry;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001613
1614/**
1615 * \brief The memory usage of a CXTranslationUnit, broken into categories.
1616 */
Ted Kremenek23324122011-04-20 16:41:07 +00001617typedef struct CXTUResourceUsage {
Ted Kremenek83f642e2011-04-18 22:47:10 +00001618 /* \brief Private data member, used for queries. */
1619 void *data;
1620
1621 /* \brief The number of entries in the 'entries' array. */
1622 unsigned numEntries;
1623
1624 /* \brief An array of key-value pairs, representing the breakdown of memory
1625 usage. */
Ted Kremenek23324122011-04-20 16:41:07 +00001626 CXTUResourceUsageEntry *entries;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001627
Ted Kremenek23324122011-04-20 16:41:07 +00001628} CXTUResourceUsage;
Ted Kremenek83f642e2011-04-18 22:47:10 +00001629
1630/**
1631 * \brief Return the memory usage of a translation unit. This object
Ted Kremenek23324122011-04-20 16:41:07 +00001632 * should be released with clang_disposeCXTUResourceUsage().
Ted Kremenek83f642e2011-04-18 22:47:10 +00001633 */
Ted Kremenek23324122011-04-20 16:41:07 +00001634CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001635
Ted Kremenek23324122011-04-20 16:41:07 +00001636CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
Ted Kremenek83f642e2011-04-18 22:47:10 +00001637
Douglas Gregoraa21cc42010-07-19 21:46:24 +00001638/**
Emilio Cobos Alvarez485ad422017-04-28 15:56:39 +00001639 * \brief Get target information for this translation unit.
1640 *
1641 * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1642 */
1643CINDEX_LINKAGE CXTargetInfo
1644clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1645
1646/**
1647 * \brief Destroy the CXTargetInfo object.
1648 */
1649CINDEX_LINKAGE void
1650clang_TargetInfo_dispose(CXTargetInfo Info);
1651
1652/**
1653 * \brief Get the normalized target triple as a string.
1654 *
1655 * Returns the empty string in case of any error.
1656 */
1657CINDEX_LINKAGE CXString
1658clang_TargetInfo_getTriple(CXTargetInfo Info);
1659
1660/**
1661 * \brief Get the pointer width of the target in bits.
1662 *
1663 * Returns -1 in case of error.
1664 */
1665CINDEX_LINKAGE int
1666clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1667
1668/**
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001669 * @}
1670 */
Ted Kremenekd071c602010-03-13 02:50:34 +00001671
Douglas Gregor4f9c3762010-01-28 00:27:43 +00001672/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001673 * \brief Describes the kind of entity that a cursor refers to.
1674 */
1675enum CXCursorKind {
1676 /* Declarations */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001677 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001678 * \brief A declaration whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001679 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001680 *
1681 * Unexposed declarations have the same operations as any other kind
1682 * of declaration; one can extract their location information,
1683 * spelling, find their definitions, etc. However, the specific kind
1684 * of the declaration is not reported.
1685 */
1686 CXCursor_UnexposedDecl = 1,
1687 /** \brief A C or C++ struct. */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001688 CXCursor_StructDecl = 2,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001689 /** \brief A C or C++ union. */
1690 CXCursor_UnionDecl = 3,
1691 /** \brief A C++ class. */
1692 CXCursor_ClassDecl = 4,
1693 /** \brief An enumeration. */
1694 CXCursor_EnumDecl = 5,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001695 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00001696 * \brief A field (in C) or non-static data member (in C++) in a
1697 * struct, union, or C++ class.
1698 */
1699 CXCursor_FieldDecl = 6,
1700 /** \brief An enumerator constant. */
1701 CXCursor_EnumConstantDecl = 7,
1702 /** \brief A function. */
1703 CXCursor_FunctionDecl = 8,
1704 /** \brief A variable. */
1705 CXCursor_VarDecl = 9,
1706 /** \brief A function or method parameter. */
1707 CXCursor_ParmDecl = 10,
James Dennett1355bd12012-06-11 06:19:40 +00001708 /** \brief An Objective-C \@interface. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001709 CXCursor_ObjCInterfaceDecl = 11,
James Dennett1355bd12012-06-11 06:19:40 +00001710 /** \brief An Objective-C \@interface for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001711 CXCursor_ObjCCategoryDecl = 12,
James Dennett1355bd12012-06-11 06:19:40 +00001712 /** \brief An Objective-C \@protocol declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001713 CXCursor_ObjCProtocolDecl = 13,
James Dennett1355bd12012-06-11 06:19:40 +00001714 /** \brief An Objective-C \@property declaration. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001715 CXCursor_ObjCPropertyDecl = 14,
1716 /** \brief An Objective-C instance variable. */
1717 CXCursor_ObjCIvarDecl = 15,
1718 /** \brief An Objective-C instance method. */
1719 CXCursor_ObjCInstanceMethodDecl = 16,
1720 /** \brief An Objective-C class method. */
1721 CXCursor_ObjCClassMethodDecl = 17,
James Dennett1355bd12012-06-11 06:19:40 +00001722 /** \brief An Objective-C \@implementation. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001723 CXCursor_ObjCImplementationDecl = 18,
James Dennett1355bd12012-06-11 06:19:40 +00001724 /** \brief An Objective-C \@implementation for a category. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001725 CXCursor_ObjCCategoryImplDecl = 19,
Saleem Abdulrasool993b2862015-08-12 03:21:44 +00001726 /** \brief A typedef. */
Douglas Gregor6007cf22010-01-22 22:29:16 +00001727 CXCursor_TypedefDecl = 20,
Ted Kremenek225b8e32010-04-13 23:39:06 +00001728 /** \brief A C++ class method. */
1729 CXCursor_CXXMethod = 21,
Ted Kremenekbd67fb22010-05-06 23:38:21 +00001730 /** \brief A C++ namespace. */
1731 CXCursor_Namespace = 22,
Ted Kremenekb80cba52010-05-07 01:04:29 +00001732 /** \brief A linkage specification, e.g. 'extern "C"'. */
1733 CXCursor_LinkageSpec = 23,
Douglas Gregor12bca222010-08-31 14:41:23 +00001734 /** \brief A C++ constructor. */
1735 CXCursor_Constructor = 24,
1736 /** \brief A C++ destructor. */
1737 CXCursor_Destructor = 25,
1738 /** \brief A C++ conversion function. */
1739 CXCursor_ConversionFunction = 26,
Douglas Gregor713602b2010-08-31 17:01:39 +00001740 /** \brief A C++ template type parameter. */
1741 CXCursor_TemplateTypeParameter = 27,
1742 /** \brief A C++ non-type template parameter. */
1743 CXCursor_NonTypeTemplateParameter = 28,
1744 /** \brief A C++ template template parameter. */
1745 CXCursor_TemplateTemplateParameter = 29,
1746 /** \brief A C++ function template. */
1747 CXCursor_FunctionTemplate = 30,
Douglas Gregor1fbaeb12010-08-31 19:02:00 +00001748 /** \brief A C++ class template. */
1749 CXCursor_ClassTemplate = 31,
Douglas Gregorf96abb22010-08-31 19:31:58 +00001750 /** \brief A C++ class template partial specialization. */
1751 CXCursor_ClassTemplatePartialSpecialization = 32,
Douglas Gregora89314e2010-08-31 23:48:11 +00001752 /** \brief A C++ namespace alias declaration. */
1753 CXCursor_NamespaceAlias = 33,
Douglas Gregor01a430132010-09-01 03:07:18 +00001754 /** \brief A C++ using directive. */
1755 CXCursor_UsingDirective = 34,
Richard Smithdda56e42011-04-15 14:24:37 +00001756 /** \brief A C++ using declaration. */
Douglas Gregora9aa29c2010-09-01 19:52:22 +00001757 CXCursor_UsingDeclaration = 35,
Richard Smithdda56e42011-04-15 14:24:37 +00001758 /** \brief A C++ alias declaration */
1759 CXCursor_TypeAliasDecl = 36,
James Dennett574cb4c2012-06-15 05:41:51 +00001760 /** \brief An Objective-C \@synthesize definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001761 CXCursor_ObjCSynthesizeDecl = 37,
James Dennett574cb4c2012-06-15 05:41:51 +00001762 /** \brief An Objective-C \@dynamic definition. */
Douglas Gregor4cd65962011-06-03 23:08:58 +00001763 CXCursor_ObjCDynamicDecl = 38,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001764 /** \brief An access specifier. */
1765 CXCursor_CXXAccessSpecifier = 39,
Douglas Gregor4c362d52011-10-05 19:00:14 +00001766
Ted Kremenek08de5c12010-05-19 21:51:10 +00001767 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
Argyrios Kyrtzidis12afd702011-09-30 17:58:23 +00001768 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001769
Douglas Gregor6007cf22010-01-22 22:29:16 +00001770 /* References */
1771 CXCursor_FirstRef = 40, /* Decl references */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001772 CXCursor_ObjCSuperClassRef = 40,
Douglas Gregor6007cf22010-01-22 22:29:16 +00001773 CXCursor_ObjCProtocolRef = 41,
1774 CXCursor_ObjCClassRef = 42,
1775 /**
1776 * \brief A reference to a type declaration.
1777 *
1778 * A type reference occurs anywhere where a type is named but not
1779 * declared. For example, given:
1780 *
1781 * \code
1782 * typedef unsigned size_type;
1783 * size_type size;
1784 * \endcode
1785 *
1786 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1787 * while the type of the variable "size" is referenced. The cursor
1788 * referenced by the type of size is the typedef for size_type.
1789 */
1790 CXCursor_TypeRef = 43,
Ted Kremenekae9e2212010-08-27 21:34:58 +00001791 CXCursor_CXXBaseSpecifier = 44,
Douglas Gregora23e8f72010-08-31 20:37:03 +00001792 /**
Douglas Gregorf3af3112010-09-09 21:42:20 +00001793 * \brief A reference to a class template, function template, template
1794 * template parameter, or class template partial specialization.
Douglas Gregora23e8f72010-08-31 20:37:03 +00001795 */
1796 CXCursor_TemplateRef = 45,
Douglas Gregora89314e2010-08-31 23:48:11 +00001797 /**
1798 * \brief A reference to a namespace or namespace alias.
1799 */
1800 CXCursor_NamespaceRef = 46,
Douglas Gregorf3af3112010-09-09 21:42:20 +00001801 /**
Douglas Gregora93ab662010-09-10 00:22:18 +00001802 * \brief A reference to a member of a struct, union, or class that occurs in
1803 * some non-expression context, e.g., a designated initializer.
Douglas Gregorf3af3112010-09-09 21:42:20 +00001804 */
1805 CXCursor_MemberRef = 47,
Douglas Gregora93ab662010-09-10 00:22:18 +00001806 /**
1807 * \brief A reference to a labeled statement.
1808 *
1809 * This cursor kind is used to describe the jump to "start_over" in the
1810 * goto statement in the following example:
1811 *
1812 * \code
1813 * start_over:
1814 * ++counter;
1815 *
1816 * goto start_over;
1817 * \endcode
1818 *
1819 * A label reference cursor refers to a label statement.
1820 */
1821 CXCursor_LabelRef = 48,
1822
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00001823 /**
1824 * \brief A reference to a set of overloaded functions or function templates
1825 * that has not yet been resolved to a specific function or function template.
1826 *
1827 * An overloaded declaration reference cursor occurs in C++ templates where
1828 * a dependent name refers to a function. For example:
1829 *
1830 * \code
1831 * template<typename T> void swap(T&, T&);
1832 *
1833 * struct X { ... };
1834 * void swap(X&, X&);
1835 *
1836 * template<typename T>
1837 * void reverse(T* first, T* last) {
1838 * while (first < last - 1) {
1839 * swap(*first, *--last);
1840 * ++first;
1841 * }
1842 * }
1843 *
1844 * struct Y { };
1845 * void swap(Y&, Y&);
1846 * \endcode
1847 *
1848 * Here, the identifier "swap" is associated with an overloaded declaration
1849 * reference. In the template definition, "swap" refers to either of the two
1850 * "swap" functions declared above, so both results will be available. At
1851 * instantiation time, "swap" may also refer to other functions found via
1852 * argument-dependent lookup (e.g., the "swap" function at the end of the
1853 * example).
1854 *
1855 * The functions \c clang_getNumOverloadedDecls() and
1856 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1857 * referenced by this cursor.
1858 */
1859 CXCursor_OverloadedDeclRef = 49,
1860
Douglas Gregor30093832012-02-15 00:54:55 +00001861 /**
1862 * \brief A reference to a variable that occurs in some non-expression
1863 * context, e.g., a C++ lambda capture list.
1864 */
1865 CXCursor_VariableRef = 50,
1866
1867 CXCursor_LastRef = CXCursor_VariableRef,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001868
Douglas Gregor6007cf22010-01-22 22:29:16 +00001869 /* Error conditions */
1870 CXCursor_FirstInvalid = 70,
1871 CXCursor_InvalidFile = 70,
1872 CXCursor_NoDeclFound = 71,
1873 CXCursor_NotImplemented = 72,
Ted Kremeneke184ac52010-03-19 20:39:03 +00001874 CXCursor_InvalidCode = 73,
1875 CXCursor_LastInvalid = CXCursor_InvalidCode,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001876
Douglas Gregor6007cf22010-01-22 22:29:16 +00001877 /* Expressions */
1878 CXCursor_FirstExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001879
Douglas Gregor6007cf22010-01-22 22:29:16 +00001880 /**
1881 * \brief An expression whose specific kind is not exposed via this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001882 * interface.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001883 *
1884 * Unexposed expressions have the same operations as any other kind
1885 * of expression; one can extract their location information,
1886 * spelling, children, etc. However, the specific kind of the
1887 * expression is not reported.
1888 */
1889 CXCursor_UnexposedExpr = 100,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001890
Douglas Gregor6007cf22010-01-22 22:29:16 +00001891 /**
1892 * \brief An expression that refers to some value declaration, such
Nico Weber7deebef2014-04-24 03:17:47 +00001893 * as a function, variable, or enumerator.
Douglas Gregor6007cf22010-01-22 22:29:16 +00001894 */
1895 CXCursor_DeclRefExpr = 101,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001896
Douglas Gregor6007cf22010-01-22 22:29:16 +00001897 /**
1898 * \brief An expression that refers to a member of a struct, union,
1899 * class, Objective-C class, etc.
1900 */
1901 CXCursor_MemberRefExpr = 102,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001902
Douglas Gregor6007cf22010-01-22 22:29:16 +00001903 /** \brief An expression that calls a function. */
1904 CXCursor_CallExpr = 103,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00001905
Douglas Gregor6007cf22010-01-22 22:29:16 +00001906 /** \brief An expression that sends a message to an Objective-C
1907 object or class. */
1908 CXCursor_ObjCMessageExpr = 104,
Ted Kremenek33b9a422010-04-11 21:47:37 +00001909
1910 /** \brief An expression that represents a block literal. */
1911 CXCursor_BlockExpr = 105,
1912
Douglas Gregor4c362d52011-10-05 19:00:14 +00001913 /** \brief An integer literal.
1914 */
1915 CXCursor_IntegerLiteral = 106,
1916
1917 /** \brief A floating point number literal.
1918 */
1919 CXCursor_FloatingLiteral = 107,
1920
1921 /** \brief An imaginary number literal.
1922 */
1923 CXCursor_ImaginaryLiteral = 108,
1924
1925 /** \brief A string literal.
1926 */
1927 CXCursor_StringLiteral = 109,
1928
1929 /** \brief A character literal.
1930 */
1931 CXCursor_CharacterLiteral = 110,
1932
1933 /** \brief A parenthesized expression, e.g. "(1)".
1934 *
1935 * This AST node is only formed if full location information is requested.
1936 */
1937 CXCursor_ParenExpr = 111,
1938
1939 /** \brief This represents the unary-expression's (except sizeof and
1940 * alignof).
1941 */
1942 CXCursor_UnaryOperator = 112,
1943
1944 /** \brief [C99 6.5.2.1] Array Subscripting.
1945 */
1946 CXCursor_ArraySubscriptExpr = 113,
1947
1948 /** \brief A builtin binary operation expression such as "x + y" or
1949 * "x <= y".
1950 */
1951 CXCursor_BinaryOperator = 114,
1952
1953 /** \brief Compound assignment such as "+=".
1954 */
1955 CXCursor_CompoundAssignOperator = 115,
1956
1957 /** \brief The ?: ternary operator.
1958 */
1959 CXCursor_ConditionalOperator = 116,
1960
1961 /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++
1962 * (C++ [expr.cast]), which uses the syntax (Type)expr.
1963 *
1964 * For example: (int)f.
1965 */
1966 CXCursor_CStyleCastExpr = 117,
1967
1968 /** \brief [C99 6.5.2.5]
1969 */
1970 CXCursor_CompoundLiteralExpr = 118,
1971
1972 /** \brief Describes an C or C++ initializer list.
1973 */
1974 CXCursor_InitListExpr = 119,
1975
1976 /** \brief The GNU address of label extension, representing &&label.
1977 */
1978 CXCursor_AddrLabelExpr = 120,
1979
1980 /** \brief This is the GNU Statement Expression extension: ({int X=4; X;})
1981 */
1982 CXCursor_StmtExpr = 121,
1983
Benjamin Kramere56f3932011-12-23 17:00:35 +00001984 /** \brief Represents a C11 generic selection.
Douglas Gregor4c362d52011-10-05 19:00:14 +00001985 */
1986 CXCursor_GenericSelectionExpr = 122,
1987
1988 /** \brief Implements the GNU __null extension, which is a name for a null
1989 * pointer constant that has integral type (e.g., int or long) and is the same
1990 * size and alignment as a pointer.
1991 *
1992 * The __null extension is typically only used by system headers, which define
1993 * NULL as __null in C++ rather than using 0 (which is an integer that may not
1994 * match the size of a pointer).
1995 */
1996 CXCursor_GNUNullExpr = 123,
1997
1998 /** \brief C++'s static_cast<> expression.
1999 */
2000 CXCursor_CXXStaticCastExpr = 124,
2001
2002 /** \brief C++'s dynamic_cast<> expression.
2003 */
2004 CXCursor_CXXDynamicCastExpr = 125,
2005
2006 /** \brief C++'s reinterpret_cast<> expression.
2007 */
2008 CXCursor_CXXReinterpretCastExpr = 126,
2009
2010 /** \brief C++'s const_cast<> expression.
2011 */
2012 CXCursor_CXXConstCastExpr = 127,
2013
2014 /** \brief Represents an explicit C++ type conversion that uses "functional"
2015 * notion (C++ [expr.type.conv]).
2016 *
2017 * Example:
2018 * \code
2019 * x = int(0.5);
2020 * \endcode
2021 */
2022 CXCursor_CXXFunctionalCastExpr = 128,
2023
2024 /** \brief A C++ typeid expression (C++ [expr.typeid]).
2025 */
2026 CXCursor_CXXTypeidExpr = 129,
2027
2028 /** \brief [C++ 2.13.5] C++ Boolean Literal.
2029 */
2030 CXCursor_CXXBoolLiteralExpr = 130,
2031
2032 /** \brief [C++0x 2.14.7] C++ Pointer Literal.
2033 */
2034 CXCursor_CXXNullPtrLiteralExpr = 131,
2035
2036 /** \brief Represents the "this" expression in C++
2037 */
2038 CXCursor_CXXThisExpr = 132,
2039
2040 /** \brief [C++ 15] C++ Throw Expression.
2041 *
2042 * This handles 'throw' and 'throw' assignment-expression. When
2043 * assignment-expression isn't present, Op will be null.
2044 */
2045 CXCursor_CXXThrowExpr = 133,
2046
2047 /** \brief A new expression for memory allocation and constructor calls, e.g:
2048 * "new CXXNewExpr(foo)".
2049 */
2050 CXCursor_CXXNewExpr = 134,
2051
2052 /** \brief A delete expression for memory deallocation and destructor calls,
2053 * e.g. "delete[] pArray".
2054 */
2055 CXCursor_CXXDeleteExpr = 135,
2056
Olivier Goffart692d5332016-06-09 16:16:06 +00002057 /** \brief A unary expression. (noexcept, sizeof, or other traits)
Douglas Gregor4c362d52011-10-05 19:00:14 +00002058 */
2059 CXCursor_UnaryExpr = 136,
2060
Douglas Gregor910c37c2011-11-11 22:35:18 +00002061 /** \brief An Objective-C string literal i.e. @"foo".
Douglas Gregor4c362d52011-10-05 19:00:14 +00002062 */
2063 CXCursor_ObjCStringLiteral = 137,
2064
James Dennett574cb4c2012-06-15 05:41:51 +00002065 /** \brief An Objective-C \@encode expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002066 */
2067 CXCursor_ObjCEncodeExpr = 138,
2068
James Dennett574cb4c2012-06-15 05:41:51 +00002069 /** \brief An Objective-C \@selector expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002070 */
2071 CXCursor_ObjCSelectorExpr = 139,
2072
James Dennett1355bd12012-06-11 06:19:40 +00002073 /** \brief An Objective-C \@protocol expression.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002074 */
2075 CXCursor_ObjCProtocolExpr = 140,
2076
2077 /** \brief An Objective-C "bridged" cast expression, which casts between
2078 * Objective-C pointers and C pointers, transferring ownership in the process.
2079 *
2080 * \code
2081 * NSString *str = (__bridge_transfer NSString *)CFCreateString();
2082 * \endcode
2083 */
2084 CXCursor_ObjCBridgedCastExpr = 141,
2085
2086 /** \brief Represents a C++0x pack expansion that produces a sequence of
2087 * expressions.
2088 *
2089 * A pack expansion expression contains a pattern (which itself is an
2090 * expression) followed by an ellipsis. For example:
2091 *
2092 * \code
2093 * template<typename F, typename ...Types>
2094 * void forward(F f, Types &&...args) {
2095 * f(static_cast<Types&&>(args)...);
2096 * }
2097 * \endcode
2098 */
2099 CXCursor_PackExpansionExpr = 142,
2100
2101 /** \brief Represents an expression that computes the length of a parameter
2102 * pack.
2103 *
2104 * \code
2105 * template<typename ...Types>
2106 * struct count {
2107 * static const unsigned value = sizeof...(Types);
2108 * };
2109 * \endcode
2110 */
2111 CXCursor_SizeOfPackExpr = 143,
2112
Douglas Gregor30093832012-02-15 00:54:55 +00002113 /* \brief Represents a C++ lambda expression that produces a local function
2114 * object.
2115 *
2116 * \code
2117 * void abssort(float *x, unsigned N) {
2118 * std::sort(x, x + N,
2119 * [](float a, float b) {
2120 * return std::abs(a) < std::abs(b);
2121 * });
2122 * }
2123 * \endcode
2124 */
2125 CXCursor_LambdaExpr = 144,
2126
Ted Kremenek77006f62012-03-06 20:06:06 +00002127 /** \brief Objective-c Boolean Literal.
2128 */
2129 CXCursor_ObjCBoolLiteralExpr = 145,
2130
Nico Weber7deebef2014-04-24 03:17:47 +00002131 /** \brief Represents the "self" expression in an Objective-C method.
Argyrios Kyrtzidisc2233be2013-04-23 17:57:17 +00002132 */
2133 CXCursor_ObjCSelfExpr = 146,
2134
Alexey Bataev1a3320e2015-08-25 14:24:04 +00002135 /** \brief OpenMP 4.0 [2.4, Array Section].
2136 */
2137 CXCursor_OMPArraySectionExpr = 147,
2138
Erik Pilkington29099de2016-07-16 00:35:23 +00002139 /** \brief Represents an @available(...) check.
2140 */
2141 CXCursor_ObjCAvailabilityCheckExpr = 148,
2142
2143 CXCursor_LastExpr = CXCursor_ObjCAvailabilityCheckExpr,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002144
Douglas Gregor6007cf22010-01-22 22:29:16 +00002145 /* Statements */
2146 CXCursor_FirstStmt = 200,
2147 /**
2148 * \brief A statement whose specific kind is not exposed via this
2149 * interface.
2150 *
2151 * Unexposed statements have the same operations as any other kind of
2152 * statement; one can extract their location information, spelling,
2153 * children, etc. However, the specific kind of the statement is not
2154 * reported.
2155 */
2156 CXCursor_UnexposedStmt = 200,
Douglas Gregora93ab662010-09-10 00:22:18 +00002157
2158 /** \brief A labelled statement in a function.
2159 *
2160 * This cursor kind is used to describe the "start_over:" label statement in
2161 * the following example:
2162 *
2163 * \code
2164 * start_over:
2165 * ++counter;
2166 * \endcode
2167 *
2168 */
2169 CXCursor_LabelStmt = 201,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002170
2171 /** \brief A group of statements like { stmt stmt }.
2172 *
2173 * This cursor kind is used to describe compound statements, e.g. function
2174 * bodies.
2175 */
2176 CXCursor_CompoundStmt = 202,
2177
Benjamin Kramer2501f142013-10-20 11:47:15 +00002178 /** \brief A case statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002179 */
2180 CXCursor_CaseStmt = 203,
2181
2182 /** \brief A default statement.
2183 */
2184 CXCursor_DefaultStmt = 204,
2185
2186 /** \brief An if statement
2187 */
2188 CXCursor_IfStmt = 205,
2189
2190 /** \brief A switch statement.
2191 */
2192 CXCursor_SwitchStmt = 206,
2193
2194 /** \brief A while statement.
2195 */
2196 CXCursor_WhileStmt = 207,
2197
2198 /** \brief A do statement.
2199 */
2200 CXCursor_DoStmt = 208,
2201
2202 /** \brief A for statement.
2203 */
2204 CXCursor_ForStmt = 209,
2205
2206 /** \brief A goto statement.
2207 */
2208 CXCursor_GotoStmt = 210,
2209
2210 /** \brief An indirect goto statement.
2211 */
2212 CXCursor_IndirectGotoStmt = 211,
2213
2214 /** \brief A continue statement.
2215 */
2216 CXCursor_ContinueStmt = 212,
2217
2218 /** \brief A break statement.
2219 */
2220 CXCursor_BreakStmt = 213,
2221
2222 /** \brief A return statement.
2223 */
2224 CXCursor_ReturnStmt = 214,
2225
Chad Rosierde70e0e2012-08-25 00:11:56 +00002226 /** \brief A GCC inline assembly statement extension.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002227 */
Chad Rosierde70e0e2012-08-25 00:11:56 +00002228 CXCursor_GCCAsmStmt = 215,
Argyrios Kyrtzidis5eae0732012-09-24 19:27:20 +00002229 CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
Douglas Gregor4c362d52011-10-05 19:00:14 +00002230
James Dennett574cb4c2012-06-15 05:41:51 +00002231 /** \brief Objective-C's overall \@try-\@catch-\@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002232 */
2233 CXCursor_ObjCAtTryStmt = 216,
2234
James Dennett574cb4c2012-06-15 05:41:51 +00002235 /** \brief Objective-C's \@catch statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002236 */
2237 CXCursor_ObjCAtCatchStmt = 217,
2238
James Dennett574cb4c2012-06-15 05:41:51 +00002239 /** \brief Objective-C's \@finally statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002240 */
2241 CXCursor_ObjCAtFinallyStmt = 218,
2242
James Dennett574cb4c2012-06-15 05:41:51 +00002243 /** \brief Objective-C's \@throw statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002244 */
2245 CXCursor_ObjCAtThrowStmt = 219,
2246
James Dennett574cb4c2012-06-15 05:41:51 +00002247 /** \brief Objective-C's \@synchronized statement.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002248 */
2249 CXCursor_ObjCAtSynchronizedStmt = 220,
2250
2251 /** \brief Objective-C's autorelease pool statement.
2252 */
2253 CXCursor_ObjCAutoreleasePoolStmt = 221,
2254
2255 /** \brief Objective-C's collection statement.
2256 */
2257 CXCursor_ObjCForCollectionStmt = 222,
2258
2259 /** \brief C++'s catch statement.
2260 */
2261 CXCursor_CXXCatchStmt = 223,
2262
2263 /** \brief C++'s try statement.
2264 */
2265 CXCursor_CXXTryStmt = 224,
2266
2267 /** \brief C++'s for (* : *) statement.
2268 */
2269 CXCursor_CXXForRangeStmt = 225,
2270
2271 /** \brief Windows Structured Exception Handling's try statement.
2272 */
2273 CXCursor_SEHTryStmt = 226,
2274
2275 /** \brief Windows Structured Exception Handling's except statement.
2276 */
2277 CXCursor_SEHExceptStmt = 227,
2278
2279 /** \brief Windows Structured Exception Handling's finally statement.
2280 */
2281 CXCursor_SEHFinallyStmt = 228,
2282
Chad Rosier32503022012-06-11 20:47:18 +00002283 /** \brief A MS inline assembly statement extension.
2284 */
2285 CXCursor_MSAsmStmt = 229,
2286
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00002287 /** \brief The null statement ";": C99 6.8.3p3.
Douglas Gregor4c362d52011-10-05 19:00:14 +00002288 *
2289 * This cursor kind is used to describe the null statement.
2290 */
2291 CXCursor_NullStmt = 230,
2292
2293 /** \brief Adaptor class for mixing declarations with statements and
2294 * expressions.
2295 */
2296 CXCursor_DeclStmt = 231,
2297
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00002298 /** \brief OpenMP parallel directive.
2299 */
2300 CXCursor_OMPParallelDirective = 232,
2301
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00002302 /** \brief OpenMP SIMD directive.
Alexey Bataev1b59ab52014-02-27 08:29:12 +00002303 */
2304 CXCursor_OMPSimdDirective = 233,
2305
Alexey Bataevf29276e2014-06-18 04:14:57 +00002306 /** \brief OpenMP for directive.
2307 */
2308 CXCursor_OMPForDirective = 234,
2309
Alexey Bataevd3f8dd22014-06-25 11:44:49 +00002310 /** \brief OpenMP sections directive.
2311 */
2312 CXCursor_OMPSectionsDirective = 235,
2313
Alexey Bataev1e0498a2014-06-26 08:21:58 +00002314 /** \brief OpenMP section directive.
2315 */
2316 CXCursor_OMPSectionDirective = 236,
2317
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002318 /** \brief OpenMP single directive.
2319 */
2320 CXCursor_OMPSingleDirective = 237,
2321
Alexey Bataev4acb8592014-07-07 13:01:15 +00002322 /** \brief OpenMP parallel for directive.
2323 */
2324 CXCursor_OMPParallelForDirective = 238,
2325
Alexey Bataev84d0b3e2014-07-08 08:12:03 +00002326 /** \brief OpenMP parallel sections directive.
2327 */
2328 CXCursor_OMPParallelSectionsDirective = 239,
2329
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +00002330 /** \brief OpenMP task directive.
2331 */
2332 CXCursor_OMPTaskDirective = 240,
2333
Alexander Musman80c22892014-07-17 08:54:58 +00002334 /** \brief OpenMP master directive.
2335 */
2336 CXCursor_OMPMasterDirective = 241,
2337
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002338 /** \brief OpenMP critical directive.
2339 */
2340 CXCursor_OMPCriticalDirective = 242,
2341
Alexey Bataev68446b72014-07-18 07:47:19 +00002342 /** \brief OpenMP taskyield directive.
2343 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002344 CXCursor_OMPTaskyieldDirective = 243,
Alexey Bataev68446b72014-07-18 07:47:19 +00002345
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002346 /** \brief OpenMP barrier directive.
2347 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002348 CXCursor_OMPBarrierDirective = 244,
Alexey Bataev4d1dfea2014-07-18 09:11:51 +00002349
Alexey Bataev2df347a2014-07-18 10:17:07 +00002350 /** \brief OpenMP taskwait directive.
2351 */
Alexander Musmand9ed09f2014-07-21 09:42:05 +00002352 CXCursor_OMPTaskwaitDirective = 245,
Alexey Bataev2df347a2014-07-18 10:17:07 +00002353
Alexey Bataev6125da92014-07-21 11:26:11 +00002354 /** \brief OpenMP flush directive.
2355 */
2356 CXCursor_OMPFlushDirective = 246,
Alexey Bataev0162e452014-07-22 10:10:35 +00002357
Reid Klecknerba764482014-07-24 18:22:15 +00002358 /** \brief Windows Structured Exception Handling's leave statement.
2359 */
2360 CXCursor_SEHLeaveStmt = 247,
2361
Alexey Bataev9fb6e642014-07-22 06:45:04 +00002362 /** \brief OpenMP ordered directive.
2363 */
Reid Klecknerba764482014-07-24 18:22:15 +00002364 CXCursor_OMPOrderedDirective = 248,
Alexey Bataev6125da92014-07-21 11:26:11 +00002365
Alexey Bataev0162e452014-07-22 10:10:35 +00002366 /** \brief OpenMP atomic directive.
2367 */
Reid Klecknerba764482014-07-24 18:22:15 +00002368 CXCursor_OMPAtomicDirective = 249,
Alexey Bataev0162e452014-07-22 10:10:35 +00002369
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00002370 /** \brief OpenMP for SIMD directive.
Alexander Musmanf82886e2014-09-18 05:12:34 +00002371 */
2372 CXCursor_OMPForSimdDirective = 250,
2373
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00002374 /** \brief OpenMP parallel for SIMD directive.
Alexander Musmane4e893b2014-09-23 09:33:00 +00002375 */
2376 CXCursor_OMPParallelForSimdDirective = 251,
2377
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002378 /** \brief OpenMP target directive.
2379 */
Alexander Musmane4e893b2014-09-23 09:33:00 +00002380 CXCursor_OMPTargetDirective = 252,
Alexey Bataev0bd520b2014-09-19 08:19:49 +00002381
Alexey Bataev13314bf2014-10-09 04:18:56 +00002382 /** \brief OpenMP teams directive.
2383 */
2384 CXCursor_OMPTeamsDirective = 253,
2385
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002386 /** \brief OpenMP taskgroup directive.
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002387 */
Michael Wong65f367f2015-07-21 13:44:28 +00002388 CXCursor_OMPTaskgroupDirective = 254,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002389
Alexey Bataev6d4ed052015-07-01 06:57:41 +00002390 /** \brief OpenMP cancellation point directive.
2391 */
Michael Wong65f367f2015-07-21 13:44:28 +00002392 CXCursor_OMPCancellationPointDirective = 255,
Alexey Bataevc30dd2d2015-06-18 12:14:09 +00002393
Alexey Bataev80909872015-07-02 11:25:17 +00002394 /** \brief OpenMP cancel directive.
2395 */
Michael Wong65f367f2015-07-21 13:44:28 +00002396 CXCursor_OMPCancelDirective = 256,
Alexey Bataev80909872015-07-02 11:25:17 +00002397
Michael Wong65f367f2015-07-21 13:44:28 +00002398 /** \brief OpenMP target data directive.
2399 */
2400 CXCursor_OMPTargetDataDirective = 257,
2401
Alexey Bataev49f6e782015-12-01 04:18:41 +00002402 /** \brief OpenMP taskloop directive.
2403 */
2404 CXCursor_OMPTaskLoopDirective = 258,
2405
Alexey Bataev0a6ed842015-12-03 09:40:15 +00002406 /** \brief OpenMP taskloop simd directive.
2407 */
2408 CXCursor_OMPTaskLoopSimdDirective = 259,
2409
Samuel Antao686c70c2016-05-26 17:30:50 +00002410 /** \brief OpenMP distribute directive.
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00002411 */
2412 CXCursor_OMPDistributeDirective = 260,
2413
Samuel Antaodf67fc42016-01-19 19:15:56 +00002414 /** \brief OpenMP target enter data directive.
2415 */
2416 CXCursor_OMPTargetEnterDataDirective = 261,
2417
Samuel Antao72590762016-01-19 20:04:50 +00002418 /** \brief OpenMP target exit data directive.
2419 */
2420 CXCursor_OMPTargetExitDataDirective = 262,
2421
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002422 /** \brief OpenMP target parallel directive.
2423 */
2424 CXCursor_OMPTargetParallelDirective = 263,
2425
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +00002426 /** \brief OpenMP target parallel for directive.
2427 */
2428 CXCursor_OMPTargetParallelForDirective = 264,
2429
Samuel Antao686c70c2016-05-26 17:30:50 +00002430 /** \brief OpenMP target update directive.
2431 */
2432 CXCursor_OMPTargetUpdateDirective = 265,
2433
Carlo Bertolli9925f152016-06-27 14:55:37 +00002434 /** \brief OpenMP distribute parallel for directive.
2435 */
2436 CXCursor_OMPDistributeParallelForDirective = 266,
2437
Kelvin Li4a39add2016-07-05 05:00:15 +00002438 /** \brief OpenMP distribute parallel for simd directive.
2439 */
2440 CXCursor_OMPDistributeParallelForSimdDirective = 267,
2441
Kelvin Li787f3fc2016-07-06 04:45:38 +00002442 /** \brief OpenMP distribute simd directive.
2443 */
2444 CXCursor_OMPDistributeSimdDirective = 268,
2445
Kelvin Lia579b912016-07-14 02:54:56 +00002446 /** \brief OpenMP target parallel for simd directive.
2447 */
2448 CXCursor_OMPTargetParallelForSimdDirective = 269,
2449
Kelvin Li986330c2016-07-20 22:57:10 +00002450 /** \brief OpenMP target simd directive.
2451 */
2452 CXCursor_OMPTargetSimdDirective = 270,
2453
Kelvin Li02532872016-08-05 14:37:37 +00002454 /** \brief OpenMP teams distribute directive.
2455 */
2456 CXCursor_OMPTeamsDistributeDirective = 271,
2457
Kelvin Li4e325f72016-10-25 12:50:55 +00002458 /** \brief OpenMP teams distribute simd directive.
2459 */
2460 CXCursor_OMPTeamsDistributeSimdDirective = 272,
2461
Kelvin Li579e41c2016-11-30 23:51:03 +00002462 /** \brief OpenMP teams distribute parallel for simd directive.
2463 */
2464 CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2465
Kelvin Li7ade93f2016-12-09 03:24:30 +00002466 /** \brief OpenMP teams distribute parallel for directive.
2467 */
2468 CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2469
Kelvin Libf594a52016-12-17 05:48:59 +00002470 /** \brief OpenMP target teams directive.
2471 */
2472 CXCursor_OMPTargetTeamsDirective = 275,
2473
Kelvin Li83c451e2016-12-25 04:52:54 +00002474 /** \brief OpenMP target teams distribute directive.
2475 */
2476 CXCursor_OMPTargetTeamsDistributeDirective = 276,
2477
Kelvin Li80e8f562016-12-29 22:16:30 +00002478 /** \brief OpenMP target teams distribute parallel for directive.
2479 */
2480 CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2481
Kelvin Li1851df52017-01-03 05:23:48 +00002482 /** \brief OpenMP target teams distribute parallel for simd directive.
2483 */
2484 CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2485
Kelvin Lida681182017-01-10 18:08:18 +00002486 /** \brief OpenMP target teams distribute simd directive.
2487 */
2488 CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2489
2490 CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002491
Douglas Gregor6007cf22010-01-22 22:29:16 +00002492 /**
2493 * \brief Cursor that represents the translation unit itself.
2494 *
2495 * The translation unit cursor exists primarily to act as the root
2496 * cursor for traversing the contents of a translation unit.
2497 */
Ted Kremenekbff31432010-02-18 03:09:07 +00002498 CXCursor_TranslationUnit = 300,
2499
Bill Wendling44426052012-12-20 19:22:21 +00002500 /* Attributes */
Ted Kremenekbff31432010-02-18 03:09:07 +00002501 CXCursor_FirstAttr = 400,
2502 /**
2503 * \brief An attribute whose specific kind is not exposed via this
2504 * interface.
2505 */
2506 CXCursor_UnexposedAttr = 400,
2507
2508 CXCursor_IBActionAttr = 401,
2509 CXCursor_IBOutletAttr = 402,
Ted Kremenek26bde772010-05-19 17:38:06 +00002510 CXCursor_IBOutletCollectionAttr = 403,
Argyrios Kyrtzidis2cb4e3c2011-09-13 17:39:31 +00002511 CXCursor_CXXFinalAttr = 404,
2512 CXCursor_CXXOverrideAttr = 405,
Erik Verbruggenca98f2a2011-10-13 09:41:32 +00002513 CXCursor_AnnotateAttr = 406,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00002514 CXCursor_AsmLabelAttr = 407,
Argyrios Kyrtzidis16834f12013-09-25 00:14:38 +00002515 CXCursor_PackedAttr = 408,
Joey Gouly81228382014-05-01 15:41:58 +00002516 CXCursor_PureAttr = 409,
2517 CXCursor_ConstAttr = 410,
2518 CXCursor_NoDuplicateAttr = 411,
Eli Bendersky2581e662014-05-28 19:29:58 +00002519 CXCursor_CUDAConstantAttr = 412,
2520 CXCursor_CUDADeviceAttr = 413,
2521 CXCursor_CUDAGlobalAttr = 414,
2522 CXCursor_CUDAHostAttr = 415,
Eli Bendersky9b071472014-08-08 14:59:00 +00002523 CXCursor_CUDASharedAttr = 416,
Saleem Abdulrasool79c69712015-09-05 18:53:43 +00002524 CXCursor_VisibilityAttr = 417,
Saleem Abdulrasool8aa0b802015-12-10 18:45:18 +00002525 CXCursor_DLLExport = 418,
2526 CXCursor_DLLImport = 419,
2527 CXCursor_LastAttr = CXCursor_DLLImport,
Eli Bendersky2581e662014-05-28 19:29:58 +00002528
Douglas Gregor92a524f2010-03-18 00:42:48 +00002529 /* Preprocessing */
2530 CXCursor_PreprocessingDirective = 500,
Douglas Gregor06d6d322010-03-18 18:04:21 +00002531 CXCursor_MacroDefinition = 501,
Chandler Carruth9e4704a2011-07-14 08:41:15 +00002532 CXCursor_MacroExpansion = 502,
2533 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
Douglas Gregor796d76a2010-10-20 22:00:55 +00002534 CXCursor_InclusionDirective = 503,
Douglas Gregor92a524f2010-03-18 00:42:48 +00002535 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002536 CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
2537
2538 /* Extra Declarations */
2539 /**
2540 * \brief A module import declaration.
2541 */
2542 CXCursor_ModuleImportDecl = 600,
Sergey Kalinichev8f3b1872015-11-15 13:48:32 +00002543 CXCursor_TypeAliasTemplateDecl = 601,
Olivier Goffart81978012016-06-09 16:15:55 +00002544 /**
2545 * \brief A static_assert or _Static_assert node
2546 */
2547 CXCursor_StaticAssert = 602,
Olivier Goffartd211c642016-11-04 06:29:27 +00002548 /**
2549 * \brief a friend declaration.
2550 */
2551 CXCursor_FriendDecl = 603,
Argyrios Kyrtzidis50e5b1d2012-10-05 00:22:24 +00002552 CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
Olivier Goffartd211c642016-11-04 06:29:27 +00002553 CXCursor_LastExtraDecl = CXCursor_FriendDecl,
Francisco Lopes da Silva975a9f62015-01-21 16:24:11 +00002554
2555 /**
2556 * \brief A code completion overload candidate.
2557 */
2558 CXCursor_OverloadCandidate = 700
Douglas Gregor6007cf22010-01-22 22:29:16 +00002559};
2560
2561/**
2562 * \brief A cursor representing some element in the abstract syntax tree for
2563 * a translation unit.
2564 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002565 * The cursor abstraction unifies the different kinds of entities in a
Douglas Gregor6007cf22010-01-22 22:29:16 +00002566 * program--declaration, statements, expressions, references to declarations,
2567 * etc.--under a single "cursor" abstraction with a common set of operations.
2568 * Common operation for a cursor include: getting the physical location in
2569 * a source file where the cursor points, getting the name associated with a
2570 * cursor, and retrieving cursors for any child nodes of a particular cursor.
2571 *
2572 * Cursors can be produced in two specific ways.
2573 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2574 * from which one can use clang_visitChildren() to explore the rest of the
2575 * translation unit. clang_getCursor() maps from a physical source location
2576 * to the entity that resides at that location, allowing one to map from the
2577 * source code into the AST.
2578 */
2579typedef struct {
2580 enum CXCursorKind kind;
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00002581 int xdata;
Dmitri Gribenkoba2f7462013-01-11 21:01:49 +00002582 const void *data[3];
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002583} CXCursor;
Douglas Gregor6007cf22010-01-22 22:29:16 +00002584
2585/**
2586 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2587 *
2588 * @{
2589 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002590
Douglas Gregor6007cf22010-01-22 22:29:16 +00002591/**
2592 * \brief Retrieve the NULL cursor, which represents no entity.
2593 */
2594CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002595
Douglas Gregor6007cf22010-01-22 22:29:16 +00002596/**
2597 * \brief Retrieve the cursor that represents the given translation unit.
2598 *
2599 * The translation unit cursor can be used to start traversing the
2600 * various declarations within the given translation unit.
2601 */
2602CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2603
2604/**
2605 * \brief Determine whether two cursors are equivalent.
2606 */
2607CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002608
Douglas Gregor6007cf22010-01-22 22:29:16 +00002609/**
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002610 * \brief Returns non-zero if \p cursor is null.
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002611 */
Dmitri Gribenko8994e0c2012-09-13 13:11:20 +00002612CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002613
2614/**
Douglas Gregor06a3f302010-11-20 00:09:34 +00002615 * \brief Compute a hash value for the given cursor.
2616 */
2617CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2618
2619/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00002620 * \brief Retrieve the kind of the given cursor.
2621 */
2622CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2623
2624/**
2625 * \brief Determine whether the given cursor kind represents a declaration.
2626 */
2627CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2628
2629/**
2630 * \brief Determine whether the given cursor kind represents a simple
2631 * reference.
2632 *
2633 * Note that other kinds of cursors (such as expressions) can also refer to
2634 * other cursors. Use clang_getCursorReferenced() to determine whether a
2635 * particular cursor refers to another entity.
2636 */
2637CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2638
2639/**
2640 * \brief Determine whether the given cursor kind represents an expression.
2641 */
2642CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2643
2644/**
2645 * \brief Determine whether the given cursor kind represents a statement.
2646 */
2647CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2648
2649/**
Douglas Gregora98034a2011-07-06 03:00:34 +00002650 * \brief Determine whether the given cursor kind represents an attribute.
2651 */
2652CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2653
2654/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00002655 * \brief Determine whether the given cursor has any attributes.
2656 */
2657CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2658
2659/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002660 * \brief Determine whether the given cursor kind represents an invalid
Douglas Gregor6007cf22010-01-22 22:29:16 +00002661 * cursor.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002662 */
Douglas Gregor6007cf22010-01-22 22:29:16 +00002663CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2664
2665/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002666 * \brief Determine whether the given cursor kind represents a translation
2667 * unit.
Douglas Gregor6007cf22010-01-22 22:29:16 +00002668 */
2669CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00002670
Ted Kremenekff9021b2010-03-08 21:17:29 +00002671/***
Douglas Gregor92a524f2010-03-18 00:42:48 +00002672 * \brief Determine whether the given cursor represents a preprocessing
2673 * element, such as a preprocessor directive or macro instantiation.
2674 */
2675CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2676
2677/***
Ted Kremenekff9021b2010-03-08 21:17:29 +00002678 * \brief Determine whether the given cursor represents a currently
2679 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2680 */
2681CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2682
Douglas Gregor6007cf22010-01-22 22:29:16 +00002683/**
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002684 * \brief Describe the linkage of the entity referred to by a cursor.
2685 */
2686enum CXLinkageKind {
2687 /** \brief This value indicates that no linkage information is available
2688 * for a provided CXCursor. */
2689 CXLinkage_Invalid,
2690 /**
2691 * \brief This is the linkage for variables, parameters, and so on that
2692 * have automatic storage. This covers normal (non-extern) local variables.
2693 */
2694 CXLinkage_NoLinkage,
2695 /** \brief This is the linkage for static variables and static functions. */
2696 CXLinkage_Internal,
2697 /** \brief This is the linkage for entities with external linkage that live
2698 * in C++ anonymous namespaces.*/
2699 CXLinkage_UniqueExternal,
2700 /** \brief This is the linkage for entities with true, external linkage. */
2701 CXLinkage_External
2702};
2703
2704/**
Ted Kremenek4ed29252010-04-12 21:22:16 +00002705 * \brief Determine the linkage of the entity referred to by a given cursor.
Ted Kremenekfb4961d2010-03-03 06:36:57 +00002706 */
2707CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2708
Ehsan Akhgarib743de72016-05-31 15:55:51 +00002709enum CXVisibilityKind {
2710 /** \brief This value indicates that no visibility information is available
2711 * for a provided CXCursor. */
2712 CXVisibility_Invalid,
2713
2714 /** \brief Symbol not seen by the linker. */
2715 CXVisibility_Hidden,
2716 /** \brief Symbol seen by the linker but resolves to a symbol inside this object. */
2717 CXVisibility_Protected,
2718 /** \brief Symbol seen by the linker and acts like a normal symbol. */
2719 CXVisibility_Default
2720};
2721
2722/**
2723 * \brief Describe the visibility of the entity referred to by a cursor.
2724 *
2725 * This returns the default visibility if not explicitly specified by
2726 * a visibility attribute. The default visibility may be changed by
2727 * commandline arguments.
2728 *
2729 * \param cursor The cursor to query.
2730 *
2731 * \returns The visibility of the cursor.
2732 */
2733CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2734
Ehsan Akhgari93697fa2015-11-23 19:56:46 +00002735/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002736 * \brief Determine the availability of the entity that this cursor refers to,
2737 * taking the current target platform into account.
Douglas Gregorf757a122010-08-23 23:00:57 +00002738 *
2739 * \param cursor The cursor to query.
2740 *
2741 * \returns The availability of the cursor.
2742 */
2743CINDEX_LINKAGE enum CXAvailabilityKind
2744clang_getCursorAvailability(CXCursor cursor);
2745
2746/**
Douglas Gregord6225d32012-05-08 00:14:45 +00002747 * Describes the availability of a given entity on a particular platform, e.g.,
2748 * a particular class might only be available on Mac OS 10.7 or newer.
2749 */
2750typedef struct CXPlatformAvailability {
2751 /**
2752 * \brief A string that describes the platform for which this structure
2753 * provides availability information.
2754 *
Manman Renccf25bb2016-06-28 20:55:30 +00002755 * Possible values are "ios" or "macos".
Douglas Gregord6225d32012-05-08 00:14:45 +00002756 */
2757 CXString Platform;
2758 /**
2759 * \brief The version number in which this entity was introduced.
2760 */
2761 CXVersion Introduced;
2762 /**
2763 * \brief The version number in which this entity was deprecated (but is
2764 * still available).
2765 */
2766 CXVersion Deprecated;
2767 /**
2768 * \brief The version number in which this entity was obsoleted, and therefore
2769 * is no longer available.
2770 */
2771 CXVersion Obsoleted;
2772 /**
2773 * \brief Whether the entity is unconditionally unavailable on this platform.
2774 */
2775 int Unavailable;
2776 /**
2777 * \brief An optional message to provide to a user of this API, e.g., to
2778 * suggest replacement APIs.
2779 */
2780 CXString Message;
2781} CXPlatformAvailability;
2782
2783/**
2784 * \brief Determine the availability of the entity that this cursor refers to
2785 * on any platforms for which availability information is known.
2786 *
2787 * \param cursor The cursor to query.
2788 *
2789 * \param always_deprecated If non-NULL, will be set to indicate whether the
2790 * entity is deprecated on all platforms.
2791 *
2792 * \param deprecated_message If non-NULL, will be set to the message text
2793 * provided along with the unconditional deprecation of this entity. The client
2794 * is responsible for deallocating this string.
2795 *
James Dennett574cb4c2012-06-15 05:41:51 +00002796 * \param always_unavailable If non-NULL, will be set to indicate whether the
Douglas Gregord6225d32012-05-08 00:14:45 +00002797 * entity is unavailable on all platforms.
2798 *
2799 * \param unavailable_message If non-NULL, will be set to the message text
2800 * provided along with the unconditional unavailability of this entity. The
2801 * client is responsible for deallocating this string.
2802 *
2803 * \param availability If non-NULL, an array of CXPlatformAvailability instances
2804 * that will be populated with platform availability information, up to either
2805 * the number of platforms for which availability information is available (as
2806 * returned by this function) or \c availability_size, whichever is smaller.
2807 *
2808 * \param availability_size The number of elements available in the
2809 * \c availability array.
2810 *
2811 * \returns The number of platforms (N) for which availability information is
2812 * available (which is unrelated to \c availability_size).
2813 *
2814 * Note that the client is responsible for calling
2815 * \c clang_disposeCXPlatformAvailability to free each of the
2816 * platform-availability structures returned. There are
2817 * \c min(N, availability_size) such structures.
2818 */
2819CINDEX_LINKAGE int
2820clang_getCursorPlatformAvailability(CXCursor cursor,
2821 int *always_deprecated,
2822 CXString *deprecated_message,
2823 int *always_unavailable,
2824 CXString *unavailable_message,
2825 CXPlatformAvailability *availability,
2826 int availability_size);
2827
2828/**
2829 * \brief Free the memory associated with a \c CXPlatformAvailability structure.
2830 */
2831CINDEX_LINKAGE void
2832clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2833
2834/**
Ted Kremenek4ed29252010-04-12 21:22:16 +00002835 * \brief Describe the "language" of the entity referred to by a cursor.
2836 */
Reid Kleckner9e3bc722013-12-30 17:48:49 +00002837enum CXLanguageKind {
Ted Kremenekee457512010-04-14 20:58:32 +00002838 CXLanguage_Invalid = 0,
Ted Kremenek4ed29252010-04-12 21:22:16 +00002839 CXLanguage_C,
2840 CXLanguage_ObjC,
Ted Kremenekee457512010-04-14 20:58:32 +00002841 CXLanguage_CPlusPlus
Ted Kremenek4ed29252010-04-12 21:22:16 +00002842};
2843
2844/**
2845 * \brief Determine the "language" of the entity referred to by a given cursor.
2846 */
2847CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2848
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002849/**
Saleem Abdulrasool50bc5652017-09-13 02:15:09 +00002850 * \brief Describe the "thread-local storage (TLS) kind" of the declaration
2851 * referred to by a cursor.
2852 */
2853enum CXTLSKind {
2854 CXTLS_None = 0,
2855 CXTLS_Dynamic,
2856 CXTLS_Static
2857};
2858
2859/**
2860 * \brief Determine the "thread-local storage (TLS) kind" of the declaration
2861 * referred to by a cursor.
2862 */
2863CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2864
2865/**
Argyrios Kyrtzidisd6e9fa52011-09-27 00:30:30 +00002866 * \brief Returns the translation unit that a cursor originated from.
2867 */
2868CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2869
Ted Kremenekc0b98662013-04-24 07:17:12 +00002870/**
2871 * \brief A fast container representing a set of CXCursors.
2872 */
2873typedef struct CXCursorSetImpl *CXCursorSet;
2874
2875/**
2876 * \brief Creates an empty CXCursorSet.
2877 */
2878CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2879
2880/**
2881 * \brief Disposes a CXCursorSet and releases its associated memory.
2882 */
2883CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2884
2885/**
2886 * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
2887 *
2888 * \returns non-zero if the set contains the specified cursor.
2889*/
2890CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2891 CXCursor cursor);
2892
2893/**
2894 * \brief Inserts a CXCursor into a CXCursorSet.
2895 *
2896 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2897*/
2898CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2899 CXCursor cursor);
2900
Douglas Gregor0576ce72010-09-22 21:22:29 +00002901/**
2902 * \brief Determine the semantic parent of the given cursor.
2903 *
2904 * The semantic parent of a cursor is the cursor that semantically contains
2905 * the given \p cursor. For many declarations, the lexical and semantic parents
2906 * are equivalent (the lexical parent is returned by
2907 * \c clang_getCursorLexicalParent()). They diverge when declarations or
2908 * definitions are provided out-of-line. For example:
2909 *
2910 * \code
2911 * class C {
2912 * void f();
2913 * };
2914 *
2915 * void C::f() { }
2916 * \endcode
2917 *
Nico Weber7deebef2014-04-24 03:17:47 +00002918 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00002919 * the class \c C, of which this function is a member. The lexical parent is
2920 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00002921 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00002922 * lexical parent for a given entity can change without affecting the semantics
2923 * of the program, and the lexical parent of different declarations of the
2924 * same entity may be different. Changing the semantic parent of a declaration,
2925 * on the other hand, can have a major impact on semantics, and redeclarations
2926 * of a particular entity should all have the same semantic context.
2927 *
2928 * In the example above, both declarations of \c C::f have \c C as their
2929 * semantic context, while the lexical context of the first \c C::f is \c C
2930 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00002931 *
2932 * For global declarations, the semantic parent is the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002933 */
2934CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
2935
2936/**
2937 * \brief Determine the lexical parent of the given cursor.
2938 *
2939 * The lexical parent of a cursor is the cursor in which the given \p cursor
2940 * was actually written. For many declarations, the lexical and semantic parents
2941 * are equivalent (the semantic parent is returned by
2942 * \c clang_getCursorSemanticParent()). They diverge when declarations or
2943 * definitions are provided out-of-line. For example:
2944 *
2945 * \code
2946 * class C {
2947 * void f();
2948 * };
2949 *
2950 * void C::f() { }
2951 * \endcode
2952 *
Nico Weber7deebef2014-04-24 03:17:47 +00002953 * In the out-of-line definition of \c C::f, the semantic parent is
Douglas Gregor0576ce72010-09-22 21:22:29 +00002954 * the class \c C, of which this function is a member. The lexical parent is
2955 * the place where the declaration actually occurs in the source code; in this
Nico Weber7deebef2014-04-24 03:17:47 +00002956 * case, the definition occurs in the translation unit. In general, the
Douglas Gregor0576ce72010-09-22 21:22:29 +00002957 * lexical parent for a given entity can change without affecting the semantics
2958 * of the program, and the lexical parent of different declarations of the
2959 * same entity may be different. Changing the semantic parent of a declaration,
2960 * on the other hand, can have a major impact on semantics, and redeclarations
2961 * of a particular entity should all have the same semantic context.
2962 *
2963 * In the example above, both declarations of \c C::f have \c C as their
2964 * semantic context, while the lexical context of the first \c C::f is \c C
2965 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor7ecd19e2010-12-21 07:55:45 +00002966 *
2967 * For declarations written in the global scope, the lexical parent is
2968 * the translation unit.
Douglas Gregor0576ce72010-09-22 21:22:29 +00002969 */
2970CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
Douglas Gregor99a26af2010-10-01 20:25:15 +00002971
2972/**
2973 * \brief Determine the set of methods that are overridden by the given
2974 * method.
2975 *
2976 * In both Objective-C and C++, a method (aka virtual member function,
2977 * in C++) can override a virtual method in a base class. For
2978 * Objective-C, a method is said to override any method in the class's
Argyrios Kyrtzidisbfb24252012-03-08 00:20:03 +00002979 * base class, its protocols, or its categories' protocols, that has the same
2980 * selector and is of the same kind (class or instance).
2981 * If no such method exists, the search continues to the class's superclass,
2982 * its protocols, and its categories, and so on. A method from an Objective-C
2983 * implementation is considered to override the same methods as its
2984 * corresponding method in the interface.
Douglas Gregor99a26af2010-10-01 20:25:15 +00002985 *
2986 * For C++, a virtual member function overrides any virtual member
2987 * function with the same signature that occurs in its base
2988 * classes. With multiple inheritance, a virtual member function can
2989 * override several virtual member functions coming from different
2990 * base classes.
2991 *
2992 * In all cases, this function determines the immediate overridden
2993 * method, rather than all of the overridden methods. For example, if
2994 * a method is originally declared in a class A, then overridden in B
2995 * (which in inherits from A) and also in C (which inherited from B),
2996 * then the only overridden method returned from this function when
2997 * invoked on C's method will be B's method. The client may then
2998 * invoke this function again, given the previously-found overridden
2999 * methods, to map out the complete method-override set.
3000 *
3001 * \param cursor A cursor representing an Objective-C or C++
3002 * method. This routine will compute the set of methods that this
3003 * method overrides.
3004 *
3005 * \param overridden A pointer whose pointee will be replaced with a
3006 * pointer to an array of cursors, representing the set of overridden
3007 * methods. If there are no overridden methods, the pointee will be
3008 * set to NULL. The pointee must be freed via a call to
3009 * \c clang_disposeOverriddenCursors().
3010 *
3011 * \param num_overridden A pointer to the number of overridden
3012 * functions, will be set to the number of overridden functions in the
3013 * array pointed to by \p overridden.
3014 */
3015CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
3016 CXCursor **overridden,
3017 unsigned *num_overridden);
3018
3019/**
3020 * \brief Free the set of overridden cursors returned by \c
3021 * clang_getOverriddenCursors().
3022 */
3023CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3024
Ted Kremenek4ed29252010-04-12 21:22:16 +00003025/**
Douglas Gregor796d76a2010-10-20 22:00:55 +00003026 * \brief Retrieve the file that is included by the given inclusion directive
3027 * cursor.
3028 */
3029CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
3030
3031/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003032 * @}
3033 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003034
Douglas Gregor6007cf22010-01-22 22:29:16 +00003035/**
3036 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3037 *
3038 * Cursors represent a location within the Abstract Syntax Tree (AST). These
3039 * routines help map between cursors and the physical locations where the
3040 * described entities occur in the source code. The mapping is provided in
3041 * both directions, so one can map from source code to the AST and back.
3042 *
3043 * @{
Steve Naroffa1c72842009-08-28 15:28:48 +00003044 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003045
Steve Naroff20bad0b2009-10-21 13:56:23 +00003046/**
Douglas Gregor816fd362010-01-22 21:44:22 +00003047 * \brief Map a source location to the cursor that describes the entity at that
3048 * location in the source code.
3049 *
3050 * clang_getCursor() maps an arbitrary source location within a translation
3051 * unit down to the most specific cursor that describes the entity at that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003052 * location. For example, given an expression \c x + y, invoking
Douglas Gregor816fd362010-01-22 21:44:22 +00003053 * clang_getCursor() with a source location pointing to "x" will return the
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003054 * cursor for "x"; similarly for "y". If the cursor points anywhere between
Douglas Gregor816fd362010-01-22 21:44:22 +00003055 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3056 * will return a cursor referring to the "+" expression.
3057 *
3058 * \returns a cursor representing the entity at the given source location, or
3059 * a NULL cursor if no such entity can be found.
Steve Naroff20bad0b2009-10-21 13:56:23 +00003060 */
Douglas Gregor816fd362010-01-22 21:44:22 +00003061CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003062
Douglas Gregor66a58812010-01-18 22:46:11 +00003063/**
3064 * \brief Retrieve the physical location of the source constructor referenced
3065 * by the given cursor.
3066 *
3067 * The location of a declaration is typically the location of the name of that
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003068 * declaration, where the name of that declaration would occur if it is
3069 * unnamed, or some keyword that introduces that particular declaration.
3070 * The location of a reference is where that reference occurs within the
Douglas Gregor66a58812010-01-18 22:46:11 +00003071 * source code.
3072 */
3073CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
Douglas Gregor6007cf22010-01-22 22:29:16 +00003074
Douglas Gregor6b8232f2010-01-19 19:34:47 +00003075/**
3076 * \brief Retrieve the physical extent of the source construct referenced by
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003077 * the given cursor.
3078 *
3079 * The extent of a cursor starts with the file/line/column pointing at the
3080 * first character within the source construct that the cursor refers to and
Nico Weber7deebef2014-04-24 03:17:47 +00003081 * ends with the last character within that source construct. For a
Douglas Gregor33c34ac2010-01-19 00:34:46 +00003082 * declaration, the extent covers the declaration itself. For a reference,
3083 * the extent covers the location of the reference (e.g., where the referenced
3084 * entity was actually used).
3085 */
3086CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
Douglas Gregorad27e8b2010-01-19 01:20:04 +00003087
Douglas Gregor6007cf22010-01-22 22:29:16 +00003088/**
3089 * @}
3090 */
Ted Kremeneka5940822010-08-26 01:42:22 +00003091
Douglas Gregor6007cf22010-01-22 22:29:16 +00003092/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003093 * \defgroup CINDEX_TYPES Type information for CXCursors
3094 *
3095 * @{
3096 */
3097
3098/**
3099 * \brief Describes the kind of type
3100 */
3101enum CXTypeKind {
3102 /**
Nico Weber7deebef2014-04-24 03:17:47 +00003103 * \brief Represents an invalid type (e.g., where no type is available).
Ted Kremenek6bca9842010-05-14 21:29:26 +00003104 */
3105 CXType_Invalid = 0,
3106
3107 /**
3108 * \brief A type whose specific kind is not exposed via this
3109 * interface.
3110 */
3111 CXType_Unexposed = 1,
3112
3113 /* Builtin types */
3114 CXType_Void = 2,
3115 CXType_Bool = 3,
3116 CXType_Char_U = 4,
3117 CXType_UChar = 5,
3118 CXType_Char16 = 6,
3119 CXType_Char32 = 7,
3120 CXType_UShort = 8,
3121 CXType_UInt = 9,
3122 CXType_ULong = 10,
3123 CXType_ULongLong = 11,
3124 CXType_UInt128 = 12,
3125 CXType_Char_S = 13,
3126 CXType_SChar = 14,
3127 CXType_WChar = 15,
3128 CXType_Short = 16,
3129 CXType_Int = 17,
3130 CXType_Long = 18,
3131 CXType_LongLong = 19,
3132 CXType_Int128 = 20,
3133 CXType_Float = 21,
3134 CXType_Double = 22,
3135 CXType_LongDouble = 23,
3136 CXType_NullPtr = 24,
3137 CXType_Overload = 25,
3138 CXType_Dependent = 26,
3139 CXType_ObjCId = 27,
3140 CXType_ObjCClass = 28,
3141 CXType_ObjCSel = 29,
Nemanja Ivanovicbb1ea2d2016-05-09 08:52:33 +00003142 CXType_Float128 = 30,
Joey Gouly6ea21852017-02-10 15:51:11 +00003143 CXType_Half = 31,
Sjoerd Meijercc623ad2017-09-08 15:15:00 +00003144 CXType_Float16 = 32,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003145 CXType_FirstBuiltin = CXType_Void,
Sjoerd Meijercc623ad2017-09-08 15:15:00 +00003146 CXType_LastBuiltin = CXType_Float16,
Ted Kremenek6bca9842010-05-14 21:29:26 +00003147
3148 CXType_Complex = 100,
3149 CXType_Pointer = 101,
3150 CXType_BlockPointer = 102,
3151 CXType_LValueReference = 103,
3152 CXType_RValueReference = 104,
3153 CXType_Record = 105,
3154 CXType_Enum = 106,
3155 CXType_Typedef = 107,
3156 CXType_ObjCInterface = 108,
Ted Kremenekc1508872010-06-21 20:15:39 +00003157 CXType_ObjCObjectPointer = 109,
3158 CXType_FunctionNoProto = 110,
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003159 CXType_FunctionProto = 111,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003160 CXType_ConstantArray = 112,
Argyrios Kyrtzidis0661a712013-07-23 17:36:21 +00003161 CXType_Vector = 113,
3162 CXType_IncompleteArray = 114,
3163 CXType_VariableArray = 115,
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003164 CXType_DependentSizedArray = 116,
Sergey Kalinichevc0151202015-11-15 13:10:10 +00003165 CXType_MemberPointer = 117,
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003166 CXType_Auto = 118,
3167
3168 /**
3169 * \brief Represents a type that was referred to using an elaborated type keyword.
3170 *
3171 * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3172 */
Sven van Haastregtcc4f1e42017-05-23 10:36:43 +00003173 CXType_Elaborated = 119,
3174
3175 /* OpenCL PipeType. */
3176 CXType_Pipe = 120,
3177
3178 /* OpenCL builtin types. */
3179 CXType_OCLImage1dRO = 121,
3180 CXType_OCLImage1dArrayRO = 122,
3181 CXType_OCLImage1dBufferRO = 123,
3182 CXType_OCLImage2dRO = 124,
3183 CXType_OCLImage2dArrayRO = 125,
3184 CXType_OCLImage2dDepthRO = 126,
3185 CXType_OCLImage2dArrayDepthRO = 127,
3186 CXType_OCLImage2dMSAARO = 128,
3187 CXType_OCLImage2dArrayMSAARO = 129,
3188 CXType_OCLImage2dMSAADepthRO = 130,
3189 CXType_OCLImage2dArrayMSAADepthRO = 131,
3190 CXType_OCLImage3dRO = 132,
3191 CXType_OCLImage1dWO = 133,
3192 CXType_OCLImage1dArrayWO = 134,
3193 CXType_OCLImage1dBufferWO = 135,
3194 CXType_OCLImage2dWO = 136,
3195 CXType_OCLImage2dArrayWO = 137,
3196 CXType_OCLImage2dDepthWO = 138,
3197 CXType_OCLImage2dArrayDepthWO = 139,
3198 CXType_OCLImage2dMSAAWO = 140,
3199 CXType_OCLImage2dArrayMSAAWO = 141,
3200 CXType_OCLImage2dMSAADepthWO = 142,
3201 CXType_OCLImage2dArrayMSAADepthWO = 143,
3202 CXType_OCLImage3dWO = 144,
3203 CXType_OCLImage1dRW = 145,
3204 CXType_OCLImage1dArrayRW = 146,
3205 CXType_OCLImage1dBufferRW = 147,
3206 CXType_OCLImage2dRW = 148,
3207 CXType_OCLImage2dArrayRW = 149,
3208 CXType_OCLImage2dDepthRW = 150,
3209 CXType_OCLImage2dArrayDepthRW = 151,
3210 CXType_OCLImage2dMSAARW = 152,
3211 CXType_OCLImage2dArrayMSAARW = 153,
3212 CXType_OCLImage2dMSAADepthRW = 154,
3213 CXType_OCLImage2dArrayMSAADepthRW = 155,
3214 CXType_OCLImage3dRW = 156,
3215 CXType_OCLSampler = 157,
3216 CXType_OCLEvent = 158,
3217 CXType_OCLQueue = 159,
3218 CXType_OCLReserveID = 160
Ted Kremenek6bca9842010-05-14 21:29:26 +00003219};
3220
3221/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003222 * \brief Describes the calling convention of a function type
3223 */
3224enum CXCallingConv {
3225 CXCallingConv_Default = 0,
3226 CXCallingConv_C = 1,
3227 CXCallingConv_X86StdCall = 2,
3228 CXCallingConv_X86FastCall = 3,
3229 CXCallingConv_X86ThisCall = 4,
3230 CXCallingConv_X86Pascal = 5,
3231 CXCallingConv_AAPCS = 6,
3232 CXCallingConv_AAPCS_VFP = 7,
Erich Keane757d3172016-11-02 18:29:35 +00003233 CXCallingConv_X86RegCall = 8,
Guy Benyeif0a014b2012-12-25 08:53:55 +00003234 CXCallingConv_IntelOclBicc = 9,
Martin Storsjo022e7822017-07-17 20:49:45 +00003235 CXCallingConv_Win64 = 10,
Nikolai Bozhenovce25d412017-08-08 14:13:50 +00003236 /* Alias for compatibility with older versions of API. */
3237 CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
Charles Davisb5a214e2013-08-30 04:39:01 +00003238 CXCallingConv_X86_64SysV = 11,
Reid Klecknerd7857f02014-10-24 17:42:17 +00003239 CXCallingConv_X86VectorCall = 12,
John McCall477f2bb2016-03-03 06:39:32 +00003240 CXCallingConv_Swift = 13,
Roman Levenstein35aa5ce2016-03-16 18:00:46 +00003241 CXCallingConv_PreserveMost = 14,
3242 CXCallingConv_PreserveAll = 15,
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003243
3244 CXCallingConv_Invalid = 100,
3245 CXCallingConv_Unexposed = 200
3246};
3247
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003248/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003249 * \brief The type of an element in the abstract syntax tree.
3250 *
3251 */
3252typedef struct {
3253 enum CXTypeKind kind;
3254 void *data[2];
3255} CXType;
3256
3257/**
3258 * \brief Retrieve the type of a CXCursor (if any).
3259 */
3260CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3261
3262/**
Dmitri Gribenko00353722013-02-15 21:15:49 +00003263 * \brief Pretty-print the underlying type using the rules of the
3264 * language of the translation unit from which it came.
3265 *
3266 * If the type is invalid, an empty string is returned.
3267 */
3268CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3269
3270/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003271 * \brief Retrieve the underlying type of a typedef declaration.
3272 *
3273 * If the cursor does not reference a typedef declaration, an invalid type is
3274 * returned.
3275 */
3276CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3277
3278/**
3279 * \brief Retrieve the integer type of an enum declaration.
3280 *
3281 * If the cursor does not reference an enum declaration, an invalid type is
3282 * returned.
3283 */
3284CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3285
3286/**
3287 * \brief Retrieve the integer value of an enum constant declaration as a signed
3288 * long long.
3289 *
3290 * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3291 * Since this is also potentially a valid constant value, the kind of the cursor
3292 * must be verified before calling this function.
3293 */
3294CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3295
3296/**
3297 * \brief Retrieve the integer value of an enum constant declaration as an unsigned
3298 * long long.
3299 *
3300 * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3301 * Since this is also potentially a valid constant value, the kind of the cursor
3302 * must be verified before calling this function.
3303 */
3304CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3305
3306/**
Dmitri Gribenkob506ba12012-12-04 15:13:46 +00003307 * \brief Retrieve the bit width of a bit field declaration as an integer.
3308 *
3309 * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3310 */
3311CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3312
3313/**
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003314 * \brief Retrieve the number of non-variadic arguments associated with a given
3315 * cursor.
3316 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003317 * The number of arguments can be determined for calls as well as for
3318 * declarations of functions or methods. For other cursors -1 is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003319 */
3320CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3321
3322/**
3323 * \brief Retrieve the argument cursor of a function or method.
3324 *
Argyrios Kyrtzidisb2792972013-04-01 17:38:59 +00003325 * The argument cursor can be determined for calls as well as for declarations
3326 * of functions or methods. For other cursors and for invalid indices, an
3327 * invalid cursor is returned.
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003328 */
3329CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3330
3331/**
Eli Benderskyc27a0c42014-10-10 20:01:05 +00003332 * \brief Describes the kind of a template argument.
3333 *
3334 * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3335 * element descriptions.
3336 */
3337enum CXTemplateArgumentKind {
3338 CXTemplateArgumentKind_Null,
3339 CXTemplateArgumentKind_Type,
3340 CXTemplateArgumentKind_Declaration,
3341 CXTemplateArgumentKind_NullPtr,
3342 CXTemplateArgumentKind_Integral,
3343 CXTemplateArgumentKind_Template,
3344 CXTemplateArgumentKind_TemplateExpansion,
3345 CXTemplateArgumentKind_Expression,
3346 CXTemplateArgumentKind_Pack,
3347 /* Indicates an error case, preventing the kind from being deduced. */
3348 CXTemplateArgumentKind_Invalid
3349};
3350
3351/**
3352 *\brief Returns the number of template args of a function decl representing a
3353 * template specialization.
3354 *
3355 * If the argument cursor cannot be converted into a template function
3356 * declaration, -1 is returned.
3357 *
3358 * For example, for the following declaration and specialization:
3359 * template <typename T, int kInt, bool kBool>
3360 * void foo() { ... }
3361 *
3362 * template <>
3363 * void foo<float, -7, true>();
3364 *
3365 * The value 3 would be returned from this call.
3366 */
3367CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3368
3369/**
3370 * \brief Retrieve the kind of the I'th template argument of the CXCursor C.
3371 *
3372 * If the argument CXCursor does not represent a FunctionDecl, an invalid
3373 * template argument kind is returned.
3374 *
3375 * For example, for the following declaration and specialization:
3376 * template <typename T, int kInt, bool kBool>
3377 * void foo() { ... }
3378 *
3379 * template <>
3380 * void foo<float, -7, true>();
3381 *
3382 * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3383 * respectively.
3384 */
3385CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3386 CXCursor C, unsigned I);
3387
3388/**
3389 * \brief Retrieve a CXType representing the type of a TemplateArgument of a
3390 * function decl representing a template specialization.
3391 *
3392 * If the argument CXCursor does not represent a FunctionDecl whose I'th
3393 * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3394 * is returned.
3395 *
3396 * For example, for the following declaration and specialization:
3397 * template <typename T, int kInt, bool kBool>
3398 * void foo() { ... }
3399 *
3400 * template <>
3401 * void foo<float, -7, true>();
3402 *
3403 * If called with I = 0, "float", will be returned.
3404 * Invalid types will be returned for I == 1 or 2.
3405 */
3406CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3407 unsigned I);
3408
3409/**
3410 * \brief Retrieve the value of an Integral TemplateArgument (of a function
3411 * decl representing a template specialization) as a signed long long.
3412 *
3413 * It is undefined to call this function on a CXCursor that does not represent a
3414 * FunctionDecl or whose I'th template argument is not an integral value.
3415 *
3416 * For example, for the following declaration and specialization:
3417 * template <typename T, int kInt, bool kBool>
3418 * void foo() { ... }
3419 *
3420 * template <>
3421 * void foo<float, -7, true>();
3422 *
3423 * If called with I = 1 or 2, -7 or true will be returned, respectively.
3424 * For I == 0, this function's behavior is undefined.
3425 */
3426CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3427 unsigned I);
3428
3429/**
3430 * \brief Retrieve the value of an Integral TemplateArgument (of a function
3431 * decl representing a template specialization) as an unsigned long long.
3432 *
3433 * It is undefined to call this function on a CXCursor that does not represent a
3434 * FunctionDecl or whose I'th template argument is not an integral value.
3435 *
3436 * For example, for the following declaration and specialization:
3437 * template <typename T, int kInt, bool kBool>
3438 * void foo() { ... }
3439 *
3440 * template <>
3441 * void foo<float, 2147483649, true>();
3442 *
3443 * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3444 * For I == 0, this function's behavior is undefined.
3445 */
3446CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3447 CXCursor C, unsigned I);
3448
3449/**
James Dennett574cb4c2012-06-15 05:41:51 +00003450 * \brief Determine whether two CXTypes represent the same type.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003451 *
James Dennett574cb4c2012-06-15 05:41:51 +00003452 * \returns non-zero if the CXTypes represent the same type and
3453 * zero otherwise.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003454 */
3455CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3456
3457/**
3458 * \brief Return the canonical type for a CXType.
3459 *
3460 * Clang's type system explicitly models typedefs and all the ways
3461 * a specific type can be represented. The canonical type is the underlying
3462 * type with all the "sugar" removed. For example, if 'T' is a typedef
3463 * for 'int', the canonical type for 'T' would be 'int'.
3464 */
3465CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3466
3467/**
James Dennett574cb4c2012-06-15 05:41:51 +00003468 * \brief Determine whether a CXType has the "const" qualifier set,
3469 * without looking through typedefs that may have added "const" at a
3470 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003471 */
3472CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3473
3474/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003475 * \brief Determine whether a CXCursor that is a macro, is
3476 * function like.
3477 */
3478CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3479
3480/**
3481 * \brief Determine whether a CXCursor that is a macro, is a
3482 * builtin one.
3483 */
3484CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3485
3486/**
3487 * \brief Determine whether a CXCursor that is a function declaration, is an
3488 * inline declaration.
3489 */
3490CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3491
3492/**
James Dennett574cb4c2012-06-15 05:41:51 +00003493 * \brief Determine whether a CXType has the "volatile" qualifier set,
3494 * without looking through typedefs that may have added "volatile" at
3495 * a different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003496 */
3497CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3498
3499/**
James Dennett574cb4c2012-06-15 05:41:51 +00003500 * \brief Determine whether a CXType has the "restrict" qualifier set,
3501 * without looking through typedefs that may have added "restrict" at a
3502 * different level.
Douglas Gregor56a63802011-01-27 16:27:11 +00003503 */
3504CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3505
3506/**
Sven van Haastregte8910422017-06-08 14:22:04 +00003507 * \brief Returns the address space of the given type.
3508 */
3509CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3510
3511/**
3512 * \brief Returns the typedef name of the given type.
3513 */
3514CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3515
3516/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003517 * \brief For pointer types, returns the type of the pointee.
Ted Kremenek6bca9842010-05-14 21:29:26 +00003518 */
3519CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3520
3521/**
3522 * \brief Return the cursor for the declaration of the given type.
3523 */
3524CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3525
David Chisnall50e4eba2010-12-30 14:05:53 +00003526/**
3527 * Returns the Objective-C type encoding for the specified declaration.
3528 */
3529CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
Ted Kremenek6bca9842010-05-14 21:29:26 +00003530
3531/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00003532 * Returns the Objective-C type encoding for the specified CXType.
3533 */
3534CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3535
3536/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003537 * \brief Retrieve the spelling of a given CXTypeKind.
3538 */
3539CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3540
3541/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003542 * \brief Retrieve the calling convention associated with a function type.
3543 *
3544 * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3545 */
3546CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3547
3548/**
Alp Toker314cc812014-01-25 16:55:45 +00003549 * \brief Retrieve the return type associated with a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003550 *
3551 * If a non-function type is passed in, an invalid type is returned.
Ted Kremenekc1508872010-06-21 20:15:39 +00003552 */
3553CINDEX_LINKAGE CXType clang_getResultType(CXType T);
3554
3555/**
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003556 * \brief Retrieve the exception specification type associated with a function type.
3557 *
3558 * If a non-function type is passed in, an error code of -1 is returned.
3559 */
3560CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3561
3562/**
Alp Toker601b22c2014-01-21 23:35:24 +00003563 * \brief Retrieve the number of non-variadic parameters associated with a
James Dennett574cb4c2012-06-15 05:41:51 +00003564 * function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003565 *
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003566 * If a non-function type is passed in, -1 is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003567 */
Argyrios Kyrtzidis0c27e4b2012-04-11 19:32:19 +00003568CINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003569
3570/**
Alp Toker601b22c2014-01-21 23:35:24 +00003571 * \brief Retrieve the type of a parameter of a function type.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003572 *
James Dennett574cb4c2012-06-15 05:41:51 +00003573 * If a non-function type is passed in or the function does not have enough
3574 * parameters, an invalid type is returned.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003575 */
3576CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3577
3578/**
3579 * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003580 */
3581CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3582
3583/**
Alp Toker314cc812014-01-25 16:55:45 +00003584 * \brief Retrieve the return type associated with a given cursor.
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003585 *
3586 * This only returns a valid type if the cursor refers to a function or method.
Ted Kremenekc62ab8d2010-06-21 20:48:56 +00003587 */
3588CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3589
3590/**
Jonathan Coe0a5b03b2017-06-27 22:54:56 +00003591 * \brief Retrieve the exception specification type associated with a given cursor.
3592 *
3593 * This only returns a valid result if the cursor refers to a function or method.
3594 */
3595CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3596
3597/**
Ted Kremenek0c7476a2010-07-30 00:14:11 +00003598 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
3599 * otherwise.
3600 */
3601CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3602
3603/**
Argyrios Kyrtzidis66f433a2011-12-06 22:05:01 +00003604 * \brief Return the element type of an array, complex, or vector type.
3605 *
3606 * If a type is passed in that is not an array, complex, or vector type,
3607 * an invalid type is returned.
3608 */
3609CINDEX_LINKAGE CXType clang_getElementType(CXType T);
3610
3611/**
3612 * \brief Return the number of elements of an array or vector type.
3613 *
3614 * If a type is passed in that is not an array or vector type,
3615 * -1 is returned.
3616 */
3617CINDEX_LINKAGE long long clang_getNumElements(CXType T);
3618
3619/**
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003620 * \brief Return the element type of an array type.
3621 *
3622 * If a non-array type is passed in, an invalid type is returned.
3623 */
3624CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3625
3626/**
Sylvestre Ledru830885c2012-07-23 08:59:39 +00003627 * \brief Return the array size of a constant array.
Argyrios Kyrtzidis2b0cf602011-09-27 17:44:34 +00003628 *
3629 * If a non-array type is passed in, -1 is returned.
3630 */
3631CINDEX_LINKAGE long long clang_getArraySize(CXType T);
3632
3633/**
Sergey Kalinichev69770ae2016-05-03 06:58:29 +00003634 * \brief Retrieve the type named by the qualified-id.
3635 *
3636 * If a non-elaborated type is passed in, an invalid type is returned.
3637 */
3638CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3639
3640/**
Argyrios Kyrtzidis3b25c912017-03-21 16:56:02 +00003641 * \brief Determine if a typedef is 'transparent' tag.
3642 *
3643 * A typedef is considered 'transparent' if it shares a name and spelling
3644 * location with its underlying tag type, as is the case with the NS_ENUM macro.
3645 *
3646 * \returns non-zero if transparent and zero otherwise.
3647 */
3648CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3649
3650/**
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003651 * \brief List the possible error codes for \c clang_Type_getSizeOf,
3652 * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3653 * \c clang_Cursor_getOffsetOf.
3654 *
3655 * A value of this enumeration type can be returned if the target type is not
3656 * a valid argument to sizeof, alignof or offsetof.
3657 */
3658enum CXTypeLayoutError {
3659 /**
3660 * \brief Type is of kind CXType_Invalid.
3661 */
3662 CXTypeLayoutError_Invalid = -1,
3663 /**
3664 * \brief The type is an incomplete Type.
3665 */
3666 CXTypeLayoutError_Incomplete = -2,
3667 /**
3668 * \brief The type is a dependent Type.
3669 */
3670 CXTypeLayoutError_Dependent = -3,
3671 /**
3672 * \brief The type is not a constant size type.
3673 */
3674 CXTypeLayoutError_NotConstantSize = -4,
3675 /**
3676 * \brief The Field name is not valid for this record.
3677 */
3678 CXTypeLayoutError_InvalidFieldName = -5
3679};
3680
3681/**
3682 * \brief Return the alignment of a type in bytes as per C++[expr.alignof]
3683 * standard.
3684 *
3685 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3686 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3687 * is returned.
3688 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3689 * returned.
3690 * If the type declaration is not a constant size type,
3691 * CXTypeLayoutError_NotConstantSize is returned.
3692 */
3693CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3694
3695/**
Argyrios Kyrtzidis7a4253b2013-10-03 16:19:23 +00003696 * \brief Return the class type of an member pointer type.
3697 *
3698 * If a non-member-pointer type is passed in, an invalid type is returned.
3699 */
3700CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3701
3702/**
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003703 * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard.
3704 *
3705 * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3706 * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3707 * is returned.
3708 * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3709 * returned.
3710 */
3711CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3712
3713/**
3714 * \brief Return the offset of a field named S in a record of type T in bits
3715 * as it would be returned by __offsetof__ as per C++11[18.2p4]
3716 *
3717 * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3718 * is returned.
3719 * If the field's type declaration is an incomplete type,
3720 * CXTypeLayoutError_Incomplete is returned.
3721 * If the field's type declaration is a dependent type,
3722 * CXTypeLayoutError_Dependent is returned.
3723 * If the field's name S is not found,
3724 * CXTypeLayoutError_InvalidFieldName is returned.
3725 */
3726CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3727
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00003728/**
3729 * \brief Return the offset of the field represented by the Cursor.
3730 *
3731 * If the cursor is not a field declaration, -1 is returned.
3732 * If the cursor semantic parent is not a record field declaration,
3733 * CXTypeLayoutError_Invalid is returned.
3734 * If the field's type declaration is an incomplete type,
3735 * CXTypeLayoutError_Incomplete is returned.
3736 * If the field's type declaration is a dependent type,
3737 * CXTypeLayoutError_Dependent is returned.
3738 * If the field's name S is not found,
3739 * CXTypeLayoutError_InvalidFieldName is returned.
3740 */
3741CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3742
3743/**
3744 * \brief Determine whether the given cursor represents an anonymous record
3745 * declaration.
3746 */
3747CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3748
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003749enum CXRefQualifierKind {
3750 /** \brief No ref-qualifier was provided. */
3751 CXRefQualifier_None = 0,
3752 /** \brief An lvalue ref-qualifier was provided (\c &). */
3753 CXRefQualifier_LValue,
3754 /** \brief An rvalue ref-qualifier was provided (\c &&). */
3755 CXRefQualifier_RValue
3756};
3757
3758/**
Argyrios Kyrtzidis35f5aab2016-11-15 20:51:46 +00003759 * \brief Returns the number of template arguments for given template
3760 * specialization, or -1 if type \c T is not a template specialization.
Dmitri Gribenko6ede6ab2014-02-27 16:05:05 +00003761 */
3762CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3763
3764/**
3765 * \brief Returns the type template argument of a template class specialization
3766 * at given index.
3767 *
3768 * This function only returns template type arguments and does not handle
3769 * template template arguments or variadic packs.
3770 */
3771CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
3772
3773/**
Argyrios Kyrtzidisadff3ae2013-10-11 19:58:38 +00003774 * \brief Retrieve the ref-qualifier kind of a function or method.
3775 *
3776 * The ref-qualifier is returned for C++ functions or methods. For other types
3777 * or non-C++ declarations, CXRefQualifier_None is returned.
3778 */
3779CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3780
Argyrios Kyrtzidise822f582013-04-11 01:20:11 +00003781/**
3782 * \brief Returns non-zero if the cursor specifies a Record member that is a
3783 * bitfield.
3784 */
3785CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3786
3787/**
Ted Kremenekae9e2212010-08-27 21:34:58 +00003788 * \brief Returns 1 if the base class specified by the cursor with kind
3789 * CX_CXXBaseSpecifier is virtual.
3790 */
3791CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3792
3793/**
3794 * \brief Represents the C++ access control level to a base class for a
3795 * cursor with kind CX_CXXBaseSpecifier.
3796 */
3797enum CX_CXXAccessSpecifier {
3798 CX_CXXInvalidAccessSpecifier,
3799 CX_CXXPublic,
3800 CX_CXXProtected,
3801 CX_CXXPrivate
3802};
3803
3804/**
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00003805 * \brief Returns the access control level for the referenced object.
Argyrios Kyrtzidisf6464082013-04-11 17:31:13 +00003806 *
Argyrios Kyrtzidis1ab09cc2013-04-11 17:02:10 +00003807 * If the cursor refers to a C++ declaration, its access control level within its
3808 * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3809 * access specifier, the specifier itself is returned.
Ted Kremenekae9e2212010-08-27 21:34:58 +00003810 */
3811CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3812
3813/**
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00003814 * \brief Represents the storage classes as declared in the source. CX_SC_Invalid
Chad Rosierdb1cc7f2014-12-05 15:50:44 +00003815 * was added for the case that the passed cursor in not a declaration.
Argyrios Kyrtzidis4e0854f2014-10-15 17:05:31 +00003816 */
3817enum CX_StorageClass {
3818 CX_SC_Invalid,
3819 CX_SC_None,
3820 CX_SC_Extern,
3821 CX_SC_Static,
3822 CX_SC_PrivateExtern,
3823 CX_SC_OpenCLWorkGroupLocal,
3824 CX_SC_Auto,
3825 CX_SC_Register
3826};
3827
3828/**
3829 * \brief Returns the storage class for a function or variable declaration.
3830 *
3831 * If the passed in Cursor is not a function or variable declaration,
3832 * CX_SC_Invalid is returned else the storage class.
3833 */
3834CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
3835
3836/**
Douglas Gregor16a2bdd2010-09-13 22:52:57 +00003837 * \brief Determine the number of overloaded declarations referenced by a
3838 * \c CXCursor_OverloadedDeclRef cursor.
3839 *
3840 * \param cursor The cursor whose overloaded declarations are being queried.
3841 *
3842 * \returns The number of overloaded declarations referenced by \c cursor. If it
3843 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
3844 */
3845CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
3846
3847/**
3848 * \brief Retrieve a cursor for one of the overloaded declarations referenced
3849 * by a \c CXCursor_OverloadedDeclRef cursor.
3850 *
3851 * \param cursor The cursor whose overloaded declarations are being queried.
3852 *
3853 * \param index The zero-based index into the set of overloaded declarations in
3854 * the cursor.
3855 *
3856 * \returns A cursor representing the declaration referenced by the given
3857 * \c cursor at the specified \c index. If the cursor does not have an
3858 * associated set of overloaded declarations, or if the index is out of bounds,
3859 * returns \c clang_getNullCursor();
3860 */
3861CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
3862 unsigned index);
3863
3864/**
Ted Kremenek6bca9842010-05-14 21:29:26 +00003865 * @}
3866 */
Ted Kremeneka5940822010-08-26 01:42:22 +00003867
3868/**
Ted Kremenek2c2c5f32010-08-27 21:34:51 +00003869 * \defgroup CINDEX_ATTRIBUTES Information for attributes
Ted Kremeneka5940822010-08-26 01:42:22 +00003870 *
3871 * @{
3872 */
3873
Ted Kremeneka5940822010-08-26 01:42:22 +00003874/**
3875 * \brief For cursors representing an iboutletcollection attribute,
3876 * this function returns the collection element type.
3877 *
3878 */
3879CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
3880
3881/**
3882 * @}
3883 */
Ted Kremenek6bca9842010-05-14 21:29:26 +00003884
3885/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003886 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
3887 *
3888 * These routines provide the ability to traverse the abstract syntax tree
3889 * using cursors.
3890 *
3891 * @{
3892 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003893
Douglas Gregor6007cf22010-01-22 22:29:16 +00003894/**
3895 * \brief Describes how the traversal of the children of a particular
3896 * cursor should proceed after visiting a particular child cursor.
3897 *
3898 * A value of this enumeration type should be returned by each
3899 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
3900 */
3901enum CXChildVisitResult {
3902 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003903 * \brief Terminates the cursor traversal.
Douglas Gregor6007cf22010-01-22 22:29:16 +00003904 */
3905 CXChildVisit_Break,
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003906 /**
Douglas Gregor6007cf22010-01-22 22:29:16 +00003907 * \brief Continues the cursor traversal with the next sibling of
3908 * the cursor just visited, without visiting its children.
3909 */
3910 CXChildVisit_Continue,
3911 /**
3912 * \brief Recursively traverse the children of this cursor, using
3913 * the same visitor and client data.
3914 */
3915 CXChildVisit_Recurse
3916};
3917
3918/**
3919 * \brief Visitor invoked for each cursor found by a traversal.
3920 *
3921 * This visitor function will be invoked for each cursor found by
3922 * clang_visitCursorChildren(). Its first argument is the cursor being
3923 * visited, its second argument is the parent visitor for that cursor,
3924 * and its third argument is the client data provided to
3925 * clang_visitCursorChildren().
3926 *
3927 * The visitor should return one of the \c CXChildVisitResult values
3928 * to direct clang_visitCursorChildren().
3929 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003930typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
3931 CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00003932 CXClientData client_data);
3933
3934/**
3935 * \brief Visit the children of a particular cursor.
3936 *
3937 * This function visits all the direct children of the given cursor,
3938 * invoking the given \p visitor function with the cursors of each
3939 * visited child. The traversal may be recursive, if the visitor returns
3940 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
3941 * the visitor returns \c CXChildVisit_Break.
3942 *
Douglas Gregor6007cf22010-01-22 22:29:16 +00003943 * \param parent the cursor whose child may be visited. All kinds of
Daniel Dunbarb9999fd2010-01-24 04:10:31 +00003944 * cursors can be visited, including invalid cursors (which, by
Douglas Gregor6007cf22010-01-22 22:29:16 +00003945 * definition, have no children).
3946 *
3947 * \param visitor the visitor function that will be invoked for each
3948 * child of \p parent.
3949 *
3950 * \param client_data pointer data supplied by the client, which will
3951 * be passed to the visitor each time it is invoked.
3952 *
3953 * \returns a non-zero value if the traversal was terminated
3954 * prematurely by the visitor returning \c CXChildVisit_Break.
3955 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003956CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
Douglas Gregor6007cf22010-01-22 22:29:16 +00003957 CXCursorVisitor visitor,
3958 CXClientData client_data);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00003959#ifdef __has_feature
3960# if __has_feature(blocks)
3961/**
3962 * \brief Visitor invoked for each cursor found by a traversal.
3963 *
3964 * This visitor block will be invoked for each cursor found by
3965 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
3966 * visited, its second argument is the parent visitor for that cursor.
3967 *
3968 * The visitor should return one of the \c CXChildVisitResult values
3969 * to direct clang_visitChildrenWithBlock().
3970 */
3971typedef enum CXChildVisitResult
3972 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3973
3974/**
3975 * Visits the children of a cursor using the specified block. Behaves
3976 * identically to clang_visitChildren() in all other respects.
3977 */
Argyrios Kyrtzidisa0a35d72016-02-07 18:21:28 +00003978CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
3979 CXCursorVisitorBlock block);
David Chisnallb2aa0ef2010-11-03 14:12:26 +00003980# endif
3981#endif
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003982
Douglas Gregor6007cf22010-01-22 22:29:16 +00003983/**
3984 * @}
3985 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003986
Douglas Gregor6007cf22010-01-22 22:29:16 +00003987/**
3988 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
3989 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003990 * These routines provide the ability to determine references within and
Douglas Gregor6007cf22010-01-22 22:29:16 +00003991 * across translation units, by providing the names of the entities referenced
3992 * by cursors, follow reference cursors to the declarations they reference,
3993 * and associate declarations with their definitions.
3994 *
3995 * @{
3996 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00003997
Douglas Gregor6007cf22010-01-22 22:29:16 +00003998/**
3999 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4000 * by the given cursor.
4001 *
4002 * A Unified Symbol Resolution (USR) is a string that identifies a particular
4003 * entity (function, class, variable, etc.) within a program. USRs can be
4004 * compared across translation units to determine, e.g., when references in
4005 * one translation refer to an entity defined in another translation unit.
4006 */
4007CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4008
4009/**
Ted Kremenekd071c602010-03-13 02:50:34 +00004010 * \brief Construct a USR for a specified Objective-C class.
4011 */
4012CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4013
4014/**
4015 * \brief Construct a USR for a specified Objective-C category.
4016 */
4017CINDEX_LINKAGE CXString
Ted Kremenekbc1a67b2010-03-15 17:38:58 +00004018 clang_constructUSR_ObjCCategory(const char *class_name,
Ted Kremenekd071c602010-03-13 02:50:34 +00004019 const char *category_name);
4020
4021/**
4022 * \brief Construct a USR for a specified Objective-C protocol.
4023 */
4024CINDEX_LINKAGE CXString
4025 clang_constructUSR_ObjCProtocol(const char *protocol_name);
4026
Ted Kremenekd071c602010-03-13 02:50:34 +00004027/**
4028 * \brief Construct a USR for a specified Objective-C instance variable and
4029 * the USR for its containing class.
4030 */
4031CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4032 CXString classUSR);
4033
4034/**
4035 * \brief Construct a USR for a specified Objective-C method and
4036 * the USR for its containing class.
4037 */
4038CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4039 unsigned isInstanceMethod,
4040 CXString classUSR);
4041
4042/**
4043 * \brief Construct a USR for a specified Objective-C property and the USR
4044 * for its containing class.
4045 */
4046CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4047 CXString classUSR);
4048
4049/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004050 * \brief Retrieve a name for the entity referenced by this cursor.
4051 */
4052CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4053
Douglas Gregor97c75712010-10-02 22:49:11 +00004054/**
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004055 * \brief Retrieve a range for a piece that forms the cursors spelling name.
4056 * Most of the times there is only one range for the complete spelling but for
Nico Weber7deebef2014-04-24 03:17:47 +00004057 * Objective-C methods and Objective-C message expressions, there are multiple
4058 * pieces for each selector identifier.
Argyrios Kyrtzidis191a6a82012-03-30 20:58:35 +00004059 *
4060 * \param pieceIndex the index of the spelling name piece. If this is greater
4061 * than the actual number of pieces, it will return a NULL (invalid) range.
4062 *
4063 * \param options Reserved.
4064 */
4065CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
4066 unsigned pieceIndex,
4067 unsigned options);
4068
4069/**
Douglas Gregor97c75712010-10-02 22:49:11 +00004070 * \brief Retrieve the display name for the entity referenced by this cursor.
4071 *
4072 * The display name contains extra information that helps identify the cursor,
4073 * such as the parameters of a function or template or the arguments of a
4074 * class template specialization.
4075 */
4076CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
4077
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004078/** \brief For a cursor that is a reference, retrieve a cursor representing the
4079 * entity that it references.
4080 *
4081 * Reference cursors refer to other entities in the AST. For example, an
4082 * Objective-C superclass reference cursor refers to an Objective-C class.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004083 * This function produces the cursor for the Objective-C class from the
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004084 * cursor for the superclass reference. If the input cursor is a declaration or
4085 * definition, it returns that declaration or definition unchanged.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004086 * Otherwise, returns the NULL cursor.
Douglas Gregorad27e8b2010-01-19 01:20:04 +00004087 */
4088CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004089
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004090/**
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004091 * \brief For a cursor that is either a reference to or a declaration
4092 * of some entity, retrieve a cursor that describes the definition of
4093 * that entity.
4094 *
4095 * Some entities can be declared multiple times within a translation
4096 * unit, but only one of those declarations can also be a
4097 * definition. For example, given:
4098 *
4099 * \code
4100 * int f(int, int);
4101 * int g(int x, int y) { return f(x, y); }
4102 * int f(int a, int b) { return a + b; }
4103 * int f(int, int);
4104 * \endcode
4105 *
4106 * there are three declarations of the function "f", but only the
4107 * second one is a definition. The clang_getCursorDefinition()
4108 * function will take any cursor pointing to a declaration of "f"
4109 * (the first or fourth lines of the example) or a cursor referenced
4110 * that uses "f" (the call to "f' inside "g") and will return a
4111 * declaration cursor pointing to the definition (the second "f"
4112 * declaration).
4113 *
4114 * If given a cursor for which there is no corresponding definition,
4115 * e.g., because there is no definition of that entity within this
4116 * translation unit, returns a NULL cursor.
4117 */
4118CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4119
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004120/**
Douglas Gregor6b8232f2010-01-19 19:34:47 +00004121 * \brief Determine whether the declaration pointed to by this cursor
4122 * is also a definition of that entity.
4123 */
4124CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4125
Douglas Gregor6007cf22010-01-22 22:29:16 +00004126/**
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004127 * \brief Retrieve the canonical cursor corresponding to the given cursor.
4128 *
4129 * In the C family of languages, many kinds of entities can be declared several
4130 * times within a single translation unit. For example, a structure type can
4131 * be forward-declared (possibly multiple times) and later defined:
4132 *
4133 * \code
4134 * struct X;
4135 * struct X;
4136 * struct X {
4137 * int member;
4138 * };
4139 * \endcode
4140 *
4141 * The declarations and the definition of \c X are represented by three
4142 * different cursors, all of which are declarations of the same underlying
4143 * entity. One of these cursor is considered the "canonical" cursor, which
4144 * is effectively the representative for the underlying entity. One can
4145 * determine if two cursors are declarations of the same underlying entity by
4146 * comparing their canonical cursors.
4147 *
4148 * \returns The canonical cursor for the entity referred to by the given cursor.
4149 */
4150CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4151
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004152/**
Nico Weber7deebef2014-04-24 03:17:47 +00004153 * \brief If the cursor points to a selector identifier in an Objective-C
4154 * method or message expression, this returns the selector index.
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004155 *
James Dennett574cb4c2012-06-15 05:41:51 +00004156 * After getting a cursor with #clang_getCursor, this can be called to
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004157 * determine if the location points to a selector identifier.
4158 *
Nico Weber7deebef2014-04-24 03:17:47 +00004159 * \returns The selector index if the cursor is an Objective-C method or message
Argyrios Kyrtzidis210f29f2012-03-30 22:15:48 +00004160 * expression and the cursor is pointing to a selector identifier, or -1
4161 * otherwise.
4162 */
4163CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4164
Douglas Gregorfec4dc92010-11-19 23:44:15 +00004165/**
Nico Weber7deebef2014-04-24 03:17:47 +00004166 * \brief Given a cursor pointing to a C++ method call or an Objective-C
4167 * message, returns non-zero if the method/message is "dynamic", meaning:
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004168 *
4169 * For a C++ method: the call is virtual.
Nico Weber7deebef2014-04-24 03:17:47 +00004170 * For an Objective-C message: the receiver is an object instance, not 'super'
4171 * or a specific class.
Argyrios Kyrtzidisb6df68212012-07-02 23:54:36 +00004172 *
4173 * If the method/message is "static" or the cursor does not point to a
4174 * method/message, it will return zero.
4175 */
4176CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4177
4178/**
Argyrios Kyrtzidis2a684862017-04-27 17:23:04 +00004179 * \brief Given a cursor pointing to an Objective-C message or property
4180 * reference, or C++ method call, returns the CXType of the receiver.
Argyrios Kyrtzidisb26a24c2012-11-01 02:01:34 +00004181 */
4182CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4183
4184/**
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004185 * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl.
4186 */
4187typedef enum {
4188 CXObjCPropertyAttr_noattr = 0x00,
4189 CXObjCPropertyAttr_readonly = 0x01,
4190 CXObjCPropertyAttr_getter = 0x02,
4191 CXObjCPropertyAttr_assign = 0x04,
4192 CXObjCPropertyAttr_readwrite = 0x08,
4193 CXObjCPropertyAttr_retain = 0x10,
4194 CXObjCPropertyAttr_copy = 0x20,
4195 CXObjCPropertyAttr_nonatomic = 0x40,
4196 CXObjCPropertyAttr_setter = 0x80,
4197 CXObjCPropertyAttr_atomic = 0x100,
4198 CXObjCPropertyAttr_weak = 0x200,
4199 CXObjCPropertyAttr_strong = 0x400,
Manman Ren04fd4d82016-05-31 23:22:04 +00004200 CXObjCPropertyAttr_unsafe_unretained = 0x800,
Manman Ren400e4c32016-06-03 23:11:41 +00004201 CXObjCPropertyAttr_class = 0x1000
Argyrios Kyrtzidis9adfd8a2013-04-18 22:15:49 +00004202} CXObjCPropertyAttrKind;
4203
4204/**
4205 * \brief Given a cursor that represents a property declaration, return the
4206 * associated property attributes. The bits are formed from
4207 * \c CXObjCPropertyAttrKind.
4208 *
4209 * \param reserved Reserved for future use, pass 0.
4210 */
4211CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4212 unsigned reserved);
4213
4214/**
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004215 * \brief 'Qualifiers' written next to the return and parameter types in
Nico Weber7deebef2014-04-24 03:17:47 +00004216 * Objective-C method declarations.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004217 */
4218typedef enum {
4219 CXObjCDeclQualifier_None = 0x0,
4220 CXObjCDeclQualifier_In = 0x1,
4221 CXObjCDeclQualifier_Inout = 0x2,
4222 CXObjCDeclQualifier_Out = 0x4,
4223 CXObjCDeclQualifier_Bycopy = 0x8,
4224 CXObjCDeclQualifier_Byref = 0x10,
4225 CXObjCDeclQualifier_Oneway = 0x20
4226} CXObjCDeclQualifierKind;
4227
4228/**
Nico Weber7deebef2014-04-24 03:17:47 +00004229 * \brief Given a cursor that represents an Objective-C method or parameter
4230 * declaration, return the associated Objective-C qualifiers for the return
4231 * type or the parameter respectively. The bits are formed from
4232 * CXObjCDeclQualifierKind.
Argyrios Kyrtzidis9d9bc012013-04-18 23:29:12 +00004233 */
4234CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4235
4236/**
Nico Weber7deebef2014-04-24 03:17:47 +00004237 * \brief Given a cursor that represents an Objective-C method or property
Alex Lorenz6c2898a2017-04-06 14:03:25 +00004238 * declaration, return non-zero if the declaration was affected by "\@optional".
4239 * Returns zero if the cursor is not such a declaration or it is "\@required".
Argyrios Kyrtzidis7b50fc52013-07-05 20:44:37 +00004240 */
4241CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4242
4243/**
Argyrios Kyrtzidis23814e42013-04-18 23:53:05 +00004244 * \brief Returns non-zero if the given cursor is a variadic function or method.
4245 */
4246CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4247
4248/**
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004249 * \brief Returns non-zero if the given cursor points to a symbol marked with
4250 * external_source_symbol attribute.
4251 *
4252 * \param language If non-NULL, and the attribute is present, will be set to
4253 * the 'language' string from the attribute.
4254 *
4255 * \param definedIn If non-NULL, and the attribute is present, will be set to
4256 * the 'definedIn' string from the attribute.
4257 *
4258 * \param isGenerated If non-NULL, and the attribute is present, will be set to
Argyrios Kyrtzidis8b337c02017-05-10 15:48:16 +00004259 * non-zero if the 'generated_declaration' is set in the attribute.
Argyrios Kyrtzidis0381cc72017-05-10 15:10:36 +00004260 */
4261CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4262 CXString *language, CXString *definedIn,
4263 unsigned *isGenerated);
4264
4265/**
Dmitri Gribenkoaab83832012-06-20 00:34:58 +00004266 * \brief Given a cursor that represents a declaration, return the associated
4267 * comment's source range. The range may include multiple consecutive comments
4268 * with whitespace in between.
4269 */
4270CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4271
4272/**
4273 * \brief Given a cursor that represents a declaration, return the associated
4274 * comment text, including comment markers.
4275 */
4276CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4277
4278/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004279 * \brief Given a cursor that represents a documentable entity (e.g.,
4280 * declaration), return the associated \\brief paragraph; otherwise return the
4281 * first paragraph.
Dmitri Gribenko5188c4b2012-06-26 20:39:18 +00004282 */
4283CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4284
4285/**
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004286 * @}
4287 */
4288
Eli Bendersky44a206f2014-07-31 18:04:56 +00004289/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4290 *
4291 * @{
4292 */
4293
4294/**
4295 * \brief Retrieve the CXString representing the mangled name of the cursor.
4296 */
4297CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4298
4299/**
Saleem Abdulrasool60034432015-11-12 03:57:22 +00004300 * \brief Retrieve the CXStrings representing the mangled symbols of the C++
4301 * constructor or destructor at the cursor.
4302 */
4303CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4304
4305/**
Dave Lee1a532c92017-09-22 16:58:57 +00004306 * \brief Retrieve the CXStrings representing the mangled symbols of the ObjC
4307 * class interface or implementation at the cursor.
4308 */
4309CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4310
4311/**
Eli Bendersky44a206f2014-07-31 18:04:56 +00004312 * @}
4313 */
4314
Dmitri Gribenko5e4fe002012-07-20 21:34:34 +00004315/**
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004316 * \defgroup CINDEX_MODULE Module introspection
4317 *
4318 * The functions in this group provide access to information about modules.
4319 *
4320 * @{
4321 */
4322
4323typedef void *CXModule;
4324
4325/**
4326 * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4327 */
4328CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4329
4330/**
Argyrios Kyrtzidisf6d49c32014-05-14 23:14:37 +00004331 * \brief Given a CXFile header file, return the module that contains it, if one
4332 * exists.
4333 */
4334CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4335
4336/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004337 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004338 *
Argyrios Kyrtzidis12fdb9e2013-04-26 22:47:49 +00004339 * \returns the module file where the provided module object came from.
4340 */
4341CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4342
4343/**
4344 * \param Module a module object.
4345 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004346 * \returns the parent of a sub-module or NULL if the given module is top-level,
4347 * e.g. for 'std.vector' it will return the 'std' module.
4348 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004349CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004350
4351/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004352 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004353 *
4354 * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4355 * will return "vector".
4356 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004357CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004358
4359/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004360 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004361 *
4362 * \returns the full name of the module, e.g. "std.vector".
4363 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004364CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004365
4366/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004367 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004368 *
Argyrios Kyrtzidis884337f2014-05-15 04:44:25 +00004369 * \returns non-zero if the module is a system one.
4370 */
4371CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4372
4373/**
4374 * \param Module a module object.
4375 *
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004376 * \returns the number of top level headers associated with this module.
4377 */
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004378CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4379 CXModule Module);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004380
4381/**
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004382 * \param Module a module object.
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004383 *
4384 * \param Index top level header index (zero-based).
4385 *
4386 * \returns the specified top level header associated with the module.
4387 */
Argyrios Kyrtzidisba30d922012-10-06 01:18:38 +00004388CINDEX_LINKAGE
Argyrios Kyrtzidis3c5305c2013-03-13 21:13:43 +00004389CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4390 CXModule Module, unsigned Index);
Argyrios Kyrtzidis2b9b5bb2012-10-05 00:22:37 +00004391
4392/**
4393 * @}
4394 */
4395
4396/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004397 * \defgroup CINDEX_CPP C++ AST introspection
4398 *
4399 * The routines in this group provide access information in the ASTs specific
4400 * to C++ language features.
4401 *
4402 * @{
4403 */
4404
4405/**
Jonathan Coe29565352016-04-27 12:48:25 +00004406 * \brief Determine if a C++ constructor is a converting constructor.
4407 */
4408CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4409
4410/**
4411 * \brief Determine if a C++ constructor is a copy constructor.
4412 */
4413CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4414
4415/**
4416 * \brief Determine if a C++ constructor is the default constructor.
4417 */
4418CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4419
4420/**
4421 * \brief Determine if a C++ constructor is a move constructor.
4422 */
4423CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4424
4425/**
Saleem Abdulrasool6ea75db2015-10-27 15:50:22 +00004426 * \brief Determine if a C++ field is declared 'mutable'.
4427 */
4428CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4429
4430/**
Jonathan Coe29565352016-04-27 12:48:25 +00004431 * \brief Determine if a C++ method is declared '= default'.
4432 */
4433CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4434
4435/**
Dmitri Gribenko62770be2013-05-17 18:38:35 +00004436 * \brief Determine if a C++ member function or member function template is
4437 * pure virtual.
4438 */
4439CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4440
4441/**
Douglas Gregorf11309e2010-08-31 22:12:17 +00004442 * \brief Determine if a C++ member function or member function template is
4443 * declared 'static'.
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004444 */
4445CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4446
4447/**
Douglas Gregor9519d922011-05-12 15:17:24 +00004448 * \brief Determine if a C++ member function or member function template is
4449 * explicitly declared 'virtual' or if it overrides a virtual method from
4450 * one of the base classes.
4451 */
4452CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4453
4454/**
Alex Lorenzff7f42e2017-07-12 11:35:11 +00004455 * \brief Determine if an enum declaration refers to a scoped enum.
4456 */
4457CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4458
4459/**
Dmitri Gribenkoe570ede2014-04-07 14:59:13 +00004460 * \brief Determine if a C++ member function or member function template is
4461 * declared 'const'.
4462 */
4463CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4464
4465/**
Douglas Gregorf11309e2010-08-31 22:12:17 +00004466 * \brief Given a cursor that represents a template, determine
4467 * the cursor kind of the specializations would be generated by instantiating
4468 * the template.
4469 *
4470 * This routine can be used to determine what flavor of function template,
4471 * class template, or class template partial specialization is stored in the
4472 * cursor. For example, it can describe whether a class template cursor is
4473 * declared with "struct", "class" or "union".
4474 *
4475 * \param C The cursor to query. This cursor should represent a template
4476 * declaration.
4477 *
4478 * \returns The cursor kind of the specializations that would be generated
4479 * by instantiating the template \p C. If \p C is not a template, returns
4480 * \c CXCursor_NoDeclFound.
4481 */
4482CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4483
4484/**
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004485 * \brief Given a cursor that may represent a specialization or instantiation
4486 * of a template, retrieve the cursor that represents the template that it
4487 * specializes or from which it was instantiated.
4488 *
4489 * This routine determines the template involved both for explicit
4490 * specializations of templates and for implicit instantiations of the template,
4491 * both of which are referred to as "specializations". For a class template
4492 * specialization (e.g., \c std::vector<bool>), this routine will return
4493 * either the primary template (\c std::vector) or, if the specialization was
4494 * instantiated from a class template partial specialization, the class template
4495 * partial specialization. For a class template partial specialization and a
4496 * function template specialization (including instantiations), this
4497 * this routine will return the specialized template.
4498 *
4499 * For members of a class template (e.g., member functions, member classes, or
4500 * static data members), returns the specialized or instantiated member.
4501 * Although not strictly "templates" in the C++ language, members of class
4502 * templates have the same notions of specializations and instantiations that
4503 * templates do, so this routine treats them similarly.
4504 *
4505 * \param C A cursor that may be a specialization of a template or a member
4506 * of a template.
4507 *
4508 * \returns If the given cursor is a specialization or instantiation of a
4509 * template or a member thereof, the template or member that it specializes or
4510 * from which it was instantiated. Otherwise, returns a NULL cursor.
4511 */
4512CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004513
4514/**
4515 * \brief Given a cursor that references something else, return the source range
4516 * covering that reference.
4517 *
4518 * \param C A cursor pointing to a member reference, a declaration reference, or
4519 * an operator call.
4520 * \param NameFlags A bitset with three independent flags:
4521 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4522 * CXNameRange_WantSinglePiece.
4523 * \param PieceIndex For contiguous names or when passing the flag
4524 * CXNameRange_WantSinglePiece, only one piece with index 0 is
4525 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
Benjamin Kramer474261a2012-06-02 10:20:41 +00004526 * non-contiguous names, this index can be used to retrieve the individual
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004527 * pieces of the name. See also CXNameRange_WantSinglePiece.
4528 *
4529 * \returns The piece of the name pointed to by the given cursor. If there is no
4530 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4531 */
Francois Pichetece689f2011-07-25 22:00:44 +00004532CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4533 unsigned NameFlags,
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004534 unsigned PieceIndex);
4535
4536enum CXNameRefFlags {
4537 /**
4538 * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4539 * range.
4540 */
4541 CXNameRange_WantQualifier = 0x1,
4542
4543 /**
James Dennett574cb4c2012-06-15 05:41:51 +00004544 * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>,
4545 * in the range.
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004546 */
4547 CXNameRange_WantTemplateArgs = 0x2,
4548
4549 /**
4550 * \brief If the name is non-contiguous, return the full spanning range.
4551 *
4552 * Non-contiguous names occur in Objective-C when a selector with two or more
4553 * parameters is used, or in C++ when using an operator:
4554 * \code
Nico Weber7deebef2014-04-24 03:17:47 +00004555 * [object doSomething:here withValue:there]; // Objective-C
Douglas Gregorc1679ec2011-07-25 17:48:11 +00004556 * return some_vector[1]; // C++
4557 * \endcode
4558 */
4559 CXNameRange_WantSinglePiece = 0x4
4560};
Douglas Gregord3f48bd2010-09-02 00:07:54 +00004561
4562/**
Ted Kremenek9cfe9e62010-05-17 20:06:56 +00004563 * @}
4564 */
4565
4566/**
Douglas Gregor61656112010-01-26 18:31:56 +00004567 * \defgroup CINDEX_LEX Token extraction and manipulation
4568 *
4569 * The routines in this group provide access to the tokens within a
4570 * translation unit, along with a semantic mapping of those tokens to
4571 * their corresponding cursors.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004572 *
4573 * @{
4574 */
4575
4576/**
4577 * \brief Describes a kind of token.
4578 */
4579typedef enum CXTokenKind {
4580 /**
4581 * \brief A token that contains some kind of punctuation.
4582 */
4583 CXToken_Punctuation,
Ted Kremenekd071c602010-03-13 02:50:34 +00004584
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004585 /**
Douglas Gregor61656112010-01-26 18:31:56 +00004586 * \brief A language keyword.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004587 */
4588 CXToken_Keyword,
Ted Kremenekd071c602010-03-13 02:50:34 +00004589
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004590 /**
4591 * \brief An identifier (that is not a keyword).
4592 */
4593 CXToken_Identifier,
Ted Kremenekd071c602010-03-13 02:50:34 +00004594
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004595 /**
4596 * \brief A numeric, string, or character literal.
4597 */
4598 CXToken_Literal,
Ted Kremenekd071c602010-03-13 02:50:34 +00004599
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004600 /**
4601 * \brief A comment.
4602 */
4603 CXToken_Comment
4604} CXTokenKind;
4605
4606/**
4607 * \brief Describes a single preprocessing token.
4608 */
4609typedef struct {
4610 unsigned int_data[4];
4611 void *ptr_data;
4612} CXToken;
4613
4614/**
4615 * \brief Determine the kind of the given token.
4616 */
4617CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004618
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004619/**
4620 * \brief Determine the spelling of the given token.
4621 *
4622 * The spelling of a token is the textual representation of that token, e.g.,
4623 * the text of an identifier or keyword.
4624 */
4625CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004626
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004627/**
4628 * \brief Retrieve the source location of the given token.
4629 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004630CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004631 CXToken);
Ted Kremenekd071c602010-03-13 02:50:34 +00004632
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004633/**
4634 * \brief Retrieve a source range that covers the given token.
4635 */
4636CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4637
4638/**
4639 * \brief Tokenize the source code described by the given range into raw
4640 * lexical tokens.
4641 *
4642 * \param TU the translation unit whose text is being tokenized.
4643 *
4644 * \param Range the source range in which text should be tokenized. All of the
4645 * tokens produced by tokenization will fall within this source range,
4646 *
4647 * \param Tokens this pointer will be set to point to the array of tokens
4648 * that occur within the given source range. The returned pointer must be
4649 * freed with clang_disposeTokens() before the translation unit is destroyed.
4650 *
4651 * \param NumTokens will be set to the number of tokens in the \c *Tokens
4652 * array.
4653 *
4654 */
4655CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4656 CXToken **Tokens, unsigned *NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004657
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004658/**
4659 * \brief Annotate the given set of tokens by providing cursors for each token
4660 * that can be mapped to a specific entity within the abstract syntax tree.
4661 *
Douglas Gregor61656112010-01-26 18:31:56 +00004662 * This token-annotation routine is equivalent to invoking
4663 * clang_getCursor() for the source locations of each of the
4664 * tokens. The cursors provided are filtered, so that only those
4665 * cursors that have a direct correspondence to the token are
4666 * accepted. For example, given a function call \c f(x),
4667 * clang_getCursor() would provide the following cursors:
4668 *
4669 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4670 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4671 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4672 *
4673 * Only the first and last of these cursors will occur within the
4674 * annotate, since the tokens "f" and "x' directly refer to a function
4675 * and a variable, respectively, but the parentheses are just a small
4676 * part of the full syntax of the function call expression, which is
4677 * not provided as an annotation.
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004678 *
4679 * \param TU the translation unit that owns the given tokens.
4680 *
4681 * \param Tokens the set of tokens to annotate.
4682 *
4683 * \param NumTokens the number of tokens in \p Tokens.
4684 *
4685 * \param Cursors an array of \p NumTokens cursors, whose contents will be
4686 * replaced with the cursors corresponding to each token.
4687 */
4688CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4689 CXToken *Tokens, unsigned NumTokens,
4690 CXCursor *Cursors);
Ted Kremenekd071c602010-03-13 02:50:34 +00004691
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004692/**
4693 * \brief Free the given set of tokens.
4694 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004695CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004696 CXToken *Tokens, unsigned NumTokens);
Ted Kremenekd071c602010-03-13 02:50:34 +00004697
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004698/**
4699 * @}
4700 */
Ted Kremenekd071c602010-03-13 02:50:34 +00004701
Douglas Gregor27b4fa92010-01-26 17:06:03 +00004702/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004703 * \defgroup CINDEX_DEBUG Debugging facilities
4704 *
4705 * These routines are used for testing and debugging, only, and should not
4706 * be relied upon.
4707 *
4708 * @{
4709 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004710
Steve Naroff76b8f132009-09-23 17:52:52 +00004711/* for debug/testing */
Ted Kremenek29004672010-02-17 00:41:32 +00004712CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004713CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4714 const char **startBuf,
Steve Naroff76b8f132009-09-23 17:52:52 +00004715 const char **endBuf,
4716 unsigned *startLine,
4717 unsigned *startColumn,
4718 unsigned *endLine,
4719 unsigned *endColumn);
Douglas Gregor1e21cc72010-02-18 23:07:20 +00004720CINDEX_LINKAGE void clang_enableStackTraces(void);
Daniel Dunbar23420652010-11-04 01:26:29 +00004721CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
4722 unsigned stack_size);
4723
Douglas Gregor9eb77012009-11-07 00:00:49 +00004724/**
Douglas Gregor6007cf22010-01-22 22:29:16 +00004725 * @}
4726 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004727
Douglas Gregor6007cf22010-01-22 22:29:16 +00004728/**
4729 * \defgroup CINDEX_CODE_COMPLET Code completion
4730 *
4731 * Code completion involves taking an (incomplete) source file, along with
4732 * knowledge of where the user is actively editing that file, and suggesting
4733 * syntactically- and semantically-valid constructs that the user might want to
4734 * use at that particular point in the source code. These data structures and
4735 * routines provide support for code completion.
4736 *
4737 * @{
4738 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004739
Douglas Gregor6007cf22010-01-22 22:29:16 +00004740/**
Douglas Gregor9eb77012009-11-07 00:00:49 +00004741 * \brief A semantic string that describes a code-completion result.
4742 *
4743 * A semantic string that describes the formatting of a code-completion
4744 * result as a single "template" of text that should be inserted into the
4745 * source buffer when a particular code-completion result is selected.
4746 * Each semantic string is made up of some number of "chunks", each of which
4747 * contains some text along with a description of what that text means, e.g.,
4748 * the name of the entity being referenced, whether the text chunk is part of
4749 * the template, or whether it is a "placeholder" that the user should replace
4750 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004751 * description of the different kinds of chunks.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004752 */
4753typedef void *CXCompletionString;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004754
Douglas Gregor9eb77012009-11-07 00:00:49 +00004755/**
4756 * \brief A single result of code completion.
4757 */
4758typedef struct {
4759 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004760 * \brief The kind of entity that this completion refers to.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004761 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004762 * The cursor kind will be a macro, keyword, or a declaration (one of the
Douglas Gregor9eb77012009-11-07 00:00:49 +00004763 * *Decl cursor kinds), describing the entity that the completion is
4764 * referring to.
4765 *
4766 * \todo In the future, we would like to provide a full cursor, to allow
4767 * the client to extract additional information from declaration.
4768 */
4769 enum CXCursorKind CursorKind;
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004770
4771 /**
Douglas Gregor9eb77012009-11-07 00:00:49 +00004772 * \brief The code-completion string that describes how to insert this
4773 * code-completion result into the editing buffer.
4774 */
4775 CXCompletionString CompletionString;
4776} CXCompletionResult;
4777
4778/**
4779 * \brief Describes a single piece of text within a code-completion string.
4780 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004781 * Each "chunk" within a code-completion string (\c CXCompletionString) is
4782 * either a piece of text with a specific "kind" that describes how that text
Douglas Gregor9eb77012009-11-07 00:00:49 +00004783 * should be interpreted by the client or is another completion string.
4784 */
4785enum CXCompletionChunkKind {
4786 /**
4787 * \brief A code-completion string that describes "optional" text that
4788 * could be a part of the template (but is not required).
4789 *
4790 * The Optional chunk is the only kind of chunk that has a code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004791 * string for its representation, which is accessible via
Douglas Gregor9eb77012009-11-07 00:00:49 +00004792 * \c clang_getCompletionChunkCompletionString(). The code-completion string
4793 * describes an additional part of the template that is completely optional.
4794 * For example, optional chunks can be used to describe the placeholders for
4795 * arguments that match up with defaulted function parameters, e.g. given:
4796 *
4797 * \code
4798 * void f(int x, float y = 3.14, double z = 2.71828);
4799 * \endcode
4800 *
4801 * The code-completion string for this function would contain:
4802 * - a TypedText chunk for "f".
4803 * - a LeftParen chunk for "(".
4804 * - a Placeholder chunk for "int x"
4805 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
4806 * - a Comma chunk for ","
Daniel Dunbar4053fae2010-02-17 08:07:44 +00004807 * - a Placeholder chunk for "float y"
Douglas Gregor9eb77012009-11-07 00:00:49 +00004808 * - an Optional chunk containing the last defaulted argument:
4809 * - a Comma chunk for ","
4810 * - a Placeholder chunk for "double z"
4811 * - a RightParen chunk for ")"
4812 *
Daniel Dunbar4053fae2010-02-17 08:07:44 +00004813 * There are many ways to handle Optional chunks. Two simple approaches are:
Douglas Gregor9eb77012009-11-07 00:00:49 +00004814 * - Completely ignore optional chunks, in which case the template for the
4815 * function "f" would only include the first parameter ("int x").
4816 * - Fully expand all optional chunks, in which case the template for the
4817 * function "f" would have all of the parameters.
4818 */
4819 CXCompletionChunk_Optional,
4820 /**
4821 * \brief Text that a user would be expected to type to get this
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004822 * code-completion result.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004823 *
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004824 * There will be exactly one "typed text" chunk in a semantic string, which
4825 * will typically provide the spelling of a keyword or the name of a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004826 * declaration that could be used at the current code point. Clients are
4827 * expected to filter the code-completion results based on the text in this
4828 * chunk.
4829 */
4830 CXCompletionChunk_TypedText,
4831 /**
4832 * \brief Text that should be inserted as part of a code-completion result.
4833 *
4834 * A "text" chunk represents text that is part of the template to be
4835 * inserted into user code should this particular code-completion result
4836 * be selected.
4837 */
4838 CXCompletionChunk_Text,
4839 /**
4840 * \brief Placeholder text that should be replaced by the user.
4841 *
4842 * A "placeholder" chunk marks a place where the user should insert text
4843 * into the code-completion template. For example, placeholders might mark
4844 * the function parameters for a function declaration, to indicate that the
4845 * user should provide arguments for each of those parameters. The actual
4846 * text in a placeholder is a suggestion for the text to display before
4847 * the user replaces the placeholder with real code.
4848 */
4849 CXCompletionChunk_Placeholder,
4850 /**
4851 * \brief Informative text that should be displayed but never inserted as
4852 * part of the template.
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004853 *
Douglas Gregor9eb77012009-11-07 00:00:49 +00004854 * An "informative" chunk contains annotations that can be displayed to
4855 * help the user decide whether a particular code-completion result is the
4856 * right option, but which is not part of the actual template to be inserted
4857 * by code completion.
4858 */
4859 CXCompletionChunk_Informative,
4860 /**
4861 * \brief Text that describes the current parameter when code-completion is
4862 * referring to function call, message send, or template specialization.
4863 *
4864 * A "current parameter" chunk occurs when code-completion is providing
4865 * information about a parameter corresponding to the argument at the
4866 * code-completion point. For example, given a function
4867 *
4868 * \code
4869 * int add(int x, int y);
4870 * \endcode
4871 *
4872 * and the source code \c add(, where the code-completion point is after the
4873 * "(", the code-completion string will contain a "current parameter" chunk
4874 * for "int x", indicating that the current argument will initialize that
4875 * parameter. After typing further, to \c add(17, (where the code-completion
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004876 * point is after the ","), the code-completion string will contain a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004877 * "current paremeter" chunk to "int y".
4878 */
4879 CXCompletionChunk_CurrentParameter,
4880 /**
4881 * \brief A left parenthesis ('('), used to initiate a function call or
4882 * signal the beginning of a function parameter list.
4883 */
4884 CXCompletionChunk_LeftParen,
4885 /**
4886 * \brief A right parenthesis (')'), used to finish a function call or
4887 * signal the end of a function parameter list.
4888 */
4889 CXCompletionChunk_RightParen,
4890 /**
4891 * \brief A left bracket ('[').
4892 */
4893 CXCompletionChunk_LeftBracket,
4894 /**
4895 * \brief A right bracket (']').
4896 */
4897 CXCompletionChunk_RightBracket,
4898 /**
4899 * \brief A left brace ('{').
4900 */
4901 CXCompletionChunk_LeftBrace,
4902 /**
4903 * \brief A right brace ('}').
4904 */
4905 CXCompletionChunk_RightBrace,
4906 /**
4907 * \brief A left angle bracket ('<').
4908 */
4909 CXCompletionChunk_LeftAngle,
4910 /**
4911 * \brief A right angle bracket ('>').
4912 */
4913 CXCompletionChunk_RightAngle,
4914 /**
4915 * \brief A comma separator (',').
4916 */
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004917 CXCompletionChunk_Comma,
4918 /**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004919 * \brief Text that specifies the result type of a given result.
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004920 *
4921 * This special kind of informative chunk is not meant to be inserted into
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004922 * the text buffer. Rather, it is meant to illustrate the type that an
Douglas Gregorb3fa9192009-12-18 18:53:37 +00004923 * expression using the given completion string would have.
4924 */
Douglas Gregor504a6ae2010-01-10 23:08:15 +00004925 CXCompletionChunk_ResultType,
4926 /**
4927 * \brief A colon (':').
4928 */
4929 CXCompletionChunk_Colon,
4930 /**
4931 * \brief A semicolon (';').
4932 */
4933 CXCompletionChunk_SemiColon,
4934 /**
4935 * \brief An '=' sign.
4936 */
4937 CXCompletionChunk_Equal,
4938 /**
4939 * Horizontal space (' ').
4940 */
4941 CXCompletionChunk_HorizontalSpace,
4942 /**
Alex Lorenz6c2898a2017-04-06 14:03:25 +00004943 * Vertical space ('\\n'), after which it is generally a good idea to
Douglas Gregor504a6ae2010-01-10 23:08:15 +00004944 * perform indentation.
4945 */
4946 CXCompletionChunk_VerticalSpace
Douglas Gregor9eb77012009-11-07 00:00:49 +00004947};
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004948
Douglas Gregor9eb77012009-11-07 00:00:49 +00004949/**
4950 * \brief Determine the kind of a particular chunk within a completion string.
4951 *
4952 * \param completion_string the completion string to query.
4953 *
4954 * \param chunk_number the 0-based index of the chunk in the completion string.
4955 *
4956 * \returns the kind of the chunk at the index \c chunk_number.
4957 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004958CINDEX_LINKAGE enum CXCompletionChunkKind
Douglas Gregor9eb77012009-11-07 00:00:49 +00004959clang_getCompletionChunkKind(CXCompletionString completion_string,
4960 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004961
Douglas Gregor9eb77012009-11-07 00:00:49 +00004962/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004963 * \brief Retrieve the text associated with a particular chunk within a
Douglas Gregor9eb77012009-11-07 00:00:49 +00004964 * completion string.
4965 *
4966 * \param completion_string the completion string to query.
4967 *
4968 * \param chunk_number the 0-based index of the chunk in the completion string.
4969 *
4970 * \returns the text associated with the chunk at index \c chunk_number.
4971 */
Ted Kremenekf602f962010-02-17 01:42:24 +00004972CINDEX_LINKAGE CXString
Douglas Gregor9eb77012009-11-07 00:00:49 +00004973clang_getCompletionChunkText(CXCompletionString completion_string,
4974 unsigned chunk_number);
4975
4976/**
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004977 * \brief Retrieve the completion string associated with a particular chunk
Douglas Gregor9eb77012009-11-07 00:00:49 +00004978 * within a completion string.
4979 *
4980 * \param completion_string the completion string to query.
4981 *
4982 * \param chunk_number the 0-based index of the chunk in the completion string.
4983 *
4984 * \returns the completion string associated with the chunk at index
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00004985 * \c chunk_number.
Douglas Gregor9eb77012009-11-07 00:00:49 +00004986 */
4987CINDEX_LINKAGE CXCompletionString
4988clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
4989 unsigned chunk_number);
Daniel Dunbar62ebf252010-01-24 02:54:26 +00004990
Douglas Gregor9eb77012009-11-07 00:00:49 +00004991/**
4992 * \brief Retrieve the number of chunks in the given code-completion string.
4993 */
4994CINDEX_LINKAGE unsigned
4995clang_getNumCompletionChunks(CXCompletionString completion_string);
4996
4997/**
Douglas Gregora2db7932010-05-26 22:00:08 +00004998 * \brief Determine the priority of this code completion.
4999 *
5000 * The priority of a code completion indicates how likely it is that this
5001 * particular completion is the completion that the user will select. The
5002 * priority is selected by various internal heuristics.
5003 *
5004 * \param completion_string The completion string to query.
5005 *
5006 * \returns The priority of this completion string. Smaller values indicate
5007 * higher-priority (more likely) completions.
5008 */
5009CINDEX_LINKAGE unsigned
5010clang_getCompletionPriority(CXCompletionString completion_string);
5011
5012/**
Douglas Gregorf757a122010-08-23 23:00:57 +00005013 * \brief Determine the availability of the entity that this code-completion
5014 * string refers to.
5015 *
5016 * \param completion_string The completion string to query.
5017 *
5018 * \returns The availability of the completion string.
5019 */
5020CINDEX_LINKAGE enum CXAvailabilityKind
5021clang_getCompletionAvailability(CXCompletionString completion_string);
5022
5023/**
Erik Verbruggen98ea7f62011-10-14 15:31:08 +00005024 * \brief Retrieve the number of annotations associated with the given
5025 * completion string.
5026 *
5027 * \param completion_string the completion string to query.
5028 *
5029 * \returns the number of annotations associated with the given completion
5030 * string.
5031 */
5032CINDEX_LINKAGE unsigned
5033clang_getCompletionNumAnnotations(CXCompletionString completion_string);
5034
5035/**
5036 * \brief Retrieve the annotation associated with the given completion string.
5037 *
5038 * \param completion_string the completion string to query.
5039 *
5040 * \param annotation_number the 0-based index of the annotation of the
5041 * completion string.
5042 *
5043 * \returns annotation string associated with the completion at index
5044 * \c annotation_number, or a NULL string if that annotation is not available.
5045 */
5046CINDEX_LINKAGE CXString
5047clang_getCompletionAnnotation(CXCompletionString completion_string,
5048 unsigned annotation_number);
5049
5050/**
Douglas Gregor78254c82012-03-27 23:34:16 +00005051 * \brief Retrieve the parent context of the given completion string.
5052 *
5053 * The parent context of a completion string is the semantic parent of
5054 * the declaration (if any) that the code completion represents. For example,
5055 * a code completion for an Objective-C method would have the method's class
5056 * or protocol as its context.
5057 *
5058 * \param completion_string The code completion string whose parent is
5059 * being queried.
5060 *
Argyrios Kyrtzidis9ae39562012-09-26 16:39:56 +00005061 * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
Douglas Gregor78254c82012-03-27 23:34:16 +00005062 *
James Dennett574cb4c2012-06-15 05:41:51 +00005063 * \returns The name of the completion parent, e.g., "NSObject" if
Douglas Gregor78254c82012-03-27 23:34:16 +00005064 * the completion string represents a method in the NSObject class.
5065 */
5066CINDEX_LINKAGE CXString
5067clang_getCompletionParent(CXCompletionString completion_string,
5068 enum CXCursorKind *kind);
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005069
5070/**
5071 * \brief Retrieve the brief documentation comment attached to the declaration
5072 * that corresponds to the given completion string.
5073 */
5074CINDEX_LINKAGE CXString
5075clang_getCompletionBriefComment(CXCompletionString completion_string);
5076
Douglas Gregor78254c82012-03-27 23:34:16 +00005077/**
Douglas Gregor3f35bb22011-08-04 20:04:59 +00005078 * \brief Retrieve a completion string for an arbitrary declaration or macro
5079 * definition cursor.
5080 *
5081 * \param cursor The cursor to query.
5082 *
5083 * \returns A non-context-sensitive completion string for declaration and macro
5084 * definition cursors, or NULL for other kinds of cursors.
5085 */
5086CINDEX_LINKAGE CXCompletionString
5087clang_getCursorCompletionString(CXCursor cursor);
5088
5089/**
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005090 * \brief Contains the results of code-completion.
5091 *
5092 * This data structure contains the results of code completion, as
Douglas Gregor6a9580282010-10-11 21:51:20 +00005093 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005094 * \c clang_disposeCodeCompleteResults.
5095 */
5096typedef struct {
5097 /**
5098 * \brief The code-completion results.
5099 */
5100 CXCompletionResult *Results;
5101
5102 /**
5103 * \brief The number of code-completion results stored in the
5104 * \c Results array.
5105 */
5106 unsigned NumResults;
5107} CXCodeCompleteResults;
5108
5109/**
Douglas Gregorb68bc592010-08-05 09:09:23 +00005110 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
5111 * modify its behavior.
5112 *
5113 * The enumerators in this enumeration can be bitwise-OR'd together to
5114 * provide multiple options to \c clang_codeCompleteAt().
5115 */
5116enum CXCodeComplete_Flags {
5117 /**
5118 * \brief Whether to include macros within the set of code
5119 * completions returned.
5120 */
5121 CXCodeComplete_IncludeMacros = 0x01,
5122
5123 /**
5124 * \brief Whether to include code patterns for language constructs
5125 * within the set of code completions, e.g., for loops.
5126 */
Dmitri Gribenko3292d062012-07-02 17:35:10 +00005127 CXCodeComplete_IncludeCodePatterns = 0x02,
5128
5129 /**
5130 * \brief Whether to include brief documentation within the set of code
5131 * completions returned.
5132 */
5133 CXCodeComplete_IncludeBriefComments = 0x04
Douglas Gregorb68bc592010-08-05 09:09:23 +00005134};
5135
5136/**
Douglas Gregor21325842011-07-07 16:03:39 +00005137 * \brief Bits that represent the context under which completion is occurring.
5138 *
5139 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5140 * contexts are occurring simultaneously.
5141 */
5142enum CXCompletionContext {
5143 /**
5144 * \brief The context for completions is unexposed, as only Clang results
5145 * should be included. (This is equivalent to having no context bits set.)
5146 */
5147 CXCompletionContext_Unexposed = 0,
5148
5149 /**
5150 * \brief Completions for any possible type should be included in the results.
5151 */
5152 CXCompletionContext_AnyType = 1 << 0,
5153
5154 /**
5155 * \brief Completions for any possible value (variables, function calls, etc.)
5156 * should be included in the results.
5157 */
5158 CXCompletionContext_AnyValue = 1 << 1,
5159 /**
5160 * \brief Completions for values that resolve to an Objective-C object should
5161 * be included in the results.
5162 */
5163 CXCompletionContext_ObjCObjectValue = 1 << 2,
5164 /**
5165 * \brief Completions for values that resolve to an Objective-C selector
5166 * should be included in the results.
5167 */
5168 CXCompletionContext_ObjCSelectorValue = 1 << 3,
5169 /**
5170 * \brief Completions for values that resolve to a C++ class type should be
5171 * included in the results.
5172 */
5173 CXCompletionContext_CXXClassTypeValue = 1 << 4,
5174
5175 /**
5176 * \brief Completions for fields of the member being accessed using the dot
5177 * operator should be included in the results.
5178 */
5179 CXCompletionContext_DotMemberAccess = 1 << 5,
5180 /**
5181 * \brief Completions for fields of the member being accessed using the arrow
5182 * operator should be included in the results.
5183 */
5184 CXCompletionContext_ArrowMemberAccess = 1 << 6,
5185 /**
5186 * \brief Completions for properties of the Objective-C object being accessed
5187 * using the dot operator should be included in the results.
5188 */
5189 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5190
5191 /**
5192 * \brief Completions for enum tags should be included in the results.
5193 */
5194 CXCompletionContext_EnumTag = 1 << 8,
5195 /**
5196 * \brief Completions for union tags should be included in the results.
5197 */
5198 CXCompletionContext_UnionTag = 1 << 9,
5199 /**
5200 * \brief Completions for struct tags should be included in the results.
5201 */
5202 CXCompletionContext_StructTag = 1 << 10,
5203
5204 /**
5205 * \brief Completions for C++ class names should be included in the results.
5206 */
5207 CXCompletionContext_ClassTag = 1 << 11,
5208 /**
5209 * \brief Completions for C++ namespaces and namespace aliases should be
5210 * included in the results.
5211 */
5212 CXCompletionContext_Namespace = 1 << 12,
5213 /**
5214 * \brief Completions for C++ nested name specifiers should be included in
5215 * the results.
5216 */
5217 CXCompletionContext_NestedNameSpecifier = 1 << 13,
5218
5219 /**
5220 * \brief Completions for Objective-C interfaces (classes) should be included
5221 * in the results.
5222 */
5223 CXCompletionContext_ObjCInterface = 1 << 14,
5224 /**
5225 * \brief Completions for Objective-C protocols should be included in
5226 * the results.
5227 */
5228 CXCompletionContext_ObjCProtocol = 1 << 15,
5229 /**
5230 * \brief Completions for Objective-C categories should be included in
5231 * the results.
5232 */
5233 CXCompletionContext_ObjCCategory = 1 << 16,
5234 /**
5235 * \brief Completions for Objective-C instance messages should be included
5236 * in the results.
5237 */
5238 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5239 /**
5240 * \brief Completions for Objective-C class messages should be included in
5241 * the results.
5242 */
5243 CXCompletionContext_ObjCClassMessage = 1 << 18,
5244 /**
5245 * \brief Completions for Objective-C selector names should be included in
5246 * the results.
5247 */
5248 CXCompletionContext_ObjCSelectorName = 1 << 19,
5249
5250 /**
5251 * \brief Completions for preprocessor macro names should be included in
5252 * the results.
5253 */
5254 CXCompletionContext_MacroName = 1 << 20,
5255
5256 /**
5257 * \brief Natural language completions should be included in the results.
5258 */
5259 CXCompletionContext_NaturalLanguage = 1 << 21,
5260
5261 /**
5262 * \brief The current context is unknown, so set all contexts.
5263 */
5264 CXCompletionContext_Unknown = ((1 << 22) - 1)
5265};
5266
5267/**
Douglas Gregorb68bc592010-08-05 09:09:23 +00005268 * \brief Returns a default set of code-completion options that can be
5269 * passed to\c clang_codeCompleteAt().
5270 */
5271CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5272
5273/**
Douglas Gregor8e984da2010-08-04 16:47:14 +00005274 * \brief Perform code completion at a given location in a translation unit.
5275 *
5276 * This function performs code completion at a particular file, line, and
5277 * column within source code, providing results that suggest potential
5278 * code snippets based on the context of the completion. The basic model
5279 * for code completion is that Clang will parse a complete source file,
5280 * performing syntax checking up to the location where code-completion has
5281 * been requested. At that point, a special code-completion token is passed
5282 * to the parser, which recognizes this token and determines, based on the
5283 * current location in the C/Objective-C/C++ grammar and the state of
5284 * semantic analysis, what completions to provide. These completions are
5285 * returned via a new \c CXCodeCompleteResults structure.
5286 *
5287 * Code completion itself is meant to be triggered by the client when the
5288 * user types punctuation characters or whitespace, at which point the
5289 * code-completion location will coincide with the cursor. For example, if \c p
5290 * is a pointer, code-completion might be triggered after the "-" and then
5291 * after the ">" in \c p->. When the code-completion location is afer the ">",
5292 * the completion results will provide, e.g., the members of the struct that
5293 * "p" points to. The client is responsible for placing the cursor at the
5294 * beginning of the token currently being typed, then filtering the results
5295 * based on the contents of the token. For example, when code-completing for
5296 * the expression \c p->get, the client should provide the location just after
5297 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5298 * client can filter the results based on the current token text ("get"), only
5299 * showing those results that start with "get". The intent of this interface
5300 * is to separate the relatively high-latency acquisition of code-completion
5301 * results from the filtering of results on a per-character basis, which must
5302 * have a lower latency.
5303 *
5304 * \param TU The translation unit in which code-completion should
5305 * occur. The source files for this translation unit need not be
5306 * completely up-to-date (and the contents of those source files may
5307 * be overridden via \p unsaved_files). Cursors referring into the
5308 * translation unit may be invalidated by this invocation.
5309 *
5310 * \param complete_filename The name of the source file where code
5311 * completion should be performed. This filename may be any file
5312 * included in the translation unit.
5313 *
5314 * \param complete_line The line at which code-completion should occur.
5315 *
5316 * \param complete_column The column at which code-completion should occur.
5317 * Note that the column should point just after the syntactic construct that
5318 * initiated code completion, and not in the middle of a lexical token.
5319 *
Vedant Kumarcbfe7bb2016-03-23 23:51:36 +00005320 * \param unsaved_files the Files that have not yet been saved to disk
Douglas Gregor8e984da2010-08-04 16:47:14 +00005321 * but may be required for parsing or code completion, including the
5322 * contents of those files. The contents and name of these files (as
5323 * specified by CXUnsavedFile) are copied when necessary, so the
5324 * client only needs to guarantee their validity until the call to
5325 * this function returns.
5326 *
5327 * \param num_unsaved_files The number of unsaved file entries in \p
5328 * unsaved_files.
5329 *
Douglas Gregorb68bc592010-08-05 09:09:23 +00005330 * \param options Extra options that control the behavior of code
5331 * completion, expressed as a bitwise OR of the enumerators of the
5332 * CXCodeComplete_Flags enumeration. The
5333 * \c clang_defaultCodeCompleteOptions() function returns a default set
5334 * of code-completion options.
5335 *
Douglas Gregor8e984da2010-08-04 16:47:14 +00005336 * \returns If successful, a new \c CXCodeCompleteResults structure
5337 * containing code-completion results, which should eventually be
5338 * freed with \c clang_disposeCodeCompleteResults(). If code
5339 * completion fails, returns NULL.
5340 */
5341CINDEX_LINKAGE
5342CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5343 const char *complete_filename,
5344 unsigned complete_line,
5345 unsigned complete_column,
5346 struct CXUnsavedFile *unsaved_files,
Douglas Gregorb68bc592010-08-05 09:09:23 +00005347 unsigned num_unsaved_files,
5348 unsigned options);
Douglas Gregor8e984da2010-08-04 16:47:14 +00005349
5350/**
Douglas Gregor49f67ce2010-08-26 13:48:20 +00005351 * \brief Sort the code-completion results in case-insensitive alphabetical
5352 * order.
5353 *
5354 * \param Results The set of results to sort.
5355 * \param NumResults The number of results in \p Results.
5356 */
5357CINDEX_LINKAGE
5358void clang_sortCodeCompletionResults(CXCompletionResult *Results,
5359 unsigned NumResults);
5360
5361/**
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005362 * \brief Free the given set of code-completion results.
5363 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005364CINDEX_LINKAGE
Douglas Gregorf72b6ac2009-12-18 16:20:58 +00005365void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Douglas Gregorf757a122010-08-23 23:00:57 +00005366
Douglas Gregor52606ff2010-01-20 01:10:47 +00005367/**
Douglas Gregor33cdd812010-02-18 18:08:43 +00005368 * \brief Determine the number of diagnostics produced prior to the
5369 * location where code completion was performed.
5370 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005371CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005372unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5373
5374/**
5375 * \brief Retrieve a diagnostic associated with the given code completion.
5376 *
James Dennett574cb4c2012-06-15 05:41:51 +00005377 * \param Results the code completion results to query.
Douglas Gregor33cdd812010-02-18 18:08:43 +00005378 * \param Index the zero-based diagnostic number to retrieve.
5379 *
5380 * \returns the requested diagnostic. This diagnostic must be freed
5381 * via a call to \c clang_disposeDiagnostic().
5382 */
Ted Kremenekd071c602010-03-13 02:50:34 +00005383CINDEX_LINKAGE
Douglas Gregor33cdd812010-02-18 18:08:43 +00005384CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5385 unsigned Index);
5386
5387/**
Nico Weberdd9c19f2014-04-24 03:06:18 +00005388 * \brief Determines what completions are appropriate for the context
Douglas Gregor21325842011-07-07 16:03:39 +00005389 * the given code completion.
5390 *
5391 * \param Results the code completion results to query
5392 *
5393 * \returns the kinds of completions that are appropriate for use
5394 * along with the given code completion results.
5395 */
5396CINDEX_LINKAGE
5397unsigned long long clang_codeCompleteGetContexts(
5398 CXCodeCompleteResults *Results);
Douglas Gregor63745d52011-07-21 01:05:26 +00005399
5400/**
5401 * \brief Returns the cursor kind for the container for the current code
5402 * completion context. The container is only guaranteed to be set for
5403 * contexts where a container exists (i.e. member accesses or Objective-C
5404 * message sends); if there is not a container, this function will return
5405 * CXCursor_InvalidCode.
5406 *
5407 * \param Results the code completion results to query
5408 *
5409 * \param IsIncomplete on return, this value will be false if Clang has complete
5410 * information about the container. If Clang does not have complete
5411 * information, this value will be true.
5412 *
5413 * \returns the container kind, or CXCursor_InvalidCode if there is not a
5414 * container
5415 */
5416CINDEX_LINKAGE
5417enum CXCursorKind clang_codeCompleteGetContainerKind(
5418 CXCodeCompleteResults *Results,
5419 unsigned *IsIncomplete);
5420
5421/**
5422 * \brief Returns the USR for the container for the current code completion
5423 * context. If there is not a container for the current context, this
5424 * function will return the empty string.
5425 *
5426 * \param Results the code completion results to query
5427 *
5428 * \returns the USR for the container
5429 */
5430CINDEX_LINKAGE
5431CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +00005432
Douglas Gregorea777402011-07-26 15:24:30 +00005433/**
5434 * \brief Returns the currently-entered selector for an Objective-C message
5435 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5436 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5437 * CXCompletionContext_ObjCClassMessage.
5438 *
5439 * \param Results the code completion results to query
5440 *
5441 * \returns the selector (or partial selector) that has been entered thus far
5442 * for an Objective-C message send.
5443 */
5444CINDEX_LINKAGE
5445CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5446
Douglas Gregor21325842011-07-07 16:03:39 +00005447/**
Douglas Gregor52606ff2010-01-20 01:10:47 +00005448 * @}
5449 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005450
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005451/**
5452 * \defgroup CINDEX_MISC Miscellaneous utility functions
5453 *
5454 * @{
5455 */
Ted Kremenek3e315a22010-01-23 17:51:23 +00005456
5457/**
5458 * \brief Return a version string, suitable for showing to a user, but not
5459 * intended to be parsed (the format is not guaranteed to be stable).
5460 */
NAKAMURA Takumieacd6672013-01-10 02:12:38 +00005461CINDEX_LINKAGE CXString clang_getClangVersion(void);
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005462
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005463/**
5464 * \brief Enable/disable crash recovery.
5465 *
James Dennett574cb4c2012-06-15 05:41:51 +00005466 * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero
5467 * value enables crash recovery, while 0 disables it.
Ted Kremenek1ec7b332011-03-18 23:05:39 +00005468 */
5469CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5470
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005471 /**
Ted Kremenekd071c602010-03-13 02:50:34 +00005472 * \brief Visitor invoked for each file in a translation unit
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005473 * (used with clang_getInclusions()).
5474 *
5475 * This visitor function will be invoked by clang_getInclusions() for each
James Dennett574cb4c2012-06-15 05:41:51 +00005476 * file included (either at the top-level or by \#include directives) within
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005477 * a translation unit. The first argument is the file being included, and
5478 * the second and third arguments provide the inclusion stack. The
5479 * array is sorted in order of immediate inclusion. For example,
5480 * the first element refers to the location that included 'included_file'.
5481 */
5482typedef void (*CXInclusionVisitor)(CXFile included_file,
5483 CXSourceLocation* inclusion_stack,
5484 unsigned include_len,
5485 CXClientData client_data);
5486
5487/**
5488 * \brief Visit the set of preprocessor inclusions in a translation unit.
5489 * The visitor function is called with the provided data for every included
5490 * file. This does not include headers included by the PCH file (unless one
5491 * is inspecting the inclusions in the PCH file itself).
5492 */
5493CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5494 CXInclusionVisitor visitor,
5495 CXClientData client_data);
5496
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005497typedef enum {
5498 CXEval_Int = 1 ,
5499 CXEval_Float = 2,
5500 CXEval_ObjCStrLiteral = 3,
5501 CXEval_StrLiteral = 4,
5502 CXEval_CFStr = 5,
5503 CXEval_Other = 6,
5504
5505 CXEval_UnExposed = 0
5506
5507} CXEvalResultKind ;
5508
5509/**
5510 * \brief Evaluation result of a cursor
5511 */
5512typedef void * CXEvalResult;
5513
5514/**
5515 * \brief If cursor is a statement declaration tries to evaluate the
5516 * statement and if its variable, tries to evaluate its initializer,
5517 * into its corresponding type.
5518 */
5519CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5520
5521/**
5522 * \brief Returns the kind of the evaluated result.
5523 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005524CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005525
5526/**
5527 * \brief Returns the evaluation result as integer if the
5528 * kind is Int.
5529 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005530CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005531
5532/**
Argyrios Kyrtzidis5dda1122016-12-01 23:41:27 +00005533 * \brief Returns the evaluation result as a long long integer if the
5534 * kind is Int. This prevents overflows that may happen if the result is
5535 * returned with clang_EvalResult_getAsInt.
5536 */
5537CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5538
5539/**
5540 * \brief Returns a non-zero value if the kind is Int and the evaluation
5541 * result resulted in an unsigned integer.
5542 */
5543CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5544
5545/**
5546 * \brief Returns the evaluation result as an unsigned integer if
5547 * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5548 */
5549CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5550
5551/**
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005552 * \brief Returns the evaluation result as double if the
5553 * kind is double.
5554 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005555CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005556
5557/**
5558 * \brief Returns the evaluation result as a constant string if the
5559 * kind is other than Int or float. User must not free this pointer,
5560 * instead call clang_EvalResult_dispose on the CXEvalResult returned
5561 * by clang_Cursor_Evaluate.
5562 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005563CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
Argyrios Kyrtzidis785705b2016-01-16 00:20:02 +00005564
5565/**
5566 * \brief Disposes the created Eval memory.
5567 */
Argyrios Kyrtzidisa851d7e2016-01-16 03:01:20 +00005568CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
Ted Kremenek0b86e3a2010-01-26 19:31:51 +00005569/**
Ted Kremenekc0f3f722010-01-22 22:44:15 +00005570 * @}
5571 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00005572
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005573/** \defgroup CINDEX_REMAPPING Remapping functions
5574 *
5575 * @{
5576 */
5577
5578/**
5579 * \brief A remapping of original source files and their translated files.
5580 */
5581typedef void *CXRemapping;
5582
5583/**
5584 * \brief Retrieve a remapping.
5585 *
5586 * \param path the path that contains metadata about remappings.
5587 *
5588 * \returns the requested remapping. This remapping must be freed
5589 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5590 */
5591CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5592
5593/**
Ted Kremenekf7639e12012-03-06 20:06:33 +00005594 * \brief Retrieve a remapping.
5595 *
5596 * \param filePaths pointer to an array of file paths containing remapping info.
5597 *
5598 * \param numFiles number of file paths.
5599 *
5600 * \returns the requested remapping. This remapping must be freed
5601 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5602 */
5603CINDEX_LINKAGE
5604CXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5605 unsigned numFiles);
5606
5607/**
Argyrios Kyrtzidisf89cc692011-07-11 20:15:00 +00005608 * \brief Determine the number of remappings.
5609 */
5610CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5611
5612/**
5613 * \brief Get the original and the associated filename from the remapping.
5614 *
5615 * \param original If non-NULL, will be set to the original filename.
5616 *
5617 * \param transformed If non-NULL, will be set to the filename that the original
5618 * is associated with.
5619 */
5620CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5621 CXString *original, CXString *transformed);
5622
5623/**
5624 * \brief Dispose the remapping.
5625 */
5626CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5627
5628/**
5629 * @}
5630 */
5631
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005632/** \defgroup CINDEX_HIGH Higher level API functions
5633 *
5634 * @{
5635 */
5636
5637enum CXVisitorResult {
5638 CXVisit_Break,
5639 CXVisit_Continue
5640};
5641
Saleem Abdulrasoolec988b72016-05-24 01:23:24 +00005642typedef struct CXCursorAndRangeVisitor {
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005643 void *context;
5644 enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
5645} CXCursorAndRangeVisitor;
5646
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005647typedef enum {
5648 /**
5649 * \brief Function returned successfully.
5650 */
5651 CXResult_Success = 0,
5652 /**
5653 * \brief One of the parameters was invalid for the function.
5654 */
5655 CXResult_Invalid = 1,
5656 /**
5657 * \brief The function was terminated by a callback (e.g. it returned
5658 * CXVisit_Break)
5659 */
5660 CXResult_VisitBreak = 2
5661
5662} CXResult;
5663
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005664/**
5665 * \brief Find references of a declaration in a specific file.
5666 *
5667 * \param cursor pointing to a declaration or a reference of one.
5668 *
5669 * \param file to search for references.
5670 *
5671 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5672 * each reference found.
5673 * The CXSourceRange will point inside the file; if the reference is inside
5674 * a macro (and not a macro argument) the CXSourceRange will be invalid.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00005675 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005676 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005677 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005678CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
5679 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005680
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005681/**
5682 * \brief Find #import/#include directives in a specific file.
5683 *
5684 * \param TU translation unit containing the file to query.
5685 *
5686 * \param file to search for #import/#include directives.
5687 *
5688 * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
5689 * each directive found.
Argyrios Kyrtzidis951f61f2013-03-08 20:42:33 +00005690 *
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005691 * \returns one of the CXResult enumerators.
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005692 */
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005693CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
5694 CXFile file,
5695 CXCursorAndRangeVisitor visitor);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005696
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005697#ifdef __has_feature
5698# if __has_feature(blocks)
5699
5700typedef enum CXVisitorResult
5701 (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
5702
5703CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005704CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
5705 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005706
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005707CINDEX_LINKAGE
Argyrios Kyrtzidis51c33182013-03-08 22:47:41 +00005708CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
5709 CXCursorAndRangeVisitorBlock);
Argyrios Kyrtzidis503c83a2013-03-08 02:32:34 +00005710
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00005711# endif
5712#endif
5713
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005714/**
5715 * \brief The client's data object that is associated with a CXFile.
5716 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005717typedef void *CXIdxClientFile;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005718
5719/**
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005720 * \brief The client's data object that is associated with a semantic entity.
5721 */
5722typedef void *CXIdxClientEntity;
5723
5724/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005725 * \brief The client's data object that is associated with a semantic container
5726 * of entities.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005727 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005728typedef void *CXIdxClientContainer;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005729
5730/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005731 * \brief The client's data object that is associated with an AST file (PCH
5732 * or module).
5733 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005734typedef void *CXIdxClientASTFile;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005735
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005736/**
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005737 * \brief Source location passed to index callbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005738 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005739typedef struct {
5740 void *ptr_data[2];
5741 unsigned int_data;
5742} CXIdxLoc;
5743
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005744/**
James Dennett574cb4c2012-06-15 05:41:51 +00005745 * \brief Data for ppIncludedFile callback.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005746 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005747typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005748 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005749 * \brief Location of '#' in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005750 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005751 CXIdxLoc hashLoc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005752 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005753 * \brief Filename as written in the \#include/\#import directive.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005754 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005755 const char *filename;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005756 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005757 * \brief The actual file that the \#include/\#import directive resolved to.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005758 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005759 CXFile file;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005760 int isImport;
5761 int isAngled;
Argyrios Kyrtzidis5e2ec482012-10-18 00:17:05 +00005762 /**
5763 * \brief Non-zero if the directive was automatically turned into a module
5764 * import.
5765 */
5766 int isModuleImport;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005767} CXIdxIncludedFileInfo;
5768
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005769/**
James Dennett574cb4c2012-06-15 05:41:51 +00005770 * \brief Data for IndexerCallbacks#importedASTFile.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005771 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005772typedef struct {
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005773 /**
5774 * \brief Top level AST file containing the imported PCH, module or submodule.
5775 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005776 CXFile file;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005777 /**
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00005778 * \brief The imported module or NULL if the AST file is a PCH.
5779 */
5780 CXModule module;
5781 /**
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005782 * \brief Location where the file is imported. Applicable only for modules.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005783 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005784 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005785 /**
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005786 * \brief Non-zero if an inclusion directive was automatically turned into
Argyrios Kyrtzidisdc78f3e2012-10-05 00:22:40 +00005787 * a module import. Applicable only for modules.
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005788 */
Argyrios Kyrtzidis184b1442012-10-03 21:05:44 +00005789 int isImplicit;
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00005790
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005791} CXIdxImportedASTFileInfo;
5792
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005793typedef enum {
5794 CXIdxEntity_Unexposed = 0,
5795 CXIdxEntity_Typedef = 1,
5796 CXIdxEntity_Function = 2,
5797 CXIdxEntity_Variable = 3,
5798 CXIdxEntity_Field = 4,
5799 CXIdxEntity_EnumConstant = 5,
5800
5801 CXIdxEntity_ObjCClass = 6,
5802 CXIdxEntity_ObjCProtocol = 7,
5803 CXIdxEntity_ObjCCategory = 8,
5804
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005805 CXIdxEntity_ObjCInstanceMethod = 9,
5806 CXIdxEntity_ObjCClassMethod = 10,
5807 CXIdxEntity_ObjCProperty = 11,
5808 CXIdxEntity_ObjCIvar = 12,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005809
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005810 CXIdxEntity_Enum = 13,
5811 CXIdxEntity_Struct = 14,
5812 CXIdxEntity_Union = 15,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005813
5814 CXIdxEntity_CXXClass = 16,
5815 CXIdxEntity_CXXNamespace = 17,
5816 CXIdxEntity_CXXNamespaceAlias = 18,
5817 CXIdxEntity_CXXStaticVariable = 19,
5818 CXIdxEntity_CXXStaticMethod = 20,
5819 CXIdxEntity_CXXInstanceMethod = 21,
Joao Matose9a3ed42012-08-31 22:18:20 +00005820 CXIdxEntity_CXXConstructor = 22,
5821 CXIdxEntity_CXXDestructor = 23,
5822 CXIdxEntity_CXXConversionFunction = 24,
5823 CXIdxEntity_CXXTypeAlias = 25,
5824 CXIdxEntity_CXXInterface = 26
5825
5826} CXIdxEntityKind;
5827
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00005828typedef enum {
5829 CXIdxEntityLang_None = 0,
5830 CXIdxEntityLang_C = 1,
5831 CXIdxEntityLang_ObjC = 2,
Argyrios Kyrtzidisb4b85f22017-04-24 14:52:00 +00005832 CXIdxEntityLang_CXX = 3,
5833 CXIdxEntityLang_Swift = 4
Argyrios Kyrtzidis52002882011-12-07 20:44:12 +00005834} CXIdxEntityLanguage;
5835
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005836/**
5837 * \brief Extra C++ template information for an entity. This can apply to:
5838 * CXIdxEntity_Function
5839 * CXIdxEntity_CXXClass
5840 * CXIdxEntity_CXXStaticMethod
5841 * CXIdxEntity_CXXInstanceMethod
5842 * CXIdxEntity_CXXConstructor
5843 * CXIdxEntity_CXXConversionFunction
5844 * CXIdxEntity_CXXTypeAlias
5845 */
5846typedef enum {
5847 CXIdxEntity_NonTemplate = 0,
5848 CXIdxEntity_Template = 1,
5849 CXIdxEntity_TemplatePartialSpecialization = 2,
5850 CXIdxEntity_TemplateSpecialization = 3
5851} CXIdxEntityCXXTemplateKind;
5852
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005853typedef enum {
5854 CXIdxAttr_Unexposed = 0,
5855 CXIdxAttr_IBAction = 1,
5856 CXIdxAttr_IBOutlet = 2,
5857 CXIdxAttr_IBOutletCollection = 3
5858} CXIdxAttrKind;
5859
5860typedef struct {
5861 CXIdxAttrKind kind;
5862 CXCursor cursor;
5863 CXIdxLoc loc;
5864} CXIdxAttrInfo;
5865
5866typedef struct {
Argyrios Kyrtzidis4d873b72011-12-15 00:05:00 +00005867 CXIdxEntityKind kind;
5868 CXIdxEntityCXXTemplateKind templateKind;
5869 CXIdxEntityLanguage lang;
5870 const char *name;
5871 const char *USR;
5872 CXCursor cursor;
5873 const CXIdxAttrInfo *const *attributes;
5874 unsigned numAttributes;
5875} CXIdxEntityInfo;
5876
5877typedef struct {
5878 CXCursor cursor;
5879} CXIdxContainerInfo;
5880
5881typedef struct {
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005882 const CXIdxAttrInfo *attrInfo;
5883 const CXIdxEntityInfo *objcClass;
5884 CXCursor classCursor;
5885 CXIdxLoc classLoc;
5886} CXIdxIBOutletCollectionAttrInfo;
5887
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005888typedef enum {
5889 CXIdxDeclFlag_Skipped = 0x1
5890} CXIdxDeclInfoFlags;
5891
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005892typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005893 const CXIdxEntityInfo *entityInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005894 CXCursor cursor;
5895 CXIdxLoc loc;
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005896 const CXIdxContainerInfo *semanticContainer;
5897 /**
James Dennett574cb4c2012-06-15 05:41:51 +00005898 * \brief Generally same as #semanticContainer but can be different in
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005899 * cases like out-of-line C++ member functions.
5900 */
5901 const CXIdxContainerInfo *lexicalContainer;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005902 int isRedeclaration;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005903 int isDefinition;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005904 int isContainer;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005905 const CXIdxContainerInfo *declAsContainer;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005906 /**
5907 * \brief Whether the declaration exists in code or was created implicitly
Nico Weber7deebef2014-04-24 03:17:47 +00005908 * by the compiler, e.g. implicit Objective-C methods for properties.
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005909 */
5910 int isImplicit;
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005911 const CXIdxAttrInfo *const *attributes;
5912 unsigned numAttributes;
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00005913
5914 unsigned flags;
5915
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005916} CXIdxDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005917
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005918typedef enum {
5919 CXIdxObjCContainer_ForwardRef = 0,
5920 CXIdxObjCContainer_Interface = 1,
5921 CXIdxObjCContainer_Implementation = 2
5922} CXIdxObjCContainerKind;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005923
5924typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005925 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00005926 CXIdxObjCContainerKind kind;
5927} CXIdxObjCContainerDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005928
5929typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005930 const CXIdxEntityInfo *base;
5931 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005932 CXIdxLoc loc;
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005933} CXIdxBaseClassInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005934
5935typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005936 const CXIdxEntityInfo *protocol;
5937 CXCursor cursor;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005938 CXIdxLoc loc;
5939} CXIdxObjCProtocolRefInfo;
5940
5941typedef struct {
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00005942 const CXIdxObjCProtocolRefInfo *const *protocols;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005943 unsigned numProtocols;
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005944} CXIdxObjCProtocolRefListInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005945
5946typedef struct {
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00005947 const CXIdxObjCContainerDeclInfo *containerInfo;
5948 const CXIdxBaseClassInfo *superInfo;
5949 const CXIdxObjCProtocolRefListInfo *protocols;
5950} CXIdxObjCInterfaceDeclInfo;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005951
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005952typedef struct {
Argyrios Kyrtzidis9b9f7a92011-12-13 18:47:45 +00005953 const CXIdxObjCContainerDeclInfo *containerInfo;
5954 const CXIdxEntityInfo *objcClass;
5955 CXCursor classCursor;
5956 CXIdxLoc classLoc;
5957 const CXIdxObjCProtocolRefListInfo *protocols;
5958} CXIdxObjCCategoryDeclInfo;
5959
5960typedef struct {
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005961 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00005962 const CXIdxEntityInfo *getter;
5963 const CXIdxEntityInfo *setter;
5964} CXIdxObjCPropertyDeclInfo;
5965
5966typedef struct {
5967 const CXIdxDeclInfo *declInfo;
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00005968 const CXIdxBaseClassInfo *const *bases;
5969 unsigned numBases;
5970} CXIdxCXXClassDeclInfo;
5971
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005972/**
James Dennett574cb4c2012-06-15 05:41:51 +00005973 * \brief Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005974 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005975typedef enum {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005976 /**
5977 * \brief The entity is referenced directly in user's code.
5978 */
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005979 CXIdxEntityRef_Direct = 1,
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005980 /**
Nico Weber7deebef2014-04-24 03:17:47 +00005981 * \brief An implicit reference, e.g. a reference of an Objective-C method
5982 * via the dot syntax.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005983 */
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00005984 CXIdxEntityRef_Implicit = 2
Argyrios Kyrtzidis0c7735e52011-10-18 15:50:50 +00005985} CXIdxEntityRefKind;
5986
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005987/**
James Dennett574cb4c2012-06-15 05:41:51 +00005988 * \brief Data for IndexerCallbacks#indexEntityReference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005989 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005990typedef struct {
Argyrios Kyrtzidis663c8ec2011-12-07 20:44:19 +00005991 CXIdxEntityRefKind kind;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005992 /**
5993 * \brief Reference cursor.
5994 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00005995 CXCursor cursor;
5996 CXIdxLoc loc;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00005997 /**
5998 * \brief The entity that gets referenced.
5999 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006000 const CXIdxEntityInfo *referencedEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006001 /**
6002 * \brief Immediate "parent" of the reference. For example:
6003 *
6004 * \code
6005 * Foo *var;
6006 * \endcode
6007 *
6008 * The parent of reference of type 'Foo' is the variable 'var'.
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00006009 * For references inside statement bodies of functions/methods,
6010 * the parentEntity will be the function/method.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006011 */
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006012 const CXIdxEntityInfo *parentEntity;
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006013 /**
Argyrios Kyrtzidis25cb0ff2011-12-13 18:47:41 +00006014 * \brief Lexical container context of the reference.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006015 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006016 const CXIdxContainerInfo *container;
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006017} CXIdxEntityRefInfo;
6018
James Dennett574cb4c2012-06-15 05:41:51 +00006019/**
6020 * \brief A group of callbacks used by #clang_indexSourceFile and
6021 * #clang_indexTranslationUnit.
6022 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006023typedef struct {
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006024 /**
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006025 * \brief Called periodically to check whether indexing should be aborted.
6026 * Should return 0 to continue, and non-zero to abort.
6027 */
6028 int (*abortQuery)(CXClientData client_data, void *reserved);
6029
6030 /**
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006031 * \brief Called at the end of indexing; passes the complete diagnostic set.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006032 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006033 void (*diagnostic)(CXClientData client_data,
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006034 CXDiagnosticSet, void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006035
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006036 CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
James Dennett574cb4c2012-06-15 05:41:51 +00006037 CXFile mainFile, void *reserved);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006038
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006039 /**
James Dennett574cb4c2012-06-15 05:41:51 +00006040 * \brief Called when a file gets \#included/\#imported.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006041 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006042 CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006043 const CXIdxIncludedFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006044
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006045 /**
6046 * \brief Called when a AST file (PCH or module) gets imported.
6047 *
6048 * AST files will not get indexed (there will not be callbacks to index all
6049 * the entities in an AST file). The recommended action is that, if the AST
Argyrios Kyrtzidis472eda02012-10-02 16:10:38 +00006050 * file is not already indexed, to initiate a new indexing job specific to
6051 * the AST file.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006052 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006053 CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006054 const CXIdxImportedASTFileInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006055
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006056 /**
6057 * \brief Called at the beginning of indexing a translation unit.
6058 */
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006059 CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006060 void *reserved);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006061
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006062 void (*indexDeclaration)(CXClientData client_data,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006063 const CXIdxDeclInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006064
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006065 /**
6066 * \brief Called to index a reference of an entity.
6067 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006068 void (*indexEntityReference)(CXClientData client_data,
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006069 const CXIdxEntityRefInfo *);
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006070
6071} IndexerCallbacks;
6072
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006073CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006074CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6075clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006076
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006077CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6078clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6079
NAKAMURA Takumiaacef7e2011-11-11 02:51:09 +00006080CINDEX_LINKAGE
Argyrios Kyrtzidis3e429e72011-11-12 02:16:30 +00006081const CXIdxObjCCategoryDeclInfo *
6082clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6083
Argyrios Kyrtzidis86acd722011-11-14 22:39:19 +00006084CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6085clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006086
Argyrios Kyrtzidis93db2922012-02-28 17:50:33 +00006087CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6088clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6089
Argyrios Kyrtzidiseffdbf52011-11-18 00:26:51 +00006090CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6091clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6092
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006093CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6094clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6095
6096/**
6097 * \brief For retrieving a custom CXIdxClientContainer attached to a
6098 * container.
6099 */
6100CINDEX_LINKAGE CXIdxClientContainer
6101clang_index_getClientContainer(const CXIdxContainerInfo *);
6102
6103/**
6104 * \brief For setting a custom CXIdxClientContainer attached to a
6105 * container.
6106 */
6107CINDEX_LINKAGE void
6108clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
6109
6110/**
6111 * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
6112 */
6113CINDEX_LINKAGE CXIdxClientEntity
6114clang_index_getClientEntity(const CXIdxEntityInfo *);
6115
6116/**
6117 * \brief For setting a custom CXIdxClientEntity attached to an entity.
6118 */
6119CINDEX_LINKAGE void
6120clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
6121
6122/**
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006123 * \brief An indexing action/session, to be applied to one or multiple
6124 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006125 */
6126typedef void *CXIndexAction;
6127
6128/**
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006129 * \brief An indexing action/session, to be applied to one or multiple
6130 * translation units.
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006131 *
6132 * \param CIdx The index object with which the index action will be associated.
6133 */
6134CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6135
6136/**
6137 * \brief Destroy the given index action.
6138 *
6139 * The index action must not be destroyed until all of the translation units
6140 * created within that index action have been destroyed.
6141 */
6142CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6143
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006144typedef enum {
6145 /**
6146 * \brief Used to indicate that no special indexing options are needed.
6147 */
6148 CXIndexOpt_None = 0x0,
6149
6150 /**
James Dennett574cb4c2012-06-15 05:41:51 +00006151 * \brief Used to indicate that IndexerCallbacks#indexEntityReference should
6152 * be invoked for only one reference of an entity per source file that does
6153 * not also include a declaration/definition of the entity.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006154 */
Argyrios Kyrtzidisfb7d1452012-01-14 00:11:49 +00006155 CXIndexOpt_SuppressRedundantRefs = 0x1,
6156
6157 /**
6158 * \brief Function-local symbols should be indexed. If this is not set
6159 * function-local symbols will be ignored.
6160 */
Argyrios Kyrtzidis7e747952012-02-14 22:23:11 +00006161 CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6162
6163 /**
6164 * \brief Implicit function/class template instantiations should be indexed.
6165 * If this is not set, implicit instantiations will be ignored.
6166 */
Argyrios Kyrtzidis6c9ed7d2012-03-27 21:38:03 +00006167 CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6168
6169 /**
6170 * \brief Suppress all compiler warnings when parsing for indexing.
6171 */
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006172 CXIndexOpt_SuppressWarnings = 0x8,
6173
6174 /**
6175 * \brief Skip a function/method body that was already parsed during an
Nico Weber7deebef2014-04-24 03:17:47 +00006176 * indexing session associated with a \c CXIndexAction object.
Argyrios Kyrtzidis8b71bc72012-12-06 19:41:16 +00006177 * Bodies in system headers are always skipped.
6178 */
6179 CXIndexOpt_SkipParsedBodiesInSession = 0x10
6180
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006181} CXIndexOptFlags;
6182
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006183/**
6184 * \brief Index the given source file and the translation unit corresponding
James Dennett574cb4c2012-06-15 05:41:51 +00006185 * to that file via callbacks implemented through #IndexerCallbacks.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006186 *
6187 * \param client_data pointer data supplied by the client, which will
6188 * be passed to the invoked callbacks.
6189 *
6190 * \param index_callbacks Pointer to indexing callbacks that the client
6191 * implements.
6192 *
James Dennett574cb4c2012-06-15 05:41:51 +00006193 * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006194 * passed in index_callbacks.
6195 *
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006196 * \param index_options A bitmask of options that affects how indexing is
6197 * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006198 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006199 * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6200 * reused after indexing is finished. Set to \c NULL if you do not require it.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006201 *
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006202 * \returns 0 on success or if there were errors from which the compiler could
Eric Christopher2c4555a2015-06-19 01:52:53 +00006203 * recover. If there is a failure from which there is no recovery, returns
Dmitri Gribenkoea4d1c32014-02-12 19:12:37 +00006204 * a non-zero \c CXErrorCode.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006205 *
James Dennett574cb4c2012-06-15 05:41:51 +00006206 * The rest of the parameters are the same as #clang_parseTranslationUnit.
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006207 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006208CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006209 CXClientData client_data,
6210 IndexerCallbacks *index_callbacks,
6211 unsigned index_callbacks_size,
6212 unsigned index_options,
6213 const char *source_filename,
6214 const char * const *command_line_args,
6215 int num_command_line_args,
6216 struct CXUnsavedFile *unsaved_files,
6217 unsigned num_unsaved_files,
6218 CXTranslationUnit *out_TU,
6219 unsigned TU_options);
6220
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006221/**
Benjamin Kramerc02670e2015-11-18 16:14:27 +00006222 * \brief Same as clang_indexSourceFile but requires a full command line
6223 * for \c command_line_args including argv[0]. This is useful if the standard
6224 * library paths are relative to the binary.
6225 */
6226CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6227 CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6228 unsigned index_callbacks_size, unsigned index_options,
6229 const char *source_filename, const char *const *command_line_args,
6230 int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6231 unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6232
6233/**
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006234 * \brief Index the given translation unit via callbacks implemented through
James Dennett574cb4c2012-06-15 05:41:51 +00006235 * #IndexerCallbacks.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006236 *
6237 * The order of callback invocations is not guaranteed to be the same as
6238 * when indexing a source file. The high level order will be:
6239 *
6240 * -Preprocessor callbacks invocations
6241 * -Declaration/reference callbacks invocations
6242 * -Diagnostic callback invocations
6243 *
James Dennett574cb4c2012-06-15 05:41:51 +00006244 * The parameters are the same as #clang_indexSourceFile.
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006245 *
Eric Christopher2c4555a2015-06-19 01:52:53 +00006246 * \returns If there is a failure from which there is no recovery, returns
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006247 * non-zero, otherwise returns 0.
6248 */
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006249CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006250 CXClientData client_data,
6251 IndexerCallbacks *index_callbacks,
6252 unsigned index_callbacks_size,
Argyrios Kyrtzidis4c910b12011-11-22 07:24:51 +00006253 unsigned index_options,
6254 CXTranslationUnit);
Argyrios Kyrtzidisd992e142011-11-15 06:20:16 +00006255
6256/**
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006257 * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by
6258 * the given CXIdxLoc.
6259 *
6260 * If the location refers into a macro expansion, retrieves the
6261 * location of the macro expansion and if it refers into a macro argument
6262 * retrieves the location of the argument.
6263 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006264CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
Argyrios Kyrtzidis7519c5e2011-11-11 00:23:36 +00006265 CXIdxClientFile *indexFile,
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006266 CXFile *file,
6267 unsigned *line,
6268 unsigned *column,
6269 unsigned *offset);
6270
Argyrios Kyrtzidis11d61142011-10-27 17:36:12 +00006271/**
6272 * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6273 */
Argyrios Kyrtzidisdc199a32011-10-17 19:48:19 +00006274CINDEX_LINKAGE
6275CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6276
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006277/**
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006278 * \brief Visitor invoked for each field found by a traversal.
6279 *
6280 * This visitor function will be invoked for each field found by
6281 * \c clang_Type_visitFields. Its first argument is the cursor being
6282 * visited, its second argument is the client data provided to
6283 * \c clang_Type_visitFields.
6284 *
6285 * The visitor should return one of the \c CXVisitorResult values
6286 * to direct \c clang_Type_visitFields.
6287 */
6288typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6289 CXClientData client_data);
6290
6291/**
6292 * \brief Visit the fields of a particular type.
6293 *
6294 * This function visits all the direct fields of the given cursor,
6295 * invoking the given \p visitor function with the cursors of each
6296 * visited field. The traversal may be ended prematurely, if
6297 * the visitor returns \c CXFieldVisit_Break.
6298 *
6299 * \param T the record type whose field may be visited.
6300 *
6301 * \param visitor the visitor function that will be invoked for each
6302 * field of \p T.
6303 *
6304 * \param client_data pointer data supplied by the client, which will
6305 * be passed to the visitor each time it is invoked.
6306 *
6307 * \returns a non-zero value if the traversal was terminated
6308 * prematurely by the visitor returning \c CXFieldVisit_Break.
6309 */
6310CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6311 CXFieldVisitor visitor,
6312 CXClientData client_data);
6313
Argyrios Kyrtzidis2bff5162015-04-13 16:55:04 +00006314/**
Argyrios Kyrtzidiscddafd32011-10-06 07:00:54 +00006315 * @}
6316 */
6317
Douglas Gregor6007cf22010-01-22 22:29:16 +00006318/**
6319 * @}
6320 */
Daniel Dunbar62ebf252010-01-24 02:54:26 +00006321
Ted Kremenekb60d87c2009-08-26 22:36:44 +00006322#ifdef __cplusplus
6323}
6324#endif
6325#endif