blob: 72c829acbbc645cb8748781106c5a9283d464def [file] [log] [blame]
Ted Kremenekd2fa5662009-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|* *|
10|* This header provides a public inferface to a Clang library for extracting *|
11|* high-level symbol information from source files without exposing the full *|
12|* Clang C++ API. *|
13|* *|
14\*===----------------------------------------------------------------------===*/
15
16#ifndef CLANG_C_INDEX_H
17#define CLANG_C_INDEX_H
18
Steve Naroff88145032009-10-27 14:35:18 +000019#include <sys/stat.h>
Chandler Carruth3d315602009-12-17 09:27:29 +000020#include <time.h>
Douglas Gregor0a812cf2010-02-18 23:07:20 +000021#include <stdio.h>
Steve Naroff88145032009-10-27 14:35:18 +000022
Ted Kremenekd2fa5662009-08-26 22:36:44 +000023#ifdef __cplusplus
24extern "C" {
25#endif
26
Steve Naroff88145032009-10-27 14:35:18 +000027/* MSVC DLL import/export. */
John Thompson2e06fc82009-10-27 13:42:56 +000028#ifdef _MSC_VER
29 #ifdef _CINDEX_LIB_
30 #define CINDEX_LINKAGE __declspec(dllexport)
31 #else
32 #define CINDEX_LINKAGE __declspec(dllimport)
33 #endif
34#else
35 #define CINDEX_LINKAGE
36#endif
37
Douglas Gregor87fb9402011-02-23 17:45:25 +000038/** \defgroup CINDEX libclang: C Interface to Clang
Douglas Gregor20d416c2010-01-20 01:10:47 +000039 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +000040 * The C Interface to Clang provides a relatively small API that exposes
Douglas Gregorf5525442010-01-20 22:45:41 +000041 * facilities for parsing source code into an abstract syntax tree (AST),
42 * loading already-parsed ASTs, traversing the AST, associating
43 * physical source locations with elements within the AST, and other
44 * facilities that support Clang-based development tools.
Douglas Gregor20d416c2010-01-20 01:10:47 +000045 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +000046 * This C interface to Clang will never provide all of the information
Douglas Gregorf5525442010-01-20 22:45:41 +000047 * representation stored in Clang's C++ AST, nor should it: the intent is to
48 * maintain an API that is relatively stable from one release to the next,
49 * providing only the basic functionality needed to support development tools.
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +000050 *
51 * To avoid namespace pollution, data types are prefixed with "CX" and
Douglas Gregorf5525442010-01-20 22:45:41 +000052 * functions are prefixed with "clang_".
Douglas Gregor20d416c2010-01-20 01:10:47 +000053 *
54 * @{
55 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +000056
Douglas Gregor7f173762010-01-20 22:28:27 +000057/**
58 * \brief An "index" that consists of a set of translation units that would
59 * typically be linked together into an executable or library.
60 */
61typedef void *CXIndex;
Steve Naroff600866c2009-08-27 19:51:58 +000062
Douglas Gregor7f173762010-01-20 22:28:27 +000063/**
64 * \brief A single translation unit, which resides in an index.
65 */
Ted Kremenek0a90d322010-11-17 23:24:11 +000066typedef struct CXTranslationUnitImpl *CXTranslationUnit;
Steve Naroff600866c2009-08-27 19:51:58 +000067
Douglas Gregor7f173762010-01-20 22:28:27 +000068/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +000069 * \brief Opaque pointer representing client data that will be passed through
70 * to various callbacks and visitors.
Douglas Gregor7f173762010-01-20 22:28:27 +000071 */
Douglas Gregorc42fefa2010-01-22 22:29:16 +000072typedef void *CXClientData;
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +000073
Douglas Gregor735df882009-12-02 09:21:34 +000074/**
75 * \brief Provides the contents of a file that has not yet been saved to disk.
76 *
77 * Each CXUnsavedFile instance provides the name of a file on the
78 * system along with the current contents of that file that have not
79 * yet been saved to disk.
80 */
81struct CXUnsavedFile {
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +000082 /**
83 * \brief The file whose contents have not yet been saved.
Douglas Gregor735df882009-12-02 09:21:34 +000084 *
85 * This file must already exist in the file system.
86 */
87 const char *Filename;
88
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +000089 /**
Douglas Gregorc8dfe5e2010-02-27 01:32:48 +000090 * \brief A buffer containing the unsaved contents of this file.
Douglas Gregor735df882009-12-02 09:21:34 +000091 */
92 const char *Contents;
93
94 /**
Douglas Gregorc8dfe5e2010-02-27 01:32:48 +000095 * \brief The length of the unsaved contents of this buffer.
Douglas Gregor735df882009-12-02 09:21:34 +000096 */
97 unsigned long Length;
98};
99
Peter Collingbourne076c22a2010-08-24 00:31:37 +0000100/**
101 * \brief Describes the availability of a particular entity, which indicates
102 * whether the use of this entity will result in a warning or error due to
103 * it being deprecated or unavailable.
104 */
Douglas Gregor58ddb602010-08-23 23:00:57 +0000105enum CXAvailabilityKind {
Peter Collingbourne076c22a2010-08-24 00:31:37 +0000106 /**
107 * \brief The entity is available.
108 */
Douglas Gregor58ddb602010-08-23 23:00:57 +0000109 CXAvailability_Available,
Peter Collingbourne076c22a2010-08-24 00:31:37 +0000110 /**
111 * \brief The entity is available, but has been deprecated (and its use is
112 * not recommended).
113 */
Douglas Gregor58ddb602010-08-23 23:00:57 +0000114 CXAvailability_Deprecated,
Peter Collingbourne076c22a2010-08-24 00:31:37 +0000115 /**
116 * \brief The entity is not available; any use of it will be an error.
117 */
Douglas Gregor58ddb602010-08-23 23:00:57 +0000118 CXAvailability_NotAvailable
119};
120
Douglas Gregor7f173762010-01-20 22:28:27 +0000121/**
Douglas Gregor7f173762010-01-20 22:28:27 +0000122 * \defgroup CINDEX_STRING String manipulation routines
123 *
124 * @{
125 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000126
Douglas Gregor7f173762010-01-20 22:28:27 +0000127/**
128 * \brief A character string.
129 *
130 * The \c CXString type is used to return strings from the interface when
131 * the ownership of that string might different from one call to the next.
132 * Use \c clang_getCString() to retrieve the string data and, once finished
133 * with the string data, call \c clang_disposeString() to free the string.
Steve Naroffef0cef62009-11-09 17:45:52 +0000134 */
135typedef struct {
Ted Kremeneka60ed472010-11-16 08:15:36 +0000136 void *data;
Ted Kremeneked122732010-11-16 01:56:27 +0000137 unsigned private_flags;
Steve Naroffef0cef62009-11-09 17:45:52 +0000138} CXString;
139
Douglas Gregor7f173762010-01-20 22:28:27 +0000140/**
141 * \brief Retrieve the character data associated with the given string.
142 */
Steve Naroffef0cef62009-11-09 17:45:52 +0000143CINDEX_LINKAGE const char *clang_getCString(CXString string);
144
Douglas Gregor7f173762010-01-20 22:28:27 +0000145/**
146 * \brief Free the given string,
147 */
Steve Naroffef0cef62009-11-09 17:45:52 +0000148CINDEX_LINKAGE void clang_disposeString(CXString string);
149
Douglas Gregor7f173762010-01-20 22:28:27 +0000150/**
151 * @}
152 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000153
154/**
Steve Naroffe56b4ba2009-10-20 14:46:24 +0000155 * \brief clang_createIndex() provides a shared context for creating
156 * translation units. It provides two options:
157 *
158 * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
159 * declarations (when loading any new translation units). A "local" declaration
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000160 * is one that belongs in the translation unit itself and not in a precompiled
Steve Naroffe56b4ba2009-10-20 14:46:24 +0000161 * header that was used by the translation unit. If zero, all declarations
162 * will be enumerated.
163 *
Steve Naroffb4ece632009-10-20 16:36:34 +0000164 * Here is an example:
165 *
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000166 * // excludeDeclsFromPCH = 1, displayDiagnostics=1
167 * Idx = clang_createIndex(1, 1);
Steve Naroffb4ece632009-10-20 16:36:34 +0000168 *
169 * // IndexTest.pch was produced with the following command:
170 * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
171 * TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
172 *
173 * // This will load all the symbols from 'IndexTest.pch'
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000174 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
Douglas Gregor002a5282010-01-20 21:37:00 +0000175 * TranslationUnitVisitor, 0);
Steve Naroffb4ece632009-10-20 16:36:34 +0000176 * clang_disposeTranslationUnit(TU);
177 *
178 * // This will load all the symbols from 'IndexTest.c', excluding symbols
179 * // from 'IndexTest.pch'.
Daniel Dunbarfd9f2342010-01-25 00:43:14 +0000180 * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
181 * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
182 * 0, 0);
Douglas Gregorb2cd4872010-01-20 23:57:43 +0000183 * clang_visitChildren(clang_getTranslationUnitCursor(TU),
184 * TranslationUnitVisitor, 0);
Steve Naroffb4ece632009-10-20 16:36:34 +0000185 * clang_disposeTranslationUnit(TU);
186 *
187 * This process of creating the 'pch', loading it separately, and using it (via
188 * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
189 * (which gives the indexer the same performance benefit as the compiler).
Steve Naroffe56b4ba2009-10-20 14:46:24 +0000190 */
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000191CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
192 int displayDiagnostics);
Ted Kremenek896b70f2010-03-13 02:50:34 +0000193
Douglas Gregor0087e1a2010-02-08 23:03:06 +0000194/**
195 * \brief Destroy the given index.
196 *
197 * The index must not be destroyed until all of the translation units created
198 * within that index have been destroyed.
199 */
Daniel Dunbar8506dde2009-12-03 01:54:28 +0000200CINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000201
202/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +0000203 * \defgroup CINDEX_FILES File manipulation routines
Douglas Gregorf5525442010-01-20 22:45:41 +0000204 *
205 * @{
206 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000207
Douglas Gregorf5525442010-01-20 22:45:41 +0000208/**
209 * \brief A particular source file that is part of a translation unit.
210 */
211typedef void *CXFile;
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000212
Douglas Gregorf5525442010-01-20 22:45:41 +0000213
214/**
215 * \brief Retrieve the complete file and path name of the given file.
Steve Naroff88145032009-10-27 14:35:18 +0000216 */
Ted Kremenek74844072010-02-17 00:41:20 +0000217CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000218
Douglas Gregorf5525442010-01-20 22:45:41 +0000219/**
220 * \brief Retrieve the last modification time of the given file.
221 */
Douglas Gregor08b0e8d2009-10-31 15:48:08 +0000222CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
Steve Naroff88145032009-10-27 14:35:18 +0000223
Douglas Gregor3c7313d2010-01-18 22:13:09 +0000224/**
Douglas Gregordd3e5542011-05-04 00:14:37 +0000225 * \brief Determine whether the given header is guarded against
226 * multiple inclusions, either with the conventional
227 * #ifndef/#define/#endif macro guards or with #pragma once.
228 */
229CINDEX_LINKAGE unsigned
230clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
231
232/**
Douglas Gregorb9790342010-01-22 21:44:22 +0000233 * \brief Retrieve a file handle within the given translation unit.
234 *
235 * \param tu the translation unit
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000236 *
Douglas Gregorb9790342010-01-22 21:44:22 +0000237 * \param file_name the name of the file.
238 *
239 * \returns the file handle for the named file in the translation unit \p tu,
240 * or a NULL file handle if the file was not a part of this translation unit.
241 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000242CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
Douglas Gregorb9790342010-01-22 21:44:22 +0000243 const char *file_name);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000244
Douglas Gregorb9790342010-01-22 21:44:22 +0000245/**
Douglas Gregorf5525442010-01-20 22:45:41 +0000246 * @}
247 */
248
249/**
250 * \defgroup CINDEX_LOCATIONS Physical source locations
251 *
252 * Clang represents physical source locations in its abstract syntax tree in
253 * great detail, with file, line, and column information for the majority of
254 * the tokens parsed in the source code. These data types and functions are
255 * used to represent source location information, either for a particular
256 * point in the program or for a range of points in the program, and extract
257 * specific location information from those data types.
258 *
259 * @{
260 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000261
Douglas Gregorf5525442010-01-20 22:45:41 +0000262/**
Douglas Gregor1db19de2010-01-19 21:36:55 +0000263 * \brief Identifies a specific source location within a translation
264 * unit.
265 *
Chandler Carruth20174222011-08-31 16:53:37 +0000266 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
Douglas Gregora9b06d42010-11-09 06:24:54 +0000267 * to map a source location to a particular file, line, and column.
Douglas Gregor3c7313d2010-01-18 22:13:09 +0000268 */
269typedef struct {
Douglas Gregor5352ac02010-01-28 00:27:43 +0000270 void *ptr_data[2];
Douglas Gregor1db19de2010-01-19 21:36:55 +0000271 unsigned int_data;
Douglas Gregor3c7313d2010-01-18 22:13:09 +0000272} CXSourceLocation;
Ted Kremenekfe6fd3d2010-01-05 23:18:49 +0000273
Douglas Gregor3c7313d2010-01-18 22:13:09 +0000274/**
Daniel Dunbard52864b2010-02-14 10:02:57 +0000275 * \brief Identifies a half-open character range in the source code.
Douglas Gregor3c7313d2010-01-18 22:13:09 +0000276 *
Douglas Gregor1db19de2010-01-19 21:36:55 +0000277 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
278 * starting and end locations from a source range, respectively.
Douglas Gregor3c7313d2010-01-18 22:13:09 +0000279 */
280typedef struct {
Douglas Gregor5352ac02010-01-28 00:27:43 +0000281 void *ptr_data[2];
Douglas Gregor1db19de2010-01-19 21:36:55 +0000282 unsigned begin_int_data;
283 unsigned end_int_data;
Douglas Gregor3c7313d2010-01-18 22:13:09 +0000284} CXSourceRange;
Ted Kremenekfe6fd3d2010-01-05 23:18:49 +0000285
Douglas Gregor1db19de2010-01-19 21:36:55 +0000286/**
Douglas Gregorb9790342010-01-22 21:44:22 +0000287 * \brief Retrieve a NULL (invalid) source location.
288 */
289CINDEX_LINKAGE CXSourceLocation clang_getNullLocation();
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000290
Douglas Gregorb9790342010-01-22 21:44:22 +0000291/**
292 * \determine Determine whether two source locations, which must refer into
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000293 * the same translation unit, refer to exactly the same point in the source
Douglas Gregorb9790342010-01-22 21:44:22 +0000294 * code.
295 *
296 * \returns non-zero if the source locations refer to the same location, zero
297 * if they refer to different locations.
298 */
299CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
300 CXSourceLocation loc2);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000301
Douglas Gregorb9790342010-01-22 21:44:22 +0000302/**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000303 * \brief Retrieves the source location associated with a given file/line/column
304 * in a particular translation unit.
Douglas Gregorb9790342010-01-22 21:44:22 +0000305 */
306CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
307 CXFile file,
308 unsigned line,
309 unsigned column);
David Chisnall83889a72010-10-15 17:07:39 +0000310/**
311 * \brief Retrieves the source location associated with a given character offset
312 * in a particular translation unit.
313 */
314CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
315 CXFile file,
316 unsigned offset);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000317
Douglas Gregorb9790342010-01-22 21:44:22 +0000318/**
Douglas Gregor5352ac02010-01-28 00:27:43 +0000319 * \brief Retrieve a NULL (invalid) source range.
320 */
321CINDEX_LINKAGE CXSourceRange clang_getNullRange();
Ted Kremenek896b70f2010-03-13 02:50:34 +0000322
Douglas Gregor5352ac02010-01-28 00:27:43 +0000323/**
Douglas Gregorb9790342010-01-22 21:44:22 +0000324 * \brief Retrieve a source range given the beginning and ending source
325 * locations.
326 */
327CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
328 CXSourceLocation end);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000329
Douglas Gregorb9790342010-01-22 21:44:22 +0000330/**
Douglas Gregorab4e83b2011-07-23 19:35:14 +0000331 * \brief Determine whether two ranges are equivalent.
332 *
333 * \returns non-zero if the ranges are the same, zero if they differ.
334 */
335CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
336 CXSourceRange range2);
337
338/**
Argyrios Kyrtzidisde5db642011-09-28 18:14:21 +0000339 * \brief Returns non-zero if \arg range is null.
340 */
341int clang_Range_isNull(CXSourceRange range);
342
343/**
Douglas Gregor46766dc2010-01-26 19:19:08 +0000344 * \brief Retrieve the file, line, column, and offset represented by
345 * the given source location.
Douglas Gregor1db19de2010-01-19 21:36:55 +0000346 *
Chandler Carruth20174222011-08-31 16:53:37 +0000347 * If the location refers into a macro expansion, retrieves the
348 * location of the macro expansion.
Douglas Gregora9b06d42010-11-09 06:24:54 +0000349 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000350 * \param location the location within a source file that will be decomposed
351 * into its parts.
Douglas Gregor1db19de2010-01-19 21:36:55 +0000352 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000353 * \param file [out] if non-NULL, will be set to the file to which the given
Douglas Gregor1db19de2010-01-19 21:36:55 +0000354 * source location points.
355 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000356 * \param line [out] if non-NULL, will be set to the line to which the given
Douglas Gregor1db19de2010-01-19 21:36:55 +0000357 * source location points.
358 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000359 * \param column [out] if non-NULL, will be set to the column to which the given
360 * source location points.
Douglas Gregor46766dc2010-01-26 19:19:08 +0000361 *
362 * \param offset [out] if non-NULL, will be set to the offset into the
363 * buffer to which the given source location points.
Douglas Gregor1db19de2010-01-19 21:36:55 +0000364 */
Chandler Carruth20174222011-08-31 16:53:37 +0000365CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
366 CXFile *file,
367 unsigned *line,
368 unsigned *column,
369 unsigned *offset);
370
371/**
Argyrios Kyrtzidise6be34d2011-09-13 21:49:08 +0000372 * \brief Retrieve the file, line, column, and offset represented by
373 * the given source location, as specified in a # line directive.
374 *
375 * Example: given the following source code in a file somefile.c
376 *
377 * #123 "dummy.c" 1
378 *
379 * static int func(void)
380 * {
381 * return 0;
382 * }
383 *
384 * the location information returned by this function would be
385 *
386 * File: dummy.c Line: 124 Column: 12
387 *
388 * whereas clang_getExpansionLocation would have returned
389 *
390 * File: somefile.c Line: 3 Column: 12
391 *
392 * \param location the location within a source file that will be decomposed
393 * into its parts.
394 *
395 * \param filename [out] if non-NULL, will be set to the filename of the
396 * source location. Note that filenames returned will be for "virtual" files,
397 * which don't necessarily exist on the machine running clang - e.g. when
398 * parsing preprocessed output obtained from a different environment. If
399 * a non-NULL value is passed in, remember to dispose of the returned value
400 * using \c clang_disposeString() once you've finished with it. For an invalid
401 * source location, an empty string is returned.
402 *
403 * \param line [out] if non-NULL, will be set to the line number of the
404 * source location. For an invalid source location, zero is returned.
405 *
406 * \param column [out] if non-NULL, will be set to the column number of the
407 * source location. For an invalid source location, zero is returned.
408 */
409CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
410 CXString *filename,
411 unsigned *line,
412 unsigned *column);
413
414/**
Chandler Carruth20174222011-08-31 16:53:37 +0000415 * \brief Legacy API to retrieve the file, line, column, and offset represented
416 * by the given source location.
417 *
418 * This interface has been replaced by the newer interface
419 * \see clang_getExpansionLocation(). See that interface's documentation for
420 * details.
421 */
Douglas Gregor1db19de2010-01-19 21:36:55 +0000422CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
423 CXFile *file,
424 unsigned *line,
Douglas Gregor46766dc2010-01-26 19:19:08 +0000425 unsigned *column,
426 unsigned *offset);
Douglas Gregore69517c2010-01-26 03:07:15 +0000427
428/**
Douglas Gregora9b06d42010-11-09 06:24:54 +0000429 * \brief Retrieve the file, line, column, and offset represented by
430 * the given source location.
431 *
432 * If the location refers into a macro instantiation, return where the
433 * location was originally spelled in the source file.
434 *
435 * \param location the location within a source file that will be decomposed
436 * into its parts.
437 *
438 * \param file [out] if non-NULL, will be set to the file to which the given
439 * source location points.
440 *
441 * \param line [out] if non-NULL, will be set to the line to which the given
442 * source location points.
443 *
444 * \param column [out] if non-NULL, will be set to the column to which the given
445 * source location points.
446 *
447 * \param offset [out] if non-NULL, will be set to the offset into the
448 * buffer to which the given source location points.
449 */
450CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
451 CXFile *file,
452 unsigned *line,
453 unsigned *column,
454 unsigned *offset);
455
456/**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000457 * \brief Retrieve a source location representing the first character within a
458 * source range.
Douglas Gregor1db19de2010-01-19 21:36:55 +0000459 */
460CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
461
462/**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +0000463 * \brief Retrieve a source location representing the last character within a
464 * source range.
Douglas Gregor1db19de2010-01-19 21:36:55 +0000465 */
466CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
467
Douglas Gregorf5525442010-01-20 22:45:41 +0000468/**
469 * @}
470 */
Douglas Gregorc42fefa2010-01-22 22:29:16 +0000471
472/**
Douglas Gregor5352ac02010-01-28 00:27:43 +0000473 * \defgroup CINDEX_DIAG Diagnostic reporting
474 *
475 * @{
476 */
477
478/**
479 * \brief Describes the severity of a particular diagnostic.
480 */
481enum CXDiagnosticSeverity {
482 /**
Ted Kremenek896b70f2010-03-13 02:50:34 +0000483 * \brief A diagnostic that has been suppressed, e.g., by a command-line
Douglas Gregor5352ac02010-01-28 00:27:43 +0000484 * option.
485 */
486 CXDiagnostic_Ignored = 0,
Ted Kremenek896b70f2010-03-13 02:50:34 +0000487
Douglas Gregor5352ac02010-01-28 00:27:43 +0000488 /**
489 * \brief This diagnostic is a note that should be attached to the
490 * previous (non-note) diagnostic.
491 */
492 CXDiagnostic_Note = 1,
493
494 /**
495 * \brief This diagnostic indicates suspicious code that may not be
496 * wrong.
497 */
498 CXDiagnostic_Warning = 2,
499
500 /**
501 * \brief This diagnostic indicates that the code is ill-formed.
502 */
503 CXDiagnostic_Error = 3,
504
505 /**
506 * \brief This diagnostic indicates that the code is ill-formed such
507 * that future parser recovery is unlikely to produce useful
508 * results.
509 */
510 CXDiagnostic_Fatal = 4
511};
512
513/**
Douglas Gregor5352ac02010-01-28 00:27:43 +0000514 * \brief A single diagnostic, containing the diagnostic's severity,
515 * location, text, source ranges, and fix-it hints.
516 */
517typedef void *CXDiagnostic;
518
519/**
Douglas Gregora88084b2010-02-18 18:08:43 +0000520 * \brief Determine the number of diagnostics produced for the given
521 * translation unit.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000522 */
Douglas Gregora88084b2010-02-18 18:08:43 +0000523CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
524
525/**
526 * \brief Retrieve a diagnostic associated with the given translation unit.
527 *
528 * \param Unit the translation unit to query.
529 * \param Index the zero-based diagnostic number to retrieve.
530 *
531 * \returns the requested diagnostic. This diagnostic must be freed
532 * via a call to \c clang_disposeDiagnostic().
533 */
534CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
535 unsigned Index);
536
537/**
538 * \brief Destroy a diagnostic.
539 */
540CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
Douglas Gregor5352ac02010-01-28 00:27:43 +0000541
542/**
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000543 * \brief Options to control the display of diagnostics.
544 *
545 * The values in this enum are meant to be combined to customize the
546 * behavior of \c clang_displayDiagnostic().
547 */
548enum CXDiagnosticDisplayOptions {
549 /**
550 * \brief Display the source-location information where the
551 * diagnostic was located.
552 *
553 * When set, diagnostics will be prefixed by the file, line, and
554 * (optionally) column to which the diagnostic refers. For example,
555 *
556 * \code
557 * test.c:28: warning: extra tokens at end of #endif directive
558 * \endcode
559 *
560 * This option corresponds to the clang flag \c -fshow-source-location.
561 */
562 CXDiagnostic_DisplaySourceLocation = 0x01,
563
564 /**
565 * \brief If displaying the source-location information of the
566 * diagnostic, also include the column number.
567 *
568 * This option corresponds to the clang flag \c -fshow-column.
569 */
570 CXDiagnostic_DisplayColumn = 0x02,
571
572 /**
573 * \brief If displaying the source-location information of the
574 * diagnostic, also include information about source ranges in a
575 * machine-parsable format.
576 *
Ted Kremenek896b70f2010-03-13 02:50:34 +0000577 * This option corresponds to the clang flag
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000578 * \c -fdiagnostics-print-source-range-info.
579 */
Douglas Gregoraa5f1352010-11-19 16:18:16 +0000580 CXDiagnostic_DisplaySourceRanges = 0x04,
581
582 /**
583 * \brief Display the option name associated with this diagnostic, if any.
584 *
585 * The option name displayed (e.g., -Wconversion) will be placed in brackets
586 * after the diagnostic text. This option corresponds to the clang flag
587 * \c -fdiagnostics-show-option.
588 */
589 CXDiagnostic_DisplayOption = 0x08,
590
591 /**
592 * \brief Display the category number associated with this diagnostic, if any.
593 *
594 * The category number is displayed within brackets after the diagnostic text.
595 * This option corresponds to the clang flag
596 * \c -fdiagnostics-show-category=id.
597 */
598 CXDiagnostic_DisplayCategoryId = 0x10,
599
600 /**
601 * \brief Display the category name associated with this diagnostic, if any.
602 *
603 * The category name is displayed within brackets after the diagnostic text.
604 * This option corresponds to the clang flag
605 * \c -fdiagnostics-show-category=name.
606 */
607 CXDiagnostic_DisplayCategoryName = 0x20
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000608};
609
610/**
Douglas Gregor274f1902010-02-22 23:17:23 +0000611 * \brief Format the given diagnostic in a manner that is suitable for display.
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000612 *
Douglas Gregor274f1902010-02-22 23:17:23 +0000613 * This routine will format the given diagnostic to a string, rendering
Ted Kremenek896b70f2010-03-13 02:50:34 +0000614 * the diagnostic according to the various options given. The
615 * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000616 * options that most closely mimics the behavior of the clang compiler.
617 *
618 * \param Diagnostic The diagnostic to print.
619 *
Ted Kremenek896b70f2010-03-13 02:50:34 +0000620 * \param Options A set of options that control the diagnostic display,
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000621 * created by combining \c CXDiagnosticDisplayOptions values.
Douglas Gregor274f1902010-02-22 23:17:23 +0000622 *
623 * \returns A new string containing for formatted diagnostic.
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000624 */
Douglas Gregor274f1902010-02-22 23:17:23 +0000625CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
626 unsigned Options);
Douglas Gregor0a812cf2010-02-18 23:07:20 +0000627
628/**
629 * \brief Retrieve the set of display options most similar to the
630 * default behavior of the clang compiler.
631 *
632 * \returns A set of display options suitable for use with \c
633 * clang_displayDiagnostic().
634 */
635CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
636
637/**
Douglas Gregor5352ac02010-01-28 00:27:43 +0000638 * \brief Determine the severity of the given diagnostic.
639 */
Ted Kremenek896b70f2010-03-13 02:50:34 +0000640CINDEX_LINKAGE enum CXDiagnosticSeverity
Douglas Gregor5352ac02010-01-28 00:27:43 +0000641clang_getDiagnosticSeverity(CXDiagnostic);
642
643/**
644 * \brief Retrieve the source location of the given diagnostic.
645 *
646 * This location is where Clang would print the caret ('^') when
647 * displaying the diagnostic on the command line.
648 */
649CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
650
651/**
652 * \brief Retrieve the text of the given diagnostic.
653 */
654CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
Douglas Gregora3890ba2010-02-08 23:11:56 +0000655
656/**
Douglas Gregoraa5f1352010-11-19 16:18:16 +0000657 * \brief Retrieve the name of the command-line option that enabled this
658 * diagnostic.
659 *
660 * \param Diag The diagnostic to be queried.
661 *
662 * \param Disable If non-NULL, will be set to the option that disables this
663 * diagnostic (if any).
664 *
665 * \returns A string that contains the command-line option used to enable this
666 * warning, such as "-Wconversion" or "-pedantic".
667 */
668CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
669 CXString *Disable);
670
671/**
672 * \brief Retrieve the category number for this diagnostic.
673 *
674 * Diagnostics can be categorized into groups along with other, related
675 * diagnostics (e.g., diagnostics under the same warning flag). This routine
676 * retrieves the category number for the given diagnostic.
677 *
678 * \returns The number of the category that contains this diagnostic, or zero
679 * if this diagnostic is uncategorized.
680 */
681CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
682
683/**
684 * \brief Retrieve the name of a particular diagnostic category.
685 *
686 * \param Category A diagnostic category number, as returned by
687 * \c clang_getDiagnosticCategory().
688 *
689 * \returns The name of the given diagnostic category.
690 */
691CINDEX_LINKAGE CXString clang_getDiagnosticCategoryName(unsigned Category);
692
693/**
Douglas Gregora3890ba2010-02-08 23:11:56 +0000694 * \brief Determine the number of source ranges associated with the given
695 * diagnostic.
696 */
697CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
Ted Kremenek896b70f2010-03-13 02:50:34 +0000698
Douglas Gregor5352ac02010-01-28 00:27:43 +0000699/**
Douglas Gregora3890ba2010-02-08 23:11:56 +0000700 * \brief Retrieve a source range associated with the diagnostic.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000701 *
Douglas Gregora3890ba2010-02-08 23:11:56 +0000702 * A diagnostic's source ranges highlight important elements in the source
Douglas Gregor5352ac02010-01-28 00:27:43 +0000703 * code. On the command line, Clang displays source ranges by
Ted Kremenek896b70f2010-03-13 02:50:34 +0000704 * underlining them with '~' characters.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000705 *
Douglas Gregora3890ba2010-02-08 23:11:56 +0000706 * \param Diagnostic the diagnostic whose range is being extracted.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000707 *
Ted Kremenek896b70f2010-03-13 02:50:34 +0000708 * \param Range the zero-based index specifying which range to
Douglas Gregor5352ac02010-01-28 00:27:43 +0000709 *
Douglas Gregora3890ba2010-02-08 23:11:56 +0000710 * \returns the requested source range.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000711 */
Ted Kremenek896b70f2010-03-13 02:50:34 +0000712CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
Douglas Gregora3890ba2010-02-08 23:11:56 +0000713 unsigned Range);
Douglas Gregor5352ac02010-01-28 00:27:43 +0000714
715/**
716 * \brief Determine the number of fix-it hints associated with the
717 * given diagnostic.
718 */
719CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
720
721/**
Douglas Gregor473d7012010-02-19 18:16:06 +0000722 * \brief Retrieve the replacement information for a given fix-it.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000723 *
Douglas Gregor473d7012010-02-19 18:16:06 +0000724 * Fix-its are described in terms of a source range whose contents
725 * should be replaced by a string. This approach generalizes over
726 * three kinds of operations: removal of source code (the range covers
727 * the code to be removed and the replacement string is empty),
728 * replacement of source code (the range covers the code to be
729 * replaced and the replacement string provides the new code), and
730 * insertion (both the start and end of the range point at the
731 * insertion location, and the replacement string provides the text to
732 * insert).
Douglas Gregor5352ac02010-01-28 00:27:43 +0000733 *
Douglas Gregor473d7012010-02-19 18:16:06 +0000734 * \param Diagnostic The diagnostic whose fix-its are being queried.
735 *
736 * \param FixIt The zero-based index of the fix-it.
737 *
738 * \param ReplacementRange The source range whose contents will be
739 * replaced with the returned replacement string. Note that source
740 * ranges are half-open ranges [a, b), so the source code should be
741 * replaced from a and up to (but not including) b.
742 *
743 * \returns A string containing text that should be replace the source
744 * code indicated by the \c ReplacementRange.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000745 */
Ted Kremenek896b70f2010-03-13 02:50:34 +0000746CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
Douglas Gregor473d7012010-02-19 18:16:06 +0000747 unsigned FixIt,
748 CXSourceRange *ReplacementRange);
Douglas Gregor5352ac02010-01-28 00:27:43 +0000749
750/**
751 * @}
752 */
753
754/**
755 * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
756 *
757 * The routines in this group provide the ability to create and destroy
758 * translation units from files, either by parsing the contents of the files or
759 * by reading in a serialized representation of a translation unit.
760 *
761 * @{
762 */
Ted Kremenek896b70f2010-03-13 02:50:34 +0000763
Douglas Gregor5352ac02010-01-28 00:27:43 +0000764/**
765 * \brief Get the original translation unit source file name.
766 */
767CINDEX_LINKAGE CXString
768clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
769
770/**
771 * \brief Return the CXTranslationUnit for a given source file and the provided
772 * command line arguments one would pass to the compiler.
773 *
774 * Note: The 'source_filename' argument is optional. If the caller provides a
775 * NULL pointer, the name of the source file is expected to reside in the
776 * specified command line arguments.
777 *
778 * Note: When encountered in 'clang_command_line_args', the following options
779 * are ignored:
780 *
781 * '-c'
782 * '-emit-ast'
783 * '-fsyntax-only'
784 * '-o <output file>' (both '-o' and '<output file>' are ignored)
785 *
Ted Kremenek1ddb02c2010-11-08 04:28:51 +0000786 * \param CIdx The index object with which the translation unit will be
787 * associated.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000788 *
789 * \param source_filename - The name of the source file to load, or NULL if the
Ted Kremenek1ddb02c2010-11-08 04:28:51 +0000790 * source file is included in \p clang_command_line_args.
791 *
792 * \param num_clang_command_line_args The number of command-line arguments in
793 * \p clang_command_line_args.
794 *
795 * \param clang_command_line_args The command-line arguments that would be
796 * passed to the \c clang executable if it were being invoked out-of-process.
797 * These command-line options will be parsed and will affect how the translation
798 * unit is parsed. Note that the following options are ignored: '-c',
799 * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000800 *
801 * \param num_unsaved_files the number of unsaved file entries in \p
802 * unsaved_files.
803 *
804 * \param unsaved_files the files that have not yet been saved to disk
805 * but may be required for code completion, including the contents of
Ted Kremenekc6f530d2010-04-12 18:47:26 +0000806 * those files. The contents and name of these files (as specified by
807 * CXUnsavedFile) are copied when necessary, so the client only needs to
808 * guarantee their validity until the call to this function returns.
Douglas Gregor5352ac02010-01-28 00:27:43 +0000809 */
810CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
811 CXIndex CIdx,
812 const char *source_filename,
813 int num_clang_command_line_args,
Douglas Gregor2ef69442010-09-01 16:43:19 +0000814 const char * const *clang_command_line_args,
Douglas Gregor5352ac02010-01-28 00:27:43 +0000815 unsigned num_unsaved_files,
Douglas Gregora88084b2010-02-18 18:08:43 +0000816 struct CXUnsavedFile *unsaved_files);
Ted Kremenek896b70f2010-03-13 02:50:34 +0000817
Douglas Gregor5352ac02010-01-28 00:27:43 +0000818/**
819 * \brief Create a translation unit from an AST file (-emit-ast).
820 */
Ted Kremenek896b70f2010-03-13 02:50:34 +0000821CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
Douglas Gregora88084b2010-02-18 18:08:43 +0000822 const char *ast_filename);
Douglas Gregor5352ac02010-01-28 00:27:43 +0000823
Douglas Gregor44c181a2010-07-23 00:33:23 +0000824/**
825 * \brief Flags that control the creation of translation units.
826 *
827 * The enumerators in this enumeration type are meant to be bitwise
828 * ORed together to specify which options should be used when
829 * constructing the translation unit.
830 */
Douglas Gregor5a430212010-07-21 18:52:53 +0000831enum CXTranslationUnit_Flags {
832 /**
833 * \brief Used to indicate that no special translation-unit options are
834 * needed.
835 */
836 CXTranslationUnit_None = 0x0,
837
838 /**
839 * \brief Used to indicate that the parser should construct a "detailed"
840 * preprocessing record, including all macro definitions and instantiations.
841 *
842 * Constructing a detailed preprocessing record requires more memory
843 * and time to parse, since the information contained in the record
844 * is usually not retained. However, it can be useful for
845 * applications that require more detailed information about the
846 * behavior of the preprocessor.
847 */
Douglas Gregor44c181a2010-07-23 00:33:23 +0000848 CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
849
850 /**
Douglas Gregorb1c031b2010-08-09 22:28:58 +0000851 * \brief Used to indicate that the translation unit is incomplete.
Douglas Gregor44c181a2010-07-23 00:33:23 +0000852 *
Douglas Gregorb1c031b2010-08-09 22:28:58 +0000853 * When a translation unit is considered "incomplete", semantic
854 * analysis that is typically performed at the end of the
855 * translation unit will be suppressed. For example, this suppresses
856 * the completion of tentative declarations in C and of
857 * instantiation of implicitly-instantiation function templates in
858 * C++. This option is typically used when parsing a header with the
859 * intent of producing a precompiled header.
Douglas Gregor44c181a2010-07-23 00:33:23 +0000860 */
Douglas Gregorb1c031b2010-08-09 22:28:58 +0000861 CXTranslationUnit_Incomplete = 0x02,
Douglas Gregor44c181a2010-07-23 00:33:23 +0000862
863 /**
864 * \brief Used to indicate that the translation unit should be built with an
865 * implicit precompiled header for the preamble.
866 *
867 * An implicit precompiled header is used as an optimization when a
868 * particular translation unit is likely to be reparsed many times
869 * when the sources aren't changing that often. In this case, an
870 * implicit precompiled header will be built containing all of the
871 * initial includes at the top of the main file (what we refer to as
872 * the "preamble" of the file). In subsequent parses, if the
873 * preamble or the files in it have not changed, \c
874 * clang_reparseTranslationUnit() will re-use the implicit
875 * precompiled header to improve parsing performance.
876 */
Douglas Gregore1e13bf2010-08-11 15:58:42 +0000877 CXTranslationUnit_PrecompiledPreamble = 0x04,
878
879 /**
880 * \brief Used to indicate that the translation unit should cache some
881 * code-completion results with each reparse of the source file.
882 *
883 * Caching of code-completion results is a performance optimization that
884 * introduces some overhead to reparsing but improves the performance of
885 * code-completion operations.
886 */
Douglas Gregor99ba2022010-10-27 17:24:53 +0000887 CXTranslationUnit_CacheCompletionResults = 0x08,
888 /**
Douglas Gregorb5af8432011-08-25 22:54:01 +0000889 * \brief DEPRECATED: Enable precompiled preambles in C++.
Douglas Gregor99ba2022010-10-27 17:24:53 +0000890 *
891 * Note: this is a *temporary* option that is available only while
Douglas Gregorb5af8432011-08-25 22:54:01 +0000892 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregor99ba2022010-10-27 17:24:53 +0000893 */
894 CXTranslationUnit_CXXPrecompiledPreamble = 0x10,
895
896 /**
Douglas Gregorb5af8432011-08-25 22:54:01 +0000897 * \brief DEPRECATED: Enabled chained precompiled preambles in C++.
Douglas Gregor99ba2022010-10-27 17:24:53 +0000898 *
899 * Note: this is a *temporary* option that is available only while
Douglas Gregorb5af8432011-08-25 22:54:01 +0000900 * we are testing C++ precompiled preamble support. It is deprecated.
Douglas Gregor99ba2022010-10-27 17:24:53 +0000901 */
Douglas Gregordca8ee82011-05-06 16:33:08 +0000902 CXTranslationUnit_CXXChainedPCH = 0x20,
903
904 /**
905 * \brief Used to indicate that the "detailed" preprocessing record,
Chandler Carruthfd14e912011-07-14 16:08:00 +0000906 * if requested, should also contain nested macro expansions.
Douglas Gregordca8ee82011-05-06 16:33:08 +0000907 *
Chandler Carruthfd14e912011-07-14 16:08:00 +0000908 * Nested macro expansions (i.e., macro expansions that occur
909 * inside another macro expansion) can, in some code bases, require
Douglas Gregordca8ee82011-05-06 16:33:08 +0000910 * a large amount of storage to due preprocessor metaprogramming. Moreover,
911 * its fairly rare that this information is useful for libclang clients.
912 */
Chandler Carruthba7537f2011-07-14 09:02:10 +0000913 CXTranslationUnit_NestedMacroExpansions = 0x40,
914
915 /**
916 * \brief Legacy name to indicate that the "detailed" preprocessing record,
Chandler Carruthfd14e912011-07-14 16:08:00 +0000917 * if requested, should contain nested macro expansions.
Chandler Carruthba7537f2011-07-14 09:02:10 +0000918 *
919 * \see CXTranslationUnit_NestedMacroExpansions for the current name for this
920 * value, and its semantics. This is just an alias.
921 */
922 CXTranslationUnit_NestedMacroInstantiations =
923 CXTranslationUnit_NestedMacroExpansions
Douglas Gregor5a430212010-07-21 18:52:53 +0000924};
925
926/**
Douglas Gregorb1c031b2010-08-09 22:28:58 +0000927 * \brief Returns the set of flags that is suitable for parsing a translation
928 * unit that is being edited.
929 *
930 * The set of flags returned provide options for \c clang_parseTranslationUnit()
931 * to indicate that the translation unit is likely to be reparsed many times,
932 * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
933 * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
934 * set contains an unspecified set of optimizations (e.g., the precompiled
935 * preamble) geared toward improving the performance of these routines. The
936 * set of optimizations enabled may change from one version to the next.
937 */
Douglas Gregore1e13bf2010-08-11 15:58:42 +0000938CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
Douglas Gregorb1c031b2010-08-09 22:28:58 +0000939
940/**
Douglas Gregor5a430212010-07-21 18:52:53 +0000941 * \brief Parse the given source file and the translation unit corresponding
942 * to that file.
943 *
944 * This routine is the main entry point for the Clang C API, providing the
945 * ability to parse a source file into a translation unit that can then be
946 * queried by other functions in the API. This routine accepts a set of
947 * command-line arguments so that the compilation can be configured in the same
948 * way that the compiler is configured on the command line.
949 *
950 * \param CIdx The index object with which the translation unit will be
951 * associated.
952 *
953 * \param source_filename The name of the source file to load, or NULL if the
Ted Kremenek1ddb02c2010-11-08 04:28:51 +0000954 * source file is included in \p command_line_args.
Douglas Gregor5a430212010-07-21 18:52:53 +0000955 *
956 * \param command_line_args The command-line arguments that would be
957 * passed to the \c clang executable if it were being invoked out-of-process.
958 * These command-line options will be parsed and will affect how the translation
959 * unit is parsed. Note that the following options are ignored: '-c',
960 * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
961 *
962 * \param num_command_line_args The number of command-line arguments in
963 * \p command_line_args.
964 *
965 * \param unsaved_files the files that have not yet been saved to disk
Douglas Gregor1abc6bc2010-08-04 16:47:14 +0000966 * but may be required for parsing, including the contents of
Douglas Gregor5a430212010-07-21 18:52:53 +0000967 * those files. The contents and name of these files (as specified by
968 * CXUnsavedFile) are copied when necessary, so the client only needs to
969 * guarantee their validity until the call to this function returns.
970 *
971 * \param num_unsaved_files the number of unsaved file entries in \p
972 * unsaved_files.
973 *
974 * \param options A bitmask of options that affects how the translation unit
975 * is managed but not its compilation. This should be a bitwise OR of the
976 * CXTranslationUnit_XXX flags.
977 *
978 * \returns A new translation unit describing the parsed code and containing
979 * any diagnostics produced by the compiler. If there is a failure from which
980 * the compiler cannot recover, returns NULL.
981 */
982CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
983 const char *source_filename,
Douglas Gregor2ef69442010-09-01 16:43:19 +0000984 const char * const *command_line_args,
Douglas Gregor5a430212010-07-21 18:52:53 +0000985 int num_command_line_args,
986 struct CXUnsavedFile *unsaved_files,
987 unsigned num_unsaved_files,
988 unsigned options);
989
Douglas Gregor5352ac02010-01-28 00:27:43 +0000990/**
Douglas Gregor19998442010-08-13 15:35:05 +0000991 * \brief Flags that control how translation units are saved.
992 *
993 * The enumerators in this enumeration type are meant to be bitwise
994 * ORed together to specify which options should be used when
995 * saving the translation unit.
996 */
997enum CXSaveTranslationUnit_Flags {
998 /**
999 * \brief Used to indicate that no special saving options are needed.
1000 */
1001 CXSaveTranslationUnit_None = 0x0
1002};
1003
1004/**
1005 * \brief Returns the set of flags that is suitable for saving a translation
1006 * unit.
1007 *
1008 * The set of flags returned provide options for
1009 * \c clang_saveTranslationUnit() by default. The returned flag
1010 * set contains an unspecified set of options that save translation units with
1011 * the most commonly-requested data.
1012 */
1013CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1014
1015/**
Douglas Gregor39c411f2011-07-06 16:43:36 +00001016 * \brief Describes the kind of error that occurred (if any) in a call to
1017 * \c clang_saveTranslationUnit().
1018 */
1019enum CXSaveError {
1020 /**
1021 * \brief Indicates that no error occurred while saving a translation unit.
1022 */
1023 CXSaveError_None = 0,
1024
1025 /**
1026 * \brief Indicates that an unknown error occurred while attempting to save
1027 * the file.
1028 *
1029 * This error typically indicates that file I/O failed when attempting to
1030 * write the file.
1031 */
1032 CXSaveError_Unknown = 1,
1033
1034 /**
1035 * \brief Indicates that errors during translation prevented this attempt
1036 * to save the translation unit.
1037 *
1038 * Errors that prevent the translation unit from being saved can be
1039 * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1040 */
1041 CXSaveError_TranslationErrors = 2,
1042
1043 /**
1044 * \brief Indicates that the translation unit to be saved was somehow
1045 * invalid (e.g., NULL).
1046 */
1047 CXSaveError_InvalidTU = 3
1048};
1049
1050/**
Douglas Gregor7ae2faa2010-08-13 05:36:37 +00001051 * \brief Saves a translation unit into a serialized representation of
1052 * that translation unit on disk.
1053 *
1054 * Any translation unit that was parsed without error can be saved
1055 * into a file. The translation unit can then be deserialized into a
1056 * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1057 * if it is an incomplete translation unit that corresponds to a
1058 * header, used as a precompiled header when parsing other translation
1059 * units.
1060 *
1061 * \param TU The translation unit to save.
Douglas Gregor19998442010-08-13 15:35:05 +00001062 *
Douglas Gregor7ae2faa2010-08-13 05:36:37 +00001063 * \param FileName The file to which the translation unit will be saved.
1064 *
Douglas Gregor19998442010-08-13 15:35:05 +00001065 * \param options A bitmask of options that affects how the translation unit
1066 * is saved. This should be a bitwise OR of the
1067 * CXSaveTranslationUnit_XXX flags.
1068 *
Douglas Gregor39c411f2011-07-06 16:43:36 +00001069 * \returns A value that will match one of the enumerators of the CXSaveError
1070 * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1071 * saved successfully, while a non-zero value indicates that a problem occurred.
Douglas Gregor7ae2faa2010-08-13 05:36:37 +00001072 */
1073CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
Douglas Gregor19998442010-08-13 15:35:05 +00001074 const char *FileName,
1075 unsigned options);
Douglas Gregor7ae2faa2010-08-13 05:36:37 +00001076
1077/**
Douglas Gregor5352ac02010-01-28 00:27:43 +00001078 * \brief Destroy the specified CXTranslationUnit object.
1079 */
1080CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
Ted Kremenek896b70f2010-03-13 02:50:34 +00001081
Douglas Gregor5352ac02010-01-28 00:27:43 +00001082/**
Douglas Gregore1e13bf2010-08-11 15:58:42 +00001083 * \brief Flags that control the reparsing of translation units.
1084 *
1085 * The enumerators in this enumeration type are meant to be bitwise
1086 * ORed together to specify which options should be used when
1087 * reparsing the translation unit.
1088 */
1089enum CXReparse_Flags {
1090 /**
1091 * \brief Used to indicate that no special reparsing options are needed.
1092 */
1093 CXReparse_None = 0x0
1094};
1095
1096/**
1097 * \brief Returns the set of flags that is suitable for reparsing a translation
1098 * unit.
1099 *
1100 * The set of flags returned provide options for
1101 * \c clang_reparseTranslationUnit() by default. The returned flag
1102 * set contains an unspecified set of optimizations geared toward common uses
1103 * of reparsing. The set of optimizations enabled may change from one version
1104 * to the next.
1105 */
1106CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1107
1108/**
Douglas Gregorabc563f2010-07-19 21:46:24 +00001109 * \brief Reparse the source files that produced this translation unit.
1110 *
1111 * This routine can be used to re-parse the source files that originally
1112 * created the given translation unit, for example because those source files
1113 * have changed (either on disk or as passed via \p unsaved_files). The
1114 * source code will be reparsed with the same command-line options as it
1115 * was originally parsed.
1116 *
1117 * Reparsing a translation unit invalidates all cursors and source locations
1118 * that refer into that translation unit. This makes reparsing a translation
1119 * unit semantically equivalent to destroying the translation unit and then
1120 * creating a new translation unit with the same command-line arguments.
1121 * However, it may be more efficient to reparse a translation
1122 * unit using this routine.
1123 *
1124 * \param TU The translation unit whose contents will be re-parsed. The
1125 * translation unit must originally have been built with
1126 * \c clang_createTranslationUnitFromSourceFile().
1127 *
1128 * \param num_unsaved_files The number of unsaved file entries in \p
1129 * unsaved_files.
1130 *
1131 * \param unsaved_files The files that have not yet been saved to disk
1132 * but may be required for parsing, including the contents of
1133 * those files. The contents and name of these files (as specified by
1134 * CXUnsavedFile) are copied when necessary, so the client only needs to
1135 * guarantee their validity until the call to this function returns.
1136 *
Douglas Gregore1e13bf2010-08-11 15:58:42 +00001137 * \param options A bitset of options composed of the flags in CXReparse_Flags.
1138 * The function \c clang_defaultReparseOptions() produces a default set of
1139 * options recommended for most uses, based on the translation unit.
1140 *
Douglas Gregorabc563f2010-07-19 21:46:24 +00001141 * \returns 0 if the sources could be reparsed. A non-zero value will be
1142 * returned if reparsing was impossible, such that the translation unit is
1143 * invalid. In such cases, the only valid call for \p TU is
1144 * \c clang_disposeTranslationUnit(TU).
1145 */
1146CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1147 unsigned num_unsaved_files,
Douglas Gregore1e13bf2010-08-11 15:58:42 +00001148 struct CXUnsavedFile *unsaved_files,
1149 unsigned options);
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001150
1151/**
1152 * \brief Categorizes how memory is being used by a translation unit.
1153 */
Ted Kremenekf7870022011-04-20 16:41:07 +00001154enum CXTUResourceUsageKind {
1155 CXTUResourceUsage_AST = 1,
1156 CXTUResourceUsage_Identifiers = 2,
1157 CXTUResourceUsage_Selectors = 3,
1158 CXTUResourceUsage_GlobalCompletionResults = 4,
Ted Kremenek457aaf02011-04-28 04:10:31 +00001159 CXTUResourceUsage_SourceManagerContentCache = 5,
Ted Kremenekba29bd22011-04-28 04:53:38 +00001160 CXTUResourceUsage_AST_SideTables = 6,
Ted Kremenekf61b8312011-04-28 20:36:42 +00001161 CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
Ted Kremeneke9b5f3d2011-04-28 23:46:20 +00001162 CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1163 CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1164 CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
Ted Kremenek5e1db6a2011-05-04 01:38:46 +00001165 CXTUResourceUsage_Preprocessor = 11,
1166 CXTUResourceUsage_PreprocessingRecord = 12,
Ted Kremenekca7dc2b2011-07-26 23:46:06 +00001167 CXTUResourceUsage_SourceManager_DataStructures = 13,
Ted Kremenekd1194fb2011-07-26 23:46:11 +00001168 CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
Ted Kremenekf7870022011-04-20 16:41:07 +00001169 CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1170 CXTUResourceUsage_MEMORY_IN_BYTES_END =
Ted Kremenekd1194fb2011-07-26 23:46:11 +00001171 CXTUResourceUsage_Preprocessor_HeaderSearch,
Ted Kremenekf7870022011-04-20 16:41:07 +00001172
1173 CXTUResourceUsage_First = CXTUResourceUsage_AST,
Ted Kremenekd1194fb2011-07-26 23:46:11 +00001174 CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001175};
1176
1177/**
1178 * \brief Returns the human-readable null-terminated C string that represents
Ted Kremenekf7870022011-04-20 16:41:07 +00001179 * the name of the memory category. This string should never be freed.
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001180 */
1181CINDEX_LINKAGE
Ted Kremenekf7870022011-04-20 16:41:07 +00001182const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001183
Ted Kremenekf7870022011-04-20 16:41:07 +00001184typedef struct CXTUResourceUsageEntry {
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001185 /* \brief The memory usage category. */
Ted Kremenekf7870022011-04-20 16:41:07 +00001186 enum CXTUResourceUsageKind kind;
1187 /* \brief Amount of resources used.
1188 The units will depend on the resource kind. */
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001189 unsigned long amount;
Ted Kremenekf7870022011-04-20 16:41:07 +00001190} CXTUResourceUsageEntry;
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001191
1192/**
1193 * \brief The memory usage of a CXTranslationUnit, broken into categories.
1194 */
Ted Kremenekf7870022011-04-20 16:41:07 +00001195typedef struct CXTUResourceUsage {
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001196 /* \brief Private data member, used for queries. */
1197 void *data;
1198
1199 /* \brief The number of entries in the 'entries' array. */
1200 unsigned numEntries;
1201
1202 /* \brief An array of key-value pairs, representing the breakdown of memory
1203 usage. */
Ted Kremenekf7870022011-04-20 16:41:07 +00001204 CXTUResourceUsageEntry *entries;
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001205
Ted Kremenekf7870022011-04-20 16:41:07 +00001206} CXTUResourceUsage;
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001207
1208/**
1209 * \brief Return the memory usage of a translation unit. This object
Ted Kremenekf7870022011-04-20 16:41:07 +00001210 * should be released with clang_disposeCXTUResourceUsage().
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001211 */
Ted Kremenekf7870022011-04-20 16:41:07 +00001212CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001213
Ted Kremenekf7870022011-04-20 16:41:07 +00001214CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
Ted Kremenek59fc1e52011-04-18 22:47:10 +00001215
Douglas Gregorabc563f2010-07-19 21:46:24 +00001216/**
Douglas Gregor5352ac02010-01-28 00:27:43 +00001217 * @}
1218 */
Ted Kremenek896b70f2010-03-13 02:50:34 +00001219
Douglas Gregor5352ac02010-01-28 00:27:43 +00001220/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001221 * \brief Describes the kind of entity that a cursor refers to.
1222 */
1223enum CXCursorKind {
1224 /* Declarations */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001225 /**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001226 * \brief A declaration whose specific kind is not exposed via this
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001227 * interface.
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001228 *
1229 * Unexposed declarations have the same operations as any other kind
1230 * of declaration; one can extract their location information,
1231 * spelling, find their definitions, etc. However, the specific kind
1232 * of the declaration is not reported.
1233 */
1234 CXCursor_UnexposedDecl = 1,
1235 /** \brief A C or C++ struct. */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001236 CXCursor_StructDecl = 2,
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001237 /** \brief A C or C++ union. */
1238 CXCursor_UnionDecl = 3,
1239 /** \brief A C++ class. */
1240 CXCursor_ClassDecl = 4,
1241 /** \brief An enumeration. */
1242 CXCursor_EnumDecl = 5,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001243 /**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001244 * \brief A field (in C) or non-static data member (in C++) in a
1245 * struct, union, or C++ class.
1246 */
1247 CXCursor_FieldDecl = 6,
1248 /** \brief An enumerator constant. */
1249 CXCursor_EnumConstantDecl = 7,
1250 /** \brief A function. */
1251 CXCursor_FunctionDecl = 8,
1252 /** \brief A variable. */
1253 CXCursor_VarDecl = 9,
1254 /** \brief A function or method parameter. */
1255 CXCursor_ParmDecl = 10,
1256 /** \brief An Objective-C @interface. */
1257 CXCursor_ObjCInterfaceDecl = 11,
1258 /** \brief An Objective-C @interface for a category. */
1259 CXCursor_ObjCCategoryDecl = 12,
1260 /** \brief An Objective-C @protocol declaration. */
1261 CXCursor_ObjCProtocolDecl = 13,
1262 /** \brief An Objective-C @property declaration. */
1263 CXCursor_ObjCPropertyDecl = 14,
1264 /** \brief An Objective-C instance variable. */
1265 CXCursor_ObjCIvarDecl = 15,
1266 /** \brief An Objective-C instance method. */
1267 CXCursor_ObjCInstanceMethodDecl = 16,
1268 /** \brief An Objective-C class method. */
1269 CXCursor_ObjCClassMethodDecl = 17,
1270 /** \brief An Objective-C @implementation. */
1271 CXCursor_ObjCImplementationDecl = 18,
1272 /** \brief An Objective-C @implementation for a category. */
1273 CXCursor_ObjCCategoryImplDecl = 19,
1274 /** \brief A typedef */
1275 CXCursor_TypedefDecl = 20,
Ted Kremenek8bd5a692010-04-13 23:39:06 +00001276 /** \brief A C++ class method. */
1277 CXCursor_CXXMethod = 21,
Ted Kremenek8f06e0e2010-05-06 23:38:21 +00001278 /** \brief A C++ namespace. */
1279 CXCursor_Namespace = 22,
Ted Kremeneka0536d82010-05-07 01:04:29 +00001280 /** \brief A linkage specification, e.g. 'extern "C"'. */
1281 CXCursor_LinkageSpec = 23,
Douglas Gregor01829d32010-08-31 14:41:23 +00001282 /** \brief A C++ constructor. */
1283 CXCursor_Constructor = 24,
1284 /** \brief A C++ destructor. */
1285 CXCursor_Destructor = 25,
1286 /** \brief A C++ conversion function. */
1287 CXCursor_ConversionFunction = 26,
Douglas Gregorfe72e9c2010-08-31 17:01:39 +00001288 /** \brief A C++ template type parameter. */
1289 CXCursor_TemplateTypeParameter = 27,
1290 /** \brief A C++ non-type template parameter. */
1291 CXCursor_NonTypeTemplateParameter = 28,
1292 /** \brief A C++ template template parameter. */
1293 CXCursor_TemplateTemplateParameter = 29,
1294 /** \brief A C++ function template. */
1295 CXCursor_FunctionTemplate = 30,
Douglas Gregor39d6f072010-08-31 19:02:00 +00001296 /** \brief A C++ class template. */
1297 CXCursor_ClassTemplate = 31,
Douglas Gregor74dbe642010-08-31 19:31:58 +00001298 /** \brief A C++ class template partial specialization. */
1299 CXCursor_ClassTemplatePartialSpecialization = 32,
Douglas Gregor69319002010-08-31 23:48:11 +00001300 /** \brief A C++ namespace alias declaration. */
1301 CXCursor_NamespaceAlias = 33,
Douglas Gregor0a35bce2010-09-01 03:07:18 +00001302 /** \brief A C++ using directive. */
1303 CXCursor_UsingDirective = 34,
Richard Smith162e1c12011-04-15 14:24:37 +00001304 /** \brief A C++ using declaration. */
Douglas Gregor7e242562010-09-01 19:52:22 +00001305 CXCursor_UsingDeclaration = 35,
Richard Smith162e1c12011-04-15 14:24:37 +00001306 /** \brief A C++ alias declaration */
1307 CXCursor_TypeAliasDecl = 36,
Douglas Gregor352697a2011-06-03 23:08:58 +00001308 /** \brief An Objective-C @synthesize definition. */
1309 CXCursor_ObjCSynthesizeDecl = 37,
1310 /** \brief An Objective-C @dynamic definition. */
1311 CXCursor_ObjCDynamicDecl = 38,
Argyrios Kyrtzidis2dfdb942011-09-30 17:58:23 +00001312 /** \brief An access specifier. */
1313 CXCursor_CXXAccessSpecifier = 39,
Ted Kremenek50aa6ac2010-05-19 21:51:10 +00001314 CXCursor_FirstDecl = CXCursor_UnexposedDecl,
Argyrios Kyrtzidis2dfdb942011-09-30 17:58:23 +00001315 CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001316
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001317 /* References */
1318 CXCursor_FirstRef = 40, /* Decl references */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001319 CXCursor_ObjCSuperClassRef = 40,
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001320 CXCursor_ObjCProtocolRef = 41,
1321 CXCursor_ObjCClassRef = 42,
1322 /**
1323 * \brief A reference to a type declaration.
1324 *
1325 * A type reference occurs anywhere where a type is named but not
1326 * declared. For example, given:
1327 *
1328 * \code
1329 * typedef unsigned size_type;
1330 * size_type size;
1331 * \endcode
1332 *
1333 * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1334 * while the type of the variable "size" is referenced. The cursor
1335 * referenced by the type of size is the typedef for size_type.
1336 */
1337 CXCursor_TypeRef = 43,
Ted Kremenek3064ef92010-08-27 21:34:58 +00001338 CXCursor_CXXBaseSpecifier = 44,
Douglas Gregor0b36e612010-08-31 20:37:03 +00001339 /**
Douglas Gregora67e03f2010-09-09 21:42:20 +00001340 * \brief A reference to a class template, function template, template
1341 * template parameter, or class template partial specialization.
Douglas Gregor0b36e612010-08-31 20:37:03 +00001342 */
1343 CXCursor_TemplateRef = 45,
Douglas Gregor69319002010-08-31 23:48:11 +00001344 /**
1345 * \brief A reference to a namespace or namespace alias.
1346 */
1347 CXCursor_NamespaceRef = 46,
Douglas Gregora67e03f2010-09-09 21:42:20 +00001348 /**
Douglas Gregor36897b02010-09-10 00:22:18 +00001349 * \brief A reference to a member of a struct, union, or class that occurs in
1350 * some non-expression context, e.g., a designated initializer.
Douglas Gregora67e03f2010-09-09 21:42:20 +00001351 */
1352 CXCursor_MemberRef = 47,
Douglas Gregor36897b02010-09-10 00:22:18 +00001353 /**
1354 * \brief A reference to a labeled statement.
1355 *
1356 * This cursor kind is used to describe the jump to "start_over" in the
1357 * goto statement in the following example:
1358 *
1359 * \code
1360 * start_over:
1361 * ++counter;
1362 *
1363 * goto start_over;
1364 * \endcode
1365 *
1366 * A label reference cursor refers to a label statement.
1367 */
1368 CXCursor_LabelRef = 48,
1369
Douglas Gregor1f60d9e2010-09-13 22:52:57 +00001370 /**
1371 * \brief A reference to a set of overloaded functions or function templates
1372 * that has not yet been resolved to a specific function or function template.
1373 *
1374 * An overloaded declaration reference cursor occurs in C++ templates where
1375 * a dependent name refers to a function. For example:
1376 *
1377 * \code
1378 * template<typename T> void swap(T&, T&);
1379 *
1380 * struct X { ... };
1381 * void swap(X&, X&);
1382 *
1383 * template<typename T>
1384 * void reverse(T* first, T* last) {
1385 * while (first < last - 1) {
1386 * swap(*first, *--last);
1387 * ++first;
1388 * }
1389 * }
1390 *
1391 * struct Y { };
1392 * void swap(Y&, Y&);
1393 * \endcode
1394 *
1395 * Here, the identifier "swap" is associated with an overloaded declaration
1396 * reference. In the template definition, "swap" refers to either of the two
1397 * "swap" functions declared above, so both results will be available. At
1398 * instantiation time, "swap" may also refer to other functions found via
1399 * argument-dependent lookup (e.g., the "swap" function at the end of the
1400 * example).
1401 *
1402 * The functions \c clang_getNumOverloadedDecls() and
1403 * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1404 * referenced by this cursor.
1405 */
1406 CXCursor_OverloadedDeclRef = 49,
1407
1408 CXCursor_LastRef = CXCursor_OverloadedDeclRef,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001409
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001410 /* Error conditions */
1411 CXCursor_FirstInvalid = 70,
1412 CXCursor_InvalidFile = 70,
1413 CXCursor_NoDeclFound = 71,
1414 CXCursor_NotImplemented = 72,
Ted Kremenekebfa3392010-03-19 20:39:03 +00001415 CXCursor_InvalidCode = 73,
1416 CXCursor_LastInvalid = CXCursor_InvalidCode,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001417
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001418 /* Expressions */
1419 CXCursor_FirstExpr = 100,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001420
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001421 /**
1422 * \brief An expression whose specific kind is not exposed via this
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001423 * interface.
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001424 *
1425 * Unexposed expressions have the same operations as any other kind
1426 * of expression; one can extract their location information,
1427 * spelling, children, etc. However, the specific kind of the
1428 * expression is not reported.
1429 */
1430 CXCursor_UnexposedExpr = 100,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001431
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001432 /**
1433 * \brief An expression that refers to some value declaration, such
1434 * as a function, varible, or enumerator.
1435 */
1436 CXCursor_DeclRefExpr = 101,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001437
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001438 /**
1439 * \brief An expression that refers to a member of a struct, union,
1440 * class, Objective-C class, etc.
1441 */
1442 CXCursor_MemberRefExpr = 102,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001443
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001444 /** \brief An expression that calls a function. */
1445 CXCursor_CallExpr = 103,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001446
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001447 /** \brief An expression that sends a message to an Objective-C
1448 object or class. */
1449 CXCursor_ObjCMessageExpr = 104,
Ted Kremenek1ee6cad2010-04-11 21:47:37 +00001450
1451 /** \brief An expression that represents a block literal. */
1452 CXCursor_BlockExpr = 105,
1453
1454 CXCursor_LastExpr = 105,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001455
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001456 /* Statements */
1457 CXCursor_FirstStmt = 200,
1458 /**
1459 * \brief A statement whose specific kind is not exposed via this
1460 * interface.
1461 *
1462 * Unexposed statements have the same operations as any other kind of
1463 * statement; one can extract their location information, spelling,
1464 * children, etc. However, the specific kind of the statement is not
1465 * reported.
1466 */
1467 CXCursor_UnexposedStmt = 200,
Douglas Gregor36897b02010-09-10 00:22:18 +00001468
1469 /** \brief A labelled statement in a function.
1470 *
1471 * This cursor kind is used to describe the "start_over:" label statement in
1472 * the following example:
1473 *
1474 * \code
1475 * start_over:
1476 * ++counter;
1477 * \endcode
1478 *
1479 */
1480 CXCursor_LabelStmt = 201,
1481
1482 CXCursor_LastStmt = CXCursor_LabelStmt,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001483
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001484 /**
1485 * \brief Cursor that represents the translation unit itself.
1486 *
1487 * The translation unit cursor exists primarily to act as the root
1488 * cursor for traversing the contents of a translation unit.
1489 */
Ted Kremeneke77f4432010-02-18 03:09:07 +00001490 CXCursor_TranslationUnit = 300,
1491
1492 /* Attributes */
1493 CXCursor_FirstAttr = 400,
1494 /**
1495 * \brief An attribute whose specific kind is not exposed via this
1496 * interface.
1497 */
1498 CXCursor_UnexposedAttr = 400,
1499
1500 CXCursor_IBActionAttr = 401,
1501 CXCursor_IBOutletAttr = 402,
Ted Kremenek857e9182010-05-19 17:38:06 +00001502 CXCursor_IBOutletCollectionAttr = 403,
Argyrios Kyrtzidis6639e922011-09-13 17:39:31 +00001503 CXCursor_CXXFinalAttr = 404,
1504 CXCursor_CXXOverrideAttr = 405,
1505 CXCursor_LastAttr = CXCursor_CXXOverrideAttr,
Douglas Gregor9f1e3ff2010-03-18 00:42:48 +00001506
1507 /* Preprocessing */
1508 CXCursor_PreprocessingDirective = 500,
Douglas Gregor572feb22010-03-18 18:04:21 +00001509 CXCursor_MacroDefinition = 501,
Chandler Carruth9b2a0ac2011-07-14 08:41:15 +00001510 CXCursor_MacroExpansion = 502,
1511 CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
Douglas Gregorecdcb882010-10-20 22:00:55 +00001512 CXCursor_InclusionDirective = 503,
Douglas Gregor9f1e3ff2010-03-18 00:42:48 +00001513 CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
Douglas Gregorecdcb882010-10-20 22:00:55 +00001514 CXCursor_LastPreprocessing = CXCursor_InclusionDirective
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001515};
1516
1517/**
1518 * \brief A cursor representing some element in the abstract syntax tree for
1519 * a translation unit.
1520 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001521 * The cursor abstraction unifies the different kinds of entities in a
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001522 * program--declaration, statements, expressions, references to declarations,
1523 * etc.--under a single "cursor" abstraction with a common set of operations.
1524 * Common operation for a cursor include: getting the physical location in
1525 * a source file where the cursor points, getting the name associated with a
1526 * cursor, and retrieving cursors for any child nodes of a particular cursor.
1527 *
1528 * Cursors can be produced in two specific ways.
1529 * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
1530 * from which one can use clang_visitChildren() to explore the rest of the
1531 * translation unit. clang_getCursor() maps from a physical source location
1532 * to the entity that resides at that location, allowing one to map from the
1533 * source code into the AST.
1534 */
1535typedef struct {
1536 enum CXCursorKind kind;
1537 void *data[3];
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001538} CXCursor;
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001539
1540/**
1541 * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
1542 *
1543 * @{
1544 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001545
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001546/**
1547 * \brief Retrieve the NULL cursor, which represents no entity.
1548 */
1549CINDEX_LINKAGE CXCursor clang_getNullCursor(void);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001550
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001551/**
1552 * \brief Retrieve the cursor that represents the given translation unit.
1553 *
1554 * The translation unit cursor can be used to start traversing the
1555 * various declarations within the given translation unit.
1556 */
1557CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
1558
1559/**
1560 * \brief Determine whether two cursors are equivalent.
1561 */
1562CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001563
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001564/**
Argyrios Kyrtzidisb0d6eaa2011-09-27 00:30:30 +00001565 * \brief Returns non-zero if \arg cursor is null.
1566 */
Argyrios Kyrtzidisfa865df2011-09-27 04:14:36 +00001567int clang_Cursor_isNull(CXCursor);
Argyrios Kyrtzidisb0d6eaa2011-09-27 00:30:30 +00001568
1569/**
Douglas Gregor9ce55842010-11-20 00:09:34 +00001570 * \brief Compute a hash value for the given cursor.
1571 */
1572CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
1573
1574/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001575 * \brief Retrieve the kind of the given cursor.
1576 */
1577CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
1578
1579/**
1580 * \brief Determine whether the given cursor kind represents a declaration.
1581 */
1582CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
1583
1584/**
1585 * \brief Determine whether the given cursor kind represents a simple
1586 * reference.
1587 *
1588 * Note that other kinds of cursors (such as expressions) can also refer to
1589 * other cursors. Use clang_getCursorReferenced() to determine whether a
1590 * particular cursor refers to another entity.
1591 */
1592CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
1593
1594/**
1595 * \brief Determine whether the given cursor kind represents an expression.
1596 */
1597CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
1598
1599/**
1600 * \brief Determine whether the given cursor kind represents a statement.
1601 */
1602CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
1603
1604/**
Douglas Gregor8be80e12011-07-06 03:00:34 +00001605 * \brief Determine whether the given cursor kind represents an attribute.
1606 */
1607CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
1608
1609/**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001610 * \brief Determine whether the given cursor kind represents an invalid
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001611 * cursor.
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001612 */
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001613CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
1614
1615/**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001616 * \brief Determine whether the given cursor kind represents a translation
1617 * unit.
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001618 */
1619CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001620
Ted Kremenekad6eff62010-03-08 21:17:29 +00001621/***
Douglas Gregor9f1e3ff2010-03-18 00:42:48 +00001622 * \brief Determine whether the given cursor represents a preprocessing
1623 * element, such as a preprocessor directive or macro instantiation.
1624 */
1625CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
1626
1627/***
Ted Kremenekad6eff62010-03-08 21:17:29 +00001628 * \brief Determine whether the given cursor represents a currently
1629 * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
1630 */
1631CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
1632
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001633/**
Ted Kremenek16b42592010-03-03 06:36:57 +00001634 * \brief Describe the linkage of the entity referred to by a cursor.
1635 */
1636enum CXLinkageKind {
1637 /** \brief This value indicates that no linkage information is available
1638 * for a provided CXCursor. */
1639 CXLinkage_Invalid,
1640 /**
1641 * \brief This is the linkage for variables, parameters, and so on that
1642 * have automatic storage. This covers normal (non-extern) local variables.
1643 */
1644 CXLinkage_NoLinkage,
1645 /** \brief This is the linkage for static variables and static functions. */
1646 CXLinkage_Internal,
1647 /** \brief This is the linkage for entities with external linkage that live
1648 * in C++ anonymous namespaces.*/
1649 CXLinkage_UniqueExternal,
1650 /** \brief This is the linkage for entities with true, external linkage. */
1651 CXLinkage_External
1652};
1653
1654/**
Ted Kremenek45e1dae2010-04-12 21:22:16 +00001655 * \brief Determine the linkage of the entity referred to by a given cursor.
Ted Kremenek16b42592010-03-03 06:36:57 +00001656 */
1657CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
1658
1659/**
Douglas Gregor58ddb602010-08-23 23:00:57 +00001660 * \brief Determine the availability of the entity that this cursor refers to.
1661 *
1662 * \param cursor The cursor to query.
1663 *
1664 * \returns The availability of the cursor.
1665 */
1666CINDEX_LINKAGE enum CXAvailabilityKind
1667clang_getCursorAvailability(CXCursor cursor);
1668
1669/**
Ted Kremenek45e1dae2010-04-12 21:22:16 +00001670 * \brief Describe the "language" of the entity referred to by a cursor.
1671 */
1672CINDEX_LINKAGE enum CXLanguageKind {
Ted Kremenek6cd1e7c2010-04-14 20:58:32 +00001673 CXLanguage_Invalid = 0,
Ted Kremenek45e1dae2010-04-12 21:22:16 +00001674 CXLanguage_C,
1675 CXLanguage_ObjC,
Ted Kremenek6cd1e7c2010-04-14 20:58:32 +00001676 CXLanguage_CPlusPlus
Ted Kremenek45e1dae2010-04-12 21:22:16 +00001677};
1678
1679/**
1680 * \brief Determine the "language" of the entity referred to by a given cursor.
1681 */
1682CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
1683
Argyrios Kyrtzidisb0d6eaa2011-09-27 00:30:30 +00001684/**
1685 * \brief Returns the translation unit that a cursor originated from.
1686 */
1687CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
1688
Ted Kremenekeca099b2010-12-08 23:43:14 +00001689
1690/**
1691 * \brief A fast container representing a set of CXCursors.
1692 */
1693typedef struct CXCursorSetImpl *CXCursorSet;
1694
1695/**
1696 * \brief Creates an empty CXCursorSet.
1697 */
1698CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet();
1699
1700/**
1701 * \brief Disposes a CXCursorSet and releases its associated memory.
1702 */
1703CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
1704
1705/**
1706 * \brief Queries a CXCursorSet to see if it contains a specific CXCursor.
1707 *
1708 * \returns non-zero if the set contains the specified cursor.
1709*/
1710CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
1711 CXCursor cursor);
1712
1713/**
1714 * \brief Inserts a CXCursor into a CXCursorSet.
1715 *
1716 * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
1717*/
1718CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
1719 CXCursor cursor);
1720
Douglas Gregor2be5bc92010-09-22 21:22:29 +00001721/**
1722 * \brief Determine the semantic parent of the given cursor.
1723 *
1724 * The semantic parent of a cursor is the cursor that semantically contains
1725 * the given \p cursor. For many declarations, the lexical and semantic parents
1726 * are equivalent (the lexical parent is returned by
1727 * \c clang_getCursorLexicalParent()). They diverge when declarations or
1728 * definitions are provided out-of-line. For example:
1729 *
1730 * \code
1731 * class C {
1732 * void f();
1733 * };
1734 *
1735 * void C::f() { }
1736 * \endcode
1737 *
1738 * In the out-of-line definition of \c C::f, the semantic parent is the
1739 * the class \c C, of which this function is a member. The lexical parent is
1740 * the place where the declaration actually occurs in the source code; in this
1741 * case, the definition occurs in the translation unit. In general, the
1742 * lexical parent for a given entity can change without affecting the semantics
1743 * of the program, and the lexical parent of different declarations of the
1744 * same entity may be different. Changing the semantic parent of a declaration,
1745 * on the other hand, can have a major impact on semantics, and redeclarations
1746 * of a particular entity should all have the same semantic context.
1747 *
1748 * In the example above, both declarations of \c C::f have \c C as their
1749 * semantic context, while the lexical context of the first \c C::f is \c C
1750 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor3910cfd2010-12-21 07:55:45 +00001751 *
1752 * For global declarations, the semantic parent is the translation unit.
Douglas Gregor2be5bc92010-09-22 21:22:29 +00001753 */
1754CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
1755
1756/**
1757 * \brief Determine the lexical parent of the given cursor.
1758 *
1759 * The lexical parent of a cursor is the cursor in which the given \p cursor
1760 * was actually written. For many declarations, the lexical and semantic parents
1761 * are equivalent (the semantic parent is returned by
1762 * \c clang_getCursorSemanticParent()). They diverge when declarations or
1763 * definitions are provided out-of-line. For example:
1764 *
1765 * \code
1766 * class C {
1767 * void f();
1768 * };
1769 *
1770 * void C::f() { }
1771 * \endcode
1772 *
1773 * In the out-of-line definition of \c C::f, the semantic parent is the
1774 * the class \c C, of which this function is a member. The lexical parent is
1775 * the place where the declaration actually occurs in the source code; in this
1776 * case, the definition occurs in the translation unit. In general, the
1777 * lexical parent for a given entity can change without affecting the semantics
1778 * of the program, and the lexical parent of different declarations of the
1779 * same entity may be different. Changing the semantic parent of a declaration,
1780 * on the other hand, can have a major impact on semantics, and redeclarations
1781 * of a particular entity should all have the same semantic context.
1782 *
1783 * In the example above, both declarations of \c C::f have \c C as their
1784 * semantic context, while the lexical context of the first \c C::f is \c C
1785 * and the lexical context of the second \c C::f is the translation unit.
Douglas Gregor3910cfd2010-12-21 07:55:45 +00001786 *
1787 * For declarations written in the global scope, the lexical parent is
1788 * the translation unit.
Douglas Gregor2be5bc92010-09-22 21:22:29 +00001789 */
1790CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
Douglas Gregor9f592342010-10-01 20:25:15 +00001791
1792/**
1793 * \brief Determine the set of methods that are overridden by the given
1794 * method.
1795 *
1796 * In both Objective-C and C++, a method (aka virtual member function,
1797 * in C++) can override a virtual method in a base class. For
1798 * Objective-C, a method is said to override any method in the class's
1799 * interface (if we're coming from an implementation), its protocols,
1800 * or its categories, that has the same selector and is of the same
1801 * kind (class or instance). If no such method exists, the search
1802 * continues to the class's superclass, its protocols, and its
1803 * categories, and so on.
1804 *
1805 * For C++, a virtual member function overrides any virtual member
1806 * function with the same signature that occurs in its base
1807 * classes. With multiple inheritance, a virtual member function can
1808 * override several virtual member functions coming from different
1809 * base classes.
1810 *
1811 * In all cases, this function determines the immediate overridden
1812 * method, rather than all of the overridden methods. For example, if
1813 * a method is originally declared in a class A, then overridden in B
1814 * (which in inherits from A) and also in C (which inherited from B),
1815 * then the only overridden method returned from this function when
1816 * invoked on C's method will be B's method. The client may then
1817 * invoke this function again, given the previously-found overridden
1818 * methods, to map out the complete method-override set.
1819 *
1820 * \param cursor A cursor representing an Objective-C or C++
1821 * method. This routine will compute the set of methods that this
1822 * method overrides.
1823 *
1824 * \param overridden A pointer whose pointee will be replaced with a
1825 * pointer to an array of cursors, representing the set of overridden
1826 * methods. If there are no overridden methods, the pointee will be
1827 * set to NULL. The pointee must be freed via a call to
1828 * \c clang_disposeOverriddenCursors().
1829 *
1830 * \param num_overridden A pointer to the number of overridden
1831 * functions, will be set to the number of overridden functions in the
1832 * array pointed to by \p overridden.
1833 */
1834CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
1835 CXCursor **overridden,
1836 unsigned *num_overridden);
1837
1838/**
1839 * \brief Free the set of overridden cursors returned by \c
1840 * clang_getOverriddenCursors().
1841 */
1842CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
1843
Ted Kremenek45e1dae2010-04-12 21:22:16 +00001844/**
Douglas Gregorecdcb882010-10-20 22:00:55 +00001845 * \brief Retrieve the file that is included by the given inclusion directive
1846 * cursor.
1847 */
1848CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
1849
1850/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001851 * @}
1852 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001853
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001854/**
1855 * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
1856 *
1857 * Cursors represent a location within the Abstract Syntax Tree (AST). These
1858 * routines help map between cursors and the physical locations where the
1859 * described entities occur in the source code. The mapping is provided in
1860 * both directions, so one can map from source code to the AST and back.
1861 *
1862 * @{
Steve Naroff50398192009-08-28 15:28:48 +00001863 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001864
Steve Naroff6a6de8b2009-10-21 13:56:23 +00001865/**
Douglas Gregorb9790342010-01-22 21:44:22 +00001866 * \brief Map a source location to the cursor that describes the entity at that
1867 * location in the source code.
1868 *
1869 * clang_getCursor() maps an arbitrary source location within a translation
1870 * unit down to the most specific cursor that describes the entity at that
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001871 * location. For example, given an expression \c x + y, invoking
Douglas Gregorb9790342010-01-22 21:44:22 +00001872 * clang_getCursor() with a source location pointing to "x" will return the
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001873 * cursor for "x"; similarly for "y". If the cursor points anywhere between
Douglas Gregorb9790342010-01-22 21:44:22 +00001874 * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
1875 * will return a cursor referring to the "+" expression.
1876 *
1877 * \returns a cursor representing the entity at the given source location, or
1878 * a NULL cursor if no such entity can be found.
Steve Naroff6a6de8b2009-10-21 13:56:23 +00001879 */
Douglas Gregorb9790342010-01-22 21:44:22 +00001880CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001881
Douglas Gregor98258af2010-01-18 22:46:11 +00001882/**
1883 * \brief Retrieve the physical location of the source constructor referenced
1884 * by the given cursor.
1885 *
1886 * The location of a declaration is typically the location of the name of that
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001887 * declaration, where the name of that declaration would occur if it is
1888 * unnamed, or some keyword that introduces that particular declaration.
1889 * The location of a reference is where that reference occurs within the
Douglas Gregor98258af2010-01-18 22:46:11 +00001890 * source code.
1891 */
1892CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001893
Douglas Gregorb6998662010-01-19 19:34:47 +00001894/**
1895 * \brief Retrieve the physical extent of the source construct referenced by
Douglas Gregora7bde202010-01-19 00:34:46 +00001896 * the given cursor.
1897 *
1898 * The extent of a cursor starts with the file/line/column pointing at the
1899 * first character within the source construct that the cursor refers to and
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00001900 * ends with the last character withinin that source construct. For a
Douglas Gregora7bde202010-01-19 00:34:46 +00001901 * declaration, the extent covers the declaration itself. For a reference,
1902 * the extent covers the location of the reference (e.g., where the referenced
1903 * entity was actually used).
1904 */
1905CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
Douglas Gregorc5d1e932010-01-19 01:20:04 +00001906
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001907/**
1908 * @}
1909 */
Ted Kremenek95f33552010-08-26 01:42:22 +00001910
Douglas Gregorc42fefa2010-01-22 22:29:16 +00001911/**
Ted Kremenek8e0ac172010-05-14 21:29:26 +00001912 * \defgroup CINDEX_TYPES Type information for CXCursors
1913 *
1914 * @{
1915 */
1916
1917/**
1918 * \brief Describes the kind of type
1919 */
1920enum CXTypeKind {
1921 /**
1922 * \brief Reprents an invalid type (e.g., where no type is available).
1923 */
1924 CXType_Invalid = 0,
1925
1926 /**
1927 * \brief A type whose specific kind is not exposed via this
1928 * interface.
1929 */
1930 CXType_Unexposed = 1,
1931
1932 /* Builtin types */
1933 CXType_Void = 2,
1934 CXType_Bool = 3,
1935 CXType_Char_U = 4,
1936 CXType_UChar = 5,
1937 CXType_Char16 = 6,
1938 CXType_Char32 = 7,
1939 CXType_UShort = 8,
1940 CXType_UInt = 9,
1941 CXType_ULong = 10,
1942 CXType_ULongLong = 11,
1943 CXType_UInt128 = 12,
1944 CXType_Char_S = 13,
1945 CXType_SChar = 14,
1946 CXType_WChar = 15,
1947 CXType_Short = 16,
1948 CXType_Int = 17,
1949 CXType_Long = 18,
1950 CXType_LongLong = 19,
1951 CXType_Int128 = 20,
1952 CXType_Float = 21,
1953 CXType_Double = 22,
1954 CXType_LongDouble = 23,
1955 CXType_NullPtr = 24,
1956 CXType_Overload = 25,
1957 CXType_Dependent = 26,
1958 CXType_ObjCId = 27,
1959 CXType_ObjCClass = 28,
1960 CXType_ObjCSel = 29,
1961 CXType_FirstBuiltin = CXType_Void,
1962 CXType_LastBuiltin = CXType_ObjCSel,
1963
1964 CXType_Complex = 100,
1965 CXType_Pointer = 101,
1966 CXType_BlockPointer = 102,
1967 CXType_LValueReference = 103,
1968 CXType_RValueReference = 104,
1969 CXType_Record = 105,
1970 CXType_Enum = 106,
1971 CXType_Typedef = 107,
1972 CXType_ObjCInterface = 108,
Ted Kremenek04c3cf32010-06-21 20:15:39 +00001973 CXType_ObjCObjectPointer = 109,
1974 CXType_FunctionNoProto = 110,
Argyrios Kyrtzidis5f0bfc52011-09-27 17:44:34 +00001975 CXType_FunctionProto = 111,
1976 CXType_ConstantArray = 112
Ted Kremenek8e0ac172010-05-14 21:29:26 +00001977};
1978
1979/**
1980 * \brief The type of an element in the abstract syntax tree.
1981 *
1982 */
1983typedef struct {
1984 enum CXTypeKind kind;
1985 void *data[2];
1986} CXType;
1987
1988/**
1989 * \brief Retrieve the type of a CXCursor (if any).
1990 */
1991CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
1992
1993/**
1994 * \determine Determine whether two CXTypes represent the same type.
1995 *
1996 * \returns non-zero if the CXTypes represent the same type and
1997 zero otherwise.
1998 */
1999CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
2000
2001/**
2002 * \brief Return the canonical type for a CXType.
2003 *
2004 * Clang's type system explicitly models typedefs and all the ways
2005 * a specific type can be represented. The canonical type is the underlying
2006 * type with all the "sugar" removed. For example, if 'T' is a typedef
2007 * for 'int', the canonical type for 'T' would be 'int'.
2008 */
2009CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
2010
2011/**
Douglas Gregore72fb6f2011-01-27 16:27:11 +00002012 * \determine Determine whether a CXType has the "const" qualifier set,
2013 * without looking through typedefs that may have added "const" at a different level.
2014 */
2015CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
2016
2017/**
2018 * \determine Determine whether a CXType has the "volatile" qualifier set,
2019 * without looking through typedefs that may have added "volatile" at a different level.
2020 */
2021CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
2022
2023/**
2024 * \determine Determine whether a CXType has the "restrict" qualifier set,
2025 * without looking through typedefs that may have added "restrict" at a different level.
2026 */
2027CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
2028
2029/**
Ted Kremenek8e0ac172010-05-14 21:29:26 +00002030 * \brief For pointer types, returns the type of the pointee.
2031 *
2032 */
2033CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
2034
2035/**
2036 * \brief Return the cursor for the declaration of the given type.
2037 */
2038CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
2039
David Chisnall5389f482010-12-30 14:05:53 +00002040/**
2041 * Returns the Objective-C type encoding for the specified declaration.
2042 */
2043CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
Ted Kremenek8e0ac172010-05-14 21:29:26 +00002044
2045/**
2046 * \brief Retrieve the spelling of a given CXTypeKind.
2047 */
2048CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
2049
2050/**
Ted Kremenek9a140842010-06-21 20:48:56 +00002051 * \brief Retrieve the result type associated with a function type.
Ted Kremenek04c3cf32010-06-21 20:15:39 +00002052 */
2053CINDEX_LINKAGE CXType clang_getResultType(CXType T);
2054
2055/**
Ted Kremenek9a140842010-06-21 20:48:56 +00002056 * \brief Retrieve the result type associated with a given cursor. This only
2057 * returns a valid type of the cursor refers to a function or method.
2058 */
2059CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
2060
2061/**
Ted Kremenek3ce9e7d2010-07-30 00:14:11 +00002062 * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
2063 * otherwise.
2064 */
2065CINDEX_LINKAGE unsigned clang_isPODType(CXType T);
2066
2067/**
Argyrios Kyrtzidis5f0bfc52011-09-27 17:44:34 +00002068 * \brief Return the element type of an array type.
2069 *
2070 * If a non-array type is passed in, an invalid type is returned.
2071 */
2072CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
2073
2074/**
2075 * \brief Return the the array size of a constant array.
2076 *
2077 * If a non-array type is passed in, -1 is returned.
2078 */
2079CINDEX_LINKAGE long long clang_getArraySize(CXType T);
2080
2081/**
Ted Kremenek3064ef92010-08-27 21:34:58 +00002082 * \brief Returns 1 if the base class specified by the cursor with kind
2083 * CX_CXXBaseSpecifier is virtual.
2084 */
2085CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
2086
2087/**
2088 * \brief Represents the C++ access control level to a base class for a
2089 * cursor with kind CX_CXXBaseSpecifier.
2090 */
2091enum CX_CXXAccessSpecifier {
2092 CX_CXXInvalidAccessSpecifier,
2093 CX_CXXPublic,
2094 CX_CXXProtected,
2095 CX_CXXPrivate
2096};
2097
2098/**
2099 * \brief Returns the access control level for the C++ base specifier
Argyrios Kyrtzidis2dfdb942011-09-30 17:58:23 +00002100 * represented by a cursor with kind CXCursor_CXXBaseSpecifier or
2101 * CXCursor_AccessSpecifier.
Ted Kremenek3064ef92010-08-27 21:34:58 +00002102 */
2103CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
2104
2105/**
Douglas Gregor1f60d9e2010-09-13 22:52:57 +00002106 * \brief Determine the number of overloaded declarations referenced by a
2107 * \c CXCursor_OverloadedDeclRef cursor.
2108 *
2109 * \param cursor The cursor whose overloaded declarations are being queried.
2110 *
2111 * \returns The number of overloaded declarations referenced by \c cursor. If it
2112 * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
2113 */
2114CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
2115
2116/**
2117 * \brief Retrieve a cursor for one of the overloaded declarations referenced
2118 * by a \c CXCursor_OverloadedDeclRef cursor.
2119 *
2120 * \param cursor The cursor whose overloaded declarations are being queried.
2121 *
2122 * \param index The zero-based index into the set of overloaded declarations in
2123 * the cursor.
2124 *
2125 * \returns A cursor representing the declaration referenced by the given
2126 * \c cursor at the specified \c index. If the cursor does not have an
2127 * associated set of overloaded declarations, or if the index is out of bounds,
2128 * returns \c clang_getNullCursor();
2129 */
2130CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
2131 unsigned index);
2132
2133/**
Ted Kremenek8e0ac172010-05-14 21:29:26 +00002134 * @}
2135 */
Ted Kremenek95f33552010-08-26 01:42:22 +00002136
2137/**
Ted Kremenekad72f4d2010-08-27 21:34:51 +00002138 * \defgroup CINDEX_ATTRIBUTES Information for attributes
Ted Kremenek95f33552010-08-26 01:42:22 +00002139 *
2140 * @{
2141 */
2142
2143
2144/**
2145 * \brief For cursors representing an iboutletcollection attribute,
2146 * this function returns the collection element type.
2147 *
2148 */
2149CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
2150
2151/**
2152 * @}
2153 */
Ted Kremenek8e0ac172010-05-14 21:29:26 +00002154
2155/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002156 * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
2157 *
2158 * These routines provide the ability to traverse the abstract syntax tree
2159 * using cursors.
2160 *
2161 * @{
2162 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002163
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002164/**
2165 * \brief Describes how the traversal of the children of a particular
2166 * cursor should proceed after visiting a particular child cursor.
2167 *
2168 * A value of this enumeration type should be returned by each
2169 * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
2170 */
2171enum CXChildVisitResult {
2172 /**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002173 * \brief Terminates the cursor traversal.
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002174 */
2175 CXChildVisit_Break,
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002176 /**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002177 * \brief Continues the cursor traversal with the next sibling of
2178 * the cursor just visited, without visiting its children.
2179 */
2180 CXChildVisit_Continue,
2181 /**
2182 * \brief Recursively traverse the children of this cursor, using
2183 * the same visitor and client data.
2184 */
2185 CXChildVisit_Recurse
2186};
2187
2188/**
2189 * \brief Visitor invoked for each cursor found by a traversal.
2190 *
2191 * This visitor function will be invoked for each cursor found by
2192 * clang_visitCursorChildren(). Its first argument is the cursor being
2193 * visited, its second argument is the parent visitor for that cursor,
2194 * and its third argument is the client data provided to
2195 * clang_visitCursorChildren().
2196 *
2197 * The visitor should return one of the \c CXChildVisitResult values
2198 * to direct clang_visitCursorChildren().
2199 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002200typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
2201 CXCursor parent,
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002202 CXClientData client_data);
2203
2204/**
2205 * \brief Visit the children of a particular cursor.
2206 *
2207 * This function visits all the direct children of the given cursor,
2208 * invoking the given \p visitor function with the cursors of each
2209 * visited child. The traversal may be recursive, if the visitor returns
2210 * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
2211 * the visitor returns \c CXChildVisit_Break.
2212 *
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002213 * \param parent the cursor whose child may be visited. All kinds of
Daniel Dunbara57259e2010-01-24 04:10:31 +00002214 * cursors can be visited, including invalid cursors (which, by
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002215 * definition, have no children).
2216 *
2217 * \param visitor the visitor function that will be invoked for each
2218 * child of \p parent.
2219 *
2220 * \param client_data pointer data supplied by the client, which will
2221 * be passed to the visitor each time it is invoked.
2222 *
2223 * \returns a non-zero value if the traversal was terminated
2224 * prematurely by the visitor returning \c CXChildVisit_Break.
2225 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002226CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002227 CXCursorVisitor visitor,
2228 CXClientData client_data);
David Chisnall3387c652010-11-03 14:12:26 +00002229#ifdef __has_feature
2230# if __has_feature(blocks)
2231/**
2232 * \brief Visitor invoked for each cursor found by a traversal.
2233 *
2234 * This visitor block will be invoked for each cursor found by
2235 * clang_visitChildrenWithBlock(). Its first argument is the cursor being
2236 * visited, its second argument is the parent visitor for that cursor.
2237 *
2238 * The visitor should return one of the \c CXChildVisitResult values
2239 * to direct clang_visitChildrenWithBlock().
2240 */
2241typedef enum CXChildVisitResult
2242 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
2243
2244/**
2245 * Visits the children of a cursor using the specified block. Behaves
2246 * identically to clang_visitChildren() in all other respects.
2247 */
2248unsigned clang_visitChildrenWithBlock(CXCursor parent,
2249 CXCursorVisitorBlock block);
2250# endif
2251#endif
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002252
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002253/**
2254 * @}
2255 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002256
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002257/**
2258 * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
2259 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002260 * These routines provide the ability to determine references within and
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002261 * across translation units, by providing the names of the entities referenced
2262 * by cursors, follow reference cursors to the declarations they reference,
2263 * and associate declarations with their definitions.
2264 *
2265 * @{
2266 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002267
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002268/**
2269 * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
2270 * by the given cursor.
2271 *
2272 * A Unified Symbol Resolution (USR) is a string that identifies a particular
2273 * entity (function, class, variable, etc.) within a program. USRs can be
2274 * compared across translation units to determine, e.g., when references in
2275 * one translation refer to an entity defined in another translation unit.
2276 */
2277CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
2278
2279/**
Ted Kremenek896b70f2010-03-13 02:50:34 +00002280 * \brief Construct a USR for a specified Objective-C class.
2281 */
2282CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
2283
2284/**
2285 * \brief Construct a USR for a specified Objective-C category.
2286 */
2287CINDEX_LINKAGE CXString
Ted Kremenek66ccaec2010-03-15 17:38:58 +00002288 clang_constructUSR_ObjCCategory(const char *class_name,
Ted Kremenek896b70f2010-03-13 02:50:34 +00002289 const char *category_name);
2290
2291/**
2292 * \brief Construct a USR for a specified Objective-C protocol.
2293 */
2294CINDEX_LINKAGE CXString
2295 clang_constructUSR_ObjCProtocol(const char *protocol_name);
2296
2297
2298/**
2299 * \brief Construct a USR for a specified Objective-C instance variable and
2300 * the USR for its containing class.
2301 */
2302CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
2303 CXString classUSR);
2304
2305/**
2306 * \brief Construct a USR for a specified Objective-C method and
2307 * the USR for its containing class.
2308 */
2309CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
2310 unsigned isInstanceMethod,
2311 CXString classUSR);
2312
2313/**
2314 * \brief Construct a USR for a specified Objective-C property and the USR
2315 * for its containing class.
2316 */
2317CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
2318 CXString classUSR);
2319
2320/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002321 * \brief Retrieve a name for the entity referenced by this cursor.
2322 */
2323CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
2324
Douglas Gregor358559d2010-10-02 22:49:11 +00002325/**
2326 * \brief Retrieve the display name for the entity referenced by this cursor.
2327 *
2328 * The display name contains extra information that helps identify the cursor,
2329 * such as the parameters of a function or template or the arguments of a
2330 * class template specialization.
2331 */
2332CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
2333
Douglas Gregorc5d1e932010-01-19 01:20:04 +00002334/** \brief For a cursor that is a reference, retrieve a cursor representing the
2335 * entity that it references.
2336 *
2337 * Reference cursors refer to other entities in the AST. For example, an
2338 * Objective-C superclass reference cursor refers to an Objective-C class.
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002339 * This function produces the cursor for the Objective-C class from the
Douglas Gregorc5d1e932010-01-19 01:20:04 +00002340 * cursor for the superclass reference. If the input cursor is a declaration or
2341 * definition, it returns that declaration or definition unchanged.
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002342 * Otherwise, returns the NULL cursor.
Douglas Gregorc5d1e932010-01-19 01:20:04 +00002343 */
2344CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
Douglas Gregorb6998662010-01-19 19:34:47 +00002345
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002346/**
Douglas Gregorb6998662010-01-19 19:34:47 +00002347 * \brief For a cursor that is either a reference to or a declaration
2348 * of some entity, retrieve a cursor that describes the definition of
2349 * that entity.
2350 *
2351 * Some entities can be declared multiple times within a translation
2352 * unit, but only one of those declarations can also be a
2353 * definition. For example, given:
2354 *
2355 * \code
2356 * int f(int, int);
2357 * int g(int x, int y) { return f(x, y); }
2358 * int f(int a, int b) { return a + b; }
2359 * int f(int, int);
2360 * \endcode
2361 *
2362 * there are three declarations of the function "f", but only the
2363 * second one is a definition. The clang_getCursorDefinition()
2364 * function will take any cursor pointing to a declaration of "f"
2365 * (the first or fourth lines of the example) or a cursor referenced
2366 * that uses "f" (the call to "f' inside "g") and will return a
2367 * declaration cursor pointing to the definition (the second "f"
2368 * declaration).
2369 *
2370 * If given a cursor for which there is no corresponding definition,
2371 * e.g., because there is no definition of that entity within this
2372 * translation unit, returns a NULL cursor.
2373 */
2374CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
2375
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002376/**
Douglas Gregorb6998662010-01-19 19:34:47 +00002377 * \brief Determine whether the declaration pointed to by this cursor
2378 * is also a definition of that entity.
2379 */
2380CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
2381
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002382/**
Douglas Gregor1a9d0502010-11-19 23:44:15 +00002383 * \brief Retrieve the canonical cursor corresponding to the given cursor.
2384 *
2385 * In the C family of languages, many kinds of entities can be declared several
2386 * times within a single translation unit. For example, a structure type can
2387 * be forward-declared (possibly multiple times) and later defined:
2388 *
2389 * \code
2390 * struct X;
2391 * struct X;
2392 * struct X {
2393 * int member;
2394 * };
2395 * \endcode
2396 *
2397 * The declarations and the definition of \c X are represented by three
2398 * different cursors, all of which are declarations of the same underlying
2399 * entity. One of these cursor is considered the "canonical" cursor, which
2400 * is effectively the representative for the underlying entity. One can
2401 * determine if two cursors are declarations of the same underlying entity by
2402 * comparing their canonical cursors.
2403 *
2404 * \returns The canonical cursor for the entity referred to by the given cursor.
2405 */
2406CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
2407
2408/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002409 * @}
2410 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002411
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002412/**
Ted Kremenek9ada39a2010-05-17 20:06:56 +00002413 * \defgroup CINDEX_CPP C++ AST introspection
2414 *
2415 * The routines in this group provide access information in the ASTs specific
2416 * to C++ language features.
2417 *
2418 * @{
2419 */
2420
2421/**
Douglas Gregor49f6f542010-08-31 22:12:17 +00002422 * \brief Determine if a C++ member function or member function template is
2423 * declared 'static'.
Ted Kremenek9ada39a2010-05-17 20:06:56 +00002424 */
2425CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
2426
2427/**
Douglas Gregor211924b2011-05-12 15:17:24 +00002428 * \brief Determine if a C++ member function or member function template is
2429 * explicitly declared 'virtual' or if it overrides a virtual method from
2430 * one of the base classes.
2431 */
2432CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
2433
2434/**
Douglas Gregor49f6f542010-08-31 22:12:17 +00002435 * \brief Given a cursor that represents a template, determine
2436 * the cursor kind of the specializations would be generated by instantiating
2437 * the template.
2438 *
2439 * This routine can be used to determine what flavor of function template,
2440 * class template, or class template partial specialization is stored in the
2441 * cursor. For example, it can describe whether a class template cursor is
2442 * declared with "struct", "class" or "union".
2443 *
2444 * \param C The cursor to query. This cursor should represent a template
2445 * declaration.
2446 *
2447 * \returns The cursor kind of the specializations that would be generated
2448 * by instantiating the template \p C. If \p C is not a template, returns
2449 * \c CXCursor_NoDeclFound.
2450 */
2451CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
2452
2453/**
Douglas Gregore0329ac2010-09-02 00:07:54 +00002454 * \brief Given a cursor that may represent a specialization or instantiation
2455 * of a template, retrieve the cursor that represents the template that it
2456 * specializes or from which it was instantiated.
2457 *
2458 * This routine determines the template involved both for explicit
2459 * specializations of templates and for implicit instantiations of the template,
2460 * both of which are referred to as "specializations". For a class template
2461 * specialization (e.g., \c std::vector<bool>), this routine will return
2462 * either the primary template (\c std::vector) or, if the specialization was
2463 * instantiated from a class template partial specialization, the class template
2464 * partial specialization. For a class template partial specialization and a
2465 * function template specialization (including instantiations), this
2466 * this routine will return the specialized template.
2467 *
2468 * For members of a class template (e.g., member functions, member classes, or
2469 * static data members), returns the specialized or instantiated member.
2470 * Although not strictly "templates" in the C++ language, members of class
2471 * templates have the same notions of specializations and instantiations that
2472 * templates do, so this routine treats them similarly.
2473 *
2474 * \param C A cursor that may be a specialization of a template or a member
2475 * of a template.
2476 *
2477 * \returns If the given cursor is a specialization or instantiation of a
2478 * template or a member thereof, the template or member that it specializes or
2479 * from which it was instantiated. Otherwise, returns a NULL cursor.
2480 */
2481CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
Douglas Gregor430d7a12011-07-25 17:48:11 +00002482
2483/**
2484 * \brief Given a cursor that references something else, return the source range
2485 * covering that reference.
2486 *
2487 * \param C A cursor pointing to a member reference, a declaration reference, or
2488 * an operator call.
2489 * \param NameFlags A bitset with three independent flags:
2490 * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
2491 * CXNameRange_WantSinglePiece.
2492 * \param PieceIndex For contiguous names or when passing the flag
2493 * CXNameRange_WantSinglePiece, only one piece with index 0 is
2494 * available. When the CXNameRange_WantSinglePiece flag is not passed for a
2495 * non-contiguous names, this index can be used to retreive the individual
2496 * pieces of the name. See also CXNameRange_WantSinglePiece.
2497 *
2498 * \returns The piece of the name pointed to by the given cursor. If there is no
2499 * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
2500 */
Francois Pichet48a8d142011-07-25 22:00:44 +00002501CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
2502 unsigned NameFlags,
Douglas Gregor430d7a12011-07-25 17:48:11 +00002503 unsigned PieceIndex);
2504
2505enum CXNameRefFlags {
2506 /**
2507 * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
2508 * range.
2509 */
2510 CXNameRange_WantQualifier = 0x1,
2511
2512 /**
2513 * \brief Include the explicit template arguments, e.g. <int> in x.f<int>, in
2514 * the range.
2515 */
2516 CXNameRange_WantTemplateArgs = 0x2,
2517
2518 /**
2519 * \brief If the name is non-contiguous, return the full spanning range.
2520 *
2521 * Non-contiguous names occur in Objective-C when a selector with two or more
2522 * parameters is used, or in C++ when using an operator:
2523 * \code
2524 * [object doSomething:here withValue:there]; // ObjC
2525 * return some_vector[1]; // C++
2526 * \endcode
2527 */
2528 CXNameRange_WantSinglePiece = 0x4
2529};
Douglas Gregore0329ac2010-09-02 00:07:54 +00002530
2531/**
Ted Kremenek9ada39a2010-05-17 20:06:56 +00002532 * @}
2533 */
2534
2535/**
Douglas Gregor0045e9f2010-01-26 18:31:56 +00002536 * \defgroup CINDEX_LEX Token extraction and manipulation
2537 *
2538 * The routines in this group provide access to the tokens within a
2539 * translation unit, along with a semantic mapping of those tokens to
2540 * their corresponding cursors.
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002541 *
2542 * @{
2543 */
2544
2545/**
2546 * \brief Describes a kind of token.
2547 */
2548typedef enum CXTokenKind {
2549 /**
2550 * \brief A token that contains some kind of punctuation.
2551 */
2552 CXToken_Punctuation,
Ted Kremenek896b70f2010-03-13 02:50:34 +00002553
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002554 /**
Douglas Gregor0045e9f2010-01-26 18:31:56 +00002555 * \brief A language keyword.
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002556 */
2557 CXToken_Keyword,
Ted Kremenek896b70f2010-03-13 02:50:34 +00002558
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002559 /**
2560 * \brief An identifier (that is not a keyword).
2561 */
2562 CXToken_Identifier,
Ted Kremenek896b70f2010-03-13 02:50:34 +00002563
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002564 /**
2565 * \brief A numeric, string, or character literal.
2566 */
2567 CXToken_Literal,
Ted Kremenek896b70f2010-03-13 02:50:34 +00002568
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002569 /**
2570 * \brief A comment.
2571 */
2572 CXToken_Comment
2573} CXTokenKind;
2574
2575/**
2576 * \brief Describes a single preprocessing token.
2577 */
2578typedef struct {
2579 unsigned int_data[4];
2580 void *ptr_data;
2581} CXToken;
2582
2583/**
2584 * \brief Determine the kind of the given token.
2585 */
2586CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
Ted Kremenek896b70f2010-03-13 02:50:34 +00002587
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002588/**
2589 * \brief Determine the spelling of the given token.
2590 *
2591 * The spelling of a token is the textual representation of that token, e.g.,
2592 * the text of an identifier or keyword.
2593 */
2594CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
Ted Kremenek896b70f2010-03-13 02:50:34 +00002595
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002596/**
2597 * \brief Retrieve the source location of the given token.
2598 */
Ted Kremenek896b70f2010-03-13 02:50:34 +00002599CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002600 CXToken);
Ted Kremenek896b70f2010-03-13 02:50:34 +00002601
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002602/**
2603 * \brief Retrieve a source range that covers the given token.
2604 */
2605CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
2606
2607/**
2608 * \brief Tokenize the source code described by the given range into raw
2609 * lexical tokens.
2610 *
2611 * \param TU the translation unit whose text is being tokenized.
2612 *
2613 * \param Range the source range in which text should be tokenized. All of the
2614 * tokens produced by tokenization will fall within this source range,
2615 *
2616 * \param Tokens this pointer will be set to point to the array of tokens
2617 * that occur within the given source range. The returned pointer must be
2618 * freed with clang_disposeTokens() before the translation unit is destroyed.
2619 *
2620 * \param NumTokens will be set to the number of tokens in the \c *Tokens
2621 * array.
2622 *
2623 */
2624CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
2625 CXToken **Tokens, unsigned *NumTokens);
Ted Kremenek896b70f2010-03-13 02:50:34 +00002626
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002627/**
2628 * \brief Annotate the given set of tokens by providing cursors for each token
2629 * that can be mapped to a specific entity within the abstract syntax tree.
2630 *
Douglas Gregor0045e9f2010-01-26 18:31:56 +00002631 * This token-annotation routine is equivalent to invoking
2632 * clang_getCursor() for the source locations of each of the
2633 * tokens. The cursors provided are filtered, so that only those
2634 * cursors that have a direct correspondence to the token are
2635 * accepted. For example, given a function call \c f(x),
2636 * clang_getCursor() would provide the following cursors:
2637 *
2638 * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
2639 * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
2640 * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
2641 *
2642 * Only the first and last of these cursors will occur within the
2643 * annotate, since the tokens "f" and "x' directly refer to a function
2644 * and a variable, respectively, but the parentheses are just a small
2645 * part of the full syntax of the function call expression, which is
2646 * not provided as an annotation.
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002647 *
2648 * \param TU the translation unit that owns the given tokens.
2649 *
2650 * \param Tokens the set of tokens to annotate.
2651 *
2652 * \param NumTokens the number of tokens in \p Tokens.
2653 *
2654 * \param Cursors an array of \p NumTokens cursors, whose contents will be
2655 * replaced with the cursors corresponding to each token.
2656 */
2657CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
2658 CXToken *Tokens, unsigned NumTokens,
2659 CXCursor *Cursors);
Ted Kremenek896b70f2010-03-13 02:50:34 +00002660
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002661/**
2662 * \brief Free the given set of tokens.
2663 */
Ted Kremenek896b70f2010-03-13 02:50:34 +00002664CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002665 CXToken *Tokens, unsigned NumTokens);
Ted Kremenek896b70f2010-03-13 02:50:34 +00002666
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002667/**
2668 * @}
2669 */
Ted Kremenek896b70f2010-03-13 02:50:34 +00002670
Douglas Gregorfc8ea232010-01-26 17:06:03 +00002671/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002672 * \defgroup CINDEX_DEBUG Debugging facilities
2673 *
2674 * These routines are used for testing and debugging, only, and should not
2675 * be relied upon.
2676 *
2677 * @{
2678 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002679
Steve Naroff4ade6d62009-09-23 17:52:52 +00002680/* for debug/testing */
Ted Kremeneke68fff62010-02-17 00:41:32 +00002681CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002682CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
2683 const char **startBuf,
Steve Naroff4ade6d62009-09-23 17:52:52 +00002684 const char **endBuf,
2685 unsigned *startLine,
2686 unsigned *startColumn,
2687 unsigned *endLine,
2688 unsigned *endColumn);
Douglas Gregor0a812cf2010-02-18 23:07:20 +00002689CINDEX_LINKAGE void clang_enableStackTraces(void);
Daniel Dunbar995aaf92010-11-04 01:26:29 +00002690CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
2691 unsigned stack_size);
2692
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002693/**
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002694 * @}
2695 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002696
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002697/**
2698 * \defgroup CINDEX_CODE_COMPLET Code completion
2699 *
2700 * Code completion involves taking an (incomplete) source file, along with
2701 * knowledge of where the user is actively editing that file, and suggesting
2702 * syntactically- and semantically-valid constructs that the user might want to
2703 * use at that particular point in the source code. These data structures and
2704 * routines provide support for code completion.
2705 *
2706 * @{
2707 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002708
Douglas Gregorc42fefa2010-01-22 22:29:16 +00002709/**
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002710 * \brief A semantic string that describes a code-completion result.
2711 *
2712 * A semantic string that describes the formatting of a code-completion
2713 * result as a single "template" of text that should be inserted into the
2714 * source buffer when a particular code-completion result is selected.
2715 * Each semantic string is made up of some number of "chunks", each of which
2716 * contains some text along with a description of what that text means, e.g.,
2717 * the name of the entity being referenced, whether the text chunk is part of
2718 * the template, or whether it is a "placeholder" that the user should replace
2719 * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002720 * description of the different kinds of chunks.
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002721 */
2722typedef void *CXCompletionString;
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002723
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002724/**
2725 * \brief A single result of code completion.
2726 */
2727typedef struct {
2728 /**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002729 * \brief The kind of entity that this completion refers to.
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002730 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002731 * The cursor kind will be a macro, keyword, or a declaration (one of the
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002732 * *Decl cursor kinds), describing the entity that the completion is
2733 * referring to.
2734 *
2735 * \todo In the future, we would like to provide a full cursor, to allow
2736 * the client to extract additional information from declaration.
2737 */
2738 enum CXCursorKind CursorKind;
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002739
2740 /**
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002741 * \brief The code-completion string that describes how to insert this
2742 * code-completion result into the editing buffer.
2743 */
2744 CXCompletionString CompletionString;
2745} CXCompletionResult;
2746
2747/**
2748 * \brief Describes a single piece of text within a code-completion string.
2749 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002750 * Each "chunk" within a code-completion string (\c CXCompletionString) is
2751 * either a piece of text with a specific "kind" that describes how that text
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002752 * should be interpreted by the client or is another completion string.
2753 */
2754enum CXCompletionChunkKind {
2755 /**
2756 * \brief A code-completion string that describes "optional" text that
2757 * could be a part of the template (but is not required).
2758 *
2759 * The Optional chunk is the only kind of chunk that has a code-completion
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002760 * string for its representation, which is accessible via
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002761 * \c clang_getCompletionChunkCompletionString(). The code-completion string
2762 * describes an additional part of the template that is completely optional.
2763 * For example, optional chunks can be used to describe the placeholders for
2764 * arguments that match up with defaulted function parameters, e.g. given:
2765 *
2766 * \code
2767 * void f(int x, float y = 3.14, double z = 2.71828);
2768 * \endcode
2769 *
2770 * The code-completion string for this function would contain:
2771 * - a TypedText chunk for "f".
2772 * - a LeftParen chunk for "(".
2773 * - a Placeholder chunk for "int x"
2774 * - an Optional chunk containing the remaining defaulted arguments, e.g.,
2775 * - a Comma chunk for ","
Daniel Dunbar71570182010-02-17 08:07:44 +00002776 * - a Placeholder chunk for "float y"
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002777 * - an Optional chunk containing the last defaulted argument:
2778 * - a Comma chunk for ","
2779 * - a Placeholder chunk for "double z"
2780 * - a RightParen chunk for ")"
2781 *
Daniel Dunbar71570182010-02-17 08:07:44 +00002782 * There are many ways to handle Optional chunks. Two simple approaches are:
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002783 * - Completely ignore optional chunks, in which case the template for the
2784 * function "f" would only include the first parameter ("int x").
2785 * - Fully expand all optional chunks, in which case the template for the
2786 * function "f" would have all of the parameters.
2787 */
2788 CXCompletionChunk_Optional,
2789 /**
2790 * \brief Text that a user would be expected to type to get this
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002791 * code-completion result.
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002792 *
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002793 * There will be exactly one "typed text" chunk in a semantic string, which
2794 * will typically provide the spelling of a keyword or the name of a
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002795 * declaration that could be used at the current code point. Clients are
2796 * expected to filter the code-completion results based on the text in this
2797 * chunk.
2798 */
2799 CXCompletionChunk_TypedText,
2800 /**
2801 * \brief Text that should be inserted as part of a code-completion result.
2802 *
2803 * A "text" chunk represents text that is part of the template to be
2804 * inserted into user code should this particular code-completion result
2805 * be selected.
2806 */
2807 CXCompletionChunk_Text,
2808 /**
2809 * \brief Placeholder text that should be replaced by the user.
2810 *
2811 * A "placeholder" chunk marks a place where the user should insert text
2812 * into the code-completion template. For example, placeholders might mark
2813 * the function parameters for a function declaration, to indicate that the
2814 * user should provide arguments for each of those parameters. The actual
2815 * text in a placeholder is a suggestion for the text to display before
2816 * the user replaces the placeholder with real code.
2817 */
2818 CXCompletionChunk_Placeholder,
2819 /**
2820 * \brief Informative text that should be displayed but never inserted as
2821 * part of the template.
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002822 *
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002823 * An "informative" chunk contains annotations that can be displayed to
2824 * help the user decide whether a particular code-completion result is the
2825 * right option, but which is not part of the actual template to be inserted
2826 * by code completion.
2827 */
2828 CXCompletionChunk_Informative,
2829 /**
2830 * \brief Text that describes the current parameter when code-completion is
2831 * referring to function call, message send, or template specialization.
2832 *
2833 * A "current parameter" chunk occurs when code-completion is providing
2834 * information about a parameter corresponding to the argument at the
2835 * code-completion point. For example, given a function
2836 *
2837 * \code
2838 * int add(int x, int y);
2839 * \endcode
2840 *
2841 * and the source code \c add(, where the code-completion point is after the
2842 * "(", the code-completion string will contain a "current parameter" chunk
2843 * for "int x", indicating that the current argument will initialize that
2844 * parameter. After typing further, to \c add(17, (where the code-completion
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002845 * point is after the ","), the code-completion string will contain a
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002846 * "current paremeter" chunk to "int y".
2847 */
2848 CXCompletionChunk_CurrentParameter,
2849 /**
2850 * \brief A left parenthesis ('('), used to initiate a function call or
2851 * signal the beginning of a function parameter list.
2852 */
2853 CXCompletionChunk_LeftParen,
2854 /**
2855 * \brief A right parenthesis (')'), used to finish a function call or
2856 * signal the end of a function parameter list.
2857 */
2858 CXCompletionChunk_RightParen,
2859 /**
2860 * \brief A left bracket ('[').
2861 */
2862 CXCompletionChunk_LeftBracket,
2863 /**
2864 * \brief A right bracket (']').
2865 */
2866 CXCompletionChunk_RightBracket,
2867 /**
2868 * \brief A left brace ('{').
2869 */
2870 CXCompletionChunk_LeftBrace,
2871 /**
2872 * \brief A right brace ('}').
2873 */
2874 CXCompletionChunk_RightBrace,
2875 /**
2876 * \brief A left angle bracket ('<').
2877 */
2878 CXCompletionChunk_LeftAngle,
2879 /**
2880 * \brief A right angle bracket ('>').
2881 */
2882 CXCompletionChunk_RightAngle,
2883 /**
2884 * \brief A comma separator (',').
2885 */
Douglas Gregorff5ce6e2009-12-18 18:53:37 +00002886 CXCompletionChunk_Comma,
2887 /**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002888 * \brief Text that specifies the result type of a given result.
Douglas Gregorff5ce6e2009-12-18 18:53:37 +00002889 *
2890 * This special kind of informative chunk is not meant to be inserted into
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002891 * the text buffer. Rather, it is meant to illustrate the type that an
Douglas Gregorff5ce6e2009-12-18 18:53:37 +00002892 * expression using the given completion string would have.
2893 */
Douglas Gregor01dfea02010-01-10 23:08:15 +00002894 CXCompletionChunk_ResultType,
2895 /**
2896 * \brief A colon (':').
2897 */
2898 CXCompletionChunk_Colon,
2899 /**
2900 * \brief A semicolon (';').
2901 */
2902 CXCompletionChunk_SemiColon,
2903 /**
2904 * \brief An '=' sign.
2905 */
2906 CXCompletionChunk_Equal,
2907 /**
2908 * Horizontal space (' ').
2909 */
2910 CXCompletionChunk_HorizontalSpace,
2911 /**
2912 * Vertical space ('\n'), after which it is generally a good idea to
2913 * perform indentation.
2914 */
2915 CXCompletionChunk_VerticalSpace
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002916};
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002917
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002918/**
2919 * \brief Determine the kind of a particular chunk within a completion string.
2920 *
2921 * \param completion_string the completion string to query.
2922 *
2923 * \param chunk_number the 0-based index of the chunk in the completion string.
2924 *
2925 * \returns the kind of the chunk at the index \c chunk_number.
2926 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002927CINDEX_LINKAGE enum CXCompletionChunkKind
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002928clang_getCompletionChunkKind(CXCompletionString completion_string,
2929 unsigned chunk_number);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002930
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002931/**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002932 * \brief Retrieve the text associated with a particular chunk within a
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002933 * completion string.
2934 *
2935 * \param completion_string the completion string to query.
2936 *
2937 * \param chunk_number the 0-based index of the chunk in the completion string.
2938 *
2939 * \returns the text associated with the chunk at index \c chunk_number.
2940 */
Ted Kremenek2ef6f8f2010-02-17 01:42:24 +00002941CINDEX_LINKAGE CXString
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002942clang_getCompletionChunkText(CXCompletionString completion_string,
2943 unsigned chunk_number);
2944
2945/**
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002946 * \brief Retrieve the completion string associated with a particular chunk
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002947 * within a completion string.
2948 *
2949 * \param completion_string the completion string to query.
2950 *
2951 * \param chunk_number the 0-based index of the chunk in the completion string.
2952 *
2953 * \returns the completion string associated with the chunk at index
2954 * \c chunk_number, or NULL if that chunk is not represented by a completion
2955 * string.
2956 */
2957CINDEX_LINKAGE CXCompletionString
2958clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
2959 unsigned chunk_number);
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00002960
Douglas Gregor0c8296d2009-11-07 00:00:49 +00002961/**
2962 * \brief Retrieve the number of chunks in the given code-completion string.
2963 */
2964CINDEX_LINKAGE unsigned
2965clang_getNumCompletionChunks(CXCompletionString completion_string);
2966
2967/**
Douglas Gregor12e13132010-05-26 22:00:08 +00002968 * \brief Determine the priority of this code completion.
2969 *
2970 * The priority of a code completion indicates how likely it is that this
2971 * particular completion is the completion that the user will select. The
2972 * priority is selected by various internal heuristics.
2973 *
2974 * \param completion_string The completion string to query.
2975 *
2976 * \returns The priority of this completion string. Smaller values indicate
2977 * higher-priority (more likely) completions.
2978 */
2979CINDEX_LINKAGE unsigned
2980clang_getCompletionPriority(CXCompletionString completion_string);
2981
2982/**
Douglas Gregor58ddb602010-08-23 23:00:57 +00002983 * \brief Determine the availability of the entity that this code-completion
2984 * string refers to.
2985 *
2986 * \param completion_string The completion string to query.
2987 *
2988 * \returns The availability of the completion string.
2989 */
2990CINDEX_LINKAGE enum CXAvailabilityKind
2991clang_getCompletionAvailability(CXCompletionString completion_string);
2992
2993/**
Douglas Gregor8fa0a802011-08-04 20:04:59 +00002994 * \brief Retrieve a completion string for an arbitrary declaration or macro
2995 * definition cursor.
2996 *
2997 * \param cursor The cursor to query.
2998 *
2999 * \returns A non-context-sensitive completion string for declaration and macro
3000 * definition cursors, or NULL for other kinds of cursors.
3001 */
3002CINDEX_LINKAGE CXCompletionString
3003clang_getCursorCompletionString(CXCursor cursor);
3004
3005/**
Douglas Gregorec6762c2009-12-18 16:20:58 +00003006 * \brief Contains the results of code-completion.
3007 *
3008 * This data structure contains the results of code completion, as
Douglas Gregore0cc52e2010-10-11 21:51:20 +00003009 * produced by \c clang_codeCompleteAt(). Its contents must be freed by
Douglas Gregorec6762c2009-12-18 16:20:58 +00003010 * \c clang_disposeCodeCompleteResults.
3011 */
3012typedef struct {
3013 /**
3014 * \brief The code-completion results.
3015 */
3016 CXCompletionResult *Results;
3017
3018 /**
3019 * \brief The number of code-completion results stored in the
3020 * \c Results array.
3021 */
3022 unsigned NumResults;
3023} CXCodeCompleteResults;
3024
3025/**
Douglas Gregorcee235c2010-08-05 09:09:23 +00003026 * \brief Flags that can be passed to \c clang_codeCompleteAt() to
3027 * modify its behavior.
3028 *
3029 * The enumerators in this enumeration can be bitwise-OR'd together to
3030 * provide multiple options to \c clang_codeCompleteAt().
3031 */
3032enum CXCodeComplete_Flags {
3033 /**
3034 * \brief Whether to include macros within the set of code
3035 * completions returned.
3036 */
3037 CXCodeComplete_IncludeMacros = 0x01,
3038
3039 /**
3040 * \brief Whether to include code patterns for language constructs
3041 * within the set of code completions, e.g., for loops.
3042 */
3043 CXCodeComplete_IncludeCodePatterns = 0x02
3044};
3045
3046/**
Douglas Gregor3da626b2011-07-07 16:03:39 +00003047 * \brief Bits that represent the context under which completion is occurring.
3048 *
3049 * The enumerators in this enumeration may be bitwise-OR'd together if multiple
3050 * contexts are occurring simultaneously.
3051 */
3052enum CXCompletionContext {
3053 /**
3054 * \brief The context for completions is unexposed, as only Clang results
3055 * should be included. (This is equivalent to having no context bits set.)
3056 */
3057 CXCompletionContext_Unexposed = 0,
3058
3059 /**
3060 * \brief Completions for any possible type should be included in the results.
3061 */
3062 CXCompletionContext_AnyType = 1 << 0,
3063
3064 /**
3065 * \brief Completions for any possible value (variables, function calls, etc.)
3066 * should be included in the results.
3067 */
3068 CXCompletionContext_AnyValue = 1 << 1,
3069 /**
3070 * \brief Completions for values that resolve to an Objective-C object should
3071 * be included in the results.
3072 */
3073 CXCompletionContext_ObjCObjectValue = 1 << 2,
3074 /**
3075 * \brief Completions for values that resolve to an Objective-C selector
3076 * should be included in the results.
3077 */
3078 CXCompletionContext_ObjCSelectorValue = 1 << 3,
3079 /**
3080 * \brief Completions for values that resolve to a C++ class type should be
3081 * included in the results.
3082 */
3083 CXCompletionContext_CXXClassTypeValue = 1 << 4,
3084
3085 /**
3086 * \brief Completions for fields of the member being accessed using the dot
3087 * operator should be included in the results.
3088 */
3089 CXCompletionContext_DotMemberAccess = 1 << 5,
3090 /**
3091 * \brief Completions for fields of the member being accessed using the arrow
3092 * operator should be included in the results.
3093 */
3094 CXCompletionContext_ArrowMemberAccess = 1 << 6,
3095 /**
3096 * \brief Completions for properties of the Objective-C object being accessed
3097 * using the dot operator should be included in the results.
3098 */
3099 CXCompletionContext_ObjCPropertyAccess = 1 << 7,
3100
3101 /**
3102 * \brief Completions for enum tags should be included in the results.
3103 */
3104 CXCompletionContext_EnumTag = 1 << 8,
3105 /**
3106 * \brief Completions for union tags should be included in the results.
3107 */
3108 CXCompletionContext_UnionTag = 1 << 9,
3109 /**
3110 * \brief Completions for struct tags should be included in the results.
3111 */
3112 CXCompletionContext_StructTag = 1 << 10,
3113
3114 /**
3115 * \brief Completions for C++ class names should be included in the results.
3116 */
3117 CXCompletionContext_ClassTag = 1 << 11,
3118 /**
3119 * \brief Completions for C++ namespaces and namespace aliases should be
3120 * included in the results.
3121 */
3122 CXCompletionContext_Namespace = 1 << 12,
3123 /**
3124 * \brief Completions for C++ nested name specifiers should be included in
3125 * the results.
3126 */
3127 CXCompletionContext_NestedNameSpecifier = 1 << 13,
3128
3129 /**
3130 * \brief Completions for Objective-C interfaces (classes) should be included
3131 * in the results.
3132 */
3133 CXCompletionContext_ObjCInterface = 1 << 14,
3134 /**
3135 * \brief Completions for Objective-C protocols should be included in
3136 * the results.
3137 */
3138 CXCompletionContext_ObjCProtocol = 1 << 15,
3139 /**
3140 * \brief Completions for Objective-C categories should be included in
3141 * the results.
3142 */
3143 CXCompletionContext_ObjCCategory = 1 << 16,
3144 /**
3145 * \brief Completions for Objective-C instance messages should be included
3146 * in the results.
3147 */
3148 CXCompletionContext_ObjCInstanceMessage = 1 << 17,
3149 /**
3150 * \brief Completions for Objective-C class messages should be included in
3151 * the results.
3152 */
3153 CXCompletionContext_ObjCClassMessage = 1 << 18,
3154 /**
3155 * \brief Completions for Objective-C selector names should be included in
3156 * the results.
3157 */
3158 CXCompletionContext_ObjCSelectorName = 1 << 19,
3159
3160 /**
3161 * \brief Completions for preprocessor macro names should be included in
3162 * the results.
3163 */
3164 CXCompletionContext_MacroName = 1 << 20,
3165
3166 /**
3167 * \brief Natural language completions should be included in the results.
3168 */
3169 CXCompletionContext_NaturalLanguage = 1 << 21,
3170
3171 /**
3172 * \brief The current context is unknown, so set all contexts.
3173 */
3174 CXCompletionContext_Unknown = ((1 << 22) - 1)
3175};
3176
3177/**
Douglas Gregorcee235c2010-08-05 09:09:23 +00003178 * \brief Returns a default set of code-completion options that can be
3179 * passed to\c clang_codeCompleteAt().
3180 */
3181CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
3182
3183/**
Douglas Gregor1abc6bc2010-08-04 16:47:14 +00003184 * \brief Perform code completion at a given location in a translation unit.
3185 *
3186 * This function performs code completion at a particular file, line, and
3187 * column within source code, providing results that suggest potential
3188 * code snippets based on the context of the completion. The basic model
3189 * for code completion is that Clang will parse a complete source file,
3190 * performing syntax checking up to the location where code-completion has
3191 * been requested. At that point, a special code-completion token is passed
3192 * to the parser, which recognizes this token and determines, based on the
3193 * current location in the C/Objective-C/C++ grammar and the state of
3194 * semantic analysis, what completions to provide. These completions are
3195 * returned via a new \c CXCodeCompleteResults structure.
3196 *
3197 * Code completion itself is meant to be triggered by the client when the
3198 * user types punctuation characters or whitespace, at which point the
3199 * code-completion location will coincide with the cursor. For example, if \c p
3200 * is a pointer, code-completion might be triggered after the "-" and then
3201 * after the ">" in \c p->. When the code-completion location is afer the ">",
3202 * the completion results will provide, e.g., the members of the struct that
3203 * "p" points to. The client is responsible for placing the cursor at the
3204 * beginning of the token currently being typed, then filtering the results
3205 * based on the contents of the token. For example, when code-completing for
3206 * the expression \c p->get, the client should provide the location just after
3207 * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
3208 * client can filter the results based on the current token text ("get"), only
3209 * showing those results that start with "get". The intent of this interface
3210 * is to separate the relatively high-latency acquisition of code-completion
3211 * results from the filtering of results on a per-character basis, which must
3212 * have a lower latency.
3213 *
3214 * \param TU The translation unit in which code-completion should
3215 * occur. The source files for this translation unit need not be
3216 * completely up-to-date (and the contents of those source files may
3217 * be overridden via \p unsaved_files). Cursors referring into the
3218 * translation unit may be invalidated by this invocation.
3219 *
3220 * \param complete_filename The name of the source file where code
3221 * completion should be performed. This filename may be any file
3222 * included in the translation unit.
3223 *
3224 * \param complete_line The line at which code-completion should occur.
3225 *
3226 * \param complete_column The column at which code-completion should occur.
3227 * Note that the column should point just after the syntactic construct that
3228 * initiated code completion, and not in the middle of a lexical token.
3229 *
3230 * \param unsaved_files the Tiles that have not yet been saved to disk
3231 * but may be required for parsing or code completion, including the
3232 * contents of those files. The contents and name of these files (as
3233 * specified by CXUnsavedFile) are copied when necessary, so the
3234 * client only needs to guarantee their validity until the call to
3235 * this function returns.
3236 *
3237 * \param num_unsaved_files The number of unsaved file entries in \p
3238 * unsaved_files.
3239 *
Douglas Gregorcee235c2010-08-05 09:09:23 +00003240 * \param options Extra options that control the behavior of code
3241 * completion, expressed as a bitwise OR of the enumerators of the
3242 * CXCodeComplete_Flags enumeration. The
3243 * \c clang_defaultCodeCompleteOptions() function returns a default set
3244 * of code-completion options.
3245 *
Douglas Gregor1abc6bc2010-08-04 16:47:14 +00003246 * \returns If successful, a new \c CXCodeCompleteResults structure
3247 * containing code-completion results, which should eventually be
3248 * freed with \c clang_disposeCodeCompleteResults(). If code
3249 * completion fails, returns NULL.
3250 */
3251CINDEX_LINKAGE
3252CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
3253 const char *complete_filename,
3254 unsigned complete_line,
3255 unsigned complete_column,
3256 struct CXUnsavedFile *unsaved_files,
Douglas Gregorcee235c2010-08-05 09:09:23 +00003257 unsigned num_unsaved_files,
3258 unsigned options);
Douglas Gregor1abc6bc2010-08-04 16:47:14 +00003259
3260/**
Douglas Gregor1e5e6682010-08-26 13:48:20 +00003261 * \brief Sort the code-completion results in case-insensitive alphabetical
3262 * order.
3263 *
3264 * \param Results The set of results to sort.
3265 * \param NumResults The number of results in \p Results.
3266 */
3267CINDEX_LINKAGE
3268void clang_sortCodeCompletionResults(CXCompletionResult *Results,
3269 unsigned NumResults);
3270
3271/**
Douglas Gregorec6762c2009-12-18 16:20:58 +00003272 * \brief Free the given set of code-completion results.
3273 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00003274CINDEX_LINKAGE
Douglas Gregorec6762c2009-12-18 16:20:58 +00003275void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
Douglas Gregor58ddb602010-08-23 23:00:57 +00003276
Douglas Gregor20d416c2010-01-20 01:10:47 +00003277/**
Douglas Gregora88084b2010-02-18 18:08:43 +00003278 * \brief Determine the number of diagnostics produced prior to the
3279 * location where code completion was performed.
3280 */
Ted Kremenek896b70f2010-03-13 02:50:34 +00003281CINDEX_LINKAGE
Douglas Gregora88084b2010-02-18 18:08:43 +00003282unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
3283
3284/**
3285 * \brief Retrieve a diagnostic associated with the given code completion.
3286 *
3287 * \param Result the code completion results to query.
3288 * \param Index the zero-based diagnostic number to retrieve.
3289 *
3290 * \returns the requested diagnostic. This diagnostic must be freed
3291 * via a call to \c clang_disposeDiagnostic().
3292 */
Ted Kremenek896b70f2010-03-13 02:50:34 +00003293CINDEX_LINKAGE
Douglas Gregora88084b2010-02-18 18:08:43 +00003294CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
3295 unsigned Index);
3296
3297/**
Douglas Gregor3da626b2011-07-07 16:03:39 +00003298 * \brief Determines what compeltions are appropriate for the context
3299 * the given code completion.
3300 *
3301 * \param Results the code completion results to query
3302 *
3303 * \returns the kinds of completions that are appropriate for use
3304 * along with the given code completion results.
3305 */
3306CINDEX_LINKAGE
3307unsigned long long clang_codeCompleteGetContexts(
3308 CXCodeCompleteResults *Results);
Douglas Gregore081a612011-07-21 01:05:26 +00003309
3310/**
3311 * \brief Returns the cursor kind for the container for the current code
3312 * completion context. The container is only guaranteed to be set for
3313 * contexts where a container exists (i.e. member accesses or Objective-C
3314 * message sends); if there is not a container, this function will return
3315 * CXCursor_InvalidCode.
3316 *
3317 * \param Results the code completion results to query
3318 *
3319 * \param IsIncomplete on return, this value will be false if Clang has complete
3320 * information about the container. If Clang does not have complete
3321 * information, this value will be true.
3322 *
3323 * \returns the container kind, or CXCursor_InvalidCode if there is not a
3324 * container
3325 */
3326CINDEX_LINKAGE
3327enum CXCursorKind clang_codeCompleteGetContainerKind(
3328 CXCodeCompleteResults *Results,
3329 unsigned *IsIncomplete);
3330
3331/**
3332 * \brief Returns the USR for the container for the current code completion
3333 * context. If there is not a container for the current context, this
3334 * function will return the empty string.
3335 *
3336 * \param Results the code completion results to query
3337 *
3338 * \returns the USR for the container
3339 */
3340CINDEX_LINKAGE
3341CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
Douglas Gregor3da626b2011-07-07 16:03:39 +00003342
Douglas Gregor0a47d692011-07-26 15:24:30 +00003343
3344/**
3345 * \brief Returns the currently-entered selector for an Objective-C message
3346 * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
3347 * non-empty string for CXCompletionContext_ObjCInstanceMessage and
3348 * CXCompletionContext_ObjCClassMessage.
3349 *
3350 * \param Results the code completion results to query
3351 *
3352 * \returns the selector (or partial selector) that has been entered thus far
3353 * for an Objective-C message send.
3354 */
3355CINDEX_LINKAGE
3356CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
3357
Douglas Gregor3da626b2011-07-07 16:03:39 +00003358/**
Douglas Gregor20d416c2010-01-20 01:10:47 +00003359 * @}
3360 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00003361
3362
Ted Kremenek04bb7162010-01-22 22:44:15 +00003363/**
3364 * \defgroup CINDEX_MISC Miscellaneous utility functions
3365 *
3366 * @{
3367 */
Ted Kremenek23e1ad02010-01-23 17:51:23 +00003368
3369/**
3370 * \brief Return a version string, suitable for showing to a user, but not
3371 * intended to be parsed (the format is not guaranteed to be stable).
3372 */
Ted Kremeneka2a9d6e2010-02-12 22:54:40 +00003373CINDEX_LINKAGE CXString clang_getClangVersion();
Ted Kremenek04bb7162010-01-22 22:44:15 +00003374
Ted Kremenekd2427dd2011-03-18 23:05:39 +00003375
3376/**
3377 * \brief Enable/disable crash recovery.
3378 *
3379 * \param Flag to indicate if crash recovery is enabled. A non-zero value
3380 * enables crash recovery, while 0 disables it.
3381 */
3382CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
3383
Ted Kremenek16b55a72010-01-26 19:31:51 +00003384 /**
Ted Kremenek896b70f2010-03-13 02:50:34 +00003385 * \brief Visitor invoked for each file in a translation unit
Ted Kremenek16b55a72010-01-26 19:31:51 +00003386 * (used with clang_getInclusions()).
3387 *
3388 * This visitor function will be invoked by clang_getInclusions() for each
3389 * file included (either at the top-level or by #include directives) within
3390 * a translation unit. The first argument is the file being included, and
3391 * the second and third arguments provide the inclusion stack. The
3392 * array is sorted in order of immediate inclusion. For example,
3393 * the first element refers to the location that included 'included_file'.
3394 */
3395typedef void (*CXInclusionVisitor)(CXFile included_file,
3396 CXSourceLocation* inclusion_stack,
3397 unsigned include_len,
3398 CXClientData client_data);
3399
3400/**
3401 * \brief Visit the set of preprocessor inclusions in a translation unit.
3402 * The visitor function is called with the provided data for every included
3403 * file. This does not include headers included by the PCH file (unless one
3404 * is inspecting the inclusions in the PCH file itself).
3405 */
3406CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
3407 CXInclusionVisitor visitor,
3408 CXClientData client_data);
3409
3410/**
Ted Kremenek04bb7162010-01-22 22:44:15 +00003411 * @}
3412 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00003413
Argyrios Kyrtzidis97c337c2011-07-11 20:15:00 +00003414/** \defgroup CINDEX_REMAPPING Remapping functions
3415 *
3416 * @{
3417 */
3418
3419/**
3420 * \brief A remapping of original source files and their translated files.
3421 */
3422typedef void *CXRemapping;
3423
3424/**
3425 * \brief Retrieve a remapping.
3426 *
3427 * \param path the path that contains metadata about remappings.
3428 *
3429 * \returns the requested remapping. This remapping must be freed
3430 * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
3431 */
3432CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
3433
3434/**
3435 * \brief Determine the number of remappings.
3436 */
3437CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
3438
3439/**
3440 * \brief Get the original and the associated filename from the remapping.
3441 *
3442 * \param original If non-NULL, will be set to the original filename.
3443 *
3444 * \param transformed If non-NULL, will be set to the filename that the original
3445 * is associated with.
3446 */
3447CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
3448 CXString *original, CXString *transformed);
3449
3450/**
3451 * \brief Dispose the remapping.
3452 */
3453CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
3454
3455/**
3456 * @}
3457 */
3458
Douglas Gregorc42fefa2010-01-22 22:29:16 +00003459/**
3460 * @}
3461 */
Daniel Dunbar1efcf3d2010-01-24 02:54:26 +00003462
Ted Kremenekd2fa5662009-08-26 22:36:44 +00003463#ifdef __cplusplus
3464}
3465#endif
3466#endif
3467