1198092Srdivacky/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2198092Srdivacky|*                                                                            *|
3353358Sdim|* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
4353358Sdim|* Exceptions.                                                                *|
5353358Sdim|* See https://llvm.org/LICENSE.txt for license information.                  *|
6353358Sdim|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
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
21360784Sdim#include "clang-c/BuildSystem.h"
22276479Sdim#include "clang-c/CXErrorCode.h"
23239462Sdim#include "clang-c/CXString.h"
24360784Sdim#include "clang-c/ExternC.h"
25360784Sdim#include "clang-c/Platform.h"
26239462Sdim
27243830Sdim/**
28341825Sdim * The version constants for the libclang API.
29243830Sdim * CINDEX_VERSION_MINOR should increase when there are API additions.
30243830Sdim * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
31243830Sdim *
32243830Sdim * The policy about the libclang API was always to keep it source and ABI
33243830Sdim * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
34243830Sdim */
35243830Sdim#define CINDEX_VERSION_MAJOR 0
36353358Sdim#define CINDEX_VERSION_MINOR 59
37243830Sdim
38243830Sdim#define CINDEX_VERSION_ENCODE(major, minor) ( \
39243830Sdim      ((major) * 10000)                       \
40243830Sdim    + ((minor) *     1))
41243830Sdim
42243830Sdim#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
43243830Sdim    CINDEX_VERSION_MAJOR,                     \
44243830Sdim    CINDEX_VERSION_MINOR )
45243830Sdim
46243830Sdim#define CINDEX_VERSION_STRINGIZE_(major, minor)   \
47243830Sdim    #major"."#minor
48243830Sdim#define CINDEX_VERSION_STRINGIZE(major, minor)    \
49243830Sdim    CINDEX_VERSION_STRINGIZE_(major, minor)
50243830Sdim
51243830Sdim#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
52243830Sdim    CINDEX_VERSION_MAJOR,                               \
53243830Sdim    CINDEX_VERSION_MINOR)
54243830Sdim
55360784SdimLLVM_CLANG_C_EXTERN_C_BEGIN
56198092Srdivacky
57219077Sdim/** \defgroup CINDEX libclang: C Interface to Clang
58202879Srdivacky *
59203955Srdivacky * The C Interface to Clang provides a relatively small API that exposes
60202879Srdivacky * facilities for parsing source code into an abstract syntax tree (AST),
61202879Srdivacky * loading already-parsed ASTs, traversing the AST, associating
62202879Srdivacky * physical source locations with elements within the AST, and other
63202879Srdivacky * facilities that support Clang-based development tools.
64202879Srdivacky *
65203955Srdivacky * This C interface to Clang will never provide all of the information
66202879Srdivacky * representation stored in Clang's C++ AST, nor should it: the intent is to
67202879Srdivacky * maintain an API that is relatively stable from one release to the next,
68202879Srdivacky * providing only the basic functionality needed to support development tools.
69203955Srdivacky *
70203955Srdivacky * To avoid namespace pollution, data types are prefixed with "CX" and
71202879Srdivacky * functions are prefixed with "clang_".
72202879Srdivacky *
73202879Srdivacky * @{
74202879Srdivacky */
75203955Srdivacky
76202879Srdivacky/**
77341825Sdim * An "index" that consists of a set of translation units that would
78202879Srdivacky * typically be linked together into an executable or library.
79202879Srdivacky */
80202879Srdivackytypedef void *CXIndex;
81198092Srdivacky
82202879Srdivacky/**
83341825Sdim * An opaque type representing target information for a given translation
84321369Sdim * unit.
85321369Sdim */
86321369Sdimtypedef struct CXTargetInfoImpl *CXTargetInfo;
87321369Sdim
88321369Sdim/**
89341825Sdim * A single translation unit, which resides in an index.
90202879Srdivacky */
91218893Sdimtypedef struct CXTranslationUnitImpl *CXTranslationUnit;
92198092Srdivacky
93200583Srdivacky/**
94341825Sdim * Opaque pointer representing client data that will be passed through
95202879Srdivacky * to various callbacks and visitors.
96202879Srdivacky */
97202879Srdivackytypedef void *CXClientData;
98203955Srdivacky
99202879Srdivacky/**
100341825Sdim * Provides the contents of a file that has not yet been saved to disk.
101200583Srdivacky *
102200583Srdivacky * Each CXUnsavedFile instance provides the name of a file on the
103200583Srdivacky * system along with the current contents of that file that have not
104200583Srdivacky * yet been saved to disk.
105200583Srdivacky */
106200583Srdivackystruct CXUnsavedFile {
107203955Srdivacky  /**
108341825Sdim   * The file whose contents have not yet been saved.
109200583Srdivacky   *
110200583Srdivacky   * This file must already exist in the file system.
111200583Srdivacky   */
112200583Srdivacky  const char *Filename;
113200583Srdivacky
114203955Srdivacky  /**
115341825Sdim   * A buffer containing the unsaved contents of this file.
116200583Srdivacky   */
117200583Srdivacky  const char *Contents;
118200583Srdivacky
119200583Srdivacky  /**
120341825Sdim   * The length of the unsaved contents of this buffer.
121200583Srdivacky   */
122200583Srdivacky  unsigned long Length;
123200583Srdivacky};
124200583Srdivacky
125199482Srdivacky/**
126341825Sdim * Describes the availability of a particular entity, which indicates
127212904Sdim * whether the use of this entity will result in a warning or error due to
128212904Sdim * it being deprecated or unavailable.
129212904Sdim */
130212904Sdimenum CXAvailabilityKind {
131212904Sdim  /**
132341825Sdim   * The entity is available.
133212904Sdim   */
134212904Sdim  CXAvailability_Available,
135212904Sdim  /**
136341825Sdim   * The entity is available, but has been deprecated (and its use is
137212904Sdim   * not recommended).
138212904Sdim   */
139212904Sdim  CXAvailability_Deprecated,
140212904Sdim  /**
141341825Sdim   * The entity is not available; any use of it will be an error.
142212904Sdim   */
143226633Sdim  CXAvailability_NotAvailable,
144226633Sdim  /**
145341825Sdim   * The entity is available, but not accessible; any use of it will be
146226633Sdim   * an error.
147226633Sdim   */
148226633Sdim  CXAvailability_NotAccessible
149212904Sdim};
150203955Srdivacky
151202879Srdivacky/**
152341825Sdim * Describes a version number of the form major.minor.subminor.
153202879Srdivacky */
154239462Sdimtypedef struct CXVersion {
155239462Sdim  /**
156341825Sdim   * The major version number, e.g., the '10' in '10.7.3'. A negative
157239462Sdim   * value indicates that there is no version number at all.
158239462Sdim   */
159239462Sdim  int Major;
160239462Sdim  /**
161341825Sdim   * The minor version number, e.g., the '7' in '10.7.3'. This value
162341825Sdim   * will be negative if no minor version number was provided, e.g., for
163239462Sdim   * version '10'.
164239462Sdim   */
165239462Sdim  int Minor;
166239462Sdim  /**
167341825Sdim   * The subminor version number, e.g., the '3' in '10.7.3'. This value
168239462Sdim   * will be negative if no minor or subminor version number was provided,
169239462Sdim   * e.g., in version '10' or '10.7'.
170239462Sdim   */
171239462Sdim  int Subminor;
172239462Sdim} CXVersion;
173321369Sdim
174202879Srdivacky/**
175341825Sdim * Describes the exception specification of a cursor.
176321369Sdim *
177321369Sdim * A negative value indicates that the cursor is not a function declaration.
178321369Sdim */
179321369Sdimenum CXCursor_ExceptionSpecificationKind {
180321369Sdim  /**
181341825Sdim   * The cursor has no exception specification.
182321369Sdim   */
183321369Sdim  CXCursor_ExceptionSpecificationKind_None,
184321369Sdim
185321369Sdim  /**
186341825Sdim   * The cursor has exception specification throw()
187321369Sdim   */
188321369Sdim  CXCursor_ExceptionSpecificationKind_DynamicNone,
189321369Sdim
190321369Sdim  /**
191341825Sdim   * The cursor has exception specification throw(T1, T2)
192321369Sdim   */
193321369Sdim  CXCursor_ExceptionSpecificationKind_Dynamic,
194321369Sdim
195321369Sdim  /**
196341825Sdim   * The cursor has exception specification throw(...).
197321369Sdim   */
198321369Sdim  CXCursor_ExceptionSpecificationKind_MSAny,
199321369Sdim
200321369Sdim  /**
201341825Sdim   * The cursor has exception specification basic noexcept.
202321369Sdim   */
203321369Sdim  CXCursor_ExceptionSpecificationKind_BasicNoexcept,
204321369Sdim
205321369Sdim  /**
206341825Sdim   * The cursor has exception specification computed noexcept.
207321369Sdim   */
208321369Sdim  CXCursor_ExceptionSpecificationKind_ComputedNoexcept,
209321369Sdim
210321369Sdim  /**
211341825Sdim   * The exception specification has not yet been evaluated.
212321369Sdim   */
213321369Sdim  CXCursor_ExceptionSpecificationKind_Unevaluated,
214321369Sdim
215321369Sdim  /**
216341825Sdim   * The exception specification has not yet been instantiated.
217321369Sdim   */
218321369Sdim  CXCursor_ExceptionSpecificationKind_Uninstantiated,
219321369Sdim
220321369Sdim  /**
221341825Sdim   * The exception specification has not been parsed yet.
222321369Sdim   */
223353358Sdim  CXCursor_ExceptionSpecificationKind_Unparsed,
224353358Sdim
225353358Sdim  /**
226353358Sdim   * The cursor has a __declspec(nothrow) exception specification.
227353358Sdim   */
228353358Sdim  CXCursor_ExceptionSpecificationKind_NoThrow
229321369Sdim};
230321369Sdim
231321369Sdim/**
232341825Sdim * Provides a shared context for creating translation units.
233198398Srdivacky *
234239462Sdim * It provides two options:
235239462Sdim *
236198398Srdivacky * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
237198398Srdivacky * declarations (when loading any new translation units). A "local" declaration
238203955Srdivacky * is one that belongs in the translation unit itself and not in a precompiled
239198398Srdivacky * header that was used by the translation unit. If zero, all declarations
240198398Srdivacky * will be enumerated.
241198398Srdivacky *
242198398Srdivacky * Here is an example:
243198398Srdivacky *
244239462Sdim * \code
245204643Srdivacky *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
246204643Srdivacky *   Idx = clang_createIndex(1, 1);
247198398Srdivacky *
248198398Srdivacky *   // IndexTest.pch was produced with the following command:
249198398Srdivacky *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
250198398Srdivacky *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
251198398Srdivacky *
252198398Srdivacky *   // This will load all the symbols from 'IndexTest.pch'
253203955Srdivacky *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
254202879Srdivacky *                       TranslationUnitVisitor, 0);
255198398Srdivacky *   clang_disposeTranslationUnit(TU);
256198398Srdivacky *
257198398Srdivacky *   // This will load all the symbols from 'IndexTest.c', excluding symbols
258198398Srdivacky *   // from 'IndexTest.pch'.
259203955Srdivacky *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
260203955Srdivacky *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
261203955Srdivacky *                                                  0, 0);
262202879Srdivacky *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
263202879Srdivacky *                       TranslationUnitVisitor, 0);
264198398Srdivacky *   clang_disposeTranslationUnit(TU);
265239462Sdim * \endcode
266198398Srdivacky *
267198398Srdivacky * This process of creating the 'pch', loading it separately, and using it (via
268198398Srdivacky * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
269198398Srdivacky * (which gives the indexer the same performance benefit as the compiler).
270198398Srdivacky */
271204643SrdivackyCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
272204643Srdivacky                                         int displayDiagnostics);
273205219Srdivacky
274203955Srdivacky/**
275341825Sdim * Destroy the given index.
276203955Srdivacky *
277203955Srdivacky * The index must not be destroyed until all of the translation units created
278203955Srdivacky * within that index have been destroyed.
279203955Srdivacky */
280200583SrdivackyCINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
281198092Srdivacky
282234353Sdimtypedef enum {
283234353Sdim  /**
284341825Sdim   * Used to indicate that no special CXIndex options are needed.
285234353Sdim   */
286234353Sdim  CXGlobalOpt_None = 0x0,
287234353Sdim
288234353Sdim  /**
289341825Sdim   * Used to indicate that threads that libclang creates for indexing
290234353Sdim   * purposes should use background priority.
291239462Sdim   *
292239462Sdim   * Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
293239462Sdim   * #clang_parseTranslationUnit, #clang_saveTranslationUnit.
294234353Sdim   */
295234353Sdim  CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
296234353Sdim
297234353Sdim  /**
298341825Sdim   * Used to indicate that threads that libclang creates for editing
299234353Sdim   * purposes should use background priority.
300239462Sdim   *
301239462Sdim   * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
302239462Sdim   * #clang_annotateTokens
303234353Sdim   */
304234353Sdim  CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
305234353Sdim
306234353Sdim  /**
307341825Sdim   * Used to indicate that all threads that libclang creates should use
308234353Sdim   * background priority.
309234353Sdim   */
310234353Sdim  CXGlobalOpt_ThreadBackgroundPriorityForAll =
311234353Sdim      CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
312234353Sdim      CXGlobalOpt_ThreadBackgroundPriorityForEditing
313234353Sdim
314234353Sdim} CXGlobalOptFlags;
315234353Sdim
316202879Srdivacky/**
317341825Sdim * Sets general options associated with a CXIndex.
318234353Sdim *
319234353Sdim * For example:
320234353Sdim * \code
321234353Sdim * CXIndex idx = ...;
322234353Sdim * clang_CXIndex_setGlobalOptions(idx,
323234353Sdim *     clang_CXIndex_getGlobalOptions(idx) |
324234353Sdim *     CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
325234353Sdim * \endcode
326234353Sdim *
327234353Sdim * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
328234353Sdim */
329234353SdimCINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
330234353Sdim
331234353Sdim/**
332341825Sdim * Gets the general options associated with a CXIndex.
333234353Sdim *
334234353Sdim * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
335234353Sdim * are associated with the given CXIndex object.
336234353Sdim */
337234353SdimCINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
338234353Sdim
339234353Sdim/**
340341825Sdim * Sets the invocation emission path option in a CXIndex.
341327952Sdim *
342327952Sdim * The invocation emission path specifies a path which will contain log
343327952Sdim * files for certain libclang invocations. A null value (default) implies that
344327952Sdim * libclang invocations are not logged..
345327952Sdim */
346327952SdimCINDEX_LINKAGE void
347327952Sdimclang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
348327952Sdim
349327952Sdim/**
350202879Srdivacky * \defgroup CINDEX_FILES File manipulation routines
351202879Srdivacky *
352202879Srdivacky * @{
353202879Srdivacky */
354203955Srdivacky
355202879Srdivacky/**
356341825Sdim * A particular source file that is part of a translation unit.
357202879Srdivacky */
358202879Srdivackytypedef void *CXFile;
359198092Srdivacky
360202879Srdivacky/**
361341825Sdim * Retrieve the complete file and path name of the given file.
362202879Srdivacky */
363204643SrdivackyCINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
364203955Srdivacky
365202879Srdivacky/**
366341825Sdim * Retrieve the last modification time of the given file.
367202879Srdivacky */
368202879SrdivackyCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
369198092Srdivacky
370202879Srdivacky/**
371341825Sdim * Uniquely identifies a CXFile, that refers to the same underlying file,
372249423Sdim * across an indexing session.
373249423Sdim */
374249423Sdimtypedef struct {
375249423Sdim  unsigned long long data[3];
376249423Sdim} CXFileUniqueID;
377249423Sdim
378249423Sdim/**
379341825Sdim * Retrieve the unique ID for the given \c file.
380249423Sdim *
381249423Sdim * \param file the file to get the ID for.
382249423Sdim * \param outID stores the returned CXFileUniqueID.
383249423Sdim * \returns If there was a failure getting the unique ID, returns non-zero,
384249423Sdim * otherwise returns 0.
385249423Sdim*/
386249423SdimCINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
387249423Sdim
388249423Sdim/**
389341825Sdim * Determine whether the given header is guarded against
390223017Sdim * multiple inclusions, either with the conventional
391239462Sdim * \#ifndef/\#define/\#endif macro guards or with \#pragma once.
392223017Sdim */
393341825SdimCINDEX_LINKAGE unsigned
394223017Sdimclang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
395223017Sdim
396223017Sdim/**
397341825Sdim * Retrieve a file handle within the given translation unit.
398202879Srdivacky *
399202879Srdivacky * \param tu the translation unit
400203955Srdivacky *
401314564Sdim * \param file_name the name of the file.
402202879Srdivacky *
403202879Srdivacky * \returns the file handle for the named file in the translation unit \p tu,
404202879Srdivacky * or a NULL file handle if the file was not a part of this translation unit.
405202879Srdivacky */
406203955SrdivackyCINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
407202879Srdivacky                                    const char *file_name);
408203955Srdivacky
409202879Srdivacky/**
410341825Sdim * Retrieve the buffer associated with the given file.
411327952Sdim *
412327952Sdim * \param tu the translation unit
413327952Sdim *
414327952Sdim * \param file the file for which to retrieve the buffer.
415327952Sdim *
416327952Sdim * \param size [out] if non-NULL, will be set to the size of the buffer.
417327952Sdim *
418327952Sdim * \returns a pointer to the buffer in memory that holds the contents of
419327952Sdim * \p file, or a NULL pointer when the file is not loaded.
420327952Sdim */
421327952SdimCINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
422327952Sdim                                                 CXFile file, size_t *size);
423327952Sdim
424327952Sdim/**
425341825Sdim * Returns non-zero if the \c file1 and \c file2 point to the same file,
426280031Sdim * or they are both NULL.
427280031Sdim */
428280031SdimCINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2);
429280031Sdim
430280031Sdim/**
431341825Sdim * Returns the real path name of \c file.
432341825Sdim *
433341825Sdim * An empty string may be returned. Use \c clang_getFileName() in that case.
434341825Sdim */
435341825SdimCINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file);
436341825Sdim
437341825Sdim/**
438202879Srdivacky * @}
439202879Srdivacky */
440198092Srdivacky
441202879Srdivacky/**
442202879Srdivacky * \defgroup CINDEX_LOCATIONS Physical source locations
443202879Srdivacky *
444202879Srdivacky * Clang represents physical source locations in its abstract syntax tree in
445202879Srdivacky * great detail, with file, line, and column information for the majority of
446202879Srdivacky * the tokens parsed in the source code. These data types and functions are
447202879Srdivacky * used to represent source location information, either for a particular
448202879Srdivacky * point in the program or for a range of points in the program, and extract
449202879Srdivacky * specific location information from those data types.
450202879Srdivacky *
451202879Srdivacky * @{
452202879Srdivacky */
453203955Srdivacky
454202879Srdivacky/**
455341825Sdim * Identifies a specific source location within a translation
456202879Srdivacky * unit.
457202879Srdivacky *
458226633Sdim * Use clang_getExpansionLocation() or clang_getSpellingLocation()
459218893Sdim * to map a source location to a particular file, line, and column.
460202879Srdivacky */
461202879Srdivackytypedef struct {
462249423Sdim  const void *ptr_data[2];
463202879Srdivacky  unsigned int_data;
464202879Srdivacky} CXSourceLocation;
465198092Srdivacky
466202879Srdivacky/**
467341825Sdim * Identifies a half-open character range in the source code.
468202879Srdivacky *
469202879Srdivacky * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
470202879Srdivacky * starting and end locations from a source range, respectively.
471198893Srdivacky */
472202879Srdivackytypedef struct {
473249423Sdim  const void *ptr_data[2];
474202879Srdivacky  unsigned begin_int_data;
475202879Srdivacky  unsigned end_int_data;
476202879Srdivacky} CXSourceRange;
477198893Srdivacky
478202879Srdivacky/**
479341825Sdim * Retrieve a NULL (invalid) source location.
480198092Srdivacky */
481249423SdimCINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
482203955Srdivacky
483202879Srdivacky/**
484341825Sdim * Determine whether two source locations, which must refer into
485203955Srdivacky * the same translation unit, refer to exactly the same point in the source
486202879Srdivacky * code.
487202879Srdivacky *
488202879Srdivacky * \returns non-zero if the source locations refer to the same location, zero
489202879Srdivacky * if they refer to different locations.
490202879Srdivacky */
491202879SrdivackyCINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
492202879Srdivacky                                             CXSourceLocation loc2);
493203955Srdivacky
494202879Srdivacky/**
495341825Sdim * Retrieves the source location associated with a given file/line/column
496203955Srdivacky * in a particular translation unit.
497202879Srdivacky */
498202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
499202879Srdivacky                                                  CXFile file,
500202879Srdivacky                                                  unsigned line,
501202879Srdivacky                                                  unsigned column);
502218893Sdim/**
503341825Sdim * Retrieves the source location associated with a given character offset
504218893Sdim * in a particular translation unit.
505218893Sdim */
506218893SdimCINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
507218893Sdim                                                           CXFile file,
508218893Sdim                                                           unsigned offset);
509203955Srdivacky
510203955Srdivacky/**
511341825Sdim * Returns non-zero if the given source location is in a system header.
512251662Sdim */
513251662SdimCINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location);
514251662Sdim
515251662Sdim/**
516341825Sdim * Returns non-zero if the given source location is in the main file of
517261991Sdim * the corresponding translation unit.
518261991Sdim */
519261991SdimCINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location);
520261991Sdim
521261991Sdim/**
522341825Sdim * Retrieve a NULL (invalid) source range.
523203955Srdivacky */
524249423SdimCINDEX_LINKAGE CXSourceRange clang_getNullRange(void);
525205219Srdivacky
526202879Srdivacky/**
527341825Sdim * Retrieve a source range given the beginning and ending source
528202879Srdivacky * locations.
529202879Srdivacky */
530202879SrdivackyCINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
531202879Srdivacky                                            CXSourceLocation end);
532203955Srdivacky
533202879Srdivacky/**
534341825Sdim * Determine whether two ranges are equivalent.
535226633Sdim *
536226633Sdim * \returns non-zero if the ranges are the same, zero if they differ.
537226633Sdim */
538226633SdimCINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1,
539226633Sdim                                          CXSourceRange range2);
540226633Sdim
541226633Sdim/**
542341825Sdim * Returns non-zero if \p range is null.
543226633Sdim */
544226633SdimCINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
545226633Sdim
546226633Sdim/**
547341825Sdim * Retrieve the file, line, column, and offset represented by
548203955Srdivacky * the given source location.
549202879Srdivacky *
550226633Sdim * If the location refers into a macro expansion, retrieves the
551226633Sdim * location of the macro expansion.
552218893Sdim *
553203955Srdivacky * \param location the location within a source file that will be decomposed
554203955Srdivacky * into its parts.
555202879Srdivacky *
556203955Srdivacky * \param file [out] if non-NULL, will be set to the file to which the given
557202879Srdivacky * source location points.
558202879Srdivacky *
559203955Srdivacky * \param line [out] if non-NULL, will be set to the line to which the given
560202879Srdivacky * source location points.
561202879Srdivacky *
562203955Srdivacky * \param column [out] if non-NULL, will be set to the column to which the given
563203955Srdivacky * source location points.
564203955Srdivacky *
565203955Srdivacky * \param offset [out] if non-NULL, will be set to the offset into the
566203955Srdivacky * buffer to which the given source location points.
567202879Srdivacky */
568226633SdimCINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
569226633Sdim                                               CXFile *file,
570226633Sdim                                               unsigned *line,
571226633Sdim                                               unsigned *column,
572226633Sdim                                               unsigned *offset);
573226633Sdim
574226633Sdim/**
575341825Sdim * Retrieve the file, line and column represented by the given source
576321369Sdim * location, as specified in a # line directive.
577226633Sdim *
578226633Sdim * Example: given the following source code in a file somefile.c
579226633Sdim *
580239462Sdim * \code
581226633Sdim * #123 "dummy.c" 1
582226633Sdim *
583226633Sdim * static int func(void)
584226633Sdim * {
585226633Sdim *     return 0;
586226633Sdim * }
587239462Sdim * \endcode
588226633Sdim *
589226633Sdim * the location information returned by this function would be
590226633Sdim *
591226633Sdim * File: dummy.c Line: 124 Column: 12
592226633Sdim *
593226633Sdim * whereas clang_getExpansionLocation would have returned
594226633Sdim *
595226633Sdim * File: somefile.c Line: 3 Column: 12
596226633Sdim *
597226633Sdim * \param location the location within a source file that will be decomposed
598226633Sdim * into its parts.
599226633Sdim *
600226633Sdim * \param filename [out] if non-NULL, will be set to the filename of the
601226633Sdim * source location. Note that filenames returned will be for "virtual" files,
602226633Sdim * which don't necessarily exist on the machine running clang - e.g. when
603226633Sdim * parsing preprocessed output obtained from a different environment. If
604226633Sdim * a non-NULL value is passed in, remember to dispose of the returned value
605226633Sdim * using \c clang_disposeString() once you've finished with it. For an invalid
606226633Sdim * source location, an empty string is returned.
607226633Sdim *
608226633Sdim * \param line [out] if non-NULL, will be set to the line number of the
609226633Sdim * source location. For an invalid source location, zero is returned.
610226633Sdim *
611226633Sdim * \param column [out] if non-NULL, will be set to the column number of the
612226633Sdim * source location. For an invalid source location, zero is returned.
613226633Sdim */
614226633SdimCINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
615226633Sdim                                              CXString *filename,
616226633Sdim                                              unsigned *line,
617226633Sdim                                              unsigned *column);
618226633Sdim
619226633Sdim/**
620341825Sdim * Legacy API to retrieve the file, line, column, and offset represented
621226633Sdim * by the given source location.
622226633Sdim *
623226633Sdim * This interface has been replaced by the newer interface
624239462Sdim * #clang_getExpansionLocation(). See that interface's documentation for
625226633Sdim * details.
626226633Sdim */
627202879SrdivackyCINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
628202879Srdivacky                                                   CXFile *file,
629202879Srdivacky                                                   unsigned *line,
630203955Srdivacky                                                   unsigned *column,
631203955Srdivacky                                                   unsigned *offset);
632202379Srdivacky
633202879Srdivacky/**
634341825Sdim * Retrieve the file, line, column, and offset represented by
635218893Sdim * the given source location.
636218893Sdim *
637218893Sdim * If the location refers into a macro instantiation, return where the
638218893Sdim * location was originally spelled in the source file.
639218893Sdim *
640218893Sdim * \param location the location within a source file that will be decomposed
641218893Sdim * into its parts.
642218893Sdim *
643218893Sdim * \param file [out] if non-NULL, will be set to the file to which the given
644218893Sdim * source location points.
645218893Sdim *
646218893Sdim * \param line [out] if non-NULL, will be set to the line to which the given
647218893Sdim * source location points.
648218893Sdim *
649218893Sdim * \param column [out] if non-NULL, will be set to the column to which the given
650218893Sdim * source location points.
651218893Sdim *
652218893Sdim * \param offset [out] if non-NULL, will be set to the offset into the
653218893Sdim * buffer to which the given source location points.
654218893Sdim */
655218893SdimCINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
656218893Sdim                                              CXFile *file,
657218893Sdim                                              unsigned *line,
658218893Sdim                                              unsigned *column,
659218893Sdim                                              unsigned *offset);
660218893Sdim
661218893Sdim/**
662341825Sdim * Retrieve the file, line, column, and offset represented by
663249423Sdim * the given source location.
664249423Sdim *
665249423Sdim * If the location refers into a macro expansion, return where the macro was
666249423Sdim * expanded or where the macro argument was written, if the location points at
667249423Sdim * a macro argument.
668249423Sdim *
669249423Sdim * \param location the location within a source file that will be decomposed
670249423Sdim * into its parts.
671249423Sdim *
672249423Sdim * \param file [out] if non-NULL, will be set to the file to which the given
673249423Sdim * source location points.
674249423Sdim *
675249423Sdim * \param line [out] if non-NULL, will be set to the line to which the given
676249423Sdim * source location points.
677249423Sdim *
678249423Sdim * \param column [out] if non-NULL, will be set to the column to which the given
679249423Sdim * source location points.
680249423Sdim *
681249423Sdim * \param offset [out] if non-NULL, will be set to the offset into the
682249423Sdim * buffer to which the given source location points.
683249423Sdim */
684249423SdimCINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
685249423Sdim                                          CXFile *file,
686249423Sdim                                          unsigned *line,
687249423Sdim                                          unsigned *column,
688249423Sdim                                          unsigned *offset);
689249423Sdim
690249423Sdim/**
691341825Sdim * Retrieve a source location representing the first character within a
692203955Srdivacky * source range.
693198092Srdivacky */
694202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
695198092Srdivacky
696202879Srdivacky/**
697341825Sdim * Retrieve a source location representing the last character within a
698203955Srdivacky * source range.
699202879Srdivacky */
700202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
701202379Srdivacky
702202879Srdivacky/**
703341825Sdim * Identifies an array of ranges.
704276479Sdim */
705276479Sdimtypedef struct {
706341825Sdim  /** The number of ranges in the \c ranges array. */
707276479Sdim  unsigned count;
708276479Sdim  /**
709341825Sdim   * An array of \c CXSourceRanges.
710276479Sdim   */
711276479Sdim  CXSourceRange *ranges;
712276479Sdim} CXSourceRangeList;
713276479Sdim
714276479Sdim/**
715341825Sdim * Retrieve all ranges that were skipped by the preprocessor.
716276479Sdim *
717276479Sdim * The preprocessor will skip lines when they are surrounded by an
718276479Sdim * if/ifdef/ifndef directive whose condition does not evaluate to true.
719276479Sdim */
720276479SdimCINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
721276479Sdim                                                         CXFile file);
722276479Sdim
723276479Sdim/**
724341825Sdim * Retrieve all ranges from all files that were skipped by the
725314564Sdim * preprocessor.
726314564Sdim *
727314564Sdim * The preprocessor will skip lines when they are surrounded by an
728314564Sdim * if/ifdef/ifndef directive whose condition does not evaluate to true.
729314564Sdim */
730314564SdimCINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
731314564Sdim
732314564Sdim/**
733341825Sdim * Destroy the given \c CXSourceRangeList.
734276479Sdim */
735276479SdimCINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges);
736276479Sdim
737276479Sdim/**
738202879Srdivacky * @}
739202879Srdivacky */
740202379Srdivacky
741202879Srdivacky/**
742203955Srdivacky * \defgroup CINDEX_DIAG Diagnostic reporting
743203955Srdivacky *
744203955Srdivacky * @{
745203955Srdivacky */
746203955Srdivacky
747203955Srdivacky/**
748341825Sdim * Describes the severity of a particular diagnostic.
749203955Srdivacky */
750203955Srdivackyenum CXDiagnosticSeverity {
751203955Srdivacky  /**
752341825Sdim   * A diagnostic that has been suppressed, e.g., by a command-line
753203955Srdivacky   * option.
754203955Srdivacky   */
755203955Srdivacky  CXDiagnostic_Ignored = 0,
756205219Srdivacky
757203955Srdivacky  /**
758341825Sdim   * This diagnostic is a note that should be attached to the
759203955Srdivacky   * previous (non-note) diagnostic.
760203955Srdivacky   */
761203955Srdivacky  CXDiagnostic_Note    = 1,
762203955Srdivacky
763203955Srdivacky  /**
764341825Sdim   * This diagnostic indicates suspicious code that may not be
765203955Srdivacky   * wrong.
766203955Srdivacky   */
767203955Srdivacky  CXDiagnostic_Warning = 2,
768203955Srdivacky
769203955Srdivacky  /**
770341825Sdim   * This diagnostic indicates that the code is ill-formed.
771203955Srdivacky   */
772203955Srdivacky  CXDiagnostic_Error   = 3,
773203955Srdivacky
774203955Srdivacky  /**
775341825Sdim   * This diagnostic indicates that the code is ill-formed such
776203955Srdivacky   * that future parser recovery is unlikely to produce useful
777203955Srdivacky   * results.
778203955Srdivacky   */
779203955Srdivacky  CXDiagnostic_Fatal   = 4
780203955Srdivacky};
781203955Srdivacky
782203955Srdivacky/**
783341825Sdim * A single diagnostic, containing the diagnostic's severity,
784204643Srdivacky * location, text, source ranges, and fix-it hints.
785203955Srdivacky */
786204643Srdivackytypedef void *CXDiagnostic;
787204643Srdivacky
788204643Srdivacky/**
789341825Sdim * A group of CXDiagnostics.
790234353Sdim */
791234353Sdimtypedef void *CXDiagnosticSet;
792341825Sdim
793234353Sdim/**
794341825Sdim * Determine the number of diagnostics in a CXDiagnosticSet.
795234353Sdim */
796234353SdimCINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags);
797234353Sdim
798234353Sdim/**
799341825Sdim * Retrieve a diagnostic associated with the given CXDiagnosticSet.
800234353Sdim *
801239462Sdim * \param Diags the CXDiagnosticSet to query.
802234353Sdim * \param Index the zero-based diagnostic number to retrieve.
803234353Sdim *
804234353Sdim * \returns the requested diagnostic. This diagnostic must be freed
805234353Sdim * via a call to \c clang_disposeDiagnostic().
806234353Sdim */
807234353SdimCINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,
808341825Sdim                                                     unsigned Index);
809234353Sdim
810234353Sdim/**
811341825Sdim * Describes the kind of error that occurred (if any) in a call to
812234353Sdim * \c clang_loadDiagnostics.
813234353Sdim */
814234353Sdimenum CXLoadDiag_Error {
815234353Sdim  /**
816341825Sdim   * Indicates that no error occurred.
817234353Sdim   */
818234353Sdim  CXLoadDiag_None = 0,
819341825Sdim
820234353Sdim  /**
821341825Sdim   * Indicates that an unknown error occurred while attempting to
822234353Sdim   * deserialize diagnostics.
823234353Sdim   */
824234353Sdim  CXLoadDiag_Unknown = 1,
825341825Sdim
826234353Sdim  /**
827341825Sdim   * Indicates that the file containing the serialized diagnostics
828234353Sdim   * could not be opened.
829234353Sdim   */
830234353Sdim  CXLoadDiag_CannotLoad = 2,
831341825Sdim
832234353Sdim  /**
833341825Sdim   * Indicates that the serialized diagnostics file is invalid or
834239462Sdim   * corrupt.
835234353Sdim   */
836234353Sdim  CXLoadDiag_InvalidFile = 3
837234353Sdim};
838341825Sdim
839234353Sdim/**
840341825Sdim * Deserialize a set of diagnostics from a Clang diagnostics bitcode
841239462Sdim * file.
842234353Sdim *
843239462Sdim * \param file The name of the file to deserialize.
844239462Sdim * \param error A pointer to a enum value recording if there was a problem
845234353Sdim *        deserializing the diagnostics.
846239462Sdim * \param errorString A pointer to a CXString for recording the error string
847234353Sdim *        if the file was not successfully loaded.
848234353Sdim *
849234353Sdim * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise.  These
850239462Sdim * diagnostics should be released using clang_disposeDiagnosticSet().
851234353Sdim */
852234353SdimCINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
853234353Sdim                                                  enum CXLoadDiag_Error *error,
854234353Sdim                                                  CXString *errorString);
855234353Sdim
856234353Sdim/**
857341825Sdim * Release a CXDiagnosticSet and all of its contained diagnostics.
858234353Sdim */
859234353SdimCINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags);
860234353Sdim
861234353Sdim/**
862341825Sdim * Retrieve the child diagnostics of a CXDiagnostic.
863239462Sdim *
864239462Sdim * This CXDiagnosticSet does not need to be released by
865261991Sdim * clang_disposeDiagnosticSet.
866234353Sdim */
867234353SdimCINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
868234353Sdim
869234353Sdim/**
870341825Sdim * Determine the number of diagnostics produced for the given
871204643Srdivacky * translation unit.
872204643Srdivacky */
873204643SrdivackyCINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
874204643Srdivacky
875204643Srdivacky/**
876341825Sdim * Retrieve a diagnostic associated with the given translation unit.
877204643Srdivacky *
878204643Srdivacky * \param Unit the translation unit to query.
879204643Srdivacky * \param Index the zero-based diagnostic number to retrieve.
880204643Srdivacky *
881204643Srdivacky * \returns the requested diagnostic. This diagnostic must be freed
882204643Srdivacky * via a call to \c clang_disposeDiagnostic().
883204643Srdivacky */
884204643SrdivackyCINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
885204643Srdivacky                                                unsigned Index);
886204643Srdivacky
887204643Srdivacky/**
888341825Sdim * Retrieve the complete set of diagnostics associated with a
889234353Sdim *        translation unit.
890234353Sdim *
891234353Sdim * \param Unit the translation unit to query.
892234353Sdim */
893234353SdimCINDEX_LINKAGE CXDiagnosticSet
894341825Sdim  clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
895234353Sdim
896234353Sdim/**
897341825Sdim * Destroy a diagnostic.
898204643Srdivacky */
899204643SrdivackyCINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
900204643Srdivacky
901204643Srdivacky/**
902341825Sdim * Options to control the display of diagnostics.
903204643Srdivacky *
904204643Srdivacky * The values in this enum are meant to be combined to customize the
905261991Sdim * behavior of \c clang_formatDiagnostic().
906204643Srdivacky */
907204643Srdivackyenum CXDiagnosticDisplayOptions {
908203955Srdivacky  /**
909341825Sdim   * Display the source-location information where the
910204643Srdivacky   * diagnostic was located.
911204643Srdivacky   *
912204643Srdivacky   * When set, diagnostics will be prefixed by the file, line, and
913204643Srdivacky   * (optionally) column to which the diagnostic refers. For example,
914204643Srdivacky   *
915204643Srdivacky   * \code
916204643Srdivacky   * test.c:28: warning: extra tokens at end of #endif directive
917204643Srdivacky   * \endcode
918204643Srdivacky   *
919204643Srdivacky   * This option corresponds to the clang flag \c -fshow-source-location.
920203955Srdivacky   */
921204643Srdivacky  CXDiagnostic_DisplaySourceLocation = 0x01,
922203955Srdivacky
923203955Srdivacky  /**
924341825Sdim   * If displaying the source-location information of the
925204643Srdivacky   * diagnostic, also include the column number.
926204643Srdivacky   *
927204643Srdivacky   * This option corresponds to the clang flag \c -fshow-column.
928203955Srdivacky   */
929204643Srdivacky  CXDiagnostic_DisplayColumn = 0x02,
930203955Srdivacky
931203955Srdivacky  /**
932341825Sdim   * If displaying the source-location information of the
933204643Srdivacky   * diagnostic, also include information about source ranges in a
934204643Srdivacky   * machine-parsable format.
935204643Srdivacky   *
936205219Srdivacky   * This option corresponds to the clang flag
937204643Srdivacky   * \c -fdiagnostics-print-source-range-info.
938203955Srdivacky   */
939218893Sdim  CXDiagnostic_DisplaySourceRanges = 0x04,
940341825Sdim
941218893Sdim  /**
942341825Sdim   * Display the option name associated with this diagnostic, if any.
943218893Sdim   *
944218893Sdim   * The option name displayed (e.g., -Wconversion) will be placed in brackets
945218893Sdim   * after the diagnostic text. This option corresponds to the clang flag
946218893Sdim   * \c -fdiagnostics-show-option.
947218893Sdim   */
948218893Sdim  CXDiagnostic_DisplayOption = 0x08,
949341825Sdim
950218893Sdim  /**
951341825Sdim   * Display the category number associated with this diagnostic, if any.
952218893Sdim   *
953218893Sdim   * The category number is displayed within brackets after the diagnostic text.
954341825Sdim   * This option corresponds to the clang flag
955218893Sdim   * \c -fdiagnostics-show-category=id.
956218893Sdim   */
957218893Sdim  CXDiagnostic_DisplayCategoryId = 0x10,
958218893Sdim
959218893Sdim  /**
960341825Sdim   * Display the category name associated with this diagnostic, if any.
961218893Sdim   *
962218893Sdim   * The category name is displayed within brackets after the diagnostic text.
963341825Sdim   * This option corresponds to the clang flag
964218893Sdim   * \c -fdiagnostics-show-category=name.
965218893Sdim   */
966218893Sdim  CXDiagnostic_DisplayCategoryName = 0x20
967203955Srdivacky};
968203955Srdivacky
969203955Srdivacky/**
970341825Sdim * Format the given diagnostic in a manner that is suitable for display.
971204643Srdivacky *
972204643Srdivacky * This routine will format the given diagnostic to a string, rendering
973205219Srdivacky * the diagnostic according to the various options given. The
974205219Srdivacky * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
975204643Srdivacky * options that most closely mimics the behavior of the clang compiler.
976204643Srdivacky *
977204643Srdivacky * \param Diagnostic The diagnostic to print.
978204643Srdivacky *
979205219Srdivacky * \param Options A set of options that control the diagnostic display,
980204643Srdivacky * created by combining \c CXDiagnosticDisplayOptions values.
981204643Srdivacky *
982204643Srdivacky * \returns A new string containing for formatted diagnostic.
983203955Srdivacky */
984204643SrdivackyCINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
985204643Srdivacky                                               unsigned Options);
986203955Srdivacky
987203955Srdivacky/**
988341825Sdim * Retrieve the set of display options most similar to the
989204643Srdivacky * default behavior of the clang compiler.
990203955Srdivacky *
991204643Srdivacky * \returns A set of display options suitable for use with \c
992261991Sdim * clang_formatDiagnostic().
993203955Srdivacky */
994204643SrdivackyCINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
995203955Srdivacky
996203955Srdivacky/**
997341825Sdim * Determine the severity of the given diagnostic.
998203955Srdivacky */
999205219SrdivackyCINDEX_LINKAGE enum CXDiagnosticSeverity
1000203955Srdivackyclang_getDiagnosticSeverity(CXDiagnostic);
1001203955Srdivacky
1002203955Srdivacky/**
1003341825Sdim * Retrieve the source location of the given diagnostic.
1004203955Srdivacky *
1005203955Srdivacky * This location is where Clang would print the caret ('^') when
1006203955Srdivacky * displaying the diagnostic on the command line.
1007203955Srdivacky */
1008203955SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
1009203955Srdivacky
1010203955Srdivacky/**
1011341825Sdim * Retrieve the text of the given diagnostic.
1012203955Srdivacky */
1013203955SrdivackyCINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
1014203955Srdivacky
1015203955Srdivacky/**
1016341825Sdim * Retrieve the name of the command-line option that enabled this
1017218893Sdim * diagnostic.
1018218893Sdim *
1019218893Sdim * \param Diag The diagnostic to be queried.
1020218893Sdim *
1021218893Sdim * \param Disable If non-NULL, will be set to the option that disables this
1022218893Sdim * diagnostic (if any).
1023218893Sdim *
1024218893Sdim * \returns A string that contains the command-line option used to enable this
1025341825Sdim * warning, such as "-Wconversion" or "-pedantic".
1026218893Sdim */
1027218893SdimCINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag,
1028218893Sdim                                                  CXString *Disable);
1029218893Sdim
1030218893Sdim/**
1031341825Sdim * Retrieve the category number for this diagnostic.
1032218893Sdim *
1033218893Sdim * Diagnostics can be categorized into groups along with other, related
1034341825Sdim * diagnostics (e.g., diagnostics under the same warning flag). This routine
1035218893Sdim * retrieves the category number for the given diagnostic.
1036218893Sdim *
1037218893Sdim * \returns The number of the category that contains this diagnostic, or zero
1038218893Sdim * if this diagnostic is uncategorized.
1039218893Sdim */
1040218893SdimCINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
1041218893Sdim
1042218893Sdim/**
1043341825Sdim * Retrieve the name of a particular diagnostic category.  This
1044234353Sdim *  is now deprecated.  Use clang_getDiagnosticCategoryText()
1045234353Sdim *  instead.
1046218893Sdim *
1047341825Sdim * \param Category A diagnostic category number, as returned by
1048218893Sdim * \c clang_getDiagnosticCategory().
1049218893Sdim *
1050218893Sdim * \returns The name of the given diagnostic category.
1051218893Sdim */
1052234353SdimCINDEX_DEPRECATED CINDEX_LINKAGE
1053234353SdimCXString clang_getDiagnosticCategoryName(unsigned Category);
1054234353Sdim
1055234353Sdim/**
1056341825Sdim * Retrieve the diagnostic category text for a given diagnostic.
1057234353Sdim *
1058234353Sdim * \returns The text of the given diagnostic category.
1059234353Sdim */
1060234353SdimCINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic);
1061341825Sdim
1062218893Sdim/**
1063341825Sdim * Determine the number of source ranges associated with the given
1064203955Srdivacky * diagnostic.
1065203955Srdivacky */
1066203955SrdivackyCINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
1067205219Srdivacky
1068203955Srdivacky/**
1069341825Sdim * Retrieve a source range associated with the diagnostic.
1070203955Srdivacky *
1071203955Srdivacky * A diagnostic's source ranges highlight important elements in the source
1072203955Srdivacky * code. On the command line, Clang displays source ranges by
1073205219Srdivacky * underlining them with '~' characters.
1074203955Srdivacky *
1075203955Srdivacky * \param Diagnostic the diagnostic whose range is being extracted.
1076203955Srdivacky *
1077205219Srdivacky * \param Range the zero-based index specifying which range to
1078203955Srdivacky *
1079203955Srdivacky * \returns the requested source range.
1080203955Srdivacky */
1081205219SrdivackyCINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
1082203955Srdivacky                                                      unsigned Range);
1083203955Srdivacky
1084203955Srdivacky/**
1085341825Sdim * Determine the number of fix-it hints associated with the
1086203955Srdivacky * given diagnostic.
1087203955Srdivacky */
1088203955SrdivackyCINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
1089203955Srdivacky
1090203955Srdivacky/**
1091341825Sdim * Retrieve the replacement information for a given fix-it.
1092203955Srdivacky *
1093204643Srdivacky * Fix-its are described in terms of a source range whose contents
1094204643Srdivacky * should be replaced by a string. This approach generalizes over
1095204643Srdivacky * three kinds of operations: removal of source code (the range covers
1096204643Srdivacky * the code to be removed and the replacement string is empty),
1097204643Srdivacky * replacement of source code (the range covers the code to be
1098204643Srdivacky * replaced and the replacement string provides the new code), and
1099204643Srdivacky * insertion (both the start and end of the range point at the
1100204643Srdivacky * insertion location, and the replacement string provides the text to
1101204643Srdivacky * insert).
1102203955Srdivacky *
1103204643Srdivacky * \param Diagnostic The diagnostic whose fix-its are being queried.
1104203955Srdivacky *
1105204643Srdivacky * \param FixIt The zero-based index of the fix-it.
1106203955Srdivacky *
1107204643Srdivacky * \param ReplacementRange The source range whose contents will be
1108204643Srdivacky * replaced with the returned replacement string. Note that source
1109204643Srdivacky * ranges are half-open ranges [a, b), so the source code should be
1110204643Srdivacky * replaced from a and up to (but not including) b.
1111203955Srdivacky *
1112204643Srdivacky * \returns A string containing text that should be replace the source
1113204643Srdivacky * code indicated by the \c ReplacementRange.
1114203955Srdivacky */
1115205219SrdivackyCINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
1116204643Srdivacky                                                 unsigned FixIt,
1117204643Srdivacky                                               CXSourceRange *ReplacementRange);
1118203955Srdivacky
1119203955Srdivacky/**
1120203955Srdivacky * @}
1121203955Srdivacky */
1122203955Srdivacky
1123203955Srdivacky/**
1124203955Srdivacky * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
1125203955Srdivacky *
1126203955Srdivacky * The routines in this group provide the ability to create and destroy
1127203955Srdivacky * translation units from files, either by parsing the contents of the files or
1128203955Srdivacky * by reading in a serialized representation of a translation unit.
1129203955Srdivacky *
1130203955Srdivacky * @{
1131203955Srdivacky */
1132205219Srdivacky
1133203955Srdivacky/**
1134341825Sdim * Get the original translation unit source file name.
1135203955Srdivacky */
1136203955SrdivackyCINDEX_LINKAGE CXString
1137203955Srdivackyclang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
1138203955Srdivacky
1139203955Srdivacky/**
1140341825Sdim * Return the CXTranslationUnit for a given source file and the provided
1141203955Srdivacky * command line arguments one would pass to the compiler.
1142203955Srdivacky *
1143203955Srdivacky * Note: The 'source_filename' argument is optional.  If the caller provides a
1144203955Srdivacky * NULL pointer, the name of the source file is expected to reside in the
1145203955Srdivacky * specified command line arguments.
1146203955Srdivacky *
1147203955Srdivacky * Note: When encountered in 'clang_command_line_args', the following options
1148203955Srdivacky * are ignored:
1149203955Srdivacky *
1150203955Srdivacky *   '-c'
1151203955Srdivacky *   '-emit-ast'
1152203955Srdivacky *   '-fsyntax-only'
1153239462Sdim *   '-o \<output file>'  (both '-o' and '\<output file>' are ignored)
1154203955Srdivacky *
1155218893Sdim * \param CIdx The index object with which the translation unit will be
1156218893Sdim * associated.
1157203955Srdivacky *
1158239462Sdim * \param source_filename The name of the source file to load, or NULL if the
1159218893Sdim * source file is included in \p clang_command_line_args.
1160203955Srdivacky *
1161218893Sdim * \param num_clang_command_line_args The number of command-line arguments in
1162218893Sdim * \p clang_command_line_args.
1163218893Sdim *
1164218893Sdim * \param clang_command_line_args The command-line arguments that would be
1165218893Sdim * passed to the \c clang executable if it were being invoked out-of-process.
1166218893Sdim * These command-line options will be parsed and will affect how the translation
1167218893Sdim * unit is parsed. Note that the following options are ignored: '-c',
1168239462Sdim * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1169218893Sdim *
1170203955Srdivacky * \param num_unsaved_files the number of unsaved file entries in \p
1171203955Srdivacky * unsaved_files.
1172203955Srdivacky *
1173203955Srdivacky * \param unsaved_files the files that have not yet been saved to disk
1174203955Srdivacky * but may be required for code completion, including the contents of
1175207619Srdivacky * those files.  The contents and name of these files (as specified by
1176207619Srdivacky * CXUnsavedFile) are copied when necessary, so the client only needs to
1177207619Srdivacky * guarantee their validity until the call to this function returns.
1178203955Srdivacky */
1179203955SrdivackyCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
1180203955Srdivacky                                         CXIndex CIdx,
1181203955Srdivacky                                         const char *source_filename,
1182203955Srdivacky                                         int num_clang_command_line_args,
1183212904Sdim                                   const char * const *clang_command_line_args,
1184203955Srdivacky                                         unsigned num_unsaved_files,
1185204643Srdivacky                                         struct CXUnsavedFile *unsaved_files);
1186205219Srdivacky
1187203955Srdivacky/**
1188341825Sdim * Same as \c clang_createTranslationUnit2, but returns
1189276479Sdim * the \c CXTranslationUnit instead of an error code.  In case of an error this
1190276479Sdim * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1191276479Sdim * error codes.
1192203955Srdivacky */
1193276479SdimCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
1194276479Sdim    CXIndex CIdx,
1195276479Sdim    const char *ast_filename);
1196203955Srdivacky
1197203955Srdivacky/**
1198341825Sdim * Create a translation unit from an AST file (\c -emit-ast).
1199276479Sdim *
1200276479Sdim * \param[out] out_TU A non-NULL pointer to store the created
1201276479Sdim * \c CXTranslationUnit.
1202276479Sdim *
1203276479Sdim * \returns Zero on success, otherwise returns an error code.
1204276479Sdim */
1205276479SdimCINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
1206276479Sdim    CXIndex CIdx,
1207276479Sdim    const char *ast_filename,
1208276479Sdim    CXTranslationUnit *out_TU);
1209276479Sdim
1210276479Sdim/**
1211341825Sdim * Flags that control the creation of translation units.
1212212904Sdim *
1213212904Sdim * The enumerators in this enumeration type are meant to be bitwise
1214212904Sdim * ORed together to specify which options should be used when
1215212904Sdim * constructing the translation unit.
1216212904Sdim */
1217212904Sdimenum CXTranslationUnit_Flags {
1218212904Sdim  /**
1219341825Sdim   * Used to indicate that no special translation-unit options are
1220212904Sdim   * needed.
1221212904Sdim   */
1222212904Sdim  CXTranslationUnit_None = 0x0,
1223212904Sdim
1224212904Sdim  /**
1225341825Sdim   * Used to indicate that the parser should construct a "detailed"
1226212904Sdim   * preprocessing record, including all macro definitions and instantiations.
1227212904Sdim   *
1228212904Sdim   * Constructing a detailed preprocessing record requires more memory
1229212904Sdim   * and time to parse, since the information contained in the record
1230212904Sdim   * is usually not retained. However, it can be useful for
1231212904Sdim   * applications that require more detailed information about the
1232212904Sdim   * behavior of the preprocessor.
1233212904Sdim   */
1234212904Sdim  CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
1235212904Sdim
1236212904Sdim  /**
1237341825Sdim   * Used to indicate that the translation unit is incomplete.
1238212904Sdim   *
1239212904Sdim   * When a translation unit is considered "incomplete", semantic
1240212904Sdim   * analysis that is typically performed at the end of the
1241212904Sdim   * translation unit will be suppressed. For example, this suppresses
1242212904Sdim   * the completion of tentative declarations in C and of
1243212904Sdim   * instantiation of implicitly-instantiation function templates in
1244212904Sdim   * C++. This option is typically used when parsing a header with the
1245212904Sdim   * intent of producing a precompiled header.
1246212904Sdim   */
1247212904Sdim  CXTranslationUnit_Incomplete = 0x02,
1248341825Sdim
1249212904Sdim  /**
1250341825Sdim   * Used to indicate that the translation unit should be built with an
1251212904Sdim   * implicit precompiled header for the preamble.
1252212904Sdim   *
1253212904Sdim   * An implicit precompiled header is used as an optimization when a
1254212904Sdim   * particular translation unit is likely to be reparsed many times
1255212904Sdim   * when the sources aren't changing that often. In this case, an
1256212904Sdim   * implicit precompiled header will be built containing all of the
1257212904Sdim   * initial includes at the top of the main file (what we refer to as
1258212904Sdim   * the "preamble" of the file). In subsequent parses, if the
1259212904Sdim   * preamble or the files in it have not changed, \c
1260212904Sdim   * clang_reparseTranslationUnit() will re-use the implicit
1261212904Sdim   * precompiled header to improve parsing performance.
1262212904Sdim   */
1263212904Sdim  CXTranslationUnit_PrecompiledPreamble = 0x04,
1264341825Sdim
1265212904Sdim  /**
1266341825Sdim   * Used to indicate that the translation unit should cache some
1267212904Sdim   * code-completion results with each reparse of the source file.
1268212904Sdim   *
1269212904Sdim   * Caching of code-completion results is a performance optimization that
1270212904Sdim   * introduces some overhead to reparsing but improves the performance of
1271212904Sdim   * code-completion operations.
1272212904Sdim   */
1273218893Sdim  CXTranslationUnit_CacheCompletionResults = 0x08,
1274243830Sdim
1275218893Sdim  /**
1276341825Sdim   * Used to indicate that the translation unit will be serialized with
1277243830Sdim   * \c clang_saveTranslationUnit.
1278218893Sdim   *
1279243830Sdim   * This option is typically used when parsing a header with the intent of
1280243830Sdim   * producing a precompiled header.
1281218893Sdim   */
1282243830Sdim  CXTranslationUnit_ForSerialization = 0x10,
1283218893Sdim
1284218893Sdim  /**
1285341825Sdim   * DEPRECATED: Enabled chained precompiled preambles in C++.
1286218893Sdim   *
1287218893Sdim   * Note: this is a *temporary* option that is available only while
1288226633Sdim   * we are testing C++ precompiled preamble support. It is deprecated.
1289218893Sdim   */
1290223017Sdim  CXTranslationUnit_CXXChainedPCH = 0x20,
1291224145Sdim
1292224145Sdim  /**
1293341825Sdim   * Used to indicate that function/method bodies should be skipped while
1294234353Sdim   * parsing.
1295224145Sdim   *
1296234353Sdim   * This option can be used to search for declarations/definitions while
1297234353Sdim   * ignoring the usages.
1298224145Sdim   */
1299239462Sdim  CXTranslationUnit_SkipFunctionBodies = 0x40,
1300239462Sdim
1301239462Sdim  /**
1302341825Sdim   * Used to indicate that brief documentation comments should be
1303239462Sdim   * included into the set of code completions returned from this translation
1304239462Sdim   * unit.
1305239462Sdim   */
1306296417Sdim  CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80,
1307296417Sdim
1308296417Sdim  /**
1309341825Sdim   * Used to indicate that the precompiled preamble should be created on
1310296417Sdim   * the first parse. Otherwise it will be created on the first reparse. This
1311296417Sdim   * trades runtime on the first parse (serializing the preamble takes time) for
1312296417Sdim   * reduced runtime on the second parse (can now reuse the preamble).
1313296417Sdim   */
1314309124Sdim  CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
1315309124Sdim
1316309124Sdim  /**
1317341825Sdim   * Do not stop processing when fatal errors are encountered.
1318309124Sdim   *
1319309124Sdim   * When fatal errors are encountered while parsing a translation unit,
1320309124Sdim   * semantic analysis is typically stopped early when compiling code. A common
1321309124Sdim   * source for fatal errors are unresolvable include files. For the
1322309124Sdim   * purposes of an IDE, this is undesirable behavior and as much information
1323309124Sdim   * as possible should be reported. Use this flag to enable this behavior.
1324309124Sdim   */
1325321369Sdim  CXTranslationUnit_KeepGoing = 0x200,
1326321369Sdim
1327321369Sdim  /**
1328341825Sdim   * Sets the preprocessor in a mode for parsing a single file only.
1329321369Sdim   */
1330341825Sdim  CXTranslationUnit_SingleFileParse = 0x400,
1331341825Sdim
1332341825Sdim  /**
1333341825Sdim   * Used in combination with CXTranslationUnit_SkipFunctionBodies to
1334341825Sdim   * constrain the skipping of function bodies to the preamble.
1335341825Sdim   *
1336341825Sdim   * The function bodies of the main file are not skipped.
1337341825Sdim   */
1338344779Sdim  CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800,
1339344779Sdim
1340344779Sdim  /**
1341344779Sdim   * Used to indicate that attributed types should be included in CXType.
1342344779Sdim   */
1343344779Sdim  CXTranslationUnit_IncludeAttributedTypes = 0x1000,
1344344779Sdim
1345344779Sdim  /**
1346344779Sdim   * Used to indicate that implicit attributes should be visited.
1347344779Sdim   */
1348353358Sdim  CXTranslationUnit_VisitImplicitAttributes = 0x2000,
1349353358Sdim
1350353358Sdim  /**
1351353358Sdim   * Used to indicate that non-errors from included files should be ignored.
1352353358Sdim   *
1353353358Sdim   * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
1354353358Sdim   * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
1355353358Sdim   * the case where these warnings are not of interest, as for an IDE for
1356353358Sdim   * example, which typically shows only the diagnostics in the main file.
1357353358Sdim   */
1358360784Sdim  CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000,
1359360784Sdim
1360360784Sdim  /**
1361360784Sdim   * Tells the preprocessor not to skip excluded conditional blocks.
1362360784Sdim   */
1363360784Sdim  CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000
1364212904Sdim};
1365212904Sdim
1366212904Sdim/**
1367341825Sdim * Returns the set of flags that is suitable for parsing a translation
1368212904Sdim * unit that is being edited.
1369212904Sdim *
1370212904Sdim * The set of flags returned provide options for \c clang_parseTranslationUnit()
1371212904Sdim * to indicate that the translation unit is likely to be reparsed many times,
1372212904Sdim * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
1373212904Sdim * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
1374341825Sdim * set contains an unspecified set of optimizations (e.g., the precompiled
1375212904Sdim * preamble) geared toward improving the performance of these routines. The
1376212904Sdim * set of optimizations enabled may change from one version to the next.
1377212904Sdim */
1378212904SdimCINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
1379276479Sdim
1380212904Sdim/**
1381341825Sdim * Same as \c clang_parseTranslationUnit2, but returns
1382276479Sdim * the \c CXTranslationUnit instead of an error code.  In case of an error this
1383276479Sdim * routine returns a \c NULL \c CXTranslationUnit, without further detailed
1384276479Sdim * error codes.
1385276479Sdim */
1386276479SdimCINDEX_LINKAGE CXTranslationUnit
1387276479Sdimclang_parseTranslationUnit(CXIndex CIdx,
1388276479Sdim                           const char *source_filename,
1389276479Sdim                           const char *const *command_line_args,
1390276479Sdim                           int num_command_line_args,
1391276479Sdim                           struct CXUnsavedFile *unsaved_files,
1392276479Sdim                           unsigned num_unsaved_files,
1393276479Sdim                           unsigned options);
1394276479Sdim
1395276479Sdim/**
1396341825Sdim * Parse the given source file and the translation unit corresponding
1397212904Sdim * to that file.
1398212904Sdim *
1399212904Sdim * This routine is the main entry point for the Clang C API, providing the
1400212904Sdim * ability to parse a source file into a translation unit that can then be
1401212904Sdim * queried by other functions in the API. This routine accepts a set of
1402212904Sdim * command-line arguments so that the compilation can be configured in the same
1403212904Sdim * way that the compiler is configured on the command line.
1404212904Sdim *
1405341825Sdim * \param CIdx The index object with which the translation unit will be
1406212904Sdim * associated.
1407212904Sdim *
1408212904Sdim * \param source_filename The name of the source file to load, or NULL if the
1409276479Sdim * source file is included in \c command_line_args.
1410212904Sdim *
1411212904Sdim * \param command_line_args The command-line arguments that would be
1412212904Sdim * passed to the \c clang executable if it were being invoked out-of-process.
1413212904Sdim * These command-line options will be parsed and will affect how the translation
1414341825Sdim * unit is parsed. Note that the following options are ignored: '-c',
1415239462Sdim * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'.
1416212904Sdim *
1417212904Sdim * \param num_command_line_args The number of command-line arguments in
1418276479Sdim * \c command_line_args.
1419212904Sdim *
1420212904Sdim * \param unsaved_files the files that have not yet been saved to disk
1421212904Sdim * but may be required for parsing, including the contents of
1422212904Sdim * those files.  The contents and name of these files (as specified by
1423212904Sdim * CXUnsavedFile) are copied when necessary, so the client only needs to
1424212904Sdim * guarantee their validity until the call to this function returns.
1425212904Sdim *
1426212904Sdim * \param num_unsaved_files the number of unsaved file entries in \p
1427212904Sdim * unsaved_files.
1428212904Sdim *
1429212904Sdim * \param options A bitmask of options that affects how the translation unit
1430212904Sdim * is managed but not its compilation. This should be a bitwise OR of the
1431212904Sdim * CXTranslationUnit_XXX flags.
1432212904Sdim *
1433276479Sdim * \param[out] out_TU A non-NULL pointer to store the created
1434276479Sdim * \c CXTranslationUnit, describing the parsed code and containing any
1435276479Sdim * diagnostics produced by the compiler.
1436276479Sdim *
1437276479Sdim * \returns Zero on success, otherwise returns an error code.
1438212904Sdim */
1439276479SdimCINDEX_LINKAGE enum CXErrorCode
1440276479Sdimclang_parseTranslationUnit2(CXIndex CIdx,
1441276479Sdim                            const char *source_filename,
1442276479Sdim                            const char *const *command_line_args,
1443276479Sdim                            int num_command_line_args,
1444276479Sdim                            struct CXUnsavedFile *unsaved_files,
1445276479Sdim                            unsigned num_unsaved_files,
1446276479Sdim                            unsigned options,
1447276479Sdim                            CXTranslationUnit *out_TU);
1448276479Sdim
1449212904Sdim/**
1450341825Sdim * Same as clang_parseTranslationUnit2 but requires a full command line
1451296417Sdim * for \c command_line_args including argv[0]. This is useful if the standard
1452296417Sdim * library paths are relative to the binary.
1453296417Sdim */
1454296417SdimCINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv(
1455296417Sdim    CXIndex CIdx, const char *source_filename,
1456296417Sdim    const char *const *command_line_args, int num_command_line_args,
1457296417Sdim    struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
1458296417Sdim    unsigned options, CXTranslationUnit *out_TU);
1459296417Sdim
1460296417Sdim/**
1461341825Sdim * Flags that control how translation units are saved.
1462212904Sdim *
1463212904Sdim * The enumerators in this enumeration type are meant to be bitwise
1464212904Sdim * ORed together to specify which options should be used when
1465212904Sdim * saving the translation unit.
1466212904Sdim */
1467212904Sdimenum CXSaveTranslationUnit_Flags {
1468212904Sdim  /**
1469341825Sdim   * Used to indicate that no special saving options are needed.
1470212904Sdim   */
1471212904Sdim  CXSaveTranslationUnit_None = 0x0
1472212904Sdim};
1473212904Sdim
1474212904Sdim/**
1475341825Sdim * Returns the set of flags that is suitable for saving a translation
1476212904Sdim * unit.
1477212904Sdim *
1478212904Sdim * The set of flags returned provide options for
1479212904Sdim * \c clang_saveTranslationUnit() by default. The returned flag
1480212904Sdim * set contains an unspecified set of options that save translation units with
1481212904Sdim * the most commonly-requested data.
1482212904Sdim */
1483212904SdimCINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
1484212904Sdim
1485212904Sdim/**
1486341825Sdim * Describes the kind of error that occurred (if any) in a call to
1487224145Sdim * \c clang_saveTranslationUnit().
1488224145Sdim */
1489224145Sdimenum CXSaveError {
1490224145Sdim  /**
1491341825Sdim   * Indicates that no error occurred while saving a translation unit.
1492224145Sdim   */
1493224145Sdim  CXSaveError_None = 0,
1494341825Sdim
1495224145Sdim  /**
1496341825Sdim   * Indicates that an unknown error occurred while attempting to save
1497224145Sdim   * the file.
1498224145Sdim   *
1499341825Sdim   * This error typically indicates that file I/O failed when attempting to
1500224145Sdim   * write the file.
1501224145Sdim   */
1502224145Sdim  CXSaveError_Unknown = 1,
1503341825Sdim
1504224145Sdim  /**
1505341825Sdim   * Indicates that errors during translation prevented this attempt
1506224145Sdim   * to save the translation unit.
1507341825Sdim   *
1508224145Sdim   * Errors that prevent the translation unit from being saved can be
1509224145Sdim   * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
1510224145Sdim   */
1511224145Sdim  CXSaveError_TranslationErrors = 2,
1512341825Sdim
1513224145Sdim  /**
1514341825Sdim   * Indicates that the translation unit to be saved was somehow
1515224145Sdim   * invalid (e.g., NULL).
1516224145Sdim   */
1517224145Sdim  CXSaveError_InvalidTU = 3
1518224145Sdim};
1519341825Sdim
1520224145Sdim/**
1521341825Sdim * Saves a translation unit into a serialized representation of
1522212904Sdim * that translation unit on disk.
1523212904Sdim *
1524212904Sdim * Any translation unit that was parsed without error can be saved
1525212904Sdim * into a file. The translation unit can then be deserialized into a
1526212904Sdim * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
1527212904Sdim * if it is an incomplete translation unit that corresponds to a
1528212904Sdim * header, used as a precompiled header when parsing other translation
1529212904Sdim * units.
1530212904Sdim *
1531212904Sdim * \param TU The translation unit to save.
1532212904Sdim *
1533212904Sdim * \param FileName The file to which the translation unit will be saved.
1534212904Sdim *
1535212904Sdim * \param options A bitmask of options that affects how the translation unit
1536212904Sdim * is saved. This should be a bitwise OR of the
1537212904Sdim * CXSaveTranslationUnit_XXX flags.
1538212904Sdim *
1539224145Sdim * \returns A value that will match one of the enumerators of the CXSaveError
1540341825Sdim * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
1541224145Sdim * saved successfully, while a non-zero value indicates that a problem occurred.
1542212904Sdim */
1543212904SdimCINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
1544212904Sdim                                             const char *FileName,
1545212904Sdim                                             unsigned options);
1546212904Sdim
1547212904Sdim/**
1548341825Sdim * Suspend a translation unit in order to free memory associated with it.
1549321369Sdim *
1550321369Sdim * A suspended translation unit uses significantly less memory but on the other
1551321369Sdim * side does not support any other calls than \c clang_reparseTranslationUnit
1552321369Sdim * to resume it or \c clang_disposeTranslationUnit to dispose it completely.
1553321369Sdim */
1554321369SdimCINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit);
1555321369Sdim
1556321369Sdim/**
1557341825Sdim * Destroy the specified CXTranslationUnit object.
1558203955Srdivacky */
1559203955SrdivackyCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
1560205219Srdivacky
1561203955Srdivacky/**
1562341825Sdim * Flags that control the reparsing of translation units.
1563212904Sdim *
1564212904Sdim * The enumerators in this enumeration type are meant to be bitwise
1565212904Sdim * ORed together to specify which options should be used when
1566212904Sdim * reparsing the translation unit.
1567212904Sdim */
1568212904Sdimenum CXReparse_Flags {
1569212904Sdim  /**
1570341825Sdim   * Used to indicate that no special reparsing options are needed.
1571212904Sdim   */
1572212904Sdim  CXReparse_None = 0x0
1573212904Sdim};
1574341825Sdim
1575212904Sdim/**
1576341825Sdim * Returns the set of flags that is suitable for reparsing a translation
1577212904Sdim * unit.
1578212904Sdim *
1579212904Sdim * The set of flags returned provide options for
1580212904Sdim * \c clang_reparseTranslationUnit() by default. The returned flag
1581212904Sdim * set contains an unspecified set of optimizations geared toward common uses
1582341825Sdim * of reparsing. The set of optimizations enabled may change from one version
1583212904Sdim * to the next.
1584212904Sdim */
1585212904SdimCINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
1586212904Sdim
1587212904Sdim/**
1588341825Sdim * Reparse the source files that produced this translation unit.
1589212904Sdim *
1590212904Sdim * This routine can be used to re-parse the source files that originally
1591212904Sdim * created the given translation unit, for example because those source files
1592212904Sdim * have changed (either on disk or as passed via \p unsaved_files). The
1593212904Sdim * source code will be reparsed with the same command-line options as it
1594341825Sdim * was originally parsed.
1595212904Sdim *
1596212904Sdim * Reparsing a translation unit invalidates all cursors and source locations
1597212904Sdim * that refer into that translation unit. This makes reparsing a translation
1598212904Sdim * unit semantically equivalent to destroying the translation unit and then
1599212904Sdim * creating a new translation unit with the same command-line arguments.
1600341825Sdim * However, it may be more efficient to reparse a translation
1601212904Sdim * unit using this routine.
1602212904Sdim *
1603212904Sdim * \param TU The translation unit whose contents will be re-parsed. The
1604341825Sdim * translation unit must originally have been built with
1605212904Sdim * \c clang_createTranslationUnitFromSourceFile().
1606212904Sdim *
1607212904Sdim * \param num_unsaved_files The number of unsaved file entries in \p
1608212904Sdim * unsaved_files.
1609212904Sdim *
1610212904Sdim * \param unsaved_files The files that have not yet been saved to disk
1611212904Sdim * but may be required for parsing, including the contents of
1612212904Sdim * those files.  The contents and name of these files (as specified by
1613212904Sdim * CXUnsavedFile) are copied when necessary, so the client only needs to
1614212904Sdim * guarantee their validity until the call to this function returns.
1615341825Sdim *
1616212904Sdim * \param options A bitset of options composed of the flags in CXReparse_Flags.
1617212904Sdim * The function \c clang_defaultReparseOptions() produces a default set of
1618212904Sdim * options recommended for most uses, based on the translation unit.
1619212904Sdim *
1620276479Sdim * \returns 0 if the sources could be reparsed.  A non-zero error code will be
1621212904Sdim * returned if reparsing was impossible, such that the translation unit is
1622276479Sdim * invalid. In such cases, the only valid call for \c TU is
1623276479Sdim * \c clang_disposeTranslationUnit(TU).  The error codes returned by this
1624276479Sdim * routine are described by the \c CXErrorCode enum.
1625212904Sdim */
1626212904SdimCINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
1627212904Sdim                                                unsigned num_unsaved_files,
1628212904Sdim                                          struct CXUnsavedFile *unsaved_files,
1629212904Sdim                                                unsigned options);
1630221345Sdim
1631212904Sdim/**
1632341825Sdim  * Categorizes how memory is being used by a translation unit.
1633221345Sdim  */
1634221345Sdimenum CXTUResourceUsageKind {
1635221345Sdim  CXTUResourceUsage_AST = 1,
1636221345Sdim  CXTUResourceUsage_Identifiers = 2,
1637221345Sdim  CXTUResourceUsage_Selectors = 3,
1638221345Sdim  CXTUResourceUsage_GlobalCompletionResults = 4,
1639221345Sdim  CXTUResourceUsage_SourceManagerContentCache = 5,
1640221345Sdim  CXTUResourceUsage_AST_SideTables = 6,
1641221345Sdim  CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7,
1642221345Sdim  CXTUResourceUsage_SourceManager_Membuffer_MMap = 8,
1643341825Sdim  CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9,
1644341825Sdim  CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10,
1645223017Sdim  CXTUResourceUsage_Preprocessor = 11,
1646223017Sdim  CXTUResourceUsage_PreprocessingRecord = 12,
1647226633Sdim  CXTUResourceUsage_SourceManager_DataStructures = 13,
1648226633Sdim  CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
1649221345Sdim  CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
1650221345Sdim  CXTUResourceUsage_MEMORY_IN_BYTES_END =
1651226633Sdim    CXTUResourceUsage_Preprocessor_HeaderSearch,
1652221345Sdim
1653221345Sdim  CXTUResourceUsage_First = CXTUResourceUsage_AST,
1654226633Sdim  CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
1655221345Sdim};
1656221345Sdim
1657221345Sdim/**
1658341825Sdim  * Returns the human-readable null-terminated C string that represents
1659221345Sdim  *  the name of the memory category.  This string should never be freed.
1660221345Sdim  */
1661221345SdimCINDEX_LINKAGE
1662221345Sdimconst char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind);
1663221345Sdim
1664221345Sdimtypedef struct CXTUResourceUsageEntry {
1665341825Sdim  /* The memory usage category. */
1666341825Sdim  enum CXTUResourceUsageKind kind;
1667341825Sdim  /* Amount of resources used.
1668221345Sdim      The units will depend on the resource kind. */
1669221345Sdim  unsigned long amount;
1670221345Sdim} CXTUResourceUsageEntry;
1671221345Sdim
1672221345Sdim/**
1673341825Sdim  * The memory usage of a CXTranslationUnit, broken into categories.
1674221345Sdim  */
1675221345Sdimtypedef struct CXTUResourceUsage {
1676341825Sdim  /* Private data member, used for queries. */
1677221345Sdim  void *data;
1678221345Sdim
1679341825Sdim  /* The number of entries in the 'entries' array. */
1680221345Sdim  unsigned numEntries;
1681221345Sdim
1682341825Sdim  /* An array of key-value pairs, representing the breakdown of memory
1683221345Sdim            usage. */
1684221345Sdim  CXTUResourceUsageEntry *entries;
1685221345Sdim
1686221345Sdim} CXTUResourceUsage;
1687221345Sdim
1688221345Sdim/**
1689341825Sdim  * Return the memory usage of a translation unit.  This object
1690221345Sdim  *  should be released with clang_disposeCXTUResourceUsage().
1691221345Sdim  */
1692221345SdimCINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
1693221345Sdim
1694221345SdimCINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
1695221345Sdim
1696221345Sdim/**
1697341825Sdim * Get target information for this translation unit.
1698321369Sdim *
1699321369Sdim * The CXTargetInfo object cannot outlive the CXTranslationUnit object.
1700321369Sdim */
1701321369SdimCINDEX_LINKAGE CXTargetInfo
1702321369Sdimclang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
1703321369Sdim
1704321369Sdim/**
1705341825Sdim * Destroy the CXTargetInfo object.
1706321369Sdim */
1707321369SdimCINDEX_LINKAGE void
1708321369Sdimclang_TargetInfo_dispose(CXTargetInfo Info);
1709321369Sdim
1710321369Sdim/**
1711341825Sdim * Get the normalized target triple as a string.
1712321369Sdim *
1713321369Sdim * Returns the empty string in case of any error.
1714321369Sdim */
1715321369SdimCINDEX_LINKAGE CXString
1716321369Sdimclang_TargetInfo_getTriple(CXTargetInfo Info);
1717321369Sdim
1718321369Sdim/**
1719341825Sdim * Get the pointer width of the target in bits.
1720321369Sdim *
1721321369Sdim * Returns -1 in case of error.
1722321369Sdim */
1723321369SdimCINDEX_LINKAGE int
1724321369Sdimclang_TargetInfo_getPointerWidth(CXTargetInfo Info);
1725321369Sdim
1726321369Sdim/**
1727203955Srdivacky * @}
1728203955Srdivacky */
1729205219Srdivacky
1730203955Srdivacky/**
1731341825Sdim * Describes the kind of entity that a cursor refers to.
1732202379Srdivacky */
1733202879Srdivackyenum CXCursorKind {
1734202879Srdivacky  /* Declarations */
1735203955Srdivacky  /**
1736341825Sdim   * A declaration whose specific kind is not exposed via this
1737203955Srdivacky   * interface.
1738202879Srdivacky   *
1739202879Srdivacky   * Unexposed declarations have the same operations as any other kind
1740202879Srdivacky   * of declaration; one can extract their location information,
1741202879Srdivacky   * spelling, find their definitions, etc. However, the specific kind
1742202879Srdivacky   * of the declaration is not reported.
1743202879Srdivacky   */
1744202879Srdivacky  CXCursor_UnexposedDecl                 = 1,
1745341825Sdim  /** A C or C++ struct. */
1746203955Srdivacky  CXCursor_StructDecl                    = 2,
1747341825Sdim  /** A C or C++ union. */
1748202879Srdivacky  CXCursor_UnionDecl                     = 3,
1749341825Sdim  /** A C++ class. */
1750202879Srdivacky  CXCursor_ClassDecl                     = 4,
1751341825Sdim  /** An enumeration. */
1752202879Srdivacky  CXCursor_EnumDecl                      = 5,
1753203955Srdivacky  /**
1754341825Sdim   * A field (in C) or non-static data member (in C++) in a
1755202879Srdivacky   * struct, union, or C++ class.
1756202879Srdivacky   */
1757202879Srdivacky  CXCursor_FieldDecl                     = 6,
1758341825Sdim  /** An enumerator constant. */
1759202879Srdivacky  CXCursor_EnumConstantDecl              = 7,
1760341825Sdim  /** A function. */
1761202879Srdivacky  CXCursor_FunctionDecl                  = 8,
1762341825Sdim  /** A variable. */
1763202879Srdivacky  CXCursor_VarDecl                       = 9,
1764341825Sdim  /** A function or method parameter. */
1765202879Srdivacky  CXCursor_ParmDecl                      = 10,
1766341825Sdim  /** An Objective-C \@interface. */
1767202879Srdivacky  CXCursor_ObjCInterfaceDecl             = 11,
1768341825Sdim  /** An Objective-C \@interface for a category. */
1769202879Srdivacky  CXCursor_ObjCCategoryDecl              = 12,
1770341825Sdim  /** An Objective-C \@protocol declaration. */
1771202879Srdivacky  CXCursor_ObjCProtocolDecl              = 13,
1772341825Sdim  /** An Objective-C \@property declaration. */
1773202879Srdivacky  CXCursor_ObjCPropertyDecl              = 14,
1774341825Sdim  /** An Objective-C instance variable. */
1775202879Srdivacky  CXCursor_ObjCIvarDecl                  = 15,
1776341825Sdim  /** An Objective-C instance method. */
1777202879Srdivacky  CXCursor_ObjCInstanceMethodDecl        = 16,
1778341825Sdim  /** An Objective-C class method. */
1779202879Srdivacky  CXCursor_ObjCClassMethodDecl           = 17,
1780341825Sdim  /** An Objective-C \@implementation. */
1781202879Srdivacky  CXCursor_ObjCImplementationDecl        = 18,
1782341825Sdim  /** An Objective-C \@implementation for a category. */
1783202879Srdivacky  CXCursor_ObjCCategoryImplDecl          = 19,
1784341825Sdim  /** A typedef. */
1785202879Srdivacky  CXCursor_TypedefDecl                   = 20,
1786341825Sdim  /** A C++ class method. */
1787207619Srdivacky  CXCursor_CXXMethod                     = 21,
1788341825Sdim  /** A C++ namespace. */
1789208600Srdivacky  CXCursor_Namespace                     = 22,
1790341825Sdim  /** A linkage specification, e.g. 'extern "C"'. */
1791208600Srdivacky  CXCursor_LinkageSpec                   = 23,
1792341825Sdim  /** A C++ constructor. */
1793212904Sdim  CXCursor_Constructor                   = 24,
1794341825Sdim  /** A C++ destructor. */
1795212904Sdim  CXCursor_Destructor                    = 25,
1796341825Sdim  /** A C++ conversion function. */
1797212904Sdim  CXCursor_ConversionFunction            = 26,
1798341825Sdim  /** A C++ template type parameter. */
1799212904Sdim  CXCursor_TemplateTypeParameter         = 27,
1800341825Sdim  /** A C++ non-type template parameter. */
1801212904Sdim  CXCursor_NonTypeTemplateParameter      = 28,
1802341825Sdim  /** A C++ template template parameter. */
1803212904Sdim  CXCursor_TemplateTemplateParameter     = 29,
1804341825Sdim  /** A C++ function template. */
1805212904Sdim  CXCursor_FunctionTemplate              = 30,
1806341825Sdim  /** A C++ class template. */
1807212904Sdim  CXCursor_ClassTemplate                 = 31,
1808341825Sdim  /** A C++ class template partial specialization. */
1809212904Sdim  CXCursor_ClassTemplatePartialSpecialization = 32,
1810341825Sdim  /** A C++ namespace alias declaration. */
1811212904Sdim  CXCursor_NamespaceAlias                = 33,
1812341825Sdim  /** A C++ using directive. */
1813212904Sdim  CXCursor_UsingDirective                = 34,
1814341825Sdim  /** A C++ using declaration. */
1815212904Sdim  CXCursor_UsingDeclaration              = 35,
1816341825Sdim  /** A C++ alias declaration */
1817221345Sdim  CXCursor_TypeAliasDecl                 = 36,
1818341825Sdim  /** An Objective-C \@synthesize definition. */
1819223017Sdim  CXCursor_ObjCSynthesizeDecl            = 37,
1820341825Sdim  /** An Objective-C \@dynamic definition. */
1821223017Sdim  CXCursor_ObjCDynamicDecl               = 38,
1822341825Sdim  /** An access specifier. */
1823226633Sdim  CXCursor_CXXAccessSpecifier            = 39,
1824226633Sdim
1825208600Srdivacky  CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
1826226633Sdim  CXCursor_LastDecl                      = CXCursor_CXXAccessSpecifier,
1827207619Srdivacky
1828202879Srdivacky  /* References */
1829202879Srdivacky  CXCursor_FirstRef                      = 40, /* Decl references */
1830203955Srdivacky  CXCursor_ObjCSuperClassRef             = 40,
1831202879Srdivacky  CXCursor_ObjCProtocolRef               = 41,
1832202879Srdivacky  CXCursor_ObjCClassRef                  = 42,
1833202879Srdivacky  /**
1834341825Sdim   * A reference to a type declaration.
1835202879Srdivacky   *
1836202879Srdivacky   * A type reference occurs anywhere where a type is named but not
1837202879Srdivacky   * declared. For example, given:
1838202879Srdivacky   *
1839202879Srdivacky   * \code
1840202879Srdivacky   * typedef unsigned size_type;
1841202879Srdivacky   * size_type size;
1842202879Srdivacky   * \endcode
1843202879Srdivacky   *
1844202879Srdivacky   * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1845202879Srdivacky   * while the type of the variable "size" is referenced. The cursor
1846202879Srdivacky   * referenced by the type of size is the typedef for size_type.
1847202879Srdivacky   */
1848202879Srdivacky  CXCursor_TypeRef                       = 43,
1849212904Sdim  CXCursor_CXXBaseSpecifier              = 44,
1850341825Sdim  /**
1851341825Sdim   * A reference to a class template, function template, template
1852218893Sdim   * template parameter, or class template partial specialization.
1853212904Sdim   */
1854212904Sdim  CXCursor_TemplateRef                   = 45,
1855212904Sdim  /**
1856341825Sdim   * A reference to a namespace or namespace alias.
1857212904Sdim   */
1858212904Sdim  CXCursor_NamespaceRef                  = 46,
1859218893Sdim  /**
1860341825Sdim   * A reference to a member of a struct, union, or class that occurs in
1861218893Sdim   * some non-expression context, e.g., a designated initializer.
1862218893Sdim   */
1863218893Sdim  CXCursor_MemberRef                     = 47,
1864218893Sdim  /**
1865341825Sdim   * A reference to a labeled statement.
1866218893Sdim   *
1867341825Sdim   * This cursor kind is used to describe the jump to "start_over" in the
1868218893Sdim   * goto statement in the following example:
1869218893Sdim   *
1870218893Sdim   * \code
1871218893Sdim   *   start_over:
1872218893Sdim   *     ++counter;
1873218893Sdim   *
1874218893Sdim   *     goto start_over;
1875218893Sdim   * \endcode
1876218893Sdim   *
1877218893Sdim   * A label reference cursor refers to a label statement.
1878218893Sdim   */
1879218893Sdim  CXCursor_LabelRef                      = 48,
1880341825Sdim
1881218893Sdim  /**
1882341825Sdim   * A reference to a set of overloaded functions or function templates
1883218893Sdim   * that has not yet been resolved to a specific function or function template.
1884218893Sdim   *
1885218893Sdim   * An overloaded declaration reference cursor occurs in C++ templates where
1886218893Sdim   * a dependent name refers to a function. For example:
1887218893Sdim   *
1888218893Sdim   * \code
1889218893Sdim   * template<typename T> void swap(T&, T&);
1890218893Sdim   *
1891218893Sdim   * struct X { ... };
1892218893Sdim   * void swap(X&, X&);
1893218893Sdim   *
1894218893Sdim   * template<typename T>
1895218893Sdim   * void reverse(T* first, T* last) {
1896218893Sdim   *   while (first < last - 1) {
1897218893Sdim   *     swap(*first, *--last);
1898218893Sdim   *     ++first;
1899218893Sdim   *   }
1900218893Sdim   * }
1901218893Sdim   *
1902218893Sdim   * struct Y { };
1903218893Sdim   * void swap(Y&, Y&);
1904218893Sdim   * \endcode
1905218893Sdim   *
1906218893Sdim   * Here, the identifier "swap" is associated with an overloaded declaration
1907218893Sdim   * reference. In the template definition, "swap" refers to either of the two
1908218893Sdim   * "swap" functions declared above, so both results will be available. At
1909218893Sdim   * instantiation time, "swap" may also refer to other functions found via
1910218893Sdim   * argument-dependent lookup (e.g., the "swap" function at the end of the
1911218893Sdim   * example).
1912218893Sdim   *
1913341825Sdim   * The functions \c clang_getNumOverloadedDecls() and
1914218893Sdim   * \c clang_getOverloadedDecl() can be used to retrieve the definitions
1915218893Sdim   * referenced by this cursor.
1916218893Sdim   */
1917218893Sdim  CXCursor_OverloadedDeclRef             = 49,
1918341825Sdim
1919234353Sdim  /**
1920341825Sdim   * A reference to a variable that occurs in some non-expression
1921234353Sdim   * context, e.g., a C++ lambda capture list.
1922234353Sdim   */
1923234353Sdim  CXCursor_VariableRef                   = 50,
1924341825Sdim
1925234353Sdim  CXCursor_LastRef                       = CXCursor_VariableRef,
1926203955Srdivacky
1927202879Srdivacky  /* Error conditions */
1928202879Srdivacky  CXCursor_FirstInvalid                  = 70,
1929202879Srdivacky  CXCursor_InvalidFile                   = 70,
1930202879Srdivacky  CXCursor_NoDeclFound                   = 71,
1931202879Srdivacky  CXCursor_NotImplemented                = 72,
1932205408Srdivacky  CXCursor_InvalidCode                   = 73,
1933205408Srdivacky  CXCursor_LastInvalid                   = CXCursor_InvalidCode,
1934203955Srdivacky
1935202879Srdivacky  /* Expressions */
1936202879Srdivacky  CXCursor_FirstExpr                     = 100,
1937203955Srdivacky
1938202879Srdivacky  /**
1939341825Sdim   * An expression whose specific kind is not exposed via this
1940203955Srdivacky   * interface.
1941202879Srdivacky   *
1942202879Srdivacky   * Unexposed expressions have the same operations as any other kind
1943202879Srdivacky   * of expression; one can extract their location information,
1944202879Srdivacky   * spelling, children, etc. However, the specific kind of the
1945202879Srdivacky   * expression is not reported.
1946202879Srdivacky   */
1947202879Srdivacky  CXCursor_UnexposedExpr                 = 100,
1948203955Srdivacky
1949202879Srdivacky  /**
1950341825Sdim   * An expression that refers to some value declaration, such
1951276479Sdim   * as a function, variable, or enumerator.
1952202879Srdivacky   */
1953202879Srdivacky  CXCursor_DeclRefExpr                   = 101,
1954203955Srdivacky
1955202879Srdivacky  /**
1956341825Sdim   * An expression that refers to a member of a struct, union,
1957202879Srdivacky   * class, Objective-C class, etc.
1958202879Srdivacky   */
1959202879Srdivacky  CXCursor_MemberRefExpr                 = 102,
1960203955Srdivacky
1961341825Sdim  /** An expression that calls a function. */
1962202879Srdivacky  CXCursor_CallExpr                      = 103,
1963203955Srdivacky
1964341825Sdim  /** An expression that sends a message to an Objective-C
1965202879Srdivacky   object or class. */
1966202879Srdivacky  CXCursor_ObjCMessageExpr               = 104,
1967203955Srdivacky
1968341825Sdim  /** An expression that represents a block literal. */
1969207619Srdivacky  CXCursor_BlockExpr                     = 105,
1970207619Srdivacky
1971341825Sdim  /** An integer literal.
1972226633Sdim   */
1973226633Sdim  CXCursor_IntegerLiteral                = 106,
1974207619Srdivacky
1975341825Sdim  /** A floating point number literal.
1976226633Sdim   */
1977226633Sdim  CXCursor_FloatingLiteral               = 107,
1978226633Sdim
1979341825Sdim  /** An imaginary number literal.
1980226633Sdim   */
1981226633Sdim  CXCursor_ImaginaryLiteral              = 108,
1982226633Sdim
1983341825Sdim  /** A string literal.
1984226633Sdim   */
1985226633Sdim  CXCursor_StringLiteral                 = 109,
1986226633Sdim
1987341825Sdim  /** A character literal.
1988226633Sdim   */
1989226633Sdim  CXCursor_CharacterLiteral              = 110,
1990226633Sdim
1991341825Sdim  /** A parenthesized expression, e.g. "(1)".
1992226633Sdim   *
1993226633Sdim   * This AST node is only formed if full location information is requested.
1994226633Sdim   */
1995226633Sdim  CXCursor_ParenExpr                     = 111,
1996226633Sdim
1997341825Sdim  /** This represents the unary-expression's (except sizeof and
1998226633Sdim   * alignof).
1999226633Sdim   */
2000226633Sdim  CXCursor_UnaryOperator                 = 112,
2001226633Sdim
2002341825Sdim  /** [C99 6.5.2.1] Array Subscripting.
2003226633Sdim   */
2004226633Sdim  CXCursor_ArraySubscriptExpr            = 113,
2005226633Sdim
2006341825Sdim  /** A builtin binary operation expression such as "x + y" or
2007226633Sdim   * "x <= y".
2008226633Sdim   */
2009226633Sdim  CXCursor_BinaryOperator                = 114,
2010226633Sdim
2011341825Sdim  /** Compound assignment such as "+=".
2012226633Sdim   */
2013226633Sdim  CXCursor_CompoundAssignOperator        = 115,
2014226633Sdim
2015341825Sdim  /** The ?: ternary operator.
2016226633Sdim   */
2017226633Sdim  CXCursor_ConditionalOperator           = 116,
2018226633Sdim
2019341825Sdim  /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++
2020226633Sdim   * (C++ [expr.cast]), which uses the syntax (Type)expr.
2021226633Sdim   *
2022226633Sdim   * For example: (int)f.
2023226633Sdim   */
2024226633Sdim  CXCursor_CStyleCastExpr                = 117,
2025226633Sdim
2026341825Sdim  /** [C99 6.5.2.5]
2027226633Sdim   */
2028226633Sdim  CXCursor_CompoundLiteralExpr           = 118,
2029226633Sdim
2030341825Sdim  /** Describes an C or C++ initializer list.
2031226633Sdim   */
2032226633Sdim  CXCursor_InitListExpr                  = 119,
2033226633Sdim
2034341825Sdim  /** The GNU address of label extension, representing &&label.
2035226633Sdim   */
2036226633Sdim  CXCursor_AddrLabelExpr                 = 120,
2037226633Sdim
2038341825Sdim  /** This is the GNU Statement Expression extension: ({int X=4; X;})
2039226633Sdim   */
2040226633Sdim  CXCursor_StmtExpr                      = 121,
2041226633Sdim
2042341825Sdim  /** Represents a C11 generic selection.
2043226633Sdim   */
2044226633Sdim  CXCursor_GenericSelectionExpr          = 122,
2045226633Sdim
2046341825Sdim  /** Implements the GNU __null extension, which is a name for a null
2047226633Sdim   * pointer constant that has integral type (e.g., int or long) and is the same
2048226633Sdim   * size and alignment as a pointer.
2049226633Sdim   *
2050226633Sdim   * The __null extension is typically only used by system headers, which define
2051226633Sdim   * NULL as __null in C++ rather than using 0 (which is an integer that may not
2052226633Sdim   * match the size of a pointer).
2053226633Sdim   */
2054226633Sdim  CXCursor_GNUNullExpr                   = 123,
2055226633Sdim
2056341825Sdim  /** C++'s static_cast<> expression.
2057226633Sdim   */
2058226633Sdim  CXCursor_CXXStaticCastExpr             = 124,
2059226633Sdim
2060341825Sdim  /** C++'s dynamic_cast<> expression.
2061226633Sdim   */
2062226633Sdim  CXCursor_CXXDynamicCastExpr            = 125,
2063226633Sdim
2064341825Sdim  /** C++'s reinterpret_cast<> expression.
2065226633Sdim   */
2066226633Sdim  CXCursor_CXXReinterpretCastExpr        = 126,
2067226633Sdim
2068341825Sdim  /** C++'s const_cast<> expression.
2069226633Sdim   */
2070226633Sdim  CXCursor_CXXConstCastExpr              = 127,
2071226633Sdim
2072341825Sdim  /** Represents an explicit C++ type conversion that uses "functional"
2073226633Sdim   * notion (C++ [expr.type.conv]).
2074226633Sdim   *
2075226633Sdim   * Example:
2076226633Sdim   * \code
2077226633Sdim   *   x = int(0.5);
2078226633Sdim   * \endcode
2079226633Sdim   */
2080226633Sdim  CXCursor_CXXFunctionalCastExpr         = 128,
2081226633Sdim
2082341825Sdim  /** A C++ typeid expression (C++ [expr.typeid]).
2083226633Sdim   */
2084226633Sdim  CXCursor_CXXTypeidExpr                 = 129,
2085226633Sdim
2086341825Sdim  /** [C++ 2.13.5] C++ Boolean Literal.
2087226633Sdim   */
2088226633Sdim  CXCursor_CXXBoolLiteralExpr            = 130,
2089226633Sdim
2090341825Sdim  /** [C++0x 2.14.7] C++ Pointer Literal.
2091226633Sdim   */
2092226633Sdim  CXCursor_CXXNullPtrLiteralExpr         = 131,
2093226633Sdim
2094341825Sdim  /** Represents the "this" expression in C++
2095226633Sdim   */
2096226633Sdim  CXCursor_CXXThisExpr                   = 132,
2097226633Sdim
2098341825Sdim  /** [C++ 15] C++ Throw Expression.
2099226633Sdim   *
2100226633Sdim   * This handles 'throw' and 'throw' assignment-expression. When
2101226633Sdim   * assignment-expression isn't present, Op will be null.
2102226633Sdim   */
2103226633Sdim  CXCursor_CXXThrowExpr                  = 133,
2104226633Sdim
2105341825Sdim  /** A new expression for memory allocation and constructor calls, e.g:
2106226633Sdim   * "new CXXNewExpr(foo)".
2107226633Sdim   */
2108226633Sdim  CXCursor_CXXNewExpr                    = 134,
2109226633Sdim
2110341825Sdim  /** A delete expression for memory deallocation and destructor calls,
2111226633Sdim   * e.g. "delete[] pArray".
2112226633Sdim   */
2113226633Sdim  CXCursor_CXXDeleteExpr                 = 135,
2114226633Sdim
2115341825Sdim  /** A unary expression. (noexcept, sizeof, or other traits)
2116226633Sdim   */
2117226633Sdim  CXCursor_UnaryExpr                     = 136,
2118226633Sdim
2119341825Sdim  /** An Objective-C string literal i.e. @"foo".
2120226633Sdim   */
2121226633Sdim  CXCursor_ObjCStringLiteral             = 137,
2122226633Sdim
2123341825Sdim  /** An Objective-C \@encode expression.
2124226633Sdim   */
2125226633Sdim  CXCursor_ObjCEncodeExpr                = 138,
2126226633Sdim
2127341825Sdim  /** An Objective-C \@selector expression.
2128226633Sdim   */
2129226633Sdim  CXCursor_ObjCSelectorExpr              = 139,
2130226633Sdim
2131341825Sdim  /** An Objective-C \@protocol expression.
2132226633Sdim   */
2133226633Sdim  CXCursor_ObjCProtocolExpr              = 140,
2134226633Sdim
2135341825Sdim  /** An Objective-C "bridged" cast expression, which casts between
2136226633Sdim   * Objective-C pointers and C pointers, transferring ownership in the process.
2137226633Sdim   *
2138226633Sdim   * \code
2139226633Sdim   *   NSString *str = (__bridge_transfer NSString *)CFCreateString();
2140226633Sdim   * \endcode
2141226633Sdim   */
2142226633Sdim  CXCursor_ObjCBridgedCastExpr           = 141,
2143226633Sdim
2144341825Sdim  /** Represents a C++0x pack expansion that produces a sequence of
2145226633Sdim   * expressions.
2146226633Sdim   *
2147226633Sdim   * A pack expansion expression contains a pattern (which itself is an
2148226633Sdim   * expression) followed by an ellipsis. For example:
2149226633Sdim   *
2150226633Sdim   * \code
2151226633Sdim   * template<typename F, typename ...Types>
2152226633Sdim   * void forward(F f, Types &&...args) {
2153226633Sdim   *  f(static_cast<Types&&>(args)...);
2154226633Sdim   * }
2155226633Sdim   * \endcode
2156226633Sdim   */
2157226633Sdim  CXCursor_PackExpansionExpr             = 142,
2158226633Sdim
2159341825Sdim  /** Represents an expression that computes the length of a parameter
2160226633Sdim   * pack.
2161226633Sdim   *
2162226633Sdim   * \code
2163226633Sdim   * template<typename ...Types>
2164226633Sdim   * struct count {
2165226633Sdim   *   static const unsigned value = sizeof...(Types);
2166226633Sdim   * };
2167226633Sdim   * \endcode
2168226633Sdim   */
2169226633Sdim  CXCursor_SizeOfPackExpr                = 143,
2170226633Sdim
2171341825Sdim  /* Represents a C++ lambda expression that produces a local function
2172234353Sdim   * object.
2173234353Sdim   *
2174234353Sdim   * \code
2175234353Sdim   * void abssort(float *x, unsigned N) {
2176234353Sdim   *   std::sort(x, x + N,
2177234353Sdim   *             [](float a, float b) {
2178234353Sdim   *               return std::abs(a) < std::abs(b);
2179234353Sdim   *             });
2180234353Sdim   * }
2181234353Sdim   * \endcode
2182234353Sdim   */
2183234353Sdim  CXCursor_LambdaExpr                    = 144,
2184341825Sdim
2185341825Sdim  /** Objective-c Boolean Literal.
2186234353Sdim   */
2187234353Sdim  CXCursor_ObjCBoolLiteralExpr           = 145,
2188226633Sdim
2189341825Sdim  /** Represents the "self" expression in an Objective-C method.
2190251662Sdim   */
2191251662Sdim  CXCursor_ObjCSelfExpr                  = 146,
2192234353Sdim
2193341825Sdim  /** OpenMP 4.0 [2.4, Array Section].
2194296417Sdim   */
2195296417Sdim  CXCursor_OMPArraySectionExpr           = 147,
2196251662Sdim
2197341825Sdim  /** Represents an @available(...) check.
2198309124Sdim   */
2199309124Sdim  CXCursor_ObjCAvailabilityCheckExpr     = 148,
2200296417Sdim
2201341825Sdim  /**
2202341825Sdim   * Fixed point literal
2203341825Sdim   */
2204341825Sdim  CXCursor_FixedPointLiteral             = 149,
2205309124Sdim
2206341825Sdim  CXCursor_LastExpr                      = CXCursor_FixedPointLiteral,
2207341825Sdim
2208202879Srdivacky  /* Statements */
2209202879Srdivacky  CXCursor_FirstStmt                     = 200,
2210202879Srdivacky  /**
2211341825Sdim   * A statement whose specific kind is not exposed via this
2212202879Srdivacky   * interface.
2213202879Srdivacky   *
2214202879Srdivacky   * Unexposed statements have the same operations as any other kind of
2215202879Srdivacky   * statement; one can extract their location information, spelling,
2216202879Srdivacky   * children, etc. However, the specific kind of the statement is not
2217202879Srdivacky   * reported.
2218202879Srdivacky   */
2219202879Srdivacky  CXCursor_UnexposedStmt                 = 200,
2220341825Sdim
2221341825Sdim  /** A labelled statement in a function.
2222218893Sdim   *
2223341825Sdim   * This cursor kind is used to describe the "start_over:" label statement in
2224218893Sdim   * the following example:
2225218893Sdim   *
2226218893Sdim   * \code
2227218893Sdim   *   start_over:
2228218893Sdim   *     ++counter;
2229218893Sdim   * \endcode
2230218893Sdim   *
2231218893Sdim   */
2232218893Sdim  CXCursor_LabelStmt                     = 201,
2233203955Srdivacky
2234341825Sdim  /** A group of statements like { stmt stmt }.
2235226633Sdim   *
2236226633Sdim   * This cursor kind is used to describe compound statements, e.g. function
2237226633Sdim   * bodies.
2238226633Sdim   */
2239226633Sdim  CXCursor_CompoundStmt                  = 202,
2240226633Sdim
2241341825Sdim  /** A case statement.
2242226633Sdim   */
2243226633Sdim  CXCursor_CaseStmt                      = 203,
2244226633Sdim
2245341825Sdim  /** A default statement.
2246226633Sdim   */
2247226633Sdim  CXCursor_DefaultStmt                   = 204,
2248226633Sdim
2249341825Sdim  /** An if statement
2250226633Sdim   */
2251226633Sdim  CXCursor_IfStmt                        = 205,
2252226633Sdim
2253341825Sdim  /** A switch statement.
2254226633Sdim   */
2255226633Sdim  CXCursor_SwitchStmt                    = 206,
2256226633Sdim
2257341825Sdim  /** A while statement.
2258226633Sdim   */
2259226633Sdim  CXCursor_WhileStmt                     = 207,
2260226633Sdim
2261341825Sdim  /** A do statement.
2262226633Sdim   */
2263226633Sdim  CXCursor_DoStmt                        = 208,
2264226633Sdim
2265341825Sdim  /** A for statement.
2266226633Sdim   */
2267226633Sdim  CXCursor_ForStmt                       = 209,
2268226633Sdim
2269341825Sdim  /** A goto statement.
2270226633Sdim   */
2271226633Sdim  CXCursor_GotoStmt                      = 210,
2272226633Sdim
2273341825Sdim  /** An indirect goto statement.
2274226633Sdim   */
2275226633Sdim  CXCursor_IndirectGotoStmt              = 211,
2276226633Sdim
2277341825Sdim  /** A continue statement.
2278226633Sdim   */
2279226633Sdim  CXCursor_ContinueStmt                  = 212,
2280226633Sdim
2281341825Sdim  /** A break statement.
2282226633Sdim   */
2283226633Sdim  CXCursor_BreakStmt                     = 213,
2284226633Sdim
2285341825Sdim  /** A return statement.
2286226633Sdim   */
2287226633Sdim  CXCursor_ReturnStmt                    = 214,
2288226633Sdim
2289341825Sdim  /** A GCC inline assembly statement extension.
2290226633Sdim   */
2291243830Sdim  CXCursor_GCCAsmStmt                    = 215,
2292243830Sdim  CXCursor_AsmStmt                       = CXCursor_GCCAsmStmt,
2293226633Sdim
2294341825Sdim  /** Objective-C's overall \@try-\@catch-\@finally statement.
2295226633Sdim   */
2296226633Sdim  CXCursor_ObjCAtTryStmt                 = 216,
2297226633Sdim
2298341825Sdim  /** Objective-C's \@catch statement.
2299226633Sdim   */
2300226633Sdim  CXCursor_ObjCAtCatchStmt               = 217,
2301226633Sdim
2302341825Sdim  /** Objective-C's \@finally statement.
2303226633Sdim   */
2304226633Sdim  CXCursor_ObjCAtFinallyStmt             = 218,
2305226633Sdim
2306341825Sdim  /** Objective-C's \@throw statement.
2307226633Sdim   */
2308226633Sdim  CXCursor_ObjCAtThrowStmt               = 219,
2309226633Sdim
2310341825Sdim  /** Objective-C's \@synchronized statement.
2311226633Sdim   */
2312226633Sdim  CXCursor_ObjCAtSynchronizedStmt        = 220,
2313226633Sdim
2314341825Sdim  /** Objective-C's autorelease pool statement.
2315226633Sdim   */
2316226633Sdim  CXCursor_ObjCAutoreleasePoolStmt       = 221,
2317226633Sdim
2318341825Sdim  /** Objective-C's collection statement.
2319226633Sdim   */
2320226633Sdim  CXCursor_ObjCForCollectionStmt         = 222,
2321226633Sdim
2322341825Sdim  /** C++'s catch statement.
2323226633Sdim   */
2324226633Sdim  CXCursor_CXXCatchStmt                  = 223,
2325226633Sdim
2326341825Sdim  /** C++'s try statement.
2327226633Sdim   */
2328226633Sdim  CXCursor_CXXTryStmt                    = 224,
2329226633Sdim
2330341825Sdim  /** C++'s for (* : *) statement.
2331226633Sdim   */
2332226633Sdim  CXCursor_CXXForRangeStmt               = 225,
2333226633Sdim
2334341825Sdim  /** Windows Structured Exception Handling's try statement.
2335226633Sdim   */
2336226633Sdim  CXCursor_SEHTryStmt                    = 226,
2337226633Sdim
2338341825Sdim  /** Windows Structured Exception Handling's except statement.
2339226633Sdim   */
2340226633Sdim  CXCursor_SEHExceptStmt                 = 227,
2341226633Sdim
2342341825Sdim  /** Windows Structured Exception Handling's finally statement.
2343226633Sdim   */
2344226633Sdim  CXCursor_SEHFinallyStmt                = 228,
2345226633Sdim
2346341825Sdim  /** A MS inline assembly statement extension.
2347239462Sdim   */
2348239462Sdim  CXCursor_MSAsmStmt                     = 229,
2349239462Sdim
2350341825Sdim  /** The null statement ";": C99 6.8.3p3.
2351226633Sdim   *
2352226633Sdim   * This cursor kind is used to describe the null statement.
2353226633Sdim   */
2354226633Sdim  CXCursor_NullStmt                      = 230,
2355226633Sdim
2356341825Sdim  /** Adaptor class for mixing declarations with statements and
2357226633Sdim   * expressions.
2358226633Sdim   */
2359226633Sdim  CXCursor_DeclStmt                      = 231,
2360226633Sdim
2361341825Sdim  /** OpenMP parallel directive.
2362261991Sdim   */
2363261991Sdim  CXCursor_OMPParallelDirective          = 232,
2364226633Sdim
2365341825Sdim  /** OpenMP SIMD directive.
2366276479Sdim   */
2367276479Sdim  CXCursor_OMPSimdDirective              = 233,
2368261991Sdim
2369341825Sdim  /** OpenMP for directive.
2370276479Sdim   */
2371276479Sdim  CXCursor_OMPForDirective               = 234,
2372276479Sdim
2373341825Sdim  /** OpenMP sections directive.
2374276479Sdim   */
2375276479Sdim  CXCursor_OMPSectionsDirective          = 235,
2376276479Sdim
2377341825Sdim  /** OpenMP section directive.
2378276479Sdim   */
2379276479Sdim  CXCursor_OMPSectionDirective           = 236,
2380276479Sdim
2381341825Sdim  /** OpenMP single directive.
2382276479Sdim   */
2383276479Sdim  CXCursor_OMPSingleDirective            = 237,
2384276479Sdim
2385341825Sdim  /** OpenMP parallel for directive.
2386276479Sdim   */
2387276479Sdim  CXCursor_OMPParallelForDirective       = 238,
2388276479Sdim
2389341825Sdim  /** OpenMP parallel sections directive.
2390276479Sdim   */
2391276479Sdim  CXCursor_OMPParallelSectionsDirective  = 239,
2392276479Sdim
2393341825Sdim  /** OpenMP task directive.
2394276479Sdim   */
2395276479Sdim  CXCursor_OMPTaskDirective              = 240,
2396276479Sdim
2397341825Sdim  /** OpenMP master directive.
2398276479Sdim   */
2399276479Sdim  CXCursor_OMPMasterDirective            = 241,
2400276479Sdim
2401341825Sdim  /** OpenMP critical directive.
2402276479Sdim   */
2403276479Sdim  CXCursor_OMPCriticalDirective          = 242,
2404276479Sdim
2405341825Sdim  /** OpenMP taskyield directive.
2406276479Sdim   */
2407276479Sdim  CXCursor_OMPTaskyieldDirective         = 243,
2408276479Sdim
2409341825Sdim  /** OpenMP barrier directive.
2410276479Sdim   */
2411276479Sdim  CXCursor_OMPBarrierDirective           = 244,
2412276479Sdim
2413341825Sdim  /** OpenMP taskwait directive.
2414276479Sdim   */
2415276479Sdim  CXCursor_OMPTaskwaitDirective          = 245,
2416276479Sdim
2417341825Sdim  /** OpenMP flush directive.
2418276479Sdim   */
2419276479Sdim  CXCursor_OMPFlushDirective             = 246,
2420276479Sdim
2421341825Sdim  /** Windows Structured Exception Handling's leave statement.
2422276479Sdim   */
2423276479Sdim  CXCursor_SEHLeaveStmt                  = 247,
2424276479Sdim
2425341825Sdim  /** OpenMP ordered directive.
2426280031Sdim   */
2427280031Sdim  CXCursor_OMPOrderedDirective           = 248,
2428276479Sdim
2429341825Sdim  /** OpenMP atomic directive.
2430280031Sdim   */
2431280031Sdim  CXCursor_OMPAtomicDirective            = 249,
2432280031Sdim
2433341825Sdim  /** OpenMP for SIMD directive.
2434280031Sdim   */
2435280031Sdim  CXCursor_OMPForSimdDirective           = 250,
2436280031Sdim
2437341825Sdim  /** OpenMP parallel for SIMD directive.
2438280031Sdim   */
2439280031Sdim  CXCursor_OMPParallelForSimdDirective   = 251,
2440280031Sdim
2441341825Sdim  /** OpenMP target directive.
2442280031Sdim   */
2443280031Sdim  CXCursor_OMPTargetDirective            = 252,
2444280031Sdim
2445341825Sdim  /** OpenMP teams directive.
2446280031Sdim   */
2447280031Sdim  CXCursor_OMPTeamsDirective             = 253,
2448280031Sdim
2449341825Sdim  /** OpenMP taskgroup directive.
2450288943Sdim   */
2451296417Sdim  CXCursor_OMPTaskgroupDirective         = 254,
2452280031Sdim
2453341825Sdim  /** OpenMP cancellation point directive.
2454288943Sdim   */
2455296417Sdim  CXCursor_OMPCancellationPointDirective = 255,
2456288943Sdim
2457341825Sdim  /** OpenMP cancel directive.
2458288943Sdim   */
2459296417Sdim  CXCursor_OMPCancelDirective            = 256,
2460288943Sdim
2461341825Sdim  /** OpenMP target data directive.
2462296417Sdim   */
2463296417Sdim  CXCursor_OMPTargetDataDirective        = 257,
2464288943Sdim
2465341825Sdim  /** OpenMP taskloop directive.
2466296417Sdim   */
2467296417Sdim  CXCursor_OMPTaskLoopDirective          = 258,
2468296417Sdim
2469341825Sdim  /** OpenMP taskloop simd directive.
2470296417Sdim   */
2471296417Sdim  CXCursor_OMPTaskLoopSimdDirective      = 259,
2472296417Sdim
2473341825Sdim  /** OpenMP distribute directive.
2474296417Sdim   */
2475296417Sdim  CXCursor_OMPDistributeDirective        = 260,
2476296417Sdim
2477341825Sdim  /** OpenMP target enter data directive.
2478309124Sdim   */
2479309124Sdim  CXCursor_OMPTargetEnterDataDirective   = 261,
2480296417Sdim
2481341825Sdim  /** OpenMP target exit data directive.
2482309124Sdim   */
2483309124Sdim  CXCursor_OMPTargetExitDataDirective    = 262,
2484309124Sdim
2485341825Sdim  /** OpenMP target parallel directive.
2486309124Sdim   */
2487309124Sdim  CXCursor_OMPTargetParallelDirective    = 263,
2488309124Sdim
2489341825Sdim  /** OpenMP target parallel for directive.
2490309124Sdim   */
2491309124Sdim  CXCursor_OMPTargetParallelForDirective = 264,
2492309124Sdim
2493341825Sdim  /** OpenMP target update directive.
2494309124Sdim   */
2495309124Sdim  CXCursor_OMPTargetUpdateDirective      = 265,
2496309124Sdim
2497341825Sdim  /** OpenMP distribute parallel for directive.
2498309124Sdim   */
2499309124Sdim  CXCursor_OMPDistributeParallelForDirective = 266,
2500309124Sdim
2501341825Sdim  /** OpenMP distribute parallel for simd directive.
2502309124Sdim   */
2503309124Sdim  CXCursor_OMPDistributeParallelForSimdDirective = 267,
2504309124Sdim
2505341825Sdim  /** OpenMP distribute simd directive.
2506309124Sdim   */
2507309124Sdim  CXCursor_OMPDistributeSimdDirective = 268,
2508309124Sdim
2509341825Sdim  /** OpenMP target parallel for simd directive.
2510309124Sdim   */
2511309124Sdim  CXCursor_OMPTargetParallelForSimdDirective = 269,
2512309124Sdim
2513341825Sdim  /** OpenMP target simd directive.
2514314564Sdim   */
2515314564Sdim  CXCursor_OMPTargetSimdDirective = 270,
2516309124Sdim
2517341825Sdim  /** OpenMP teams distribute directive.
2518314564Sdim   */
2519314564Sdim  CXCursor_OMPTeamsDistributeDirective = 271,
2520314564Sdim
2521341825Sdim  /** OpenMP teams distribute simd directive.
2522314564Sdim   */
2523314564Sdim  CXCursor_OMPTeamsDistributeSimdDirective = 272,
2524314564Sdim
2525341825Sdim  /** OpenMP teams distribute parallel for simd directive.
2526314564Sdim   */
2527314564Sdim  CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2528314564Sdim
2529341825Sdim  /** OpenMP teams distribute parallel for directive.
2530314564Sdim   */
2531314564Sdim  CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2532314564Sdim
2533341825Sdim  /** OpenMP target teams directive.
2534314564Sdim   */
2535314564Sdim  CXCursor_OMPTargetTeamsDirective = 275,
2536314564Sdim
2537341825Sdim  /** OpenMP target teams distribute directive.
2538314564Sdim   */
2539314564Sdim  CXCursor_OMPTargetTeamsDistributeDirective = 276,
2540314564Sdim
2541341825Sdim  /** OpenMP target teams distribute parallel for directive.
2542314564Sdim   */
2543314564Sdim  CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2544314564Sdim
2545341825Sdim  /** OpenMP target teams distribute parallel for simd directive.
2546314564Sdim   */
2547314564Sdim  CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2548314564Sdim
2549341825Sdim  /** OpenMP target teams distribute simd directive.
2550314564Sdim   */
2551314564Sdim  CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2552314564Sdim
2553353358Sdim  /** C++2a std::bit_cast expression.
2554353358Sdim   */
2555353358Sdim  CXCursor_BuiltinBitCastExpr = 280,
2556314564Sdim
2557360784Sdim  /** OpenMP master taskloop directive.
2558360784Sdim   */
2559360784Sdim  CXCursor_OMPMasterTaskLoopDirective = 281,
2560353358Sdim
2561360784Sdim  /** OpenMP parallel master taskloop directive.
2562360784Sdim   */
2563360784Sdim  CXCursor_OMPParallelMasterTaskLoopDirective = 282,
2564360784Sdim
2565360784Sdim  /** OpenMP master taskloop simd directive.
2566360784Sdim   */
2567360784Sdim  CXCursor_OMPMasterTaskLoopSimdDirective      = 283,
2568360784Sdim
2569360784Sdim  /** OpenMP parallel master taskloop simd directive.
2570360784Sdim   */
2571360784Sdim  CXCursor_OMPParallelMasterTaskLoopSimdDirective      = 284,
2572360784Sdim
2573360784Sdim  /** OpenMP parallel master directive.
2574360784Sdim   */
2575360784Sdim  CXCursor_OMPParallelMasterDirective      = 285,
2576360784Sdim
2577360784Sdim  CXCursor_LastStmt = CXCursor_OMPParallelMasterDirective,
2578360784Sdim
2579202879Srdivacky  /**
2580341825Sdim   * Cursor that represents the translation unit itself.
2581202879Srdivacky   *
2582202879Srdivacky   * The translation unit cursor exists primarily to act as the root
2583202879Srdivacky   * cursor for traversing the contents of a translation unit.
2584202879Srdivacky   */
2585204643Srdivacky  CXCursor_TranslationUnit               = 300,
2586204643Srdivacky
2587204643Srdivacky  /* Attributes */
2588204643Srdivacky  CXCursor_FirstAttr                     = 400,
2589204643Srdivacky  /**
2590341825Sdim   * An attribute whose specific kind is not exposed via this
2591204643Srdivacky   * interface.
2592204643Srdivacky   */
2593204643Srdivacky  CXCursor_UnexposedAttr                 = 400,
2594204643Srdivacky
2595204643Srdivacky  CXCursor_IBActionAttr                  = 401,
2596204643Srdivacky  CXCursor_IBOutletAttr                  = 402,
2597208600Srdivacky  CXCursor_IBOutletCollectionAttr        = 403,
2598226633Sdim  CXCursor_CXXFinalAttr                  = 404,
2599226633Sdim  CXCursor_CXXOverrideAttr               = 405,
2600226633Sdim  CXCursor_AnnotateAttr                  = 406,
2601234353Sdim  CXCursor_AsmLabelAttr                  = 407,
2602261991Sdim  CXCursor_PackedAttr                    = 408,
2603276479Sdim  CXCursor_PureAttr                      = 409,
2604276479Sdim  CXCursor_ConstAttr                     = 410,
2605276479Sdim  CXCursor_NoDuplicateAttr               = 411,
2606276479Sdim  CXCursor_CUDAConstantAttr              = 412,
2607276479Sdim  CXCursor_CUDADeviceAttr                = 413,
2608276479Sdim  CXCursor_CUDAGlobalAttr                = 414,
2609276479Sdim  CXCursor_CUDAHostAttr                  = 415,
2610280031Sdim  CXCursor_CUDASharedAttr                = 416,
2611296417Sdim  CXCursor_VisibilityAttr                = 417,
2612296417Sdim  CXCursor_DLLExport                     = 418,
2613296417Sdim  CXCursor_DLLImport                     = 419,
2614344779Sdim  CXCursor_NSReturnsRetained             = 420,
2615344779Sdim  CXCursor_NSReturnsNotRetained          = 421,
2616344779Sdim  CXCursor_NSReturnsAutoreleased         = 422,
2617344779Sdim  CXCursor_NSConsumesSelf                = 423,
2618344779Sdim  CXCursor_NSConsumed                    = 424,
2619344779Sdim  CXCursor_ObjCException                 = 425,
2620344779Sdim  CXCursor_ObjCNSObject                  = 426,
2621344779Sdim  CXCursor_ObjCIndependentClass          = 427,
2622344779Sdim  CXCursor_ObjCPreciseLifetime           = 428,
2623344779Sdim  CXCursor_ObjCReturnsInnerPointer       = 429,
2624344779Sdim  CXCursor_ObjCRequiresSuper             = 430,
2625344779Sdim  CXCursor_ObjCRootClass                 = 431,
2626344779Sdim  CXCursor_ObjCSubclassingRestricted     = 432,
2627344779Sdim  CXCursor_ObjCExplicitProtocolImpl      = 433,
2628344779Sdim  CXCursor_ObjCDesignatedInitializer     = 434,
2629344779Sdim  CXCursor_ObjCRuntimeVisible            = 435,
2630344779Sdim  CXCursor_ObjCBoxable                   = 436,
2631344779Sdim  CXCursor_FlagEnum                      = 437,
2632353358Sdim  CXCursor_ConvergentAttr                = 438,
2633353358Sdim  CXCursor_WarnUnusedAttr                = 439,
2634353358Sdim  CXCursor_WarnUnusedResultAttr          = 440,
2635353358Sdim  CXCursor_AlignedAttr                   = 441,
2636353358Sdim  CXCursor_LastAttr                      = CXCursor_AlignedAttr,
2637276479Sdim
2638205408Srdivacky  /* Preprocessing */
2639205408Srdivacky  CXCursor_PreprocessingDirective        = 500,
2640205408Srdivacky  CXCursor_MacroDefinition               = 501,
2641224145Sdim  CXCursor_MacroExpansion                = 502,
2642224145Sdim  CXCursor_MacroInstantiation            = CXCursor_MacroExpansion,
2643218893Sdim  CXCursor_InclusionDirective            = 503,
2644205408Srdivacky  CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
2645243830Sdim  CXCursor_LastPreprocessing             = CXCursor_InclusionDirective,
2646243830Sdim
2647243830Sdim  /* Extra Declarations */
2648243830Sdim  /**
2649341825Sdim   * A module import declaration.
2650243830Sdim   */
2651243830Sdim  CXCursor_ModuleImportDecl              = 600,
2652296417Sdim  CXCursor_TypeAliasTemplateDecl         = 601,
2653309124Sdim  /**
2654341825Sdim   * A static_assert or _Static_assert node
2655309124Sdim   */
2656309124Sdim  CXCursor_StaticAssert                  = 602,
2657314564Sdim  /**
2658341825Sdim   * a friend declaration.
2659314564Sdim   */
2660314564Sdim  CXCursor_FriendDecl                    = 603,
2661243830Sdim  CXCursor_FirstExtraDecl                = CXCursor_ModuleImportDecl,
2662314564Sdim  CXCursor_LastExtraDecl                 = CXCursor_FriendDecl,
2663288943Sdim
2664288943Sdim  /**
2665341825Sdim   * A code completion overload candidate.
2666288943Sdim   */
2667288943Sdim  CXCursor_OverloadCandidate             = 700
2668202879Srdivacky};
2669202379Srdivacky
2670202879Srdivacky/**
2671341825Sdim * A cursor representing some element in the abstract syntax tree for
2672202879Srdivacky * a translation unit.
2673202879Srdivacky *
2674203955Srdivacky * The cursor abstraction unifies the different kinds of entities in a
2675202879Srdivacky * program--declaration, statements, expressions, references to declarations,
2676202879Srdivacky * etc.--under a single "cursor" abstraction with a common set of operations.
2677202879Srdivacky * Common operation for a cursor include: getting the physical location in
2678202879Srdivacky * a source file where the cursor points, getting the name associated with a
2679202879Srdivacky * cursor, and retrieving cursors for any child nodes of a particular cursor.
2680202879Srdivacky *
2681202879Srdivacky * Cursors can be produced in two specific ways.
2682202879Srdivacky * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
2683202879Srdivacky * from which one can use clang_visitChildren() to explore the rest of the
2684202879Srdivacky * translation unit. clang_getCursor() maps from a physical source location
2685202879Srdivacky * to the entity that resides at that location, allowing one to map from the
2686202879Srdivacky * source code into the AST.
2687198092Srdivacky */
2688202879Srdivackytypedef struct {
2689202879Srdivacky  enum CXCursorKind kind;
2690226633Sdim  int xdata;
2691249423Sdim  const void *data[3];
2692203955Srdivacky} CXCursor;
2693202879Srdivacky
2694198398Srdivacky/**
2695202879Srdivacky * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
2696202879Srdivacky *
2697202879Srdivacky * @{
2698198398Srdivacky */
2699203955Srdivacky
2700202879Srdivacky/**
2701341825Sdim * Retrieve the NULL cursor, which represents no entity.
2702202879Srdivacky */
2703199482SrdivackyCINDEX_LINKAGE CXCursor clang_getNullCursor(void);
2704203955Srdivacky
2705202879Srdivacky/**
2706341825Sdim * Retrieve the cursor that represents the given translation unit.
2707202879Srdivacky *
2708202879Srdivacky * The translation unit cursor can be used to start traversing the
2709202879Srdivacky * various declarations within the given translation unit.
2710202879Srdivacky */
2711202879SrdivackyCINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
2712198092Srdivacky
2713202879Srdivacky/**
2714341825Sdim * Determine whether two cursors are equivalent.
2715202879Srdivacky */
2716202879SrdivackyCINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
2717203955Srdivacky
2718202879Srdivacky/**
2719341825Sdim * Returns non-zero if \p cursor is null.
2720226633Sdim */
2721243830SdimCINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor);
2722226633Sdim
2723226633Sdim/**
2724341825Sdim * Compute a hash value for the given cursor.
2725218893Sdim */
2726218893SdimCINDEX_LINKAGE unsigned clang_hashCursor(CXCursor);
2727341825Sdim
2728218893Sdim/**
2729341825Sdim * Retrieve the kind of the given cursor.
2730202879Srdivacky */
2731198893SrdivackyCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
2732202879Srdivacky
2733202879Srdivacky/**
2734341825Sdim * Determine whether the given cursor kind represents a declaration.
2735202879Srdivacky */
2736198893SrdivackyCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
2737202879Srdivacky
2738202879Srdivacky/**
2739341825Sdim * Determine whether the given declaration is invalid.
2740341825Sdim *
2741341825Sdim * A declaration is invalid if it could not be parsed successfully.
2742341825Sdim *
2743341825Sdim * \returns non-zero if the cursor represents a declaration and it is
2744341825Sdim * invalid, otherwise NULL.
2745341825Sdim */
2746341825SdimCINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
2747341825Sdim
2748341825Sdim/**
2749341825Sdim * Determine whether the given cursor kind represents a simple
2750202879Srdivacky * reference.
2751202879Srdivacky *
2752202879Srdivacky * Note that other kinds of cursors (such as expressions) can also refer to
2753202879Srdivacky * other cursors. Use clang_getCursorReferenced() to determine whether a
2754202879Srdivacky * particular cursor refers to another entity.
2755202879Srdivacky */
2756198893SrdivackyCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
2757202879Srdivacky
2758202879Srdivacky/**
2759341825Sdim * Determine whether the given cursor kind represents an expression.
2760202879Srdivacky */
2761202879SrdivackyCINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
2762202879Srdivacky
2763202879Srdivacky/**
2764341825Sdim * Determine whether the given cursor kind represents a statement.
2765202879Srdivacky */
2766202879SrdivackyCINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
2767202879Srdivacky
2768202879Srdivacky/**
2769341825Sdim * Determine whether the given cursor kind represents an attribute.
2770224145Sdim */
2771224145SdimCINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind);
2772224145Sdim
2773224145Sdim/**
2774341825Sdim * Determine whether the given cursor has any attributes.
2775309124Sdim */
2776309124SdimCINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C);
2777309124Sdim
2778309124Sdim/**
2779341825Sdim * Determine whether the given cursor kind represents an invalid
2780202879Srdivacky * cursor.
2781203955Srdivacky */
2782198893SrdivackyCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
2783198398Srdivacky
2784202879Srdivacky/**
2785341825Sdim * Determine whether the given cursor kind represents a translation
2786203955Srdivacky * unit.
2787202879Srdivacky */
2788202879SrdivackyCINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
2789203955Srdivacky
2790204962Srdivacky/***
2791341825Sdim * Determine whether the given cursor represents a preprocessing
2792205408Srdivacky * element, such as a preprocessor directive or macro instantiation.
2793205408Srdivacky */
2794205408SrdivackyCINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
2795341825Sdim
2796205408Srdivacky/***
2797341825Sdim * Determine whether the given cursor represents a currently
2798204962Srdivacky *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
2799204962Srdivacky */
2800204962SrdivackyCINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
2801204962Srdivacky
2802202879Srdivacky/**
2803341825Sdim * Describe the linkage of the entity referred to by a cursor.
2804204643Srdivacky */
2805204643Srdivackyenum CXLinkageKind {
2806341825Sdim  /** This value indicates that no linkage information is available
2807204643Srdivacky   * for a provided CXCursor. */
2808204643Srdivacky  CXLinkage_Invalid,
2809204643Srdivacky  /**
2810341825Sdim   * This is the linkage for variables, parameters, and so on that
2811204643Srdivacky   *  have automatic storage.  This covers normal (non-extern) local variables.
2812204643Srdivacky   */
2813204643Srdivacky  CXLinkage_NoLinkage,
2814341825Sdim  /** This is the linkage for static variables and static functions. */
2815204643Srdivacky  CXLinkage_Internal,
2816341825Sdim  /** This is the linkage for entities with external linkage that live
2817204643Srdivacky   * in C++ anonymous namespaces.*/
2818204643Srdivacky  CXLinkage_UniqueExternal,
2819341825Sdim  /** This is the linkage for entities with true, external linkage. */
2820204643Srdivacky  CXLinkage_External
2821204643Srdivacky};
2822204643Srdivacky
2823204643Srdivacky/**
2824341825Sdim * Determine the linkage of the entity referred to by a given cursor.
2825204643Srdivacky */
2826204643SrdivackyCINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
2827204643Srdivacky
2828296417Sdimenum CXVisibilityKind {
2829341825Sdim  /** This value indicates that no visibility information is available
2830296417Sdim   * for a provided CXCursor. */
2831296417Sdim  CXVisibility_Invalid,
2832296417Sdim
2833341825Sdim  /** Symbol not seen by the linker. */
2834296417Sdim  CXVisibility_Hidden,
2835341825Sdim  /** Symbol seen by the linker but resolves to a symbol inside this object. */
2836296417Sdim  CXVisibility_Protected,
2837341825Sdim  /** Symbol seen by the linker and acts like a normal symbol. */
2838296417Sdim  CXVisibility_Default
2839296417Sdim};
2840296417Sdim
2841204643Srdivacky/**
2842341825Sdim * Describe the visibility of the entity referred to by a cursor.
2843296417Sdim *
2844296417Sdim * This returns the default visibility if not explicitly specified by
2845296417Sdim * a visibility attribute. The default visibility may be changed by
2846296417Sdim * commandline arguments.
2847296417Sdim *
2848296417Sdim * \param cursor The cursor to query.
2849296417Sdim *
2850296417Sdim * \returns The visibility of the cursor.
2851296417Sdim */
2852296417SdimCINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor);
2853296417Sdim
2854296417Sdim/**
2855341825Sdim * Determine the availability of the entity that this cursor refers to,
2856239462Sdim * taking the current target platform into account.
2857212904Sdim *
2858212904Sdim * \param cursor The cursor to query.
2859212904Sdim *
2860212904Sdim * \returns The availability of the cursor.
2861212904Sdim */
2862341825SdimCINDEX_LINKAGE enum CXAvailabilityKind
2863212904Sdimclang_getCursorAvailability(CXCursor cursor);
2864212904Sdim
2865212904Sdim/**
2866239462Sdim * Describes the availability of a given entity on a particular platform, e.g.,
2867239462Sdim * a particular class might only be available on Mac OS 10.7 or newer.
2868239462Sdim */
2869239462Sdimtypedef struct CXPlatformAvailability {
2870239462Sdim  /**
2871341825Sdim   * A string that describes the platform for which this structure
2872239462Sdim   * provides availability information.
2873239462Sdim   *
2874309124Sdim   * Possible values are "ios" or "macos".
2875239462Sdim   */
2876239462Sdim  CXString Platform;
2877239462Sdim  /**
2878341825Sdim   * The version number in which this entity was introduced.
2879239462Sdim   */
2880239462Sdim  CXVersion Introduced;
2881239462Sdim  /**
2882341825Sdim   * The version number in which this entity was deprecated (but is
2883239462Sdim   * still available).
2884239462Sdim   */
2885239462Sdim  CXVersion Deprecated;
2886239462Sdim  /**
2887341825Sdim   * The version number in which this entity was obsoleted, and therefore
2888239462Sdim   * is no longer available.
2889239462Sdim   */
2890239462Sdim  CXVersion Obsoleted;
2891239462Sdim  /**
2892341825Sdim   * Whether the entity is unconditionally unavailable on this platform.
2893239462Sdim   */
2894239462Sdim  int Unavailable;
2895239462Sdim  /**
2896341825Sdim   * An optional message to provide to a user of this API, e.g., to
2897239462Sdim   * suggest replacement APIs.
2898239462Sdim   */
2899239462Sdim  CXString Message;
2900239462Sdim} CXPlatformAvailability;
2901239462Sdim
2902239462Sdim/**
2903341825Sdim * Determine the availability of the entity that this cursor refers to
2904239462Sdim * on any platforms for which availability information is known.
2905239462Sdim *
2906239462Sdim * \param cursor The cursor to query.
2907239462Sdim *
2908341825Sdim * \param always_deprecated If non-NULL, will be set to indicate whether the
2909239462Sdim * entity is deprecated on all platforms.
2910239462Sdim *
2911341825Sdim * \param deprecated_message If non-NULL, will be set to the message text
2912239462Sdim * provided along with the unconditional deprecation of this entity. The client
2913239462Sdim * is responsible for deallocating this string.
2914239462Sdim *
2915239462Sdim * \param always_unavailable If non-NULL, will be set to indicate whether the
2916239462Sdim * entity is unavailable on all platforms.
2917239462Sdim *
2918239462Sdim * \param unavailable_message If non-NULL, will be set to the message text
2919341825Sdim * provided along with the unconditional unavailability of this entity. The
2920239462Sdim * client is responsible for deallocating this string.
2921239462Sdim *
2922239462Sdim * \param availability If non-NULL, an array of CXPlatformAvailability instances
2923239462Sdim * that will be populated with platform availability information, up to either
2924239462Sdim * the number of platforms for which availability information is available (as
2925239462Sdim * returned by this function) or \c availability_size, whichever is smaller.
2926239462Sdim *
2927341825Sdim * \param availability_size The number of elements available in the
2928239462Sdim * \c availability array.
2929239462Sdim *
2930239462Sdim * \returns The number of platforms (N) for which availability information is
2931239462Sdim * available (which is unrelated to \c availability_size).
2932239462Sdim *
2933341825Sdim * Note that the client is responsible for calling
2934341825Sdim * \c clang_disposeCXPlatformAvailability to free each of the
2935341825Sdim * platform-availability structures returned. There are
2936239462Sdim * \c min(N, availability_size) such structures.
2937239462Sdim */
2938239462SdimCINDEX_LINKAGE int
2939239462Sdimclang_getCursorPlatformAvailability(CXCursor cursor,
2940239462Sdim                                    int *always_deprecated,
2941239462Sdim                                    CXString *deprecated_message,
2942239462Sdim                                    int *always_unavailable,
2943239462Sdim                                    CXString *unavailable_message,
2944239462Sdim                                    CXPlatformAvailability *availability,
2945239462Sdim                                    int availability_size);
2946239462Sdim
2947239462Sdim/**
2948341825Sdim * Free the memory associated with a \c CXPlatformAvailability structure.
2949239462Sdim */
2950239462SdimCINDEX_LINKAGE void
2951239462Sdimclang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);
2952341825Sdim
2953239462Sdim/**
2954341825Sdim * Describe the "language" of the entity referred to by a cursor.
2955207619Srdivacky */
2956276479Sdimenum CXLanguageKind {
2957207619Srdivacky  CXLanguage_Invalid = 0,
2958207619Srdivacky  CXLanguage_C,
2959207619Srdivacky  CXLanguage_ObjC,
2960207619Srdivacky  CXLanguage_CPlusPlus
2961207619Srdivacky};
2962207619Srdivacky
2963207619Srdivacky/**
2964341825Sdim * Determine the "language" of the entity referred to by a given cursor.
2965207619Srdivacky */
2966207619SrdivackyCINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
2967207619Srdivacky
2968226633Sdim/**
2969341825Sdim * Describe the "thread-local storage (TLS) kind" of the declaration
2970327952Sdim * referred to by a cursor.
2971327952Sdim */
2972327952Sdimenum CXTLSKind {
2973327952Sdim  CXTLS_None = 0,
2974327952Sdim  CXTLS_Dynamic,
2975327952Sdim  CXTLS_Static
2976327952Sdim};
2977327952Sdim
2978327952Sdim/**
2979341825Sdim * Determine the "thread-local storage (TLS) kind" of the declaration
2980327952Sdim * referred to by a cursor.
2981327952Sdim */
2982327952SdimCINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2983327952Sdim
2984327952Sdim/**
2985341825Sdim * Returns the translation unit that a cursor originated from.
2986226633Sdim */
2987226633SdimCINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor);
2988218893Sdim
2989207619Srdivacky/**
2990341825Sdim * A fast container representing a set of CXCursors.
2991218893Sdim */
2992218893Sdimtypedef struct CXCursorSetImpl *CXCursorSet;
2993218893Sdim
2994218893Sdim/**
2995341825Sdim * Creates an empty CXCursorSet.
2996218893Sdim */
2997249423SdimCINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void);
2998218893Sdim
2999218893Sdim/**
3000341825Sdim * Disposes a CXCursorSet and releases its associated memory.
3001218893Sdim */
3002218893SdimCINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
3003218893Sdim
3004218893Sdim/**
3005341825Sdim * Queries a CXCursorSet to see if it contains a specific CXCursor.
3006218893Sdim *
3007218893Sdim * \returns non-zero if the set contains the specified cursor.
3008218893Sdim*/
3009218893SdimCINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
3010218893Sdim                                                   CXCursor cursor);
3011218893Sdim
3012218893Sdim/**
3013341825Sdim * Inserts a CXCursor into a CXCursorSet.
3014218893Sdim *
3015218893Sdim * \returns zero if the CXCursor was already in the set, and non-zero otherwise.
3016218893Sdim*/
3017218893SdimCINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
3018218893Sdim                                                 CXCursor cursor);
3019218893Sdim
3020218893Sdim/**
3021341825Sdim * Determine the semantic parent of the given cursor.
3022218893Sdim *
3023218893Sdim * The semantic parent of a cursor is the cursor that semantically contains
3024218893Sdim * the given \p cursor. For many declarations, the lexical and semantic parents
3025341825Sdim * are equivalent (the lexical parent is returned by
3026218893Sdim * \c clang_getCursorLexicalParent()). They diverge when declarations or
3027218893Sdim * definitions are provided out-of-line. For example:
3028218893Sdim *
3029218893Sdim * \code
3030218893Sdim * class C {
3031218893Sdim *  void f();
3032218893Sdim * };
3033218893Sdim *
3034218893Sdim * void C::f() { }
3035218893Sdim * \endcode
3036218893Sdim *
3037276479Sdim * In the out-of-line definition of \c C::f, the semantic parent is
3038218893Sdim * the class \c C, of which this function is a member. The lexical parent is
3039218893Sdim * the place where the declaration actually occurs in the source code; in this
3040276479Sdim * case, the definition occurs in the translation unit. In general, the
3041218893Sdim * lexical parent for a given entity can change without affecting the semantics
3042218893Sdim * of the program, and the lexical parent of different declarations of the
3043218893Sdim * same entity may be different. Changing the semantic parent of a declaration,
3044218893Sdim * on the other hand, can have a major impact on semantics, and redeclarations
3045218893Sdim * of a particular entity should all have the same semantic context.
3046218893Sdim *
3047218893Sdim * In the example above, both declarations of \c C::f have \c C as their
3048218893Sdim * semantic context, while the lexical context of the first \c C::f is \c C
3049218893Sdim * and the lexical context of the second \c C::f is the translation unit.
3050218893Sdim *
3051218893Sdim * For global declarations, the semantic parent is the translation unit.
3052218893Sdim */
3053218893SdimCINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
3054218893Sdim
3055218893Sdim/**
3056341825Sdim * Determine the lexical parent of the given cursor.
3057218893Sdim *
3058218893Sdim * The lexical parent of a cursor is the cursor in which the given \p cursor
3059218893Sdim * was actually written. For many declarations, the lexical and semantic parents
3060341825Sdim * are equivalent (the semantic parent is returned by
3061218893Sdim * \c clang_getCursorSemanticParent()). They diverge when declarations or
3062218893Sdim * definitions are provided out-of-line. For example:
3063218893Sdim *
3064218893Sdim * \code
3065218893Sdim * class C {
3066218893Sdim *  void f();
3067218893Sdim * };
3068218893Sdim *
3069218893Sdim * void C::f() { }
3070218893Sdim * \endcode
3071218893Sdim *
3072276479Sdim * In the out-of-line definition of \c C::f, the semantic parent is
3073218893Sdim * the class \c C, of which this function is a member. The lexical parent is
3074218893Sdim * the place where the declaration actually occurs in the source code; in this
3075276479Sdim * case, the definition occurs in the translation unit. In general, the
3076218893Sdim * lexical parent for a given entity can change without affecting the semantics
3077218893Sdim * of the program, and the lexical parent of different declarations of the
3078218893Sdim * same entity may be different. Changing the semantic parent of a declaration,
3079218893Sdim * on the other hand, can have a major impact on semantics, and redeclarations
3080218893Sdim * of a particular entity should all have the same semantic context.
3081218893Sdim *
3082218893Sdim * In the example above, both declarations of \c C::f have \c C as their
3083218893Sdim * semantic context, while the lexical context of the first \c C::f is \c C
3084218893Sdim * and the lexical context of the second \c C::f is the translation unit.
3085218893Sdim *
3086218893Sdim * For declarations written in the global scope, the lexical parent is
3087218893Sdim * the translation unit.
3088218893Sdim */
3089218893SdimCINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
3090218893Sdim
3091218893Sdim/**
3092341825Sdim * Determine the set of methods that are overridden by the given
3093218893Sdim * method.
3094218893Sdim *
3095218893Sdim * In both Objective-C and C++, a method (aka virtual member function,
3096218893Sdim * in C++) can override a virtual method in a base class. For
3097218893Sdim * Objective-C, a method is said to override any method in the class's
3098234353Sdim * base class, its protocols, or its categories' protocols, that has the same
3099234353Sdim * selector and is of the same kind (class or instance).
3100234353Sdim * If no such method exists, the search continues to the class's superclass,
3101234353Sdim * its protocols, and its categories, and so on. A method from an Objective-C
3102234353Sdim * implementation is considered to override the same methods as its
3103234353Sdim * corresponding method in the interface.
3104218893Sdim *
3105218893Sdim * For C++, a virtual member function overrides any virtual member
3106218893Sdim * function with the same signature that occurs in its base
3107218893Sdim * classes. With multiple inheritance, a virtual member function can
3108218893Sdim * override several virtual member functions coming from different
3109218893Sdim * base classes.
3110218893Sdim *
3111218893Sdim * In all cases, this function determines the immediate overridden
3112218893Sdim * method, rather than all of the overridden methods. For example, if
3113218893Sdim * a method is originally declared in a class A, then overridden in B
3114218893Sdim * (which in inherits from A) and also in C (which inherited from B),
3115218893Sdim * then the only overridden method returned from this function when
3116218893Sdim * invoked on C's method will be B's method. The client may then
3117218893Sdim * invoke this function again, given the previously-found overridden
3118218893Sdim * methods, to map out the complete method-override set.
3119218893Sdim *
3120218893Sdim * \param cursor A cursor representing an Objective-C or C++
3121218893Sdim * method. This routine will compute the set of methods that this
3122218893Sdim * method overrides.
3123341825Sdim *
3124218893Sdim * \param overridden A pointer whose pointee will be replaced with a
3125218893Sdim * pointer to an array of cursors, representing the set of overridden
3126218893Sdim * methods. If there are no overridden methods, the pointee will be
3127341825Sdim * set to NULL. The pointee must be freed via a call to
3128218893Sdim * \c clang_disposeOverriddenCursors().
3129218893Sdim *
3130218893Sdim * \param num_overridden A pointer to the number of overridden
3131218893Sdim * functions, will be set to the number of overridden functions in the
3132218893Sdim * array pointed to by \p overridden.
3133218893Sdim */
3134341825SdimCINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
3135218893Sdim                                               CXCursor **overridden,
3136218893Sdim                                               unsigned *num_overridden);
3137218893Sdim
3138218893Sdim/**
3139341825Sdim * Free the set of overridden cursors returned by \c
3140218893Sdim * clang_getOverriddenCursors().
3141218893Sdim */
3142218893SdimCINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
3143218893Sdim
3144218893Sdim/**
3145341825Sdim * Retrieve the file that is included by the given inclusion directive
3146218893Sdim * cursor.
3147218893Sdim */
3148218893SdimCINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
3149341825Sdim
3150218893Sdim/**
3151202879Srdivacky * @}
3152202879Srdivacky */
3153203955Srdivacky
3154202879Srdivacky/**
3155202879Srdivacky * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
3156202879Srdivacky *
3157202879Srdivacky * Cursors represent a location within the Abstract Syntax Tree (AST). These
3158202879Srdivacky * routines help map between cursors and the physical locations where the
3159202879Srdivacky * described entities occur in the source code. The mapping is provided in
3160202879Srdivacky * both directions, so one can map from source code to the AST and back.
3161202879Srdivacky *
3162202879Srdivacky * @{
3163202879Srdivacky */
3164203955Srdivacky
3165202879Srdivacky/**
3166341825Sdim * Map a source location to the cursor that describes the entity at that
3167202879Srdivacky * location in the source code.
3168202879Srdivacky *
3169202879Srdivacky * clang_getCursor() maps an arbitrary source location within a translation
3170202879Srdivacky * unit down to the most specific cursor that describes the entity at that
3171203955Srdivacky * location. For example, given an expression \c x + y, invoking
3172202879Srdivacky * clang_getCursor() with a source location pointing to "x" will return the
3173203955Srdivacky * cursor for "x"; similarly for "y". If the cursor points anywhere between
3174202879Srdivacky * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
3175202879Srdivacky * will return a cursor referring to the "+" expression.
3176202879Srdivacky *
3177202879Srdivacky * \returns a cursor representing the entity at the given source location, or
3178202879Srdivacky * a NULL cursor if no such entity can be found.
3179202879Srdivacky */
3180202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
3181203955Srdivacky
3182202879Srdivacky/**
3183341825Sdim * Retrieve the physical location of the source constructor referenced
3184202879Srdivacky * by the given cursor.
3185202879Srdivacky *
3186202879Srdivacky * The location of a declaration is typically the location of the name of that
3187203955Srdivacky * declaration, where the name of that declaration would occur if it is
3188203955Srdivacky * unnamed, or some keyword that introduces that particular declaration.
3189203955Srdivacky * The location of a reference is where that reference occurs within the
3190202879Srdivacky * source code.
3191202879Srdivacky */
3192202879SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
3193199482Srdivacky
3194202879Srdivacky/**
3195341825Sdim * Retrieve the physical extent of the source construct referenced by
3196202879Srdivacky * the given cursor.
3197202879Srdivacky *
3198202879Srdivacky * The extent of a cursor starts with the file/line/column pointing at the
3199202879Srdivacky * first character within the source construct that the cursor refers to and
3200276479Sdim * ends with the last character within that source construct. For a
3201202879Srdivacky * declaration, the extent covers the declaration itself. For a reference,
3202202879Srdivacky * the extent covers the location of the reference (e.g., where the referenced
3203202879Srdivacky * entity was actually used).
3204202879Srdivacky */
3205202879SrdivackyCINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
3206202879Srdivacky
3207202879Srdivacky/**
3208202879Srdivacky * @}
3209202879Srdivacky */
3210341825Sdim
3211202879Srdivacky/**
3212208600Srdivacky * \defgroup CINDEX_TYPES Type information for CXCursors
3213208600Srdivacky *
3214208600Srdivacky * @{
3215208600Srdivacky */
3216208600Srdivacky
3217208600Srdivacky/**
3218341825Sdim * Describes the kind of type
3219208600Srdivacky */
3220208600Srdivackyenum CXTypeKind {
3221208600Srdivacky  /**
3222341825Sdim   * Represents an invalid type (e.g., where no type is available).
3223208600Srdivacky   */
3224208600Srdivacky  CXType_Invalid = 0,
3225208600Srdivacky
3226208600Srdivacky  /**
3227341825Sdim   * A type whose specific kind is not exposed via this
3228208600Srdivacky   * interface.
3229208600Srdivacky   */
3230208600Srdivacky  CXType_Unexposed = 1,
3231208600Srdivacky
3232208600Srdivacky  /* Builtin types */
3233208600Srdivacky  CXType_Void = 2,
3234208600Srdivacky  CXType_Bool = 3,
3235208600Srdivacky  CXType_Char_U = 4,
3236208600Srdivacky  CXType_UChar = 5,
3237208600Srdivacky  CXType_Char16 = 6,
3238208600Srdivacky  CXType_Char32 = 7,
3239208600Srdivacky  CXType_UShort = 8,
3240208600Srdivacky  CXType_UInt = 9,
3241208600Srdivacky  CXType_ULong = 10,
3242208600Srdivacky  CXType_ULongLong = 11,
3243208600Srdivacky  CXType_UInt128 = 12,
3244208600Srdivacky  CXType_Char_S = 13,
3245208600Srdivacky  CXType_SChar = 14,
3246208600Srdivacky  CXType_WChar = 15,
3247208600Srdivacky  CXType_Short = 16,
3248208600Srdivacky  CXType_Int = 17,
3249208600Srdivacky  CXType_Long = 18,
3250208600Srdivacky  CXType_LongLong = 19,
3251208600Srdivacky  CXType_Int128 = 20,
3252208600Srdivacky  CXType_Float = 21,
3253208600Srdivacky  CXType_Double = 22,
3254208600Srdivacky  CXType_LongDouble = 23,
3255208600Srdivacky  CXType_NullPtr = 24,
3256208600Srdivacky  CXType_Overload = 25,
3257208600Srdivacky  CXType_Dependent = 26,
3258208600Srdivacky  CXType_ObjCId = 27,
3259208600Srdivacky  CXType_ObjCClass = 28,
3260208600Srdivacky  CXType_ObjCSel = 29,
3261309124Sdim  CXType_Float128 = 30,
3262321369Sdim  CXType_Half = 31,
3263327952Sdim  CXType_Float16 = 32,
3264341825Sdim  CXType_ShortAccum = 33,
3265341825Sdim  CXType_Accum = 34,
3266341825Sdim  CXType_LongAccum = 35,
3267341825Sdim  CXType_UShortAccum = 36,
3268341825Sdim  CXType_UAccum = 37,
3269341825Sdim  CXType_ULongAccum = 38,
3270208600Srdivacky  CXType_FirstBuiltin = CXType_Void,
3271341825Sdim  CXType_LastBuiltin = CXType_ULongAccum,
3272208600Srdivacky
3273208600Srdivacky  CXType_Complex = 100,
3274208600Srdivacky  CXType_Pointer = 101,
3275208600Srdivacky  CXType_BlockPointer = 102,
3276208600Srdivacky  CXType_LValueReference = 103,
3277208600Srdivacky  CXType_RValueReference = 104,
3278208600Srdivacky  CXType_Record = 105,
3279208600Srdivacky  CXType_Enum = 106,
3280208600Srdivacky  CXType_Typedef = 107,
3281208600Srdivacky  CXType_ObjCInterface = 108,
3282210299Sed  CXType_ObjCObjectPointer = 109,
3283210299Sed  CXType_FunctionNoProto = 110,
3284226633Sdim  CXType_FunctionProto = 111,
3285234353Sdim  CXType_ConstantArray = 112,
3286261991Sdim  CXType_Vector = 113,
3287261991Sdim  CXType_IncompleteArray = 114,
3288261991Sdim  CXType_VariableArray = 115,
3289261991Sdim  CXType_DependentSizedArray = 116,
3290296417Sdim  CXType_MemberPointer = 117,
3291309124Sdim  CXType_Auto = 118,
3292309124Sdim
3293309124Sdim  /**
3294341825Sdim   * Represents a type that was referred to using an elaborated type keyword.
3295309124Sdim   *
3296309124Sdim   * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
3297309124Sdim   */
3298321369Sdim  CXType_Elaborated = 119,
3299321369Sdim
3300321369Sdim  /* OpenCL PipeType. */
3301321369Sdim  CXType_Pipe = 120,
3302321369Sdim
3303321369Sdim  /* OpenCL builtin types. */
3304321369Sdim  CXType_OCLImage1dRO = 121,
3305321369Sdim  CXType_OCLImage1dArrayRO = 122,
3306321369Sdim  CXType_OCLImage1dBufferRO = 123,
3307321369Sdim  CXType_OCLImage2dRO = 124,
3308321369Sdim  CXType_OCLImage2dArrayRO = 125,
3309321369Sdim  CXType_OCLImage2dDepthRO = 126,
3310321369Sdim  CXType_OCLImage2dArrayDepthRO = 127,
3311321369Sdim  CXType_OCLImage2dMSAARO = 128,
3312321369Sdim  CXType_OCLImage2dArrayMSAARO = 129,
3313321369Sdim  CXType_OCLImage2dMSAADepthRO = 130,
3314321369Sdim  CXType_OCLImage2dArrayMSAADepthRO = 131,
3315321369Sdim  CXType_OCLImage3dRO = 132,
3316321369Sdim  CXType_OCLImage1dWO = 133,
3317321369Sdim  CXType_OCLImage1dArrayWO = 134,
3318321369Sdim  CXType_OCLImage1dBufferWO = 135,
3319321369Sdim  CXType_OCLImage2dWO = 136,
3320321369Sdim  CXType_OCLImage2dArrayWO = 137,
3321321369Sdim  CXType_OCLImage2dDepthWO = 138,
3322321369Sdim  CXType_OCLImage2dArrayDepthWO = 139,
3323321369Sdim  CXType_OCLImage2dMSAAWO = 140,
3324321369Sdim  CXType_OCLImage2dArrayMSAAWO = 141,
3325321369Sdim  CXType_OCLImage2dMSAADepthWO = 142,
3326321369Sdim  CXType_OCLImage2dArrayMSAADepthWO = 143,
3327321369Sdim  CXType_OCLImage3dWO = 144,
3328321369Sdim  CXType_OCLImage1dRW = 145,
3329321369Sdim  CXType_OCLImage1dArrayRW = 146,
3330321369Sdim  CXType_OCLImage1dBufferRW = 147,
3331321369Sdim  CXType_OCLImage2dRW = 148,
3332321369Sdim  CXType_OCLImage2dArrayRW = 149,
3333321369Sdim  CXType_OCLImage2dDepthRW = 150,
3334321369Sdim  CXType_OCLImage2dArrayDepthRW = 151,
3335321369Sdim  CXType_OCLImage2dMSAARW = 152,
3336321369Sdim  CXType_OCLImage2dArrayMSAARW = 153,
3337321369Sdim  CXType_OCLImage2dMSAADepthRW = 154,
3338321369Sdim  CXType_OCLImage2dArrayMSAADepthRW = 155,
3339321369Sdim  CXType_OCLImage3dRW = 156,
3340321369Sdim  CXType_OCLSampler = 157,
3341321369Sdim  CXType_OCLEvent = 158,
3342321369Sdim  CXType_OCLQueue = 159,
3343344779Sdim  CXType_OCLReserveID = 160,
3344344779Sdim
3345344779Sdim  CXType_ObjCObject = 161,
3346344779Sdim  CXType_ObjCTypeParam = 162,
3347344779Sdim  CXType_Attributed = 163,
3348344779Sdim
3349344779Sdim  CXType_OCLIntelSubgroupAVCMcePayload = 164,
3350344779Sdim  CXType_OCLIntelSubgroupAVCImePayload = 165,
3351344779Sdim  CXType_OCLIntelSubgroupAVCRefPayload = 166,
3352344779Sdim  CXType_OCLIntelSubgroupAVCSicPayload = 167,
3353344779Sdim  CXType_OCLIntelSubgroupAVCMceResult = 168,
3354344779Sdim  CXType_OCLIntelSubgroupAVCImeResult = 169,
3355344779Sdim  CXType_OCLIntelSubgroupAVCRefResult = 170,
3356344779Sdim  CXType_OCLIntelSubgroupAVCSicResult = 171,
3357344779Sdim  CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
3358344779Sdim  CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
3359344779Sdim  CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
3360344779Sdim
3361353358Sdim  CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175,
3362353358Sdim
3363353358Sdim  CXType_ExtVector = 176
3364208600Srdivacky};
3365208600Srdivacky
3366208600Srdivacky/**
3367341825Sdim * Describes the calling convention of a function type
3368234353Sdim */
3369234353Sdimenum CXCallingConv {
3370234353Sdim  CXCallingConv_Default = 0,
3371234353Sdim  CXCallingConv_C = 1,
3372234353Sdim  CXCallingConv_X86StdCall = 2,
3373234353Sdim  CXCallingConv_X86FastCall = 3,
3374234353Sdim  CXCallingConv_X86ThisCall = 4,
3375234353Sdim  CXCallingConv_X86Pascal = 5,
3376234353Sdim  CXCallingConv_AAPCS = 6,
3377234353Sdim  CXCallingConv_AAPCS_VFP = 7,
3378314564Sdim  CXCallingConv_X86RegCall = 8,
3379249423Sdim  CXCallingConv_IntelOclBicc = 9,
3380321369Sdim  CXCallingConv_Win64 = 10,
3381322740Sdim  /* Alias for compatibility with older versions of API. */
3382322740Sdim  CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
3383256030Sdim  CXCallingConv_X86_64SysV = 11,
3384280031Sdim  CXCallingConv_X86VectorCall = 12,
3385309124Sdim  CXCallingConv_Swift = 13,
3386309124Sdim  CXCallingConv_PreserveMost = 14,
3387309124Sdim  CXCallingConv_PreserveAll = 15,
3388344779Sdim  CXCallingConv_AArch64VectorCall = 16,
3389234353Sdim
3390234353Sdim  CXCallingConv_Invalid = 100,
3391234353Sdim  CXCallingConv_Unexposed = 200
3392234353Sdim};
3393234353Sdim
3394234353Sdim/**
3395341825Sdim * The type of an element in the abstract syntax tree.
3396208600Srdivacky *
3397208600Srdivacky */
3398208600Srdivackytypedef struct {
3399208600Srdivacky  enum CXTypeKind kind;
3400208600Srdivacky  void *data[2];
3401208600Srdivacky} CXType;
3402208600Srdivacky
3403208600Srdivacky/**
3404341825Sdim * Retrieve the type of a CXCursor (if any).
3405208600Srdivacky */
3406208600SrdivackyCINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
3407208600Srdivacky
3408208600Srdivacky/**
3409341825Sdim * Pretty-print the underlying type using the rules of the
3410249423Sdim * language of the translation unit from which it came.
3411249423Sdim *
3412249423Sdim * If the type is invalid, an empty string is returned.
3413249423Sdim */
3414249423SdimCINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
3415249423Sdim
3416249423Sdim/**
3417341825Sdim * Retrieve the underlying type of a typedef declaration.
3418234353Sdim *
3419234353Sdim * If the cursor does not reference a typedef declaration, an invalid type is
3420234353Sdim * returned.
3421234353Sdim */
3422234353SdimCINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C);
3423234353Sdim
3424234353Sdim/**
3425341825Sdim * Retrieve the integer type of an enum declaration.
3426234353Sdim *
3427234353Sdim * If the cursor does not reference an enum declaration, an invalid type is
3428234353Sdim * returned.
3429234353Sdim */
3430234353SdimCINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
3431234353Sdim
3432234353Sdim/**
3433341825Sdim * Retrieve the integer value of an enum constant declaration as a signed
3434234353Sdim *  long long.
3435234353Sdim *
3436234353Sdim * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned.
3437234353Sdim * Since this is also potentially a valid constant value, the kind of the cursor
3438234353Sdim * must be verified before calling this function.
3439234353Sdim */
3440234353SdimCINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
3441234353Sdim
3442234353Sdim/**
3443341825Sdim * Retrieve the integer value of an enum constant declaration as an unsigned
3444234353Sdim *  long long.
3445234353Sdim *
3446234353Sdim * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned.
3447234353Sdim * Since this is also potentially a valid constant value, the kind of the cursor
3448234353Sdim * must be verified before calling this function.
3449234353Sdim */
3450234353SdimCINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
3451234353Sdim
3452234353Sdim/**
3453341825Sdim * Retrieve the bit width of a bit field declaration as an integer.
3454249423Sdim *
3455249423Sdim * If a cursor that is not a bit field declaration is passed in, -1 is returned.
3456249423Sdim */
3457249423SdimCINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
3458249423Sdim
3459249423Sdim/**
3460341825Sdim * Retrieve the number of non-variadic arguments associated with a given
3461234353Sdim * cursor.
3462234353Sdim *
3463249423Sdim * The number of arguments can be determined for calls as well as for
3464249423Sdim * declarations of functions or methods. For other cursors -1 is returned.
3465234353Sdim */
3466234353SdimCINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C);
3467234353Sdim
3468234353Sdim/**
3469341825Sdim * Retrieve the argument cursor of a function or method.
3470234353Sdim *
3471249423Sdim * The argument cursor can be determined for calls as well as for declarations
3472249423Sdim * of functions or methods. For other cursors and for invalid indices, an
3473249423Sdim * invalid cursor is returned.
3474234353Sdim */
3475234353SdimCINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i);
3476234353Sdim
3477234353Sdim/**
3478341825Sdim * Describes the kind of a template argument.
3479280031Sdim *
3480280031Sdim * See the definition of llvm::clang::TemplateArgument::ArgKind for full
3481280031Sdim * element descriptions.
3482280031Sdim */
3483280031Sdimenum CXTemplateArgumentKind {
3484280031Sdim  CXTemplateArgumentKind_Null,
3485280031Sdim  CXTemplateArgumentKind_Type,
3486280031Sdim  CXTemplateArgumentKind_Declaration,
3487280031Sdim  CXTemplateArgumentKind_NullPtr,
3488280031Sdim  CXTemplateArgumentKind_Integral,
3489280031Sdim  CXTemplateArgumentKind_Template,
3490280031Sdim  CXTemplateArgumentKind_TemplateExpansion,
3491280031Sdim  CXTemplateArgumentKind_Expression,
3492280031Sdim  CXTemplateArgumentKind_Pack,
3493280031Sdim  /* Indicates an error case, preventing the kind from being deduced. */
3494280031Sdim  CXTemplateArgumentKind_Invalid
3495280031Sdim};
3496280031Sdim
3497280031Sdim/**
3498341825Sdim *Returns the number of template args of a function decl representing a
3499280031Sdim * template specialization.
3500280031Sdim *
3501280031Sdim * If the argument cursor cannot be converted into a template function
3502280031Sdim * declaration, -1 is returned.
3503280031Sdim *
3504280031Sdim * For example, for the following declaration and specialization:
3505280031Sdim *   template <typename T, int kInt, bool kBool>
3506280031Sdim *   void foo() { ... }
3507280031Sdim *
3508280031Sdim *   template <>
3509280031Sdim *   void foo<float, -7, true>();
3510280031Sdim *
3511280031Sdim * The value 3 would be returned from this call.
3512280031Sdim */
3513280031SdimCINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
3514280031Sdim
3515280031Sdim/**
3516341825Sdim * Retrieve the kind of the I'th template argument of the CXCursor C.
3517280031Sdim *
3518280031Sdim * If the argument CXCursor does not represent a FunctionDecl, an invalid
3519280031Sdim * template argument kind is returned.
3520280031Sdim *
3521280031Sdim * For example, for the following declaration and specialization:
3522280031Sdim *   template <typename T, int kInt, bool kBool>
3523280031Sdim *   void foo() { ... }
3524280031Sdim *
3525280031Sdim *   template <>
3526280031Sdim *   void foo<float, -7, true>();
3527280031Sdim *
3528280031Sdim * For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
3529280031Sdim * respectively.
3530280031Sdim */
3531280031SdimCINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
3532280031Sdim    CXCursor C, unsigned I);
3533280031Sdim
3534280031Sdim/**
3535341825Sdim * Retrieve a CXType representing the type of a TemplateArgument of a
3536280031Sdim *  function decl representing a template specialization.
3537280031Sdim *
3538280031Sdim * If the argument CXCursor does not represent a FunctionDecl whose I'th
3539280031Sdim * template argument has a kind of CXTemplateArgKind_Integral, an invalid type
3540280031Sdim * is returned.
3541280031Sdim *
3542280031Sdim * For example, for the following declaration and specialization:
3543280031Sdim *   template <typename T, int kInt, bool kBool>
3544280031Sdim *   void foo() { ... }
3545280031Sdim *
3546280031Sdim *   template <>
3547280031Sdim *   void foo<float, -7, true>();
3548280031Sdim *
3549280031Sdim * If called with I = 0, "float", will be returned.
3550280031Sdim * Invalid types will be returned for I == 1 or 2.
3551280031Sdim */
3552280031SdimCINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C,
3553280031Sdim                                                           unsigned I);
3554280031Sdim
3555280031Sdim/**
3556341825Sdim * Retrieve the value of an Integral TemplateArgument (of a function
3557280031Sdim *  decl representing a template specialization) as a signed long long.
3558280031Sdim *
3559280031Sdim * It is undefined to call this function on a CXCursor that does not represent a
3560280031Sdim * FunctionDecl or whose I'th template argument is not an integral value.
3561280031Sdim *
3562280031Sdim * For example, for the following declaration and specialization:
3563280031Sdim *   template <typename T, int kInt, bool kBool>
3564280031Sdim *   void foo() { ... }
3565280031Sdim *
3566280031Sdim *   template <>
3567280031Sdim *   void foo<float, -7, true>();
3568280031Sdim *
3569280031Sdim * If called with I = 1 or 2, -7 or true will be returned, respectively.
3570280031Sdim * For I == 0, this function's behavior is undefined.
3571280031Sdim */
3572280031SdimCINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
3573280031Sdim                                                               unsigned I);
3574280031Sdim
3575280031Sdim/**
3576341825Sdim * Retrieve the value of an Integral TemplateArgument (of a function
3577280031Sdim *  decl representing a template specialization) as an unsigned long long.
3578280031Sdim *
3579280031Sdim * It is undefined to call this function on a CXCursor that does not represent a
3580280031Sdim * FunctionDecl or whose I'th template argument is not an integral value.
3581280031Sdim *
3582280031Sdim * For example, for the following declaration and specialization:
3583280031Sdim *   template <typename T, int kInt, bool kBool>
3584280031Sdim *   void foo() { ... }
3585280031Sdim *
3586280031Sdim *   template <>
3587280031Sdim *   void foo<float, 2147483649, true>();
3588280031Sdim *
3589280031Sdim * If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
3590280031Sdim * For I == 0, this function's behavior is undefined.
3591280031Sdim */
3592280031SdimCINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
3593280031Sdim    CXCursor C, unsigned I);
3594280031Sdim
3595280031Sdim/**
3596341825Sdim * Determine whether two CXTypes represent the same type.
3597208600Srdivacky *
3598239462Sdim * \returns non-zero if the CXTypes represent the same type and
3599239462Sdim *          zero otherwise.
3600208600Srdivacky */
3601208600SrdivackyCINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
3602208600Srdivacky
3603208600Srdivacky/**
3604341825Sdim * Return the canonical type for a CXType.
3605208600Srdivacky *
3606208600Srdivacky * Clang's type system explicitly models typedefs and all the ways
3607208600Srdivacky * a specific type can be represented.  The canonical type is the underlying
3608208600Srdivacky * type with all the "sugar" removed.  For example, if 'T' is a typedef
3609208600Srdivacky * for 'int', the canonical type for 'T' would be 'int'.
3610208600Srdivacky */
3611208600SrdivackyCINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
3612208600Srdivacky
3613208600Srdivacky/**
3614341825Sdim * Determine whether a CXType has the "const" qualifier set,
3615239462Sdim * without looking through typedefs that may have added "const" at a
3616239462Sdim * different level.
3617218893Sdim */
3618218893SdimCINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T);
3619218893Sdim
3620218893Sdim/**
3621341825Sdim * Determine whether a  CXCursor that is a macro, is
3622309124Sdim * function like.
3623309124Sdim */
3624309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C);
3625309124Sdim
3626309124Sdim/**
3627341825Sdim * Determine whether a  CXCursor that is a macro, is a
3628309124Sdim * builtin one.
3629309124Sdim */
3630309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C);
3631309124Sdim
3632309124Sdim/**
3633341825Sdim * Determine whether a  CXCursor that is a function declaration, is an
3634309124Sdim * inline declaration.
3635309124Sdim */
3636309124SdimCINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C);
3637309124Sdim
3638309124Sdim/**
3639341825Sdim * Determine whether a CXType has the "volatile" qualifier set,
3640239462Sdim * without looking through typedefs that may have added "volatile" at
3641239462Sdim * a different level.
3642218893Sdim */
3643218893SdimCINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T);
3644218893Sdim
3645218893Sdim/**
3646341825Sdim * Determine whether a CXType has the "restrict" qualifier set,
3647239462Sdim * without looking through typedefs that may have added "restrict" at a
3648239462Sdim * different level.
3649218893Sdim */
3650218893SdimCINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
3651218893Sdim
3652218893Sdim/**
3653341825Sdim * Returns the address space of the given type.
3654321369Sdim */
3655321369SdimCINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
3656321369Sdim
3657321369Sdim/**
3658341825Sdim * Returns the typedef name of the given type.
3659321369Sdim */
3660321369SdimCINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
3661321369Sdim
3662321369Sdim/**
3663341825Sdim * For pointer types, returns the type of the pointee.
3664208600Srdivacky */
3665208600SrdivackyCINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
3666208600Srdivacky
3667208600Srdivacky/**
3668341825Sdim * Return the cursor for the declaration of the given type.
3669208600Srdivacky */
3670208600SrdivackyCINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
3671208600Srdivacky
3672218893Sdim/**
3673218893Sdim * Returns the Objective-C type encoding for the specified declaration.
3674218893Sdim */
3675218893SdimCINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C);
3676208600Srdivacky
3677208600Srdivacky/**
3678309124Sdim * Returns the Objective-C type encoding for the specified CXType.
3679309124Sdim */
3680341825SdimCINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type);
3681309124Sdim
3682309124Sdim/**
3683341825Sdim * Retrieve the spelling of a given CXTypeKind.
3684208600Srdivacky */
3685208600SrdivackyCINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
3686208600Srdivacky
3687208600Srdivacky/**
3688341825Sdim * Retrieve the calling convention associated with a function type.
3689234353Sdim *
3690234353Sdim * If a non-function type is passed in, CXCallingConv_Invalid is returned.
3691234353Sdim */
3692234353SdimCINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T);
3693234353Sdim
3694234353Sdim/**
3695341825Sdim * Retrieve the return type associated with a function type.
3696234353Sdim *
3697234353Sdim * If a non-function type is passed in, an invalid type is returned.
3698210299Sed */
3699210299SedCINDEX_LINKAGE CXType clang_getResultType(CXType T);
3700210299Sed
3701210299Sed/**
3702341825Sdim * Retrieve the exception specification type associated with a function type.
3703341825Sdim * This is a value of type CXCursor_ExceptionSpecificationKind.
3704321369Sdim *
3705321369Sdim * If a non-function type is passed in, an error code of -1 is returned.
3706321369Sdim */
3707321369SdimCINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T);
3708321369Sdim
3709321369Sdim/**
3710341825Sdim * Retrieve the number of non-variadic parameters associated with a
3711239462Sdim * function type.
3712234353Sdim *
3713234353Sdim * If a non-function type is passed in, -1 is returned.
3714210299Sed */
3715234353SdimCINDEX_LINKAGE int clang_getNumArgTypes(CXType T);
3716234353Sdim
3717234353Sdim/**
3718341825Sdim * Retrieve the type of a parameter of a function type.
3719234353Sdim *
3720239462Sdim * If a non-function type is passed in or the function does not have enough
3721239462Sdim * parameters, an invalid type is returned.
3722234353Sdim */
3723234353SdimCINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i);
3724234353Sdim
3725234353Sdim/**
3726344779Sdim * Retrieves the base type of the ObjCObjectType.
3727344779Sdim *
3728344779Sdim * If the type is not an ObjC object, an invalid type is returned.
3729344779Sdim */
3730344779SdimCINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T);
3731344779Sdim
3732344779Sdim/**
3733344779Sdim * Retrieve the number of protocol references associated with an ObjC object/id.
3734344779Sdim *
3735344779Sdim * If the type is not an ObjC object, 0 is returned.
3736344779Sdim */
3737344779SdimCINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T);
3738344779Sdim
3739344779Sdim/**
3740344779Sdim * Retrieve the decl for a protocol reference for an ObjC object/id.
3741344779Sdim *
3742344779Sdim * If the type is not an ObjC object or there are not enough protocol
3743344779Sdim * references, an invalid cursor is returned.
3744344779Sdim */
3745344779SdimCINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i);
3746344779Sdim
3747344779Sdim/**
3748344779Sdim * Retreive the number of type arguments associated with an ObjC object.
3749344779Sdim *
3750344779Sdim * If the type is not an ObjC object, 0 is returned.
3751344779Sdim */
3752344779SdimCINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T);
3753344779Sdim
3754344779Sdim/**
3755344779Sdim * Retrieve a type argument associated with an ObjC object.
3756344779Sdim *
3757344779Sdim * If the type is not an ObjC or the index is not valid,
3758344779Sdim * an invalid type is returned.
3759344779Sdim */
3760344779SdimCINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i);
3761344779Sdim
3762344779Sdim/**
3763341825Sdim * Return 1 if the CXType is a variadic function type, and 0 otherwise.
3764234353Sdim */
3765234353SdimCINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T);
3766234353Sdim
3767234353Sdim/**
3768341825Sdim * Retrieve the return type associated with a given cursor.
3769234353Sdim *
3770234353Sdim * This only returns a valid type if the cursor refers to a function or method.
3771234353Sdim */
3772210299SedCINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
3773210299Sed
3774210299Sed/**
3775341825Sdim * Retrieve the exception specification type associated with a given cursor.
3776341825Sdim * This is a value of type CXCursor_ExceptionSpecificationKind.
3777321369Sdim *
3778321369Sdim * This only returns a valid result if the cursor refers to a function or method.
3779321369Sdim */
3780321369SdimCINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
3781321369Sdim
3782321369Sdim/**
3783341825Sdim * Return 1 if the CXType is a POD (plain old data) type, and 0
3784212904Sdim *  otherwise.
3785212904Sdim */
3786212904SdimCINDEX_LINKAGE unsigned clang_isPODType(CXType T);
3787212904Sdim
3788212904Sdim/**
3789341825Sdim * Return the element type of an array, complex, or vector type.
3790234353Sdim *
3791234353Sdim * If a type is passed in that is not an array, complex, or vector type,
3792234353Sdim * an invalid type is returned.
3793234353Sdim */
3794234353SdimCINDEX_LINKAGE CXType clang_getElementType(CXType T);
3795234353Sdim
3796234353Sdim/**
3797341825Sdim * Return the number of elements of an array or vector type.
3798234353Sdim *
3799234353Sdim * If a type is passed in that is not an array or vector type,
3800234353Sdim * -1 is returned.
3801234353Sdim */
3802234353SdimCINDEX_LINKAGE long long clang_getNumElements(CXType T);
3803234353Sdim
3804234353Sdim/**
3805341825Sdim * Return the element type of an array type.
3806226633Sdim *
3807226633Sdim * If a non-array type is passed in, an invalid type is returned.
3808226633Sdim */
3809226633SdimCINDEX_LINKAGE CXType clang_getArrayElementType(CXType T);
3810226633Sdim
3811226633Sdim/**
3812341825Sdim * Return the array size of a constant array.
3813226633Sdim *
3814226633Sdim * If a non-array type is passed in, -1 is returned.
3815226633Sdim */
3816226633SdimCINDEX_LINKAGE long long clang_getArraySize(CXType T);
3817226633Sdim
3818226633Sdim/**
3819341825Sdim * Retrieve the type named by the qualified-id.
3820309124Sdim *
3821309124Sdim * If a non-elaborated type is passed in, an invalid type is returned.
3822309124Sdim */
3823309124SdimCINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
3824309124Sdim
3825309124Sdim/**
3826341825Sdim * Determine if a typedef is 'transparent' tag.
3827321369Sdim *
3828321369Sdim * A typedef is considered 'transparent' if it shares a name and spelling
3829321369Sdim * location with its underlying tag type, as is the case with the NS_ENUM macro.
3830321369Sdim *
3831321369Sdim * \returns non-zero if transparent and zero otherwise.
3832321369Sdim */
3833321369SdimCINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
3834321369Sdim
3835344779Sdimenum CXTypeNullabilityKind {
3836344779Sdim  /**
3837344779Sdim   * Values of this type can never be null.
3838344779Sdim   */
3839344779Sdim  CXTypeNullability_NonNull = 0,
3840344779Sdim  /**
3841344779Sdim   * Values of this type can be null.
3842344779Sdim   */
3843344779Sdim  CXTypeNullability_Nullable = 1,
3844344779Sdim  /**
3845344779Sdim   * Whether values of this type can be null is (explicitly)
3846344779Sdim   * unspecified. This captures a (fairly rare) case where we
3847344779Sdim   * can't conclude anything about the nullability of the type even
3848344779Sdim   * though it has been considered.
3849344779Sdim   */
3850344779Sdim  CXTypeNullability_Unspecified = 2,
3851344779Sdim  /**
3852344779Sdim   * Nullability is not applicable to this type.
3853344779Sdim   */
3854344779Sdim  CXTypeNullability_Invalid = 3
3855344779Sdim};
3856344779Sdim
3857321369Sdim/**
3858344779Sdim * Retrieve the nullability kind of a pointer type.
3859344779Sdim */
3860344779SdimCINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T);
3861344779Sdim
3862344779Sdim/**
3863341825Sdim * List the possible error codes for \c clang_Type_getSizeOf,
3864251662Sdim *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
3865251662Sdim *   \c clang_Cursor_getOffsetOf.
3866251662Sdim *
3867251662Sdim * A value of this enumeration type can be returned if the target type is not
3868251662Sdim * a valid argument to sizeof, alignof or offsetof.
3869251662Sdim */
3870251662Sdimenum CXTypeLayoutError {
3871251662Sdim  /**
3872341825Sdim   * Type is of kind CXType_Invalid.
3873251662Sdim   */
3874251662Sdim  CXTypeLayoutError_Invalid = -1,
3875251662Sdim  /**
3876341825Sdim   * The type is an incomplete Type.
3877251662Sdim   */
3878251662Sdim  CXTypeLayoutError_Incomplete = -2,
3879251662Sdim  /**
3880341825Sdim   * The type is a dependent Type.
3881251662Sdim   */
3882251662Sdim  CXTypeLayoutError_Dependent = -3,
3883251662Sdim  /**
3884341825Sdim   * The type is not a constant size type.
3885251662Sdim   */
3886251662Sdim  CXTypeLayoutError_NotConstantSize = -4,
3887251662Sdim  /**
3888341825Sdim   * The Field name is not valid for this record.
3889251662Sdim   */
3890353358Sdim  CXTypeLayoutError_InvalidFieldName = -5,
3891353358Sdim  /**
3892353358Sdim   * The type is undeduced.
3893353358Sdim   */
3894353358Sdim  CXTypeLayoutError_Undeduced = -6
3895251662Sdim};
3896251662Sdim
3897251662Sdim/**
3898341825Sdim * Return the alignment of a type in bytes as per C++[expr.alignof]
3899251662Sdim *   standard.
3900251662Sdim *
3901251662Sdim * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3902251662Sdim * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3903251662Sdim *   is returned.
3904251662Sdim * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3905251662Sdim *   returned.
3906251662Sdim * If the type declaration is not a constant size type,
3907251662Sdim *   CXTypeLayoutError_NotConstantSize is returned.
3908251662Sdim */
3909251662SdimCINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T);
3910251662Sdim
3911251662Sdim/**
3912341825Sdim * Return the class type of an member pointer type.
3913261991Sdim *
3914261991Sdim * If a non-member-pointer type is passed in, an invalid type is returned.
3915261991Sdim */
3916261991SdimCINDEX_LINKAGE CXType clang_Type_getClassType(CXType T);
3917261991Sdim
3918261991Sdim/**
3919341825Sdim * Return the size of a type in bytes as per C++[expr.sizeof] standard.
3920251662Sdim *
3921251662Sdim * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned.
3922251662Sdim * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete
3923251662Sdim *   is returned.
3924251662Sdim * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is
3925251662Sdim *   returned.
3926251662Sdim */
3927251662SdimCINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T);
3928251662Sdim
3929251662Sdim/**
3930341825Sdim * Return the offset of a field named S in a record of type T in bits
3931251662Sdim *   as it would be returned by __offsetof__ as per C++11[18.2p4]
3932251662Sdim *
3933251662Sdim * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid
3934251662Sdim *   is returned.
3935251662Sdim * If the field's type declaration is an incomplete type,
3936251662Sdim *   CXTypeLayoutError_Incomplete is returned.
3937251662Sdim * If the field's type declaration is a dependent type,
3938251662Sdim *   CXTypeLayoutError_Dependent is returned.
3939251662Sdim * If the field's name S is not found,
3940251662Sdim *   CXTypeLayoutError_InvalidFieldName is returned.
3941251662Sdim */
3942251662SdimCINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S);
3943251662Sdim
3944288943Sdim/**
3945344779Sdim * Return the type that was modified by this attributed type.
3946344779Sdim *
3947344779Sdim * If the type is not an attributed type, an invalid type is returned.
3948344779Sdim */
3949344779SdimCINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T);
3950344779Sdim
3951344779Sdim/**
3952341825Sdim * Return the offset of the field represented by the Cursor.
3953288943Sdim *
3954288943Sdim * If the cursor is not a field declaration, -1 is returned.
3955288943Sdim * If the cursor semantic parent is not a record field declaration,
3956288943Sdim *   CXTypeLayoutError_Invalid is returned.
3957288943Sdim * If the field's type declaration is an incomplete type,
3958288943Sdim *   CXTypeLayoutError_Incomplete is returned.
3959288943Sdim * If the field's type declaration is a dependent type,
3960288943Sdim *   CXTypeLayoutError_Dependent is returned.
3961288943Sdim * If the field's name S is not found,
3962288943Sdim *   CXTypeLayoutError_InvalidFieldName is returned.
3963288943Sdim */
3964288943SdimCINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C);
3965288943Sdim
3966288943Sdim/**
3967353358Sdim * Determine whether the given cursor represents an anonymous
3968353358Sdim * tag or namespace
3969353358Sdim */
3970353358SdimCINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C);
3971353358Sdim
3972353358Sdim/**
3973341825Sdim * Determine whether the given cursor represents an anonymous record
3974288943Sdim * declaration.
3975288943Sdim */
3976353358SdimCINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
3977288943Sdim
3978353358Sdim/**
3979353358Sdim * Determine whether the given cursor represents an inline namespace
3980353358Sdim * declaration.
3981353358Sdim */
3982353358SdimCINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
3983353358Sdim
3984261991Sdimenum CXRefQualifierKind {
3985341825Sdim  /** No ref-qualifier was provided. */
3986261991Sdim  CXRefQualifier_None = 0,
3987341825Sdim  /** An lvalue ref-qualifier was provided (\c &). */
3988261991Sdim  CXRefQualifier_LValue,
3989341825Sdim  /** An rvalue ref-qualifier was provided (\c &&). */
3990261991Sdim  CXRefQualifier_RValue
3991261991Sdim};
3992261991Sdim
3993251662Sdim/**
3994341825Sdim * Returns the number of template arguments for given template
3995314564Sdim * specialization, or -1 if type \c T is not a template specialization.
3996276479Sdim */
3997276479SdimCINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
3998276479Sdim
3999276479Sdim/**
4000341825Sdim * Returns the type template argument of a template class specialization
4001276479Sdim * at given index.
4002276479Sdim *
4003276479Sdim * This function only returns template type arguments and does not handle
4004276479Sdim * template template arguments or variadic packs.
4005276479Sdim */
4006276479SdimCINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
4007276479Sdim
4008276479Sdim/**
4009341825Sdim * Retrieve the ref-qualifier kind of a function or method.
4010261991Sdim *
4011261991Sdim * The ref-qualifier is returned for C++ functions or methods. For other types
4012261991Sdim * or non-C++ declarations, CXRefQualifier_None is returned.
4013261991Sdim */
4014261991SdimCINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T);
4015261991Sdim
4016261991Sdim/**
4017341825Sdim * Returns non-zero if the cursor specifies a Record member that is a
4018251662Sdim *   bitfield.
4019251662Sdim */
4020251662SdimCINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C);
4021251662Sdim
4022251662Sdim/**
4023341825Sdim * Returns 1 if the base class specified by the cursor with kind
4024212904Sdim *   CX_CXXBaseSpecifier is virtual.
4025212904Sdim */
4026212904SdimCINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
4027341825Sdim
4028212904Sdim/**
4029341825Sdim * Represents the C++ access control level to a base class for a
4030212904Sdim * cursor with kind CX_CXXBaseSpecifier.
4031212904Sdim */
4032212904Sdimenum CX_CXXAccessSpecifier {
4033212904Sdim  CX_CXXInvalidAccessSpecifier,
4034212904Sdim  CX_CXXPublic,
4035212904Sdim  CX_CXXProtected,
4036212904Sdim  CX_CXXPrivate
4037212904Sdim};
4038212904Sdim
4039212904Sdim/**
4040341825Sdim * Returns the access control level for the referenced object.
4041251662Sdim *
4042251662Sdim * If the cursor refers to a C++ declaration, its access control level within its
4043251662Sdim * parent scope is returned. Otherwise, if the cursor refers to a base specifier or
4044251662Sdim * access specifier, the specifier itself is returned.
4045212904Sdim */
4046212904SdimCINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
4047212904Sdim
4048212904Sdim/**
4049341825Sdim * Represents the storage classes as declared in the source. CX_SC_Invalid
4050280031Sdim * was added for the case that the passed cursor in not a declaration.
4051280031Sdim */
4052280031Sdimenum CX_StorageClass {
4053280031Sdim  CX_SC_Invalid,
4054280031Sdim  CX_SC_None,
4055280031Sdim  CX_SC_Extern,
4056280031Sdim  CX_SC_Static,
4057280031Sdim  CX_SC_PrivateExtern,
4058280031Sdim  CX_SC_OpenCLWorkGroupLocal,
4059280031Sdim  CX_SC_Auto,
4060280031Sdim  CX_SC_Register
4061280031Sdim};
4062280031Sdim
4063280031Sdim/**
4064341825Sdim * Returns the storage class for a function or variable declaration.
4065280031Sdim *
4066280031Sdim * If the passed in Cursor is not a function or variable declaration,
4067280031Sdim * CX_SC_Invalid is returned else the storage class.
4068280031Sdim */
4069280031SdimCINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor);
4070280031Sdim
4071280031Sdim/**
4072341825Sdim * Determine the number of overloaded declarations referenced by a
4073218893Sdim * \c CXCursor_OverloadedDeclRef cursor.
4074218893Sdim *
4075218893Sdim * \param cursor The cursor whose overloaded declarations are being queried.
4076218893Sdim *
4077218893Sdim * \returns The number of overloaded declarations referenced by \c cursor. If it
4078218893Sdim * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
4079218893Sdim */
4080218893SdimCINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
4081218893Sdim
4082218893Sdim/**
4083341825Sdim * Retrieve a cursor for one of the overloaded declarations referenced
4084218893Sdim * by a \c CXCursor_OverloadedDeclRef cursor.
4085218893Sdim *
4086218893Sdim * \param cursor The cursor whose overloaded declarations are being queried.
4087218893Sdim *
4088218893Sdim * \param index The zero-based index into the set of overloaded declarations in
4089218893Sdim * the cursor.
4090218893Sdim *
4091341825Sdim * \returns A cursor representing the declaration referenced by the given
4092341825Sdim * \c cursor at the specified \c index. If the cursor does not have an
4093218893Sdim * associated set of overloaded declarations, or if the index is out of bounds,
4094218893Sdim * returns \c clang_getNullCursor();
4095218893Sdim */
4096341825SdimCINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
4097218893Sdim                                                unsigned index);
4098341825Sdim
4099218893Sdim/**
4100208600Srdivacky * @}
4101208600Srdivacky */
4102341825Sdim
4103212904Sdim/**
4104212904Sdim * \defgroup CINDEX_ATTRIBUTES Information for attributes
4105212904Sdim *
4106212904Sdim * @{
4107212904Sdim */
4108208600Srdivacky
4109208600Srdivacky/**
4110341825Sdim * For cursors representing an iboutletcollection attribute,
4111212904Sdim *  this function returns the collection element type.
4112212904Sdim *
4113212904Sdim */
4114212904SdimCINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
4115212904Sdim
4116212904Sdim/**
4117212904Sdim * @}
4118212904Sdim */
4119212904Sdim
4120212904Sdim/**
4121202879Srdivacky * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
4122202879Srdivacky *
4123202879Srdivacky * These routines provide the ability to traverse the abstract syntax tree
4124202879Srdivacky * using cursors.
4125202879Srdivacky *
4126202879Srdivacky * @{
4127202879Srdivacky */
4128203955Srdivacky
4129202879Srdivacky/**
4130341825Sdim * Describes how the traversal of the children of a particular
4131202879Srdivacky * cursor should proceed after visiting a particular child cursor.
4132202879Srdivacky *
4133202879Srdivacky * A value of this enumeration type should be returned by each
4134202879Srdivacky * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
4135202879Srdivacky */
4136202879Srdivackyenum CXChildVisitResult {
4137202879Srdivacky  /**
4138341825Sdim   * Terminates the cursor traversal.
4139202879Srdivacky   */
4140202879Srdivacky  CXChildVisit_Break,
4141203955Srdivacky  /**
4142341825Sdim   * Continues the cursor traversal with the next sibling of
4143202879Srdivacky   * the cursor just visited, without visiting its children.
4144202879Srdivacky   */
4145202879Srdivacky  CXChildVisit_Continue,
4146202879Srdivacky  /**
4147341825Sdim   * Recursively traverse the children of this cursor, using
4148202879Srdivacky   * the same visitor and client data.
4149202879Srdivacky   */
4150202879Srdivacky  CXChildVisit_Recurse
4151202879Srdivacky};
4152202879Srdivacky
4153202879Srdivacky/**
4154341825Sdim * Visitor invoked for each cursor found by a traversal.
4155202879Srdivacky *
4156202879Srdivacky * This visitor function will be invoked for each cursor found by
4157202879Srdivacky * clang_visitCursorChildren(). Its first argument is the cursor being
4158202879Srdivacky * visited, its second argument is the parent visitor for that cursor,
4159202879Srdivacky * and its third argument is the client data provided to
4160202879Srdivacky * clang_visitCursorChildren().
4161202879Srdivacky *
4162202879Srdivacky * The visitor should return one of the \c CXChildVisitResult values
4163202879Srdivacky * to direct clang_visitCursorChildren().
4164202879Srdivacky */
4165203955Srdivackytypedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
4166203955Srdivacky                                                   CXCursor parent,
4167202879Srdivacky                                                   CXClientData client_data);
4168202879Srdivacky
4169202879Srdivacky/**
4170341825Sdim * Visit the children of a particular cursor.
4171202879Srdivacky *
4172202879Srdivacky * This function visits all the direct children of the given cursor,
4173202879Srdivacky * invoking the given \p visitor function with the cursors of each
4174202879Srdivacky * visited child. The traversal may be recursive, if the visitor returns
4175202879Srdivacky * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
4176202879Srdivacky * the visitor returns \c CXChildVisit_Break.
4177202879Srdivacky *
4178202879Srdivacky * \param parent the cursor whose child may be visited. All kinds of
4179203955Srdivacky * cursors can be visited, including invalid cursors (which, by
4180202879Srdivacky * definition, have no children).
4181202879Srdivacky *
4182202879Srdivacky * \param visitor the visitor function that will be invoked for each
4183202879Srdivacky * child of \p parent.
4184202879Srdivacky *
4185202879Srdivacky * \param client_data pointer data supplied by the client, which will
4186202879Srdivacky * be passed to the visitor each time it is invoked.
4187202879Srdivacky *
4188202879Srdivacky * \returns a non-zero value if the traversal was terminated
4189202879Srdivacky * prematurely by the visitor returning \c CXChildVisit_Break.
4190202879Srdivacky */
4191203955SrdivackyCINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
4192202879Srdivacky                                            CXCursorVisitor visitor,
4193202879Srdivacky                                            CXClientData client_data);
4194218893Sdim#ifdef __has_feature
4195218893Sdim#  if __has_feature(blocks)
4196218893Sdim/**
4197341825Sdim * Visitor invoked for each cursor found by a traversal.
4198218893Sdim *
4199218893Sdim * This visitor block will be invoked for each cursor found by
4200218893Sdim * clang_visitChildrenWithBlock(). Its first argument is the cursor being
4201218893Sdim * visited, its second argument is the parent visitor for that cursor.
4202218893Sdim *
4203218893Sdim * The visitor should return one of the \c CXChildVisitResult values
4204218893Sdim * to direct clang_visitChildrenWithBlock().
4205218893Sdim */
4206341825Sdimtypedef enum CXChildVisitResult
4207218893Sdim     (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
4208203955Srdivacky
4209202879Srdivacky/**
4210218893Sdim * Visits the children of a cursor using the specified block.  Behaves
4211218893Sdim * identically to clang_visitChildren() in all other respects.
4212218893Sdim */
4213309124SdimCINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
4214309124Sdim                                                    CXCursorVisitorBlock block);
4215218893Sdim#  endif
4216218893Sdim#endif
4217218893Sdim
4218218893Sdim/**
4219202879Srdivacky * @}
4220202879Srdivacky */
4221203955Srdivacky
4222202879Srdivacky/**
4223202879Srdivacky * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
4224202879Srdivacky *
4225203955Srdivacky * These routines provide the ability to determine references within and
4226202879Srdivacky * across translation units, by providing the names of the entities referenced
4227202879Srdivacky * by cursors, follow reference cursors to the declarations they reference,
4228202879Srdivacky * and associate declarations with their definitions.
4229202879Srdivacky *
4230202879Srdivacky * @{
4231202879Srdivacky */
4232203955Srdivacky
4233202879Srdivacky/**
4234341825Sdim * Retrieve a Unified Symbol Resolution (USR) for the entity referenced
4235202879Srdivacky * by the given cursor.
4236202879Srdivacky *
4237202879Srdivacky * A Unified Symbol Resolution (USR) is a string that identifies a particular
4238202879Srdivacky * entity (function, class, variable, etc.) within a program. USRs can be
4239202879Srdivacky * compared across translation units to determine, e.g., when references in
4240202879Srdivacky * one translation refer to an entity defined in another translation unit.
4241202879Srdivacky */
4242202879SrdivackyCINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
4243202879Srdivacky
4244202879Srdivacky/**
4245341825Sdim * Construct a USR for a specified Objective-C class.
4246205219Srdivacky */
4247205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
4248205219Srdivacky
4249205219Srdivacky/**
4250341825Sdim * Construct a USR for a specified Objective-C category.
4251205219Srdivacky */
4252205219SrdivackyCINDEX_LINKAGE CXString
4253205219Srdivacky  clang_constructUSR_ObjCCategory(const char *class_name,
4254205219Srdivacky                                 const char *category_name);
4255205219Srdivacky
4256205219Srdivacky/**
4257341825Sdim * Construct a USR for a specified Objective-C protocol.
4258205219Srdivacky */
4259205219SrdivackyCINDEX_LINKAGE CXString
4260205219Srdivacky  clang_constructUSR_ObjCProtocol(const char *protocol_name);
4261205219Srdivacky
4262205219Srdivacky/**
4263341825Sdim * Construct a USR for a specified Objective-C instance variable and
4264205219Srdivacky *   the USR for its containing class.
4265205219Srdivacky */
4266205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
4267205219Srdivacky                                                    CXString classUSR);
4268205219Srdivacky
4269205219Srdivacky/**
4270341825Sdim * Construct a USR for a specified Objective-C method and
4271205219Srdivacky *   the USR for its containing class.
4272205219Srdivacky */
4273205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
4274205219Srdivacky                                                      unsigned isInstanceMethod,
4275205219Srdivacky                                                      CXString classUSR);
4276205219Srdivacky
4277205219Srdivacky/**
4278341825Sdim * Construct a USR for a specified Objective-C property and the USR
4279205219Srdivacky *  for its containing class.
4280205219Srdivacky */
4281205219SrdivackyCINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
4282205219Srdivacky                                                        CXString classUSR);
4283205219Srdivacky
4284205219Srdivacky/**
4285341825Sdim * Retrieve a name for the entity referenced by this cursor.
4286202879Srdivacky */
4287199482SrdivackyCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
4288198398Srdivacky
4289218893Sdim/**
4290341825Sdim * Retrieve a range for a piece that forms the cursors spelling name.
4291234353Sdim * Most of the times there is only one range for the complete spelling but for
4292276479Sdim * Objective-C methods and Objective-C message expressions, there are multiple
4293276479Sdim * pieces for each selector identifier.
4294341825Sdim *
4295234353Sdim * \param pieceIndex the index of the spelling name piece. If this is greater
4296234353Sdim * than the actual number of pieces, it will return a NULL (invalid) range.
4297341825Sdim *
4298234353Sdim * \param options Reserved.
4299234353Sdim */
4300234353SdimCINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
4301234353Sdim                                                          unsigned pieceIndex,
4302234353Sdim                                                          unsigned options);
4303234353Sdim
4304234353Sdim/**
4305341825Sdim * Opaque pointer representing a policy that controls pretty printing
4306341825Sdim * for \c clang_getCursorPrettyPrinted.
4307341825Sdim */
4308341825Sdimtypedef void *CXPrintingPolicy;
4309341825Sdim
4310341825Sdim/**
4311341825Sdim * Properties for the printing policy.
4312218893Sdim *
4313341825Sdim * See \c clang::PrintingPolicy for more information.
4314341825Sdim */
4315341825Sdimenum CXPrintingPolicyProperty {
4316341825Sdim  CXPrintingPolicy_Indentation,
4317341825Sdim  CXPrintingPolicy_SuppressSpecifiers,
4318341825Sdim  CXPrintingPolicy_SuppressTagKeyword,
4319341825Sdim  CXPrintingPolicy_IncludeTagDefinition,
4320341825Sdim  CXPrintingPolicy_SuppressScope,
4321341825Sdim  CXPrintingPolicy_SuppressUnwrittenScope,
4322341825Sdim  CXPrintingPolicy_SuppressInitializers,
4323341825Sdim  CXPrintingPolicy_ConstantArraySizeAsWritten,
4324341825Sdim  CXPrintingPolicy_AnonymousTagLocations,
4325341825Sdim  CXPrintingPolicy_SuppressStrongLifetime,
4326341825Sdim  CXPrintingPolicy_SuppressLifetimeQualifiers,
4327341825Sdim  CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors,
4328341825Sdim  CXPrintingPolicy_Bool,
4329341825Sdim  CXPrintingPolicy_Restrict,
4330341825Sdim  CXPrintingPolicy_Alignof,
4331341825Sdim  CXPrintingPolicy_UnderscoreAlignof,
4332341825Sdim  CXPrintingPolicy_UseVoidForZeroParams,
4333341825Sdim  CXPrintingPolicy_TerseOutput,
4334341825Sdim  CXPrintingPolicy_PolishForDeclaration,
4335341825Sdim  CXPrintingPolicy_Half,
4336341825Sdim  CXPrintingPolicy_MSWChar,
4337341825Sdim  CXPrintingPolicy_IncludeNewlines,
4338341825Sdim  CXPrintingPolicy_MSVCFormatting,
4339341825Sdim  CXPrintingPolicy_ConstantsAsWritten,
4340341825Sdim  CXPrintingPolicy_SuppressImplicitBase,
4341341825Sdim  CXPrintingPolicy_FullyQualifiedName,
4342341825Sdim
4343341825Sdim  CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName
4344341825Sdim};
4345341825Sdim
4346341825Sdim/**
4347341825Sdim * Get a property value for the given printing policy.
4348341825Sdim */
4349341825SdimCINDEX_LINKAGE unsigned
4350341825Sdimclang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
4351341825Sdim                                 enum CXPrintingPolicyProperty Property);
4352341825Sdim
4353341825Sdim/**
4354341825Sdim * Set a property value for the given printing policy.
4355341825Sdim */
4356341825SdimCINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
4357341825Sdim                                                     enum CXPrintingPolicyProperty Property,
4358341825Sdim                                                     unsigned Value);
4359341825Sdim
4360341825Sdim/**
4361341825Sdim * Retrieve the default policy for the cursor.
4362341825Sdim *
4363341825Sdim * The policy should be released after use with \c
4364341825Sdim * clang_PrintingPolicy_dispose.
4365341825Sdim */
4366341825SdimCINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor);
4367341825Sdim
4368341825Sdim/**
4369341825Sdim * Release a printing policy.
4370341825Sdim */
4371341825SdimCINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy);
4372341825Sdim
4373341825Sdim/**
4374341825Sdim * Pretty print declarations.
4375341825Sdim *
4376341825Sdim * \param Cursor The cursor representing a declaration.
4377341825Sdim *
4378341825Sdim * \param Policy The policy to control the entities being printed. If
4379341825Sdim * NULL, a default policy is used.
4380341825Sdim *
4381341825Sdim * \returns The pretty printed declaration or the empty string for
4382341825Sdim * other cursors.
4383341825Sdim */
4384341825SdimCINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor,
4385341825Sdim                                                     CXPrintingPolicy Policy);
4386341825Sdim
4387341825Sdim/**
4388341825Sdim * Retrieve the display name for the entity referenced by this cursor.
4389341825Sdim *
4390218893Sdim * The display name contains extra information that helps identify the cursor,
4391341825Sdim * such as the parameters of a function or template or the arguments of a
4392218893Sdim * class template specialization.
4393218893Sdim */
4394218893SdimCINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
4395341825Sdim
4396341825Sdim/** For a cursor that is a reference, retrieve a cursor representing the
4397202879Srdivacky * entity that it references.
4398202879Srdivacky *
4399202879Srdivacky * Reference cursors refer to other entities in the AST. For example, an
4400202879Srdivacky * Objective-C superclass reference cursor refers to an Objective-C class.
4401203955Srdivacky * This function produces the cursor for the Objective-C class from the
4402202879Srdivacky * cursor for the superclass reference. If the input cursor is a declaration or
4403202879Srdivacky * definition, it returns that declaration or definition unchanged.
4404203955Srdivacky * Otherwise, returns the NULL cursor.
4405202879Srdivacky */
4406202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
4407202879Srdivacky
4408203955Srdivacky/**
4409341825Sdim *  For a cursor that is either a reference to or a declaration
4410202879Srdivacky *  of some entity, retrieve a cursor that describes the definition of
4411202879Srdivacky *  that entity.
4412202879Srdivacky *
4413202879Srdivacky *  Some entities can be declared multiple times within a translation
4414202879Srdivacky *  unit, but only one of those declarations can also be a
4415202879Srdivacky *  definition. For example, given:
4416202879Srdivacky *
4417202879Srdivacky *  \code
4418202879Srdivacky *  int f(int, int);
4419202879Srdivacky *  int g(int x, int y) { return f(x, y); }
4420202879Srdivacky *  int f(int a, int b) { return a + b; }
4421202879Srdivacky *  int f(int, int);
4422202879Srdivacky *  \endcode
4423202879Srdivacky *
4424202879Srdivacky *  there are three declarations of the function "f", but only the
4425202879Srdivacky *  second one is a definition. The clang_getCursorDefinition()
4426202879Srdivacky *  function will take any cursor pointing to a declaration of "f"
4427202879Srdivacky *  (the first or fourth lines of the example) or a cursor referenced
4428202879Srdivacky *  that uses "f" (the call to "f' inside "g") and will return a
4429202879Srdivacky *  declaration cursor pointing to the definition (the second "f"
4430202879Srdivacky *  declaration).
4431202879Srdivacky *
4432202879Srdivacky *  If given a cursor for which there is no corresponding definition,
4433202879Srdivacky *  e.g., because there is no definition of that entity within this
4434202879Srdivacky *  translation unit, returns a NULL cursor.
4435202879Srdivacky */
4436202879SrdivackyCINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
4437202879Srdivacky
4438203955Srdivacky/**
4439341825Sdim * Determine whether the declaration pointed to by this cursor
4440202879Srdivacky * is also a definition of that entity.
4441202879Srdivacky */
4442202879SrdivackyCINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
4443202879Srdivacky
4444202879Srdivacky/**
4445341825Sdim * Retrieve the canonical cursor corresponding to the given cursor.
4446218893Sdim *
4447218893Sdim * In the C family of languages, many kinds of entities can be declared several
4448218893Sdim * times within a single translation unit. For example, a structure type can
4449218893Sdim * be forward-declared (possibly multiple times) and later defined:
4450218893Sdim *
4451218893Sdim * \code
4452218893Sdim * struct X;
4453218893Sdim * struct X;
4454218893Sdim * struct X {
4455218893Sdim *   int member;
4456218893Sdim * };
4457218893Sdim * \endcode
4458218893Sdim *
4459341825Sdim * The declarations and the definition of \c X are represented by three
4460341825Sdim * different cursors, all of which are declarations of the same underlying
4461218893Sdim * entity. One of these cursor is considered the "canonical" cursor, which
4462341825Sdim * is effectively the representative for the underlying entity. One can
4463218893Sdim * determine if two cursors are declarations of the same underlying entity by
4464218893Sdim * comparing their canonical cursors.
4465218893Sdim *
4466218893Sdim * \returns The canonical cursor for the entity referred to by the given cursor.
4467218893Sdim */
4468218893SdimCINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
4469218893Sdim
4470218893Sdim/**
4471341825Sdim * If the cursor points to a selector identifier in an Objective-C
4472276479Sdim * method or message expression, this returns the selector index.
4473234353Sdim *
4474239462Sdim * After getting a cursor with #clang_getCursor, this can be called to
4475234353Sdim * determine if the location points to a selector identifier.
4476234353Sdim *
4477276479Sdim * \returns The selector index if the cursor is an Objective-C method or message
4478234353Sdim * expression and the cursor is pointing to a selector identifier, or -1
4479234353Sdim * otherwise.
4480234353Sdim */
4481234353SdimCINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor);
4482234353Sdim
4483234353Sdim/**
4484341825Sdim * Given a cursor pointing to a C++ method call or an Objective-C
4485276479Sdim * message, returns non-zero if the method/message is "dynamic", meaning:
4486341825Sdim *
4487239462Sdim * For a C++ method: the call is virtual.
4488276479Sdim * For an Objective-C message: the receiver is an object instance, not 'super'
4489276479Sdim * or a specific class.
4490341825Sdim *
4491239462Sdim * If the method/message is "static" or the cursor does not point to a
4492239462Sdim * method/message, it will return zero.
4493239462Sdim */
4494239462SdimCINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C);
4495239462Sdim
4496239462Sdim/**
4497341825Sdim * Given a cursor pointing to an Objective-C message or property
4498321369Sdim * reference, or C++ method call, returns the CXType of the receiver.
4499243830Sdim */
4500243830SdimCINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
4501243830Sdim
4502243830Sdim/**
4503341825Sdim * Property attributes for a \c CXCursor_ObjCPropertyDecl.
4504251662Sdim */
4505251662Sdimtypedef enum {
4506251662Sdim  CXObjCPropertyAttr_noattr    = 0x00,
4507251662Sdim  CXObjCPropertyAttr_readonly  = 0x01,
4508251662Sdim  CXObjCPropertyAttr_getter    = 0x02,
4509251662Sdim  CXObjCPropertyAttr_assign    = 0x04,
4510251662Sdim  CXObjCPropertyAttr_readwrite = 0x08,
4511251662Sdim  CXObjCPropertyAttr_retain    = 0x10,
4512251662Sdim  CXObjCPropertyAttr_copy      = 0x20,
4513251662Sdim  CXObjCPropertyAttr_nonatomic = 0x40,
4514251662Sdim  CXObjCPropertyAttr_setter    = 0x80,
4515251662Sdim  CXObjCPropertyAttr_atomic    = 0x100,
4516251662Sdim  CXObjCPropertyAttr_weak      = 0x200,
4517251662Sdim  CXObjCPropertyAttr_strong    = 0x400,
4518309124Sdim  CXObjCPropertyAttr_unsafe_unretained = 0x800,
4519309124Sdim  CXObjCPropertyAttr_class = 0x1000
4520251662Sdim} CXObjCPropertyAttrKind;
4521251662Sdim
4522251662Sdim/**
4523341825Sdim * Given a cursor that represents a property declaration, return the
4524251662Sdim * associated property attributes. The bits are formed from
4525251662Sdim * \c CXObjCPropertyAttrKind.
4526251662Sdim *
4527251662Sdim * \param reserved Reserved for future use, pass 0.
4528251662Sdim */
4529251662SdimCINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
4530251662Sdim                                                             unsigned reserved);
4531251662Sdim
4532251662Sdim/**
4533344779Sdim * Given a cursor that represents a property declaration, return the
4534344779Sdim * name of the method that implements the getter.
4535344779Sdim */
4536344779SdimCINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C);
4537344779Sdim
4538344779Sdim/**
4539344779Sdim * Given a cursor that represents a property declaration, return the
4540344779Sdim * name of the method that implements the setter, if any.
4541344779Sdim */
4542344779SdimCINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C);
4543344779Sdim
4544344779Sdim/**
4545341825Sdim * 'Qualifiers' written next to the return and parameter types in
4546276479Sdim * Objective-C method declarations.
4547251662Sdim */
4548251662Sdimtypedef enum {
4549251662Sdim  CXObjCDeclQualifier_None = 0x0,
4550251662Sdim  CXObjCDeclQualifier_In = 0x1,
4551251662Sdim  CXObjCDeclQualifier_Inout = 0x2,
4552251662Sdim  CXObjCDeclQualifier_Out = 0x4,
4553251662Sdim  CXObjCDeclQualifier_Bycopy = 0x8,
4554251662Sdim  CXObjCDeclQualifier_Byref = 0x10,
4555251662Sdim  CXObjCDeclQualifier_Oneway = 0x20
4556251662Sdim} CXObjCDeclQualifierKind;
4557251662Sdim
4558251662Sdim/**
4559341825Sdim * Given a cursor that represents an Objective-C method or parameter
4560276479Sdim * declaration, return the associated Objective-C qualifiers for the return
4561276479Sdim * type or the parameter respectively. The bits are formed from
4562276479Sdim * CXObjCDeclQualifierKind.
4563251662Sdim */
4564251662SdimCINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C);
4565251662Sdim
4566251662Sdim/**
4567341825Sdim * Given a cursor that represents an Objective-C method or property
4568321369Sdim * declaration, return non-zero if the declaration was affected by "\@optional".
4569321369Sdim * Returns zero if the cursor is not such a declaration or it is "\@required".
4570261991Sdim */
4571261991SdimCINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C);
4572261991Sdim
4573261991Sdim/**
4574341825Sdim * Returns non-zero if the given cursor is a variadic function or method.
4575251662Sdim */
4576251662SdimCINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
4577251662Sdim
4578251662Sdim/**
4579341825Sdim * Returns non-zero if the given cursor points to a symbol marked with
4580321369Sdim * external_source_symbol attribute.
4581321369Sdim *
4582321369Sdim * \param language If non-NULL, and the attribute is present, will be set to
4583321369Sdim * the 'language' string from the attribute.
4584321369Sdim *
4585321369Sdim * \param definedIn If non-NULL, and the attribute is present, will be set to
4586321369Sdim * the 'definedIn' string from the attribute.
4587321369Sdim *
4588321369Sdim * \param isGenerated If non-NULL, and the attribute is present, will be set to
4589321369Sdim * non-zero if the 'generated_declaration' is set in the attribute.
4590321369Sdim */
4591321369SdimCINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
4592321369Sdim                                       CXString *language, CXString *definedIn,
4593321369Sdim                                       unsigned *isGenerated);
4594321369Sdim
4595321369Sdim/**
4596341825Sdim * Given a cursor that represents a declaration, return the associated
4597239462Sdim * comment's source range.  The range may include multiple consecutive comments
4598239462Sdim * with whitespace in between.
4599239462Sdim */
4600239462SdimCINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C);
4601239462Sdim
4602239462Sdim/**
4603341825Sdim * Given a cursor that represents a declaration, return the associated
4604239462Sdim * comment text, including comment markers.
4605239462Sdim */
4606239462SdimCINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C);
4607239462Sdim
4608239462Sdim/**
4609341825Sdim * Given a cursor that represents a documentable entity (e.g.,
4610341825Sdim * declaration), return the associated \paragraph; otherwise return the
4611239462Sdim * first paragraph.
4612239462Sdim */
4613239462SdimCINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C);
4614239462Sdim
4615239462Sdim/**
4616202879Srdivacky * @}
4617202879Srdivacky */
4618203955Srdivacky
4619280031Sdim/** \defgroup CINDEX_MANGLE Name Mangling API Functions
4620280031Sdim *
4621280031Sdim * @{
4622280031Sdim */
4623280031Sdim
4624203955Srdivacky/**
4625341825Sdim * Retrieve the CXString representing the mangled name of the cursor.
4626280031Sdim */
4627280031SdimCINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
4628280031Sdim
4629280031Sdim/**
4630341825Sdim * Retrieve the CXStrings representing the mangled symbols of the C++
4631296417Sdim * constructor or destructor at the cursor.
4632296417Sdim */
4633296417SdimCINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
4634296417Sdim
4635296417Sdim/**
4636341825Sdim * Retrieve the CXStrings representing the mangled symbols of the ObjC
4637327952Sdim * class interface or implementation at the cursor.
4638327952Sdim */
4639327952SdimCINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4640327952Sdim
4641327952Sdim/**
4642280031Sdim * @}
4643280031Sdim */
4644280031Sdim
4645280031Sdim/**
4646243830Sdim * \defgroup CINDEX_MODULE Module introspection
4647243830Sdim *
4648243830Sdim * The functions in this group provide access to information about modules.
4649243830Sdim *
4650243830Sdim * @{
4651243830Sdim */
4652243830Sdim
4653243830Sdimtypedef void *CXModule;
4654243830Sdim
4655243830Sdim/**
4656341825Sdim * Given a CXCursor_ModuleImportDecl cursor, return the associated module.
4657243830Sdim */
4658243830SdimCINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C);
4659243830Sdim
4660243830Sdim/**
4661341825Sdim * Given a CXFile header file, return the module that contains it, if one
4662276479Sdim * exists.
4663276479Sdim */
4664276479SdimCINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile);
4665276479Sdim
4666276479Sdim/**
4667243830Sdim * \param Module a module object.
4668243830Sdim *
4669251662Sdim * \returns the module file where the provided module object came from.
4670251662Sdim */
4671251662SdimCINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module);
4672251662Sdim
4673251662Sdim/**
4674251662Sdim * \param Module a module object.
4675251662Sdim *
4676243830Sdim * \returns the parent of a sub-module or NULL if the given module is top-level,
4677243830Sdim * e.g. for 'std.vector' it will return the 'std' module.
4678243830Sdim */
4679243830SdimCINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module);
4680243830Sdim
4681243830Sdim/**
4682243830Sdim * \param Module a module object.
4683243830Sdim *
4684243830Sdim * \returns the name of the module, e.g. for the 'std.vector' sub-module it
4685243830Sdim * will return "vector".
4686243830Sdim */
4687243830SdimCINDEX_LINKAGE CXString clang_Module_getName(CXModule Module);
4688243830Sdim
4689243830Sdim/**
4690243830Sdim * \param Module a module object.
4691243830Sdim *
4692243830Sdim * \returns the full name of the module, e.g. "std.vector".
4693243830Sdim */
4694243830SdimCINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module);
4695243830Sdim
4696243830Sdim/**
4697243830Sdim * \param Module a module object.
4698243830Sdim *
4699276479Sdim * \returns non-zero if the module is a system one.
4700276479Sdim */
4701276479SdimCINDEX_LINKAGE int clang_Module_isSystem(CXModule Module);
4702276479Sdim
4703276479Sdim/**
4704276479Sdim * \param Module a module object.
4705276479Sdim *
4706243830Sdim * \returns the number of top level headers associated with this module.
4707243830Sdim */
4708249423SdimCINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
4709249423Sdim                                                           CXModule Module);
4710243830Sdim
4711243830Sdim/**
4712243830Sdim * \param Module a module object.
4713243830Sdim *
4714243830Sdim * \param Index top level header index (zero-based).
4715243830Sdim *
4716243830Sdim * \returns the specified top level header associated with the module.
4717243830Sdim */
4718243830SdimCINDEX_LINKAGE
4719249423SdimCXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
4720249423Sdim                                      CXModule Module, unsigned Index);
4721243830Sdim
4722243830Sdim/**
4723243830Sdim * @}
4724243830Sdim */
4725243830Sdim
4726243830Sdim/**
4727208600Srdivacky * \defgroup CINDEX_CPP C++ AST introspection
4728208600Srdivacky *
4729208600Srdivacky * The routines in this group provide access information in the ASTs specific
4730208600Srdivacky * to C++ language features.
4731208600Srdivacky *
4732208600Srdivacky * @{
4733208600Srdivacky */
4734208600Srdivacky
4735208600Srdivacky/**
4736341825Sdim * Determine if a C++ constructor is a converting constructor.
4737309124Sdim */
4738309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
4739309124Sdim
4740309124Sdim/**
4741341825Sdim * Determine if a C++ constructor is a copy constructor.
4742309124Sdim */
4743309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C);
4744309124Sdim
4745309124Sdim/**
4746341825Sdim * Determine if a C++ constructor is the default constructor.
4747309124Sdim */
4748309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C);
4749309124Sdim
4750309124Sdim/**
4751341825Sdim * Determine if a C++ constructor is a move constructor.
4752309124Sdim */
4753309124SdimCINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C);
4754309124Sdim
4755309124Sdim/**
4756341825Sdim * Determine if a C++ field is declared 'mutable'.
4757296417Sdim */
4758296417SdimCINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C);
4759296417Sdim
4760296417Sdim/**
4761341825Sdim * Determine if a C++ method is declared '= default'.
4762309124Sdim */
4763309124SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
4764309124Sdim
4765309124Sdim/**
4766341825Sdim * Determine if a C++ member function or member function template is
4767261991Sdim * pure virtual.
4768261991Sdim */
4769261991SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
4770261991Sdim
4771261991Sdim/**
4772341825Sdim * Determine if a C++ member function or member function template is
4773212904Sdim * declared 'static'.
4774208600Srdivacky */
4775208600SrdivackyCINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
4776208600Srdivacky
4777208600Srdivacky/**
4778341825Sdim * Determine if a C++ member function or member function template is
4779223017Sdim * explicitly declared 'virtual' or if it overrides a virtual method from
4780223017Sdim * one of the base classes.
4781223017Sdim */
4782223017SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
4783223017Sdim
4784223017Sdim/**
4785341825Sdim * Determine if a C++ record is abstract, i.e. whether a class or struct
4786327952Sdim * has a pure virtual member function.
4787327952Sdim */
4788327952SdimCINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4789327952Sdim
4790327952Sdim/**
4791341825Sdim * Determine if an enum declaration refers to a scoped enum.
4792321369Sdim */
4793321369SdimCINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C);
4794321369Sdim
4795321369Sdim/**
4796341825Sdim * Determine if a C++ member function or member function template is
4797276479Sdim * declared 'const'.
4798276479Sdim */
4799276479SdimCINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C);
4800276479Sdim
4801276479Sdim/**
4802341825Sdim * Given a cursor that represents a template, determine
4803212904Sdim * the cursor kind of the specializations would be generated by instantiating
4804212904Sdim * the template.
4805212904Sdim *
4806212904Sdim * This routine can be used to determine what flavor of function template,
4807212904Sdim * class template, or class template partial specialization is stored in the
4808212904Sdim * cursor. For example, it can describe whether a class template cursor is
4809212904Sdim * declared with "struct", "class" or "union".
4810212904Sdim *
4811212904Sdim * \param C The cursor to query. This cursor should represent a template
4812212904Sdim * declaration.
4813212904Sdim *
4814212904Sdim * \returns The cursor kind of the specializations that would be generated
4815212904Sdim * by instantiating the template \p C. If \p C is not a template, returns
4816212904Sdim * \c CXCursor_NoDeclFound.
4817212904Sdim */
4818212904SdimCINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
4819341825Sdim
4820212904Sdim/**
4821341825Sdim * Given a cursor that may represent a specialization or instantiation
4822212904Sdim * of a template, retrieve the cursor that represents the template that it
4823212904Sdim * specializes or from which it was instantiated.
4824212904Sdim *
4825341825Sdim * This routine determines the template involved both for explicit
4826212904Sdim * specializations of templates and for implicit instantiations of the template,
4827212904Sdim * both of which are referred to as "specializations". For a class template
4828341825Sdim * specialization (e.g., \c std::vector<bool>), this routine will return
4829212904Sdim * either the primary template (\c std::vector) or, if the specialization was
4830212904Sdim * instantiated from a class template partial specialization, the class template
4831212904Sdim * partial specialization. For a class template partial specialization and a
4832212904Sdim * function template specialization (including instantiations), this
4833212904Sdim * this routine will return the specialized template.
4834212904Sdim *
4835212904Sdim * For members of a class template (e.g., member functions, member classes, or
4836341825Sdim * static data members), returns the specialized or instantiated member.
4837212904Sdim * Although not strictly "templates" in the C++ language, members of class
4838212904Sdim * templates have the same notions of specializations and instantiations that
4839212904Sdim * templates do, so this routine treats them similarly.
4840212904Sdim *
4841212904Sdim * \param C A cursor that may be a specialization of a template or a member
4842212904Sdim * of a template.
4843212904Sdim *
4844341825Sdim * \returns If the given cursor is a specialization or instantiation of a
4845212904Sdim * template or a member thereof, the template or member that it specializes or
4846212904Sdim * from which it was instantiated. Otherwise, returns a NULL cursor.
4847212904Sdim */
4848212904SdimCINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
4849226633Sdim
4850226633Sdim/**
4851341825Sdim * Given a cursor that references something else, return the source range
4852226633Sdim * covering that reference.
4853226633Sdim *
4854226633Sdim * \param C A cursor pointing to a member reference, a declaration reference, or
4855226633Sdim * an operator call.
4856341825Sdim * \param NameFlags A bitset with three independent flags:
4857226633Sdim * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and
4858226633Sdim * CXNameRange_WantSinglePiece.
4859341825Sdim * \param PieceIndex For contiguous names or when passing the flag
4860341825Sdim * CXNameRange_WantSinglePiece, only one piece with index 0 is
4861226633Sdim * available. When the CXNameRange_WantSinglePiece flag is not passed for a
4862239462Sdim * non-contiguous names, this index can be used to retrieve the individual
4863226633Sdim * pieces of the name. See also CXNameRange_WantSinglePiece.
4864226633Sdim *
4865226633Sdim * \returns The piece of the name pointed to by the given cursor. If there is no
4866226633Sdim * name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
4867226633Sdim */
4868226633SdimCINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
4869341825Sdim                                                unsigned NameFlags,
4870226633Sdim                                                unsigned PieceIndex);
4871226633Sdim
4872226633Sdimenum CXNameRefFlags {
4873226633Sdim  /**
4874341825Sdim   * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the
4875226633Sdim   * range.
4876226633Sdim   */
4877226633Sdim  CXNameRange_WantQualifier = 0x1,
4878341825Sdim
4879226633Sdim  /**
4880341825Sdim   * Include the explicit template arguments, e.g. \<int> in x.f<int>,
4881239462Sdim   * in the range.
4882226633Sdim   */
4883226633Sdim  CXNameRange_WantTemplateArgs = 0x2,
4884226633Sdim
4885226633Sdim  /**
4886341825Sdim   * If the name is non-contiguous, return the full spanning range.
4887226633Sdim   *
4888226633Sdim   * Non-contiguous names occur in Objective-C when a selector with two or more
4889226633Sdim   * parameters is used, or in C++ when using an operator:
4890226633Sdim   * \code
4891276479Sdim   * [object doSomething:here withValue:there]; // Objective-C
4892226633Sdim   * return some_vector[1]; // C++
4893226633Sdim   * \endcode
4894226633Sdim   */
4895226633Sdim  CXNameRange_WantSinglePiece = 0x4
4896226633Sdim};
4897341825Sdim
4898212904Sdim/**
4899208600Srdivacky * @}
4900208600Srdivacky */
4901208600Srdivacky
4902208600Srdivacky/**
4903203955Srdivacky * \defgroup CINDEX_LEX Token extraction and manipulation
4904203955Srdivacky *
4905203955Srdivacky * The routines in this group provide access to the tokens within a
4906203955Srdivacky * translation unit, along with a semantic mapping of those tokens to
4907203955Srdivacky * their corresponding cursors.
4908203955Srdivacky *
4909203955Srdivacky * @{
4910203955Srdivacky */
4911203955Srdivacky
4912203955Srdivacky/**
4913341825Sdim * Describes a kind of token.
4914203955Srdivacky */
4915203955Srdivackytypedef enum CXTokenKind {
4916203955Srdivacky  /**
4917341825Sdim   * A token that contains some kind of punctuation.
4918203955Srdivacky   */
4919203955Srdivacky  CXToken_Punctuation,
4920205219Srdivacky
4921203955Srdivacky  /**
4922341825Sdim   * A language keyword.
4923203955Srdivacky   */
4924203955Srdivacky  CXToken_Keyword,
4925205219Srdivacky
4926203955Srdivacky  /**
4927341825Sdim   * An identifier (that is not a keyword).
4928203955Srdivacky   */
4929203955Srdivacky  CXToken_Identifier,
4930205219Srdivacky
4931203955Srdivacky  /**
4932341825Sdim   * A numeric, string, or character literal.
4933203955Srdivacky   */
4934203955Srdivacky  CXToken_Literal,
4935205219Srdivacky
4936203955Srdivacky  /**
4937341825Sdim   * A comment.
4938203955Srdivacky   */
4939203955Srdivacky  CXToken_Comment
4940203955Srdivacky} CXTokenKind;
4941203955Srdivacky
4942202879Srdivacky/**
4943341825Sdim * Describes a single preprocessing token.
4944203955Srdivacky */
4945203955Srdivackytypedef struct {
4946203955Srdivacky  unsigned int_data[4];
4947203955Srdivacky  void *ptr_data;
4948203955Srdivacky} CXToken;
4949203955Srdivacky
4950203955Srdivacky/**
4951341825Sdim * Get the raw lexical token starting with the given location.
4952341825Sdim *
4953341825Sdim * \param TU the translation unit whose text is being tokenized.
4954341825Sdim *
4955341825Sdim * \param Location the source location with which the token starts.
4956341825Sdim *
4957341825Sdim * \returns The token starting with the given location or NULL if no such token
4958341825Sdim * exist. The returned pointer must be freed with clang_disposeTokens before the
4959341825Sdim * translation unit is destroyed.
4960203955Srdivacky */
4961341825SdimCINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU,
4962341825Sdim                                       CXSourceLocation Location);
4963341825Sdim
4964341825Sdim/**
4965341825Sdim * Determine the kind of the given token.
4966341825Sdim */
4967203955SrdivackyCINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
4968205219Srdivacky
4969203955Srdivacky/**
4970341825Sdim * Determine the spelling of the given token.
4971203955Srdivacky *
4972203955Srdivacky * The spelling of a token is the textual representation of that token, e.g.,
4973203955Srdivacky * the text of an identifier or keyword.
4974203955Srdivacky */
4975203955SrdivackyCINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
4976205219Srdivacky
4977203955Srdivacky/**
4978341825Sdim * Retrieve the source location of the given token.
4979203955Srdivacky */
4980205219SrdivackyCINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
4981203955Srdivacky                                                       CXToken);
4982205219Srdivacky
4983203955Srdivacky/**
4984341825Sdim * Retrieve a source range that covers the given token.
4985203955Srdivacky */
4986203955SrdivackyCINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
4987203955Srdivacky
4988203955Srdivacky/**
4989341825Sdim * Tokenize the source code described by the given range into raw
4990203955Srdivacky * lexical tokens.
4991203955Srdivacky *
4992203955Srdivacky * \param TU the translation unit whose text is being tokenized.
4993203955Srdivacky *
4994203955Srdivacky * \param Range the source range in which text should be tokenized. All of the
4995203955Srdivacky * tokens produced by tokenization will fall within this source range,
4996203955Srdivacky *
4997203955Srdivacky * \param Tokens this pointer will be set to point to the array of tokens
4998203955Srdivacky * that occur within the given source range. The returned pointer must be
4999203955Srdivacky * freed with clang_disposeTokens() before the translation unit is destroyed.
5000203955Srdivacky *
5001203955Srdivacky * \param NumTokens will be set to the number of tokens in the \c *Tokens
5002203955Srdivacky * array.
5003203955Srdivacky *
5004203955Srdivacky */
5005203955SrdivackyCINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
5006203955Srdivacky                                   CXToken **Tokens, unsigned *NumTokens);
5007205219Srdivacky
5008203955Srdivacky/**
5009341825Sdim * Annotate the given set of tokens by providing cursors for each token
5010203955Srdivacky * that can be mapped to a specific entity within the abstract syntax tree.
5011203955Srdivacky *
5012203955Srdivacky * This token-annotation routine is equivalent to invoking
5013203955Srdivacky * clang_getCursor() for the source locations of each of the
5014203955Srdivacky * tokens. The cursors provided are filtered, so that only those
5015203955Srdivacky * cursors that have a direct correspondence to the token are
5016203955Srdivacky * accepted. For example, given a function call \c f(x),
5017203955Srdivacky * clang_getCursor() would provide the following cursors:
5018203955Srdivacky *
5019203955Srdivacky *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
5020203955Srdivacky *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
5021203955Srdivacky *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
5022203955Srdivacky *
5023203955Srdivacky * Only the first and last of these cursors will occur within the
5024203955Srdivacky * annotate, since the tokens "f" and "x' directly refer to a function
5025203955Srdivacky * and a variable, respectively, but the parentheses are just a small
5026203955Srdivacky * part of the full syntax of the function call expression, which is
5027203955Srdivacky * not provided as an annotation.
5028203955Srdivacky *
5029203955Srdivacky * \param TU the translation unit that owns the given tokens.
5030203955Srdivacky *
5031203955Srdivacky * \param Tokens the set of tokens to annotate.
5032203955Srdivacky *
5033203955Srdivacky * \param NumTokens the number of tokens in \p Tokens.
5034203955Srdivacky *
5035203955Srdivacky * \param Cursors an array of \p NumTokens cursors, whose contents will be
5036203955Srdivacky * replaced with the cursors corresponding to each token.
5037203955Srdivacky */
5038203955SrdivackyCINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
5039203955Srdivacky                                         CXToken *Tokens, unsigned NumTokens,
5040203955Srdivacky                                         CXCursor *Cursors);
5041205219Srdivacky
5042203955Srdivacky/**
5043341825Sdim * Free the given set of tokens.
5044203955Srdivacky */
5045205219SrdivackyCINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
5046203955Srdivacky                                        CXToken *Tokens, unsigned NumTokens);
5047205219Srdivacky
5048203955Srdivacky/**
5049203955Srdivacky * @}
5050203955Srdivacky */
5051205219Srdivacky
5052203955Srdivacky/**
5053202879Srdivacky * \defgroup CINDEX_DEBUG Debugging facilities
5054202879Srdivacky *
5055202879Srdivacky * These routines are used for testing and debugging, only, and should not
5056202879Srdivacky * be relied upon.
5057202879Srdivacky *
5058202879Srdivacky * @{
5059202879Srdivacky */
5060203955Srdivacky
5061198092Srdivacky/* for debug/testing */
5062204643SrdivackyCINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
5063203955SrdivackyCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
5064203955Srdivacky                                          const char **startBuf,
5065198092Srdivacky                                          const char **endBuf,
5066198092Srdivacky                                          unsigned *startLine,
5067198092Srdivacky                                          unsigned *startColumn,
5068198092Srdivacky                                          unsigned *endLine,
5069198092Srdivacky                                          unsigned *endColumn);
5070204643SrdivackyCINDEX_LINKAGE void clang_enableStackTraces(void);
5071218893SdimCINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
5072218893Sdim                                          unsigned stack_size);
5073218893Sdim
5074202879Srdivacky/**
5075202879Srdivacky * @}
5076198092Srdivacky */
5077203955Srdivacky
5078199482Srdivacky/**
5079202879Srdivacky * \defgroup CINDEX_CODE_COMPLET Code completion
5080202879Srdivacky *
5081202879Srdivacky * Code completion involves taking an (incomplete) source file, along with
5082202879Srdivacky * knowledge of where the user is actively editing that file, and suggesting
5083202879Srdivacky * syntactically- and semantically-valid constructs that the user might want to
5084202879Srdivacky * use at that particular point in the source code. These data structures and
5085202879Srdivacky * routines provide support for code completion.
5086202879Srdivacky *
5087202879Srdivacky * @{
5088202879Srdivacky */
5089203955Srdivacky
5090202879Srdivacky/**
5091341825Sdim * A semantic string that describes a code-completion result.
5092199482Srdivacky *
5093199482Srdivacky * A semantic string that describes the formatting of a code-completion
5094199482Srdivacky * result as a single "template" of text that should be inserted into the
5095199482Srdivacky * source buffer when a particular code-completion result is selected.
5096199482Srdivacky * Each semantic string is made up of some number of "chunks", each of which
5097199482Srdivacky * contains some text along with a description of what that text means, e.g.,
5098199482Srdivacky * the name of the entity being referenced, whether the text chunk is part of
5099199482Srdivacky * the template, or whether it is a "placeholder" that the user should replace
5100199482Srdivacky * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
5101203955Srdivacky * description of the different kinds of chunks.
5102199482Srdivacky */
5103199482Srdivackytypedef void *CXCompletionString;
5104203955Srdivacky
5105199482Srdivacky/**
5106341825Sdim * A single result of code completion.
5107199482Srdivacky */
5108199482Srdivackytypedef struct {
5109199482Srdivacky  /**
5110341825Sdim   * The kind of entity that this completion refers to.
5111199482Srdivacky   *
5112203955Srdivacky   * The cursor kind will be a macro, keyword, or a declaration (one of the
5113199482Srdivacky   * *Decl cursor kinds), describing the entity that the completion is
5114199482Srdivacky   * referring to.
5115199482Srdivacky   *
5116199482Srdivacky   * \todo In the future, we would like to provide a full cursor, to allow
5117199482Srdivacky   * the client to extract additional information from declaration.
5118199482Srdivacky   */
5119199482Srdivacky  enum CXCursorKind CursorKind;
5120203955Srdivacky
5121203955Srdivacky  /**
5122341825Sdim   * The code-completion string that describes how to insert this
5123199482Srdivacky   * code-completion result into the editing buffer.
5124199482Srdivacky   */
5125199482Srdivacky  CXCompletionString CompletionString;
5126199482Srdivacky} CXCompletionResult;
5127199482Srdivacky
5128199482Srdivacky/**
5129341825Sdim * Describes a single piece of text within a code-completion string.
5130199482Srdivacky *
5131203955Srdivacky * Each "chunk" within a code-completion string (\c CXCompletionString) is
5132203955Srdivacky * either a piece of text with a specific "kind" that describes how that text
5133199482Srdivacky * should be interpreted by the client or is another completion string.
5134199482Srdivacky */
5135199482Srdivackyenum CXCompletionChunkKind {
5136199482Srdivacky  /**
5137341825Sdim   * A code-completion string that describes "optional" text that
5138199482Srdivacky   * could be a part of the template (but is not required).
5139199482Srdivacky   *
5140199482Srdivacky   * The Optional chunk is the only kind of chunk that has a code-completion
5141203955Srdivacky   * string for its representation, which is accessible via
5142199482Srdivacky   * \c clang_getCompletionChunkCompletionString(). The code-completion string
5143199482Srdivacky   * describes an additional part of the template that is completely optional.
5144199482Srdivacky   * For example, optional chunks can be used to describe the placeholders for
5145199482Srdivacky   * arguments that match up with defaulted function parameters, e.g. given:
5146199482Srdivacky   *
5147199482Srdivacky   * \code
5148199482Srdivacky   * void f(int x, float y = 3.14, double z = 2.71828);
5149199482Srdivacky   * \endcode
5150199482Srdivacky   *
5151199482Srdivacky   * The code-completion string for this function would contain:
5152199482Srdivacky   *   - a TypedText chunk for "f".
5153199482Srdivacky   *   - a LeftParen chunk for "(".
5154199482Srdivacky   *   - a Placeholder chunk for "int x"
5155199482Srdivacky   *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
5156199482Srdivacky   *       - a Comma chunk for ","
5157204643Srdivacky   *       - a Placeholder chunk for "float y"
5158199482Srdivacky   *       - an Optional chunk containing the last defaulted argument:
5159199482Srdivacky   *           - a Comma chunk for ","
5160199482Srdivacky   *           - a Placeholder chunk for "double z"
5161199482Srdivacky   *   - a RightParen chunk for ")"
5162199482Srdivacky   *
5163204643Srdivacky   * There are many ways to handle Optional chunks. Two simple approaches are:
5164199482Srdivacky   *   - Completely ignore optional chunks, in which case the template for the
5165199482Srdivacky   *     function "f" would only include the first parameter ("int x").
5166199482Srdivacky   *   - Fully expand all optional chunks, in which case the template for the
5167199482Srdivacky   *     function "f" would have all of the parameters.
5168199482Srdivacky   */
5169199482Srdivacky  CXCompletionChunk_Optional,
5170199482Srdivacky  /**
5171341825Sdim   * Text that a user would be expected to type to get this
5172203955Srdivacky   * code-completion result.
5173199482Srdivacky   *
5174203955Srdivacky   * There will be exactly one "typed text" chunk in a semantic string, which
5175203955Srdivacky   * will typically provide the spelling of a keyword or the name of a
5176199482Srdivacky   * declaration that could be used at the current code point. Clients are
5177199482Srdivacky   * expected to filter the code-completion results based on the text in this
5178199482Srdivacky   * chunk.
5179199482Srdivacky   */
5180199482Srdivacky  CXCompletionChunk_TypedText,
5181199482Srdivacky  /**
5182341825Sdim   * Text that should be inserted as part of a code-completion result.
5183199482Srdivacky   *
5184199482Srdivacky   * A "text" chunk represents text that is part of the template to be
5185199482Srdivacky   * inserted into user code should this particular code-completion result
5186199482Srdivacky   * be selected.
5187199482Srdivacky   */
5188199482Srdivacky  CXCompletionChunk_Text,
5189199482Srdivacky  /**
5190341825Sdim   * Placeholder text that should be replaced by the user.
5191199482Srdivacky   *
5192199482Srdivacky   * A "placeholder" chunk marks a place where the user should insert text
5193199482Srdivacky   * into the code-completion template. For example, placeholders might mark
5194199482Srdivacky   * the function parameters for a function declaration, to indicate that the
5195199482Srdivacky   * user should provide arguments for each of those parameters. The actual
5196199482Srdivacky   * text in a placeholder is a suggestion for the text to display before
5197199482Srdivacky   * the user replaces the placeholder with real code.
5198199482Srdivacky   */
5199199482Srdivacky  CXCompletionChunk_Placeholder,
5200199482Srdivacky  /**
5201341825Sdim   * Informative text that should be displayed but never inserted as
5202199482Srdivacky   * part of the template.
5203203955Srdivacky   *
5204199482Srdivacky   * An "informative" chunk contains annotations that can be displayed to
5205199482Srdivacky   * help the user decide whether a particular code-completion result is the
5206199482Srdivacky   * right option, but which is not part of the actual template to be inserted
5207199482Srdivacky   * by code completion.
5208199482Srdivacky   */
5209199482Srdivacky  CXCompletionChunk_Informative,
5210199482Srdivacky  /**
5211341825Sdim   * Text that describes the current parameter when code-completion is
5212199482Srdivacky   * referring to function call, message send, or template specialization.
5213199482Srdivacky   *
5214199482Srdivacky   * A "current parameter" chunk occurs when code-completion is providing
5215199482Srdivacky   * information about a parameter corresponding to the argument at the
5216199482Srdivacky   * code-completion point. For example, given a function
5217199482Srdivacky   *
5218199482Srdivacky   * \code
5219199482Srdivacky   * int add(int x, int y);
5220199482Srdivacky   * \endcode
5221199482Srdivacky   *
5222199482Srdivacky   * and the source code \c add(, where the code-completion point is after the
5223199482Srdivacky   * "(", the code-completion string will contain a "current parameter" chunk
5224199482Srdivacky   * for "int x", indicating that the current argument will initialize that
5225199482Srdivacky   * parameter. After typing further, to \c add(17, (where the code-completion
5226203955Srdivacky   * point is after the ","), the code-completion string will contain a
5227341825Sdim   * "current parameter" chunk to "int y".
5228199482Srdivacky   */
5229199482Srdivacky  CXCompletionChunk_CurrentParameter,
5230199482Srdivacky  /**
5231341825Sdim   * A left parenthesis ('('), used to initiate a function call or
5232199482Srdivacky   * signal the beginning of a function parameter list.
5233199482Srdivacky   */
5234199482Srdivacky  CXCompletionChunk_LeftParen,
5235199482Srdivacky  /**
5236341825Sdim   * A right parenthesis (')'), used to finish a function call or
5237199482Srdivacky   * signal the end of a function parameter list.
5238199482Srdivacky   */
5239199482Srdivacky  CXCompletionChunk_RightParen,
5240199482Srdivacky  /**
5241341825Sdim   * A left bracket ('[').
5242199482Srdivacky   */
5243199482Srdivacky  CXCompletionChunk_LeftBracket,
5244199482Srdivacky  /**
5245341825Sdim   * A right bracket (']').
5246199482Srdivacky   */
5247199482Srdivacky  CXCompletionChunk_RightBracket,
5248199482Srdivacky  /**
5249341825Sdim   * A left brace ('{').
5250199482Srdivacky   */
5251199482Srdivacky  CXCompletionChunk_LeftBrace,
5252199482Srdivacky  /**
5253341825Sdim   * A right brace ('}').
5254199482Srdivacky   */
5255199482Srdivacky  CXCompletionChunk_RightBrace,
5256199482Srdivacky  /**
5257341825Sdim   * A left angle bracket ('<').
5258199482Srdivacky   */
5259199482Srdivacky  CXCompletionChunk_LeftAngle,
5260199482Srdivacky  /**
5261341825Sdim   * A right angle bracket ('>').
5262199482Srdivacky   */
5263199482Srdivacky  CXCompletionChunk_RightAngle,
5264199482Srdivacky  /**
5265341825Sdim   * A comma separator (',').
5266199482Srdivacky   */
5267201361Srdivacky  CXCompletionChunk_Comma,
5268201361Srdivacky  /**
5269341825Sdim   * Text that specifies the result type of a given result.
5270201361Srdivacky   *
5271201361Srdivacky   * This special kind of informative chunk is not meant to be inserted into
5272203955Srdivacky   * the text buffer. Rather, it is meant to illustrate the type that an
5273201361Srdivacky   * expression using the given completion string would have.
5274201361Srdivacky   */
5275202379Srdivacky  CXCompletionChunk_ResultType,
5276202379Srdivacky  /**
5277341825Sdim   * A colon (':').
5278202379Srdivacky   */
5279202379Srdivacky  CXCompletionChunk_Colon,
5280202379Srdivacky  /**
5281341825Sdim   * A semicolon (';').
5282202379Srdivacky   */
5283202379Srdivacky  CXCompletionChunk_SemiColon,
5284202379Srdivacky  /**
5285341825Sdim   * An '=' sign.
5286202379Srdivacky   */
5287202379Srdivacky  CXCompletionChunk_Equal,
5288202379Srdivacky  /**
5289202379Srdivacky   * Horizontal space (' ').
5290202379Srdivacky   */
5291202379Srdivacky  CXCompletionChunk_HorizontalSpace,
5292202379Srdivacky  /**
5293321369Sdim   * Vertical space ('\\n'), after which it is generally a good idea to
5294202379Srdivacky   * perform indentation.
5295202379Srdivacky   */
5296202379Srdivacky  CXCompletionChunk_VerticalSpace
5297199482Srdivacky};
5298203955Srdivacky
5299199482Srdivacky/**
5300341825Sdim * Determine the kind of a particular chunk within a completion string.
5301199482Srdivacky *
5302199482Srdivacky * \param completion_string the completion string to query.
5303199482Srdivacky *
5304199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
5305199482Srdivacky *
5306199482Srdivacky * \returns the kind of the chunk at the index \c chunk_number.
5307199482Srdivacky */
5308203955SrdivackyCINDEX_LINKAGE enum CXCompletionChunkKind
5309199482Srdivackyclang_getCompletionChunkKind(CXCompletionString completion_string,
5310199482Srdivacky                             unsigned chunk_number);
5311203955Srdivacky
5312199482Srdivacky/**
5313341825Sdim * Retrieve the text associated with a particular chunk within a
5314199482Srdivacky * completion string.
5315199482Srdivacky *
5316199482Srdivacky * \param completion_string the completion string to query.
5317199482Srdivacky *
5318199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
5319199482Srdivacky *
5320199482Srdivacky * \returns the text associated with the chunk at index \c chunk_number.
5321199482Srdivacky */
5322204643SrdivackyCINDEX_LINKAGE CXString
5323199482Srdivackyclang_getCompletionChunkText(CXCompletionString completion_string,
5324199482Srdivacky                             unsigned chunk_number);
5325199482Srdivacky
5326199482Srdivacky/**
5327341825Sdim * Retrieve the completion string associated with a particular chunk
5328199482Srdivacky * within a completion string.
5329199482Srdivacky *
5330199482Srdivacky * \param completion_string the completion string to query.
5331199482Srdivacky *
5332199482Srdivacky * \param chunk_number the 0-based index of the chunk in the completion string.
5333199482Srdivacky *
5334199482Srdivacky * \returns the completion string associated with the chunk at index
5335226633Sdim * \c chunk_number.
5336199482Srdivacky */
5337199482SrdivackyCINDEX_LINKAGE CXCompletionString
5338199482Srdivackyclang_getCompletionChunkCompletionString(CXCompletionString completion_string,
5339199482Srdivacky                                         unsigned chunk_number);
5340203955Srdivacky
5341199482Srdivacky/**
5342341825Sdim * Retrieve the number of chunks in the given code-completion string.
5343199482Srdivacky */
5344199482SrdivackyCINDEX_LINKAGE unsigned
5345199482Srdivackyclang_getNumCompletionChunks(CXCompletionString completion_string);
5346199482Srdivacky
5347199482Srdivacky/**
5348341825Sdim * Determine the priority of this code completion.
5349208600Srdivacky *
5350341825Sdim * The priority of a code completion indicates how likely it is that this
5351208600Srdivacky * particular completion is the completion that the user will select. The
5352208600Srdivacky * priority is selected by various internal heuristics.
5353208600Srdivacky *
5354208600Srdivacky * \param completion_string The completion string to query.
5355208600Srdivacky *
5356208600Srdivacky * \returns The priority of this completion string. Smaller values indicate
5357208600Srdivacky * higher-priority (more likely) completions.
5358208600Srdivacky */
5359208600SrdivackyCINDEX_LINKAGE unsigned
5360208600Srdivackyclang_getCompletionPriority(CXCompletionString completion_string);
5361341825Sdim
5362208600Srdivacky/**
5363341825Sdim * Determine the availability of the entity that this code-completion
5364212904Sdim * string refers to.
5365212904Sdim *
5366212904Sdim * \param completion_string The completion string to query.
5367212904Sdim *
5368212904Sdim * \returns The availability of the completion string.
5369212904Sdim */
5370341825SdimCINDEX_LINKAGE enum CXAvailabilityKind
5371212904Sdimclang_getCompletionAvailability(CXCompletionString completion_string);
5372212904Sdim
5373212904Sdim/**
5374341825Sdim * Retrieve the number of annotations associated with the given
5375226633Sdim * completion string.
5376226633Sdim *
5377226633Sdim * \param completion_string the completion string to query.
5378226633Sdim *
5379226633Sdim * \returns the number of annotations associated with the given completion
5380226633Sdim * string.
5381226633Sdim */
5382226633SdimCINDEX_LINKAGE unsigned
5383226633Sdimclang_getCompletionNumAnnotations(CXCompletionString completion_string);
5384226633Sdim
5385226633Sdim/**
5386341825Sdim * Retrieve the annotation associated with the given completion string.
5387226633Sdim *
5388226633Sdim * \param completion_string the completion string to query.
5389226633Sdim *
5390226633Sdim * \param annotation_number the 0-based index of the annotation of the
5391226633Sdim * completion string.
5392226633Sdim *
5393226633Sdim * \returns annotation string associated with the completion at index
5394226633Sdim * \c annotation_number, or a NULL string if that annotation is not available.
5395226633Sdim */
5396226633SdimCINDEX_LINKAGE CXString
5397226633Sdimclang_getCompletionAnnotation(CXCompletionString completion_string,
5398226633Sdim                              unsigned annotation_number);
5399226633Sdim
5400226633Sdim/**
5401341825Sdim * Retrieve the parent context of the given completion string.
5402234353Sdim *
5403341825Sdim * The parent context of a completion string is the semantic parent of
5404234353Sdim * the declaration (if any) that the code completion represents. For example,
5405234353Sdim * a code completion for an Objective-C method would have the method's class
5406234353Sdim * or protocol as its context.
5407234353Sdim *
5408234353Sdim * \param completion_string The code completion string whose parent is
5409234353Sdim * being queried.
5410234353Sdim *
5411243830Sdim * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL.
5412234353Sdim *
5413239462Sdim * \returns The name of the completion parent, e.g., "NSObject" if
5414234353Sdim * the completion string represents a method in the NSObject class.
5415234353Sdim */
5416234353SdimCINDEX_LINKAGE CXString
5417234353Sdimclang_getCompletionParent(CXCompletionString completion_string,
5418234353Sdim                          enum CXCursorKind *kind);
5419239462Sdim
5420234353Sdim/**
5421341825Sdim * Retrieve the brief documentation comment attached to the declaration
5422239462Sdim * that corresponds to the given completion string.
5423239462Sdim */
5424239462SdimCINDEX_LINKAGE CXString
5425239462Sdimclang_getCompletionBriefComment(CXCompletionString completion_string);
5426239462Sdim
5427239462Sdim/**
5428341825Sdim * Retrieve a completion string for an arbitrary declaration or macro
5429226633Sdim * definition cursor.
5430226633Sdim *
5431226633Sdim * \param cursor The cursor to query.
5432226633Sdim *
5433226633Sdim * \returns A non-context-sensitive completion string for declaration and macro
5434226633Sdim * definition cursors, or NULL for other kinds of cursors.
5435226633Sdim */
5436226633SdimCINDEX_LINKAGE CXCompletionString
5437226633Sdimclang_getCursorCompletionString(CXCursor cursor);
5438341825Sdim
5439226633Sdim/**
5440341825Sdim * Contains the results of code-completion.
5441201361Srdivacky *
5442201361Srdivacky * This data structure contains the results of code completion, as
5443218893Sdim * produced by \c clang_codeCompleteAt(). Its contents must be freed by
5444201361Srdivacky * \c clang_disposeCodeCompleteResults.
5445201361Srdivacky */
5446201361Srdivackytypedef struct {
5447201361Srdivacky  /**
5448341825Sdim   * The code-completion results.
5449201361Srdivacky   */
5450201361Srdivacky  CXCompletionResult *Results;
5451201361Srdivacky
5452201361Srdivacky  /**
5453341825Sdim   * The number of code-completion results stored in the
5454201361Srdivacky   * \c Results array.
5455201361Srdivacky   */
5456201361Srdivacky  unsigned NumResults;
5457201361Srdivacky} CXCodeCompleteResults;
5458201361Srdivacky
5459201361Srdivacky/**
5460341825Sdim * Retrieve the number of fix-its for the given completion index.
5461341825Sdim *
5462341825Sdim * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts
5463341825Sdim * option was set.
5464341825Sdim *
5465341825Sdim * \param results The structure keeping all completion results
5466341825Sdim *
5467341825Sdim * \param completion_index The index of the completion
5468341825Sdim *
5469341825Sdim * \return The number of fix-its which must be applied before the completion at
5470341825Sdim * completion_index can be applied
5471341825Sdim */
5472341825SdimCINDEX_LINKAGE unsigned
5473341825Sdimclang_getCompletionNumFixIts(CXCodeCompleteResults *results,
5474341825Sdim                             unsigned completion_index);
5475341825Sdim
5476341825Sdim/**
5477341825Sdim * Fix-its that *must* be applied before inserting the text for the
5478341825Sdim * corresponding completion.
5479341825Sdim *
5480341825Sdim * By default, clang_codeCompleteAt() only returns completions with empty
5481341825Sdim * fix-its. Extra completions with non-empty fix-its should be explicitly
5482341825Sdim * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts.
5483341825Sdim *
5484341825Sdim * For the clients to be able to compute position of the cursor after applying
5485341825Sdim * fix-its, the following conditions are guaranteed to hold for
5486341825Sdim * replacement_range of the stored fix-its:
5487341825Sdim *  - Ranges in the fix-its are guaranteed to never contain the completion
5488341825Sdim *  point (or identifier under completion point, if any) inside them, except
5489341825Sdim *  at the start or at the end of the range.
5490341825Sdim *  - If a fix-it range starts or ends with completion point (or starts or
5491341825Sdim *  ends after the identifier under completion point), it will contain at
5492341825Sdim *  least one character. It allows to unambiguously recompute completion
5493341825Sdim *  point after applying the fix-it.
5494341825Sdim *
5495341825Sdim * The intuition is that provided fix-its change code around the identifier we
5496341825Sdim * complete, but are not allowed to touch the identifier itself or the
5497341825Sdim * completion point. One example of completions with corrections are the ones
5498341825Sdim * replacing '.' with '->' and vice versa:
5499341825Sdim *
5500341825Sdim * std::unique_ptr<std::vector<int>> vec_ptr;
5501341825Sdim * In 'vec_ptr.^', one of the completions is 'push_back', it requires
5502341825Sdim * replacing '.' with '->'.
5503341825Sdim * In 'vec_ptr->^', one of the completions is 'release', it requires
5504341825Sdim * replacing '->' with '.'.
5505341825Sdim *
5506341825Sdim * \param results The structure keeping all completion results
5507341825Sdim *
5508341825Sdim * \param completion_index The index of the completion
5509341825Sdim *
5510341825Sdim * \param fixit_index The index of the fix-it for the completion at
5511341825Sdim * completion_index
5512341825Sdim *
5513341825Sdim * \param replacement_range The fix-it range that must be replaced before the
5514341825Sdim * completion at completion_index can be applied
5515341825Sdim *
5516341825Sdim * \returns The fix-it string that must replace the code at replacement_range
5517341825Sdim * before the completion at completion_index can be applied
5518341825Sdim */
5519341825SdimCINDEX_LINKAGE CXString clang_getCompletionFixIt(
5520341825Sdim    CXCodeCompleteResults *results, unsigned completion_index,
5521341825Sdim    unsigned fixit_index, CXSourceRange *replacement_range);
5522341825Sdim
5523341825Sdim/**
5524341825Sdim * Flags that can be passed to \c clang_codeCompleteAt() to
5525212904Sdim * modify its behavior.
5526212904Sdim *
5527212904Sdim * The enumerators in this enumeration can be bitwise-OR'd together to
5528212904Sdim * provide multiple options to \c clang_codeCompleteAt().
5529212904Sdim */
5530212904Sdimenum CXCodeComplete_Flags {
5531212904Sdim  /**
5532341825Sdim   * Whether to include macros within the set of code
5533212904Sdim   * completions returned.
5534212904Sdim   */
5535212904Sdim  CXCodeComplete_IncludeMacros = 0x01,
5536212904Sdim
5537212904Sdim  /**
5538341825Sdim   * Whether to include code patterns for language constructs
5539212904Sdim   * within the set of code completions, e.g., for loops.
5540212904Sdim   */
5541239462Sdim  CXCodeComplete_IncludeCodePatterns = 0x02,
5542239462Sdim
5543239462Sdim  /**
5544341825Sdim   * Whether to include brief documentation within the set of code
5545239462Sdim   * completions returned.
5546239462Sdim   */
5547341825Sdim  CXCodeComplete_IncludeBriefComments = 0x04,
5548341825Sdim
5549341825Sdim  /**
5550341825Sdim   * Whether to speed up completion by omitting top- or namespace-level entities
5551341825Sdim   * defined in the preamble. There's no guarantee any particular entity is
5552341825Sdim   * omitted. This may be useful if the headers are indexed externally.
5553341825Sdim   */
5554341825Sdim  CXCodeComplete_SkipPreamble = 0x08,
5555341825Sdim
5556341825Sdim  /**
5557341825Sdim   * Whether to include completions with small
5558341825Sdim   * fix-its, e.g. change '.' to '->' on member access, etc.
5559341825Sdim   */
5560341825Sdim  CXCodeComplete_IncludeCompletionsWithFixIts = 0x10
5561212904Sdim};
5562212904Sdim
5563212904Sdim/**
5564341825Sdim * Bits that represent the context under which completion is occurring.
5565224145Sdim *
5566224145Sdim * The enumerators in this enumeration may be bitwise-OR'd together if multiple
5567224145Sdim * contexts are occurring simultaneously.
5568224145Sdim */
5569224145Sdimenum CXCompletionContext {
5570224145Sdim  /**
5571341825Sdim   * The context for completions is unexposed, as only Clang results
5572224145Sdim   * should be included. (This is equivalent to having no context bits set.)
5573224145Sdim   */
5574224145Sdim  CXCompletionContext_Unexposed = 0,
5575341825Sdim
5576224145Sdim  /**
5577341825Sdim   * Completions for any possible type should be included in the results.
5578224145Sdim   */
5579224145Sdim  CXCompletionContext_AnyType = 1 << 0,
5580341825Sdim
5581224145Sdim  /**
5582341825Sdim   * Completions for any possible value (variables, function calls, etc.)
5583224145Sdim   * should be included in the results.
5584224145Sdim   */
5585224145Sdim  CXCompletionContext_AnyValue = 1 << 1,
5586224145Sdim  /**
5587341825Sdim   * Completions for values that resolve to an Objective-C object should
5588224145Sdim   * be included in the results.
5589224145Sdim   */
5590224145Sdim  CXCompletionContext_ObjCObjectValue = 1 << 2,
5591224145Sdim  /**
5592341825Sdim   * Completions for values that resolve to an Objective-C selector
5593224145Sdim   * should be included in the results.
5594224145Sdim   */
5595224145Sdim  CXCompletionContext_ObjCSelectorValue = 1 << 3,
5596224145Sdim  /**
5597341825Sdim   * Completions for values that resolve to a C++ class type should be
5598224145Sdim   * included in the results.
5599224145Sdim   */
5600224145Sdim  CXCompletionContext_CXXClassTypeValue = 1 << 4,
5601341825Sdim
5602224145Sdim  /**
5603341825Sdim   * Completions for fields of the member being accessed using the dot
5604224145Sdim   * operator should be included in the results.
5605224145Sdim   */
5606224145Sdim  CXCompletionContext_DotMemberAccess = 1 << 5,
5607224145Sdim  /**
5608341825Sdim   * Completions for fields of the member being accessed using the arrow
5609224145Sdim   * operator should be included in the results.
5610224145Sdim   */
5611224145Sdim  CXCompletionContext_ArrowMemberAccess = 1 << 6,
5612224145Sdim  /**
5613341825Sdim   * Completions for properties of the Objective-C object being accessed
5614224145Sdim   * using the dot operator should be included in the results.
5615224145Sdim   */
5616224145Sdim  CXCompletionContext_ObjCPropertyAccess = 1 << 7,
5617341825Sdim
5618224145Sdim  /**
5619341825Sdim   * Completions for enum tags should be included in the results.
5620224145Sdim   */
5621224145Sdim  CXCompletionContext_EnumTag = 1 << 8,
5622224145Sdim  /**
5623341825Sdim   * Completions for union tags should be included in the results.
5624224145Sdim   */
5625224145Sdim  CXCompletionContext_UnionTag = 1 << 9,
5626224145Sdim  /**
5627341825Sdim   * Completions for struct tags should be included in the results.
5628224145Sdim   */
5629224145Sdim  CXCompletionContext_StructTag = 1 << 10,
5630341825Sdim
5631224145Sdim  /**
5632341825Sdim   * Completions for C++ class names should be included in the results.
5633224145Sdim   */
5634224145Sdim  CXCompletionContext_ClassTag = 1 << 11,
5635224145Sdim  /**
5636341825Sdim   * Completions for C++ namespaces and namespace aliases should be
5637224145Sdim   * included in the results.
5638224145Sdim   */
5639224145Sdim  CXCompletionContext_Namespace = 1 << 12,
5640224145Sdim  /**
5641341825Sdim   * Completions for C++ nested name specifiers should be included in
5642224145Sdim   * the results.
5643224145Sdim   */
5644224145Sdim  CXCompletionContext_NestedNameSpecifier = 1 << 13,
5645341825Sdim
5646224145Sdim  /**
5647341825Sdim   * Completions for Objective-C interfaces (classes) should be included
5648224145Sdim   * in the results.
5649224145Sdim   */
5650224145Sdim  CXCompletionContext_ObjCInterface = 1 << 14,
5651224145Sdim  /**
5652341825Sdim   * Completions for Objective-C protocols should be included in
5653224145Sdim   * the results.
5654224145Sdim   */
5655224145Sdim  CXCompletionContext_ObjCProtocol = 1 << 15,
5656224145Sdim  /**
5657341825Sdim   * Completions for Objective-C categories should be included in
5658224145Sdim   * the results.
5659224145Sdim   */
5660224145Sdim  CXCompletionContext_ObjCCategory = 1 << 16,
5661224145Sdim  /**
5662341825Sdim   * Completions for Objective-C instance messages should be included
5663224145Sdim   * in the results.
5664224145Sdim   */
5665224145Sdim  CXCompletionContext_ObjCInstanceMessage = 1 << 17,
5666224145Sdim  /**
5667341825Sdim   * Completions for Objective-C class messages should be included in
5668224145Sdim   * the results.
5669224145Sdim   */
5670224145Sdim  CXCompletionContext_ObjCClassMessage = 1 << 18,
5671224145Sdim  /**
5672341825Sdim   * Completions for Objective-C selector names should be included in
5673224145Sdim   * the results.
5674224145Sdim   */
5675224145Sdim  CXCompletionContext_ObjCSelectorName = 1 << 19,
5676341825Sdim
5677224145Sdim  /**
5678341825Sdim   * Completions for preprocessor macro names should be included in
5679224145Sdim   * the results.
5680224145Sdim   */
5681224145Sdim  CXCompletionContext_MacroName = 1 << 20,
5682341825Sdim
5683224145Sdim  /**
5684341825Sdim   * Natural language completions should be included in the results.
5685224145Sdim   */
5686224145Sdim  CXCompletionContext_NaturalLanguage = 1 << 21,
5687341825Sdim
5688224145Sdim  /**
5689344779Sdim   * #include file completions should be included in the results.
5690344779Sdim   */
5691344779Sdim  CXCompletionContext_IncludedFile = 1 << 22,
5692344779Sdim
5693344779Sdim  /**
5694341825Sdim   * The current context is unknown, so set all contexts.
5695224145Sdim   */
5696344779Sdim  CXCompletionContext_Unknown = ((1 << 23) - 1)
5697224145Sdim};
5698341825Sdim
5699224145Sdim/**
5700341825Sdim * Returns a default set of code-completion options that can be
5701341825Sdim * passed to\c clang_codeCompleteAt().
5702212904Sdim */
5703212904SdimCINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
5704212904Sdim
5705212904Sdim/**
5706341825Sdim * Perform code completion at a given location in a translation unit.
5707212904Sdim *
5708212904Sdim * This function performs code completion at a particular file, line, and
5709212904Sdim * column within source code, providing results that suggest potential
5710212904Sdim * code snippets based on the context of the completion. The basic model
5711212904Sdim * for code completion is that Clang will parse a complete source file,
5712212904Sdim * performing syntax checking up to the location where code-completion has
5713212904Sdim * been requested. At that point, a special code-completion token is passed
5714212904Sdim * to the parser, which recognizes this token and determines, based on the
5715212904Sdim * current location in the C/Objective-C/C++ grammar and the state of
5716212904Sdim * semantic analysis, what completions to provide. These completions are
5717212904Sdim * returned via a new \c CXCodeCompleteResults structure.
5718212904Sdim *
5719212904Sdim * Code completion itself is meant to be triggered by the client when the
5720212904Sdim * user types punctuation characters or whitespace, at which point the
5721212904Sdim * code-completion location will coincide with the cursor. For example, if \c p
5722212904Sdim * is a pointer, code-completion might be triggered after the "-" and then
5723341825Sdim * after the ">" in \c p->. When the code-completion location is after the ">",
5724212904Sdim * the completion results will provide, e.g., the members of the struct that
5725212904Sdim * "p" points to. The client is responsible for placing the cursor at the
5726212904Sdim * beginning of the token currently being typed, then filtering the results
5727212904Sdim * based on the contents of the token. For example, when code-completing for
5728212904Sdim * the expression \c p->get, the client should provide the location just after
5729212904Sdim * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
5730212904Sdim * client can filter the results based on the current token text ("get"), only
5731212904Sdim * showing those results that start with "get". The intent of this interface
5732212904Sdim * is to separate the relatively high-latency acquisition of code-completion
5733212904Sdim * results from the filtering of results on a per-character basis, which must
5734212904Sdim * have a lower latency.
5735212904Sdim *
5736212904Sdim * \param TU The translation unit in which code-completion should
5737212904Sdim * occur. The source files for this translation unit need not be
5738212904Sdim * completely up-to-date (and the contents of those source files may
5739212904Sdim * be overridden via \p unsaved_files). Cursors referring into the
5740212904Sdim * translation unit may be invalidated by this invocation.
5741212904Sdim *
5742212904Sdim * \param complete_filename The name of the source file where code
5743212904Sdim * completion should be performed. This filename may be any file
5744212904Sdim * included in the translation unit.
5745212904Sdim *
5746212904Sdim * \param complete_line The line at which code-completion should occur.
5747212904Sdim *
5748212904Sdim * \param complete_column The column at which code-completion should occur.
5749212904Sdim * Note that the column should point just after the syntactic construct that
5750212904Sdim * initiated code completion, and not in the middle of a lexical token.
5751212904Sdim *
5752309124Sdim * \param unsaved_files the Files that have not yet been saved to disk
5753212904Sdim * but may be required for parsing or code completion, including the
5754212904Sdim * contents of those files.  The contents and name of these files (as
5755212904Sdim * specified by CXUnsavedFile) are copied when necessary, so the
5756212904Sdim * client only needs to guarantee their validity until the call to
5757212904Sdim * this function returns.
5758212904Sdim *
5759212904Sdim * \param num_unsaved_files The number of unsaved file entries in \p
5760212904Sdim * unsaved_files.
5761212904Sdim *
5762212904Sdim * \param options Extra options that control the behavior of code
5763212904Sdim * completion, expressed as a bitwise OR of the enumerators of the
5764341825Sdim * CXCodeComplete_Flags enumeration. The
5765212904Sdim * \c clang_defaultCodeCompleteOptions() function returns a default set
5766212904Sdim * of code-completion options.
5767212904Sdim *
5768212904Sdim * \returns If successful, a new \c CXCodeCompleteResults structure
5769212904Sdim * containing code-completion results, which should eventually be
5770212904Sdim * freed with \c clang_disposeCodeCompleteResults(). If code
5771212904Sdim * completion fails, returns NULL.
5772212904Sdim */
5773212904SdimCINDEX_LINKAGE
5774212904SdimCXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
5775212904Sdim                                            const char *complete_filename,
5776212904Sdim                                            unsigned complete_line,
5777212904Sdim                                            unsigned complete_column,
5778212904Sdim                                            struct CXUnsavedFile *unsaved_files,
5779212904Sdim                                            unsigned num_unsaved_files,
5780212904Sdim                                            unsigned options);
5781212904Sdim
5782212904Sdim/**
5783341825Sdim * Sort the code-completion results in case-insensitive alphabetical
5784212904Sdim * order.
5785212904Sdim *
5786212904Sdim * \param Results The set of results to sort.
5787212904Sdim * \param NumResults The number of results in \p Results.
5788212904Sdim */
5789212904SdimCINDEX_LINKAGE
5790212904Sdimvoid clang_sortCodeCompletionResults(CXCompletionResult *Results,
5791212904Sdim                                     unsigned NumResults);
5792341825Sdim
5793212904Sdim/**
5794341825Sdim * Free the given set of code-completion results.
5795201361Srdivacky */
5796203955SrdivackyCINDEX_LINKAGE
5797201361Srdivackyvoid clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
5798341825Sdim
5799202879Srdivacky/**
5800341825Sdim * Determine the number of diagnostics produced prior to the
5801204643Srdivacky * location where code completion was performed.
5802204643Srdivacky */
5803205219SrdivackyCINDEX_LINKAGE
5804204643Srdivackyunsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
5805204643Srdivacky
5806204643Srdivacky/**
5807341825Sdim * Retrieve a diagnostic associated with the given code completion.
5808204643Srdivacky *
5809239462Sdim * \param Results the code completion results to query.
5810204643Srdivacky * \param Index the zero-based diagnostic number to retrieve.
5811204643Srdivacky *
5812204643Srdivacky * \returns the requested diagnostic. This diagnostic must be freed
5813204643Srdivacky * via a call to \c clang_disposeDiagnostic().
5814204643Srdivacky */
5815205219SrdivackyCINDEX_LINKAGE
5816204643SrdivackyCXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
5817204643Srdivacky                                             unsigned Index);
5818204643Srdivacky
5819204643Srdivacky/**
5820341825Sdim * Determines what completions are appropriate for the context
5821224145Sdim * the given code completion.
5822341825Sdim *
5823224145Sdim * \param Results the code completion results to query
5824224145Sdim *
5825224145Sdim * \returns the kinds of completions that are appropriate for use
5826224145Sdim * along with the given code completion results.
5827224145Sdim */
5828224145SdimCINDEX_LINKAGE
5829224145Sdimunsigned long long clang_codeCompleteGetContexts(
5830224145Sdim                                                CXCodeCompleteResults *Results);
5831226633Sdim
5832226633Sdim/**
5833341825Sdim * Returns the cursor kind for the container for the current code
5834226633Sdim * completion context. The container is only guaranteed to be set for
5835226633Sdim * contexts where a container exists (i.e. member accesses or Objective-C
5836226633Sdim * message sends); if there is not a container, this function will return
5837226633Sdim * CXCursor_InvalidCode.
5838226633Sdim *
5839226633Sdim * \param Results the code completion results to query
5840226633Sdim *
5841226633Sdim * \param IsIncomplete on return, this value will be false if Clang has complete
5842226633Sdim * information about the container. If Clang does not have complete
5843226633Sdim * information, this value will be true.
5844226633Sdim *
5845226633Sdim * \returns the container kind, or CXCursor_InvalidCode if there is not a
5846226633Sdim * container
5847226633Sdim */
5848226633SdimCINDEX_LINKAGE
5849226633Sdimenum CXCursorKind clang_codeCompleteGetContainerKind(
5850226633Sdim                                                 CXCodeCompleteResults *Results,
5851226633Sdim                                                     unsigned *IsIncomplete);
5852226633Sdim
5853226633Sdim/**
5854341825Sdim * Returns the USR for the container for the current code completion
5855226633Sdim * context. If there is not a container for the current context, this
5856226633Sdim * function will return the empty string.
5857226633Sdim *
5858226633Sdim * \param Results the code completion results to query
5859226633Sdim *
5860226633Sdim * \returns the USR for the container
5861226633Sdim */
5862226633SdimCINDEX_LINKAGE
5863226633SdimCXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results);
5864296417Sdim
5865224145Sdim/**
5866341825Sdim * Returns the currently-entered selector for an Objective-C message
5867226633Sdim * send, formatted like "initWithFoo:bar:". Only guaranteed to return a
5868226633Sdim * non-empty string for CXCompletionContext_ObjCInstanceMessage and
5869226633Sdim * CXCompletionContext_ObjCClassMessage.
5870226633Sdim *
5871226633Sdim * \param Results the code completion results to query
5872226633Sdim *
5873226633Sdim * \returns the selector (or partial selector) that has been entered thus far
5874226633Sdim * for an Objective-C message send.
5875226633Sdim */
5876226633SdimCINDEX_LINKAGE
5877226633SdimCXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results);
5878341825Sdim
5879226633Sdim/**
5880202879Srdivacky * @}
5881202879Srdivacky */
5882203955Srdivacky
5883202879Srdivacky/**
5884202879Srdivacky * \defgroup CINDEX_MISC Miscellaneous utility functions
5885202879Srdivacky *
5886202879Srdivacky * @{
5887202879Srdivacky */
5888202879Srdivacky
5889202879Srdivacky/**
5890341825Sdim * Return a version string, suitable for showing to a user, but not
5891203955Srdivacky *        intended to be parsed (the format is not guaranteed to be stable).
5892203955Srdivacky */
5893249423SdimCINDEX_LINKAGE CXString clang_getClangVersion(void);
5894203955Srdivacky
5895221345Sdim/**
5896341825Sdim * Enable/disable crash recovery.
5897221345Sdim *
5898239462Sdim * \param isEnabled Flag to indicate if crash recovery is enabled.  A non-zero
5899239462Sdim *        value enables crash recovery, while 0 disables it.
5900221345Sdim */
5901221345SdimCINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
5902341825Sdim
5903203955Srdivacky /**
5904341825Sdim  * Visitor invoked for each file in a translation unit
5905203955Srdivacky  *        (used with clang_getInclusions()).
5906203955Srdivacky  *
5907203955Srdivacky  * This visitor function will be invoked by clang_getInclusions() for each
5908239462Sdim  * file included (either at the top-level or by \#include directives) within
5909203955Srdivacky  * a translation unit.  The first argument is the file being included, and
5910203955Srdivacky  * the second and third arguments provide the inclusion stack.  The
5911203955Srdivacky  * array is sorted in order of immediate inclusion.  For example,
5912203955Srdivacky  * the first element refers to the location that included 'included_file'.
5913203955Srdivacky  */
5914203955Srdivackytypedef void (*CXInclusionVisitor)(CXFile included_file,
5915203955Srdivacky                                   CXSourceLocation* inclusion_stack,
5916203955Srdivacky                                   unsigned include_len,
5917203955Srdivacky                                   CXClientData client_data);
5918203955Srdivacky
5919203955Srdivacky/**
5920341825Sdim * Visit the set of preprocessor inclusions in a translation unit.
5921203955Srdivacky *   The visitor function is called with the provided data for every included
5922203955Srdivacky *   file.  This does not include headers included by the PCH file (unless one
5923203955Srdivacky *   is inspecting the inclusions in the PCH file itself).
5924203955Srdivacky */
5925203955SrdivackyCINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
5926203955Srdivacky                                        CXInclusionVisitor visitor,
5927203955Srdivacky                                        CXClientData client_data);
5928203955Srdivacky
5929309124Sdimtypedef enum {
5930309124Sdim  CXEval_Int = 1 ,
5931309124Sdim  CXEval_Float = 2,
5932309124Sdim  CXEval_ObjCStrLiteral = 3,
5933309124Sdim  CXEval_StrLiteral = 4,
5934309124Sdim  CXEval_CFStr = 5,
5935309124Sdim  CXEval_Other = 6,
5936309124Sdim
5937309124Sdim  CXEval_UnExposed = 0
5938309124Sdim
5939309124Sdim} CXEvalResultKind ;
5940309124Sdim
5941203955Srdivacky/**
5942341825Sdim * Evaluation result of a cursor
5943309124Sdim */
5944309124Sdimtypedef void * CXEvalResult;
5945309124Sdim
5946309124Sdim/**
5947341825Sdim * If cursor is a statement declaration tries to evaluate the
5948309124Sdim * statement and if its variable, tries to evaluate its initializer,
5949309124Sdim * into its corresponding type.
5950309124Sdim */
5951309124SdimCINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
5952309124Sdim
5953309124Sdim/**
5954341825Sdim * Returns the kind of the evaluated result.
5955309124Sdim */
5956309124SdimCINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
5957309124Sdim
5958309124Sdim/**
5959341825Sdim * Returns the evaluation result as integer if the
5960309124Sdim * kind is Int.
5961309124Sdim */
5962309124SdimCINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
5963309124Sdim
5964309124Sdim/**
5965341825Sdim * Returns the evaluation result as a long long integer if the
5966314564Sdim * kind is Int. This prevents overflows that may happen if the result is
5967314564Sdim * returned with clang_EvalResult_getAsInt.
5968314564Sdim */
5969314564SdimCINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5970314564Sdim
5971314564Sdim/**
5972341825Sdim * Returns a non-zero value if the kind is Int and the evaluation
5973314564Sdim * result resulted in an unsigned integer.
5974314564Sdim */
5975314564SdimCINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5976314564Sdim
5977314564Sdim/**
5978341825Sdim * Returns the evaluation result as an unsigned integer if
5979314564Sdim * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5980314564Sdim */
5981314564SdimCINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5982314564Sdim
5983314564Sdim/**
5984341825Sdim * Returns the evaluation result as double if the
5985309124Sdim * kind is double.
5986309124Sdim */
5987309124SdimCINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
5988309124Sdim
5989309124Sdim/**
5990341825Sdim * Returns the evaluation result as a constant string if the
5991309124Sdim * kind is other than Int or float. User must not free this pointer,
5992309124Sdim * instead call clang_EvalResult_dispose on the CXEvalResult returned
5993309124Sdim * by clang_Cursor_Evaluate.
5994309124Sdim */
5995309124SdimCINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
5996309124Sdim
5997309124Sdim/**
5998341825Sdim * Disposes the created Eval memory.
5999309124Sdim */
6000309124SdimCINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E);
6001309124Sdim/**
6002202879Srdivacky * @}
6003202879Srdivacky */
6004203955Srdivacky
6005224145Sdim/** \defgroup CINDEX_REMAPPING Remapping functions
6006224145Sdim *
6007224145Sdim * @{
6008224145Sdim */
6009224145Sdim
6010202879Srdivacky/**
6011341825Sdim * A remapping of original source files and their translated files.
6012224145Sdim */
6013224145Sdimtypedef void *CXRemapping;
6014224145Sdim
6015224145Sdim/**
6016341825Sdim * Retrieve a remapping.
6017224145Sdim *
6018224145Sdim * \param path the path that contains metadata about remappings.
6019224145Sdim *
6020224145Sdim * \returns the requested remapping. This remapping must be freed
6021224145Sdim * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6022224145Sdim */
6023224145SdimCINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
6024224145Sdim
6025224145Sdim/**
6026341825Sdim * Retrieve a remapping.
6027234353Sdim *
6028234353Sdim * \param filePaths pointer to an array of file paths containing remapping info.
6029234353Sdim *
6030234353Sdim * \param numFiles number of file paths.
6031234353Sdim *
6032234353Sdim * \returns the requested remapping. This remapping must be freed
6033234353Sdim * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
6034234353Sdim */
6035234353SdimCINDEX_LINKAGE
6036234353SdimCXRemapping clang_getRemappingsFromFileList(const char **filePaths,
6037234353Sdim                                            unsigned numFiles);
6038234353Sdim
6039234353Sdim/**
6040341825Sdim * Determine the number of remappings.
6041224145Sdim */
6042224145SdimCINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
6043224145Sdim
6044224145Sdim/**
6045341825Sdim * Get the original and the associated filename from the remapping.
6046341825Sdim *
6047224145Sdim * \param original If non-NULL, will be set to the original filename.
6048224145Sdim *
6049224145Sdim * \param transformed If non-NULL, will be set to the filename that the original
6050224145Sdim * is associated with.
6051224145Sdim */
6052224145SdimCINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
6053224145Sdim                                     CXString *original, CXString *transformed);
6054224145Sdim
6055224145Sdim/**
6056341825Sdim * Dispose the remapping.
6057224145Sdim */
6058224145SdimCINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
6059224145Sdim
6060224145Sdim/**
6061202879Srdivacky * @}
6062202879Srdivacky */
6063203955Srdivacky
6064226633Sdim/** \defgroup CINDEX_HIGH Higher level API functions
6065226633Sdim *
6066226633Sdim * @{
6067226633Sdim */
6068226633Sdim
6069226633Sdimenum CXVisitorResult {
6070226633Sdim  CXVisit_Break,
6071226633Sdim  CXVisit_Continue
6072226633Sdim};
6073226633Sdim
6074309124Sdimtypedef struct CXCursorAndRangeVisitor {
6075226633Sdim  void *context;
6076226633Sdim  enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange);
6077226633Sdim} CXCursorAndRangeVisitor;
6078226633Sdim
6079249423Sdimtypedef enum {
6080249423Sdim  /**
6081341825Sdim   * Function returned successfully.
6082249423Sdim   */
6083249423Sdim  CXResult_Success = 0,
6084249423Sdim  /**
6085341825Sdim   * One of the parameters was invalid for the function.
6086249423Sdim   */
6087249423Sdim  CXResult_Invalid = 1,
6088249423Sdim  /**
6089341825Sdim   * The function was terminated by a callback (e.g. it returned
6090249423Sdim   * CXVisit_Break)
6091249423Sdim   */
6092249423Sdim  CXResult_VisitBreak = 2
6093249423Sdim
6094249423Sdim} CXResult;
6095249423Sdim
6096224145Sdim/**
6097341825Sdim * Find references of a declaration in a specific file.
6098341825Sdim *
6099226633Sdim * \param cursor pointing to a declaration or a reference of one.
6100226633Sdim *
6101226633Sdim * \param file to search for references.
6102226633Sdim *
6103226633Sdim * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6104226633Sdim * each reference found.
6105226633Sdim * The CXSourceRange will point inside the file; if the reference is inside
6106226633Sdim * a macro (and not a macro argument) the CXSourceRange will be invalid.
6107249423Sdim *
6108249423Sdim * \returns one of the CXResult enumerators.
6109226633Sdim */
6110249423SdimCINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
6111226633Sdim                                               CXCursorAndRangeVisitor visitor);
6112226633Sdim
6113249423Sdim/**
6114341825Sdim * Find #import/#include directives in a specific file.
6115249423Sdim *
6116249423Sdim * \param TU translation unit containing the file to query.
6117249423Sdim *
6118249423Sdim * \param file to search for #import/#include directives.
6119249423Sdim *
6120249423Sdim * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for
6121249423Sdim * each directive found.
6122249423Sdim *
6123249423Sdim * \returns one of the CXResult enumerators.
6124249423Sdim */
6125249423SdimCINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
6126249423Sdim                                                 CXFile file,
6127249423Sdim                                              CXCursorAndRangeVisitor visitor);
6128249423Sdim
6129226633Sdim#ifdef __has_feature
6130226633Sdim#  if __has_feature(blocks)
6131226633Sdim
6132226633Sdimtypedef enum CXVisitorResult
6133226633Sdim    (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
6134226633Sdim
6135226633SdimCINDEX_LINKAGE
6136249423SdimCXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
6137249423Sdim                                             CXCursorAndRangeVisitorBlock);
6138226633Sdim
6139249423SdimCINDEX_LINKAGE
6140249423SdimCXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
6141249423Sdim                                           CXCursorAndRangeVisitorBlock);
6142249423Sdim
6143226633Sdim#  endif
6144226633Sdim#endif
6145226633Sdim
6146226633Sdim/**
6147341825Sdim * The client's data object that is associated with a CXFile.
6148234353Sdim */
6149234353Sdimtypedef void *CXIdxClientFile;
6150234353Sdim
6151234353Sdim/**
6152341825Sdim * The client's data object that is associated with a semantic entity.
6153234353Sdim */
6154234353Sdimtypedef void *CXIdxClientEntity;
6155234353Sdim
6156234353Sdim/**
6157341825Sdim * The client's data object that is associated with a semantic container
6158234353Sdim * of entities.
6159234353Sdim */
6160234353Sdimtypedef void *CXIdxClientContainer;
6161234353Sdim
6162234353Sdim/**
6163341825Sdim * The client's data object that is associated with an AST file (PCH
6164234353Sdim * or module).
6165234353Sdim */
6166234353Sdimtypedef void *CXIdxClientASTFile;
6167234353Sdim
6168234353Sdim/**
6169341825Sdim * Source location passed to index callbacks.
6170234353Sdim */
6171234353Sdimtypedef struct {
6172234353Sdim  void *ptr_data[2];
6173234353Sdim  unsigned int_data;
6174234353Sdim} CXIdxLoc;
6175234353Sdim
6176234353Sdim/**
6177341825Sdim * Data for ppIncludedFile callback.
6178234353Sdim */
6179234353Sdimtypedef struct {
6180234353Sdim  /**
6181341825Sdim   * Location of '#' in the \#include/\#import directive.
6182234353Sdim   */
6183234353Sdim  CXIdxLoc hashLoc;
6184234353Sdim  /**
6185341825Sdim   * Filename as written in the \#include/\#import directive.
6186234353Sdim   */
6187234353Sdim  const char *filename;
6188234353Sdim  /**
6189341825Sdim   * The actual file that the \#include/\#import directive resolved to.
6190234353Sdim   */
6191234353Sdim  CXFile file;
6192234353Sdim  int isImport;
6193234353Sdim  int isAngled;
6194243830Sdim  /**
6195341825Sdim   * Non-zero if the directive was automatically turned into a module
6196243830Sdim   * import.
6197243830Sdim   */
6198243830Sdim  int isModuleImport;
6199234353Sdim} CXIdxIncludedFileInfo;
6200234353Sdim
6201234353Sdim/**
6202341825Sdim * Data for IndexerCallbacks#importedASTFile.
6203234353Sdim */
6204234353Sdimtypedef struct {
6205243830Sdim  /**
6206341825Sdim   * Top level AST file containing the imported PCH, module or submodule.
6207243830Sdim   */
6208234353Sdim  CXFile file;
6209234353Sdim  /**
6210341825Sdim   * The imported module or NULL if the AST file is a PCH.
6211234353Sdim   */
6212243830Sdim  CXModule module;
6213243830Sdim  /**
6214341825Sdim   * Location where the file is imported. Applicable only for modules.
6215243830Sdim   */
6216234353Sdim  CXIdxLoc loc;
6217234353Sdim  /**
6218341825Sdim   * Non-zero if an inclusion directive was automatically turned into
6219243830Sdim   * a module import. Applicable only for modules.
6220234353Sdim   */
6221243830Sdim  int isImplicit;
6222243830Sdim
6223234353Sdim} CXIdxImportedASTFileInfo;
6224234353Sdim
6225234353Sdimtypedef enum {
6226234353Sdim  CXIdxEntity_Unexposed     = 0,
6227234353Sdim  CXIdxEntity_Typedef       = 1,
6228234353Sdim  CXIdxEntity_Function      = 2,
6229234353Sdim  CXIdxEntity_Variable      = 3,
6230234353Sdim  CXIdxEntity_Field         = 4,
6231234353Sdim  CXIdxEntity_EnumConstant  = 5,
6232234353Sdim
6233234353Sdim  CXIdxEntity_ObjCClass     = 6,
6234234353Sdim  CXIdxEntity_ObjCProtocol  = 7,
6235234353Sdim  CXIdxEntity_ObjCCategory  = 8,
6236234353Sdim
6237234353Sdim  CXIdxEntity_ObjCInstanceMethod = 9,
6238234353Sdim  CXIdxEntity_ObjCClassMethod    = 10,
6239234353Sdim  CXIdxEntity_ObjCProperty  = 11,
6240234353Sdim  CXIdxEntity_ObjCIvar      = 12,
6241234353Sdim
6242234353Sdim  CXIdxEntity_Enum          = 13,
6243234353Sdim  CXIdxEntity_Struct        = 14,
6244234353Sdim  CXIdxEntity_Union         = 15,
6245234353Sdim
6246234353Sdim  CXIdxEntity_CXXClass              = 16,
6247234353Sdim  CXIdxEntity_CXXNamespace          = 17,
6248234353Sdim  CXIdxEntity_CXXNamespaceAlias     = 18,
6249234353Sdim  CXIdxEntity_CXXStaticVariable     = 19,
6250234353Sdim  CXIdxEntity_CXXStaticMethod       = 20,
6251234353Sdim  CXIdxEntity_CXXInstanceMethod     = 21,
6252234353Sdim  CXIdxEntity_CXXConstructor        = 22,
6253234353Sdim  CXIdxEntity_CXXDestructor         = 23,
6254234353Sdim  CXIdxEntity_CXXConversionFunction = 24,
6255243830Sdim  CXIdxEntity_CXXTypeAlias          = 25,
6256243830Sdim  CXIdxEntity_CXXInterface          = 26
6257234353Sdim
6258234353Sdim} CXIdxEntityKind;
6259234353Sdim
6260234353Sdimtypedef enum {
6261234353Sdim  CXIdxEntityLang_None = 0,
6262234353Sdim  CXIdxEntityLang_C    = 1,
6263234353Sdim  CXIdxEntityLang_ObjC = 2,
6264321369Sdim  CXIdxEntityLang_CXX  = 3,
6265321369Sdim  CXIdxEntityLang_Swift  = 4
6266234353Sdim} CXIdxEntityLanguage;
6267234353Sdim
6268234353Sdim/**
6269341825Sdim * Extra C++ template information for an entity. This can apply to:
6270234353Sdim * CXIdxEntity_Function
6271234353Sdim * CXIdxEntity_CXXClass
6272234353Sdim * CXIdxEntity_CXXStaticMethod
6273234353Sdim * CXIdxEntity_CXXInstanceMethod
6274234353Sdim * CXIdxEntity_CXXConstructor
6275234353Sdim * CXIdxEntity_CXXConversionFunction
6276234353Sdim * CXIdxEntity_CXXTypeAlias
6277234353Sdim */
6278234353Sdimtypedef enum {
6279234353Sdim  CXIdxEntity_NonTemplate   = 0,
6280234353Sdim  CXIdxEntity_Template      = 1,
6281234353Sdim  CXIdxEntity_TemplatePartialSpecialization = 2,
6282234353Sdim  CXIdxEntity_TemplateSpecialization = 3
6283234353Sdim} CXIdxEntityCXXTemplateKind;
6284234353Sdim
6285234353Sdimtypedef enum {
6286234353Sdim  CXIdxAttr_Unexposed     = 0,
6287234353Sdim  CXIdxAttr_IBAction      = 1,
6288234353Sdim  CXIdxAttr_IBOutlet      = 2,
6289234353Sdim  CXIdxAttr_IBOutletCollection = 3
6290234353Sdim} CXIdxAttrKind;
6291234353Sdim
6292234353Sdimtypedef struct {
6293234353Sdim  CXIdxAttrKind kind;
6294234353Sdim  CXCursor cursor;
6295234353Sdim  CXIdxLoc loc;
6296234353Sdim} CXIdxAttrInfo;
6297234353Sdim
6298234353Sdimtypedef struct {
6299234353Sdim  CXIdxEntityKind kind;
6300234353Sdim  CXIdxEntityCXXTemplateKind templateKind;
6301234353Sdim  CXIdxEntityLanguage lang;
6302234353Sdim  const char *name;
6303234353Sdim  const char *USR;
6304234353Sdim  CXCursor cursor;
6305234353Sdim  const CXIdxAttrInfo *const *attributes;
6306234353Sdim  unsigned numAttributes;
6307234353Sdim} CXIdxEntityInfo;
6308234353Sdim
6309234353Sdimtypedef struct {
6310234353Sdim  CXCursor cursor;
6311234353Sdim} CXIdxContainerInfo;
6312234353Sdim
6313234353Sdimtypedef struct {
6314234353Sdim  const CXIdxAttrInfo *attrInfo;
6315234353Sdim  const CXIdxEntityInfo *objcClass;
6316234353Sdim  CXCursor classCursor;
6317234353Sdim  CXIdxLoc classLoc;
6318234353Sdim} CXIdxIBOutletCollectionAttrInfo;
6319234353Sdim
6320249423Sdimtypedef enum {
6321249423Sdim  CXIdxDeclFlag_Skipped = 0x1
6322249423Sdim} CXIdxDeclInfoFlags;
6323249423Sdim
6324234353Sdimtypedef struct {
6325234353Sdim  const CXIdxEntityInfo *entityInfo;
6326234353Sdim  CXCursor cursor;
6327234353Sdim  CXIdxLoc loc;
6328234353Sdim  const CXIdxContainerInfo *semanticContainer;
6329234353Sdim  /**
6330341825Sdim   * Generally same as #semanticContainer but can be different in
6331234353Sdim   * cases like out-of-line C++ member functions.
6332234353Sdim   */
6333234353Sdim  const CXIdxContainerInfo *lexicalContainer;
6334234353Sdim  int isRedeclaration;
6335234353Sdim  int isDefinition;
6336234353Sdim  int isContainer;
6337234353Sdim  const CXIdxContainerInfo *declAsContainer;
6338234353Sdim  /**
6339341825Sdim   * Whether the declaration exists in code or was created implicitly
6340276479Sdim   * by the compiler, e.g. implicit Objective-C methods for properties.
6341234353Sdim   */
6342234353Sdim  int isImplicit;
6343234353Sdim  const CXIdxAttrInfo *const *attributes;
6344234353Sdim  unsigned numAttributes;
6345249423Sdim
6346249423Sdim  unsigned flags;
6347249423Sdim
6348234353Sdim} CXIdxDeclInfo;
6349234353Sdim
6350234353Sdimtypedef enum {
6351234353Sdim  CXIdxObjCContainer_ForwardRef = 0,
6352234353Sdim  CXIdxObjCContainer_Interface = 1,
6353234353Sdim  CXIdxObjCContainer_Implementation = 2
6354234353Sdim} CXIdxObjCContainerKind;
6355234353Sdim
6356234353Sdimtypedef struct {
6357234353Sdim  const CXIdxDeclInfo *declInfo;
6358234353Sdim  CXIdxObjCContainerKind kind;
6359234353Sdim} CXIdxObjCContainerDeclInfo;
6360234353Sdim
6361234353Sdimtypedef struct {
6362234353Sdim  const CXIdxEntityInfo *base;
6363234353Sdim  CXCursor cursor;
6364234353Sdim  CXIdxLoc loc;
6365234353Sdim} CXIdxBaseClassInfo;
6366234353Sdim
6367234353Sdimtypedef struct {
6368234353Sdim  const CXIdxEntityInfo *protocol;
6369234353Sdim  CXCursor cursor;
6370234353Sdim  CXIdxLoc loc;
6371234353Sdim} CXIdxObjCProtocolRefInfo;
6372234353Sdim
6373234353Sdimtypedef struct {
6374234353Sdim  const CXIdxObjCProtocolRefInfo *const *protocols;
6375234353Sdim  unsigned numProtocols;
6376234353Sdim} CXIdxObjCProtocolRefListInfo;
6377234353Sdim
6378234353Sdimtypedef struct {
6379234353Sdim  const CXIdxObjCContainerDeclInfo *containerInfo;
6380234353Sdim  const CXIdxBaseClassInfo *superInfo;
6381234353Sdim  const CXIdxObjCProtocolRefListInfo *protocols;
6382234353Sdim} CXIdxObjCInterfaceDeclInfo;
6383234353Sdim
6384234353Sdimtypedef struct {
6385234353Sdim  const CXIdxObjCContainerDeclInfo *containerInfo;
6386234353Sdim  const CXIdxEntityInfo *objcClass;
6387234353Sdim  CXCursor classCursor;
6388234353Sdim  CXIdxLoc classLoc;
6389234353Sdim  const CXIdxObjCProtocolRefListInfo *protocols;
6390234353Sdim} CXIdxObjCCategoryDeclInfo;
6391234353Sdim
6392234353Sdimtypedef struct {
6393234353Sdim  const CXIdxDeclInfo *declInfo;
6394234353Sdim  const CXIdxEntityInfo *getter;
6395234353Sdim  const CXIdxEntityInfo *setter;
6396234353Sdim} CXIdxObjCPropertyDeclInfo;
6397234353Sdim
6398234353Sdimtypedef struct {
6399234353Sdim  const CXIdxDeclInfo *declInfo;
6400234353Sdim  const CXIdxBaseClassInfo *const *bases;
6401234353Sdim  unsigned numBases;
6402234353Sdim} CXIdxCXXClassDeclInfo;
6403234353Sdim
6404234353Sdim/**
6405341825Sdim * Data for IndexerCallbacks#indexEntityReference.
6406341825Sdim *
6407341825Sdim * This may be deprecated in a future version as this duplicates
6408341825Sdim * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole.
6409234353Sdim */
6410234353Sdimtypedef enum {
6411234353Sdim  /**
6412341825Sdim   * The entity is referenced directly in user's code.
6413234353Sdim   */
6414234353Sdim  CXIdxEntityRef_Direct = 1,
6415234353Sdim  /**
6416341825Sdim   * An implicit reference, e.g. a reference of an Objective-C method
6417276479Sdim   * via the dot syntax.
6418234353Sdim   */
6419234353Sdim  CXIdxEntityRef_Implicit = 2
6420234353Sdim} CXIdxEntityRefKind;
6421234353Sdim
6422234353Sdim/**
6423341825Sdim * Roles that are attributed to symbol occurrences.
6424341825Sdim *
6425341825Sdim * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with
6426341825Sdim * higher bits zeroed. These high bits may be exposed in the future.
6427234353Sdim */
6428341825Sdimtypedef enum {
6429341825Sdim  CXSymbolRole_None = 0,
6430341825Sdim  CXSymbolRole_Declaration = 1 << 0,
6431341825Sdim  CXSymbolRole_Definition = 1 << 1,
6432341825Sdim  CXSymbolRole_Reference = 1 << 2,
6433341825Sdim  CXSymbolRole_Read = 1 << 3,
6434341825Sdim  CXSymbolRole_Write = 1 << 4,
6435341825Sdim  CXSymbolRole_Call = 1 << 5,
6436341825Sdim  CXSymbolRole_Dynamic = 1 << 6,
6437341825Sdim  CXSymbolRole_AddressOf = 1 << 7,
6438341825Sdim  CXSymbolRole_Implicit = 1 << 8
6439341825Sdim} CXSymbolRole;
6440341825Sdim
6441341825Sdim/**
6442341825Sdim * Data for IndexerCallbacks#indexEntityReference.
6443341825Sdim */
6444234353Sdimtypedef struct {
6445234353Sdim  CXIdxEntityRefKind kind;
6446234353Sdim  /**
6447341825Sdim   * Reference cursor.
6448234353Sdim   */
6449234353Sdim  CXCursor cursor;
6450234353Sdim  CXIdxLoc loc;
6451234353Sdim  /**
6452341825Sdim   * The entity that gets referenced.
6453234353Sdim   */
6454234353Sdim  const CXIdxEntityInfo *referencedEntity;
6455234353Sdim  /**
6456341825Sdim   * Immediate "parent" of the reference. For example:
6457341825Sdim   *
6458234353Sdim   * \code
6459234353Sdim   * Foo *var;
6460234353Sdim   * \endcode
6461341825Sdim   *
6462234353Sdim   * The parent of reference of type 'Foo' is the variable 'var'.
6463234353Sdim   * For references inside statement bodies of functions/methods,
6464234353Sdim   * the parentEntity will be the function/method.
6465234353Sdim   */
6466234353Sdim  const CXIdxEntityInfo *parentEntity;
6467234353Sdim  /**
6468341825Sdim   * Lexical container context of the reference.
6469234353Sdim   */
6470234353Sdim  const CXIdxContainerInfo *container;
6471341825Sdim  /**
6472341825Sdim   * Sets of symbol roles of the reference.
6473341825Sdim   */
6474341825Sdim  CXSymbolRole role;
6475234353Sdim} CXIdxEntityRefInfo;
6476234353Sdim
6477239462Sdim/**
6478341825Sdim * A group of callbacks used by #clang_indexSourceFile and
6479239462Sdim * #clang_indexTranslationUnit.
6480239462Sdim */
6481234353Sdimtypedef struct {
6482234353Sdim  /**
6483341825Sdim   * Called periodically to check whether indexing should be aborted.
6484234353Sdim   * Should return 0 to continue, and non-zero to abort.
6485234353Sdim   */
6486234353Sdim  int (*abortQuery)(CXClientData client_data, void *reserved);
6487234353Sdim
6488234353Sdim  /**
6489341825Sdim   * Called at the end of indexing; passes the complete diagnostic set.
6490234353Sdim   */
6491234353Sdim  void (*diagnostic)(CXClientData client_data,
6492234353Sdim                     CXDiagnosticSet, void *reserved);
6493234353Sdim
6494234353Sdim  CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
6495239462Sdim                                     CXFile mainFile, void *reserved);
6496341825Sdim
6497234353Sdim  /**
6498341825Sdim   * Called when a file gets \#included/\#imported.
6499234353Sdim   */
6500234353Sdim  CXIdxClientFile (*ppIncludedFile)(CXClientData client_data,
6501234353Sdim                                    const CXIdxIncludedFileInfo *);
6502341825Sdim
6503234353Sdim  /**
6504341825Sdim   * Called when a AST file (PCH or module) gets imported.
6505341825Sdim   *
6506234353Sdim   * AST files will not get indexed (there will not be callbacks to index all
6507234353Sdim   * the entities in an AST file). The recommended action is that, if the AST
6508243830Sdim   * file is not already indexed, to initiate a new indexing job specific to
6509243830Sdim   * the AST file.
6510234353Sdim   */
6511234353Sdim  CXIdxClientASTFile (*importedASTFile)(CXClientData client_data,
6512234353Sdim                                        const CXIdxImportedASTFileInfo *);
6513234353Sdim
6514234353Sdim  /**
6515341825Sdim   * Called at the beginning of indexing a translation unit.
6516234353Sdim   */
6517234353Sdim  CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
6518234353Sdim                                                 void *reserved);
6519234353Sdim
6520234353Sdim  void (*indexDeclaration)(CXClientData client_data,
6521234353Sdim                           const CXIdxDeclInfo *);
6522234353Sdim
6523234353Sdim  /**
6524341825Sdim   * Called to index a reference of an entity.
6525234353Sdim   */
6526234353Sdim  void (*indexEntityReference)(CXClientData client_data,
6527234353Sdim                               const CXIdxEntityRefInfo *);
6528234353Sdim
6529234353Sdim} IndexerCallbacks;
6530234353Sdim
6531234353SdimCINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind);
6532234353SdimCINDEX_LINKAGE const CXIdxObjCContainerDeclInfo *
6533234353Sdimclang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *);
6534234353Sdim
6535234353SdimCINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo *
6536234353Sdimclang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *);
6537234353Sdim
6538234353SdimCINDEX_LINKAGE
6539234353Sdimconst CXIdxObjCCategoryDeclInfo *
6540234353Sdimclang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *);
6541234353Sdim
6542234353SdimCINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo *
6543234353Sdimclang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *);
6544234353Sdim
6545234353SdimCINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo *
6546234353Sdimclang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *);
6547234353Sdim
6548234353SdimCINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
6549234353Sdimclang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
6550234353Sdim
6551234353SdimCINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
6552234353Sdimclang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
6553234353Sdim
6554234353Sdim/**
6555341825Sdim * For retrieving a custom CXIdxClientContainer attached to a
6556234353Sdim * container.
6557234353Sdim */
6558234353SdimCINDEX_LINKAGE CXIdxClientContainer
6559234353Sdimclang_index_getClientContainer(const CXIdxContainerInfo *);
6560234353Sdim
6561234353Sdim/**
6562341825Sdim * For setting a custom CXIdxClientContainer attached to a
6563234353Sdim * container.
6564234353Sdim */
6565234353SdimCINDEX_LINKAGE void
6566234353Sdimclang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
6567234353Sdim
6568234353Sdim/**
6569341825Sdim * For retrieving a custom CXIdxClientEntity attached to an entity.
6570234353Sdim */
6571234353SdimCINDEX_LINKAGE CXIdxClientEntity
6572234353Sdimclang_index_getClientEntity(const CXIdxEntityInfo *);
6573234353Sdim
6574234353Sdim/**
6575341825Sdim * For setting a custom CXIdxClientEntity attached to an entity.
6576234353Sdim */
6577234353SdimCINDEX_LINKAGE void
6578234353Sdimclang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
6579234353Sdim
6580234353Sdim/**
6581341825Sdim * An indexing action/session, to be applied to one or multiple
6582249423Sdim * translation units.
6583234353Sdim */
6584234353Sdimtypedef void *CXIndexAction;
6585234353Sdim
6586234353Sdim/**
6587341825Sdim * An indexing action/session, to be applied to one or multiple
6588249423Sdim * translation units.
6589234353Sdim *
6590234353Sdim * \param CIdx The index object with which the index action will be associated.
6591234353Sdim */
6592234353SdimCINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
6593234353Sdim
6594234353Sdim/**
6595341825Sdim * Destroy the given index action.
6596234353Sdim *
6597234353Sdim * The index action must not be destroyed until all of the translation units
6598234353Sdim * created within that index action have been destroyed.
6599234353Sdim */
6600234353SdimCINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
6601234353Sdim
6602234353Sdimtypedef enum {
6603234353Sdim  /**
6604341825Sdim   * Used to indicate that no special indexing options are needed.
6605234353Sdim   */
6606234353Sdim  CXIndexOpt_None = 0x0,
6607341825Sdim
6608234353Sdim  /**
6609341825Sdim   * Used to indicate that IndexerCallbacks#indexEntityReference should
6610239462Sdim   * be invoked for only one reference of an entity per source file that does
6611239462Sdim   * not also include a declaration/definition of the entity.
6612234353Sdim   */
6613234353Sdim  CXIndexOpt_SuppressRedundantRefs = 0x1,
6614234353Sdim
6615234353Sdim  /**
6616341825Sdim   * Function-local symbols should be indexed. If this is not set
6617234353Sdim   * function-local symbols will be ignored.
6618234353Sdim   */
6619234353Sdim  CXIndexOpt_IndexFunctionLocalSymbols = 0x2,
6620234353Sdim
6621234353Sdim  /**
6622341825Sdim   * Implicit function/class template instantiations should be indexed.
6623234353Sdim   * If this is not set, implicit instantiations will be ignored.
6624234353Sdim   */
6625234353Sdim  CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4,
6626234353Sdim
6627234353Sdim  /**
6628341825Sdim   * Suppress all compiler warnings when parsing for indexing.
6629234353Sdim   */
6630249423Sdim  CXIndexOpt_SuppressWarnings = 0x8,
6631249423Sdim
6632249423Sdim  /**
6633341825Sdim   * Skip a function/method body that was already parsed during an
6634276479Sdim   * indexing session associated with a \c CXIndexAction object.
6635249423Sdim   * Bodies in system headers are always skipped.
6636249423Sdim   */
6637249423Sdim  CXIndexOpt_SkipParsedBodiesInSession = 0x10
6638249423Sdim
6639234353Sdim} CXIndexOptFlags;
6640234353Sdim
6641234353Sdim/**
6642341825Sdim * Index the given source file and the translation unit corresponding
6643239462Sdim * to that file via callbacks implemented through #IndexerCallbacks.
6644234353Sdim *
6645234353Sdim * \param client_data pointer data supplied by the client, which will
6646234353Sdim * be passed to the invoked callbacks.
6647234353Sdim *
6648234353Sdim * \param index_callbacks Pointer to indexing callbacks that the client
6649234353Sdim * implements.
6650234353Sdim *
6651239462Sdim * \param index_callbacks_size Size of #IndexerCallbacks structure that gets
6652234353Sdim * passed in index_callbacks.
6653234353Sdim *
6654234353Sdim * \param index_options A bitmask of options that affects how indexing is
6655234353Sdim * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags.
6656234353Sdim *
6657276479Sdim * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be
6658276479Sdim * reused after indexing is finished. Set to \c NULL if you do not require it.
6659234353Sdim *
6660276479Sdim * \returns 0 on success or if there were errors from which the compiler could
6661288943Sdim * recover.  If there is a failure from which there is no recovery, returns
6662276479Sdim * a non-zero \c CXErrorCode.
6663234353Sdim *
6664239462Sdim * The rest of the parameters are the same as #clang_parseTranslationUnit.
6665234353Sdim */
6666234353SdimCINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
6667234353Sdim                                         CXClientData client_data,
6668234353Sdim                                         IndexerCallbacks *index_callbacks,
6669234353Sdim                                         unsigned index_callbacks_size,
6670234353Sdim                                         unsigned index_options,
6671234353Sdim                                         const char *source_filename,
6672234353Sdim                                         const char * const *command_line_args,
6673234353Sdim                                         int num_command_line_args,
6674234353Sdim                                         struct CXUnsavedFile *unsaved_files,
6675234353Sdim                                         unsigned num_unsaved_files,
6676234353Sdim                                         CXTranslationUnit *out_TU,
6677234353Sdim                                         unsigned TU_options);
6678234353Sdim
6679234353Sdim/**
6680341825Sdim * Same as clang_indexSourceFile but requires a full command line
6681296417Sdim * for \c command_line_args including argv[0]. This is useful if the standard
6682296417Sdim * library paths are relative to the binary.
6683296417Sdim */
6684296417SdimCINDEX_LINKAGE int clang_indexSourceFileFullArgv(
6685296417Sdim    CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
6686296417Sdim    unsigned index_callbacks_size, unsigned index_options,
6687296417Sdim    const char *source_filename, const char *const *command_line_args,
6688296417Sdim    int num_command_line_args, struct CXUnsavedFile *unsaved_files,
6689296417Sdim    unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
6690296417Sdim
6691296417Sdim/**
6692341825Sdim * Index the given translation unit via callbacks implemented through
6693239462Sdim * #IndexerCallbacks.
6694341825Sdim *
6695234353Sdim * The order of callback invocations is not guaranteed to be the same as
6696234353Sdim * when indexing a source file. The high level order will be:
6697341825Sdim *
6698234353Sdim *   -Preprocessor callbacks invocations
6699234353Sdim *   -Declaration/reference callbacks invocations
6700234353Sdim *   -Diagnostic callback invocations
6701234353Sdim *
6702239462Sdim * The parameters are the same as #clang_indexSourceFile.
6703341825Sdim *
6704288943Sdim * \returns If there is a failure from which there is no recovery, returns
6705234353Sdim * non-zero, otherwise returns 0.
6706234353Sdim */
6707234353SdimCINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
6708234353Sdim                                              CXClientData client_data,
6709234353Sdim                                              IndexerCallbacks *index_callbacks,
6710234353Sdim                                              unsigned index_callbacks_size,
6711234353Sdim                                              unsigned index_options,
6712234353Sdim                                              CXTranslationUnit);
6713234353Sdim
6714234353Sdim/**
6715341825Sdim * Retrieve the CXIdxFile, file, line, column, and offset represented by
6716234353Sdim * the given CXIdxLoc.
6717234353Sdim *
6718234353Sdim * If the location refers into a macro expansion, retrieves the
6719234353Sdim * location of the macro expansion and if it refers into a macro argument
6720234353Sdim * retrieves the location of the argument.
6721234353Sdim */
6722234353SdimCINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
6723234353Sdim                                                   CXIdxClientFile *indexFile,
6724234353Sdim                                                   CXFile *file,
6725234353Sdim                                                   unsigned *line,
6726234353Sdim                                                   unsigned *column,
6727234353Sdim                                                   unsigned *offset);
6728234353Sdim
6729234353Sdim/**
6730341825Sdim * Retrieve the CXSourceLocation represented by the given CXIdxLoc.
6731234353Sdim */
6732234353SdimCINDEX_LINKAGE
6733234353SdimCXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc);
6734234353Sdim
6735234353Sdim/**
6736341825Sdim * Visitor invoked for each field found by a traversal.
6737288943Sdim *
6738288943Sdim * This visitor function will be invoked for each field found by
6739288943Sdim * \c clang_Type_visitFields. Its first argument is the cursor being
6740288943Sdim * visited, its second argument is the client data provided to
6741288943Sdim * \c clang_Type_visitFields.
6742288943Sdim *
6743288943Sdim * The visitor should return one of the \c CXVisitorResult values
6744288943Sdim * to direct \c clang_Type_visitFields.
6745288943Sdim */
6746288943Sdimtypedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
6747288943Sdim                                               CXClientData client_data);
6748288943Sdim
6749288943Sdim/**
6750341825Sdim * Visit the fields of a particular type.
6751288943Sdim *
6752288943Sdim * This function visits all the direct fields of the given cursor,
6753288943Sdim * invoking the given \p visitor function with the cursors of each
6754288943Sdim * visited field. The traversal may be ended prematurely, if
6755288943Sdim * the visitor returns \c CXFieldVisit_Break.
6756288943Sdim *
6757288943Sdim * \param T the record type whose field may be visited.
6758288943Sdim *
6759288943Sdim * \param visitor the visitor function that will be invoked for each
6760288943Sdim * field of \p T.
6761288943Sdim *
6762288943Sdim * \param client_data pointer data supplied by the client, which will
6763288943Sdim * be passed to the visitor each time it is invoked.
6764288943Sdim *
6765288943Sdim * \returns a non-zero value if the traversal was terminated
6766288943Sdim * prematurely by the visitor returning \c CXFieldVisit_Break.
6767288943Sdim */
6768288943SdimCINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
6769288943Sdim                                               CXFieldVisitor visitor,
6770288943Sdim                                               CXClientData client_data);
6771288943Sdim
6772288943Sdim/**
6773224145Sdim * @}
6774224145Sdim */
6775224145Sdim
6776226633Sdim/**
6777226633Sdim * @}
6778226633Sdim */
6779226633Sdim
6780360784SdimLLVM_CLANG_C_EXTERN_C_END
6781360784Sdim
6782198092Srdivacky#endif
6783