Index.h revision 344779
1198092Srdivacky/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2198092Srdivacky|*                                                                            *|
3198092Srdivacky|*                     The LLVM Compiler Infrastructure                       *|
4198092Srdivacky|*                                                                            *|
5198092Srdivacky|* This file is distributed under the University of Illinois Open Source      *|
6198092Srdivacky|* License. See LICENSE.TXT for details.                                      *|
7198092Srdivacky|*                                                                            *|
8198092Srdivacky|*===----------------------------------------------------------------------===*|
9198092Srdivacky|*                                                                            *|
10321369Sdim|* This header provides a public interface to a Clang library for extracting  *|
11198092Srdivacky|* high-level symbol information from source files without exposing the full  *|
12198092Srdivacky|* Clang C++ API.                                                             *|
13198092Srdivacky|*                                                                            *|
14198092Srdivacky\*===----------------------------------------------------------------------===*/
15198092Srdivacky
16280031Sdim#ifndef LLVM_CLANG_C_INDEX_H
17280031Sdim#define LLVM_CLANG_C_INDEX_H
18198092Srdivacky
19201361Srdivacky#include <time.h>
20198893Srdivacky
21239462Sdim#include "clang-c/Platform.h"
22276479Sdim#include "clang-c/CXErrorCode.h"
23239462Sdim#include "clang-c/CXString.h"
24276479Sdim#include "clang-c/BuildSystem.h"
25239462Sdim
26243830Sdim/**
27341825Sdim * The version constants for the libclang API.
28243830Sdim * CINDEX_VERSION_MINOR should increase when there are API additions.
29243830Sdim * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
30243830Sdim *
31243830Sdim * The policy about the libclang API was always to keep it source and ABI
32243830Sdim * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
33243830Sdim */
34243830Sdim#define CINDEX_VERSION_MAJOR 0
35344779Sdim#define CINDEX_VERSION_MINOR 50
36243830Sdim
37243830Sdim#define CINDEX_VERSION_ENCODE(major, minor) ( \
38243830Sdim      ((major) * 10000)                       \
39243830Sdim    + ((minor) *     1))
40243830Sdim
41243830Sdim#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
42243830Sdim    CINDEX_VERSION_MAJOR,                     \
43243830Sdim    CINDEX_VERSION_MINOR )
44243830Sdim
45243830Sdim#define CINDEX_VERSION_STRINGIZE_(major, minor)   \
46243830Sdim    #major"."#minor
47243830Sdim#define CINDEX_VERSION_STRINGIZE(major, minor)    \
48243830Sdim    CINDEX_VERSION_STRINGIZE_(major, minor)
49243830Sdim
50243830Sdim#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
51243830Sdim    CINDEX_VERSION_MAJOR,                               \
52243830Sdim    CINDEX_VERSION_MINOR)
53243830Sdim
54198092Srdivacky#ifdef __cplusplus
55198092Srdivackyextern "C" {
56198092Srdivacky#endif
57198092Srdivacky
58219077Sdim/** \defgroup CINDEX libclang: C Interface to Clang
59202879Srdivacky *
60203955Srdivacky * The C Interface to Clang provides a relatively small API that exposes
61202879Srdivacky * facilities for parsing source code into an abstract syntax tree (AST),
62202879Srdivacky * loading already-parsed ASTs, traversing the AST, associating
63202879Srdivacky * physical source locations with elements within the AST, and other
64202879Srdivacky * facilities that support Clang-based development tools.
65202879Srdivacky *
66203955Srdivacky * This C interface to Clang will never provide all of the information
67202879Srdivacky * representation stored in Clang's C++ AST, nor should it: the intent is to
68202879Srdivacky * maintain an API that is relatively stable from one release to the next,
69202879Srdivacky * providing only the basic functionality needed to support development tools.
70203955Srdivacky *
71203955Srdivacky * To avoid namespace pollution, data types are prefixed with "CX" and
72202879Srdivacky * functions are prefixed with "clang_".
73202879Srdivacky *
74202879Srdivacky * @{
75202879Srdivacky */
76203955Srdivacky
77202879Srdivacky/**
78341825Sdim * An "index" that consists of a set of translation units that would
79202879Srdivacky * typically be linked together into an executable or library.
80202879Srdivacky */
81202879Srdivackytypedef void *CXIndex;
82198092Srdivacky
83202879Srdivacky/**
84341825Sdim * An opaque type representing target information for a given translation
85321369Sdim * unit.
86321369Sdim */
87321369Sdimtypedef struct CXTargetInfoImpl *CXTargetInfo;
88321369Sdim
89321369Sdim/**
90341825Sdim * A single translation unit, which resides in an index.
91202879Srdivacky */
92218893Sdimtypedef struct CXTranslationUnitImpl *CXTranslationUnit;
93198092Srdivacky
94200583Srdivacky/**
95341825Sdim * Opaque pointer representing client data that will be passed through
96202879Srdivacky * to various callbacks and visitors.
97202879Srdivacky */
98202879Srdivackytypedef void *CXClientData;
99203955Srdivacky
100202879Srdivacky/**
101341825Sdim * Provides the contents of a file that has not yet been saved to disk.
102200583Srdivacky *
103200583Srdivacky * Each CXUnsavedFile instance provides the name of a file on the
104200583Srdivacky * system along with the current contents of that file that have not
105200583Srdivacky * yet been saved to disk.
106200583Srdivacky */
107200583Srdivackystruct CXUnsavedFile {
108203955Srdivacky  /**
109341825Sdim   * The file whose contents have not yet been saved.
110200583Srdivacky   *
111200583Srdivacky   * This file must already exist in the file system.
112200583Srdivacky   */
113200583Srdivacky  const char *Filename;
114200583Srdivacky
115203955Srdivacky  /**
116341825Sdim   * A buffer containing the unsaved contents of this file.
117200583Srdivacky   */
118200583Srdivacky  const char *Contents;
119200583Srdivacky
120200583Srdivacky  /**
121341825Sdim   * The length of the unsaved contents of this buffer.
122200583Srdivacky   */
123200583Srdivacky  unsigned long Length;
124200583Srdivacky};
125200583Srdivacky
126199482Srdivacky/**
127341825Sdim * Describes the availability of a particular entity, which indicates
128212904Sdim * whether the use of this entity will result in a warning or error due to
129212904Sdim * it being deprecated or unavailable.
130212904Sdim */
131212904Sdimenum CXAvailabilityKind {
132212904Sdim  /**
133341825Sdim   * The entity is available.
134212904Sdim   */
135212904Sdim  CXAvailability_Available,
136212904Sdim  /**
137341825Sdim   * The entity is available, but has been deprecated (and its use is
138212904Sdim   * not recommended).
139212904Sdim   */
140212904Sdim  CXAvailability_Deprecated,
141212904Sdim  /**
142341825Sdim   * The entity is not available; any use of it will be an error.
143212904Sdim   */
144226633Sdim  CXAvailability_NotAvailable,
145226633Sdim  /**
146341825Sdim   * The entity is available, but not accessible; any use of it will be
147226633Sdim   * an error.
148226633Sdim   */
149226633Sdim  CXAvailability_NotAccessible
150212904Sdim};
151203955Srdivacky
152202879Srdivacky/**
153341825Sdim * Describes a version number of the form major.minor.subminor.
154202879Srdivacky */
155239462Sdimtypedef struct CXVersion {
156239462Sdim  /**
157341825Sdim   * The major version number, e.g., the '10' in '10.7.3'. A negative
158239462Sdim   * value indicates that there is no version number at all.
159239462Sdim   */
160239462Sdim  int Major;
161239462Sdim  /**
162341825Sdim   * The minor version number, e.g., the '7' in '10.7.3'. This value
163341825Sdim   * will be negative if no minor version number was provided, e.g., for
164239462Sdim   * version '10'.
165239462Sdim   */
166239462Sdim  int Minor;
167239462Sdim  /**
168341825Sdim   * The subminor version number, e.g., the '3' in '10.7.3'. This value
169239462Sdim   * will be negative if no minor or subminor version number was provided,
170239462Sdim   * e.g., in version '10' or '10.7'.
171239462Sdim   */
172239462Sdim  int Subminor;
173239462Sdim} CXVersion;
174321369Sdim
175202879Srdivacky/**
176341825Sdim * Describes the exception specification of a cursor.
177321369Sdim *
178321369Sdim * A negative value indicates that the cursor is not a function declaration.
179321369Sdim */
180321369Sdimenum CXCursor_ExceptionSpecificationKind {
181321369Sdim  /**
182341825Sdim   * The cursor has no exception specification.
183321369Sdim   */
184321369Sdim  CXCursor_ExceptionSpecificationKind_None,
185321369Sdim
186321369Sdim  /**
187341825Sdim   * The cursor has exception specification throw()
188321369Sdim   */
189321369Sdim  CXCursor_ExceptionSpecificationKind_DynamicNone,
190321369Sdim
191321369Sdim  /**
192341825Sdim   * The cursor has exception specification throw(T1, T2)
193321369Sdim   */
194321369Sdim  CXCursor_ExceptionSpecificationKind_Dynamic,
195321369Sdim
196321369Sdim  /**
197341825Sdim   * The cursor has exception specification throw(...).
198321369Sdim   */
199321369Sdim  CXCursor_ExceptionSpecificationKind_MSAny,
200321369Sdim
201321369Sdim  /**
202341825Sdim   * The cursor has exception specification basic noexcept.
203321369Sdim   */
204321369Sdim  CXCursor_ExceptionSpecificationKind_BasicNoexcept,
205321369Sdim
206321369Sdim  /**
207341825Sdim   * The cursor has exception specification computed noexcept.
208321369Sdim   */
209321369Sdim  CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
210321369Sdim
211321369Sdim  /**
212341825Sdim   * The exception specification has not yet been evaluated.
213321369Sdim   */
214321369Sdim  CXCursor_ExceptionSpecificationKind_Unevaluated,
215321369Sdim
216321369Sdim  /**
217341825Sdim   * The exception specification has not yet been instantiated.
218321369Sdim   */
219321369Sdim  CXCursor_ExceptionSpecificationKind_Uninstantiated,
220321369Sdim
221321369Sdim  /**
222341825Sdim   * The exception specification has not been parsed yet.
223321369Sdim   */
224321369Sdim  CXCursor_ExceptionSpecificationKind_Unparsed
225321369Sdim};
226321369Sdim
227321369Sdim/**
228341825Sdim * Provides a shared context for creating translation units.
229198398Srdivacky *
230239462Sdim * It provides two options:
231239462Sdim *
232198398Srdivacky * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
233198398Srdivacky * declarations (when loading any new translation units). A "local" declaration
234203955Srdivacky * is one that belongs in the translation unit itself and not in a precompiled
235198398Srdivacky * header that was used by the translation unit. If zero, all declarations
236198398Srdivacky * will be enumerated.
237198398Srdivacky *
238198398Srdivacky * Here is an example:
239198398Srdivacky *
240239462Sdim * \code
241204643Srdivacky *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
242204643Srdivacky *   Idx = clang_createIndex(1, 1);
243198398Srdivacky *
244198398Srdivacky *   // IndexTest.pch was produced with the following command:
245198398Srdivacky *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
246198398Srdivacky *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
247198398Srdivacky *
248198398Srdivacky *   // This will load all the symbols from 'IndexTest.pch'
249203955Srdivacky *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
250202879Srdivacky *                       TranslationUnitVisitor, 0);
251198398Srdivacky *   clang_disposeTranslationUnit(TU);
252198398Srdivacky *
253198398Srdivacky *   // This will load all the symbols from 'IndexTest.c', excluding symbols
254198398Srdivacky *   // from 'IndexTest.pch'.
255203955Srdivacky *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
256203955Srdivacky *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
257203955Srdivacky *                                                  0, 0);
258202879Srdivacky *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
259202879Srdivacky *                       TranslationUnitVisitor, 0);
260198398Srdivacky *   clang_disposeTranslationUnit(TU);
261239462Sdim * \endcode
262198398Srdivacky *
263198398Srdivacky * This process of creating the 'pch', loading it separately, and using it (via
264198398Srdivacky * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
265198398Srdivacky * (which gives the indexer the same performance benefit as the compiler).
266198398Srdivacky */
267204643SrdivackyCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
268204643Srdivacky                                         int displayDiagnostics);
269205219Srdivacky
270203955Srdivacky/**
271341825Sdim * Destroy the given index.
272203955Srdivacky *
273203955Srdivacky * The index must not be destroyed until all of the translation units created
274203955Srdivacky * within that index have been destroyed.
275203955Srdivacky */
276200583SrdivackyCINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
277198092Srdivacky
278234353Sdimtypedef enum {
279234353Sdim  /**
280341825Sdim   * Used to indicate that no special CXIndex options are needed.
281234353Sdim   */
282234353Sdim  CXGlobalOpt_None = 0x0,
283234353Sdim
284234353Sdim  /**
285341825Sdim   * Used to indicate that threads that libclang creates for indexing
286234353Sdim   * purposes should use background priority.
287239462Sdim   *
288239462Sdim   * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
289239462Sdim   * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
290234353Sdim   */
291234353Sdim  CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
292234353Sdim
293234353Sdim  /**
294341825Sdim   * Used to indicate that threads that libclang creates for editing
295234353Sdim   * purposes should use background priority.
296239462Sdim   *
297239462Sdim   * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
298239462Sdim   * #clang_annotateTokens
299234353Sdim   */
300234353Sdim  CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
301234353Sdim
302234353Sdim  /**
303341825Sdim   * Used to indicate that all threads that libclang creates should use
304234353Sdim   * background priority.
305234353Sdim   */
306234353Sdim  CXGlobalOpt_ThreadBackgroundPriorityForAll =
307234353Sdim      CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
308234353Sdim      CXGlobalOpt_ThreadBackgroundPriorityForEditing
309234353Sdim
310234353Sdim} CXGlobalOptFlags;
311234353Sdim
312202879Srdivacky/**
313341825Sdim * Sets general options associated with a CXIndex.
314234353Sdim *
315234353Sdim * For example:
316234353Sdim * \code
317234353Sdim * CXIndex idx = ...;
318234353Sdim * clang_CXIndex_setGlobalOptions(idx,
319234353Sdim *     clang_CXIndex_getGlobalOptions(idx) |
320234353Sdim *     CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
321234353Sdim * \endcode
322234353Sdim *
323234353Sdim * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
324234353Sdim */
325234353SdimCINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
326234353Sdim
327234353Sdim/**
328341825Sdim * Gets the general options associated with a CXIndex.
329234353Sdim *
330234353Sdim * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
331234353Sdim * are associated with the given CXIndex object.
332234353Sdim */
333234353SdimCINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
334234353Sdim
335234353Sdim/**
336341825Sdim * Sets the invocation emission path option in a CXIndex.
337327952Sdim *
338327952Sdim * The invocation emission path specifies a path which will contain log
339327952Sdim * files for certain libclang invocations. A null value (default) implies that
340327952Sdim * libclang invocations are not logged..
341327952Sdim */
342327952SdimCINDEX_LINKAGE void
343327952Sdimclang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
344327952Sdim
345327952Sdim/**
346202879Srdivacky * \defgroup CINDEX_FILES File manipulation routines
347202879Srdivacky *
348202879Srdivacky * @{
349202879Srdivacky */
350203955Srdivacky
351202879Srdivacky/**
352341825Sdim * A particular source file that is part of a translation unit.
353202879Srdivacky */
354202879Srdivackytypedef void *CXFile;
355198092Srdivacky
356202879Srdivacky/**
357341825Sdim * Retrieve the complete file and path name of the given file.
358202879Srdivacky */
359204643SrdivackyCINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
360203955Srdivacky
361202879Srdivacky/**
362341825Sdim * Retrieve the last modification time of the given file.
363202879Srdivacky */
364202879SrdivackyCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
365198092Srdivacky
366202879Srdivacky/**
367341825Sdim * Uniquely identifies a CXFile, that refers to the same underlying file,
368249423Sdim * across an indexing session.
369249423Sdim */
370249423Sdimtypedef struct {
371249423Sdim  unsigned long long data[3];
372249423Sdim} CXFileUniqueID;
373249423Sdim
374249423Sdim/**
375341825Sdim * Retrieve the unique ID for the given \c file.
376249423Sdim *
377249423Sdim * \param file the file to get the ID for.
378249423Sdim * \param outID stores the returned CXFileUniqueID.
379249423Sdim * \returns If there was a failure getting the unique ID, returns non-zero,
380249423Sdim * otherwise returns 0.
381249423Sdim*/
382249423SdimCINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
383249423Sdim
384249423Sdim/**
385341825Sdim * Determine whether the given header is guarded against
386223017Sdim * multiple inclusions, either with the conventional
387239462Sdim * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
388223017Sdim */
389341825SdimCINDEX_LINKAGE unsigned
390223017Sdimclang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
391223017Sdim
392223017Sdim/**
393341825Sdim * Retrieve a file handle within the given translation unit.
394202879Srdivacky *
395202879Srdivacky * \param tu the translation unit
396203955Srdivacky *
397314564Sdim * \param file_name the name of the file.
398202879Srdivacky *
399202879Srdivacky * \returns the file handle for the named file in the translation unit \p tu,
400202879Srdivacky * or a NULL file handle if the file was not a part of this translation unit.
401202879Srdivacky */
402203955SrdivackyCINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
403202879Srdivacky                                    const char *file_name);
404203955Srdivacky
405202879Srdivacky/**
406341825Sdim * Retrieve the buffer associated with the given file.
407327952Sdim *
408327952Sdim * \param tu the translation unit
409327952Sdim *
410327952Sdim * \param file the file for which to retrieve the buffer.
411327952Sdim *
412327952Sdim * \param size [out] if non-NULL, will be set to the size of the buffer.
413327952Sdim *
414327952Sdim * \returns a pointer to the buffer in memory that holds the contents of
415327952Sdim * \p file, or a NULL pointer when the file is not loaded.
416327952Sdim */
417327952SdimCINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
418327952Sdim                                                 CXFile file, size_t *size);
419327952Sdim
420327952Sdim/**
421341825Sdim * Returns non-zero if the \c file1 and \c file2 point to the same file,
422280031Sdim * or they are both NULL.
423280031Sdim */
424280031SdimCINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
425280031Sdim
426280031Sdim/**
427341825Sdim * Returns the real path name of \c file.
428341825Sdim *
429341825Sdim * An empty string may be returned. Use \c clang_getFileName() in that case.
430341825Sdim */
431341825SdimCINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
432341825Sdim
433341825Sdim/**
434202879Srdivacky * @}
435202879Srdivacky */
436198092Srdivacky
437202879Srdivacky/**
438202879Srdivacky * \defgroup CINDEX_LOCATIONS Physical source locations
439202879Srdivacky *
440202879Srdivacky * Clang represents physical source locations in its abstract syntax tree in
441202879Srdivacky * great detail, with file, line, and column information for the majority of
442202879Srdivacky * the tokens parsed in the source code. These data types and functions are
443202879Srdivacky * used to represent source location information, either for a particular
444202879Srdivacky * point in the program or for a range of points in the program, and extract
445202879Srdivacky * specific location information from those data types.
446202879Srdivacky *
447202879Srdivacky * @{
448202879Srdivacky */
449203955Srdivacky
450202879Srdivacky/**
451341825Sdim * Identifies a specific source location within a translation
452202879Srdivacky * unit.
453202879Srdivacky *
454226633Sdim * Use clang_getExpansionLocation() or clang_getSpellingLocation()
455218893Sdim * to map a source location to a particular file, line, and column.
456202879Srdivacky */
457202879Srdivackytypedef struct {
458249423Sdim  const void *ptr_data[2];
459202879Srdivacky  unsigned int_data;
460202879Srdivacky} CXSourceLocation;
461198092Srdivacky
462202879Srdivacky/**
463341825Sdim * Identifies a half-open character range in the source code.
464202879Srdivacky *
465202879Srdivacky * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
466202879Srdivacky * starting and end locations from a source range, respectively.
467198893Srdivacky */
468202879Srdivackytypedef struct {
469249423Sdim  const void *ptr_data[2];
470202879Srdivacky  unsigned begin_int_data;
471202879Srdivacky  unsigned end_int_data;
472202879Srdivacky} CXSourceRange;
473198893Srdivacky
474202879Srdivacky/**
475341825Sdim * Retrieve a NULL (invalid) source location.
476198092Srdivacky */
477249423SdimCINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
478203955Srdivacky
479202879Srdivacky/**
480341825Sdim * Determine whether two source locations, which must refer into
481203955Srdivacky * the same translation unit, refer to exactly the same point in the source
482202879Srdivacky * code.
483202879Srdivacky *
484202879Srdivacky * \returns non-zero if the source locations refer to the same location, zero
485202879Srdivacky * if they refer to different locations.
486202879Srdivacky */
487202879SrdivackyCINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
488202879Srdivacky                                             CXSourceLocation loc2);
489203955Srdivacky
490202879Srdivacky/**
491341825Sdim * Retrieves the source location associated with a given file/line/column
492203955Srdivacky * in a particular translation unit.
493202879Srdivacky */
494202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
495202879Srdivacky                                                  CXFile file,
496202879Srdivacky                                                  unsigned line,
497202879Srdivacky                                                  unsigned column);
498218893Sdim/**
499341825Sdim * Retrieves the source location associated with a given character offset
500218893Sdim * in a particular translation unit.
501218893Sdim */
502218893SdimCINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
503218893Sdim                                                           CXFile file,
504218893Sdim                                                           unsigned offset);
505203955Srdivacky
506203955Srdivacky/**
507341825Sdim * Returns non-zero if the given source location is in a system header.
508251662Sdim */
509251662SdimCINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
510251662Sdim
511251662Sdim/**
512341825Sdim * Returns non-zero if the given source location is in the main file of
513261991Sdim * the corresponding translation unit.
514261991Sdim */
515261991SdimCINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
516261991Sdim
517261991Sdim/**
518341825Sdim * Retrieve a NULL (invalid) source range.
519203955Srdivacky */
520249423SdimCINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
521205219Srdivacky
522202879Srdivacky/**
523341825Sdim * Retrieve a source range given the beginning and ending source
524202879Srdivacky * locations.
525202879Srdivacky */
526202879SrdivackyCINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
527202879Srdivacky                                            CXSourceLocation end);
528203955Srdivacky
529202879Srdivacky/**
530341825Sdim * Determine whether two ranges are equivalent.
531226633Sdim *
532226633Sdim * \returns non-zero if the ranges are the same, zero if they differ.
533226633Sdim */
534226633SdimCINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
535226633Sdim                                          CXSourceRange range2);
536226633Sdim
537226633Sdim/**
538341825Sdim * Returns non-zero if \p range is null.
539226633Sdim */
540226633SdimCINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
541226633Sdim
542226633Sdim/**
543341825Sdim * Retrieve the file, line, column, and offset represented by
544203955Srdivacky * the given source location.
545202879Srdivacky *
546226633Sdim * If the location refers into a macro expansion, retrieves the
547226633Sdim * location of the macro expansion.
548218893Sdim *
549203955Srdivacky * \param location the location within a source file that will be decomposed
550203955Srdivacky * into its parts.
551202879Srdivacky *
552203955Srdivacky * \param file [out] if non-NULL, will be set to the file to which the given
553202879Srdivacky * source location points.
554202879Srdivacky *
555203955Srdivacky * \param line [out] if non-NULL, will be set to the line to which the given
556202879Srdivacky * source location points.
557202879Srdivacky *
558203955Srdivacky * \param column [out] if non-NULL, will be set to the column to which the given
559203955Srdivacky * source location points.
560203955Srdivacky *
561203955Srdivacky * \param offset [out] if non-NULL, will be set to the offset into the
562203955Srdivacky * buffer to which the given source location points.
563202879Srdivacky */
564226633SdimCINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
565226633Sdim                                               CXFile *file,
566226633Sdim                                               unsigned *line,
567226633Sdim                                               unsigned *column,
568226633Sdim                                               unsigned *offset);
569226633Sdim
570226633Sdim/**
571341825Sdim * Retrieve the file, line and column represented by the given source
572321369Sdim * location, as specified in a # line directive.
573226633Sdim *
574226633Sdim * Example: given the following source code in a file somefile.c
575226633Sdim *
576239462Sdim * \code
577226633Sdim * #123 "dummy.c" 1
578226633Sdim *
579226633Sdim * static int func(void)
580226633Sdim * {
581226633Sdim *     return 0;
582226633Sdim * }
583239462Sdim * \endcode
584226633Sdim *
585226633Sdim * the location information returned by this function would be
586226633Sdim *
587226633Sdim * File: dummy.c Line: 124 Column: 12
588226633Sdim *
589226633Sdim * whereas clang_getExpansionLocation would have returned
590226633Sdim *
591226633Sdim * File: somefile.c Line: 3 Column: 12
592226633Sdim *
593226633Sdim * \param location the location within a source file that will be decomposed
594226633Sdim * into its parts.
595226633Sdim *
596226633Sdim * \param filename [out] if non-NULL, will be set to the filename of the
597226633Sdim * source location. Note that filenames returned will be for "virtual" files,
598226633Sdim * which don't necessarily exist on the machine running clang - e.g. when
599226633Sdim * parsing preprocessed output obtained from a different environment. If
600226633Sdim * a non-NULL value is passed in, remember to dispose of the returned value
601226633Sdim * using \c clang_disposeString() once you've finished with it. For an invalid
602226633Sdim * source location, an empty string is returned.
603226633Sdim *
604226633Sdim * \param line [out] if non-NULL, will be set to the line number of the
605226633Sdim * source location. For an invalid source location, zero is returned.
606226633Sdim *
607226633Sdim * \param column [out] if non-NULL, will be set to the column number of the
608226633Sdim * source location. For an invalid source location, zero is returned.
609226633Sdim */
610226633SdimCINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
611226633Sdim                                              CXString *filename,
612226633Sdim                                              unsigned *line,
613226633Sdim                                              unsigned *column);
614226633Sdim
615226633Sdim/**
616341825Sdim * Legacy API to retrieve the file, line, column, and offset represented
617226633Sdim * by the given source location.
618226633Sdim *
619226633Sdim * This interface has been replaced by the newer interface
620239462Sdim * #clang_getExpansionLocation(). See that interface's documentation for
621226633Sdim * details.
622226633Sdim */
623202879SrdivackyCINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
624202879Srdivacky                                                   CXFile *file,
625202879Srdivacky                                                   unsigned *line,
626203955Srdivacky                                                   unsigned *column,
627203955Srdivacky                                                   unsigned *offset);
628202379Srdivacky
629202879Srdivacky/**
630341825Sdim * Retrieve the file, line, column, and offset represented by
631218893Sdim * the given source location.
632218893Sdim *
633218893Sdim * If the location refers into a macro instantiation, return where the
634218893Sdim * location was originally spelled in the source file.
635218893Sdim *
636218893Sdim * \param location the location within a source file that will be decomposed
637218893Sdim * into its parts.
638218893Sdim *
639218893Sdim * \param file [out] if non-NULL, will be set to the file to which the given
640218893Sdim * source location points.
641218893Sdim *
642218893Sdim * \param line [out] if non-NULL, will be set to the line to which the given
643218893Sdim * source location points.
644218893Sdim *
645218893Sdim * \param column [out] if non-NULL, will be set to the column to which the given
646218893Sdim * source location points.
647218893Sdim *
648218893Sdim * \param offset [out] if non-NULL, will be set to the offset into the
649218893Sdim * buffer to which the given source location points.
650218893Sdim */
651218893SdimCINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
652218893Sdim                                              CXFile *file,
653218893Sdim                                              unsigned *line,
654218893Sdim                                              unsigned *column,
655218893Sdim                                              unsigned *offset);
656218893Sdim
657218893Sdim/**
658341825Sdim * Retrieve the file, line, column, and offset represented by
659249423Sdim * the given source location.
660249423Sdim *
661249423Sdim * If the location refers into a macro expansion, return where the macro was
662249423Sdim * expanded or where the macro argument was written, if the location points at
663249423Sdim * a macro argument.
664249423Sdim *
665249423Sdim * \param location the location within a source file that will be decomposed
666249423Sdim * into its parts.
667249423Sdim *
668249423Sdim * \param file [out] if non-NULL, will be set to the file to which the given
669249423Sdim * source location points.
670249423Sdim *
671249423Sdim * \param line [out] if non-NULL, will be set to the line to which the given
672249423Sdim * source location points.
673249423Sdim *
674249423Sdim * \param column [out] if non-NULL, will be set to the column to which the given
675249423Sdim * source location points.
676249423Sdim *
677249423Sdim * \param offset [out] if non-NULL, will be set to the offset into the
678249423Sdim * buffer to which the given source location points.
679249423Sdim */
680249423SdimCINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
681249423Sdim                                          CXFile *file,
682249423Sdim                                          unsigned *line,
683249423Sdim                                          unsigned *column,
684249423Sdim                                          unsigned *offset);
685249423Sdim
686249423Sdim/**
687341825Sdim * Retrieve a source location representing the first character within a
688203955Srdivacky * source range.
689198092Srdivacky */
690202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
691198092Srdivacky
692202879Srdivacky/**
693341825Sdim * Retrieve a source location representing the last character within a
694203955Srdivacky * source range.
695202879Srdivacky */
696202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
697202379Srdivacky
698202879Srdivacky/**
699341825Sdim * Identifies an array of ranges.
700276479Sdim */
701276479Sdimtypedef struct {
702341825Sdim  /** The number of ranges in the \c ranges array. */
703276479Sdim  unsigned count;
704276479Sdim  /**
705341825Sdim   * An array of \c CXSourceRanges.
706276479Sdim   */
707276479Sdim  CXSourceRange *ranges;
708276479Sdim} CXSourceRangeList;
709276479Sdim
710276479Sdim/**
711341825Sdim * Retrieve all ranges that were skipped by the preprocessor.
712276479Sdim *
713276479Sdim * The preprocessor will skip lines when they are surrounded by an
714276479Sdim * if/ifdef/ifndef directive whose condition does not evaluate to true.
715276479Sdim */
716276479SdimCINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
717276479Sdim                                                         CXFile file);
718276479Sdim
719276479Sdim/**
720341825Sdim * Retrieve all ranges from all files that were skipped by the
721314564Sdim * preprocessor.
722314564Sdim *
723314564Sdim * The preprocessor will skip lines when they are surrounded by an
724314564Sdim * if/ifdef/ifndef directive whose condition does not evaluate to true.
725314564Sdim */
726314564SdimCINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
727314564Sdim
728314564Sdim/**
729341825Sdim * Destroy the given \c CXSourceRangeList.
730276479Sdim */
731276479SdimCINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
732276479Sdim
733276479Sdim/**
734202879Srdivacky * @}
735202879Srdivacky */
736202379Srdivacky
737202879Srdivacky/**
738203955Srdivacky * \defgroup CINDEX_DIAG Diagnostic reporting
739203955Srdivacky *
740203955Srdivacky * @{
741203955Srdivacky */
742203955Srdivacky
743203955Srdivacky/**
744341825Sdim * Describes the severity of a particular diagnostic.
745203955Srdivacky */
746203955Srdivackyenum CXDiagnosticSeverity {
747203955Srdivacky  /**
748341825Sdim   * A diagnostic that has been suppressed, e.g., by a command-line
749203955Srdivacky   * option.
750203955Srdivacky   */
751203955Srdivacky  CXDiagnostic_Ignored = 0,
752205219Srdivacky
753203955Srdivacky  /**
754341825Sdim   * This diagnostic is a note that should be attached to the
755203955Srdivacky   * previous (non-note) diagnostic.
756203955Srdivacky   */
757203955Srdivacky  CXDiagnostic_Note    = 1,
758203955Srdivacky
759203955Srdivacky  /**
760341825Sdim   * This diagnostic indicates suspicious code that may not be
761203955Srdivacky   * wrong.
762203955Srdivacky   */
763203955Srdivacky  CXDiagnostic_Warning = 2,
764203955Srdivacky
765203955Srdivacky  /**
766341825Sdim   * This diagnostic indicates that the code is ill-formed.
767203955Srdivacky   */
768203955Srdivacky  CXDiagnostic_Error   = 3,
769203955Srdivacky
770203955Srdivacky  /**
771341825Sdim   * This diagnostic indicates that the code is ill-formed such
772203955Srdivacky   * that future parser recovery is unlikely to produce useful
773203955Srdivacky   * results.
774203955Srdivacky   */
775203955Srdivacky  CXDiagnostic_Fatal   = 4
776203955Srdivacky};
777203955Srdivacky
778203955Srdivacky/**
779341825Sdim * A single diagnostic, containing the diagnostic's severity,
780204643Srdivacky * location, text, source ranges, and fix-it hints.
781203955Srdivacky */
782204643Srdivackytypedef void *CXDiagnostic;
783204643Srdivacky
784204643Srdivacky/**
785341825Sdim * A group of CXDiagnostics.
786234353Sdim */
787234353Sdimtypedef void *CXDiagnosticSet;
788341825Sdim
789234353Sdim/**
790341825Sdim * Determine the number of diagnostics in a CXDiagnosticSet.
791234353Sdim */
792234353SdimCINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
793234353Sdim
794234353Sdim/**
795341825Sdim * Retrieve a diagnostic associated with the given CXDiagnosticSet.
796234353Sdim *
797239462Sdim * \param Diags the CXDiagnosticSet to query.
798234353Sdim * \param Index the zero-based diagnostic number to retrieve.
799234353Sdim *
800234353Sdim * \returns the requested diagnostic. This diagnostic must be freed
801234353Sdim * via a call to \c clang_disposeDiagnostic().
802234353Sdim */
803234353SdimCINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
804341825Sdim                                                     unsigned Index);
805234353Sdim
806234353Sdim/**
807341825Sdim * Describes the kind of error that occurred (if any) in a call to
808234353Sdim * \c clang_loadDiagnostics.
809234353Sdim */
810234353Sdimenum CXLoadDiag_Error {
811234353Sdim  /**
812341825Sdim   * Indicates that no error occurred.
813234353Sdim   */
814234353Sdim  CXLoadDiag_None = 0,
815341825Sdim
816234353Sdim  /**
817341825Sdim   * Indicates that an unknown error occurred while attempting to
818234353Sdim   * deserialize diagnostics.
819234353Sdim   */
820234353Sdim  CXLoadDiag_Unknown = 1,
821341825Sdim
822234353Sdim  /**
823341825Sdim   * Indicates that the file containing the serialized diagnostics
824234353Sdim   * could not be opened.
825234353Sdim   */
826234353Sdim  CXLoadDiag_CannotLoad = 2,
827341825Sdim
828234353Sdim  /**
829341825Sdim   * Indicates that the serialized diagnostics file is invalid or
830239462Sdim   * corrupt.
831234353Sdim   */
832234353Sdim  CXLoadDiag_InvalidFile = 3
833234353Sdim};
834341825Sdim
835234353Sdim/**
836341825Sdim * Deserialize a set of diagnostics from a Clang diagnostics bitcode
837239462Sdim * file.
838234353Sdim *
839239462Sdim * \param file The name of the file to deserialize.
840239462Sdim * \param error A pointer to a enum value recording if there was a problem
841234353Sdim *        deserializing the diagnostics.
842239462Sdim * \param errorString A pointer to a CXString for recording the error string
843234353Sdim *        if the file was not successfully loaded.
844234353Sdim *
845234353Sdim * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise.  These
846239462Sdim * diagnostics should be released using clang_disposeDiagnosticSet().
847234353Sdim */
848234353SdimCINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
849234353Sdim                                                  enum CXLoadDiag_Error *error,
850234353Sdim                                                  CXString *errorString);
851234353Sdim
852234353Sdim/**
853341825Sdim * Release a CXDiagnosticSet and all of its contained diagnostics.
854234353Sdim */
855234353SdimCINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
856234353Sdim
857234353Sdim/**
858341825Sdim * Retrieve the child diagnostics of a CXDiagnostic.
859239462Sdim *
860239462Sdim * This CXDiagnosticSet does not need to be released by
861261991Sdim * clang_disposeDiagnosticSet.
862234353Sdim */
863234353SdimCINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
864234353Sdim
865234353Sdim/**
866341825Sdim * Determine the number of diagnostics produced for the given
867204643Srdivacky * translation unit.
868204643Srdivacky */
869204643SrdivackyCINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
870204643Srdivacky
871204643Srdivacky/**
872341825Sdim * Retrieve a diagnostic associated with the given translation unit.
873204643Srdivacky *
874204643Srdivacky * \param Unit the translation unit to query.
875204643Srdivacky * \param Index the zero-based diagnostic number to retrieve.
876204643Srdivacky *
877204643Srdivacky * \returns the requested diagnostic. This diagnostic must be freed
878204643Srdivacky * via a call to \c clang_disposeDiagnostic().
879204643Srdivacky */
880204643SrdivackyCINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
881204643Srdivacky                                                unsigned Index);
882204643Srdivacky
883204643Srdivacky/**
884341825Sdim * Retrieve the complete set of diagnostics associated with a
885234353Sdim *        translation unit.
886234353Sdim *
887234353Sdim * \param Unit the translation unit to query.
888234353Sdim */
889234353SdimCINDEX_LINKAGE CXDiagnosticSet
890341825Sdim  clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
891234353Sdim
892234353Sdim/**
893341825Sdim * Destroy a diagnostic.
894204643Srdivacky */
895204643SrdivackyCINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
896204643Srdivacky
897204643Srdivacky/**
898341825Sdim * Options to control the display of diagnostics.
899204643Srdivacky *
900204643Srdivacky * The values in this enum are meant to be combined to customize the
901261991Sdim * behavior of \c clang_formatDiagnostic().
902204643Srdivacky */
903204643Srdivackyenum CXDiagnosticDisplayOptions {
904203955Srdivacky  /**
905341825Sdim   * Display the source-location information where the
906204643Srdivacky   * diagnostic was located.
907204643Srdivacky   *
908204643Srdivacky   * When set, diagnostics will be prefixed by the file, line, and
909204643Srdivacky   * (optionally) column to which the diagnostic refers. For example,
910204643Srdivacky   *
911204643Srdivacky   * \code
912204643Srdivacky   * test.c:28: warning: extra tokens at end of #endif directive
913204643Srdivacky   * \endcode
914204643Srdivacky   *
915204643Srdivacky   * This option corresponds to the clang flag \c -fshow-source-location.
916203955Srdivacky   */
917204643Srdivacky  CXDiagnostic_DisplaySourceLocation = 0x01,
918203955Srdivacky
919203955Srdivacky  /**
920341825Sdim   * If displaying the source-location information of the
921204643Srdivacky   * diagnostic, also include the column number.
922204643Srdivacky   *
923204643Srdivacky   * This option corresponds to the clang flag \c -fshow-column.
924203955Srdivacky   */
925204643Srdivacky  CXDiagnostic_DisplayColumn = 0x02,
926203955Srdivacky
927203955Srdivacky  /**
928341825Sdim   * If displaying the source-location information of the
929204643Srdivacky   * diagnostic, also include information about source ranges in a
930204643Srdivacky   * machine-parsable format.
931204643Srdivacky   *
932205219Srdivacky   * This option corresponds to the clang flag
933204643Srdivacky   * \c -fdiagnostics-print-source-range-info.
934203955Srdivacky   */
935218893Sdim  CXDiagnostic_DisplaySourceRanges = 0x04,
936341825Sdim
937218893Sdim  /**
938341825Sdim   * Display the option name associated with this diagnostic, if any.
939218893Sdim   *
940218893Sdim   * The option name displayed (e.g., -Wconversion) will be placed in brackets
941218893Sdim   * after the diagnostic text. This option corresponds to the clang flag
942218893Sdim   * \c -fdiagnostics-show-option.
943218893Sdim   */
944218893Sdim  CXDiagnostic_DisplayOption = 0x08,
945341825Sdim
946218893Sdim  /**
947341825Sdim   * Display the category number associated with this diagnostic, if any.
948218893Sdim   *
949218893Sdim   * The category number is displayed within brackets after the diagnostic text.
950341825Sdim   * This option corresponds to the clang flag
951218893Sdim   * \c -fdiagnostics-show-category=id.
952218893Sdim   */
953218893Sdim  CXDiagnostic_DisplayCategoryId = 0x10,
954218893Sdim
955218893Sdim  /**
956341825Sdim   * Display the category name associated with this diagnostic, if any.
957218893Sdim   *
958218893Sdim   * The category name is displayed within brackets after the diagnostic text.
959341825Sdim   * This option corresponds to the clang flag
960218893Sdim   * \c -fdiagnostics-show-category=name.
961218893Sdim   */
962218893Sdim  CXDiagnostic_DisplayCategoryName = 0x20
963203955Srdivacky};
964203955Srdivacky
965203955Srdivacky/**
966341825Sdim * Format the given diagnostic in a manner that is suitable for display.
967204643Srdivacky *
968204643Srdivacky * This routine will format the given diagnostic to a string, rendering
969205219Srdivacky * the diagnostic according to the various options given. The
970205219Srdivacky * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
971204643Srdivacky * options that most closely mimics the behavior of the clang compiler.
972204643Srdivacky *
973204643Srdivacky * \param Diagnostic The diagnostic to print.
974204643Srdivacky *
975205219Srdivacky * \param Options A set of options that control the diagnostic display,
976204643Srdivacky * created by combining \c CXDiagnosticDisplayOptions values.
977204643Srdivacky *
978204643Srdivacky * \returns A new string containing for formatted diagnostic.
979203955Srdivacky */
980204643SrdivackyCINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
981204643Srdivacky                                               unsigned Options);
982203955Srdivacky
983203955Srdivacky/**
984341825Sdim * Retrieve the set of display options most similar to the
985204643Srdivacky * default behavior of the clang compiler.
986203955Srdivacky *
987204643Srdivacky * \returns A set of display options suitable for use with \c
988261991Sdim * clang_formatDiagnostic().
989203955Srdivacky */
990204643SrdivackyCINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
991203955Srdivacky
992203955Srdivacky/**
993341825Sdim * Determine the severity of the given diagnostic.
994203955Srdivacky */
995205219SrdivackyCINDEX_LINKAGE enum CXDiagnosticSeverity
996203955Srdivackyclang_getDiagnosticSeverity(CXDiagnostic);
997203955Srdivacky
998203955Srdivacky/**
999341825Sdim * Retrieve the source location of the given diagnostic.
1000203955Srdivacky *
1001203955Srdivacky * This location is where Clang would print the caret ('^') when
1002203955Srdivacky * displaying the diagnostic on the command line.
1003203955Srdivacky */
1004203955SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
1005203955Srdivacky
1006203955Srdivacky/**
1007341825Sdim * Retrieve the text of the given diagnostic.
1008203955Srdivacky */
1009203955SrdivackyCINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
1010203955Srdivacky
1011203955Srdivacky/**
1012341825Sdim * Retrieve the name of the command-line option that enabled this
1013218893Sdim * diagnostic.
1014218893Sdim *
1015218893Sdim * \param Diag The diagnostic to be queried.
1016218893Sdim *
1017218893Sdim * \param Disable If non-NULL, will be set to the option that disables this
1018218893Sdim * diagnostic (if any).
1019218893Sdim *
1020218893Sdim * \returns A string that contains the command-line option used to enable this
1021341825Sdim * warning, such as "-Wconversion" or "-pedantic".
1022218893Sdim */
1023218893SdimCINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1024218893Sdim                                                  CXString *Disable);
1025218893Sdim
1026218893Sdim/**
1027341825Sdim * Retrieve the category number for this diagnostic.
1028218893Sdim *
1029218893Sdim * Diagnostics can be categorized into groups along with other, related
1030341825Sdim * diagnostics (e.g., diagnostics under the same warning flag). This routine
1031218893Sdim * retrieves the category number for the given diagnostic.
1032218893Sdim *
1033218893Sdim * \returns The number of the category that contains this diagnostic, or zero
1034218893Sdim * if this diagnostic is uncategorized.
1035218893Sdim */
1036218893SdimCINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1037218893Sdim
1038218893Sdim/**
1039341825Sdim * Retrieve the name of a particular diagnostic category.  This
1040234353Sdim *  is now deprecated.  Use clang_getDiagnosticCategoryText()
1041234353Sdim *  instead.
1042218893Sdim *
1043341825Sdim * \param Category A diagnostic category number, as returned by
1044218893Sdim * \c clang_getDiagnosticCategory().
1045218893Sdim *
1046218893Sdim * \returns The name of the given diagnostic category.
1047218893Sdim */
1048234353SdimCINDEX_DEPRECATED CINDEX_LINKAGE
1049234353SdimCXString clang_getDiagnosticCategoryName(unsigned Category);
1050234353Sdim
1051234353Sdim/**
1052341825Sdim * Retrieve the diagnostic category text for a given diagnostic.
1053234353Sdim *
1054234353Sdim * \returns The text of the given diagnostic category.
1055234353Sdim */
1056234353SdimCINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
1057341825Sdim
1058218893Sdim/**
1059341825Sdim * Determine the number of source ranges associated with the given
1060203955Srdivacky * diagnostic.
1061203955Srdivacky */
1062203955SrdivackyCINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
1063205219Srdivacky
1064203955Srdivacky/**
1065341825Sdim * Retrieve a source range associated with the diagnostic.
1066203955Srdivacky *
1067203955Srdivacky * A diagnostic's source ranges highlight important elements in the source
1068203955Srdivacky * code. On the command line, Clang displays source ranges by
1069205219Srdivacky * underlining them with '~' characters.
1070203955Srdivacky *
1071203955Srdivacky * \param Diagnostic the diagnostic whose range is being extracted.
1072203955Srdivacky *
1073205219Srdivacky * \param Range the zero-based index specifying which range to
1074203955Srdivacky *
1075203955Srdivacky * \returns the requested source range.
1076203955Srdivacky */
1077205219SrdivackyCINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
1078203955Srdivacky                                                      unsigned Range);
1079203955Srdivacky
1080203955Srdivacky/**
1081341825Sdim * Determine the number of fix-it hints associated with the
1082203955Srdivacky * given diagnostic.
1083203955Srdivacky */
1084203955SrdivackyCINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1085203955Srdivacky
1086203955Srdivacky/**
1087341825Sdim * Retrieve the replacement information for a given fix-it.
1088203955Srdivacky *
1089204643Srdivacky * Fix-its are described in terms of a source range whose contents
1090204643Srdivacky * should be replaced by a string. This approach generalizes over
1091204643Srdivacky * three kinds of operations: removal of source code (the range covers
1092204643Srdivacky * the code to be removed and the replacement string is empty),
1093204643Srdivacky * replacement of source code (the range covers the code to be
1094204643Srdivacky * replaced and the replacement string provides the new code), and
1095204643Srdivacky * insertion (both the start and end of the range point at the
1096204643Srdivacky * insertion location, and the replacement string provides the text to
1097204643Srdivacky * insert).
1098203955Srdivacky *
1099204643Srdivacky * \param Diagnostic The diagnostic whose fix-its are being queried.
1100203955Srdivacky *
1101204643Srdivacky * \param FixIt The zero-based index of the fix-it.
1102203955Srdivacky *
1103204643Srdivacky * \param ReplacementRange The source range whose contents will be
1104204643Srdivacky * replaced with the returned replacement string. Note that source
1105204643Srdivacky * ranges are half-open ranges [a, b), so the source code should be
1106204643Srdivacky * replaced from a and up to (but not including) b.
1107203955Srdivacky *
1108204643Srdivacky * \returns A string containing text that should be replace the source
1109204643Srdivacky * code indicated by the \c ReplacementRange.
1110203955Srdivacky */
1111205219SrdivackyCINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
1112204643Srdivacky                                                 unsigned FixIt,
1113204643Srdivacky                                               CXSourceRange *ReplacementRange);
1114203955Srdivacky
1115203955Srdivacky/**
1116203955Srdivacky * @}
1117203955Srdivacky */
1118203955Srdivacky
1119203955Srdivacky/**
1120203955Srdivacky * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1121203955Srdivacky *
1122203955Srdivacky * The routines in this group provide the ability to create and destroy
1123203955Srdivacky * translation units from files, either by parsing the contents of the files or
1124203955Srdivacky * by reading in a serialized representation of a translation unit.
1125203955Srdivacky *
1126203955Srdivacky * @{
1127203955Srdivacky */
1128205219Srdivacky
1129203955Srdivacky/**
1130341825Sdim * Get the original translation unit source file name.
1131203955Srdivacky */
1132203955SrdivackyCINDEX_LINKAGE CXString
1133203955Srdivackyclang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1134203955Srdivacky
1135203955Srdivacky/**
1136341825Sdim * Return the CXTranslationUnit for a given source file and the provided
1137203955Srdivacky * command line arguments one would pass to the compiler.
1138203955Srdivacky *
1139203955Srdivacky * Note: The 'source_filename' argument is optional.  If the caller provides a
1140203955Srdivacky * NULL pointer, the name of the source file is expected to reside in the
1141203955Srdivacky * specified command line arguments.
1142203955Srdivacky *
1143203955Srdivacky * Note: When encountered in 'clang_command_line_args', the following options
1144203955Srdivacky * are ignored:
1145203955Srdivacky *
1146203955Srdivacky *   '-c'
1147203955Srdivacky *   '-emit-ast'
1148203955Srdivacky *   '-fsyntax-only'
1149239462Sdim *   '-o \<output file>'  (both '-o' and '\<output file>' are ignored)
1150203955Srdivacky *
1151218893Sdim * \param CIdx The index object with which the translation unit will be
1152218893Sdim * associated.
1153203955Srdivacky *
1154239462Sdim * \param source_filename The name of the source file to load, or NULL if the
1155218893Sdim * source file is included in \p clang_command_line_args.
1156203955Srdivacky *
1157218893Sdim * \param num_clang_command_line_args The number of command-line arguments in
1158218893Sdim * \p clang_command_line_args.
1159218893Sdim *
1160218893Sdim * \param clang_command_line_args The command-line arguments that would be
1161218893Sdim * passed to the \c clang executable if it were being invoked out-of-process.
1162218893Sdim * These command-line options will be parsed and will affect how the translation
1163218893Sdim * unit is parsed. Note that the following options are ignored: '-c',
1164239462Sdim * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1165218893Sdim *
1166203955Srdivacky * \param num_unsaved_files the number of unsaved file entries in \p
1167203955Srdivacky * unsaved_files.
1168203955Srdivacky *
1169203955Srdivacky * \param unsaved_files the files that have not yet been saved to disk
1170203955Srdivacky * but may be required for code completion, including the contents of
1171207619Srdivacky * those files.  The contents and name of these files (as specified by
1172207619Srdivacky * CXUnsavedFile) are copied when necessary, so the client only needs to
1173207619Srdivacky * guarantee their validity until the call to this function returns.
1174203955Srdivacky */
1175203955SrdivackyCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1176203955Srdivacky                                         CXIndex CIdx,
1177203955Srdivacky                                         const char *source_filename,
1178203955Srdivacky                                         int num_clang_command_line_args,
1179212904Sdim                                   const char * const *clang_command_line_args,
1180203955Srdivacky                                         unsigned num_unsaved_files,
1181204643Srdivacky                                         struct CXUnsavedFile *unsaved_files);
1182205219Srdivacky
1183203955Srdivacky/**
1184341825Sdim * Same as \c clang_createTranslationUnit2, but returns
1185276479Sdim * the \c CXTranslationUnit instead of an error code.  In case of an error this
1186276479Sdim * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1187276479Sdim * error codes.
1188203955Srdivacky */
1189276479SdimCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1190276479Sdim    CXIndex CIdx,
1191276479Sdim    const char *ast_filename);
1192203955Srdivacky
1193203955Srdivacky/**
1194341825Sdim * Create a translation unit from an AST file (\c -emit-ast).
1195276479Sdim *
1196276479Sdim * \param[out] out_TU A non-NULL pointer to store the created
1197276479Sdim * \c CXTranslationUnit.
1198276479Sdim *
1199276479Sdim * \returns Zero on success, otherwise returns an error code.
1200276479Sdim */
1201276479SdimCINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1202276479Sdim    CXIndex CIdx,
1203276479Sdim    const char *ast_filename,
1204276479Sdim    CXTranslationUnit *out_TU);
1205276479Sdim
1206276479Sdim/**
1207341825Sdim * Flags that control the creation of translation units.
1208212904Sdim *
1209212904Sdim * The enumerators in this enumeration type are meant to be bitwise
1210212904Sdim * ORed together to specify which options should be used when
1211212904Sdim * constructing the translation unit.
1212212904Sdim */
1213212904Sdimenum CXTranslationUnit_Flags {
1214212904Sdim  /**
1215341825Sdim   * Used to indicate that no special translation-unit options are
1216212904Sdim   * needed.
1217212904Sdim   */
1218212904Sdim  CXTranslationUnit_None = 0x0,
1219212904Sdim
1220212904Sdim  /**
1221341825Sdim   * Used to indicate that the parser should construct a "detailed"
1222212904Sdim   * preprocessing record, including all macro definitions and instantiations.
1223212904Sdim   *
1224212904Sdim   * Constructing a detailed preprocessing record requires more memory
1225212904Sdim   * and time to parse, since the information contained in the record
1226212904Sdim   * is usually not retained. However, it can be useful for
1227212904Sdim   * applications that require more detailed information about the
1228212904Sdim   * behavior of the preprocessor.
1229212904Sdim   */
1230212904Sdim  CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1231212904Sdim
1232212904Sdim  /**
1233341825Sdim   * Used to indicate that the translation unit is incomplete.
1234212904Sdim   *
1235212904Sdim   * When a translation unit is considered "incomplete", semantic
1236212904Sdim   * analysis that is typically performed at the end of the
1237212904Sdim   * translation unit will be suppressed. For example, this suppresses
1238212904Sdim   * the completion of tentative declarations in C and of
1239212904Sdim   * instantiation of implicitly-instantiation function templates in
1240212904Sdim   * C++. This option is typically used when parsing a header with the
1241212904Sdim   * intent of producing a precompiled header.
1242212904Sdim   */
1243212904Sdim  CXTranslationUnit_Incomplete = 0x02,
1244341825Sdim
1245212904Sdim  /**
1246341825Sdim   * Used to indicate that the translation unit should be built with an
1247212904Sdim   * implicit precompiled header for the preamble.
1248212904Sdim   *
1249212904Sdim   * An implicit precompiled header is used as an optimization when a
1250212904Sdim   * particular translation unit is likely to be reparsed many times
1251212904Sdim   * when the sources aren't changing that often. In this case, an
1252212904Sdim   * implicit precompiled header will be built containing all of the
1253212904Sdim   * initial includes at the top of the main file (what we refer to as
1254212904Sdim   * the "preamble" of the file). In subsequent parses, if the
1255212904Sdim   * preamble or the files in it have not changed, \c
1256212904Sdim   * clang_reparseTranslationUnit() will re-use the implicit
1257212904Sdim   * precompiled header to improve parsing performance.
1258212904Sdim   */
1259212904Sdim  CXTranslationUnit_PrecompiledPreamble = 0x04,
1260341825Sdim
1261212904Sdim  /**
1262341825Sdim   * Used to indicate that the translation unit should cache some
1263212904Sdim   * code-completion results with each reparse of the source file.
1264212904Sdim   *
1265212904Sdim   * Caching of code-completion results is a performance optimization that
1266212904Sdim   * introduces some overhead to reparsing but improves the performance of
1267212904Sdim   * code-completion operations.
1268212904Sdim   */
1269218893Sdim  CXTranslationUnit_CacheCompletionResults = 0x08,
1270243830Sdim
1271218893Sdim  /**
1272341825Sdim   * Used to indicate that the translation unit will be serialized with
1273243830Sdim   * \c clang_saveTranslationUnit.
1274218893Sdim   *
1275243830Sdim   * This option is typically used when parsing a header with the intent of
1276243830Sdim   * producing a precompiled header.
1277218893Sdim   */
1278243830Sdim  CXTranslationUnit_ForSerialization = 0x10,
1279218893Sdim
1280218893Sdim  /**
1281341825Sdim   * DEPRECATED: Enabled chained precompiled preambles in C++.
1282218893Sdim   *
1283218893Sdim   * Note: this is a *temporary* option that is available only while
1284226633Sdim   * we are testing C++ precompiled preamble support. It is deprecated.
1285218893Sdim   */
1286223017Sdim  CXTranslationUnit_CXXChainedPCH = 0x20,
1287224145Sdim
1288224145Sdim  /**
1289341825Sdim   * Used to indicate that function/method bodies should be skipped while
1290234353Sdim   * parsing.
1291224145Sdim   *
1292234353Sdim   * This option can be used to search for declarations/definitions while
1293234353Sdim   * ignoring the usages.
1294224145Sdim   */
1295239462Sdim  CXTranslationUnit_SkipFunctionBodies = 0x40,
1296239462Sdim
1297239462Sdim  /**
1298341825Sdim   * Used to indicate that brief documentation comments should be
1299239462Sdim   * included into the set of code completions returned from this translation
1300239462Sdim   * unit.
1301239462Sdim   */
1302296417Sdim  CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1303296417Sdim
1304296417Sdim  /**
1305341825Sdim   * Used to indicate that the precompiled preamble should be created on
1306296417Sdim   * the first parse. Otherwise it will be created on the first reparse. This
1307296417Sdim   * trades runtime on the first parse (serializing the preamble takes time) for
1308296417Sdim   * reduced runtime on the second parse (can now reuse the preamble).
1309296417Sdim   */
1310309124Sdim  CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1311309124Sdim
1312309124Sdim  /**
1313341825Sdim   * Do not stop processing when fatal errors are encountered.
1314309124Sdim   *
1315309124Sdim   * When fatal errors are encountered while parsing a translation unit,
1316309124Sdim   * semantic analysis is typically stopped early when compiling code. A common
1317309124Sdim   * source for fatal errors are unresolvable include files. For the
1318309124Sdim   * purposes of an IDE, this is undesirable behavior and as much information
1319309124Sdim   * as possible should be reported. Use this flag to enable this behavior.
1320309124Sdim   */
1321321369Sdim  CXTranslationUnit_KeepGoing = 0x200,
1322321369Sdim
1323321369Sdim  /**
1324341825Sdim   * Sets the preprocessor in a mode for parsing a single file only.
1325321369Sdim   */
1326341825Sdim  CXTranslationUnit_SingleFileParse = 0x400,
1327341825Sdim
1328341825Sdim  /**
1329341825Sdim   * Used in combination with CXTranslationUnit_SkipFunctionBodies to
1330341825Sdim   * constrain the skipping of function bodies to the preamble.
1331341825Sdim   *
1332341825Sdim   * The function bodies of the main file are not skipped.
1333341825Sdim   */
1334344779Sdim  CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
1335344779Sdim
1336344779Sdim  /**
1337344779Sdim   * Used to indicate that attributed types should be included in CXType.
1338344779Sdim   */
1339344779Sdim  CXTranslationUnit_IncludeAttributedTypes = 0x1000,
1340344779Sdim
1341344779Sdim  /**
1342344779Sdim   * Used to indicate that implicit attributes should be visited.
1343344779Sdim   */
1344344779Sdim  CXTranslationUnit_VisitImplicitAttributes = 0x2000
1345212904Sdim};
1346212904Sdim
1347212904Sdim/**
1348341825Sdim * Returns the set of flags that is suitable for parsing a translation
1349212904Sdim * unit that is being edited.
1350212904Sdim *
1351212904Sdim * The set of flags returned provide options for \c clang_parseTranslationUnit()
1352212904Sdim * to indicate that the translation unit is likely to be reparsed many times,
1353212904Sdim * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1354212904Sdim * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1355341825Sdim * set contains an unspecified set of optimizations (e.g., the precompiled
1356212904Sdim * preamble) geared toward improving the performance of these routines. The
1357212904Sdim * set of optimizations enabled may change from one version to the next.
1358212904Sdim */
1359212904SdimCINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1360276479Sdim
1361212904Sdim/**
1362341825Sdim * Same as \c clang_parseTranslationUnit2, but returns
1363276479Sdim * the \c CXTranslationUnit instead of an error code.  In case of an error this
1364276479Sdim * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1365276479Sdim * error codes.
1366276479Sdim */
1367276479SdimCINDEX_LINKAGE CXTranslationUnit
1368276479Sdimclang_parseTranslationUnit(CXIndex CIdx,
1369276479Sdim                           const char *source_filename,
1370276479Sdim                           const char *const *command_line_args,
1371276479Sdim                           int num_command_line_args,
1372276479Sdim                           struct CXUnsavedFile *unsaved_files,
1373276479Sdim                           unsigned num_unsaved_files,
1374276479Sdim                           unsigned options);
1375276479Sdim
1376276479Sdim/**
1377341825Sdim * Parse the given source file and the translation unit corresponding
1378212904Sdim * to that file.
1379212904Sdim *
1380212904Sdim * This routine is the main entry point for the Clang C API, providing the
1381212904Sdim * ability to parse a source file into a translation unit that can then be
1382212904Sdim * queried by other functions in the API. This routine accepts a set of
1383212904Sdim * command-line arguments so that the compilation can be configured in the same
1384212904Sdim * way that the compiler is configured on the command line.
1385212904Sdim *
1386341825Sdim * \param CIdx The index object with which the translation unit will be
1387212904Sdim * associated.
1388212904Sdim *
1389212904Sdim * \param source_filename The name of the source file to load, or NULL if the
1390276479Sdim * source file is included in \c command_line_args.
1391212904Sdim *
1392212904Sdim * \param command_line_args The command-line arguments that would be
1393212904Sdim * passed to the \c clang executable if it were being invoked out-of-process.
1394212904Sdim * These command-line options will be parsed and will affect how the translation
1395341825Sdim * unit is parsed. Note that the following options are ignored: '-c',
1396239462Sdim * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1397212904Sdim *
1398212904Sdim * \param num_command_line_args The number of command-line arguments in
1399276479Sdim * \c command_line_args.
1400212904Sdim *
1401212904Sdim * \param unsaved_files the files that have not yet been saved to disk
1402212904Sdim * but may be required for parsing, including the contents of
1403212904Sdim * those files.  The contents and name of these files (as specified by
1404212904Sdim * CXUnsavedFile) are copied when necessary, so the client only needs to
1405212904Sdim * guarantee their validity until the call to this function returns.
1406212904Sdim *
1407212904Sdim * \param num_unsaved_files the number of unsaved file entries in \p
1408212904Sdim * unsaved_files.
1409212904Sdim *
1410212904Sdim * \param options A bitmask of options that affects how the translation unit
1411212904Sdim * is managed but not its compilation. This should be a bitwise OR of the
1412212904Sdim * CXTranslationUnit_XXX flags.
1413212904Sdim *
1414276479Sdim * \param[out] out_TU A non-NULL pointer to store the created
1415276479Sdim * \c CXTranslationUnit, describing the parsed code and containing any
1416276479Sdim * diagnostics produced by the compiler.
1417276479Sdim *
1418276479Sdim * \returns Zero on success, otherwise returns an error code.
1419212904Sdim */
1420276479SdimCINDEX_LINKAGE enum CXErrorCode
1421276479Sdimclang_parseTranslationUnit2(CXIndex CIdx,
1422276479Sdim                            const char *source_filename,
1423276479Sdim                            const char *const *command_line_args,
1424276479Sdim                            int num_command_line_args,
1425276479Sdim                            struct CXUnsavedFile *unsaved_files,
1426276479Sdim                            unsigned num_unsaved_files,
1427276479Sdim                            unsigned options,
1428276479Sdim                            CXTranslationUnit *out_TU);
1429276479Sdim
1430212904Sdim/**
1431341825Sdim * Same as clang_parseTranslationUnit2 but requires a full command line
1432296417Sdim * for \c command_line_args including argv[0]. This is useful if the standard
1433296417Sdim * library paths are relative to the binary.
1434296417Sdim */
1435296417SdimCINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1436296417Sdim    CXIndex CIdx, const char *source_filename,
1437296417Sdim    const char *const *command_line_args, int num_command_line_args,
1438296417Sdim    struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1439296417Sdim    unsigned options, CXTranslationUnit *out_TU);
1440296417Sdim
1441296417Sdim/**
1442341825Sdim * Flags that control how translation units are saved.
1443212904Sdim *
1444212904Sdim * The enumerators in this enumeration type are meant to be bitwise
1445212904Sdim * ORed together to specify which options should be used when
1446212904Sdim * saving the translation unit.
1447212904Sdim */
1448212904Sdimenum CXSaveTranslationUnit_Flags {
1449212904Sdim  /**
1450341825Sdim   * Used to indicate that no special saving options are needed.
1451212904Sdim   */
1452212904Sdim  CXSaveTranslationUnit_None = 0x0
1453212904Sdim};
1454212904Sdim
1455212904Sdim/**
1456341825Sdim * Returns the set of flags that is suitable for saving a translation
1457212904Sdim * unit.
1458212904Sdim *
1459212904Sdim * The set of flags returned provide options for
1460212904Sdim * \c clang_saveTranslationUnit() by default. The returned flag
1461212904Sdim * set contains an unspecified set of options that save translation units with
1462212904Sdim * the most commonly-requested data.
1463212904Sdim */
1464212904SdimCINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1465212904Sdim
1466212904Sdim/**
1467341825Sdim * Describes the kind of error that occurred (if any) in a call to
1468224145Sdim * \c clang_saveTranslationUnit().
1469224145Sdim */
1470224145Sdimenum CXSaveError {
1471224145Sdim  /**
1472341825Sdim   * Indicates that no error occurred while saving a translation unit.
1473224145Sdim   */
1474224145Sdim  CXSaveError_None = 0,
1475341825Sdim
1476224145Sdim  /**
1477341825Sdim   * Indicates that an unknown error occurred while attempting to save
1478224145Sdim   * the file.
1479224145Sdim   *
1480341825Sdim   * This error typically indicates that file I/O failed when attempting to
1481224145Sdim   * write the file.
1482224145Sdim   */
1483224145Sdim  CXSaveError_Unknown = 1,
1484341825Sdim
1485224145Sdim  /**
1486341825Sdim   * Indicates that errors during translation prevented this attempt
1487224145Sdim   * to save the translation unit.
1488341825Sdim   *
1489224145Sdim   * Errors that prevent the translation unit from being saved can be
1490224145Sdim   * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1491224145Sdim   */
1492224145Sdim  CXSaveError_TranslationErrors = 2,
1493341825Sdim
1494224145Sdim  /**
1495341825Sdim   * Indicates that the translation unit to be saved was somehow
1496224145Sdim   * invalid (e.g., NULL).
1497224145Sdim   */
1498224145Sdim  CXSaveError_InvalidTU = 3
1499224145Sdim};
1500341825Sdim
1501224145Sdim/**
1502341825Sdim * Saves a translation unit into a serialized representation of
1503212904Sdim * that translation unit on disk.
1504212904Sdim *
1505212904Sdim * Any translation unit that was parsed without error can be saved
1506212904Sdim * into a file. The translation unit can then be deserialized into a
1507212904Sdim * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1508212904Sdim * if it is an incomplete translation unit that corresponds to a
1509212904Sdim * header, used as a precompiled header when parsing other translation
1510212904Sdim * units.
1511212904Sdim *
1512212904Sdim * \param TU The translation unit to save.
1513212904Sdim *
1514212904Sdim * \param FileName The file to which the translation unit will be saved.
1515212904Sdim *
1516212904Sdim * \param options A bitmask of options that affects how the translation unit
1517212904Sdim * is saved. This should be a bitwise OR of the
1518212904Sdim * CXSaveTranslationUnit_XXX flags.
1519212904Sdim *
1520224145Sdim * \returns A value that will match one of the enumerators of the CXSaveError
1521341825Sdim * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1522224145Sdim * saved successfully, while a non-zero value indicates that a problem occurred.
1523212904Sdim */
1524212904SdimCINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1525212904Sdim                                             const char *FileName,
1526212904Sdim                                             unsigned options);
1527212904Sdim
1528212904Sdim/**
1529341825Sdim * Suspend a translation unit in order to free memory associated with it.
1530321369Sdim *
1531321369Sdim * A suspended translation unit uses significantly less memory but on the other
1532321369Sdim * side does not support any other calls than \c clang_reparseTranslationUnit
1533321369Sdim * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1534321369Sdim */
1535321369SdimCINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1536321369Sdim
1537321369Sdim/**
1538341825Sdim * Destroy the specified CXTranslationUnit object.
1539203955Srdivacky */
1540203955SrdivackyCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1541205219Srdivacky
1542203955Srdivacky/**
1543341825Sdim * Flags that control the reparsing of translation units.
1544212904Sdim *
1545212904Sdim * The enumerators in this enumeration type are meant to be bitwise
1546212904Sdim * ORed together to specify which options should be used when
1547212904Sdim * reparsing the translation unit.
1548212904Sdim */
1549212904Sdimenum CXReparse_Flags {
1550212904Sdim  /**
1551341825Sdim   * Used to indicate that no special reparsing options are needed.
1552212904Sdim   */
1553212904Sdim  CXReparse_None = 0x0
1554212904Sdim};
1555341825Sdim
1556212904Sdim/**
1557341825Sdim * Returns the set of flags that is suitable for reparsing a translation
1558212904Sdim * unit.
1559212904Sdim *
1560212904Sdim * The set of flags returned provide options for
1561212904Sdim * \c clang_reparseTranslationUnit() by default. The returned flag
1562212904Sdim * set contains an unspecified set of optimizations geared toward common uses
1563341825Sdim * of reparsing. The set of optimizations enabled may change from one version
1564212904Sdim * to the next.
1565212904Sdim */
1566212904SdimCINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1567212904Sdim
1568212904Sdim/**
1569341825Sdim * Reparse the source files that produced this translation unit.
1570212904Sdim *
1571212904Sdim * This routine can be used to re-parse the source files that originally
1572212904Sdim * created the given translation unit, for example because those source files
1573212904Sdim * have changed (either on disk or as passed via \p unsaved_files). The
1574212904Sdim * source code will be reparsed with the same command-line options as it
1575341825Sdim * was originally parsed.
1576212904Sdim *
1577212904Sdim * Reparsing a translation unit invalidates all cursors and source locations
1578212904Sdim * that refer into that translation unit. This makes reparsing a translation
1579212904Sdim * unit semantically equivalent to destroying the translation unit and then
1580212904Sdim * creating a new translation unit with the same command-line arguments.
1581341825Sdim * However, it may be more efficient to reparse a translation
1582212904Sdim * unit using this routine.
1583212904Sdim *
1584212904Sdim * \param TU The translation unit whose contents will be re-parsed. The
1585341825Sdim * translation unit must originally have been built with
1586212904Sdim * \c clang_createTranslationUnitFromSourceFile().
1587212904Sdim *
1588212904Sdim * \param num_unsaved_files The number of unsaved file entries in \p
1589212904Sdim * unsaved_files.
1590212904Sdim *
1591212904Sdim * \param unsaved_files The files that have not yet been saved to disk
1592212904Sdim * but may be required for parsing, including the contents of
1593212904Sdim * those files.  The contents and name of these files (as specified by
1594212904Sdim * CXUnsavedFile) are copied when necessary, so the client only needs to
1595212904Sdim * guarantee their validity until the call to this function returns.
1596341825Sdim *
1597212904Sdim * \param options A bitset of options composed of the flags in CXReparse_Flags.
1598212904Sdim * The function \c clang_defaultReparseOptions() produces a default set of
1599212904Sdim * options recommended for most uses, based on the translation unit.
1600212904Sdim *
1601276479Sdim * \returns 0 if the sources could be reparsed.  A non-zero error code will be
1602212904Sdim * returned if reparsing was impossible, such that the translation unit is
1603276479Sdim * invalid. In such cases, the only valid call for \c TU is
1604276479Sdim * \c clang_disposeTranslationUnit(TU).  The error codes returned by this
1605276479Sdim * routine are described by the \c CXErrorCode enum.
1606212904Sdim */
1607212904SdimCINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1608212904Sdim                                                unsigned num_unsaved_files,
1609212904Sdim                                          struct CXUnsavedFile *unsaved_files,
1610212904Sdim                                                unsigned options);
1611221345Sdim
1612212904Sdim/**
1613341825Sdim  * Categorizes how memory is being used by a translation unit.
1614221345Sdim  */
1615221345Sdimenum CXTUResourceUsageKind {
1616221345Sdim  CXTUResourceUsage_AST = 1,
1617221345Sdim  CXTUResourceUsage_Identifiers = 2,
1618221345Sdim  CXTUResourceUsage_Selectors = 3,
1619221345Sdim  CXTUResourceUsage_GlobalCompletionResults = 4,
1620221345Sdim  CXTUResourceUsage_SourceManagerContentCache = 5,
1621221345Sdim  CXTUResourceUsage_AST_SideTables = 6,
1622221345Sdim  CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1623221345Sdim  CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1624341825Sdim  CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1625341825Sdim  CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1626223017Sdim  CXTUResourceUsage_Preprocessor = 11,
1627223017Sdim  CXTUResourceUsage_PreprocessingRecord = 12,
1628226633Sdim  CXTUResourceUsage_SourceManager_DataStructures = 13,
1629226633Sdim  CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1630221345Sdim  CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1631221345Sdim  CXTUResourceUsage_MEMORY_IN_BYTES_END =
1632226633Sdim    CXTUResourceUsage_Preprocessor_HeaderSearch,
1633221345Sdim
1634221345Sdim  CXTUResourceUsage_First = CXTUResourceUsage_AST,
1635226633Sdim  CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1636221345Sdim};
1637221345Sdim
1638221345Sdim/**
1639341825Sdim  * Returns the human-readable null-terminated C string that represents
1640221345Sdim  *  the name of the memory category.  This string should never be freed.
1641221345Sdim  */
1642221345SdimCINDEX_LINKAGE
1643221345Sdimconst char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1644221345Sdim
1645221345Sdimtypedef struct CXTUResourceUsageEntry {
1646341825Sdim  /* The memory usage category. */
1647341825Sdim  enum CXTUResourceUsageKind kind;
1648341825Sdim  /* Amount of resources used.
1649221345Sdim      The units will depend on the resource kind. */
1650221345Sdim  unsigned long amount;
1651221345Sdim} CXTUResourceUsageEntry;
1652221345Sdim
1653221345Sdim/**
1654341825Sdim  * The memory usage of a CXTranslationUnit, broken into categories.
1655221345Sdim  */
1656221345Sdimtypedef struct CXTUResourceUsage {
1657341825Sdim  /* Private data member, used for queries. */
1658221345Sdim  void *data;
1659221345Sdim
1660341825Sdim  /* The number of entries in the 'entries' array. */
1661221345Sdim  unsigned numEntries;
1662221345Sdim
1663341825Sdim  /* An array of key-value pairs, representing the breakdown of memory
1664221345Sdim            usage. */
1665221345Sdim  CXTUResourceUsageEntry *entries;
1666221345Sdim
1667221345Sdim} CXTUResourceUsage;
1668221345Sdim
1669221345Sdim/**
1670341825Sdim  * Return the memory usage of a translation unit.  This object
1671221345Sdim  *  should be released with clang_disposeCXTUResourceUsage().
1672221345Sdim  */
1673221345SdimCINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1674221345Sdim
1675221345SdimCINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1676221345Sdim
1677221345Sdim/**
1678341825Sdim * Get target information for this translation unit.
1679321369Sdim *
1680321369Sdim * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1681321369Sdim */
1682321369SdimCINDEX_LINKAGE CXTargetInfo
1683321369Sdimclang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1684321369Sdim
1685321369Sdim/**
1686341825Sdim * Destroy the CXTargetInfo object.
1687321369Sdim */
1688321369SdimCINDEX_LINKAGE void
1689321369Sdimclang_TargetInfo_dispose(CXTargetInfo Info);
1690321369Sdim
1691321369Sdim/**
1692341825Sdim * Get the normalized target triple as a string.
1693321369Sdim *
1694321369Sdim * Returns the empty string in case of any error.
1695321369Sdim */
1696321369SdimCINDEX_LINKAGE CXString
1697321369Sdimclang_TargetInfo_getTriple(CXTargetInfo Info);
1698321369Sdim
1699321369Sdim/**
1700341825Sdim * Get the pointer width of the target in bits.
1701321369Sdim *
1702321369Sdim * Returns -1 in case of error.
1703321369Sdim */
1704321369SdimCINDEX_LINKAGE int
1705321369Sdimclang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1706321369Sdim
1707321369Sdim/**
1708203955Srdivacky * @}
1709203955Srdivacky */
1710205219Srdivacky
1711203955Srdivacky/**
1712341825Sdim * Describes the kind of entity that a cursor refers to.
1713202379Srdivacky */
1714202879Srdivackyenum CXCursorKind {
1715202879Srdivacky  /* Declarations */
1716203955Srdivacky  /**
1717341825Sdim   * A declaration whose specific kind is not exposed via this
1718203955Srdivacky   * interface.
1719202879Srdivacky   *
1720202879Srdivacky   * Unexposed declarations have the same operations as any other kind
1721202879Srdivacky   * of declaration; one can extract their location information,
1722202879Srdivacky   * spelling, find their definitions, etc. However, the specific kind
1723202879Srdivacky   * of the declaration is not reported.
1724202879Srdivacky   */
1725202879Srdivacky  CXCursor_UnexposedDecl                 = 1,
1726341825Sdim  /** A C or C++ struct. */
1727203955Srdivacky  CXCursor_StructDecl                    = 2,
1728341825Sdim  /** A C or C++ union. */
1729202879Srdivacky  CXCursor_UnionDecl                     = 3,
1730341825Sdim  /** A C++ class. */
1731202879Srdivacky  CXCursor_ClassDecl                     = 4,
1732341825Sdim  /** An enumeration. */
1733202879Srdivacky  CXCursor_EnumDecl                      = 5,
1734203955Srdivacky  /**
1735341825Sdim   * A field (in C) or non-static data member (in C++) in a
1736202879Srdivacky   * struct, union, or C++ class.
1737202879Srdivacky   */
1738202879Srdivacky  CXCursor_FieldDecl                     = 6,
1739341825Sdim  /** An enumerator constant. */
1740202879Srdivacky  CXCursor_EnumConstantDecl              = 7,
1741341825Sdim  /** A function. */
1742202879Srdivacky  CXCursor_FunctionDecl                  = 8,
1743341825Sdim  /** A variable. */
1744202879Srdivacky  CXCursor_VarDecl                       = 9,
1745341825Sdim  /** A function or method parameter. */
1746202879Srdivacky  CXCursor_ParmDecl                      = 10,
1747341825Sdim  /** An Objective-C \@interface. */
1748202879Srdivacky  CXCursor_ObjCInterfaceDecl             = 11,
1749341825Sdim  /** An Objective-C \@interface for a category. */
1750202879Srdivacky  CXCursor_ObjCCategoryDecl              = 12,
1751341825Sdim  /** An Objective-C \@protocol declaration. */
1752202879Srdivacky  CXCursor_ObjCProtocolDecl              = 13,
1753341825Sdim  /** An Objective-C \@property declaration. */
1754202879Srdivacky  CXCursor_ObjCPropertyDecl              = 14,
1755341825Sdim  /** An Objective-C instance variable. */
1756202879Srdivacky  CXCursor_ObjCIvarDecl                  = 15,
1757341825Sdim  /** An Objective-C instance method. */
1758202879Srdivacky  CXCursor_ObjCInstanceMethodDecl        = 16,
1759341825Sdim  /** An Objective-C class method. */
1760202879Srdivacky  CXCursor_ObjCClassMethodDecl           = 17,
1761341825Sdim  /** An Objective-C \@implementation. */
1762202879Srdivacky  CXCursor_ObjCImplementationDecl        = 18,
1763341825Sdim  /** An Objective-C \@implementation for a category. */
1764202879Srdivacky  CXCursor_ObjCCategoryImplDecl          = 19,
1765341825Sdim  /** A typedef. */
1766202879Srdivacky  CXCursor_TypedefDecl                   = 20,
1767341825Sdim  /** A C++ class method. */
1768207619Srdivacky  CXCursor_CXXMethod                     = 21,
1769341825Sdim  /** A C++ namespace. */
1770208600Srdivacky  CXCursor_Namespace                     = 22,
1771341825Sdim  /** A linkage specification, e.g. 'extern "C"'. */
1772208600Srdivacky  CXCursor_LinkageSpec                   = 23,
1773341825Sdim  /** A C++ constructor. */
1774212904Sdim  CXCursor_Constructor                   = 24,
1775341825Sdim  /** A C++ destructor. */
1776212904Sdim  CXCursor_Destructor                    = 25,
1777341825Sdim  /** A C++ conversion function. */
1778212904Sdim  CXCursor_ConversionFunction            = 26,
1779341825Sdim  /** A C++ template type parameter. */
1780212904Sdim  CXCursor_TemplateTypeParameter         = 27,
1781341825Sdim  /** A C++ non-type template parameter. */
1782212904Sdim  CXCursor_NonTypeTemplateParameter      = 28,
1783341825Sdim  /** A C++ template template parameter. */
1784212904Sdim  CXCursor_TemplateTemplateParameter     = 29,
1785341825Sdim  /** A C++ function template. */
1786212904Sdim  CXCursor_FunctionTemplate              = 30,
1787341825Sdim  /** A C++ class template. */
1788212904Sdim  CXCursor_ClassTemplate                 = 31,
1789341825Sdim  /** A C++ class template partial specialization. */
1790212904Sdim  CXCursor_ClassTemplatePartialSpecialization = 32,
1791341825Sdim  /** A C++ namespace alias declaration. */
1792212904Sdim  CXCursor_NamespaceAlias                = 33,
1793341825Sdim  /** A C++ using directive. */
1794212904Sdim  CXCursor_UsingDirective                = 34,
1795341825Sdim  /** A C++ using declaration. */
1796212904Sdim  CXCursor_UsingDeclaration              = 35,
1797341825Sdim  /** A C++ alias declaration */
1798221345Sdim  CXCursor_TypeAliasDecl                 = 36,
1799341825Sdim  /** An Objective-C \@synthesize definition. */
1800223017Sdim  CXCursor_ObjCSynthesizeDecl            = 37,
1801341825Sdim  /** An Objective-C \@dynamic definition. */
1802223017Sdim  CXCursor_ObjCDynamicDecl               = 38,
1803341825Sdim  /** An access specifier. */
1804226633Sdim  CXCursor_CXXAccessSpecifier            = 39,
1805226633Sdim
1806208600Srdivacky  CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
1807226633Sdim  CXCursor_LastDecl                      = CXCursor_CXXAccessSpecifier,
1808207619Srdivacky
1809202879Srdivacky  /* References */
1810202879Srdivacky  CXCursor_FirstRef                      = 40, /* Decl references */
1811203955Srdivacky  CXCursor_ObjCSuperClassRef             = 40,
1812202879Srdivacky  CXCursor_ObjCProtocolRef               = 41,
1813202879Srdivacky  CXCursor_ObjCClassRef                  = 42,
1814202879Srdivacky  /**
1815341825Sdim   * A reference to a type declaration.
1816202879Srdivacky   *
1817202879Srdivacky   * A type reference occurs anywhere where a type is named but not
1818202879Srdivacky   * declared. For example, given:
1819202879Srdivacky   *
1820202879Srdivacky   * \code
1821202879Srdivacky   * typedef unsigned size_type;
1822202879Srdivacky   * size_type size;
1823202879Srdivacky   * \endcode
1824202879Srdivacky   *
1825202879Srdivacky   * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1826202879Srdivacky   * while the type of the variable "size" is referenced. The cursor
1827202879Srdivacky   * referenced by the type of size is the typedef for size_type.
1828202879Srdivacky   */
1829202879Srdivacky  CXCursor_TypeRef                       = 43,
1830212904Sdim  CXCursor_CXXBaseSpecifier              = 44,
1831341825Sdim  /**
1832341825Sdim   * A reference to a class template, function template, template
1833218893Sdim   * template parameter, or class template partial specialization.
1834212904Sdim   */
1835212904Sdim  CXCursor_TemplateRef                   = 45,
1836212904Sdim  /**
1837341825Sdim   * A reference to a namespace or namespace alias.
1838212904Sdim   */
1839212904Sdim  CXCursor_NamespaceRef                  = 46,
1840218893Sdim  /**
1841341825Sdim   * A reference to a member of a struct, union, or class that occurs in
1842218893Sdim   * some non-expression context, e.g., a designated initializer.
1843218893Sdim   */
1844218893Sdim  CXCursor_MemberRef                     = 47,
1845218893Sdim  /**
1846341825Sdim   * A reference to a labeled statement.
1847218893Sdim   *
1848341825Sdim   * This cursor kind is used to describe the jump to "start_over" in the
1849218893Sdim   * goto statement in the following example:
1850218893Sdim   *
1851218893Sdim   * \code
1852218893Sdim   *   start_over:
1853218893Sdim   *     ++counter;
1854218893Sdim   *
1855218893Sdim   *     goto start_over;
1856218893Sdim   * \endcode
1857218893Sdim   *
1858218893Sdim   * A label reference cursor refers to a label statement.
1859218893Sdim   */
1860218893Sdim  CXCursor_LabelRef                      = 48,
1861341825Sdim
1862218893Sdim  /**
1863341825Sdim   * A reference to a set of overloaded functions or function templates
1864218893Sdim   * that has not yet been resolved to a specific function or function template.
1865218893Sdim   *
1866218893Sdim   * An overloaded declaration reference cursor occurs in C++ templates where
1867218893Sdim   * a dependent name refers to a function. For example:
1868218893Sdim   *
1869218893Sdim   * \code
1870218893Sdim   * template<typename T> void swap(T&, T&);
1871218893Sdim   *
1872218893Sdim   * struct X { ... };
1873218893Sdim   * void swap(X&, X&);
1874218893Sdim   *
1875218893Sdim   * template<typename T>
1876218893Sdim   * void reverse(T* first, T* last) {
1877218893Sdim   *   while (first < last - 1) {
1878218893Sdim   *     swap(*first, *--last);
1879218893Sdim   *     ++first;
1880218893Sdim   *   }
1881218893Sdim   * }
1882218893Sdim   *
1883218893Sdim   * struct Y { };
1884218893Sdim   * void swap(Y&, Y&);
1885218893Sdim   * \endcode
1886218893Sdim   *
1887218893Sdim   * Here, the identifier "swap" is associated with an overloaded declaration
1888218893Sdim   * reference. In the template definition, "swap" refers to either of the two
1889218893Sdim   * "swap" functions declared above, so both results will be available. At
1890218893Sdim   * instantiation time, "swap" may also refer to other functions found via
1891218893Sdim   * argument-dependent lookup (e.g., the "swap" function at the end of the
1892218893Sdim   * example).
1893218893Sdim   *
1894341825Sdim   * The functions \c clang_getNumOverloadedDecls() and
1895218893Sdim   * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1896218893Sdim   * referenced by this cursor.
1897218893Sdim   */
1898218893Sdim  CXCursor_OverloadedDeclRef             = 49,
1899341825Sdim
1900234353Sdim  /**
1901341825Sdim   * A reference to a variable that occurs in some non-expression
1902234353Sdim   * context, e.g., a C++ lambda capture list.
1903234353Sdim   */
1904234353Sdim  CXCursor_VariableRef                   = 50,
1905341825Sdim
1906234353Sdim  CXCursor_LastRef                       = CXCursor_VariableRef,
1907203955Srdivacky
1908202879Srdivacky  /* Error conditions */
1909202879Srdivacky  CXCursor_FirstInvalid                  = 70,
1910202879Srdivacky  CXCursor_InvalidFile                   = 70,
1911202879Srdivacky  CXCursor_NoDeclFound                   = 71,
1912202879Srdivacky  CXCursor_NotImplemented                = 72,
1913205408Srdivacky  CXCursor_InvalidCode                   = 73,
1914205408Srdivacky  CXCursor_LastInvalid                   = CXCursor_InvalidCode,
1915203955Srdivacky
1916202879Srdivacky  /* Expressions */
1917202879Srdivacky  CXCursor_FirstExpr                     = 100,
1918203955Srdivacky
1919202879Srdivacky  /**
1920341825Sdim   * An expression whose specific kind is not exposed via this
1921203955Srdivacky   * interface.
1922202879Srdivacky   *
1923202879Srdivacky   * Unexposed expressions have the same operations as any other kind
1924202879Srdivacky   * of expression; one can extract their location information,
1925202879Srdivacky   * spelling, children, etc. However, the specific kind of the
1926202879Srdivacky   * expression is not reported.
1927202879Srdivacky   */
1928202879Srdivacky  CXCursor_UnexposedExpr                 = 100,
1929203955Srdivacky
1930202879Srdivacky  /**
1931341825Sdim   * An expression that refers to some value declaration, such
1932276479Sdim   * as a function, variable, or enumerator.
1933202879Srdivacky   */
1934202879Srdivacky  CXCursor_DeclRefExpr                   = 101,
1935203955Srdivacky
1936202879Srdivacky  /**
1937341825Sdim   * An expression that refers to a member of a struct, union,
1938202879Srdivacky   * class, Objective-C class, etc.
1939202879Srdivacky   */
1940202879Srdivacky  CXCursor_MemberRefExpr                 = 102,
1941203955Srdivacky
1942341825Sdim  /** An expression that calls a function. */
1943202879Srdivacky  CXCursor_CallExpr                      = 103,
1944203955Srdivacky
1945341825Sdim  /** An expression that sends a message to an Objective-C
1946202879Srdivacky   object or class. */
1947202879Srdivacky  CXCursor_ObjCMessageExpr               = 104,
1948203955Srdivacky
1949341825Sdim  /** An expression that represents a block literal. */
1950207619Srdivacky  CXCursor_BlockExpr                     = 105,
1951207619Srdivacky
1952341825Sdim  /** An integer literal.
1953226633Sdim   */
1954226633Sdim  CXCursor_IntegerLiteral                = 106,
1955207619Srdivacky
1956341825Sdim  /** A floating point number literal.
1957226633Sdim   */
1958226633Sdim  CXCursor_FloatingLiteral               = 107,
1959226633Sdim
1960341825Sdim  /** An imaginary number literal.
1961226633Sdim   */
1962226633Sdim  CXCursor_ImaginaryLiteral              = 108,
1963226633Sdim
1964341825Sdim  /** A string literal.
1965226633Sdim   */
1966226633Sdim  CXCursor_StringLiteral                 = 109,
1967226633Sdim
1968341825Sdim  /** A character literal.
1969226633Sdim   */
1970226633Sdim  CXCursor_CharacterLiteral              = 110,
1971226633Sdim
1972341825Sdim  /** A parenthesized expression, e.g. "(1)".
1973226633Sdim   *
1974226633Sdim   * This AST node is only formed if full location information is requested.
1975226633Sdim   */
1976226633Sdim  CXCursor_ParenExpr                     = 111,
1977226633Sdim
1978341825Sdim  /** This represents the unary-expression's (except sizeof and
1979226633Sdim   * alignof).
1980226633Sdim   */
1981226633Sdim  CXCursor_UnaryOperator                 = 112,
1982226633Sdim
1983341825Sdim  /** [C99 6.5.2.1] Array Subscripting.
1984226633Sdim   */
1985226633Sdim  CXCursor_ArraySubscriptExpr            = 113,
1986226633Sdim
1987341825Sdim  /** A builtin binary operation expression such as "x + y" or
1988226633Sdim   * "x <= y".
1989226633Sdim   */
1990226633Sdim  CXCursor_BinaryOperator                = 114,
1991226633Sdim
1992341825Sdim  /** Compound assignment such as "+=".
1993226633Sdim   */
1994226633Sdim  CXCursor_CompoundAssignOperator        = 115,
1995226633Sdim
1996341825Sdim  /** The ?: ternary operator.
1997226633Sdim   */
1998226633Sdim  CXCursor_ConditionalOperator           = 116,
1999226633Sdim
2000341825Sdim  /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
2001226633Sdim   * (C++ [expr.cast]), which uses the syntax (Type)expr.
2002226633Sdim   *
2003226633Sdim   * For example: (int)f.
2004226633Sdim   */
2005226633Sdim  CXCursor_CStyleCastExpr                = 117,
2006226633Sdim
2007341825Sdim  /** [C99 6.5.2.5]
2008226633Sdim   */
2009226633Sdim  CXCursor_CompoundLiteralExpr           = 118,
2010226633Sdim
2011341825Sdim  /** Describes an C or C++ initializer list.
2012226633Sdim   */
2013226633Sdim  CXCursor_InitListExpr                  = 119,
2014226633Sdim
2015341825Sdim  /** The GNU address of label extension, representing &&label.
2016226633Sdim   */
2017226633Sdim  CXCursor_AddrLabelExpr                 = 120,
2018226633Sdim
2019341825Sdim  /** This is the GNU Statement Expression extension: ({int X=4; X;})
2020226633Sdim   */
2021226633Sdim  CXCursor_StmtExpr                      = 121,
2022226633Sdim
2023341825Sdim  /** Represents a C11 generic selection.
2024226633Sdim   */
2025226633Sdim  CXCursor_GenericSelectionExpr          = 122,
2026226633Sdim
2027341825Sdim  /** Implements the GNU __null extension, which is a name for a null
2028226633Sdim   * pointer constant that has integral type (e.g., int or long) and is the same
2029226633Sdim   * size and alignment as a pointer.
2030226633Sdim   *
2031226633Sdim   * The __null extension is typically only used by system headers, which define
2032226633Sdim   * NULL as __null in C++ rather than using 0 (which is an integer that may not
2033226633Sdim   * match the size of a pointer).
2034226633Sdim   */
2035226633Sdim  CXCursor_GNUNullExpr                   = 123,
2036226633Sdim
2037341825Sdim  /** C++'s static_cast<> expression.
2038226633Sdim   */
2039226633Sdim  CXCursor_CXXStaticCastExpr             = 124,
2040226633Sdim
2041341825Sdim  /** C++'s dynamic_cast<> expression.
2042226633Sdim   */
2043226633Sdim  CXCursor_CXXDynamicCastExpr            = 125,
2044226633Sdim
2045341825Sdim  /** C++'s reinterpret_cast<> expression.
2046226633Sdim   */
2047226633Sdim  CXCursor_CXXReinterpretCastExpr        = 126,
2048226633Sdim
2049341825Sdim  /** C++'s const_cast<> expression.
2050226633Sdim   */
2051226633Sdim  CXCursor_CXXConstCastExpr              = 127,
2052226633Sdim
2053341825Sdim  /** Represents an explicit C++ type conversion that uses "functional"
2054226633Sdim   * notion (C++ [expr.type.conv]).
2055226633Sdim   *
2056226633Sdim   * Example:
2057226633Sdim   * \code
2058226633Sdim   *   x = int(0.5);
2059226633Sdim   * \endcode
2060226633Sdim   */
2061226633Sdim  CXCursor_CXXFunctionalCastExpr         = 128,
2062226633Sdim
2063341825Sdim  /** A C++ typeid expression (C++ [expr.typeid]).
2064226633Sdim   */
2065226633Sdim  CXCursor_CXXTypeidExpr                 = 129,
2066226633Sdim
2067341825Sdim  /** [C++ 2.13.5] C++ Boolean Literal.
2068226633Sdim   */
2069226633Sdim  CXCursor_CXXBoolLiteralExpr            = 130,
2070226633Sdim
2071341825Sdim  /** [C++0x 2.14.7] C++ Pointer Literal.
2072226633Sdim   */
2073226633Sdim  CXCursor_CXXNullPtrLiteralExpr         = 131,
2074226633Sdim
2075341825Sdim  /** Represents the "this" expression in C++
2076226633Sdim   */
2077226633Sdim  CXCursor_CXXThisExpr                   = 132,
2078226633Sdim
2079341825Sdim  /** [C++ 15] C++ Throw Expression.
2080226633Sdim   *
2081226633Sdim   * This handles 'throw' and 'throw' assignment-expression. When
2082226633Sdim   * assignment-expression isn't present, Op will be null.
2083226633Sdim   */
2084226633Sdim  CXCursor_CXXThrowExpr                  = 133,
2085226633Sdim
2086341825Sdim  /** A new expression for memory allocation and constructor calls, e.g:
2087226633Sdim   * "new CXXNewExpr(foo)".
2088226633Sdim   */
2089226633Sdim  CXCursor_CXXNewExpr                    = 134,
2090226633Sdim
2091341825Sdim  /** A delete expression for memory deallocation and destructor calls,
2092226633Sdim   * e.g. "delete[] pArray".
2093226633Sdim   */
2094226633Sdim  CXCursor_CXXDeleteExpr                 = 135,
2095226633Sdim
2096341825Sdim  /** A unary expression. (noexcept, sizeof, or other traits)
2097226633Sdim   */
2098226633Sdim  CXCursor_UnaryExpr                     = 136,
2099226633Sdim
2100341825Sdim  /** An Objective-C string literal i.e. @"foo".
2101226633Sdim   */
2102226633Sdim  CXCursor_ObjCStringLiteral             = 137,
2103226633Sdim
2104341825Sdim  /** An Objective-C \@encode expression.
2105226633Sdim   */
2106226633Sdim  CXCursor_ObjCEncodeExpr                = 138,
2107226633Sdim
2108341825Sdim  /** An Objective-C \@selector expression.
2109226633Sdim   */
2110226633Sdim  CXCursor_ObjCSelectorExpr              = 139,
2111226633Sdim
2112341825Sdim  /** An Objective-C \@protocol expression.
2113226633Sdim   */
2114226633Sdim  CXCursor_ObjCProtocolExpr              = 140,
2115226633Sdim
2116341825Sdim  /** An Objective-C "bridged" cast expression, which casts between
2117226633Sdim   * Objective-C pointers and C pointers, transferring ownership in the process.
2118226633Sdim   *
2119226633Sdim   * \code
2120226633Sdim   *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
2121226633Sdim   * \endcode
2122226633Sdim   */
2123226633Sdim  CXCursor_ObjCBridgedCastExpr           = 141,
2124226633Sdim
2125341825Sdim  /** Represents a C++0x pack expansion that produces a sequence of
2126226633Sdim   * expressions.
2127226633Sdim   *
2128226633Sdim   * A pack expansion expression contains a pattern (which itself is an
2129226633Sdim   * expression) followed by an ellipsis. For example:
2130226633Sdim   *
2131226633Sdim   * \code
2132226633Sdim   * template<typename F, typename ...Types>
2133226633Sdim   * void forward(F f, Types &&...args) {
2134226633Sdim   *  f(static_cast<Types&&>(args)...);
2135226633Sdim   * }
2136226633Sdim   * \endcode
2137226633Sdim   */
2138226633Sdim  CXCursor_PackExpansionExpr             = 142,
2139226633Sdim
2140341825Sdim  /** Represents an expression that computes the length of a parameter
2141226633Sdim   * pack.
2142226633Sdim   *
2143226633Sdim   * \code
2144226633Sdim   * template<typename ...Types>
2145226633Sdim   * struct count {
2146226633Sdim   *   static const unsigned value = sizeof...(Types);
2147226633Sdim   * };
2148226633Sdim   * \endcode
2149226633Sdim   */
2150226633Sdim  CXCursor_SizeOfPackExpr                = 143,
2151226633Sdim
2152341825Sdim  /* Represents a C++ lambda expression that produces a local function
2153234353Sdim   * object.
2154234353Sdim   *
2155234353Sdim   * \code
2156234353Sdim   * void abssort(float *x, unsigned N) {
2157234353Sdim   *   std::sort(x, x + N,
2158234353Sdim   *             [](float a, float b) {
2159234353Sdim   *               return std::abs(a) < std::abs(b);
2160234353Sdim   *             });
2161234353Sdim   * }
2162234353Sdim   * \endcode
2163234353Sdim   */
2164234353Sdim  CXCursor_LambdaExpr                    = 144,
2165341825Sdim
2166341825Sdim  /** Objective-c Boolean Literal.
2167234353Sdim   */
2168234353Sdim  CXCursor_ObjCBoolLiteralExpr           = 145,
2169226633Sdim
2170341825Sdim  /** Represents the "self" expression in an Objective-C method.
2171251662Sdim   */
2172251662Sdim  CXCursor_ObjCSelfExpr                  = 146,
2173234353Sdim
2174341825Sdim  /** OpenMP 4.0 [2.4, Array Section].
2175296417Sdim   */
2176296417Sdim  CXCursor_OMPArraySectionExpr           = 147,
2177251662Sdim
2178341825Sdim  /** Represents an @available(...) check.
2179309124Sdim   */
2180309124Sdim  CXCursor_ObjCAvailabilityCheckExpr     = 148,
2181296417Sdim
2182341825Sdim  /**
2183341825Sdim   * Fixed point literal
2184341825Sdim   */
2185341825Sdim  CXCursor_FixedPointLiteral             = 149,
2186309124Sdim
2187341825Sdim  CXCursor_LastExpr                      = CXCursor_FixedPointLiteral,
2188341825Sdim
2189202879Srdivacky  /* Statements */
2190202879Srdivacky  CXCursor_FirstStmt                     = 200,
2191202879Srdivacky  /**
2192341825Sdim   * A statement whose specific kind is not exposed via this
2193202879Srdivacky   * interface.
2194202879Srdivacky   *
2195202879Srdivacky   * Unexposed statements have the same operations as any other kind of
2196202879Srdivacky   * statement; one can extract their location information, spelling,
2197202879Srdivacky   * children, etc. However, the specific kind of the statement is not
2198202879Srdivacky   * reported.
2199202879Srdivacky   */
2200202879Srdivacky  CXCursor_UnexposedStmt                 = 200,
2201341825Sdim
2202341825Sdim  /** A labelled statement in a function.
2203218893Sdim   *
2204341825Sdim   * This cursor kind is used to describe the "start_over:" label statement in
2205218893Sdim   * the following example:
2206218893Sdim   *
2207218893Sdim   * \code
2208218893Sdim   *   start_over:
2209218893Sdim   *     ++counter;
2210218893Sdim   * \endcode
2211218893Sdim   *
2212218893Sdim   */
2213218893Sdim  CXCursor_LabelStmt                     = 201,
2214203955Srdivacky
2215341825Sdim  /** A group of statements like { stmt stmt }.
2216226633Sdim   *
2217226633Sdim   * This cursor kind is used to describe compound statements, e.g. function
2218226633Sdim   * bodies.
2219226633Sdim   */
2220226633Sdim  CXCursor_CompoundStmt                  = 202,
2221226633Sdim
2222341825Sdim  /** A case statement.
2223226633Sdim   */
2224226633Sdim  CXCursor_CaseStmt                      = 203,
2225226633Sdim
2226341825Sdim  /** A default statement.
2227226633Sdim   */
2228226633Sdim  CXCursor_DefaultStmt                   = 204,
2229226633Sdim
2230341825Sdim  /** An if statement
2231226633Sdim   */
2232226633Sdim  CXCursor_IfStmt                        = 205,
2233226633Sdim
2234341825Sdim  /** A switch statement.
2235226633Sdim   */
2236226633Sdim  CXCursor_SwitchStmt                    = 206,
2237226633Sdim
2238341825Sdim  /** A while statement.
2239226633Sdim   */
2240226633Sdim  CXCursor_WhileStmt                     = 207,
2241226633Sdim
2242341825Sdim  /** A do statement.
2243226633Sdim   */
2244226633Sdim  CXCursor_DoStmt                        = 208,
2245226633Sdim
2246341825Sdim  /** A for statement.
2247226633Sdim   */
2248226633Sdim  CXCursor_ForStmt                       = 209,
2249226633Sdim
2250341825Sdim  /** A goto statement.
2251226633Sdim   */
2252226633Sdim  CXCursor_GotoStmt                      = 210,
2253226633Sdim
2254341825Sdim  /** An indirect goto statement.
2255226633Sdim   */
2256226633Sdim  CXCursor_IndirectGotoStmt              = 211,
2257226633Sdim
2258341825Sdim  /** A continue statement.
2259226633Sdim   */
2260226633Sdim  CXCursor_ContinueStmt                  = 212,
2261226633Sdim
2262341825Sdim  /** A break statement.
2263226633Sdim   */
2264226633Sdim  CXCursor_BreakStmt                     = 213,
2265226633Sdim
2266341825Sdim  /** A return statement.
2267226633Sdim   */
2268226633Sdim  CXCursor_ReturnStmt                    = 214,
2269226633Sdim
2270341825Sdim  /** A GCC inline assembly statement extension.
2271226633Sdim   */
2272243830Sdim  CXCursor_GCCAsmStmt                    = 215,
2273243830Sdim  CXCursor_AsmStmt                       = CXCursor_GCCAsmStmt,
2274226633Sdim
2275341825Sdim  /** Objective-C's overall \@try-\@catch-\@finally statement.
2276226633Sdim   */
2277226633Sdim  CXCursor_ObjCAtTryStmt                 = 216,
2278226633Sdim
2279341825Sdim  /** Objective-C's \@catch statement.
2280226633Sdim   */
2281226633Sdim  CXCursor_ObjCAtCatchStmt               = 217,
2282226633Sdim
2283341825Sdim  /** Objective-C's \@finally statement.
2284226633Sdim   */
2285226633Sdim  CXCursor_ObjCAtFinallyStmt             = 218,
2286226633Sdim
2287341825Sdim  /** Objective-C's \@throw statement.
2288226633Sdim   */
2289226633Sdim  CXCursor_ObjCAtThrowStmt               = 219,
2290226633Sdim
2291341825Sdim  /** Objective-C's \@synchronized statement.
2292226633Sdim   */
2293226633Sdim  CXCursor_ObjCAtSynchronizedStmt        = 220,
2294226633Sdim
2295341825Sdim  /** Objective-C's autorelease pool statement.
2296226633Sdim   */
2297226633Sdim  CXCursor_ObjCAutoreleasePoolStmt       = 221,
2298226633Sdim
2299341825Sdim  /** Objective-C's collection statement.
2300226633Sdim   */
2301226633Sdim  CXCursor_ObjCForCollectionStmt         = 222,
2302226633Sdim
2303341825Sdim  /** C++'s catch statement.
2304226633Sdim   */
2305226633Sdim  CXCursor_CXXCatchStmt                  = 223,
2306226633Sdim
2307341825Sdim  /** C++'s try statement.
2308226633Sdim   */
2309226633Sdim  CXCursor_CXXTryStmt                    = 224,
2310226633Sdim
2311341825Sdim  /** C++'s for (* : *) statement.
2312226633Sdim   */
2313226633Sdim  CXCursor_CXXForRangeStmt               = 225,
2314226633Sdim
2315341825Sdim  /** Windows Structured Exception Handling's try statement.
2316226633Sdim   */
2317226633Sdim  CXCursor_SEHTryStmt                    = 226,
2318226633Sdim
2319341825Sdim  /** Windows Structured Exception Handling's except statement.
2320226633Sdim   */
2321226633Sdim  CXCursor_SEHExceptStmt                 = 227,
2322226633Sdim
2323341825Sdim  /** Windows Structured Exception Handling's finally statement.
2324226633Sdim   */
2325226633Sdim  CXCursor_SEHFinallyStmt                = 228,
2326226633Sdim
2327341825Sdim  /** A MS inline assembly statement extension.
2328239462Sdim   */
2329239462Sdim  CXCursor_MSAsmStmt                     = 229,
2330239462Sdim
2331341825Sdim  /** The null statement ";": C99 6.8.3p3.
2332226633Sdim   *
2333226633Sdim   * This cursor kind is used to describe the null statement.
2334226633Sdim   */
2335226633Sdim  CXCursor_NullStmt                      = 230,
2336226633Sdim
2337341825Sdim  /** Adaptor class for mixing declarations with statements and
2338226633Sdim   * expressions.
2339226633Sdim   */
2340226633Sdim  CXCursor_DeclStmt                      = 231,
2341226633Sdim
2342341825Sdim  /** OpenMP parallel directive.
2343261991Sdim   */
2344261991Sdim  CXCursor_OMPParallelDirective          = 232,
2345226633Sdim
2346341825Sdim  /** OpenMP SIMD directive.
2347276479Sdim   */
2348276479Sdim  CXCursor_OMPSimdDirective              = 233,
2349261991Sdim
2350341825Sdim  /** OpenMP for directive.
2351276479Sdim   */
2352276479Sdim  CXCursor_OMPForDirective               = 234,
2353276479Sdim
2354341825Sdim  /** OpenMP sections directive.
2355276479Sdim   */
2356276479Sdim  CXCursor_OMPSectionsDirective          = 235,
2357276479Sdim
2358341825Sdim  /** OpenMP section directive.
2359276479Sdim   */
2360276479Sdim  CXCursor_OMPSectionDirective           = 236,
2361276479Sdim
2362341825Sdim  /** OpenMP single directive.
2363276479Sdim   */
2364276479Sdim  CXCursor_OMPSingleDirective            = 237,
2365276479Sdim
2366341825Sdim  /** OpenMP parallel for directive.
2367276479Sdim   */
2368276479Sdim  CXCursor_OMPParallelForDirective       = 238,
2369276479Sdim
2370341825Sdim  /** OpenMP parallel sections directive.
2371276479Sdim   */
2372276479Sdim  CXCursor_OMPParallelSectionsDirective  = 239,
2373276479Sdim
2374341825Sdim  /** OpenMP task directive.
2375276479Sdim   */
2376276479Sdim  CXCursor_OMPTaskDirective              = 240,
2377276479Sdim
2378341825Sdim  /** OpenMP master directive.
2379276479Sdim   */
2380276479Sdim  CXCursor_OMPMasterDirective            = 241,
2381276479Sdim
2382341825Sdim  /** OpenMP critical directive.
2383276479Sdim   */
2384276479Sdim  CXCursor_OMPCriticalDirective          = 242,
2385276479Sdim
2386341825Sdim  /** OpenMP taskyield directive.
2387276479Sdim   */
2388276479Sdim  CXCursor_OMPTaskyieldDirective         = 243,
2389276479Sdim
2390341825Sdim  /** OpenMP barrier directive.
2391276479Sdim   */
2392276479Sdim  CXCursor_OMPBarrierDirective           = 244,
2393276479Sdim
2394341825Sdim  /** OpenMP taskwait directive.
2395276479Sdim   */
2396276479Sdim  CXCursor_OMPTaskwaitDirective          = 245,
2397276479Sdim
2398341825Sdim  /** OpenMP flush directive.
2399276479Sdim   */
2400276479Sdim  CXCursor_OMPFlushDirective             = 246,
2401276479Sdim
2402341825Sdim  /** Windows Structured Exception Handling's leave statement.
2403276479Sdim   */
2404276479Sdim  CXCursor_SEHLeaveStmt                  = 247,
2405276479Sdim
2406341825Sdim  /** OpenMP ordered directive.
2407280031Sdim   */
2408280031Sdim  CXCursor_OMPOrderedDirective           = 248,
2409276479Sdim
2410341825Sdim  /** OpenMP atomic directive.
2411280031Sdim   */
2412280031Sdim  CXCursor_OMPAtomicDirective            = 249,
2413280031Sdim
2414341825Sdim  /** OpenMP for SIMD directive.
2415280031Sdim   */
2416280031Sdim  CXCursor_OMPForSimdDirective           = 250,
2417280031Sdim
2418341825Sdim  /** OpenMP parallel for SIMD directive.
2419280031Sdim   */
2420280031Sdim  CXCursor_OMPParallelForSimdDirective   = 251,
2421280031Sdim
2422341825Sdim  /** OpenMP target directive.
2423280031Sdim   */
2424280031Sdim  CXCursor_OMPTargetDirective            = 252,
2425280031Sdim
2426341825Sdim  /** OpenMP teams directive.
2427280031Sdim   */
2428280031Sdim  CXCursor_OMPTeamsDirective             = 253,
2429280031Sdim
2430341825Sdim  /** OpenMP taskgroup directive.
2431288943Sdim   */
2432296417Sdim  CXCursor_OMPTaskgroupDirective         = 254,
2433280031Sdim
2434341825Sdim  /** OpenMP cancellation point directive.
2435288943Sdim   */
2436296417Sdim  CXCursor_OMPCancellationPointDirective = 255,
2437288943Sdim
2438341825Sdim  /** OpenMP cancel directive.
2439288943Sdim   */
2440296417Sdim  CXCursor_OMPCancelDirective            = 256,
2441288943Sdim
2442341825Sdim  /** OpenMP target data directive.
2443296417Sdim   */
2444296417Sdim  CXCursor_OMPTargetDataDirective        = 257,
2445288943Sdim
2446341825Sdim  /** OpenMP taskloop directive.
2447296417Sdim   */
2448296417Sdim  CXCursor_OMPTaskLoopDirective          = 258,
2449296417Sdim
2450341825Sdim  /** OpenMP taskloop simd directive.
2451296417Sdim   */
2452296417Sdim  CXCursor_OMPTaskLoopSimdDirective      = 259,
2453296417Sdim
2454341825Sdim  /** OpenMP distribute directive.
2455296417Sdim   */
2456296417Sdim  CXCursor_OMPDistributeDirective        = 260,
2457296417Sdim
2458341825Sdim  /** OpenMP target enter data directive.
2459309124Sdim   */
2460309124Sdim  CXCursor_OMPTargetEnterDataDirective   = 261,
2461296417Sdim
2462341825Sdim  /** OpenMP target exit data directive.
2463309124Sdim   */
2464309124Sdim  CXCursor_OMPTargetExitDataDirective    = 262,
2465309124Sdim
2466341825Sdim  /** OpenMP target parallel directive.
2467309124Sdim   */
2468309124Sdim  CXCursor_OMPTargetParallelDirective    = 263,
2469309124Sdim
2470341825Sdim  /** OpenMP target parallel for directive.
2471309124Sdim   */
2472309124Sdim  CXCursor_OMPTargetParallelForDirective = 264,
2473309124Sdim
2474341825Sdim  /** OpenMP target update directive.
2475309124Sdim   */
2476309124Sdim  CXCursor_OMPTargetUpdateDirective      = 265,
2477309124Sdim
2478341825Sdim  /** OpenMP distribute parallel for directive.
2479309124Sdim   */
2480309124Sdim  CXCursor_OMPDistributeParallelForDirective = 266,
2481309124Sdim
2482341825Sdim  /** OpenMP distribute parallel for simd directive.
2483309124Sdim   */
2484309124Sdim  CXCursor_OMPDistributeParallelForSimdDirective = 267,
2485309124Sdim
2486341825Sdim  /** OpenMP distribute simd directive.
2487309124Sdim   */
2488309124Sdim  CXCursor_OMPDistributeSimdDirective = 268,
2489309124Sdim
2490341825Sdim  /** OpenMP target parallel for simd directive.
2491309124Sdim   */
2492309124Sdim  CXCursor_OMPTargetParallelForSimdDirective = 269,
2493309124Sdim
2494341825Sdim  /** OpenMP target simd directive.
2495314564Sdim   */
2496314564Sdim  CXCursor_OMPTargetSimdDirective = 270,
2497309124Sdim
2498341825Sdim  /** OpenMP teams distribute directive.
2499314564Sdim   */
2500314564Sdim  CXCursor_OMPTeamsDistributeDirective = 271,
2501314564Sdim
2502341825Sdim  /** OpenMP teams distribute simd directive.
2503314564Sdim   */
2504314564Sdim  CXCursor_OMPTeamsDistributeSimdDirective = 272,
2505314564Sdim
2506341825Sdim  /** OpenMP teams distribute parallel for simd directive.
2507314564Sdim   */
2508314564Sdim  CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2509314564Sdim
2510341825Sdim  /** OpenMP teams distribute parallel for directive.
2511314564Sdim   */
2512314564Sdim  CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2513314564Sdim
2514341825Sdim  /** OpenMP target teams directive.
2515314564Sdim   */
2516314564Sdim  CXCursor_OMPTargetTeamsDirective = 275,
2517314564Sdim
2518341825Sdim  /** OpenMP target teams distribute directive.
2519314564Sdim   */
2520314564Sdim  CXCursor_OMPTargetTeamsDistributeDirective = 276,
2521314564Sdim
2522341825Sdim  /** OpenMP target teams distribute parallel for directive.
2523314564Sdim   */
2524314564Sdim  CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2525314564Sdim
2526341825Sdim  /** OpenMP target teams distribute parallel for simd directive.
2527314564Sdim   */
2528314564Sdim  CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2529314564Sdim
2530341825Sdim  /** OpenMP target teams distribute simd directive.
2531314564Sdim   */
2532314564Sdim  CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2533314564Sdim
2534314564Sdim  CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
2535314564Sdim
2536202879Srdivacky  /**
2537341825Sdim   * Cursor that represents the translation unit itself.
2538202879Srdivacky   *
2539202879Srdivacky   * The translation unit cursor exists primarily to act as the root
2540202879Srdivacky   * cursor for traversing the contents of a translation unit.
2541202879Srdivacky   */
2542204643Srdivacky  CXCursor_TranslationUnit               = 300,
2543204643Srdivacky
2544204643Srdivacky  /* Attributes */
2545204643Srdivacky  CXCursor_FirstAttr                     = 400,
2546204643Srdivacky  /**
2547341825Sdim   * An attribute whose specific kind is not exposed via this
2548204643Srdivacky   * interface.
2549204643Srdivacky   */
2550204643Srdivacky  CXCursor_UnexposedAttr                 = 400,
2551204643Srdivacky
2552204643Srdivacky  CXCursor_IBActionAttr                  = 401,
2553204643Srdivacky  CXCursor_IBOutletAttr                  = 402,
2554208600Srdivacky  CXCursor_IBOutletCollectionAttr        = 403,
2555226633Sdim  CXCursor_CXXFinalAttr                  = 404,
2556226633Sdim  CXCursor_CXXOverrideAttr               = 405,
2557226633Sdim  CXCursor_AnnotateAttr                  = 406,
2558234353Sdim  CXCursor_AsmLabelAttr                  = 407,
2559261991Sdim  CXCursor_PackedAttr                    = 408,
2560276479Sdim  CXCursor_PureAttr                      = 409,
2561276479Sdim  CXCursor_ConstAttr                     = 410,
2562276479Sdim  CXCursor_NoDuplicateAttr               = 411,
2563276479Sdim  CXCursor_CUDAConstantAttr              = 412,
2564276479Sdim  CXCursor_CUDADeviceAttr                = 413,
2565276479Sdim  CXCursor_CUDAGlobalAttr                = 414,
2566276479Sdim  CXCursor_CUDAHostAttr                  = 415,
2567280031Sdim  CXCursor_CUDASharedAttr                = 416,
2568296417Sdim  CXCursor_VisibilityAttr                = 417,
2569296417Sdim  CXCursor_DLLExport                     = 418,
2570296417Sdim  CXCursor_DLLImport                     = 419,
2571344779Sdim  CXCursor_NSReturnsRetained             = 420,
2572344779Sdim  CXCursor_NSReturnsNotRetained          = 421,
2573344779Sdim  CXCursor_NSReturnsAutoreleased         = 422,
2574344779Sdim  CXCursor_NSConsumesSelf                = 423,
2575344779Sdim  CXCursor_NSConsumed                    = 424,
2576344779Sdim  CXCursor_ObjCException                 = 425,
2577344779Sdim  CXCursor_ObjCNSObject                  = 426,
2578344779Sdim  CXCursor_ObjCIndependentClass          = 427,
2579344779Sdim  CXCursor_ObjCPreciseLifetime           = 428,
2580344779Sdim  CXCursor_ObjCReturnsInnerPointer       = 429,
2581344779Sdim  CXCursor_ObjCRequiresSuper             = 430,
2582344779Sdim  CXCursor_ObjCRootClass                 = 431,
2583344779Sdim  CXCursor_ObjCSubclassingRestricted     = 432,
2584344779Sdim  CXCursor_ObjCExplicitProtocolImpl      = 433,
2585344779Sdim  CXCursor_ObjCDesignatedInitializer     = 434,
2586344779Sdim  CXCursor_ObjCRuntimeVisible            = 435,
2587344779Sdim  CXCursor_ObjCBoxable                   = 436,
2588344779Sdim  CXCursor_FlagEnum                      = 437,
2589344779Sdim  CXCursor_LastAttr                      = CXCursor_FlagEnum,
2590276479Sdim
2591205408Srdivacky  /* Preprocessing */
2592205408Srdivacky  CXCursor_PreprocessingDirective        = 500,
2593205408Srdivacky  CXCursor_MacroDefinition               = 501,
2594224145Sdim  CXCursor_MacroExpansion                = 502,
2595224145Sdim  CXCursor_MacroInstantiation            = CXCursor_MacroExpansion,
2596218893Sdim  CXCursor_InclusionDirective            = 503,
2597205408Srdivacky  CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
2598243830Sdim  CXCursor_LastPreprocessing             = CXCursor_InclusionDirective,
2599243830Sdim
2600243830Sdim  /* Extra Declarations */
2601243830Sdim  /**
2602341825Sdim   * A module import declaration.
2603243830Sdim   */
2604243830Sdim  CXCursor_ModuleImportDecl              = 600,
2605296417Sdim  CXCursor_TypeAliasTemplateDecl         = 601,
2606309124Sdim  /**
2607341825Sdim   * A static_assert or _Static_assert node
2608309124Sdim   */
2609309124Sdim  CXCursor_StaticAssert                  = 602,
2610314564Sdim  /**
2611341825Sdim   * a friend declaration.
2612314564Sdim   */
2613314564Sdim  CXCursor_FriendDecl                    = 603,
2614243830Sdim  CXCursor_FirstExtraDecl                = CXCursor_ModuleImportDecl,
2615314564Sdim  CXCursor_LastExtraDecl                 = CXCursor_FriendDecl,
2616288943Sdim
2617288943Sdim  /**
2618341825Sdim   * A code completion overload candidate.
2619288943Sdim   */
2620288943Sdim  CXCursor_OverloadCandidate             = 700
2621202879Srdivacky};
2622202379Srdivacky
2623202879Srdivacky/**
2624341825Sdim * A cursor representing some element in the abstract syntax tree for
2625202879Srdivacky * a translation unit.
2626202879Srdivacky *
2627203955Srdivacky * The cursor abstraction unifies the different kinds of entities in a
2628202879Srdivacky * program--declaration, statements, expressions, references to declarations,
2629202879Srdivacky * etc.--under a single "cursor" abstraction with a common set of operations.
2630202879Srdivacky * Common operation for a cursor include: getting the physical location in
2631202879Srdivacky * a source file where the cursor points, getting the name associated with a
2632202879Srdivacky * cursor, and retrieving cursors for any child nodes of a particular cursor.
2633202879Srdivacky *
2634202879Srdivacky * Cursors can be produced in two specific ways.
2635202879Srdivacky * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2636202879Srdivacky * from which one can use clang_visitChildren() to explore the rest of the
2637202879Srdivacky * translation unit. clang_getCursor() maps from a physical source location
2638202879Srdivacky * to the entity that resides at that location, allowing one to map from the
2639202879Srdivacky * source code into the AST.
2640198092Srdivacky */
2641202879Srdivackytypedef struct {
2642202879Srdivacky  enum CXCursorKind kind;
2643226633Sdim  int xdata;
2644249423Sdim  const void *data[3];
2645203955Srdivacky} CXCursor;
2646202879Srdivacky
2647198398Srdivacky/**
2648202879Srdivacky * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2649202879Srdivacky *
2650202879Srdivacky * @{
2651198398Srdivacky */
2652203955Srdivacky
2653202879Srdivacky/**
2654341825Sdim * Retrieve the NULL cursor, which represents no entity.
2655202879Srdivacky */
2656199482SrdivackyCINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2657203955Srdivacky
2658202879Srdivacky/**
2659341825Sdim * Retrieve the cursor that represents the given translation unit.
2660202879Srdivacky *
2661202879Srdivacky * The translation unit cursor can be used to start traversing the
2662202879Srdivacky * various declarations within the given translation unit.
2663202879Srdivacky */
2664202879SrdivackyCINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2665198092Srdivacky
2666202879Srdivacky/**
2667341825Sdim * Determine whether two cursors are equivalent.
2668202879Srdivacky */
2669202879SrdivackyCINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2670203955Srdivacky
2671202879Srdivacky/**
2672341825Sdim * Returns non-zero if \p cursor is null.
2673226633Sdim */
2674243830SdimCINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2675226633Sdim
2676226633Sdim/**
2677341825Sdim * Compute a hash value for the given cursor.
2678218893Sdim */
2679218893SdimCINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2680341825Sdim
2681218893Sdim/**
2682341825Sdim * Retrieve the kind of the given cursor.
2683202879Srdivacky */
2684198893SrdivackyCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2685202879Srdivacky
2686202879Srdivacky/**
2687341825Sdim * Determine whether the given cursor kind represents a declaration.
2688202879Srdivacky */
2689198893SrdivackyCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2690202879Srdivacky
2691202879Srdivacky/**
2692341825Sdim * Determine whether the given declaration is invalid.
2693341825Sdim *
2694341825Sdim * A declaration is invalid if it could not be parsed successfully.
2695341825Sdim *
2696341825Sdim * \returns non-zero if the cursor represents a declaration and it is
2697341825Sdim * invalid, otherwise NULL.
2698341825Sdim */
2699341825SdimCINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2700341825Sdim
2701341825Sdim/**
2702341825Sdim * Determine whether the given cursor kind represents a simple
2703202879Srdivacky * reference.
2704202879Srdivacky *
2705202879Srdivacky * Note that other kinds of cursors (such as expressions) can also refer to
2706202879Srdivacky * other cursors. Use clang_getCursorReferenced() to determine whether a
2707202879Srdivacky * particular cursor refers to another entity.
2708202879Srdivacky */
2709198893SrdivackyCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2710202879Srdivacky
2711202879Srdivacky/**
2712341825Sdim * Determine whether the given cursor kind represents an expression.
2713202879Srdivacky */
2714202879SrdivackyCINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2715202879Srdivacky
2716202879Srdivacky/**
2717341825Sdim * Determine whether the given cursor kind represents a statement.
2718202879Srdivacky */
2719202879SrdivackyCINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2720202879Srdivacky
2721202879Srdivacky/**
2722341825Sdim * Determine whether the given cursor kind represents an attribute.
2723224145Sdim */
2724224145SdimCINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2725224145Sdim
2726224145Sdim/**
2727341825Sdim * Determine whether the given cursor has any attributes.
2728309124Sdim */
2729309124SdimCINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2730309124Sdim
2731309124Sdim/**
2732341825Sdim * Determine whether the given cursor kind represents an invalid
2733202879Srdivacky * cursor.
2734203955Srdivacky */
2735198893SrdivackyCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2736198398Srdivacky
2737202879Srdivacky/**
2738341825Sdim * Determine whether the given cursor kind represents a translation
2739203955Srdivacky * unit.
2740202879Srdivacky */
2741202879SrdivackyCINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2742203955Srdivacky
2743204962Srdivacky/***
2744341825Sdim * Determine whether the given cursor represents a preprocessing
2745205408Srdivacky * element, such as a preprocessor directive or macro instantiation.
2746205408Srdivacky */
2747205408SrdivackyCINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2748341825Sdim
2749205408Srdivacky/***
2750341825Sdim * Determine whether the given cursor represents a currently
2751204962Srdivacky *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2752204962Srdivacky */
2753204962SrdivackyCINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2754204962Srdivacky
2755202879Srdivacky/**
2756341825Sdim * Describe the linkage of the entity referred to by a cursor.
2757204643Srdivacky */
2758204643Srdivackyenum CXLinkageKind {
2759341825Sdim  /** This value indicates that no linkage information is available
2760204643Srdivacky   * for a provided CXCursor. */
2761204643Srdivacky  CXLinkage_Invalid,
2762204643Srdivacky  /**
2763341825Sdim   * This is the linkage for variables, parameters, and so on that
2764204643Srdivacky   *  have automatic storage.  This covers normal (non-extern) local variables.
2765204643Srdivacky   */
2766204643Srdivacky  CXLinkage_NoLinkage,
2767341825Sdim  /** This is the linkage for static variables and static functions. */
2768204643Srdivacky  CXLinkage_Internal,
2769341825Sdim  /** This is the linkage for entities with external linkage that live
2770204643Srdivacky   * in C++ anonymous namespaces.*/
2771204643Srdivacky  CXLinkage_UniqueExternal,
2772341825Sdim  /** This is the linkage for entities with true, external linkage. */
2773204643Srdivacky  CXLinkage_External
2774204643Srdivacky};
2775204643Srdivacky
2776204643Srdivacky/**
2777341825Sdim * Determine the linkage of the entity referred to by a given cursor.
2778204643Srdivacky */
2779204643SrdivackyCINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2780204643Srdivacky
2781296417Sdimenum CXVisibilityKind {
2782341825Sdim  /** This value indicates that no visibility information is available
2783296417Sdim   * for a provided CXCursor. */
2784296417Sdim  CXVisibility_Invalid,
2785296417Sdim
2786341825Sdim  /** Symbol not seen by the linker. */
2787296417Sdim  CXVisibility_Hidden,
2788341825Sdim  /** Symbol seen by the linker but resolves to a symbol inside this object. */
2789296417Sdim  CXVisibility_Protected,
2790341825Sdim  /** Symbol seen by the linker and acts like a normal symbol. */
2791296417Sdim  CXVisibility_Default
2792296417Sdim};
2793296417Sdim
2794204643Srdivacky/**
2795341825Sdim * Describe the visibility of the entity referred to by a cursor.
2796296417Sdim *
2797296417Sdim * This returns the default visibility if not explicitly specified by
2798296417Sdim * a visibility attribute. The default visibility may be changed by
2799296417Sdim * commandline arguments.
2800296417Sdim *
2801296417Sdim * \param cursor The cursor to query.
2802296417Sdim *
2803296417Sdim * \returns The visibility of the cursor.
2804296417Sdim */
2805296417SdimCINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2806296417Sdim
2807296417Sdim/**
2808341825Sdim * Determine the availability of the entity that this cursor refers to,
2809239462Sdim * taking the current target platform into account.
2810212904Sdim *
2811212904Sdim * \param cursor The cursor to query.
2812212904Sdim *
2813212904Sdim * \returns The availability of the cursor.
2814212904Sdim */
2815341825SdimCINDEX_LINKAGE enum CXAvailabilityKind
2816212904Sdimclang_getCursorAvailability(CXCursor cursor);
2817212904Sdim
2818212904Sdim/**
2819239462Sdim * Describes the availability of a given entity on a particular platform, e.g.,
2820239462Sdim * a particular class might only be available on Mac OS 10.7 or newer.
2821239462Sdim */
2822239462Sdimtypedef struct CXPlatformAvailability {
2823239462Sdim  /**
2824341825Sdim   * A string that describes the platform for which this structure
2825239462Sdim   * provides availability information.
2826239462Sdim   *
2827309124Sdim   * Possible values are "ios" or "macos".
2828239462Sdim   */
2829239462Sdim  CXString Platform;
2830239462Sdim  /**
2831341825Sdim   * The version number in which this entity was introduced.
2832239462Sdim   */
2833239462Sdim  CXVersion Introduced;
2834239462Sdim  /**
2835341825Sdim   * The version number in which this entity was deprecated (but is
2836239462Sdim   * still available).
2837239462Sdim   */
2838239462Sdim  CXVersion Deprecated;
2839239462Sdim  /**
2840341825Sdim   * The version number in which this entity was obsoleted, and therefore
2841239462Sdim   * is no longer available.
2842239462Sdim   */
2843239462Sdim  CXVersion Obsoleted;
2844239462Sdim  /**
2845341825Sdim   * Whether the entity is unconditionally unavailable on this platform.
2846239462Sdim   */
2847239462Sdim  int Unavailable;
2848239462Sdim  /**
2849341825Sdim   * An optional message to provide to a user of this API, e.g., to
2850239462Sdim   * suggest replacement APIs.
2851239462Sdim   */
2852239462Sdim  CXString Message;
2853239462Sdim} CXPlatformAvailability;
2854239462Sdim
2855239462Sdim/**
2856341825Sdim * Determine the availability of the entity that this cursor refers to
2857239462Sdim * on any platforms for which availability information is known.
2858239462Sdim *
2859239462Sdim * \param cursor The cursor to query.
2860239462Sdim *
2861341825Sdim * \param always_deprecated If non-NULL, will be set to indicate whether the
2862239462Sdim * entity is deprecated on all platforms.
2863239462Sdim *
2864341825Sdim * \param deprecated_message If non-NULL, will be set to the message text
2865239462Sdim * provided along with the unconditional deprecation of this entity. The client
2866239462Sdim * is responsible for deallocating this string.
2867239462Sdim *
2868239462Sdim * \param always_unavailable If non-NULL, will be set to indicate whether the
2869239462Sdim * entity is unavailable on all platforms.
2870239462Sdim *
2871239462Sdim * \param unavailable_message If non-NULL, will be set to the message text
2872341825Sdim * provided along with the unconditional unavailability of this entity. The
2873239462Sdim * client is responsible for deallocating this string.
2874239462Sdim *
2875239462Sdim * \param availability If non-NULL, an array of CXPlatformAvailability instances
2876239462Sdim * that will be populated with platform availability information, up to either
2877239462Sdim * the number of platforms for which availability information is available (as
2878239462Sdim * returned by this function) or \c availability_size, whichever is smaller.
2879239462Sdim *
2880341825Sdim * \param availability_size The number of elements available in the
2881239462Sdim * \c availability array.
2882239462Sdim *
2883239462Sdim * \returns The number of platforms (N) for which availability information is
2884239462Sdim * available (which is unrelated to \c availability_size).
2885239462Sdim *
2886341825Sdim * Note that the client is responsible for calling
2887341825Sdim * \c clang_disposeCXPlatformAvailability to free each of the
2888341825Sdim * platform-availability structures returned. There are
2889239462Sdim * \c min(N, availability_size) such structures.
2890239462Sdim */
2891239462SdimCINDEX_LINKAGE int
2892239462Sdimclang_getCursorPlatformAvailability(CXCursor cursor,
2893239462Sdim                                    int *always_deprecated,
2894239462Sdim                                    CXString *deprecated_message,
2895239462Sdim                                    int *always_unavailable,
2896239462Sdim                                    CXString *unavailable_message,
2897239462Sdim                                    CXPlatformAvailability *availability,
2898239462Sdim                                    int availability_size);
2899239462Sdim
2900239462Sdim/**
2901341825Sdim * Free the memory associated with a \c CXPlatformAvailability structure.
2902239462Sdim */
2903239462SdimCINDEX_LINKAGE void
2904239462Sdimclang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2905341825Sdim
2906239462Sdim/**
2907341825Sdim * Describe the "language" of the entity referred to by a cursor.
2908207619Srdivacky */
2909276479Sdimenum CXLanguageKind {
2910207619Srdivacky  CXLanguage_Invalid = 0,
2911207619Srdivacky  CXLanguage_C,
2912207619Srdivacky  CXLanguage_ObjC,
2913207619Srdivacky  CXLanguage_CPlusPlus
2914207619Srdivacky};
2915207619Srdivacky
2916207619Srdivacky/**
2917341825Sdim * Determine the "language" of the entity referred to by a given cursor.
2918207619Srdivacky */
2919207619SrdivackyCINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2920207619Srdivacky
2921226633Sdim/**
2922341825Sdim * Describe the "thread-local storage (TLS) kind" of the declaration
2923327952Sdim * referred to by a cursor.
2924327952Sdim */
2925327952Sdimenum CXTLSKind {
2926327952Sdim  CXTLS_None = 0,
2927327952Sdim  CXTLS_Dynamic,
2928327952Sdim  CXTLS_Static
2929327952Sdim};
2930327952Sdim
2931327952Sdim/**
2932341825Sdim * Determine the "thread-local storage (TLS) kind" of the declaration
2933327952Sdim * referred to by a cursor.
2934327952Sdim */
2935327952SdimCINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2936327952Sdim
2937327952Sdim/**
2938341825Sdim * Returns the translation unit that a cursor originated from.
2939226633Sdim */
2940226633SdimCINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2941218893Sdim
2942207619Srdivacky/**
2943341825Sdim * A fast container representing a set of CXCursors.
2944218893Sdim */
2945218893Sdimtypedef struct CXCursorSetImpl *CXCursorSet;
2946218893Sdim
2947218893Sdim/**
2948341825Sdim * Creates an empty CXCursorSet.
2949218893Sdim */
2950249423SdimCINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2951218893Sdim
2952218893Sdim/**
2953341825Sdim * Disposes a CXCursorSet and releases its associated memory.
2954218893Sdim */
2955218893SdimCINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
2956218893Sdim
2957218893Sdim/**
2958341825Sdim * Queries a CXCursorSet to see if it contains a specific CXCursor.
2959218893Sdim *
2960218893Sdim * \returns non-zero if the set contains the specified cursor.
2961218893Sdim*/
2962218893SdimCINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
2963218893Sdim                                                   CXCursor cursor);
2964218893Sdim
2965218893Sdim/**
2966341825Sdim * Inserts a CXCursor into a CXCursorSet.
2967218893Sdim *
2968218893Sdim * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
2969218893Sdim*/
2970218893SdimCINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
2971218893Sdim                                                 CXCursor cursor);
2972218893Sdim
2973218893Sdim/**
2974341825Sdim * Determine the semantic parent of the given cursor.
2975218893Sdim *
2976218893Sdim * The semantic parent of a cursor is the cursor that semantically contains
2977218893Sdim * the given \p cursor. For many declarations, the lexical and semantic parents
2978341825Sdim * are equivalent (the lexical parent is returned by
2979218893Sdim * \c clang_getCursorLexicalParent()). They diverge when declarations or
2980218893Sdim * definitions are provided out-of-line. For example:
2981218893Sdim *
2982218893Sdim * \code
2983218893Sdim * class C {
2984218893Sdim *  void f();
2985218893Sdim * };
2986218893Sdim *
2987218893Sdim * void C::f() { }
2988218893Sdim * \endcode
2989218893Sdim *
2990276479Sdim * In the out-of-line definition of \c C::f, the semantic parent is
2991218893Sdim * the class \c C, of which this function is a member. The lexical parent is
2992218893Sdim * the place where the declaration actually occurs in the source code; in this
2993276479Sdim * case, the definition occurs in the translation unit. In general, the
2994218893Sdim * lexical parent for a given entity can change without affecting the semantics
2995218893Sdim * of the program, and the lexical parent of different declarations of the
2996218893Sdim * same entity may be different. Changing the semantic parent of a declaration,
2997218893Sdim * on the other hand, can have a major impact on semantics, and redeclarations
2998218893Sdim * of a particular entity should all have the same semantic context.
2999218893Sdim *
3000218893Sdim * In the example above, both declarations of \c C::f have \c C as their
3001218893Sdim * semantic context, while the lexical context of the first \c C::f is \c C
3002218893Sdim * and the lexical context of the second \c C::f is the translation unit.
3003218893Sdim *
3004218893Sdim * For global declarations, the semantic parent is the translation unit.
3005218893Sdim */
3006218893SdimCINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3007218893Sdim
3008218893Sdim/**
3009341825Sdim * Determine the lexical parent of the given cursor.
3010218893Sdim *
3011218893Sdim * The lexical parent of a cursor is the cursor in which the given \p cursor
3012218893Sdim * was actually written. For many declarations, the lexical and semantic parents
3013341825Sdim * are equivalent (the semantic parent is returned by
3014218893Sdim * \c clang_getCursorSemanticParent()). They diverge when declarations or
3015218893Sdim * definitions are provided out-of-line. For example:
3016218893Sdim *
3017218893Sdim * \code
3018218893Sdim * class C {
3019218893Sdim *  void f();
3020218893Sdim * };
3021218893Sdim *
3022218893Sdim * void C::f() { }
3023218893Sdim * \endcode
3024218893Sdim *
3025276479Sdim * In the out-of-line definition of \c C::f, the semantic parent is
3026218893Sdim * the class \c C, of which this function is a member. The lexical parent is
3027218893Sdim * the place where the declaration actually occurs in the source code; in this
3028276479Sdim * case, the definition occurs in the translation unit. In general, the
3029218893Sdim * lexical parent for a given entity can change without affecting the semantics
3030218893Sdim * of the program, and the lexical parent of different declarations of the
3031218893Sdim * same entity may be different. Changing the semantic parent of a declaration,
3032218893Sdim * on the other hand, can have a major impact on semantics, and redeclarations
3033218893Sdim * of a particular entity should all have the same semantic context.
3034218893Sdim *
3035218893Sdim * In the example above, both declarations of \c C::f have \c C as their
3036218893Sdim * semantic context, while the lexical context of the first \c C::f is \c C
3037218893Sdim * and the lexical context of the second \c C::f is the translation unit.
3038218893Sdim *
3039218893Sdim * For declarations written in the global scope, the lexical parent is
3040218893Sdim * the translation unit.
3041218893Sdim */
3042218893SdimCINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
3043218893Sdim
3044218893Sdim/**
3045341825Sdim * Determine the set of methods that are overridden by the given
3046218893Sdim * method.
3047218893Sdim *
3048218893Sdim * In both Objective-C and C++, a method (aka virtual member function,
3049218893Sdim * in C++) can override a virtual method in a base class. For
3050218893Sdim * Objective-C, a method is said to override any method in the class's
3051234353Sdim * base class, its protocols, or its categories' protocols, that has the same
3052234353Sdim * selector and is of the same kind (class or instance).
3053234353Sdim * If no such method exists, the search continues to the class's superclass,
3054234353Sdim * its protocols, and its categories, and so on. A method from an Objective-C
3055234353Sdim * implementation is considered to override the same methods as its
3056234353Sdim * corresponding method in the interface.
3057218893Sdim *
3058218893Sdim * For C++, a virtual member function overrides any virtual member
3059218893Sdim * function with the same signature that occurs in its base
3060218893Sdim * classes. With multiple inheritance, a virtual member function can
3061218893Sdim * override several virtual member functions coming from different
3062218893Sdim * base classes.
3063218893Sdim *
3064218893Sdim * In all cases, this function determines the immediate overridden
3065218893Sdim * method, rather than all of the overridden methods. For example, if
3066218893Sdim * a method is originally declared in a class A, then overridden in B
3067218893Sdim * (which in inherits from A) and also in C (which inherited from B),
3068218893Sdim * then the only overridden method returned from this function when
3069218893Sdim * invoked on C's method will be B's method. The client may then
3070218893Sdim * invoke this function again, given the previously-found overridden
3071218893Sdim * methods, to map out the complete method-override set.
3072218893Sdim *
3073218893Sdim * \param cursor A cursor representing an Objective-C or C++
3074218893Sdim * method. This routine will compute the set of methods that this
3075218893Sdim * method overrides.
3076341825Sdim *
3077218893Sdim * \param overridden A pointer whose pointee will be replaced with a
3078218893Sdim * pointer to an array of cursors, representing the set of overridden
3079218893Sdim * methods. If there are no overridden methods, the pointee will be
3080341825Sdim * set to NULL. The pointee must be freed via a call to
3081218893Sdim * \c clang_disposeOverriddenCursors().
3082218893Sdim *
3083218893Sdim * \param num_overridden A pointer to the number of overridden
3084218893Sdim * functions, will be set to the number of overridden functions in the
3085218893Sdim * array pointed to by \p overridden.
3086218893Sdim */
3087341825SdimCINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
3088218893Sdim                                               CXCursor **overridden,
3089218893Sdim                                               unsigned *num_overridden);
3090218893Sdim
3091218893Sdim/**
3092341825Sdim * Free the set of overridden cursors returned by \c
3093218893Sdim * clang_getOverriddenCursors().
3094218893Sdim */
3095218893SdimCINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3096218893Sdim
3097218893Sdim/**
3098341825Sdim * Retrieve the file that is included by the given inclusion directive
3099218893Sdim * cursor.
3100218893Sdim */
3101218893SdimCINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
3102341825Sdim
3103218893Sdim/**
3104202879Srdivacky * @}
3105202879Srdivacky */
3106203955Srdivacky
3107202879Srdivacky/**
3108202879Srdivacky * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3109202879Srdivacky *
3110202879Srdivacky * Cursors represent a location within the Abstract Syntax Tree (AST). These
3111202879Srdivacky * routines help map between cursors and the physical locations where the
3112202879Srdivacky * described entities occur in the source code. The mapping is provided in
3113202879Srdivacky * both directions, so one can map from source code to the AST and back.
3114202879Srdivacky *
3115202879Srdivacky * @{
3116202879Srdivacky */
3117203955Srdivacky
3118202879Srdivacky/**
3119341825Sdim * Map a source location to the cursor that describes the entity at that
3120202879Srdivacky * location in the source code.
3121202879Srdivacky *
3122202879Srdivacky * clang_getCursor() maps an arbitrary source location within a translation
3123202879Srdivacky * unit down to the most specific cursor that describes the entity at that
3124203955Srdivacky * location. For example, given an expression \c x + y, invoking
3125202879Srdivacky * clang_getCursor() with a source location pointing to "x" will return the
3126203955Srdivacky * cursor for "x"; similarly for "y". If the cursor points anywhere between
3127202879Srdivacky * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3128202879Srdivacky * will return a cursor referring to the "+" expression.
3129202879Srdivacky *
3130202879Srdivacky * \returns a cursor representing the entity at the given source location, or
3131202879Srdivacky * a NULL cursor if no such entity can be found.
3132202879Srdivacky */
3133202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
3134203955Srdivacky
3135202879Srdivacky/**
3136341825Sdim * Retrieve the physical location of the source constructor referenced
3137202879Srdivacky * by the given cursor.
3138202879Srdivacky *
3139202879Srdivacky * The location of a declaration is typically the location of the name of that
3140203955Srdivacky * declaration, where the name of that declaration would occur if it is
3141203955Srdivacky * unnamed, or some keyword that introduces that particular declaration.
3142203955Srdivacky * The location of a reference is where that reference occurs within the
3143202879Srdivacky * source code.
3144202879Srdivacky */
3145202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
3146199482Srdivacky
3147202879Srdivacky/**
3148341825Sdim * Retrieve the physical extent of the source construct referenced by
3149202879Srdivacky * the given cursor.
3150202879Srdivacky *
3151202879Srdivacky * The extent of a cursor starts with the file/line/column pointing at the
3152202879Srdivacky * first character within the source construct that the cursor refers to and
3153276479Sdim * ends with the last character within that source construct. For a
3154202879Srdivacky * declaration, the extent covers the declaration itself. For a reference,
3155202879Srdivacky * the extent covers the location of the reference (e.g., where the referenced
3156202879Srdivacky * entity was actually used).
3157202879Srdivacky */
3158202879SrdivackyCINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
3159202879Srdivacky
3160202879Srdivacky/**
3161202879Srdivacky * @}
3162202879Srdivacky */
3163341825Sdim
3164202879Srdivacky/**
3165208600Srdivacky * \defgroup CINDEX_TYPES Type information for CXCursors
3166208600Srdivacky *
3167208600Srdivacky * @{
3168208600Srdivacky */
3169208600Srdivacky
3170208600Srdivacky/**
3171341825Sdim * Describes the kind of type
3172208600Srdivacky */
3173208600Srdivackyenum CXTypeKind {
3174208600Srdivacky  /**
3175341825Sdim   * Represents an invalid type (e.g., where no type is available).
3176208600Srdivacky   */
3177208600Srdivacky  CXType_Invalid = 0,
3178208600Srdivacky
3179208600Srdivacky  /**
3180341825Sdim   * A type whose specific kind is not exposed via this
3181208600Srdivacky   * interface.
3182208600Srdivacky   */
3183208600Srdivacky  CXType_Unexposed = 1,
3184208600Srdivacky
3185208600Srdivacky  /* Builtin types */
3186208600Srdivacky  CXType_Void = 2,
3187208600Srdivacky  CXType_Bool = 3,
3188208600Srdivacky  CXType_Char_U = 4,
3189208600Srdivacky  CXType_UChar = 5,
3190208600Srdivacky  CXType_Char16 = 6,
3191208600Srdivacky  CXType_Char32 = 7,
3192208600Srdivacky  CXType_UShort = 8,
3193208600Srdivacky  CXType_UInt = 9,
3194208600Srdivacky  CXType_ULong = 10,
3195208600Srdivacky  CXType_ULongLong = 11,
3196208600Srdivacky  CXType_UInt128 = 12,
3197208600Srdivacky  CXType_Char_S = 13,
3198208600Srdivacky  CXType_SChar = 14,
3199208600Srdivacky  CXType_WChar = 15,
3200208600Srdivacky  CXType_Short = 16,
3201208600Srdivacky  CXType_Int = 17,
3202208600Srdivacky  CXType_Long = 18,
3203208600Srdivacky  CXType_LongLong = 19,
3204208600Srdivacky  CXType_Int128 = 20,
3205208600Srdivacky  CXType_Float = 21,
3206208600Srdivacky  CXType_Double = 22,
3207208600Srdivacky  CXType_LongDouble = 23,
3208208600Srdivacky  CXType_NullPtr = 24,
3209208600Srdivacky  CXType_Overload = 25,
3210208600Srdivacky  CXType_Dependent = 26,
3211208600Srdivacky  CXType_ObjCId = 27,
3212208600Srdivacky  CXType_ObjCClass = 28,
3213208600Srdivacky  CXType_ObjCSel = 29,
3214309124Sdim  CXType_Float128 = 30,
3215321369Sdim  CXType_Half = 31,
3216327952Sdim  CXType_Float16 = 32,
3217341825Sdim  CXType_ShortAccum = 33,
3218341825Sdim  CXType_Accum = 34,
3219341825Sdim  CXType_LongAccum = 35,
3220341825Sdim  CXType_UShortAccum = 36,
3221341825Sdim  CXType_UAccum = 37,
3222341825Sdim  CXType_ULongAccum = 38,
3223208600Srdivacky  CXType_FirstBuiltin = CXType_Void,
3224341825Sdim  CXType_LastBuiltin = CXType_ULongAccum,
3225208600Srdivacky
3226208600Srdivacky  CXType_Complex = 100,
3227208600Srdivacky  CXType_Pointer = 101,
3228208600Srdivacky  CXType_BlockPointer = 102,
3229208600Srdivacky  CXType_LValueReference = 103,
3230208600Srdivacky  CXType_RValueReference = 104,
3231208600Srdivacky  CXType_Record = 105,
3232208600Srdivacky  CXType_Enum = 106,
3233208600Srdivacky  CXType_Typedef = 107,
3234208600Srdivacky  CXType_ObjCInterface = 108,
3235210299Sed  CXType_ObjCObjectPointer = 109,
3236210299Sed  CXType_FunctionNoProto = 110,
3237226633Sdim  CXType_FunctionProto = 111,
3238234353Sdim  CXType_ConstantArray = 112,
3239261991Sdim  CXType_Vector = 113,
3240261991Sdim  CXType_IncompleteArray = 114,
3241261991Sdim  CXType_VariableArray = 115,
3242261991Sdim  CXType_DependentSizedArray = 116,
3243296417Sdim  CXType_MemberPointer = 117,
3244309124Sdim  CXType_Auto = 118,
3245309124Sdim
3246309124Sdim  /**
3247341825Sdim   * Represents a type that was referred to using an elaborated type keyword.
3248309124Sdim   *
3249309124Sdim   * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3250309124Sdim   */
3251321369Sdim  CXType_Elaborated = 119,
3252321369Sdim
3253321369Sdim  /* OpenCL PipeType. */
3254321369Sdim  CXType_Pipe = 120,
3255321369Sdim
3256321369Sdim  /* OpenCL builtin types. */
3257321369Sdim  CXType_OCLImage1dRO = 121,
3258321369Sdim  CXType_OCLImage1dArrayRO = 122,
3259321369Sdim  CXType_OCLImage1dBufferRO = 123,
3260321369Sdim  CXType_OCLImage2dRO = 124,
3261321369Sdim  CXType_OCLImage2dArrayRO = 125,
3262321369Sdim  CXType_OCLImage2dDepthRO = 126,
3263321369Sdim  CXType_OCLImage2dArrayDepthRO = 127,
3264321369Sdim  CXType_OCLImage2dMSAARO = 128,
3265321369Sdim  CXType_OCLImage2dArrayMSAARO = 129,
3266321369Sdim  CXType_OCLImage2dMSAADepthRO = 130,
3267321369Sdim  CXType_OCLImage2dArrayMSAADepthRO = 131,
3268321369Sdim  CXType_OCLImage3dRO = 132,
3269321369Sdim  CXType_OCLImage1dWO = 133,
3270321369Sdim  CXType_OCLImage1dArrayWO = 134,
3271321369Sdim  CXType_OCLImage1dBufferWO = 135,
3272321369Sdim  CXType_OCLImage2dWO = 136,
3273321369Sdim  CXType_OCLImage2dArrayWO = 137,
3274321369Sdim  CXType_OCLImage2dDepthWO = 138,
3275321369Sdim  CXType_OCLImage2dArrayDepthWO = 139,
3276321369Sdim  CXType_OCLImage2dMSAAWO = 140,
3277321369Sdim  CXType_OCLImage2dArrayMSAAWO = 141,
3278321369Sdim  CXType_OCLImage2dMSAADepthWO = 142,
3279321369Sdim  CXType_OCLImage2dArrayMSAADepthWO = 143,
3280321369Sdim  CXType_OCLImage3dWO = 144,
3281321369Sdim  CXType_OCLImage1dRW = 145,
3282321369Sdim  CXType_OCLImage1dArrayRW = 146,
3283321369Sdim  CXType_OCLImage1dBufferRW = 147,
3284321369Sdim  CXType_OCLImage2dRW = 148,
3285321369Sdim  CXType_OCLImage2dArrayRW = 149,
3286321369Sdim  CXType_OCLImage2dDepthRW = 150,
3287321369Sdim  CXType_OCLImage2dArrayDepthRW = 151,
3288321369Sdim  CXType_OCLImage2dMSAARW = 152,
3289321369Sdim  CXType_OCLImage2dArrayMSAARW = 153,
3290321369Sdim  CXType_OCLImage2dMSAADepthRW = 154,
3291321369Sdim  CXType_OCLImage2dArrayMSAADepthRW = 155,
3292321369Sdim  CXType_OCLImage3dRW = 156,
3293321369Sdim  CXType_OCLSampler = 157,
3294321369Sdim  CXType_OCLEvent = 158,
3295321369Sdim  CXType_OCLQueue = 159,
3296344779Sdim  CXType_OCLReserveID = 160,
3297344779Sdim
3298344779Sdim  CXType_ObjCObject = 161,
3299344779Sdim  CXType_ObjCTypeParam = 162,
3300344779Sdim  CXType_Attributed = 163,
3301344779Sdim
3302344779Sdim  CXType_OCLIntelSubgroupAVCMcePayload = 164,
3303344779Sdim  CXType_OCLIntelSubgroupAVCImePayload = 165,
3304344779Sdim  CXType_OCLIntelSubgroupAVCRefPayload = 166,
3305344779Sdim  CXType_OCLIntelSubgroupAVCSicPayload = 167,
3306344779Sdim  CXType_OCLIntelSubgroupAVCMceResult = 168,
3307344779Sdim  CXType_OCLIntelSubgroupAVCImeResult = 169,
3308344779Sdim  CXType_OCLIntelSubgroupAVCRefResult = 170,
3309344779Sdim  CXType_OCLIntelSubgroupAVCSicResult = 171,
3310344779Sdim  CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3311344779Sdim  CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3312344779Sdim  CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3313344779Sdim
3314344779Sdim  CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175
3315208600Srdivacky};
3316208600Srdivacky
3317208600Srdivacky/**
3318341825Sdim * Describes the calling convention of a function type
3319234353Sdim */
3320234353Sdimenum CXCallingConv {
3321234353Sdim  CXCallingConv_Default = 0,
3322234353Sdim  CXCallingConv_C = 1,
3323234353Sdim  CXCallingConv_X86StdCall = 2,
3324234353Sdim  CXCallingConv_X86FastCall = 3,
3325234353Sdim  CXCallingConv_X86ThisCall = 4,
3326234353Sdim  CXCallingConv_X86Pascal = 5,
3327234353Sdim  CXCallingConv_AAPCS = 6,
3328234353Sdim  CXCallingConv_AAPCS_VFP = 7,
3329314564Sdim  CXCallingConv_X86RegCall = 8,
3330249423Sdim  CXCallingConv_IntelOclBicc = 9,
3331321369Sdim  CXCallingConv_Win64 = 10,
3332322740Sdim  /* Alias for compatibility with older versions of API. */
3333322740Sdim  CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
3334256030Sdim  CXCallingConv_X86_64SysV = 11,
3335280031Sdim  CXCallingConv_X86VectorCall = 12,
3336309124Sdim  CXCallingConv_Swift = 13,
3337309124Sdim  CXCallingConv_PreserveMost = 14,
3338309124Sdim  CXCallingConv_PreserveAll = 15,
3339344779Sdim  CXCallingConv_AArch64VectorCall = 16,
3340234353Sdim
3341234353Sdim  CXCallingConv_Invalid = 100,
3342234353Sdim  CXCallingConv_Unexposed = 200
3343234353Sdim};
3344234353Sdim
3345234353Sdim/**
3346341825Sdim * The type of an element in the abstract syntax tree.
3347208600Srdivacky *
3348208600Srdivacky */
3349208600Srdivackytypedef struct {
3350208600Srdivacky  enum CXTypeKind kind;
3351208600Srdivacky  void *data[2];
3352208600Srdivacky} CXType;
3353208600Srdivacky
3354208600Srdivacky/**
3355341825Sdim * Retrieve the type of a CXCursor (if any).
3356208600Srdivacky */
3357208600SrdivackyCINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3358208600Srdivacky
3359208600Srdivacky/**
3360341825Sdim * Pretty-print the underlying type using the rules of the
3361249423Sdim * language of the translation unit from which it came.
3362249423Sdim *
3363249423Sdim * If the type is invalid, an empty string is returned.
3364249423Sdim */
3365249423SdimCINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3366249423Sdim
3367249423Sdim/**
3368341825Sdim * Retrieve the underlying type of a typedef declaration.
3369234353Sdim *
3370234353Sdim * If the cursor does not reference a typedef declaration, an invalid type is
3371234353Sdim * returned.
3372234353Sdim */
3373234353SdimCINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3374234353Sdim
3375234353Sdim/**
3376341825Sdim * Retrieve the integer type of an enum declaration.
3377234353Sdim *
3378234353Sdim * If the cursor does not reference an enum declaration, an invalid type is
3379234353Sdim * returned.
3380234353Sdim */
3381234353SdimCINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3382234353Sdim
3383234353Sdim/**
3384341825Sdim * Retrieve the integer value of an enum constant declaration as a signed
3385234353Sdim *  long long.
3386234353Sdim *
3387234353Sdim * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3388234353Sdim * Since this is also potentially a valid constant value, the kind of the cursor
3389234353Sdim * must be verified before calling this function.
3390234353Sdim */
3391234353SdimCINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3392234353Sdim
3393234353Sdim/**
3394341825Sdim * Retrieve the integer value of an enum constant declaration as an unsigned
3395234353Sdim *  long long.
3396234353Sdim *
3397234353Sdim * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3398234353Sdim * Since this is also potentially a valid constant value, the kind of the cursor
3399234353Sdim * must be verified before calling this function.
3400234353Sdim */
3401234353SdimCINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3402234353Sdim
3403234353Sdim/**
3404341825Sdim * Retrieve the bit width of a bit field declaration as an integer.
3405249423Sdim *
3406249423Sdim * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3407249423Sdim */
3408249423SdimCINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3409249423Sdim
3410249423Sdim/**
3411341825Sdim * Retrieve the number of non-variadic arguments associated with a given
3412234353Sdim * cursor.
3413234353Sdim *
3414249423Sdim * The number of arguments can be determined for calls as well as for
3415249423Sdim * declarations of functions or methods. For other cursors -1 is returned.
3416234353Sdim */
3417234353SdimCINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3418234353Sdim
3419234353Sdim/**
3420341825Sdim * Retrieve the argument cursor of a function or method.
3421234353Sdim *
3422249423Sdim * The argument cursor can be determined for calls as well as for declarations
3423249423Sdim * of functions or methods. For other cursors and for invalid indices, an
3424249423Sdim * invalid cursor is returned.
3425234353Sdim */
3426234353SdimCINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3427234353Sdim
3428234353Sdim/**
3429341825Sdim * Describes the kind of a template argument.
3430280031Sdim *
3431280031Sdim * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3432280031Sdim * element descriptions.
3433280031Sdim */
3434280031Sdimenum CXTemplateArgumentKind {
3435280031Sdim  CXTemplateArgumentKind_Null,
3436280031Sdim  CXTemplateArgumentKind_Type,
3437280031Sdim  CXTemplateArgumentKind_Declaration,
3438280031Sdim  CXTemplateArgumentKind_NullPtr,
3439280031Sdim  CXTemplateArgumentKind_Integral,
3440280031Sdim  CXTemplateArgumentKind_Template,
3441280031Sdim  CXTemplateArgumentKind_TemplateExpansion,
3442280031Sdim  CXTemplateArgumentKind_Expression,
3443280031Sdim  CXTemplateArgumentKind_Pack,
3444280031Sdim  /* Indicates an error case, preventing the kind from being deduced. */
3445280031Sdim  CXTemplateArgumentKind_Invalid
3446280031Sdim};
3447280031Sdim
3448280031Sdim/**
3449341825Sdim *Returns the number of template args of a function decl representing a
3450280031Sdim * template specialization.
3451280031Sdim *
3452280031Sdim * If the argument cursor cannot be converted into a template function
3453280031Sdim * declaration, -1 is returned.
3454280031Sdim *
3455280031Sdim * For example, for the following declaration and specialization:
3456280031Sdim *   template <typename T, int kInt, bool kBool>
3457280031Sdim *   void foo() { ... }
3458280031Sdim *
3459280031Sdim *   template <>
3460280031Sdim *   void foo<float, -7, true>();
3461280031Sdim *
3462280031Sdim * The value 3 would be returned from this call.
3463280031Sdim */
3464280031SdimCINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3465280031Sdim
3466280031Sdim/**
3467341825Sdim * Retrieve the kind of the I'th template argument of the CXCursor C.
3468280031Sdim *
3469280031Sdim * If the argument CXCursor does not represent a FunctionDecl, an invalid
3470280031Sdim * template argument kind is returned.
3471280031Sdim *
3472280031Sdim * For example, for the following declaration and specialization:
3473280031Sdim *   template <typename T, int kInt, bool kBool>
3474280031Sdim *   void foo() { ... }
3475280031Sdim *
3476280031Sdim *   template <>
3477280031Sdim *   void foo<float, -7, true>();
3478280031Sdim *
3479280031Sdim * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3480280031Sdim * respectively.
3481280031Sdim */
3482280031SdimCINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3483280031Sdim    CXCursor C, unsigned I);
3484280031Sdim
3485280031Sdim/**
3486341825Sdim * Retrieve a CXType representing the type of a TemplateArgument of a
3487280031Sdim *  function decl representing a template specialization.
3488280031Sdim *
3489280031Sdim * If the argument CXCursor does not represent a FunctionDecl whose I'th
3490280031Sdim * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3491280031Sdim * is returned.
3492280031Sdim *
3493280031Sdim * For example, for the following declaration and specialization:
3494280031Sdim *   template <typename T, int kInt, bool kBool>
3495280031Sdim *   void foo() { ... }
3496280031Sdim *
3497280031Sdim *   template <>
3498280031Sdim *   void foo<float, -7, true>();
3499280031Sdim *
3500280031Sdim * If called with I = 0, "float", will be returned.
3501280031Sdim * Invalid types will be returned for I == 1 or 2.
3502280031Sdim */
3503280031SdimCINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3504280031Sdim                                                           unsigned I);
3505280031Sdim
3506280031Sdim/**
3507341825Sdim * Retrieve the value of an Integral TemplateArgument (of a function
3508280031Sdim *  decl representing a template specialization) as a signed long long.
3509280031Sdim *
3510280031Sdim * It is undefined to call this function on a CXCursor that does not represent a
3511280031Sdim * FunctionDecl or whose I'th template argument is not an integral value.
3512280031Sdim *
3513280031Sdim * For example, for the following declaration and specialization:
3514280031Sdim *   template <typename T, int kInt, bool kBool>
3515280031Sdim *   void foo() { ... }
3516280031Sdim *
3517280031Sdim *   template <>
3518280031Sdim *   void foo<float, -7, true>();
3519280031Sdim *
3520280031Sdim * If called with I = 1 or 2, -7 or true will be returned, respectively.
3521280031Sdim * For I == 0, this function's behavior is undefined.
3522280031Sdim */
3523280031SdimCINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3524280031Sdim                                                               unsigned I);
3525280031Sdim
3526280031Sdim/**
3527341825Sdim * Retrieve the value of an Integral TemplateArgument (of a function
3528280031Sdim *  decl representing a template specialization) as an unsigned long long.
3529280031Sdim *
3530280031Sdim * It is undefined to call this function on a CXCursor that does not represent a
3531280031Sdim * FunctionDecl or whose I'th template argument is not an integral value.
3532280031Sdim *
3533280031Sdim * For example, for the following declaration and specialization:
3534280031Sdim *   template <typename T, int kInt, bool kBool>
3535280031Sdim *   void foo() { ... }
3536280031Sdim *
3537280031Sdim *   template <>
3538280031Sdim *   void foo<float, 2147483649, true>();
3539280031Sdim *
3540280031Sdim * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3541280031Sdim * For I == 0, this function's behavior is undefined.
3542280031Sdim */
3543280031SdimCINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3544280031Sdim    CXCursor C, unsigned I);
3545280031Sdim
3546280031Sdim/**
3547341825Sdim * Determine whether two CXTypes represent the same type.
3548208600Srdivacky *
3549239462Sdim * \returns non-zero if the CXTypes represent the same type and
3550239462Sdim *          zero otherwise.
3551208600Srdivacky */
3552208600SrdivackyCINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3553208600Srdivacky
3554208600Srdivacky/**
3555341825Sdim * Return the canonical type for a CXType.
3556208600Srdivacky *
3557208600Srdivacky * Clang's type system explicitly models typedefs and all the ways
3558208600Srdivacky * a specific type can be represented.  The canonical type is the underlying
3559208600Srdivacky * type with all the "sugar" removed.  For example, if 'T' is a typedef
3560208600Srdivacky * for 'int', the canonical type for 'T' would be 'int'.
3561208600Srdivacky */
3562208600SrdivackyCINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3563208600Srdivacky
3564208600Srdivacky/**
3565341825Sdim * Determine whether a CXType has the "const" qualifier set,
3566239462Sdim * without looking through typedefs that may have added "const" at a
3567239462Sdim * different level.
3568218893Sdim */
3569218893SdimCINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3570218893Sdim
3571218893Sdim/**
3572341825Sdim * Determine whether a  CXCursor that is a macro, is
3573309124Sdim * function like.
3574309124Sdim */
3575309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3576309124Sdim
3577309124Sdim/**
3578341825Sdim * Determine whether a  CXCursor that is a macro, is a
3579309124Sdim * builtin one.
3580309124Sdim */
3581309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3582309124Sdim
3583309124Sdim/**
3584341825Sdim * Determine whether a  CXCursor that is a function declaration, is an
3585309124Sdim * inline declaration.
3586309124Sdim */
3587309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3588309124Sdim
3589309124Sdim/**
3590341825Sdim * Determine whether a CXType has the "volatile" qualifier set,
3591239462Sdim * without looking through typedefs that may have added "volatile" at
3592239462Sdim * a different level.
3593218893Sdim */
3594218893SdimCINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3595218893Sdim
3596218893Sdim/**
3597341825Sdim * Determine whether a CXType has the "restrict" qualifier set,
3598239462Sdim * without looking through typedefs that may have added "restrict" at a
3599239462Sdim * different level.
3600218893Sdim */
3601218893SdimCINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3602218893Sdim
3603218893Sdim/**
3604341825Sdim * Returns the address space of the given type.
3605321369Sdim */
3606321369SdimCINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3607321369Sdim
3608321369Sdim/**
3609341825Sdim * Returns the typedef name of the given type.
3610321369Sdim */
3611321369SdimCINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3612321369Sdim
3613321369Sdim/**
3614341825Sdim * For pointer types, returns the type of the pointee.
3615208600Srdivacky */
3616208600SrdivackyCINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3617208600Srdivacky
3618208600Srdivacky/**
3619341825Sdim * Return the cursor for the declaration of the given type.
3620208600Srdivacky */
3621208600SrdivackyCINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3622208600Srdivacky
3623218893Sdim/**
3624218893Sdim * Returns the Objective-C type encoding for the specified declaration.
3625218893Sdim */
3626218893SdimCINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3627208600Srdivacky
3628208600Srdivacky/**
3629309124Sdim * Returns the Objective-C type encoding for the specified CXType.
3630309124Sdim */
3631341825SdimCINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3632309124Sdim
3633309124Sdim/**
3634341825Sdim * Retrieve the spelling of a given CXTypeKind.
3635208600Srdivacky */
3636208600SrdivackyCINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3637208600Srdivacky
3638208600Srdivacky/**
3639341825Sdim * Retrieve the calling convention associated with a function type.
3640234353Sdim *
3641234353Sdim * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3642234353Sdim */
3643234353SdimCINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3644234353Sdim
3645234353Sdim/**
3646341825Sdim * Retrieve the return type associated with a function type.
3647234353Sdim *
3648234353Sdim * If a non-function type is passed in, an invalid type is returned.
3649210299Sed */
3650210299SedCINDEX_LINKAGE CXType clang_getResultType(CXType T);
3651210299Sed
3652210299Sed/**
3653341825Sdim * Retrieve the exception specification type associated with a function type.
3654341825Sdim * This is a value of type CXCursor_ExceptionSpecificationKind.
3655321369Sdim *
3656321369Sdim * If a non-function type is passed in, an error code of -1 is returned.
3657321369Sdim */
3658321369SdimCINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3659321369Sdim
3660321369Sdim/**
3661341825Sdim * Retrieve the number of non-variadic parameters associated with a
3662239462Sdim * function type.
3663234353Sdim *
3664234353Sdim * If a non-function type is passed in, -1 is returned.
3665210299Sed */
3666234353SdimCINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3667234353Sdim
3668234353Sdim/**
3669341825Sdim * Retrieve the type of a parameter of a function type.
3670234353Sdim *
3671239462Sdim * If a non-function type is passed in or the function does not have enough
3672239462Sdim * parameters, an invalid type is returned.
3673234353Sdim */
3674234353SdimCINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3675234353Sdim
3676234353Sdim/**
3677344779Sdim * Retrieves the base type of the ObjCObjectType.
3678344779Sdim *
3679344779Sdim * If the type is not an ObjC object, an invalid type is returned.
3680344779Sdim */
3681344779SdimCINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3682344779Sdim
3683344779Sdim/**
3684344779Sdim * Retrieve the number of protocol references associated with an ObjC object/id.
3685344779Sdim *
3686344779Sdim * If the type is not an ObjC object, 0 is returned.
3687344779Sdim */
3688344779SdimCINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3689344779Sdim
3690344779Sdim/**
3691344779Sdim * Retrieve the decl for a protocol reference for an ObjC object/id.
3692344779Sdim *
3693344779Sdim * If the type is not an ObjC object or there are not enough protocol
3694344779Sdim * references, an invalid cursor is returned.
3695344779Sdim */
3696344779SdimCINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3697344779Sdim
3698344779Sdim/**
3699344779Sdim * Retreive the number of type arguments associated with an ObjC object.
3700344779Sdim *
3701344779Sdim * If the type is not an ObjC object, 0 is returned.
3702344779Sdim */
3703344779SdimCINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3704344779Sdim
3705344779Sdim/**
3706344779Sdim * Retrieve a type argument associated with an ObjC object.
3707344779Sdim *
3708344779Sdim * If the type is not an ObjC or the index is not valid,
3709344779Sdim * an invalid type is returned.
3710344779Sdim */
3711344779SdimCINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3712344779Sdim
3713344779Sdim/**
3714341825Sdim * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3715234353Sdim */
3716234353SdimCINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3717234353Sdim
3718234353Sdim/**
3719341825Sdim * Retrieve the return type associated with a given cursor.
3720234353Sdim *
3721234353Sdim * This only returns a valid type if the cursor refers to a function or method.
3722234353Sdim */
3723210299SedCINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3724210299Sed
3725210299Sed/**
3726341825Sdim * Retrieve the exception specification type associated with a given cursor.
3727341825Sdim * This is a value of type CXCursor_ExceptionSpecificationKind.
3728321369Sdim *
3729321369Sdim * This only returns a valid result if the cursor refers to a function or method.
3730321369Sdim */
3731321369SdimCINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3732321369Sdim
3733321369Sdim/**
3734341825Sdim * Return 1 if the CXType is a POD (plain old data) type, and 0
3735212904Sdim *  otherwise.
3736212904Sdim */
3737212904SdimCINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3738212904Sdim
3739212904Sdim/**
3740341825Sdim * Return the element type of an array, complex, or vector type.
3741234353Sdim *
3742234353Sdim * If a type is passed in that is not an array, complex, or vector type,
3743234353Sdim * an invalid type is returned.
3744234353Sdim */
3745234353SdimCINDEX_LINKAGE CXType clang_getElementType(CXType T);
3746234353Sdim
3747234353Sdim/**
3748341825Sdim * Return the number of elements of an array or vector type.
3749234353Sdim *
3750234353Sdim * If a type is passed in that is not an array or vector type,
3751234353Sdim * -1 is returned.
3752234353Sdim */
3753234353SdimCINDEX_LINKAGE long long clang_getNumElements(CXType T);
3754234353Sdim
3755234353Sdim/**
3756341825Sdim * Return the element type of an array type.
3757226633Sdim *
3758226633Sdim * If a non-array type is passed in, an invalid type is returned.
3759226633Sdim */
3760226633SdimCINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3761226633Sdim
3762226633Sdim/**
3763341825Sdim * Return the array size of a constant array.
3764226633Sdim *
3765226633Sdim * If a non-array type is passed in, -1 is returned.
3766226633Sdim */
3767226633SdimCINDEX_LINKAGE long long clang_getArraySize(CXType T);
3768226633Sdim
3769226633Sdim/**
3770341825Sdim * Retrieve the type named by the qualified-id.
3771309124Sdim *
3772309124Sdim * If a non-elaborated type is passed in, an invalid type is returned.
3773309124Sdim */
3774309124SdimCINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3775309124Sdim
3776309124Sdim/**
3777341825Sdim * Determine if a typedef is 'transparent' tag.
3778321369Sdim *
3779321369Sdim * A typedef is considered 'transparent' if it shares a name and spelling
3780321369Sdim * location with its underlying tag type, as is the case with the NS_ENUM macro.
3781321369Sdim *
3782321369Sdim * \returns non-zero if transparent and zero otherwise.
3783321369Sdim */
3784321369SdimCINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3785321369Sdim
3786344779Sdimenum CXTypeNullabilityKind {
3787344779Sdim  /**
3788344779Sdim   * Values of this type can never be null.
3789344779Sdim   */
3790344779Sdim  CXTypeNullability_NonNull = 0,
3791344779Sdim  /**
3792344779Sdim   * Values of this type can be null.
3793344779Sdim   */
3794344779Sdim  CXTypeNullability_Nullable = 1,
3795344779Sdim  /**
3796344779Sdim   * Whether values of this type can be null is (explicitly)
3797344779Sdim   * unspecified. This captures a (fairly rare) case where we
3798344779Sdim   * can't conclude anything about the nullability of the type even
3799344779Sdim   * though it has been considered.
3800344779Sdim   */
3801344779Sdim  CXTypeNullability_Unspecified = 2,
3802344779Sdim  /**
3803344779Sdim   * Nullability is not applicable to this type.
3804344779Sdim   */
3805344779Sdim  CXTypeNullability_Invalid = 3
3806344779Sdim};
3807344779Sdim
3808321369Sdim/**
3809344779Sdim * Retrieve the nullability kind of a pointer type.
3810344779Sdim */
3811344779SdimCINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3812344779Sdim
3813344779Sdim/**
3814341825Sdim * List the possible error codes for \c clang_Type_getSizeOf,
3815251662Sdim *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3816251662Sdim *   \c clang_Cursor_getOffsetOf.
3817251662Sdim *
3818251662Sdim * A value of this enumeration type can be returned if the target type is not
3819251662Sdim * a valid argument to sizeof, alignof or offsetof.
3820251662Sdim */
3821251662Sdimenum CXTypeLayoutError {
3822251662Sdim  /**
3823341825Sdim   * Type is of kind CXType_Invalid.
3824251662Sdim   */
3825251662Sdim  CXTypeLayoutError_Invalid = -1,
3826251662Sdim  /**
3827341825Sdim   * The type is an incomplete Type.
3828251662Sdim   */
3829251662Sdim  CXTypeLayoutError_Incomplete = -2,
3830251662Sdim  /**
3831341825Sdim   * The type is a dependent Type.
3832251662Sdim   */
3833251662Sdim  CXTypeLayoutError_Dependent = -3,
3834251662Sdim  /**
3835341825Sdim   * The type is not a constant size type.
3836251662Sdim   */
3837251662Sdim  CXTypeLayoutError_NotConstantSize = -4,
3838251662Sdim  /**
3839341825Sdim   * The Field name is not valid for this record.
3840251662Sdim   */
3841251662Sdim  CXTypeLayoutError_InvalidFieldName = -5
3842251662Sdim};
3843251662Sdim
3844251662Sdim/**
3845341825Sdim * Return the alignment of a type in bytes as per C++[expr.alignof]
3846251662Sdim *   standard.
3847251662Sdim *
3848251662Sdim * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3849251662Sdim * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3850251662Sdim *   is returned.
3851251662Sdim * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3852251662Sdim *   returned.
3853251662Sdim * If the type declaration is not a constant size type,
3854251662Sdim *   CXTypeLayoutError_NotConstantSize is returned.
3855251662Sdim */
3856251662SdimCINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3857251662Sdim
3858251662Sdim/**
3859341825Sdim * Return the class type of an member pointer type.
3860261991Sdim *
3861261991Sdim * If a non-member-pointer type is passed in, an invalid type is returned.
3862261991Sdim */
3863261991SdimCINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3864261991Sdim
3865261991Sdim/**
3866341825Sdim * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3867251662Sdim *
3868251662Sdim * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3869251662Sdim * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3870251662Sdim *   is returned.
3871251662Sdim * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3872251662Sdim *   returned.
3873251662Sdim */
3874251662SdimCINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3875251662Sdim
3876251662Sdim/**
3877341825Sdim * Return the offset of a field named S in a record of type T in bits
3878251662Sdim *   as it would be returned by __offsetof__ as per C++11[18.2p4]
3879251662Sdim *
3880251662Sdim * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3881251662Sdim *   is returned.
3882251662Sdim * If the field's type declaration is an incomplete type,
3883251662Sdim *   CXTypeLayoutError_Incomplete is returned.
3884251662Sdim * If the field's type declaration is a dependent type,
3885251662Sdim *   CXTypeLayoutError_Dependent is returned.
3886251662Sdim * If the field's name S is not found,
3887251662Sdim *   CXTypeLayoutError_InvalidFieldName is returned.
3888251662Sdim */
3889251662SdimCINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3890251662Sdim
3891288943Sdim/**
3892344779Sdim * Return the type that was modified by this attributed type.
3893344779Sdim *
3894344779Sdim * If the type is not an attributed type, an invalid type is returned.
3895344779Sdim */
3896344779SdimCINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3897344779Sdim
3898344779Sdim/**
3899341825Sdim * Return the offset of the field represented by the Cursor.
3900288943Sdim *
3901288943Sdim * If the cursor is not a field declaration, -1 is returned.
3902288943Sdim * If the cursor semantic parent is not a record field declaration,
3903288943Sdim *   CXTypeLayoutError_Invalid is returned.
3904288943Sdim * If the field's type declaration is an incomplete type,
3905288943Sdim *   CXTypeLayoutError_Incomplete is returned.
3906288943Sdim * If the field's type declaration is a dependent type,
3907288943Sdim *   CXTypeLayoutError_Dependent is returned.
3908288943Sdim * If the field's name S is not found,
3909288943Sdim *   CXTypeLayoutError_InvalidFieldName is returned.
3910288943Sdim */
3911288943SdimCINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3912288943Sdim
3913288943Sdim/**
3914341825Sdim * Determine whether the given cursor represents an anonymous record
3915288943Sdim * declaration.
3916288943Sdim */
3917288943SdimCINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3918288943Sdim
3919261991Sdimenum CXRefQualifierKind {
3920341825Sdim  /** No ref-qualifier was provided. */
3921261991Sdim  CXRefQualifier_None = 0,
3922341825Sdim  /** An lvalue ref-qualifier was provided (\c &). */
3923261991Sdim  CXRefQualifier_LValue,
3924341825Sdim  /** An rvalue ref-qualifier was provided (\c &&). */
3925261991Sdim  CXRefQualifier_RValue
3926261991Sdim};
3927261991Sdim
3928251662Sdim/**
3929341825Sdim * Returns the number of template arguments for given template
3930314564Sdim * specialization, or -1 if type \c T is not a template specialization.
3931276479Sdim */
3932276479SdimCINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3933276479Sdim
3934276479Sdim/**
3935341825Sdim * Returns the type template argument of a template class specialization
3936276479Sdim * at given index.
3937276479Sdim *
3938276479Sdim * This function only returns template type arguments and does not handle
3939276479Sdim * template template arguments or variadic packs.
3940276479Sdim */
3941276479SdimCINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
3942276479Sdim
3943276479Sdim/**
3944341825Sdim * Retrieve the ref-qualifier kind of a function or method.
3945261991Sdim *
3946261991Sdim * The ref-qualifier is returned for C++ functions or methods. For other types
3947261991Sdim * or non-C++ declarations, CXRefQualifier_None is returned.
3948261991Sdim */
3949261991SdimCINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
3950261991Sdim
3951261991Sdim/**
3952341825Sdim * Returns non-zero if the cursor specifies a Record member that is a
3953251662Sdim *   bitfield.
3954251662Sdim */
3955251662SdimCINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
3956251662Sdim
3957251662Sdim/**
3958341825Sdim * Returns 1 if the base class specified by the cursor with kind
3959212904Sdim *   CX_CXXBaseSpecifier is virtual.
3960212904Sdim */
3961212904SdimCINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
3962341825Sdim
3963212904Sdim/**
3964341825Sdim * Represents the C++ access control level to a base class for a
3965212904Sdim * cursor with kind CX_CXXBaseSpecifier.
3966212904Sdim */
3967212904Sdimenum CX_CXXAccessSpecifier {
3968212904Sdim  CX_CXXInvalidAccessSpecifier,
3969212904Sdim  CX_CXXPublic,
3970212904Sdim  CX_CXXProtected,
3971212904Sdim  CX_CXXPrivate
3972212904Sdim};
3973212904Sdim
3974212904Sdim/**
3975341825Sdim * Returns the access control level for the referenced object.
3976251662Sdim *
3977251662Sdim * If the cursor refers to a C++ declaration, its access control level within its
3978251662Sdim * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
3979251662Sdim * access specifier, the specifier itself is returned.
3980212904Sdim */
3981212904SdimCINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
3982212904Sdim
3983212904Sdim/**
3984341825Sdim * Represents the storage classes as declared in the source. CX_SC_Invalid
3985280031Sdim * was added for the case that the passed cursor in not a declaration.
3986280031Sdim */
3987280031Sdimenum CX_StorageClass {
3988280031Sdim  CX_SC_Invalid,
3989280031Sdim  CX_SC_None,
3990280031Sdim  CX_SC_Extern,
3991280031Sdim  CX_SC_Static,
3992280031Sdim  CX_SC_PrivateExtern,
3993280031Sdim  CX_SC_OpenCLWorkGroupLocal,
3994280031Sdim  CX_SC_Auto,
3995280031Sdim  CX_SC_Register
3996280031Sdim};
3997280031Sdim
3998280031Sdim/**
3999341825Sdim * Returns the storage class for a function or variable declaration.
4000280031Sdim *
4001280031Sdim * If the passed in Cursor is not a function or variable declaration,
4002280031Sdim * CX_SC_Invalid is returned else the storage class.
4003280031Sdim */
4004280031SdimCINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4005280031Sdim
4006280031Sdim/**
4007341825Sdim * Determine the number of overloaded declarations referenced by a
4008218893Sdim * \c CXCursor_OverloadedDeclRef cursor.
4009218893Sdim *
4010218893Sdim * \param cursor The cursor whose overloaded declarations are being queried.
4011218893Sdim *
4012218893Sdim * \returns The number of overloaded declarations referenced by \c cursor. If it
4013218893Sdim * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4014218893Sdim */
4015218893SdimCINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
4016218893Sdim
4017218893Sdim/**
4018341825Sdim * Retrieve a cursor for one of the overloaded declarations referenced
4019218893Sdim * by a \c CXCursor_OverloadedDeclRef cursor.
4020218893Sdim *
4021218893Sdim * \param cursor The cursor whose overloaded declarations are being queried.
4022218893Sdim *
4023218893Sdim * \param index The zero-based index into the set of overloaded declarations in
4024218893Sdim * the cursor.
4025218893Sdim *
4026341825Sdim * \returns A cursor representing the declaration referenced by the given
4027341825Sdim * \c cursor at the specified \c index. If the cursor does not have an
4028218893Sdim * associated set of overloaded declarations, or if the index is out of bounds,
4029218893Sdim * returns \c clang_getNullCursor();
4030218893Sdim */
4031341825SdimCINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
4032218893Sdim                                                unsigned index);
4033341825Sdim
4034218893Sdim/**
4035208600Srdivacky * @}
4036208600Srdivacky */
4037341825Sdim
4038212904Sdim/**
4039212904Sdim * \defgroup CINDEX_ATTRIBUTES Information for attributes
4040212904Sdim *
4041212904Sdim * @{
4042212904Sdim */
4043208600Srdivacky
4044208600Srdivacky/**
4045341825Sdim * For cursors representing an iboutletcollection attribute,
4046212904Sdim *  this function returns the collection element type.
4047212904Sdim *
4048212904Sdim */
4049212904SdimCINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
4050212904Sdim
4051212904Sdim/**
4052212904Sdim * @}
4053212904Sdim */
4054212904Sdim
4055212904Sdim/**
4056202879Srdivacky * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4057202879Srdivacky *
4058202879Srdivacky * These routines provide the ability to traverse the abstract syntax tree
4059202879Srdivacky * using cursors.
4060202879Srdivacky *
4061202879Srdivacky * @{
4062202879Srdivacky */
4063203955Srdivacky
4064202879Srdivacky/**
4065341825Sdim * Describes how the traversal of the children of a particular
4066202879Srdivacky * cursor should proceed after visiting a particular child cursor.
4067202879Srdivacky *
4068202879Srdivacky * A value of this enumeration type should be returned by each
4069202879Srdivacky * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4070202879Srdivacky */
4071202879Srdivackyenum CXChildVisitResult {
4072202879Srdivacky  /**
4073341825Sdim   * Terminates the cursor traversal.
4074202879Srdivacky   */
4075202879Srdivacky  CXChildVisit_Break,
4076203955Srdivacky  /**
4077341825Sdim   * Continues the cursor traversal with the next sibling of
4078202879Srdivacky   * the cursor just visited, without visiting its children.
4079202879Srdivacky   */
4080202879Srdivacky  CXChildVisit_Continue,
4081202879Srdivacky  /**
4082341825Sdim   * Recursively traverse the children of this cursor, using
4083202879Srdivacky   * the same visitor and client data.
4084202879Srdivacky   */
4085202879Srdivacky  CXChildVisit_Recurse
4086202879Srdivacky};
4087202879Srdivacky
4088202879Srdivacky/**
4089341825Sdim * Visitor invoked for each cursor found by a traversal.
4090202879Srdivacky *
4091202879Srdivacky * This visitor function will be invoked for each cursor found by
4092202879Srdivacky * clang_visitCursorChildren(). Its first argument is the cursor being
4093202879Srdivacky * visited, its second argument is the parent visitor for that cursor,
4094202879Srdivacky * and its third argument is the client data provided to
4095202879Srdivacky * clang_visitCursorChildren().
4096202879Srdivacky *
4097202879Srdivacky * The visitor should return one of the \c CXChildVisitResult values
4098202879Srdivacky * to direct clang_visitCursorChildren().
4099202879Srdivacky */
4100203955Srdivackytypedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4101203955Srdivacky                                                   CXCursor parent,
4102202879Srdivacky                                                   CXClientData client_data);
4103202879Srdivacky
4104202879Srdivacky/**
4105341825Sdim * Visit the children of a particular cursor.
4106202879Srdivacky *
4107202879Srdivacky * This function visits all the direct children of the given cursor,
4108202879Srdivacky * invoking the given \p visitor function with the cursors of each
4109202879Srdivacky * visited child. The traversal may be recursive, if the visitor returns
4110202879Srdivacky * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4111202879Srdivacky * the visitor returns \c CXChildVisit_Break.
4112202879Srdivacky *
4113202879Srdivacky * \param parent the cursor whose child may be visited. All kinds of
4114203955Srdivacky * cursors can be visited, including invalid cursors (which, by
4115202879Srdivacky * definition, have no children).
4116202879Srdivacky *
4117202879Srdivacky * \param visitor the visitor function that will be invoked for each
4118202879Srdivacky * child of \p parent.
4119202879Srdivacky *
4120202879Srdivacky * \param client_data pointer data supplied by the client, which will
4121202879Srdivacky * be passed to the visitor each time it is invoked.
4122202879Srdivacky *
4123202879Srdivacky * \returns a non-zero value if the traversal was terminated
4124202879Srdivacky * prematurely by the visitor returning \c CXChildVisit_Break.
4125202879Srdivacky */
4126203955SrdivackyCINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
4127202879Srdivacky                                            CXCursorVisitor visitor,
4128202879Srdivacky                                            CXClientData client_data);
4129218893Sdim#ifdef __has_feature
4130218893Sdim#  if __has_feature(blocks)
4131218893Sdim/**
4132341825Sdim * Visitor invoked for each cursor found by a traversal.
4133218893Sdim *
4134218893Sdim * This visitor block will be invoked for each cursor found by
4135218893Sdim * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4136218893Sdim * visited, its second argument is the parent visitor for that cursor.
4137218893Sdim *
4138218893Sdim * The visitor should return one of the \c CXChildVisitResult values
4139218893Sdim * to direct clang_visitChildrenWithBlock().
4140218893Sdim */
4141341825Sdimtypedef enum CXChildVisitResult
4142218893Sdim     (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
4143203955Srdivacky
4144202879Srdivacky/**
4145218893Sdim * Visits the children of a cursor using the specified block.  Behaves
4146218893Sdim * identically to clang_visitChildren() in all other respects.
4147218893Sdim */
4148309124SdimCINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
4149309124Sdim                                                    CXCursorVisitorBlock block);
4150218893Sdim#  endif
4151218893Sdim#endif
4152218893Sdim
4153218893Sdim/**
4154202879Srdivacky * @}
4155202879Srdivacky */
4156203955Srdivacky
4157202879Srdivacky/**
4158202879Srdivacky * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4159202879Srdivacky *
4160203955Srdivacky * These routines provide the ability to determine references within and
4161202879Srdivacky * across translation units, by providing the names of the entities referenced
4162202879Srdivacky * by cursors, follow reference cursors to the declarations they reference,
4163202879Srdivacky * and associate declarations with their definitions.
4164202879Srdivacky *
4165202879Srdivacky * @{
4166202879Srdivacky */
4167203955Srdivacky
4168202879Srdivacky/**
4169341825Sdim * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4170202879Srdivacky * by the given cursor.
4171202879Srdivacky *
4172202879Srdivacky * A Unified Symbol Resolution (USR) is a string that identifies a particular
4173202879Srdivacky * entity (function, class, variable, etc.) within a program. USRs can be
4174202879Srdivacky * compared across translation units to determine, e.g., when references in
4175202879Srdivacky * one translation refer to an entity defined in another translation unit.
4176202879Srdivacky */
4177202879SrdivackyCINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4178202879Srdivacky
4179202879Srdivacky/**
4180341825Sdim * Construct a USR for a specified Objective-C class.
4181205219Srdivacky */
4182205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4183205219Srdivacky
4184205219Srdivacky/**
4185341825Sdim * Construct a USR for a specified Objective-C category.
4186205219Srdivacky */
4187205219SrdivackyCINDEX_LINKAGE CXString
4188205219Srdivacky  clang_constructUSR_ObjCCategory(const char *class_name,
4189205219Srdivacky                                 const char *category_name);
4190205219Srdivacky
4191205219Srdivacky/**
4192341825Sdim * Construct a USR for a specified Objective-C protocol.
4193205219Srdivacky */
4194205219SrdivackyCINDEX_LINKAGE CXString
4195205219Srdivacky  clang_constructUSR_ObjCProtocol(const char *protocol_name);
4196205219Srdivacky
4197205219Srdivacky/**
4198341825Sdim * Construct a USR for a specified Objective-C instance variable and
4199205219Srdivacky *   the USR for its containing class.
4200205219Srdivacky */
4201205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4202205219Srdivacky                                                    CXString classUSR);
4203205219Srdivacky
4204205219Srdivacky/**
4205341825Sdim * Construct a USR for a specified Objective-C method and
4206205219Srdivacky *   the USR for its containing class.
4207205219Srdivacky */
4208205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4209205219Srdivacky                                                      unsigned isInstanceMethod,
4210205219Srdivacky                                                      CXString classUSR);
4211205219Srdivacky
4212205219Srdivacky/**
4213341825Sdim * Construct a USR for a specified Objective-C property and the USR
4214205219Srdivacky *  for its containing class.
4215205219Srdivacky */
4216205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4217205219Srdivacky                                                        CXString classUSR);
4218205219Srdivacky
4219205219Srdivacky/**
4220341825Sdim * Retrieve a name for the entity referenced by this cursor.
4221202879Srdivacky */
4222199482SrdivackyCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4223198398Srdivacky
4224218893Sdim/**
4225341825Sdim * Retrieve a range for a piece that forms the cursors spelling name.
4226234353Sdim * Most of the times there is only one range for the complete spelling but for
4227276479Sdim * Objective-C methods and Objective-C message expressions, there are multiple
4228276479Sdim * pieces for each selector identifier.
4229341825Sdim *
4230234353Sdim * \param pieceIndex the index of the spelling name piece. If this is greater
4231234353Sdim * than the actual number of pieces, it will return a NULL (invalid) range.
4232341825Sdim *
4233234353Sdim * \param options Reserved.
4234234353Sdim */
4235234353SdimCINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
4236234353Sdim                                                          unsigned pieceIndex,
4237234353Sdim                                                          unsigned options);
4238234353Sdim
4239234353Sdim/**
4240341825Sdim * Opaque pointer representing a policy that controls pretty printing
4241341825Sdim * for \c clang_getCursorPrettyPrinted.
4242341825Sdim */
4243341825Sdimtypedef void *CXPrintingPolicy;
4244341825Sdim
4245341825Sdim/**
4246341825Sdim * Properties for the printing policy.
4247218893Sdim *
4248341825Sdim * See \c clang::PrintingPolicy for more information.
4249341825Sdim */
4250341825Sdimenum CXPrintingPolicyProperty {
4251341825Sdim  CXPrintingPolicy_Indentation,
4252341825Sdim  CXPrintingPolicy_SuppressSpecifiers,
4253341825Sdim  CXPrintingPolicy_SuppressTagKeyword,
4254341825Sdim  CXPrintingPolicy_IncludeTagDefinition,
4255341825Sdim  CXPrintingPolicy_SuppressScope,
4256341825Sdim  CXPrintingPolicy_SuppressUnwrittenScope,
4257341825Sdim  CXPrintingPolicy_SuppressInitializers,
4258341825Sdim  CXPrintingPolicy_ConstantArraySizeAsWritten,
4259341825Sdim  CXPrintingPolicy_AnonymousTagLocations,
4260341825Sdim  CXPrintingPolicy_SuppressStrongLifetime,
4261341825Sdim  CXPrintingPolicy_SuppressLifetimeQualifiers,
4262341825Sdim  CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4263341825Sdim  CXPrintingPolicy_Bool,
4264341825Sdim  CXPrintingPolicy_Restrict,
4265341825Sdim  CXPrintingPolicy_Alignof,
4266341825Sdim  CXPrintingPolicy_UnderscoreAlignof,
4267341825Sdim  CXPrintingPolicy_UseVoidForZeroParams,
4268341825Sdim  CXPrintingPolicy_TerseOutput,
4269341825Sdim  CXPrintingPolicy_PolishForDeclaration,
4270341825Sdim  CXPrintingPolicy_Half,
4271341825Sdim  CXPrintingPolicy_MSWChar,
4272341825Sdim  CXPrintingPolicy_IncludeNewlines,
4273341825Sdim  CXPrintingPolicy_MSVCFormatting,
4274341825Sdim  CXPrintingPolicy_ConstantsAsWritten,
4275341825Sdim  CXPrintingPolicy_SuppressImplicitBase,
4276341825Sdim  CXPrintingPolicy_FullyQualifiedName,
4277341825Sdim
4278341825Sdim  CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4279341825Sdim};
4280341825Sdim
4281341825Sdim/**
4282341825Sdim * Get a property value for the given printing policy.
4283341825Sdim */
4284341825SdimCINDEX_LINKAGE unsigned
4285341825Sdimclang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4286341825Sdim                                 enum CXPrintingPolicyProperty Property);
4287341825Sdim
4288341825Sdim/**
4289341825Sdim * Set a property value for the given printing policy.
4290341825Sdim */
4291341825SdimCINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4292341825Sdim                                                     enum CXPrintingPolicyProperty Property,
4293341825Sdim                                                     unsigned Value);
4294341825Sdim
4295341825Sdim/**
4296341825Sdim * Retrieve the default policy for the cursor.
4297341825Sdim *
4298341825Sdim * The policy should be released after use with \c
4299341825Sdim * clang_PrintingPolicy_dispose.
4300341825Sdim */
4301341825SdimCINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4302341825Sdim
4303341825Sdim/**
4304341825Sdim * Release a printing policy.
4305341825Sdim */
4306341825SdimCINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4307341825Sdim
4308341825Sdim/**
4309341825Sdim * Pretty print declarations.
4310341825Sdim *
4311341825Sdim * \param Cursor The cursor representing a declaration.
4312341825Sdim *
4313341825Sdim * \param Policy The policy to control the entities being printed. If
4314341825Sdim * NULL, a default policy is used.
4315341825Sdim *
4316341825Sdim * \returns The pretty printed declaration or the empty string for
4317341825Sdim * other cursors.
4318341825Sdim */
4319341825SdimCINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4320341825Sdim                                                     CXPrintingPolicy Policy);
4321341825Sdim
4322341825Sdim/**
4323341825Sdim * Retrieve the display name for the entity referenced by this cursor.
4324341825Sdim *
4325218893Sdim * The display name contains extra information that helps identify the cursor,
4326341825Sdim * such as the parameters of a function or template or the arguments of a
4327218893Sdim * class template specialization.
4328218893Sdim */
4329218893SdimCINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
4330341825Sdim
4331341825Sdim/** For a cursor that is a reference, retrieve a cursor representing the
4332202879Srdivacky * entity that it references.
4333202879Srdivacky *
4334202879Srdivacky * Reference cursors refer to other entities in the AST. For example, an
4335202879Srdivacky * Objective-C superclass reference cursor refers to an Objective-C class.
4336203955Srdivacky * This function produces the cursor for the Objective-C class from the
4337202879Srdivacky * cursor for the superclass reference. If the input cursor is a declaration or
4338202879Srdivacky * definition, it returns that declaration or definition unchanged.
4339203955Srdivacky * Otherwise, returns the NULL cursor.
4340202879Srdivacky */
4341202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
4342202879Srdivacky
4343203955Srdivacky/**
4344341825Sdim *  For a cursor that is either a reference to or a declaration
4345202879Srdivacky *  of some entity, retrieve a cursor that describes the definition of
4346202879Srdivacky *  that entity.
4347202879Srdivacky *
4348202879Srdivacky *  Some entities can be declared multiple times within a translation
4349202879Srdivacky *  unit, but only one of those declarations can also be a
4350202879Srdivacky *  definition. For example, given:
4351202879Srdivacky *
4352202879Srdivacky *  \code
4353202879Srdivacky *  int f(int, int);
4354202879Srdivacky *  int g(int x, int y) { return f(x, y); }
4355202879Srdivacky *  int f(int a, int b) { return a + b; }
4356202879Srdivacky *  int f(int, int);
4357202879Srdivacky *  \endcode
4358202879Srdivacky *
4359202879Srdivacky *  there are three declarations of the function "f", but only the
4360202879Srdivacky *  second one is a definition. The clang_getCursorDefinition()
4361202879Srdivacky *  function will take any cursor pointing to a declaration of "f"
4362202879Srdivacky *  (the first or fourth lines of the example) or a cursor referenced
4363202879Srdivacky *  that uses "f" (the call to "f' inside "g") and will return a
4364202879Srdivacky *  declaration cursor pointing to the definition (the second "f"
4365202879Srdivacky *  declaration).
4366202879Srdivacky *
4367202879Srdivacky *  If given a cursor for which there is no corresponding definition,
4368202879Srdivacky *  e.g., because there is no definition of that entity within this
4369202879Srdivacky *  translation unit, returns a NULL cursor.
4370202879Srdivacky */
4371202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4372202879Srdivacky
4373203955Srdivacky/**
4374341825Sdim * Determine whether the declaration pointed to by this cursor
4375202879Srdivacky * is also a definition of that entity.
4376202879Srdivacky */
4377202879SrdivackyCINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4378202879Srdivacky
4379202879Srdivacky/**
4380341825Sdim * Retrieve the canonical cursor corresponding to the given cursor.
4381218893Sdim *
4382218893Sdim * In the C family of languages, many kinds of entities can be declared several
4383218893Sdim * times within a single translation unit. For example, a structure type can
4384218893Sdim * be forward-declared (possibly multiple times) and later defined:
4385218893Sdim *
4386218893Sdim * \code
4387218893Sdim * struct X;
4388218893Sdim * struct X;
4389218893Sdim * struct X {
4390218893Sdim *   int member;
4391218893Sdim * };
4392218893Sdim * \endcode
4393218893Sdim *
4394341825Sdim * The declarations and the definition of \c X are represented by three
4395341825Sdim * different cursors, all of which are declarations of the same underlying
4396218893Sdim * entity. One of these cursor is considered the "canonical" cursor, which
4397341825Sdim * is effectively the representative for the underlying entity. One can
4398218893Sdim * determine if two cursors are declarations of the same underlying entity by
4399218893Sdim * comparing their canonical cursors.
4400218893Sdim *
4401218893Sdim * \returns The canonical cursor for the entity referred to by the given cursor.
4402218893Sdim */
4403218893SdimCINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4404218893Sdim
4405218893Sdim/**
4406341825Sdim * If the cursor points to a selector identifier in an Objective-C
4407276479Sdim * method or message expression, this returns the selector index.
4408234353Sdim *
4409239462Sdim * After getting a cursor with #clang_getCursor, this can be called to
4410234353Sdim * determine if the location points to a selector identifier.
4411234353Sdim *
4412276479Sdim * \returns The selector index if the cursor is an Objective-C method or message
4413234353Sdim * expression and the cursor is pointing to a selector identifier, or -1
4414234353Sdim * otherwise.
4415234353Sdim */
4416234353SdimCINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4417234353Sdim
4418234353Sdim/**
4419341825Sdim * Given a cursor pointing to a C++ method call or an Objective-C
4420276479Sdim * message, returns non-zero if the method/message is "dynamic", meaning:
4421341825Sdim *
4422239462Sdim * For a C++ method: the call is virtual.
4423276479Sdim * For an Objective-C message: the receiver is an object instance, not 'super'
4424276479Sdim * or a specific class.
4425341825Sdim *
4426239462Sdim * If the method/message is "static" or the cursor does not point to a
4427239462Sdim * method/message, it will return zero.
4428239462Sdim */
4429239462SdimCINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4430239462Sdim
4431239462Sdim/**
4432341825Sdim * Given a cursor pointing to an Objective-C message or property
4433321369Sdim * reference, or C++ method call, returns the CXType of the receiver.
4434243830Sdim */
4435243830SdimCINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4436243830Sdim
4437243830Sdim/**
4438341825Sdim * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4439251662Sdim */
4440251662Sdimtypedef enum {
4441251662Sdim  CXObjCPropertyAttr_noattr    = 0x00,
4442251662Sdim  CXObjCPropertyAttr_readonly  = 0x01,
4443251662Sdim  CXObjCPropertyAttr_getter    = 0x02,
4444251662Sdim  CXObjCPropertyAttr_assign    = 0x04,
4445251662Sdim  CXObjCPropertyAttr_readwrite = 0x08,
4446251662Sdim  CXObjCPropertyAttr_retain    = 0x10,
4447251662Sdim  CXObjCPropertyAttr_copy      = 0x20,
4448251662Sdim  CXObjCPropertyAttr_nonatomic = 0x40,
4449251662Sdim  CXObjCPropertyAttr_setter    = 0x80,
4450251662Sdim  CXObjCPropertyAttr_atomic    = 0x100,
4451251662Sdim  CXObjCPropertyAttr_weak      = 0x200,
4452251662Sdim  CXObjCPropertyAttr_strong    = 0x400,
4453309124Sdim  CXObjCPropertyAttr_unsafe_unretained = 0x800,
4454309124Sdim  CXObjCPropertyAttr_class = 0x1000
4455251662Sdim} CXObjCPropertyAttrKind;
4456251662Sdim
4457251662Sdim/**
4458341825Sdim * Given a cursor that represents a property declaration, return the
4459251662Sdim * associated property attributes. The bits are formed from
4460251662Sdim * \c CXObjCPropertyAttrKind.
4461251662Sdim *
4462251662Sdim * \param reserved Reserved for future use, pass 0.
4463251662Sdim */
4464251662SdimCINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4465251662Sdim                                                             unsigned reserved);
4466251662Sdim
4467251662Sdim/**
4468344779Sdim * Given a cursor that represents a property declaration, return the
4469344779Sdim * name of the method that implements the getter.
4470344779Sdim */
4471344779SdimCINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4472344779Sdim
4473344779Sdim/**
4474344779Sdim * Given a cursor that represents a property declaration, return the
4475344779Sdim * name of the method that implements the setter, if any.
4476344779Sdim */
4477344779SdimCINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4478344779Sdim
4479344779Sdim/**
4480341825Sdim * 'Qualifiers' written next to the return and parameter types in
4481276479Sdim * Objective-C method declarations.
4482251662Sdim */
4483251662Sdimtypedef enum {
4484251662Sdim  CXObjCDeclQualifier_None = 0x0,
4485251662Sdim  CXObjCDeclQualifier_In = 0x1,
4486251662Sdim  CXObjCDeclQualifier_Inout = 0x2,
4487251662Sdim  CXObjCDeclQualifier_Out = 0x4,
4488251662Sdim  CXObjCDeclQualifier_Bycopy = 0x8,
4489251662Sdim  CXObjCDeclQualifier_Byref = 0x10,
4490251662Sdim  CXObjCDeclQualifier_Oneway = 0x20
4491251662Sdim} CXObjCDeclQualifierKind;
4492251662Sdim
4493251662Sdim/**
4494341825Sdim * Given a cursor that represents an Objective-C method or parameter
4495276479Sdim * declaration, return the associated Objective-C qualifiers for the return
4496276479Sdim * type or the parameter respectively. The bits are formed from
4497276479Sdim * CXObjCDeclQualifierKind.
4498251662Sdim */
4499251662SdimCINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4500251662Sdim
4501251662Sdim/**
4502341825Sdim * Given a cursor that represents an Objective-C method or property
4503321369Sdim * declaration, return non-zero if the declaration was affected by "\@optional".
4504321369Sdim * Returns zero if the cursor is not such a declaration or it is "\@required".
4505261991Sdim */
4506261991SdimCINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4507261991Sdim
4508261991Sdim/**
4509341825Sdim * Returns non-zero if the given cursor is a variadic function or method.
4510251662Sdim */
4511251662SdimCINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4512251662Sdim
4513251662Sdim/**
4514341825Sdim * Returns non-zero if the given cursor points to a symbol marked with
4515321369Sdim * external_source_symbol attribute.
4516321369Sdim *
4517321369Sdim * \param language If non-NULL, and the attribute is present, will be set to
4518321369Sdim * the 'language' string from the attribute.
4519321369Sdim *
4520321369Sdim * \param definedIn If non-NULL, and the attribute is present, will be set to
4521321369Sdim * the 'definedIn' string from the attribute.
4522321369Sdim *
4523321369Sdim * \param isGenerated If non-NULL, and the attribute is present, will be set to
4524321369Sdim * non-zero if the 'generated_declaration' is set in the attribute.
4525321369Sdim */
4526321369SdimCINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4527321369Sdim                                       CXString *language, CXString *definedIn,
4528321369Sdim                                       unsigned *isGenerated);
4529321369Sdim
4530321369Sdim/**
4531341825Sdim * Given a cursor that represents a declaration, return the associated
4532239462Sdim * comment's source range.  The range may include multiple consecutive comments
4533239462Sdim * with whitespace in between.
4534239462Sdim */
4535239462SdimCINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4536239462Sdim
4537239462Sdim/**
4538341825Sdim * Given a cursor that represents a declaration, return the associated
4539239462Sdim * comment text, including comment markers.
4540239462Sdim */
4541239462SdimCINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4542239462Sdim
4543239462Sdim/**
4544341825Sdim * Given a cursor that represents a documentable entity (e.g.,
4545341825Sdim * declaration), return the associated \paragraph; otherwise return the
4546239462Sdim * first paragraph.
4547239462Sdim */
4548239462SdimCINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4549239462Sdim
4550239462Sdim/**
4551202879Srdivacky * @}
4552202879Srdivacky */
4553203955Srdivacky
4554280031Sdim/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4555280031Sdim *
4556280031Sdim * @{
4557280031Sdim */
4558280031Sdim
4559203955Srdivacky/**
4560341825Sdim * Retrieve the CXString representing the mangled name of the cursor.
4561280031Sdim */
4562280031SdimCINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4563280031Sdim
4564280031Sdim/**
4565341825Sdim * Retrieve the CXStrings representing the mangled symbols of the C++
4566296417Sdim * constructor or destructor at the cursor.
4567296417Sdim */
4568296417SdimCINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4569296417Sdim
4570296417Sdim/**
4571341825Sdim * Retrieve the CXStrings representing the mangled symbols of the ObjC
4572327952Sdim * class interface or implementation at the cursor.
4573327952Sdim */
4574327952SdimCINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4575327952Sdim
4576327952Sdim/**
4577280031Sdim * @}
4578280031Sdim */
4579280031Sdim
4580280031Sdim/**
4581243830Sdim * \defgroup CINDEX_MODULE Module introspection
4582243830Sdim *
4583243830Sdim * The functions in this group provide access to information about modules.
4584243830Sdim *
4585243830Sdim * @{
4586243830Sdim */
4587243830Sdim
4588243830Sdimtypedef void *CXModule;
4589243830Sdim
4590243830Sdim/**
4591341825Sdim * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4592243830Sdim */
4593243830SdimCINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4594243830Sdim
4595243830Sdim/**
4596341825Sdim * Given a CXFile header file, return the module that contains it, if one
4597276479Sdim * exists.
4598276479Sdim */
4599276479SdimCINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4600276479Sdim
4601276479Sdim/**
4602243830Sdim * \param Module a module object.
4603243830Sdim *
4604251662Sdim * \returns the module file where the provided module object came from.
4605251662Sdim */
4606251662SdimCINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4607251662Sdim
4608251662Sdim/**
4609251662Sdim * \param Module a module object.
4610251662Sdim *
4611243830Sdim * \returns the parent of a sub-module or NULL if the given module is top-level,
4612243830Sdim * e.g. for 'std.vector' it will return the 'std' module.
4613243830Sdim */
4614243830SdimCINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4615243830Sdim
4616243830Sdim/**
4617243830Sdim * \param Module a module object.
4618243830Sdim *
4619243830Sdim * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4620243830Sdim * will return "vector".
4621243830Sdim */
4622243830SdimCINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4623243830Sdim
4624243830Sdim/**
4625243830Sdim * \param Module a module object.
4626243830Sdim *
4627243830Sdim * \returns the full name of the module, e.g. "std.vector".
4628243830Sdim */
4629243830SdimCINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4630243830Sdim
4631243830Sdim/**
4632243830Sdim * \param Module a module object.
4633243830Sdim *
4634276479Sdim * \returns non-zero if the module is a system one.
4635276479Sdim */
4636276479SdimCINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4637276479Sdim
4638276479Sdim/**
4639276479Sdim * \param Module a module object.
4640276479Sdim *
4641243830Sdim * \returns the number of top level headers associated with this module.
4642243830Sdim */
4643249423SdimCINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4644249423Sdim                                                           CXModule Module);
4645243830Sdim
4646243830Sdim/**
4647243830Sdim * \param Module a module object.
4648243830Sdim *
4649243830Sdim * \param Index top level header index (zero-based).
4650243830Sdim *
4651243830Sdim * \returns the specified top level header associated with the module.
4652243830Sdim */
4653243830SdimCINDEX_LINKAGE
4654249423SdimCXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4655249423Sdim                                      CXModule Module, unsigned Index);
4656243830Sdim
4657243830Sdim/**
4658243830Sdim * @}
4659243830Sdim */
4660243830Sdim
4661243830Sdim/**
4662208600Srdivacky * \defgroup CINDEX_CPP C++ AST introspection
4663208600Srdivacky *
4664208600Srdivacky * The routines in this group provide access information in the ASTs specific
4665208600Srdivacky * to C++ language features.
4666208600Srdivacky *
4667208600Srdivacky * @{
4668208600Srdivacky */
4669208600Srdivacky
4670208600Srdivacky/**
4671341825Sdim * Determine if a C++ constructor is a converting constructor.
4672309124Sdim */
4673309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4674309124Sdim
4675309124Sdim/**
4676341825Sdim * Determine if a C++ constructor is a copy constructor.
4677309124Sdim */
4678309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4679309124Sdim
4680309124Sdim/**
4681341825Sdim * Determine if a C++ constructor is the default constructor.
4682309124Sdim */
4683309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4684309124Sdim
4685309124Sdim/**
4686341825Sdim * Determine if a C++ constructor is a move constructor.
4687309124Sdim */
4688309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4689309124Sdim
4690309124Sdim/**
4691341825Sdim * Determine if a C++ field is declared 'mutable'.
4692296417Sdim */
4693296417SdimCINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4694296417Sdim
4695296417Sdim/**
4696341825Sdim * Determine if a C++ method is declared '= default'.
4697309124Sdim */
4698309124SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4699309124Sdim
4700309124Sdim/**
4701341825Sdim * Determine if a C++ member function or member function template is
4702261991Sdim * pure virtual.
4703261991Sdim */
4704261991SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4705261991Sdim
4706261991Sdim/**
4707341825Sdim * Determine if a C++ member function or member function template is
4708212904Sdim * declared 'static'.
4709208600Srdivacky */
4710208600SrdivackyCINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4711208600Srdivacky
4712208600Srdivacky/**
4713341825Sdim * Determine if a C++ member function or member function template is
4714223017Sdim * explicitly declared 'virtual' or if it overrides a virtual method from
4715223017Sdim * one of the base classes.
4716223017Sdim */
4717223017SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4718223017Sdim
4719223017Sdim/**
4720341825Sdim * Determine if a C++ record is abstract, i.e. whether a class or struct
4721327952Sdim * has a pure virtual member function.
4722327952Sdim */
4723327952SdimCINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4724327952Sdim
4725327952Sdim/**
4726341825Sdim * Determine if an enum declaration refers to a scoped enum.
4727321369Sdim */
4728321369SdimCINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4729321369Sdim
4730321369Sdim/**
4731341825Sdim * Determine if a C++ member function or member function template is
4732276479Sdim * declared 'const'.
4733276479Sdim */
4734276479SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4735276479Sdim
4736276479Sdim/**
4737341825Sdim * Given a cursor that represents a template, determine
4738212904Sdim * the cursor kind of the specializations would be generated by instantiating
4739212904Sdim * the template.
4740212904Sdim *
4741212904Sdim * This routine can be used to determine what flavor of function template,
4742212904Sdim * class template, or class template partial specialization is stored in the
4743212904Sdim * cursor. For example, it can describe whether a class template cursor is
4744212904Sdim * declared with "struct", "class" or "union".
4745212904Sdim *
4746212904Sdim * \param C The cursor to query. This cursor should represent a template
4747212904Sdim * declaration.
4748212904Sdim *
4749212904Sdim * \returns The cursor kind of the specializations that would be generated
4750212904Sdim * by instantiating the template \p C. If \p C is not a template, returns
4751212904Sdim * \c CXCursor_NoDeclFound.
4752212904Sdim */
4753212904SdimCINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4754341825Sdim
4755212904Sdim/**
4756341825Sdim * Given a cursor that may represent a specialization or instantiation
4757212904Sdim * of a template, retrieve the cursor that represents the template that it
4758212904Sdim * specializes or from which it was instantiated.
4759212904Sdim *
4760341825Sdim * This routine determines the template involved both for explicit
4761212904Sdim * specializations of templates and for implicit instantiations of the template,
4762212904Sdim * both of which are referred to as "specializations". For a class template
4763341825Sdim * specialization (e.g., \c std::vector<bool>), this routine will return
4764212904Sdim * either the primary template (\c std::vector) or, if the specialization was
4765212904Sdim * instantiated from a class template partial specialization, the class template
4766212904Sdim * partial specialization. For a class template partial specialization and a
4767212904Sdim * function template specialization (including instantiations), this
4768212904Sdim * this routine will return the specialized template.
4769212904Sdim *
4770212904Sdim * For members of a class template (e.g., member functions, member classes, or
4771341825Sdim * static data members), returns the specialized or instantiated member.
4772212904Sdim * Although not strictly "templates" in the C++ language, members of class
4773212904Sdim * templates have the same notions of specializations and instantiations that
4774212904Sdim * templates do, so this routine treats them similarly.
4775212904Sdim *
4776212904Sdim * \param C A cursor that may be a specialization of a template or a member
4777212904Sdim * of a template.
4778212904Sdim *
4779341825Sdim * \returns If the given cursor is a specialization or instantiation of a
4780212904Sdim * template or a member thereof, the template or member that it specializes or
4781212904Sdim * from which it was instantiated. Otherwise, returns a NULL cursor.
4782212904Sdim */
4783212904SdimCINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4784226633Sdim
4785226633Sdim/**
4786341825Sdim * Given a cursor that references something else, return the source range
4787226633Sdim * covering that reference.
4788226633Sdim *
4789226633Sdim * \param C A cursor pointing to a member reference, a declaration reference, or
4790226633Sdim * an operator call.
4791341825Sdim * \param NameFlags A bitset with three independent flags:
4792226633Sdim * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4793226633Sdim * CXNameRange_WantSinglePiece.
4794341825Sdim * \param PieceIndex For contiguous names or when passing the flag
4795341825Sdim * CXNameRange_WantSinglePiece, only one piece with index 0 is
4796226633Sdim * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4797239462Sdim * non-contiguous names, this index can be used to retrieve the individual
4798226633Sdim * pieces of the name. See also CXNameRange_WantSinglePiece.
4799226633Sdim *
4800226633Sdim * \returns The piece of the name pointed to by the given cursor. If there is no
4801226633Sdim * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4802226633Sdim */
4803226633SdimCINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4804341825Sdim                                                unsigned NameFlags,
4805226633Sdim                                                unsigned PieceIndex);
4806226633Sdim
4807226633Sdimenum CXNameRefFlags {
4808226633Sdim  /**
4809341825Sdim   * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4810226633Sdim   * range.
4811226633Sdim   */
4812226633Sdim  CXNameRange_WantQualifier = 0x1,
4813341825Sdim
4814226633Sdim  /**
4815341825Sdim   * Include the explicit template arguments, e.g. \<int> in x.f<int>,
4816239462Sdim   * in the range.
4817226633Sdim   */
4818226633Sdim  CXNameRange_WantTemplateArgs = 0x2,
4819226633Sdim
4820226633Sdim  /**
4821341825Sdim   * If the name is non-contiguous, return the full spanning range.
4822226633Sdim   *
4823226633Sdim   * Non-contiguous names occur in Objective-C when a selector with two or more
4824226633Sdim   * parameters is used, or in C++ when using an operator:
4825226633Sdim   * \code
4826276479Sdim   * [object doSomething:here withValue:there]; // Objective-C
4827226633Sdim   * return some_vector[1]; // C++
4828226633Sdim   * \endcode
4829226633Sdim   */
4830226633Sdim  CXNameRange_WantSinglePiece = 0x4
4831226633Sdim};
4832341825Sdim
4833212904Sdim/**
4834208600Srdivacky * @}
4835208600Srdivacky */
4836208600Srdivacky
4837208600Srdivacky/**
4838203955Srdivacky * \defgroup CINDEX_LEX Token extraction and manipulation
4839203955Srdivacky *
4840203955Srdivacky * The routines in this group provide access to the tokens within a
4841203955Srdivacky * translation unit, along with a semantic mapping of those tokens to
4842203955Srdivacky * their corresponding cursors.
4843203955Srdivacky *
4844203955Srdivacky * @{
4845203955Srdivacky */
4846203955Srdivacky
4847203955Srdivacky/**
4848341825Sdim * Describes a kind of token.
4849203955Srdivacky */
4850203955Srdivackytypedef enum CXTokenKind {
4851203955Srdivacky  /**
4852341825Sdim   * A token that contains some kind of punctuation.
4853203955Srdivacky   */
4854203955Srdivacky  CXToken_Punctuation,
4855205219Srdivacky
4856203955Srdivacky  /**
4857341825Sdim   * A language keyword.
4858203955Srdivacky   */
4859203955Srdivacky  CXToken_Keyword,
4860205219Srdivacky
4861203955Srdivacky  /**
4862341825Sdim   * An identifier (that is not a keyword).
4863203955Srdivacky   */
4864203955Srdivacky  CXToken_Identifier,
4865205219Srdivacky
4866203955Srdivacky  /**
4867341825Sdim   * A numeric, string, or character literal.
4868203955Srdivacky   */
4869203955Srdivacky  CXToken_Literal,
4870205219Srdivacky
4871203955Srdivacky  /**
4872341825Sdim   * A comment.
4873203955Srdivacky   */
4874203955Srdivacky  CXToken_Comment
4875203955Srdivacky} CXTokenKind;
4876203955Srdivacky
4877202879Srdivacky/**
4878341825Sdim * Describes a single preprocessing token.
4879203955Srdivacky */
4880203955Srdivackytypedef struct {
4881203955Srdivacky  unsigned int_data[4];
4882203955Srdivacky  void *ptr_data;
4883203955Srdivacky} CXToken;
4884203955Srdivacky
4885203955Srdivacky/**
4886341825Sdim * Get the raw lexical token starting with the given location.
4887341825Sdim *
4888341825Sdim * \param TU the translation unit whose text is being tokenized.
4889341825Sdim *
4890341825Sdim * \param Location the source location with which the token starts.
4891341825Sdim *
4892341825Sdim * \returns The token starting with the given location or NULL if no such token
4893341825Sdim * exist. The returned pointer must be freed with clang_disposeTokens before the
4894341825Sdim * translation unit is destroyed.
4895203955Srdivacky */
4896341825SdimCINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4897341825Sdim                                       CXSourceLocation Location);
4898341825Sdim
4899341825Sdim/**
4900341825Sdim * Determine the kind of the given token.
4901341825Sdim */
4902203955SrdivackyCINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4903205219Srdivacky
4904203955Srdivacky/**
4905341825Sdim * Determine the spelling of the given token.
4906203955Srdivacky *
4907203955Srdivacky * The spelling of a token is the textual representation of that token, e.g.,
4908203955Srdivacky * the text of an identifier or keyword.
4909203955Srdivacky */
4910203955SrdivackyCINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4911205219Srdivacky
4912203955Srdivacky/**
4913341825Sdim * Retrieve the source location of the given token.
4914203955Srdivacky */
4915205219SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4916203955Srdivacky                                                       CXToken);
4917205219Srdivacky
4918203955Srdivacky/**
4919341825Sdim * Retrieve a source range that covers the given token.
4920203955Srdivacky */
4921203955SrdivackyCINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4922203955Srdivacky
4923203955Srdivacky/**
4924341825Sdim * Tokenize the source code described by the given range into raw
4925203955Srdivacky * lexical tokens.
4926203955Srdivacky *
4927203955Srdivacky * \param TU the translation unit whose text is being tokenized.
4928203955Srdivacky *
4929203955Srdivacky * \param Range the source range in which text should be tokenized. All of the
4930203955Srdivacky * tokens produced by tokenization will fall within this source range,
4931203955Srdivacky *
4932203955Srdivacky * \param Tokens this pointer will be set to point to the array of tokens
4933203955Srdivacky * that occur within the given source range. The returned pointer must be
4934203955Srdivacky * freed with clang_disposeTokens() before the translation unit is destroyed.
4935203955Srdivacky *
4936203955Srdivacky * \param NumTokens will be set to the number of tokens in the \c *Tokens
4937203955Srdivacky * array.
4938203955Srdivacky *
4939203955Srdivacky */
4940203955SrdivackyCINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
4941203955Srdivacky                                   CXToken **Tokens, unsigned *NumTokens);
4942205219Srdivacky
4943203955Srdivacky/**
4944341825Sdim * Annotate the given set of tokens by providing cursors for each token
4945203955Srdivacky * that can be mapped to a specific entity within the abstract syntax tree.
4946203955Srdivacky *
4947203955Srdivacky * This token-annotation routine is equivalent to invoking
4948203955Srdivacky * clang_getCursor() for the source locations of each of the
4949203955Srdivacky * tokens. The cursors provided are filtered, so that only those
4950203955Srdivacky * cursors that have a direct correspondence to the token are
4951203955Srdivacky * accepted. For example, given a function call \c f(x),
4952203955Srdivacky * clang_getCursor() would provide the following cursors:
4953203955Srdivacky *
4954203955Srdivacky *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
4955203955Srdivacky *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
4956203955Srdivacky *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
4957203955Srdivacky *
4958203955Srdivacky * Only the first and last of these cursors will occur within the
4959203955Srdivacky * annotate, since the tokens "f" and "x' directly refer to a function
4960203955Srdivacky * and a variable, respectively, but the parentheses are just a small
4961203955Srdivacky * part of the full syntax of the function call expression, which is
4962203955Srdivacky * not provided as an annotation.
4963203955Srdivacky *
4964203955Srdivacky * \param TU the translation unit that owns the given tokens.
4965203955Srdivacky *
4966203955Srdivacky * \param Tokens the set of tokens to annotate.
4967203955Srdivacky *
4968203955Srdivacky * \param NumTokens the number of tokens in \p Tokens.
4969203955Srdivacky *
4970203955Srdivacky * \param Cursors an array of \p NumTokens cursors, whose contents will be
4971203955Srdivacky * replaced with the cursors corresponding to each token.
4972203955Srdivacky */
4973203955SrdivackyCINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
4974203955Srdivacky                                         CXToken *Tokens, unsigned NumTokens,
4975203955Srdivacky                                         CXCursor *Cursors);
4976205219Srdivacky
4977203955Srdivacky/**
4978341825Sdim * Free the given set of tokens.
4979203955Srdivacky */
4980205219SrdivackyCINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
4981203955Srdivacky                                        CXToken *Tokens, unsigned NumTokens);
4982205219Srdivacky
4983203955Srdivacky/**
4984203955Srdivacky * @}
4985203955Srdivacky */
4986205219Srdivacky
4987203955Srdivacky/**
4988202879Srdivacky * \defgroup CINDEX_DEBUG Debugging facilities
4989202879Srdivacky *
4990202879Srdivacky * These routines are used for testing and debugging, only, and should not
4991202879Srdivacky * be relied upon.
4992202879Srdivacky *
4993202879Srdivacky * @{
4994202879Srdivacky */
4995203955Srdivacky
4996198092Srdivacky/* for debug/testing */
4997204643SrdivackyCINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
4998203955SrdivackyCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
4999203955Srdivacky                                          const char **startBuf,
5000198092Srdivacky                                          const char **endBuf,
5001198092Srdivacky                                          unsigned *startLine,
5002198092Srdivacky                                          unsigned *startColumn,
5003198092Srdivacky                                          unsigned *endLine,
5004198092Srdivacky                                          unsigned *endColumn);
5005204643SrdivackyCINDEX_LINKAGE void clang_enableStackTraces(void);
5006218893SdimCINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
5007218893Sdim                                          unsigned stack_size);
5008218893Sdim
5009202879Srdivacky/**
5010202879Srdivacky * @}
5011198092Srdivacky */
5012203955Srdivacky
5013199482Srdivacky/**
5014202879Srdivacky * \defgroup CINDEX_CODE_COMPLET Code completion
5015202879Srdivacky *
5016202879Srdivacky * Code completion involves taking an (incomplete) source file, along with
5017202879Srdivacky * knowledge of where the user is actively editing that file, and suggesting
5018202879Srdivacky * syntactically- and semantically-valid constructs that the user might want to
5019202879Srdivacky * use at that particular point in the source code. These data structures and
5020202879Srdivacky * routines provide support for code completion.
5021202879Srdivacky *
5022202879Srdivacky * @{
5023202879Srdivacky */
5024203955Srdivacky
5025202879Srdivacky/**
5026341825Sdim * A semantic string that describes a code-completion result.
5027199482Srdivacky *
5028199482Srdivacky * A semantic string that describes the formatting of a code-completion
5029199482Srdivacky * result as a single "template" of text that should be inserted into the
5030199482Srdivacky * source buffer when a particular code-completion result is selected.
5031199482Srdivacky * Each semantic string is made up of some number of "chunks", each of which
5032199482Srdivacky * contains some text along with a description of what that text means, e.g.,
5033199482Srdivacky * the name of the entity being referenced, whether the text chunk is part of
5034199482Srdivacky * the template, or whether it is a "placeholder" that the user should replace
5035199482Srdivacky * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
5036203955Srdivacky * description of the different kinds of chunks.
5037199482Srdivacky */
5038199482Srdivackytypedef void *CXCompletionString;
5039203955Srdivacky
5040199482Srdivacky/**
5041341825Sdim * A single result of code completion.
5042199482Srdivacky */
5043199482Srdivackytypedef struct {
5044199482Srdivacky  /**
5045341825Sdim   * The kind of entity that this completion refers to.
5046199482Srdivacky   *
5047203955Srdivacky   * The cursor kind will be a macro, keyword, or a declaration (one of the
5048199482Srdivacky   * *Decl cursor kinds), describing the entity that the completion is
5049199482Srdivacky   * referring to.
5050199482Srdivacky   *
5051199482Srdivacky   * \todo In the future, we would like to provide a full cursor, to allow
5052199482Srdivacky   * the client to extract additional information from declaration.
5053199482Srdivacky   */
5054199482Srdivacky  enum CXCursorKind CursorKind;
5055203955Srdivacky
5056203955Srdivacky  /**
5057341825Sdim   * The code-completion string that describes how to insert this
5058199482Srdivacky   * code-completion result into the editing buffer.
5059199482Srdivacky   */
5060199482Srdivacky  CXCompletionString CompletionString;
5061199482Srdivacky} CXCompletionResult;
5062199482Srdivacky
5063199482Srdivacky/**
5064341825Sdim * Describes a single piece of text within a code-completion string.
5065199482Srdivacky *
5066203955Srdivacky * Each "chunk" within a code-completion string (\c CXCompletionString) is
5067203955Srdivacky * either a piece of text with a specific "kind" that describes how that text
5068199482Srdivacky * should be interpreted by the client or is another completion string.
5069199482Srdivacky */
5070199482Srdivackyenum CXCompletionChunkKind {
5071199482Srdivacky  /**
5072341825Sdim   * A code-completion string that describes "optional" text that
5073199482Srdivacky   * could be a part of the template (but is not required).
5074199482Srdivacky   *
5075199482Srdivacky   * The Optional chunk is the only kind of chunk that has a code-completion
5076203955Srdivacky   * string for its representation, which is accessible via
5077199482Srdivacky   * \c clang_getCompletionChunkCompletionString(). The code-completion string
5078199482Srdivacky   * describes an additional part of the template that is completely optional.
5079199482Srdivacky   * For example, optional chunks can be used to describe the placeholders for
5080199482Srdivacky   * arguments that match up with defaulted function parameters, e.g. given:
5081199482Srdivacky   *
5082199482Srdivacky   * \code
5083199482Srdivacky   * void f(int x, float y = 3.14, double z = 2.71828);
5084199482Srdivacky   * \endcode
5085199482Srdivacky   *
5086199482Srdivacky   * The code-completion string for this function would contain:
5087199482Srdivacky   *   - a TypedText chunk for "f".
5088199482Srdivacky   *   - a LeftParen chunk for "(".
5089199482Srdivacky   *   - a Placeholder chunk for "int x"
5090199482Srdivacky   *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
5091199482Srdivacky   *       - a Comma chunk for ","
5092204643Srdivacky   *       - a Placeholder chunk for "float y"
5093199482Srdivacky   *       - an Optional chunk containing the last defaulted argument:
5094199482Srdivacky   *           - a Comma chunk for ","
5095199482Srdivacky   *           - a Placeholder chunk for "double z"
5096199482Srdivacky   *   - a RightParen chunk for ")"
5097199482Srdivacky   *
5098204643Srdivacky   * There are many ways to handle Optional chunks. Two simple approaches are:
5099199482Srdivacky   *   - Completely ignore optional chunks, in which case the template for the
5100199482Srdivacky   *     function "f" would only include the first parameter ("int x").
5101199482Srdivacky   *   - Fully expand all optional chunks, in which case the template for the
5102199482Srdivacky   *     function "f" would have all of the parameters.
5103199482Srdivacky   */
5104199482Srdivacky  CXCompletionChunk_Optional,
5105199482Srdivacky  /**
5106341825Sdim   * Text that a user would be expected to type to get this
5107203955Srdivacky   * code-completion result.
5108199482Srdivacky   *
5109203955Srdivacky   * There will be exactly one "typed text" chunk in a semantic string, which
5110203955Srdivacky   * will typically provide the spelling of a keyword or the name of a
5111199482Srdivacky   * declaration that could be used at the current code point. Clients are
5112199482Srdivacky   * expected to filter the code-completion results based on the text in this
5113199482Srdivacky   * chunk.
5114199482Srdivacky   */
5115199482Srdivacky  CXCompletionChunk_TypedText,
5116199482Srdivacky  /**
5117341825Sdim   * Text that should be inserted as part of a code-completion result.
5118199482Srdivacky   *
5119199482Srdivacky   * A "text" chunk represents text that is part of the template to be
5120199482Srdivacky   * inserted into user code should this particular code-completion result
5121199482Srdivacky   * be selected.
5122199482Srdivacky   */
5123199482Srdivacky  CXCompletionChunk_Text,
5124199482Srdivacky  /**
5125341825Sdim   * Placeholder text that should be replaced by the user.
5126199482Srdivacky   *
5127199482Srdivacky   * A "placeholder" chunk marks a place where the user should insert text
5128199482Srdivacky   * into the code-completion template. For example, placeholders might mark
5129199482Srdivacky   * the function parameters for a function declaration, to indicate that the
5130199482Srdivacky   * user should provide arguments for each of those parameters. The actual
5131199482Srdivacky   * text in a placeholder is a suggestion for the text to display before
5132199482Srdivacky   * the user replaces the placeholder with real code.
5133199482Srdivacky   */
5134199482Srdivacky  CXCompletionChunk_Placeholder,
5135199482Srdivacky  /**
5136341825Sdim   * Informative text that should be displayed but never inserted as
5137199482Srdivacky   * part of the template.
5138203955Srdivacky   *
5139199482Srdivacky   * An "informative" chunk contains annotations that can be displayed to
5140199482Srdivacky   * help the user decide whether a particular code-completion result is the
5141199482Srdivacky   * right option, but which is not part of the actual template to be inserted
5142199482Srdivacky   * by code completion.
5143199482Srdivacky   */
5144199482Srdivacky  CXCompletionChunk_Informative,
5145199482Srdivacky  /**
5146341825Sdim   * Text that describes the current parameter when code-completion is
5147199482Srdivacky   * referring to function call, message send, or template specialization.
5148199482Srdivacky   *
5149199482Srdivacky   * A "current parameter" chunk occurs when code-completion is providing
5150199482Srdivacky   * information about a parameter corresponding to the argument at the
5151199482Srdivacky   * code-completion point. For example, given a function
5152199482Srdivacky   *
5153199482Srdivacky   * \code
5154199482Srdivacky   * int add(int x, int y);
5155199482Srdivacky   * \endcode
5156199482Srdivacky   *
5157199482Srdivacky   * and the source code \c add(, where the code-completion point is after the
5158199482Srdivacky   * "(", the code-completion string will contain a "current parameter" chunk
5159199482Srdivacky   * for "int x", indicating that the current argument will initialize that
5160199482Srdivacky   * parameter. After typing further, to \c add(17, (where the code-completion
5161203955Srdivacky   * point is after the ","), the code-completion string will contain a
5162341825Sdim   * "current parameter" chunk to "int y".
5163199482Srdivacky   */
5164199482Srdivacky  CXCompletionChunk_CurrentParameter,
5165199482Srdivacky  /**
5166341825Sdim   * A left parenthesis ('('), used to initiate a function call or
5167199482Srdivacky   * signal the beginning of a function parameter list.
5168199482Srdivacky   */
5169199482Srdivacky  CXCompletionChunk_LeftParen,
5170199482Srdivacky  /**
5171341825Sdim   * A right parenthesis (')'), used to finish a function call or
5172199482Srdivacky   * signal the end of a function parameter list.
5173199482Srdivacky   */
5174199482Srdivacky  CXCompletionChunk_RightParen,
5175199482Srdivacky  /**
5176341825Sdim   * A left bracket ('[').
5177199482Srdivacky   */
5178199482Srdivacky  CXCompletionChunk_LeftBracket,
5179199482Srdivacky  /**
5180341825Sdim   * A right bracket (']').
5181199482Srdivacky   */
5182199482Srdivacky  CXCompletionChunk_RightBracket,
5183199482Srdivacky  /**
5184341825Sdim   * A left brace ('{').
5185199482Srdivacky   */
5186199482Srdivacky  CXCompletionChunk_LeftBrace,
5187199482Srdivacky  /**
5188341825Sdim   * A right brace ('}').
5189199482Srdivacky   */
5190199482Srdivacky  CXCompletionChunk_RightBrace,
5191199482Srdivacky  /**
5192341825Sdim   * A left angle bracket ('<').
5193199482Srdivacky   */
5194199482Srdivacky  CXCompletionChunk_LeftAngle,
5195199482Srdivacky  /**
5196341825Sdim   * A right angle bracket ('>').
5197199482Srdivacky   */
5198199482Srdivacky  CXCompletionChunk_RightAngle,
5199199482Srdivacky  /**
5200341825Sdim   * A comma separator (',').
5201199482Srdivacky   */
5202201361Srdivacky  CXCompletionChunk_Comma,
5203201361Srdivacky  /**
5204341825Sdim   * Text that specifies the result type of a given result.
5205201361Srdivacky   *
5206201361Srdivacky   * This special kind of informative chunk is not meant to be inserted into
5207203955Srdivacky   * the text buffer. Rather, it is meant to illustrate the type that an
5208201361Srdivacky   * expression using the given completion string would have.
5209201361Srdivacky   */
5210202379Srdivacky  CXCompletionChunk_ResultType,
5211202379Srdivacky  /**
5212341825Sdim   * A colon (':').
5213202379Srdivacky   */
5214202379Srdivacky  CXCompletionChunk_Colon,
5215202379Srdivacky  /**
5216341825Sdim   * A semicolon (';').
5217202379Srdivacky   */
5218202379Srdivacky  CXCompletionChunk_SemiColon,
5219202379Srdivacky  /**
5220341825Sdim   * An '=' sign.
5221202379Srdivacky   */
5222202379Srdivacky  CXCompletionChunk_Equal,
5223202379Srdivacky  /**
5224202379Srdivacky   * Horizontal space (' ').
5225202379Srdivacky   */
5226202379Srdivacky  CXCompletionChunk_HorizontalSpace,
5227202379Srdivacky  /**
5228321369Sdim   * Vertical space ('\\n'), after which it is generally a good idea to
5229202379Srdivacky   * perform indentation.
5230202379Srdivacky   */
5231202379Srdivacky  CXCompletionChunk_VerticalSpace
5232199482Srdivacky};
5233203955Srdivacky
5234199482Srdivacky/**
5235341825Sdim * Determine the kind of a particular chunk within a completion string.
5236199482Srdivacky *
5237199482Srdivacky * \param completion_string the completion string to query.
5238199482Srdivacky *
5239199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
5240199482Srdivacky *
5241199482Srdivacky * \returns the kind of the chunk at the index \c chunk_number.
5242199482Srdivacky */
5243203955SrdivackyCINDEX_LINKAGE enum CXCompletionChunkKind
5244199482Srdivackyclang_getCompletionChunkKind(CXCompletionString completion_string,
5245199482Srdivacky                             unsigned chunk_number);
5246203955Srdivacky
5247199482Srdivacky/**
5248341825Sdim * Retrieve the text associated with a particular chunk within a
5249199482Srdivacky * completion string.
5250199482Srdivacky *
5251199482Srdivacky * \param completion_string the completion string to query.
5252199482Srdivacky *
5253199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
5254199482Srdivacky *
5255199482Srdivacky * \returns the text associated with the chunk at index \c chunk_number.
5256199482Srdivacky */
5257204643SrdivackyCINDEX_LINKAGE CXString
5258199482Srdivackyclang_getCompletionChunkText(CXCompletionString completion_string,
5259199482Srdivacky                             unsigned chunk_number);
5260199482Srdivacky
5261199482Srdivacky/**
5262341825Sdim * Retrieve the completion string associated with a particular chunk
5263199482Srdivacky * within a completion string.
5264199482Srdivacky *
5265199482Srdivacky * \param completion_string the completion string to query.
5266199482Srdivacky *
5267199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
5268199482Srdivacky *
5269199482Srdivacky * \returns the completion string associated with the chunk at index
5270226633Sdim * \c chunk_number.
5271199482Srdivacky */
5272199482SrdivackyCINDEX_LINKAGE CXCompletionString
5273199482Srdivackyclang_getCompletionChunkCompletionString(CXCompletionString completion_string,
5274199482Srdivacky                                         unsigned chunk_number);
5275203955Srdivacky
5276199482Srdivacky/**
5277341825Sdim * Retrieve the number of chunks in the given code-completion string.
5278199482Srdivacky */
5279199482SrdivackyCINDEX_LINKAGE unsigned
5280199482Srdivackyclang_getNumCompletionChunks(CXCompletionString completion_string);
5281199482Srdivacky
5282199482Srdivacky/**
5283341825Sdim * Determine the priority of this code completion.
5284208600Srdivacky *
5285341825Sdim * The priority of a code completion indicates how likely it is that this
5286208600Srdivacky * particular completion is the completion that the user will select. The
5287208600Srdivacky * priority is selected by various internal heuristics.
5288208600Srdivacky *
5289208600Srdivacky * \param completion_string The completion string to query.
5290208600Srdivacky *
5291208600Srdivacky * \returns The priority of this completion string. Smaller values indicate
5292208600Srdivacky * higher-priority (more likely) completions.
5293208600Srdivacky */
5294208600SrdivackyCINDEX_LINKAGE unsigned
5295208600Srdivackyclang_getCompletionPriority(CXCompletionString completion_string);
5296341825Sdim
5297208600Srdivacky/**
5298341825Sdim * Determine the availability of the entity that this code-completion
5299212904Sdim * string refers to.
5300212904Sdim *
5301212904Sdim * \param completion_string The completion string to query.
5302212904Sdim *
5303212904Sdim * \returns The availability of the completion string.
5304212904Sdim */
5305341825SdimCINDEX_LINKAGE enum CXAvailabilityKind
5306212904Sdimclang_getCompletionAvailability(CXCompletionString completion_string);
5307212904Sdim
5308212904Sdim/**
5309341825Sdim * Retrieve the number of annotations associated with the given
5310226633Sdim * completion string.
5311226633Sdim *
5312226633Sdim * \param completion_string the completion string to query.
5313226633Sdim *
5314226633Sdim * \returns the number of annotations associated with the given completion
5315226633Sdim * string.
5316226633Sdim */
5317226633SdimCINDEX_LINKAGE unsigned
5318226633Sdimclang_getCompletionNumAnnotations(CXCompletionString completion_string);
5319226633Sdim
5320226633Sdim/**
5321341825Sdim * Retrieve the annotation associated with the given completion string.
5322226633Sdim *
5323226633Sdim * \param completion_string the completion string to query.
5324226633Sdim *
5325226633Sdim * \param annotation_number the 0-based index of the annotation of the
5326226633Sdim * completion string.
5327226633Sdim *
5328226633Sdim * \returns annotation string associated with the completion at index
5329226633Sdim * \c annotation_number, or a NULL string if that annotation is not available.
5330226633Sdim */
5331226633SdimCINDEX_LINKAGE CXString
5332226633Sdimclang_getCompletionAnnotation(CXCompletionString completion_string,
5333226633Sdim                              unsigned annotation_number);
5334226633Sdim
5335226633Sdim/**
5336341825Sdim * Retrieve the parent context of the given completion string.
5337234353Sdim *
5338341825Sdim * The parent context of a completion string is the semantic parent of
5339234353Sdim * the declaration (if any) that the code completion represents. For example,
5340234353Sdim * a code completion for an Objective-C method would have the method's class
5341234353Sdim * or protocol as its context.
5342234353Sdim *
5343234353Sdim * \param completion_string The code completion string whose parent is
5344234353Sdim * being queried.
5345234353Sdim *
5346243830Sdim * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5347234353Sdim *
5348239462Sdim * \returns The name of the completion parent, e.g., "NSObject" if
5349234353Sdim * the completion string represents a method in the NSObject class.
5350234353Sdim */
5351234353SdimCINDEX_LINKAGE CXString
5352234353Sdimclang_getCompletionParent(CXCompletionString completion_string,
5353234353Sdim                          enum CXCursorKind *kind);
5354239462Sdim
5355234353Sdim/**
5356341825Sdim * Retrieve the brief documentation comment attached to the declaration
5357239462Sdim * that corresponds to the given completion string.
5358239462Sdim */
5359239462SdimCINDEX_LINKAGE CXString
5360239462Sdimclang_getCompletionBriefComment(CXCompletionString completion_string);
5361239462Sdim
5362239462Sdim/**
5363341825Sdim * Retrieve a completion string for an arbitrary declaration or macro
5364226633Sdim * definition cursor.
5365226633Sdim *
5366226633Sdim * \param cursor The cursor to query.
5367226633Sdim *
5368226633Sdim * \returns A non-context-sensitive completion string for declaration and macro
5369226633Sdim * definition cursors, or NULL for other kinds of cursors.
5370226633Sdim */
5371226633SdimCINDEX_LINKAGE CXCompletionString
5372226633Sdimclang_getCursorCompletionString(CXCursor cursor);
5373341825Sdim
5374226633Sdim/**
5375341825Sdim * Contains the results of code-completion.
5376201361Srdivacky *
5377201361Srdivacky * This data structure contains the results of code completion, as
5378218893Sdim * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5379201361Srdivacky * \c clang_disposeCodeCompleteResults.
5380201361Srdivacky */
5381201361Srdivackytypedef struct {
5382201361Srdivacky  /**
5383341825Sdim   * The code-completion results.
5384201361Srdivacky   */
5385201361Srdivacky  CXCompletionResult *Results;
5386201361Srdivacky
5387201361Srdivacky  /**
5388341825Sdim   * The number of code-completion results stored in the
5389201361Srdivacky   * \c Results array.
5390201361Srdivacky   */
5391201361Srdivacky  unsigned NumResults;
5392201361Srdivacky} CXCodeCompleteResults;
5393201361Srdivacky
5394201361Srdivacky/**
5395341825Sdim * Retrieve the number of fix-its for the given completion index.
5396341825Sdim *
5397341825Sdim * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5398341825Sdim * option was set.
5399341825Sdim *
5400341825Sdim * \param results The structure keeping all completion results
5401341825Sdim *
5402341825Sdim * \param completion_index The index of the completion
5403341825Sdim *
5404341825Sdim * \return The number of fix-its which must be applied before the completion at
5405341825Sdim * completion_index can be applied
5406341825Sdim */
5407341825SdimCINDEX_LINKAGE unsigned
5408341825Sdimclang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5409341825Sdim                             unsigned completion_index);
5410341825Sdim
5411341825Sdim/**
5412341825Sdim * Fix-its that *must* be applied before inserting the text for the
5413341825Sdim * corresponding completion.
5414341825Sdim *
5415341825Sdim * By default, clang_codeCompleteAt() only returns completions with empty
5416341825Sdim * fix-its. Extra completions with non-empty fix-its should be explicitly
5417341825Sdim * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5418341825Sdim *
5419341825Sdim * For the clients to be able to compute position of the cursor after applying
5420341825Sdim * fix-its, the following conditions are guaranteed to hold for
5421341825Sdim * replacement_range of the stored fix-its:
5422341825Sdim *  - Ranges in the fix-its are guaranteed to never contain the completion
5423341825Sdim *  point (or identifier under completion point, if any) inside them, except
5424341825Sdim *  at the start or at the end of the range.
5425341825Sdim *  - If a fix-it range starts or ends with completion point (or starts or
5426341825Sdim *  ends after the identifier under completion point), it will contain at
5427341825Sdim *  least one character. It allows to unambiguously recompute completion
5428341825Sdim *  point after applying the fix-it.
5429341825Sdim *
5430341825Sdim * The intuition is that provided fix-its change code around the identifier we
5431341825Sdim * complete, but are not allowed to touch the identifier itself or the
5432341825Sdim * completion point. One example of completions with corrections are the ones
5433341825Sdim * replacing '.' with '->' and vice versa:
5434341825Sdim *
5435341825Sdim * std::unique_ptr<std::vector<int>> vec_ptr;
5436341825Sdim * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5437341825Sdim * replacing '.' with '->'.
5438341825Sdim * In 'vec_ptr->^', one of the completions is 'release', it requires
5439341825Sdim * replacing '->' with '.'.
5440341825Sdim *
5441341825Sdim * \param results The structure keeping all completion results
5442341825Sdim *
5443341825Sdim * \param completion_index The index of the completion
5444341825Sdim *
5445341825Sdim * \param fixit_index The index of the fix-it for the completion at
5446341825Sdim * completion_index
5447341825Sdim *
5448341825Sdim * \param replacement_range The fix-it range that must be replaced before the
5449341825Sdim * completion at completion_index can be applied
5450341825Sdim *
5451341825Sdim * \returns The fix-it string that must replace the code at replacement_range
5452341825Sdim * before the completion at completion_index can be applied
5453341825Sdim */
5454341825SdimCINDEX_LINKAGE CXString clang_getCompletionFixIt(
5455341825Sdim    CXCodeCompleteResults *results, unsigned completion_index,
5456341825Sdim    unsigned fixit_index, CXSourceRange *replacement_range);
5457341825Sdim
5458341825Sdim/**
5459341825Sdim * Flags that can be passed to \c clang_codeCompleteAt() to
5460212904Sdim * modify its behavior.
5461212904Sdim *
5462212904Sdim * The enumerators in this enumeration can be bitwise-OR'd together to
5463212904Sdim * provide multiple options to \c clang_codeCompleteAt().
5464212904Sdim */
5465212904Sdimenum CXCodeComplete_Flags {
5466212904Sdim  /**
5467341825Sdim   * Whether to include macros within the set of code
5468212904Sdim   * completions returned.
5469212904Sdim   */
5470212904Sdim  CXCodeComplete_IncludeMacros = 0x01,
5471212904Sdim
5472212904Sdim  /**
5473341825Sdim   * Whether to include code patterns for language constructs
5474212904Sdim   * within the set of code completions, e.g., for loops.
5475212904Sdim   */
5476239462Sdim  CXCodeComplete_IncludeCodePatterns = 0x02,
5477239462Sdim
5478239462Sdim  /**
5479341825Sdim   * Whether to include brief documentation within the set of code
5480239462Sdim   * completions returned.
5481239462Sdim   */
5482341825Sdim  CXCodeComplete_IncludeBriefComments = 0x04,
5483341825Sdim
5484341825Sdim  /**
5485341825Sdim   * Whether to speed up completion by omitting top- or namespace-level entities
5486341825Sdim   * defined in the preamble. There's no guarantee any particular entity is
5487341825Sdim   * omitted. This may be useful if the headers are indexed externally.
5488341825Sdim   */
5489341825Sdim  CXCodeComplete_SkipPreamble = 0x08,
5490341825Sdim
5491341825Sdim  /**
5492341825Sdim   * Whether to include completions with small
5493341825Sdim   * fix-its, e.g. change '.' to '->' on member access, etc.
5494341825Sdim   */
5495341825Sdim  CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
5496212904Sdim};
5497212904Sdim
5498212904Sdim/**
5499341825Sdim * Bits that represent the context under which completion is occurring.
5500224145Sdim *
5501224145Sdim * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5502224145Sdim * contexts are occurring simultaneously.
5503224145Sdim */
5504224145Sdimenum CXCompletionContext {
5505224145Sdim  /**
5506341825Sdim   * The context for completions is unexposed, as only Clang results
5507224145Sdim   * should be included. (This is equivalent to having no context bits set.)
5508224145Sdim   */
5509224145Sdim  CXCompletionContext_Unexposed = 0,
5510341825Sdim
5511224145Sdim  /**
5512341825Sdim   * Completions for any possible type should be included in the results.
5513224145Sdim   */
5514224145Sdim  CXCompletionContext_AnyType = 1 << 0,
5515341825Sdim
5516224145Sdim  /**
5517341825Sdim   * Completions for any possible value (variables, function calls, etc.)
5518224145Sdim   * should be included in the results.
5519224145Sdim   */
5520224145Sdim  CXCompletionContext_AnyValue = 1 << 1,
5521224145Sdim  /**
5522341825Sdim   * Completions for values that resolve to an Objective-C object should
5523224145Sdim   * be included in the results.
5524224145Sdim   */
5525224145Sdim  CXCompletionContext_ObjCObjectValue = 1 << 2,
5526224145Sdim  /**
5527341825Sdim   * Completions for values that resolve to an Objective-C selector
5528224145Sdim   * should be included in the results.
5529224145Sdim   */
5530224145Sdim  CXCompletionContext_ObjCSelectorValue = 1 << 3,
5531224145Sdim  /**
5532341825Sdim   * Completions for values that resolve to a C++ class type should be
5533224145Sdim   * included in the results.
5534224145Sdim   */
5535224145Sdim  CXCompletionContext_CXXClassTypeValue = 1 << 4,
5536341825Sdim
5537224145Sdim  /**
5538341825Sdim   * Completions for fields of the member being accessed using the dot
5539224145Sdim   * operator should be included in the results.
5540224145Sdim   */
5541224145Sdim  CXCompletionContext_DotMemberAccess = 1 << 5,
5542224145Sdim  /**
5543341825Sdim   * Completions for fields of the member being accessed using the arrow
5544224145Sdim   * operator should be included in the results.
5545224145Sdim   */
5546224145Sdim  CXCompletionContext_ArrowMemberAccess = 1 << 6,
5547224145Sdim  /**
5548341825Sdim   * Completions for properties of the Objective-C object being accessed
5549224145Sdim   * using the dot operator should be included in the results.
5550224145Sdim   */
5551224145Sdim  CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5552341825Sdim
5553224145Sdim  /**
5554341825Sdim   * Completions for enum tags should be included in the results.
5555224145Sdim   */
5556224145Sdim  CXCompletionContext_EnumTag = 1 << 8,
5557224145Sdim  /**
5558341825Sdim   * Completions for union tags should be included in the results.
5559224145Sdim   */
5560224145Sdim  CXCompletionContext_UnionTag = 1 << 9,
5561224145Sdim  /**
5562341825Sdim   * Completions for struct tags should be included in the results.
5563224145Sdim   */
5564224145Sdim  CXCompletionContext_StructTag = 1 << 10,
5565341825Sdim
5566224145Sdim  /**
5567341825Sdim   * Completions for C++ class names should be included in the results.
5568224145Sdim   */
5569224145Sdim  CXCompletionContext_ClassTag = 1 << 11,
5570224145Sdim  /**
5571341825Sdim   * Completions for C++ namespaces and namespace aliases should be
5572224145Sdim   * included in the results.
5573224145Sdim   */
5574224145Sdim  CXCompletionContext_Namespace = 1 << 12,
5575224145Sdim  /**
5576341825Sdim   * Completions for C++ nested name specifiers should be included in
5577224145Sdim   * the results.
5578224145Sdim   */
5579224145Sdim  CXCompletionContext_NestedNameSpecifier = 1 << 13,
5580341825Sdim
5581224145Sdim  /**
5582341825Sdim   * Completions for Objective-C interfaces (classes) should be included
5583224145Sdim   * in the results.
5584224145Sdim   */
5585224145Sdim  CXCompletionContext_ObjCInterface = 1 << 14,
5586224145Sdim  /**
5587341825Sdim   * Completions for Objective-C protocols should be included in
5588224145Sdim   * the results.
5589224145Sdim   */
5590224145Sdim  CXCompletionContext_ObjCProtocol = 1 << 15,
5591224145Sdim  /**
5592341825Sdim   * Completions for Objective-C categories should be included in
5593224145Sdim   * the results.
5594224145Sdim   */
5595224145Sdim  CXCompletionContext_ObjCCategory = 1 << 16,
5596224145Sdim  /**
5597341825Sdim   * Completions for Objective-C instance messages should be included
5598224145Sdim   * in the results.
5599224145Sdim   */
5600224145Sdim  CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5601224145Sdim  /**
5602341825Sdim   * Completions for Objective-C class messages should be included in
5603224145Sdim   * the results.
5604224145Sdim   */
5605224145Sdim  CXCompletionContext_ObjCClassMessage = 1 << 18,
5606224145Sdim  /**
5607341825Sdim   * Completions for Objective-C selector names should be included in
5608224145Sdim   * the results.
5609224145Sdim   */
5610224145Sdim  CXCompletionContext_ObjCSelectorName = 1 << 19,
5611341825Sdim
5612224145Sdim  /**
5613341825Sdim   * Completions for preprocessor macro names should be included in
5614224145Sdim   * the results.
5615224145Sdim   */
5616224145Sdim  CXCompletionContext_MacroName = 1 << 20,
5617341825Sdim
5618224145Sdim  /**
5619341825Sdim   * Natural language completions should be included in the results.
5620224145Sdim   */
5621224145Sdim  CXCompletionContext_NaturalLanguage = 1 << 21,
5622341825Sdim
5623224145Sdim  /**
5624344779Sdim   * #include file completions should be included in the results.
5625344779Sdim   */
5626344779Sdim  CXCompletionContext_IncludedFile = 1 << 22,
5627344779Sdim
5628344779Sdim  /**
5629341825Sdim   * The current context is unknown, so set all contexts.
5630224145Sdim   */
5631344779Sdim  CXCompletionContext_Unknown = ((1 << 23) - 1)
5632224145Sdim};
5633341825Sdim
5634224145Sdim/**
5635341825Sdim * Returns a default set of code-completion options that can be
5636341825Sdim * passed to\c clang_codeCompleteAt().
5637212904Sdim */
5638212904SdimCINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5639212904Sdim
5640212904Sdim/**
5641341825Sdim * Perform code completion at a given location in a translation unit.
5642212904Sdim *
5643212904Sdim * This function performs code completion at a particular file, line, and
5644212904Sdim * column within source code, providing results that suggest potential
5645212904Sdim * code snippets based on the context of the completion. The basic model
5646212904Sdim * for code completion is that Clang will parse a complete source file,
5647212904Sdim * performing syntax checking up to the location where code-completion has
5648212904Sdim * been requested. At that point, a special code-completion token is passed
5649212904Sdim * to the parser, which recognizes this token and determines, based on the
5650212904Sdim * current location in the C/Objective-C/C++ grammar and the state of
5651212904Sdim * semantic analysis, what completions to provide. These completions are
5652212904Sdim * returned via a new \c CXCodeCompleteResults structure.
5653212904Sdim *
5654212904Sdim * Code completion itself is meant to be triggered by the client when the
5655212904Sdim * user types punctuation characters or whitespace, at which point the
5656212904Sdim * code-completion location will coincide with the cursor. For example, if \c p
5657212904Sdim * is a pointer, code-completion might be triggered after the "-" and then
5658341825Sdim * after the ">" in \c p->. When the code-completion location is after the ">",
5659212904Sdim * the completion results will provide, e.g., the members of the struct that
5660212904Sdim * "p" points to. The client is responsible for placing the cursor at the
5661212904Sdim * beginning of the token currently being typed, then filtering the results
5662212904Sdim * based on the contents of the token. For example, when code-completing for
5663212904Sdim * the expression \c p->get, the client should provide the location just after
5664212904Sdim * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5665212904Sdim * client can filter the results based on the current token text ("get"), only
5666212904Sdim * showing those results that start with "get". The intent of this interface
5667212904Sdim * is to separate the relatively high-latency acquisition of code-completion
5668212904Sdim * results from the filtering of results on a per-character basis, which must
5669212904Sdim * have a lower latency.
5670212904Sdim *
5671212904Sdim * \param TU The translation unit in which code-completion should
5672212904Sdim * occur. The source files for this translation unit need not be
5673212904Sdim * completely up-to-date (and the contents of those source files may
5674212904Sdim * be overridden via \p unsaved_files). Cursors referring into the
5675212904Sdim * translation unit may be invalidated by this invocation.
5676212904Sdim *
5677212904Sdim * \param complete_filename The name of the source file where code
5678212904Sdim * completion should be performed. This filename may be any file
5679212904Sdim * included in the translation unit.
5680212904Sdim *
5681212904Sdim * \param complete_line The line at which code-completion should occur.
5682212904Sdim *
5683212904Sdim * \param complete_column The column at which code-completion should occur.
5684212904Sdim * Note that the column should point just after the syntactic construct that
5685212904Sdim * initiated code completion, and not in the middle of a lexical token.
5686212904Sdim *
5687309124Sdim * \param unsaved_files the Files that have not yet been saved to disk
5688212904Sdim * but may be required for parsing or code completion, including the
5689212904Sdim * contents of those files.  The contents and name of these files (as
5690212904Sdim * specified by CXUnsavedFile) are copied when necessary, so the
5691212904Sdim * client only needs to guarantee their validity until the call to
5692212904Sdim * this function returns.
5693212904Sdim *
5694212904Sdim * \param num_unsaved_files The number of unsaved file entries in \p
5695212904Sdim * unsaved_files.
5696212904Sdim *
5697212904Sdim * \param options Extra options that control the behavior of code
5698212904Sdim * completion, expressed as a bitwise OR of the enumerators of the
5699341825Sdim * CXCodeComplete_Flags enumeration. The
5700212904Sdim * \c clang_defaultCodeCompleteOptions() function returns a default set
5701212904Sdim * of code-completion options.
5702212904Sdim *
5703212904Sdim * \returns If successful, a new \c CXCodeCompleteResults structure
5704212904Sdim * containing code-completion results, which should eventually be
5705212904Sdim * freed with \c clang_disposeCodeCompleteResults(). If code
5706212904Sdim * completion fails, returns NULL.
5707212904Sdim */
5708212904SdimCINDEX_LINKAGE
5709212904SdimCXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5710212904Sdim                                            const char *complete_filename,
5711212904Sdim                                            unsigned complete_line,
5712212904Sdim                                            unsigned complete_column,
5713212904Sdim                                            struct CXUnsavedFile *unsaved_files,
5714212904Sdim                                            unsigned num_unsaved_files,
5715212904Sdim                                            unsigned options);
5716212904Sdim
5717212904Sdim/**
5718341825Sdim * Sort the code-completion results in case-insensitive alphabetical
5719212904Sdim * order.
5720212904Sdim *
5721212904Sdim * \param Results The set of results to sort.
5722212904Sdim * \param NumResults The number of results in \p Results.
5723212904Sdim */
5724212904SdimCINDEX_LINKAGE
5725212904Sdimvoid clang_sortCodeCompletionResults(CXCompletionResult *Results,
5726212904Sdim                                     unsigned NumResults);
5727341825Sdim
5728212904Sdim/**
5729341825Sdim * Free the given set of code-completion results.
5730201361Srdivacky */
5731203955SrdivackyCINDEX_LINKAGE
5732201361Srdivackyvoid clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
5733341825Sdim
5734202879Srdivacky/**
5735341825Sdim * Determine the number of diagnostics produced prior to the
5736204643Srdivacky * location where code completion was performed.
5737204643Srdivacky */
5738205219SrdivackyCINDEX_LINKAGE
5739204643Srdivackyunsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5740204643Srdivacky
5741204643Srdivacky/**
5742341825Sdim * Retrieve a diagnostic associated with the given code completion.
5743204643Srdivacky *
5744239462Sdim * \param Results the code completion results to query.
5745204643Srdivacky * \param Index the zero-based diagnostic number to retrieve.
5746204643Srdivacky *
5747204643Srdivacky * \returns the requested diagnostic. This diagnostic must be freed
5748204643Srdivacky * via a call to \c clang_disposeDiagnostic().
5749204643Srdivacky */
5750205219SrdivackyCINDEX_LINKAGE
5751204643SrdivackyCXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5752204643Srdivacky                                             unsigned Index);
5753204643Srdivacky
5754204643Srdivacky/**
5755341825Sdim * Determines what completions are appropriate for the context
5756224145Sdim * the given code completion.
5757341825Sdim *
5758224145Sdim * \param Results the code completion results to query
5759224145Sdim *
5760224145Sdim * \returns the kinds of completions that are appropriate for use
5761224145Sdim * along with the given code completion results.
5762224145Sdim */
5763224145SdimCINDEX_LINKAGE
5764224145Sdimunsigned long long clang_codeCompleteGetContexts(
5765224145Sdim                                                CXCodeCompleteResults *Results);
5766226633Sdim
5767226633Sdim/**
5768341825Sdim * Returns the cursor kind for the container for the current code
5769226633Sdim * completion context. The container is only guaranteed to be set for
5770226633Sdim * contexts where a container exists (i.e. member accesses or Objective-C
5771226633Sdim * message sends); if there is not a container, this function will return
5772226633Sdim * CXCursor_InvalidCode.
5773226633Sdim *
5774226633Sdim * \param Results the code completion results to query
5775226633Sdim *
5776226633Sdim * \param IsIncomplete on return, this value will be false if Clang has complete
5777226633Sdim * information about the container. If Clang does not have complete
5778226633Sdim * information, this value will be true.
5779226633Sdim *
5780226633Sdim * \returns the container kind, or CXCursor_InvalidCode if there is not a
5781226633Sdim * container
5782226633Sdim */
5783226633SdimCINDEX_LINKAGE
5784226633Sdimenum CXCursorKind clang_codeCompleteGetContainerKind(
5785226633Sdim                                                 CXCodeCompleteResults *Results,
5786226633Sdim                                                     unsigned *IsIncomplete);
5787226633Sdim
5788226633Sdim/**
5789341825Sdim * Returns the USR for the container for the current code completion
5790226633Sdim * context. If there is not a container for the current context, this
5791226633Sdim * function will return the empty string.
5792226633Sdim *
5793226633Sdim * \param Results the code completion results to query
5794226633Sdim *
5795226633Sdim * \returns the USR for the container
5796226633Sdim */
5797226633SdimCINDEX_LINKAGE
5798226633SdimCXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5799296417Sdim
5800224145Sdim/**
5801341825Sdim * Returns the currently-entered selector for an Objective-C message
5802226633Sdim * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5803226633Sdim * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5804226633Sdim * CXCompletionContext_ObjCClassMessage.
5805226633Sdim *
5806226633Sdim * \param Results the code completion results to query
5807226633Sdim *
5808226633Sdim * \returns the selector (or partial selector) that has been entered thus far
5809226633Sdim * for an Objective-C message send.
5810226633Sdim */
5811226633SdimCINDEX_LINKAGE
5812226633SdimCXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5813341825Sdim
5814226633Sdim/**
5815202879Srdivacky * @}
5816202879Srdivacky */
5817203955Srdivacky
5818202879Srdivacky/**
5819202879Srdivacky * \defgroup CINDEX_MISC Miscellaneous utility functions
5820202879Srdivacky *
5821202879Srdivacky * @{
5822202879Srdivacky */
5823202879Srdivacky
5824202879Srdivacky/**
5825341825Sdim * Return a version string, suitable for showing to a user, but not
5826203955Srdivacky *        intended to be parsed (the format is not guaranteed to be stable).
5827203955Srdivacky */
5828249423SdimCINDEX_LINKAGE CXString clang_getClangVersion(void);
5829203955Srdivacky
5830221345Sdim/**
5831341825Sdim * Enable/disable crash recovery.
5832221345Sdim *
5833239462Sdim * \param isEnabled Flag to indicate if crash recovery is enabled.  A non-zero
5834239462Sdim *        value enables crash recovery, while 0 disables it.
5835221345Sdim */
5836221345SdimCINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5837341825Sdim
5838203955Srdivacky /**
5839341825Sdim  * Visitor invoked for each file in a translation unit
5840203955Srdivacky  *        (used with clang_getInclusions()).
5841203955Srdivacky  *
5842203955Srdivacky  * This visitor function will be invoked by clang_getInclusions() for each
5843239462Sdim  * file included (either at the top-level or by \#include directives) within
5844203955Srdivacky  * a translation unit.  The first argument is the file being included, and
5845203955Srdivacky  * the second and third arguments provide the inclusion stack.  The
5846203955Srdivacky  * array is sorted in order of immediate inclusion.  For example,
5847203955Srdivacky  * the first element refers to the location that included 'included_file'.
5848203955Srdivacky  */
5849203955Srdivackytypedef void (*CXInclusionVisitor)(CXFile included_file,
5850203955Srdivacky                                   CXSourceLocation* inclusion_stack,
5851203955Srdivacky                                   unsigned include_len,
5852203955Srdivacky                                   CXClientData client_data);
5853203955Srdivacky
5854203955Srdivacky/**
5855341825Sdim * Visit the set of preprocessor inclusions in a translation unit.
5856203955Srdivacky *   The visitor function is called with the provided data for every included
5857203955Srdivacky *   file.  This does not include headers included by the PCH file (unless one
5858203955Srdivacky *   is inspecting the inclusions in the PCH file itself).
5859203955Srdivacky */
5860203955SrdivackyCINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5861203955Srdivacky                                        CXInclusionVisitor visitor,
5862203955Srdivacky                                        CXClientData client_data);
5863203955Srdivacky
5864309124Sdimtypedef enum {
5865309124Sdim  CXEval_Int = 1 ,
5866309124Sdim  CXEval_Float = 2,
5867309124Sdim  CXEval_ObjCStrLiteral = 3,
5868309124Sdim  CXEval_StrLiteral = 4,
5869309124Sdim  CXEval_CFStr = 5,
5870309124Sdim  CXEval_Other = 6,
5871309124Sdim
5872309124Sdim  CXEval_UnExposed = 0
5873309124Sdim
5874309124Sdim} CXEvalResultKind ;
5875309124Sdim
5876203955Srdivacky/**
5877341825Sdim * Evaluation result of a cursor
5878309124Sdim */
5879309124Sdimtypedef void * CXEvalResult;
5880309124Sdim
5881309124Sdim/**
5882341825Sdim * If cursor is a statement declaration tries to evaluate the
5883309124Sdim * statement and if its variable, tries to evaluate its initializer,
5884309124Sdim * into its corresponding type.
5885309124Sdim */
5886309124SdimCINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5887309124Sdim
5888309124Sdim/**
5889341825Sdim * Returns the kind of the evaluated result.
5890309124Sdim */
5891309124SdimCINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
5892309124Sdim
5893309124Sdim/**
5894341825Sdim * Returns the evaluation result as integer if the
5895309124Sdim * kind is Int.
5896309124Sdim */
5897309124SdimCINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5898309124Sdim
5899309124Sdim/**
5900341825Sdim * Returns the evaluation result as a long long integer if the
5901314564Sdim * kind is Int. This prevents overflows that may happen if the result is
5902314564Sdim * returned with clang_EvalResult_getAsInt.
5903314564Sdim */
5904314564SdimCINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5905314564Sdim
5906314564Sdim/**
5907341825Sdim * Returns a non-zero value if the kind is Int and the evaluation
5908314564Sdim * result resulted in an unsigned integer.
5909314564Sdim */
5910314564SdimCINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5911314564Sdim
5912314564Sdim/**
5913341825Sdim * Returns the evaluation result as an unsigned integer if
5914314564Sdim * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5915314564Sdim */
5916314564SdimCINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5917314564Sdim
5918314564Sdim/**
5919341825Sdim * Returns the evaluation result as double if the
5920309124Sdim * kind is double.
5921309124Sdim */
5922309124SdimCINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5923309124Sdim
5924309124Sdim/**
5925341825Sdim * Returns the evaluation result as a constant string if the
5926309124Sdim * kind is other than Int or float. User must not free this pointer,
5927309124Sdim * instead call clang_EvalResult_dispose on the CXEvalResult returned
5928309124Sdim * by clang_Cursor_Evaluate.
5929309124Sdim */
5930309124SdimCINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
5931309124Sdim
5932309124Sdim/**
5933341825Sdim * Disposes the created Eval memory.
5934309124Sdim */
5935309124SdimCINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
5936309124Sdim/**
5937202879Srdivacky * @}
5938202879Srdivacky */
5939203955Srdivacky
5940224145Sdim/** \defgroup CINDEX_REMAPPING Remapping functions
5941224145Sdim *
5942224145Sdim * @{
5943224145Sdim */
5944224145Sdim
5945202879Srdivacky/**
5946341825Sdim * A remapping of original source files and their translated files.
5947224145Sdim */
5948224145Sdimtypedef void *CXRemapping;
5949224145Sdim
5950224145Sdim/**
5951341825Sdim * Retrieve a remapping.
5952224145Sdim *
5953224145Sdim * \param path the path that contains metadata about remappings.
5954224145Sdim *
5955224145Sdim * \returns the requested remapping. This remapping must be freed
5956224145Sdim * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5957224145Sdim */
5958224145SdimCINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
5959224145Sdim
5960224145Sdim/**
5961341825Sdim * Retrieve a remapping.
5962234353Sdim *
5963234353Sdim * \param filePaths pointer to an array of file paths containing remapping info.
5964234353Sdim *
5965234353Sdim * \param numFiles number of file paths.
5966234353Sdim *
5967234353Sdim * \returns the requested remapping. This remapping must be freed
5968234353Sdim * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
5969234353Sdim */
5970234353SdimCINDEX_LINKAGE
5971234353SdimCXRemapping clang_getRemappingsFromFileList(const char **filePaths,
5972234353Sdim                                            unsigned numFiles);
5973234353Sdim
5974234353Sdim/**
5975341825Sdim * Determine the number of remappings.
5976224145Sdim */
5977224145SdimCINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
5978224145Sdim
5979224145Sdim/**
5980341825Sdim * Get the original and the associated filename from the remapping.
5981341825Sdim *
5982224145Sdim * \param original If non-NULL, will be set to the original filename.
5983224145Sdim *
5984224145Sdim * \param transformed If non-NULL, will be set to the filename that the original
5985224145Sdim * is associated with.
5986224145Sdim */
5987224145SdimCINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
5988224145Sdim                                     CXString *original, CXString *transformed);
5989224145Sdim
5990224145Sdim/**
5991341825Sdim * Dispose the remapping.
5992224145Sdim */
5993224145SdimCINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
5994224145Sdim
5995224145Sdim/**
5996202879Srdivacky * @}
5997202879Srdivacky */
5998203955Srdivacky
5999226633Sdim/** \defgroup CINDEX_HIGH Higher level API functions
6000226633Sdim *
6001226633Sdim * @{
6002226633Sdim */
6003226633Sdim
6004226633Sdimenum CXVisitorResult {
6005226633Sdim  CXVisit_Break,
6006226633Sdim  CXVisit_Continue
6007226633Sdim};
6008226633Sdim
6009309124Sdimtypedef struct CXCursorAndRangeVisitor {
6010226633Sdim  void *context;
6011226633Sdim  enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
6012226633Sdim} CXCursorAndRangeVisitor;
6013226633Sdim
6014249423Sdimtypedef enum {
6015249423Sdim  /**
6016341825Sdim   * Function returned successfully.
6017249423Sdim   */
6018249423Sdim  CXResult_Success = 0,
6019249423Sdim  /**
6020341825Sdim   * One of the parameters was invalid for the function.
6021249423Sdim   */
6022249423Sdim  CXResult_Invalid = 1,
6023249423Sdim  /**
6024341825Sdim   * The function was terminated by a callback (e.g. it returned
6025249423Sdim   * CXVisit_Break)
6026249423Sdim   */
6027249423Sdim  CXResult_VisitBreak = 2
6028249423Sdim
6029249423Sdim} CXResult;
6030249423Sdim
6031224145Sdim/**
6032341825Sdim * Find references of a declaration in a specific file.
6033341825Sdim *
6034226633Sdim * \param cursor pointing to a declaration or a reference of one.
6035226633Sdim *
6036226633Sdim * \param file to search for references.
6037226633Sdim *
6038226633Sdim * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6039226633Sdim * each reference found.
6040226633Sdim * The CXSourceRange will point inside the file; if the reference is inside
6041226633Sdim * a macro (and not a macro argument) the CXSourceRange will be invalid.
6042249423Sdim *
6043249423Sdim * \returns one of the CXResult enumerators.
6044226633Sdim */
6045249423SdimCINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
6046226633Sdim                                               CXCursorAndRangeVisitor visitor);
6047226633Sdim
6048249423Sdim/**
6049341825Sdim * Find #import/#include directives in a specific file.
6050249423Sdim *
6051249423Sdim * \param TU translation unit containing the file to query.
6052249423Sdim *
6053249423Sdim * \param file to search for #import/#include directives.
6054249423Sdim *
6055249423Sdim * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6056249423Sdim * each directive found.
6057249423Sdim *
6058249423Sdim * \returns one of the CXResult enumerators.
6059249423Sdim */
6060249423SdimCINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
6061249423Sdim                                                 CXFile file,
6062249423Sdim                                              CXCursorAndRangeVisitor visitor);
6063249423Sdim
6064226633Sdim#ifdef __has_feature
6065226633Sdim#  if __has_feature(blocks)
6066226633Sdim
6067226633Sdimtypedef enum CXVisitorResult
6068226633Sdim    (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
6069226633Sdim
6070226633SdimCINDEX_LINKAGE
6071249423SdimCXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6072249423Sdim                                             CXCursorAndRangeVisitorBlock);
6073226633Sdim
6074249423SdimCINDEX_LINKAGE
6075249423SdimCXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6076249423Sdim                                           CXCursorAndRangeVisitorBlock);
6077249423Sdim
6078226633Sdim#  endif
6079226633Sdim#endif
6080226633Sdim
6081226633Sdim/**
6082341825Sdim * The client's data object that is associated with a CXFile.
6083234353Sdim */
6084234353Sdimtypedef void *CXIdxClientFile;
6085234353Sdim
6086234353Sdim/**
6087341825Sdim * The client's data object that is associated with a semantic entity.
6088234353Sdim */
6089234353Sdimtypedef void *CXIdxClientEntity;
6090234353Sdim
6091234353Sdim/**
6092341825Sdim * The client's data object that is associated with a semantic container
6093234353Sdim * of entities.
6094234353Sdim */
6095234353Sdimtypedef void *CXIdxClientContainer;
6096234353Sdim
6097234353Sdim/**
6098341825Sdim * The client's data object that is associated with an AST file (PCH
6099234353Sdim * or module).
6100234353Sdim */
6101234353Sdimtypedef void *CXIdxClientASTFile;
6102234353Sdim
6103234353Sdim/**
6104341825Sdim * Source location passed to index callbacks.
6105234353Sdim */
6106234353Sdimtypedef struct {
6107234353Sdim  void *ptr_data[2];
6108234353Sdim  unsigned int_data;
6109234353Sdim} CXIdxLoc;
6110234353Sdim
6111234353Sdim/**
6112341825Sdim * Data for ppIncludedFile callback.
6113234353Sdim */
6114234353Sdimtypedef struct {
6115234353Sdim  /**
6116341825Sdim   * Location of '#' in the \#include/\#import directive.
6117234353Sdim   */
6118234353Sdim  CXIdxLoc hashLoc;
6119234353Sdim  /**
6120341825Sdim   * Filename as written in the \#include/\#import directive.
6121234353Sdim   */
6122234353Sdim  const char *filename;
6123234353Sdim  /**
6124341825Sdim   * The actual file that the \#include/\#import directive resolved to.
6125234353Sdim   */
6126234353Sdim  CXFile file;
6127234353Sdim  int isImport;
6128234353Sdim  int isAngled;
6129243830Sdim  /**
6130341825Sdim   * Non-zero if the directive was automatically turned into a module
6131243830Sdim   * import.
6132243830Sdim   */
6133243830Sdim  int isModuleImport;
6134234353Sdim} CXIdxIncludedFileInfo;
6135234353Sdim
6136234353Sdim/**
6137341825Sdim * Data for IndexerCallbacks#importedASTFile.
6138234353Sdim */
6139234353Sdimtypedef struct {
6140243830Sdim  /**
6141341825Sdim   * Top level AST file containing the imported PCH, module or submodule.
6142243830Sdim   */
6143234353Sdim  CXFile file;
6144234353Sdim  /**
6145341825Sdim   * The imported module or NULL if the AST file is a PCH.
6146234353Sdim   */
6147243830Sdim  CXModule module;
6148243830Sdim  /**
6149341825Sdim   * Location where the file is imported. Applicable only for modules.
6150243830Sdim   */
6151234353Sdim  CXIdxLoc loc;
6152234353Sdim  /**
6153341825Sdim   * Non-zero if an inclusion directive was automatically turned into
6154243830Sdim   * a module import. Applicable only for modules.
6155234353Sdim   */
6156243830Sdim  int isImplicit;
6157243830Sdim
6158234353Sdim} CXIdxImportedASTFileInfo;
6159234353Sdim
6160234353Sdimtypedef enum {
6161234353Sdim  CXIdxEntity_Unexposed     = 0,
6162234353Sdim  CXIdxEntity_Typedef       = 1,
6163234353Sdim  CXIdxEntity_Function      = 2,
6164234353Sdim  CXIdxEntity_Variable      = 3,
6165234353Sdim  CXIdxEntity_Field         = 4,
6166234353Sdim  CXIdxEntity_EnumConstant  = 5,
6167234353Sdim
6168234353Sdim  CXIdxEntity_ObjCClass     = 6,
6169234353Sdim  CXIdxEntity_ObjCProtocol  = 7,
6170234353Sdim  CXIdxEntity_ObjCCategory  = 8,
6171234353Sdim
6172234353Sdim  CXIdxEntity_ObjCInstanceMethod = 9,
6173234353Sdim  CXIdxEntity_ObjCClassMethod    = 10,
6174234353Sdim  CXIdxEntity_ObjCProperty  = 11,
6175234353Sdim  CXIdxEntity_ObjCIvar      = 12,
6176234353Sdim
6177234353Sdim  CXIdxEntity_Enum          = 13,
6178234353Sdim  CXIdxEntity_Struct        = 14,
6179234353Sdim  CXIdxEntity_Union         = 15,
6180234353Sdim
6181234353Sdim  CXIdxEntity_CXXClass              = 16,
6182234353Sdim  CXIdxEntity_CXXNamespace          = 17,
6183234353Sdim  CXIdxEntity_CXXNamespaceAlias     = 18,
6184234353Sdim  CXIdxEntity_CXXStaticVariable     = 19,
6185234353Sdim  CXIdxEntity_CXXStaticMethod       = 20,
6186234353Sdim  CXIdxEntity_CXXInstanceMethod     = 21,
6187234353Sdim  CXIdxEntity_CXXConstructor        = 22,
6188234353Sdim  CXIdxEntity_CXXDestructor         = 23,
6189234353Sdim  CXIdxEntity_CXXConversionFunction = 24,
6190243830Sdim  CXIdxEntity_CXXTypeAlias          = 25,
6191243830Sdim  CXIdxEntity_CXXInterface          = 26
6192234353Sdim
6193234353Sdim} CXIdxEntityKind;
6194234353Sdim
6195234353Sdimtypedef enum {
6196234353Sdim  CXIdxEntityLang_None = 0,
6197234353Sdim  CXIdxEntityLang_C    = 1,
6198234353Sdim  CXIdxEntityLang_ObjC = 2,
6199321369Sdim  CXIdxEntityLang_CXX  = 3,
6200321369Sdim  CXIdxEntityLang_Swift  = 4
6201234353Sdim} CXIdxEntityLanguage;
6202234353Sdim
6203234353Sdim/**
6204341825Sdim * Extra C++ template information for an entity. This can apply to:
6205234353Sdim * CXIdxEntity_Function
6206234353Sdim * CXIdxEntity_CXXClass
6207234353Sdim * CXIdxEntity_CXXStaticMethod
6208234353Sdim * CXIdxEntity_CXXInstanceMethod
6209234353Sdim * CXIdxEntity_CXXConstructor
6210234353Sdim * CXIdxEntity_CXXConversionFunction
6211234353Sdim * CXIdxEntity_CXXTypeAlias
6212234353Sdim */
6213234353Sdimtypedef enum {
6214234353Sdim  CXIdxEntity_NonTemplate   = 0,
6215234353Sdim  CXIdxEntity_Template      = 1,
6216234353Sdim  CXIdxEntity_TemplatePartialSpecialization = 2,
6217234353Sdim  CXIdxEntity_TemplateSpecialization = 3
6218234353Sdim} CXIdxEntityCXXTemplateKind;
6219234353Sdim
6220234353Sdimtypedef enum {
6221234353Sdim  CXIdxAttr_Unexposed     = 0,
6222234353Sdim  CXIdxAttr_IBAction      = 1,
6223234353Sdim  CXIdxAttr_IBOutlet      = 2,
6224234353Sdim  CXIdxAttr_IBOutletCollection = 3
6225234353Sdim} CXIdxAttrKind;
6226234353Sdim
6227234353Sdimtypedef struct {
6228234353Sdim  CXIdxAttrKind kind;
6229234353Sdim  CXCursor cursor;
6230234353Sdim  CXIdxLoc loc;
6231234353Sdim} CXIdxAttrInfo;
6232234353Sdim
6233234353Sdimtypedef struct {
6234234353Sdim  CXIdxEntityKind kind;
6235234353Sdim  CXIdxEntityCXXTemplateKind templateKind;
6236234353Sdim  CXIdxEntityLanguage lang;
6237234353Sdim  const char *name;
6238234353Sdim  const char *USR;
6239234353Sdim  CXCursor cursor;
6240234353Sdim  const CXIdxAttrInfo *const *attributes;
6241234353Sdim  unsigned numAttributes;
6242234353Sdim} CXIdxEntityInfo;
6243234353Sdim
6244234353Sdimtypedef struct {
6245234353Sdim  CXCursor cursor;
6246234353Sdim} CXIdxContainerInfo;
6247234353Sdim
6248234353Sdimtypedef struct {
6249234353Sdim  const CXIdxAttrInfo *attrInfo;
6250234353Sdim  const CXIdxEntityInfo *objcClass;
6251234353Sdim  CXCursor classCursor;
6252234353Sdim  CXIdxLoc classLoc;
6253234353Sdim} CXIdxIBOutletCollectionAttrInfo;
6254234353Sdim
6255249423Sdimtypedef enum {
6256249423Sdim  CXIdxDeclFlag_Skipped = 0x1
6257249423Sdim} CXIdxDeclInfoFlags;
6258249423Sdim
6259234353Sdimtypedef struct {
6260234353Sdim  const CXIdxEntityInfo *entityInfo;
6261234353Sdim  CXCursor cursor;
6262234353Sdim  CXIdxLoc loc;
6263234353Sdim  const CXIdxContainerInfo *semanticContainer;
6264234353Sdim  /**
6265341825Sdim   * Generally same as #semanticContainer but can be different in
6266234353Sdim   * cases like out-of-line C++ member functions.
6267234353Sdim   */
6268234353Sdim  const CXIdxContainerInfo *lexicalContainer;
6269234353Sdim  int isRedeclaration;
6270234353Sdim  int isDefinition;
6271234353Sdim  int isContainer;
6272234353Sdim  const CXIdxContainerInfo *declAsContainer;
6273234353Sdim  /**
6274341825Sdim   * Whether the declaration exists in code or was created implicitly
6275276479Sdim   * by the compiler, e.g. implicit Objective-C methods for properties.
6276234353Sdim   */
6277234353Sdim  int isImplicit;
6278234353Sdim  const CXIdxAttrInfo *const *attributes;
6279234353Sdim  unsigned numAttributes;
6280249423Sdim
6281249423Sdim  unsigned flags;
6282249423Sdim
6283234353Sdim} CXIdxDeclInfo;
6284234353Sdim
6285234353Sdimtypedef enum {
6286234353Sdim  CXIdxObjCContainer_ForwardRef = 0,
6287234353Sdim  CXIdxObjCContainer_Interface = 1,
6288234353Sdim  CXIdxObjCContainer_Implementation = 2
6289234353Sdim} CXIdxObjCContainerKind;
6290234353Sdim
6291234353Sdimtypedef struct {
6292234353Sdim  const CXIdxDeclInfo *declInfo;
6293234353Sdim  CXIdxObjCContainerKind kind;
6294234353Sdim} CXIdxObjCContainerDeclInfo;
6295234353Sdim
6296234353Sdimtypedef struct {
6297234353Sdim  const CXIdxEntityInfo *base;
6298234353Sdim  CXCursor cursor;
6299234353Sdim  CXIdxLoc loc;
6300234353Sdim} CXIdxBaseClassInfo;
6301234353Sdim
6302234353Sdimtypedef struct {
6303234353Sdim  const CXIdxEntityInfo *protocol;
6304234353Sdim  CXCursor cursor;
6305234353Sdim  CXIdxLoc loc;
6306234353Sdim} CXIdxObjCProtocolRefInfo;
6307234353Sdim
6308234353Sdimtypedef struct {
6309234353Sdim  const CXIdxObjCProtocolRefInfo *const *protocols;
6310234353Sdim  unsigned numProtocols;
6311234353Sdim} CXIdxObjCProtocolRefListInfo;
6312234353Sdim
6313234353Sdimtypedef struct {
6314234353Sdim  const CXIdxObjCContainerDeclInfo *containerInfo;
6315234353Sdim  const CXIdxBaseClassInfo *superInfo;
6316234353Sdim  const CXIdxObjCProtocolRefListInfo *protocols;
6317234353Sdim} CXIdxObjCInterfaceDeclInfo;
6318234353Sdim
6319234353Sdimtypedef struct {
6320234353Sdim  const CXIdxObjCContainerDeclInfo *containerInfo;
6321234353Sdim  const CXIdxEntityInfo *objcClass;
6322234353Sdim  CXCursor classCursor;
6323234353Sdim  CXIdxLoc classLoc;
6324234353Sdim  const CXIdxObjCProtocolRefListInfo *protocols;
6325234353Sdim} CXIdxObjCCategoryDeclInfo;
6326234353Sdim
6327234353Sdimtypedef struct {
6328234353Sdim  const CXIdxDeclInfo *declInfo;
6329234353Sdim  const CXIdxEntityInfo *getter;
6330234353Sdim  const CXIdxEntityInfo *setter;
6331234353Sdim} CXIdxObjCPropertyDeclInfo;
6332234353Sdim
6333234353Sdimtypedef struct {
6334234353Sdim  const CXIdxDeclInfo *declInfo;
6335234353Sdim  const CXIdxBaseClassInfo *const *bases;
6336234353Sdim  unsigned numBases;
6337234353Sdim} CXIdxCXXClassDeclInfo;
6338234353Sdim
6339234353Sdim/**
6340341825Sdim * Data for IndexerCallbacks#indexEntityReference.
6341341825Sdim *
6342341825Sdim * This may be deprecated in a future version as this duplicates
6343341825Sdim * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6344234353Sdim */
6345234353Sdimtypedef enum {
6346234353Sdim  /**
6347341825Sdim   * The entity is referenced directly in user's code.
6348234353Sdim   */
6349234353Sdim  CXIdxEntityRef_Direct = 1,
6350234353Sdim  /**
6351341825Sdim   * An implicit reference, e.g. a reference of an Objective-C method
6352276479Sdim   * via the dot syntax.
6353234353Sdim   */
6354234353Sdim  CXIdxEntityRef_Implicit = 2
6355234353Sdim} CXIdxEntityRefKind;
6356234353Sdim
6357234353Sdim/**
6358341825Sdim * Roles that are attributed to symbol occurrences.
6359341825Sdim *
6360341825Sdim * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6361341825Sdim * higher bits zeroed. These high bits may be exposed in the future.
6362234353Sdim */
6363341825Sdimtypedef enum {
6364341825Sdim  CXSymbolRole_None = 0,
6365341825Sdim  CXSymbolRole_Declaration = 1 << 0,
6366341825Sdim  CXSymbolRole_Definition = 1 << 1,
6367341825Sdim  CXSymbolRole_Reference = 1 << 2,
6368341825Sdim  CXSymbolRole_Read = 1 << 3,
6369341825Sdim  CXSymbolRole_Write = 1 << 4,
6370341825Sdim  CXSymbolRole_Call = 1 << 5,
6371341825Sdim  CXSymbolRole_Dynamic = 1 << 6,
6372341825Sdim  CXSymbolRole_AddressOf = 1 << 7,
6373341825Sdim  CXSymbolRole_Implicit = 1 << 8
6374341825Sdim} CXSymbolRole;
6375341825Sdim
6376341825Sdim/**
6377341825Sdim * Data for IndexerCallbacks#indexEntityReference.
6378341825Sdim */
6379234353Sdimtypedef struct {
6380234353Sdim  CXIdxEntityRefKind kind;
6381234353Sdim  /**
6382341825Sdim   * Reference cursor.
6383234353Sdim   */
6384234353Sdim  CXCursor cursor;
6385234353Sdim  CXIdxLoc loc;
6386234353Sdim  /**
6387341825Sdim   * The entity that gets referenced.
6388234353Sdim   */
6389234353Sdim  const CXIdxEntityInfo *referencedEntity;
6390234353Sdim  /**
6391341825Sdim   * Immediate "parent" of the reference. For example:
6392341825Sdim   *
6393234353Sdim   * \code
6394234353Sdim   * Foo *var;
6395234353Sdim   * \endcode
6396341825Sdim   *
6397234353Sdim   * The parent of reference of type 'Foo' is the variable 'var'.
6398234353Sdim   * For references inside statement bodies of functions/methods,
6399234353Sdim   * the parentEntity will be the function/method.
6400234353Sdim   */
6401234353Sdim  const CXIdxEntityInfo *parentEntity;
6402234353Sdim  /**
6403341825Sdim   * Lexical container context of the reference.
6404234353Sdim   */
6405234353Sdim  const CXIdxContainerInfo *container;
6406341825Sdim  /**
6407341825Sdim   * Sets of symbol roles of the reference.
6408341825Sdim   */
6409341825Sdim  CXSymbolRole role;
6410234353Sdim} CXIdxEntityRefInfo;
6411234353Sdim
6412239462Sdim/**
6413341825Sdim * A group of callbacks used by #clang_indexSourceFile and
6414239462Sdim * #clang_indexTranslationUnit.
6415239462Sdim */
6416234353Sdimtypedef struct {
6417234353Sdim  /**
6418341825Sdim   * Called periodically to check whether indexing should be aborted.
6419234353Sdim   * Should return 0 to continue, and non-zero to abort.
6420234353Sdim   */
6421234353Sdim  int (*abortQuery)(CXClientData client_data, void *reserved);
6422234353Sdim
6423234353Sdim  /**
6424341825Sdim   * Called at the end of indexing; passes the complete diagnostic set.
6425234353Sdim   */
6426234353Sdim  void (*diagnostic)(CXClientData client_data,
6427234353Sdim                     CXDiagnosticSet, void *reserved);
6428234353Sdim
6429234353Sdim  CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
6430239462Sdim                                     CXFile mainFile, void *reserved);
6431341825Sdim
6432234353Sdim  /**
6433341825Sdim   * Called when a file gets \#included/\#imported.
6434234353Sdim   */
6435234353Sdim  CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
6436234353Sdim                                    const CXIdxIncludedFileInfo *);
6437341825Sdim
6438234353Sdim  /**
6439341825Sdim   * Called when a AST file (PCH or module) gets imported.
6440341825Sdim   *
6441234353Sdim   * AST files will not get indexed (there will not be callbacks to index all
6442234353Sdim   * the entities in an AST file). The recommended action is that, if the AST
6443243830Sdim   * file is not already indexed, to initiate a new indexing job specific to
6444243830Sdim   * the AST file.
6445234353Sdim   */
6446234353Sdim  CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
6447234353Sdim                                        const CXIdxImportedASTFileInfo *);
6448234353Sdim
6449234353Sdim  /**
6450341825Sdim   * Called at the beginning of indexing a translation unit.
6451234353Sdim   */
6452234353Sdim  CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
6453234353Sdim                                                 void *reserved);
6454234353Sdim
6455234353Sdim  void (*indexDeclaration)(CXClientData client_data,
6456234353Sdim                           const CXIdxDeclInfo *);
6457234353Sdim
6458234353Sdim  /**
6459341825Sdim   * Called to index a reference of an entity.
6460234353Sdim   */
6461234353Sdim  void (*indexEntityReference)(CXClientData client_data,
6462234353Sdim                               const CXIdxEntityRefInfo *);
6463234353Sdim
6464234353Sdim} IndexerCallbacks;
6465234353Sdim
6466234353SdimCINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6467234353SdimCINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6468234353Sdimclang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
6469234353Sdim
6470234353SdimCINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6471234353Sdimclang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6472234353Sdim
6473234353SdimCINDEX_LINKAGE
6474234353Sdimconst CXIdxObjCCategoryDeclInfo *
6475234353Sdimclang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6476234353Sdim
6477234353SdimCINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6478234353Sdimclang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
6479234353Sdim
6480234353SdimCINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6481234353Sdimclang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6482234353Sdim
6483234353SdimCINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6484234353Sdimclang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6485234353Sdim
6486234353SdimCINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6487234353Sdimclang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6488234353Sdim
6489234353Sdim/**
6490341825Sdim * For retrieving a custom CXIdxClientContainer attached to a
6491234353Sdim * container.
6492234353Sdim */
6493234353SdimCINDEX_LINKAGE CXIdxClientContainer
6494234353Sdimclang_index_getClientContainer(const CXIdxContainerInfo *);
6495234353Sdim
6496234353Sdim/**
6497341825Sdim * For setting a custom CXIdxClientContainer attached to a
6498234353Sdim * container.
6499234353Sdim */
6500234353SdimCINDEX_LINKAGE void
6501234353Sdimclang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
6502234353Sdim
6503234353Sdim/**
6504341825Sdim * For retrieving a custom CXIdxClientEntity attached to an entity.
6505234353Sdim */
6506234353SdimCINDEX_LINKAGE CXIdxClientEntity
6507234353Sdimclang_index_getClientEntity(const CXIdxEntityInfo *);
6508234353Sdim
6509234353Sdim/**
6510341825Sdim * For setting a custom CXIdxClientEntity attached to an entity.
6511234353Sdim */
6512234353SdimCINDEX_LINKAGE void
6513234353Sdimclang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
6514234353Sdim
6515234353Sdim/**
6516341825Sdim * An indexing action/session, to be applied to one or multiple
6517249423Sdim * translation units.
6518234353Sdim */
6519234353Sdimtypedef void *CXIndexAction;
6520234353Sdim
6521234353Sdim/**
6522341825Sdim * An indexing action/session, to be applied to one or multiple
6523249423Sdim * translation units.
6524234353Sdim *
6525234353Sdim * \param CIdx The index object with which the index action will be associated.
6526234353Sdim */
6527234353SdimCINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6528234353Sdim
6529234353Sdim/**
6530341825Sdim * Destroy the given index action.
6531234353Sdim *
6532234353Sdim * The index action must not be destroyed until all of the translation units
6533234353Sdim * created within that index action have been destroyed.
6534234353Sdim */
6535234353SdimCINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6536234353Sdim
6537234353Sdimtypedef enum {
6538234353Sdim  /**
6539341825Sdim   * Used to indicate that no special indexing options are needed.
6540234353Sdim   */
6541234353Sdim  CXIndexOpt_None = 0x0,
6542341825Sdim
6543234353Sdim  /**
6544341825Sdim   * Used to indicate that IndexerCallbacks#indexEntityReference should
6545239462Sdim   * be invoked for only one reference of an entity per source file that does
6546239462Sdim   * not also include a declaration/definition of the entity.
6547234353Sdim   */
6548234353Sdim  CXIndexOpt_SuppressRedundantRefs = 0x1,
6549234353Sdim
6550234353Sdim  /**
6551341825Sdim   * Function-local symbols should be indexed. If this is not set
6552234353Sdim   * function-local symbols will be ignored.
6553234353Sdim   */
6554234353Sdim  CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6555234353Sdim
6556234353Sdim  /**
6557341825Sdim   * Implicit function/class template instantiations should be indexed.
6558234353Sdim   * If this is not set, implicit instantiations will be ignored.
6559234353Sdim   */
6560234353Sdim  CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6561234353Sdim
6562234353Sdim  /**
6563341825Sdim   * Suppress all compiler warnings when parsing for indexing.
6564234353Sdim   */
6565249423Sdim  CXIndexOpt_SuppressWarnings = 0x8,
6566249423Sdim
6567249423Sdim  /**
6568341825Sdim   * Skip a function/method body that was already parsed during an
6569276479Sdim   * indexing session associated with a \c CXIndexAction object.
6570249423Sdim   * Bodies in system headers are always skipped.
6571249423Sdim   */
6572249423Sdim  CXIndexOpt_SkipParsedBodiesInSession = 0x10
6573249423Sdim
6574234353Sdim} CXIndexOptFlags;
6575234353Sdim
6576234353Sdim/**
6577341825Sdim * Index the given source file and the translation unit corresponding
6578239462Sdim * to that file via callbacks implemented through #IndexerCallbacks.
6579234353Sdim *
6580234353Sdim * \param client_data pointer data supplied by the client, which will
6581234353Sdim * be passed to the invoked callbacks.
6582234353Sdim *
6583234353Sdim * \param index_callbacks Pointer to indexing callbacks that the client
6584234353Sdim * implements.
6585234353Sdim *
6586239462Sdim * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6587234353Sdim * passed in index_callbacks.
6588234353Sdim *
6589234353Sdim * \param index_options A bitmask of options that affects how indexing is
6590234353Sdim * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6591234353Sdim *
6592276479Sdim * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6593276479Sdim * reused after indexing is finished. Set to \c NULL if you do not require it.
6594234353Sdim *
6595276479Sdim * \returns 0 on success or if there were errors from which the compiler could
6596288943Sdim * recover.  If there is a failure from which there is no recovery, returns
6597276479Sdim * a non-zero \c CXErrorCode.
6598234353Sdim *
6599239462Sdim * The rest of the parameters are the same as #clang_parseTranslationUnit.
6600234353Sdim */
6601234353SdimCINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
6602234353Sdim                                         CXClientData client_data,
6603234353Sdim                                         IndexerCallbacks *index_callbacks,
6604234353Sdim                                         unsigned index_callbacks_size,
6605234353Sdim                                         unsigned index_options,
6606234353Sdim                                         const char *source_filename,
6607234353Sdim                                         const char * const *command_line_args,
6608234353Sdim                                         int num_command_line_args,
6609234353Sdim                                         struct CXUnsavedFile *unsaved_files,
6610234353Sdim                                         unsigned num_unsaved_files,
6611234353Sdim                                         CXTranslationUnit *out_TU,
6612234353Sdim                                         unsigned TU_options);
6613234353Sdim
6614234353Sdim/**
6615341825Sdim * Same as clang_indexSourceFile but requires a full command line
6616296417Sdim * for \c command_line_args including argv[0]. This is useful if the standard
6617296417Sdim * library paths are relative to the binary.
6618296417Sdim */
6619296417SdimCINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6620296417Sdim    CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6621296417Sdim    unsigned index_callbacks_size, unsigned index_options,
6622296417Sdim    const char *source_filename, const char *const *command_line_args,
6623296417Sdim    int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6624296417Sdim    unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6625296417Sdim
6626296417Sdim/**
6627341825Sdim * Index the given translation unit via callbacks implemented through
6628239462Sdim * #IndexerCallbacks.
6629341825Sdim *
6630234353Sdim * The order of callback invocations is not guaranteed to be the same as
6631234353Sdim * when indexing a source file. The high level order will be:
6632341825Sdim *
6633234353Sdim *   -Preprocessor callbacks invocations
6634234353Sdim *   -Declaration/reference callbacks invocations
6635234353Sdim *   -Diagnostic callback invocations
6636234353Sdim *
6637239462Sdim * The parameters are the same as #clang_indexSourceFile.
6638341825Sdim *
6639288943Sdim * \returns If there is a failure from which there is no recovery, returns
6640234353Sdim * non-zero, otherwise returns 0.
6641234353Sdim */
6642234353SdimCINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
6643234353Sdim                                              CXClientData client_data,
6644234353Sdim                                              IndexerCallbacks *index_callbacks,
6645234353Sdim                                              unsigned index_callbacks_size,
6646234353Sdim                                              unsigned index_options,
6647234353Sdim                                              CXTranslationUnit);
6648234353Sdim
6649234353Sdim/**
6650341825Sdim * Retrieve the CXIdxFile, file, line, column, and offset represented by
6651234353Sdim * the given CXIdxLoc.
6652234353Sdim *
6653234353Sdim * If the location refers into a macro expansion, retrieves the
6654234353Sdim * location of the macro expansion and if it refers into a macro argument
6655234353Sdim * retrieves the location of the argument.
6656234353Sdim */
6657234353SdimCINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6658234353Sdim                                                   CXIdxClientFile *indexFile,
6659234353Sdim                                                   CXFile *file,
6660234353Sdim                                                   unsigned *line,
6661234353Sdim                                                   unsigned *column,
6662234353Sdim                                                   unsigned *offset);
6663234353Sdim
6664234353Sdim/**
6665341825Sdim * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6666234353Sdim */
6667234353SdimCINDEX_LINKAGE
6668234353SdimCXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6669234353Sdim
6670234353Sdim/**
6671341825Sdim * Visitor invoked for each field found by a traversal.
6672288943Sdim *
6673288943Sdim * This visitor function will be invoked for each field found by
6674288943Sdim * \c clang_Type_visitFields. Its first argument is the cursor being
6675288943Sdim * visited, its second argument is the client data provided to
6676288943Sdim * \c clang_Type_visitFields.
6677288943Sdim *
6678288943Sdim * The visitor should return one of the \c CXVisitorResult values
6679288943Sdim * to direct \c clang_Type_visitFields.
6680288943Sdim */
6681288943Sdimtypedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6682288943Sdim                                               CXClientData client_data);
6683288943Sdim
6684288943Sdim/**
6685341825Sdim * Visit the fields of a particular type.
6686288943Sdim *
6687288943Sdim * This function visits all the direct fields of the given cursor,
6688288943Sdim * invoking the given \p visitor function with the cursors of each
6689288943Sdim * visited field. The traversal may be ended prematurely, if
6690288943Sdim * the visitor returns \c CXFieldVisit_Break.
6691288943Sdim *
6692288943Sdim * \param T the record type whose field may be visited.
6693288943Sdim *
6694288943Sdim * \param visitor the visitor function that will be invoked for each
6695288943Sdim * field of \p T.
6696288943Sdim *
6697288943Sdim * \param client_data pointer data supplied by the client, which will
6698288943Sdim * be passed to the visitor each time it is invoked.
6699288943Sdim *
6700288943Sdim * \returns a non-zero value if the traversal was terminated
6701288943Sdim * prematurely by the visitor returning \c CXFieldVisit_Break.
6702288943Sdim */
6703288943SdimCINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6704288943Sdim                                               CXFieldVisitor visitor,
6705288943Sdim                                               CXClientData client_data);
6706288943Sdim
6707288943Sdim/**
6708224145Sdim * @}
6709224145Sdim */
6710224145Sdim
6711226633Sdim/**
6712226633Sdim * @}
6713226633Sdim */
6714226633Sdim
6715198092Srdivacky#ifdef __cplusplus
6716198092Srdivacky}
6717198092Srdivacky#endif
6718198092Srdivacky#endif
6719