Index.h revision a60ed47da13393796d8552b9fdca12abbb3eea42
1d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
2d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*                                                                            *|
3d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*                     The LLVM Compiler Infrastructure                       *|
4d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*                                                                            *|
5d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* This file is distributed under the University of Illinois Open Source      *|
6d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* License. See LICENSE.TXT for details.                                      *|
7d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*                                                                            *|
8d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*===----------------------------------------------------------------------===*|
9d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*                                                                            *|
10d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* This header provides a public inferface to a Clang library for extracting  *|
11d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* high-level symbol information from source files without exposing the full  *|
12d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|* Clang C++ API.                                                             *|
13d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek|*                                                                            *|
14d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek\*===----------------------------------------------------------------------===*/
15d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek
16d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifndef CLANG_C_INDEX_H
17d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#define CLANG_C_INDEX_H
18d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek
1988145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff#include <sys/stat.h>
203d31560343856c573376a04558a7111e7afad4f7Chandler Carruth#include <time.h>
210a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor#include <stdio.h>
2288145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff
23d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus
24d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenekextern "C" {
25d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif
26d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek
2788145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff/* MSVC DLL import/export. */
282e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#ifdef _MSC_VER
292e06fc877a633abea3b40a64950c7316dac29ca8John Thompson  #ifdef _CINDEX_LIB_
302e06fc877a633abea3b40a64950c7316dac29ca8John Thompson    #define CINDEX_LINKAGE __declspec(dllexport)
312e06fc877a633abea3b40a64950c7316dac29ca8John Thompson  #else
322e06fc877a633abea3b40a64950c7316dac29ca8John Thompson    #define CINDEX_LINKAGE __declspec(dllimport)
332e06fc877a633abea3b40a64950c7316dac29ca8John Thompson  #endif
342e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#else
352e06fc877a633abea3b40a64950c7316dac29ca8John Thompson  #define CINDEX_LINKAGE
362e06fc877a633abea3b40a64950c7316dac29ca8John Thompson#endif
372e06fc877a633abea3b40a64950c7316dac29ca8John Thompson
3820d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor/** \defgroup CINDEX C Interface to Clang
3920d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor *
401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The C Interface to Clang provides a relatively small API that exposes
41f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * facilities for parsing source code into an abstract syntax tree (AST),
42f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * loading already-parsed ASTs, traversing the AST, associating
43f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * physical source locations with elements within the AST, and other
44f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * facilities that support Clang-based development tools.
45f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor *
461efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * This C interface to Clang will never provide all of the information
47f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * representation stored in Clang's C++ AST, nor should it: the intent is to
48f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * maintain an API that is relatively stable from one release to the next,
49f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * providing only the basic functionality needed to support development tools.
501efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar *
511efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * To avoid namespace pollution, data types are prefixed with "CX" and
52f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * functions are prefixed with "clang_".
5320d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor *
5420d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * @{
5520d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor */
561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
577f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
587f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief An "index" that consists of a set of translation units that would
597f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * typically be linked together into an executable or library.
607f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
617f17376e0931a337d544b75d9030bc92763be287Douglas Gregortypedef void *CXIndex;
62600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff
637f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
647f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief A single translation unit, which resides in an index.
657f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
66a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenektypedef struct CXTranslationUnitImpl {
67a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek  void *TUData;
68a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek  void *StringPool;
69a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek} *CXTranslationUnit;  /* A translation unit instance. */
70600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff
717f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
72c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Opaque pointer representing client data that will be passed through
73c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to various callbacks and visitors.
747f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
75c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregortypedef void *CXClientData;
761efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
77735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor/**
78735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \brief Provides the contents of a file that has not yet been saved to disk.
79735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor *
80735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * Each CXUnsavedFile instance provides the name of a file on the
81735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * system along with the current contents of that file that have not
82735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * yet been saved to disk.
83735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */
84735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregorstruct CXUnsavedFile {
851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
861efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * \brief The file whose contents have not yet been saved.
87735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   *
88735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   * This file must already exist in the file system.
89735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   */
90735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor  const char *Filename;
91735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor
921efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
93c8dfe5ece04e683106eb96c58a2999f70b53ac21Douglas Gregor   * \brief A buffer containing the unsaved contents of this file.
94735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   */
95735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor  const char *Contents;
96735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor
97735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor  /**
98c8dfe5ece04e683106eb96c58a2999f70b53ac21Douglas Gregor   * \brief The length of the unsaved contents of this buffer.
99735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   */
100735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor  unsigned long Length;
101735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor};
102735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor
103076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne/**
104076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * \brief Describes the availability of a particular entity, which indicates
105076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * whether the use of this entity will result in a warning or error due to
106076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * it being deprecated or unavailable.
107076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne */
10858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorenum CXAvailabilityKind {
109076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne  /**
110076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   * \brief The entity is available.
111076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   */
11258ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor  CXAvailability_Available,
113076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne  /**
114076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   * \brief The entity is available, but has been deprecated (and its use is
115076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   * not recommended).
116076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   */
11758ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor  CXAvailability_Deprecated,
118076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne  /**
119076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   * \brief The entity is not available; any use of it will be an error.
120076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   */
12158ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor  CXAvailability_NotAvailable
12258ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor};
12358ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor
1247f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1257f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \defgroup CINDEX_STRING String manipulation routines
1267f17376e0931a337d544b75d9030bc92763be287Douglas Gregor *
1277f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * @{
1287f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
1291efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1307f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1317f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief A character string.
1327f17376e0931a337d544b75d9030bc92763be287Douglas Gregor *
1337f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * The \c CXString type is used to return strings from the interface when
1347f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * the ownership of that string might different from one call to the next.
1357f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * Use \c clang_getCString() to retrieve the string data and, once finished
1367f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * with the string data, call \c clang_disposeString() to free the string.
137ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff */
138ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Narofftypedef struct {
139a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek  void *data;
140ed122735639d83c10f18c28c7fd117bfcd0f62cbTed Kremenek  unsigned private_flags;
141ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff} CXString;
142ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff
1437f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1447f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief Retrieve the character data associated with the given string.
1457f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
146ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE const char *clang_getCString(CXString string);
147ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff
1487f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1497f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief Free the given string,
1507f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
151ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE void clang_disposeString(CXString string);
152ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff
1537f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1547f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * @}
1557f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
1561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1571efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/**
158e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * \brief clang_createIndex() provides a shared context for creating
159e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * translation units. It provides two options:
160e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff *
161e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
162e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * declarations (when loading any new translation units). A "local" declaration
1631efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * is one that belongs in the translation unit itself and not in a precompiled
164e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * header that was used by the translation unit. If zero, all declarations
165e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * will be enumerated.
166e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff *
167b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * Here is an example:
168b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
1690a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
1700a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *   Idx = clang_createIndex(1, 1);
171b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
172b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // IndexTest.pch was produced with the following command:
173b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
174b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
175b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
176b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // This will load all the symbols from 'IndexTest.pch'
1771efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
178002a528ab0189fc60cfbf9328962c96ccbe567eeDouglas Gregor *                       TranslationUnitVisitor, 0);
179b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   clang_disposeTranslationUnit(TU);
180b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
181b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // This will load all the symbols from 'IndexTest.c', excluding symbols
182b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // from 'IndexTest.pch'.
183fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
184fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
185fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar *                                                  0, 0);
186b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
187b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor *                       TranslationUnitVisitor, 0);
188b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   clang_disposeTranslationUnit(TU);
189b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
190b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * This process of creating the 'pch', loading it separately, and using it (via
191b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
192b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * (which gives the indexer the same performance benefit as the compiler).
193e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff */
1940a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
1950a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor                                         int displayDiagnostics);
196896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1970087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor/**
1980087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * \brief Destroy the given index.
1990087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor *
2000087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * The index must not be destroyed until all of the translation units created
2010087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * within that index have been destroyed.
2020087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor */
2038506dde586459887b7e14e23a30af8ac5be5adb6Daniel DunbarCINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
2041efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/**
206c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_FILES File manipulation routines
207f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor *
208f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @{
209f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
2101efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
211f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
212f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief A particular source file that is part of a translation unit.
213f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
214f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregortypedef void *CXFile;
2151efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
216f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor
217f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
218f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief Retrieve the complete file and path name of the given file.
21988145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff */
22074844072411bae91d5dbb89955d200cbe1e0a1c8Ted KremenekCINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
2211efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
222f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
223f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief Retrieve the last modification time of the given file.
224f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
22508b0e8daeb683686b876d72674962ad96df21d45Douglas GregorCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
22688145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff
2273c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor/**
228b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a file handle within the given translation unit.
229b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
230b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \param tu the translation unit
2311efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar *
232b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \param file_name the name of the file.
233b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
234b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns the file handle for the named file in the translation unit \p tu,
235b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * or a NULL file handle if the file was not a part of this translation unit.
236b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
2371efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
238b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                    const char *file_name);
2391efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
240b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
241f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @}
242f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
243f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor
244f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
245f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \defgroup CINDEX_LOCATIONS Physical source locations
246f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor *
247f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * Clang represents physical source locations in its abstract syntax tree in
248f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * great detail, with file, line, and column information for the majority of
249f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * the tokens parsed in the source code. These data types and functions are
250f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * used to represent source location information, either for a particular
251f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * point in the program or for a range of points in the program, and extract
252f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * specific location information from those data types.
253f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor *
254f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @{
255f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
2561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
257f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
2581db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * \brief Identifies a specific source location within a translation
2591db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * unit.
2601db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
261a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * Use clang_getInstantiationLocation() or clang_getSpellingLocation()
262a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * to map a source location to a particular file, line, and column.
2633c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor */
2643c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregortypedef struct {
2655352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  void *ptr_data[2];
2661db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor  unsigned int_data;
2673c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor} CXSourceLocation;
268fe6fd3d41a7f48317d6856c9327b6cead32c3498Ted Kremenek
2693c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor/**
270d52864bd33c66aacc84133460d8c9c0dfcdd5c18Daniel Dunbar * \brief Identifies a half-open character range in the source code.
2713c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor *
2721db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
2731db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * starting and end locations from a source range, respectively.
2743c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor */
2753c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregortypedef struct {
2765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  void *ptr_data[2];
2771db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor  unsigned begin_int_data;
2781db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor  unsigned end_int_data;
2793c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor} CXSourceRange;
280fe6fd3d41a7f48317d6856c9327b6cead32c3498Ted Kremenek
2811db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor/**
282b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a NULL (invalid) source location.
283b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
284b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getNullLocation();
2851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
286b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
287b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \determine Determine whether two source locations, which must refer into
2881efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * the same translation unit, refer to exactly the same point in the source
289b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * code.
290b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
291b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns non-zero if the source locations refer to the same location, zero
292b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * if they refer to different locations.
293b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
294b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
295b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                             CXSourceLocation loc2);
2961efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
297b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
2981efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieves the source location associated with a given file/line/column
2991efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * in a particular translation unit.
300b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
301b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
302b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                                  CXFile file,
303b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                                  unsigned line,
304b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                                  unsigned column);
30583889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall/**
30683889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall * \brief Retrieves the source location associated with a given character offset
30783889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall * in a particular translation unit.
30883889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall */
30983889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid ChisnallCINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
31083889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall                                                           CXFile file,
31183889a7f1f338e343ef72aeeef9c27f7b62c0f0fDavid Chisnall                                                           unsigned offset);
3121efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
313b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
3145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve a NULL (invalid) source range.
3155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
3165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getNullRange();
317896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
3185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
319b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a source range given the beginning and ending source
320b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * locations.
321b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
322b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
323b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                            CXSourceLocation end);
3241efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
325b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
32646766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * \brief Retrieve the file, line, column, and offset represented by
32746766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * the given source location.
3281db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
329a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * If the location refers into a macro instantiation, retrieves the
330a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * location of the macro instantiation.
331a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor *
3321efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param location the location within a source file that will be decomposed
3331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * into its parts.
3341db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
3351efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param file [out] if non-NULL, will be set to the file to which the given
3361db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * source location points.
3371db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
3381efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param line [out] if non-NULL, will be set to the line to which the given
3391db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * source location points.
3401db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
3411efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param column [out] if non-NULL, will be set to the column to which the given
3421efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source location points.
34346766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor *
34446766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * \param offset [out] if non-NULL, will be set to the offset into the
34546766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * buffer to which the given source location points.
3461db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */
3471db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
3481db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor                                                   CXFile *file,
3491db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor                                                   unsigned *line,
35046766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor                                                   unsigned *column,
35146766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor                                                   unsigned *offset);
352e69517ce61638f12c9abe4605753a45275ac4e37Douglas Gregor
353e69517ce61638f12c9abe4605753a45275ac4e37Douglas Gregor/**
354a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \brief Retrieve the file, line, column, and offset represented by
355a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * the given source location.
356a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor *
357a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * If the location refers into a macro instantiation, return where the
358a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * location was originally spelled in the source file.
359a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor *
360a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param location the location within a source file that will be decomposed
361a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * into its parts.
362a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor *
363a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param file [out] if non-NULL, will be set to the file to which the given
364a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * source location points.
365a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor *
366a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param line [out] if non-NULL, will be set to the line to which the given
367a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * source location points.
368a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor *
369a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param column [out] if non-NULL, will be set to the column to which the given
370a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * source location points.
371a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor *
372a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * \param offset [out] if non-NULL, will be set to the offset into the
373a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor * buffer to which the given source location points.
374a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor */
375a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas GregorCINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
376a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor                                              CXFile *file,
377a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor                                              unsigned *line,
378a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor                                              unsigned *column,
379a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor                                              unsigned *offset);
380a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor
381a9b06d4c246d6c301e3dd1844f5dba669ed9c631Douglas Gregor/**
3821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve a source location representing the first character within a
3831efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source range.
3841db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */
3851db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
3861db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor
3871db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor/**
3881efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve a source location representing the last character within a
3891efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source range.
3901db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */
3911db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
3921db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor
393f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
394f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @}
395f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
396c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
397c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
3985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \defgroup CINDEX_DIAG Diagnostic reporting
3995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
4005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @{
4015352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
4025352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4035352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
4045352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Describes the severity of a particular diagnostic.
4055352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
4065352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorenum CXDiagnosticSeverity {
4075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
408896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek   * \brief A diagnostic that has been suppressed, e.g., by a command-line
4095352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * option.
4105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
4115352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Ignored = 0,
412896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
4135352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
4145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * \brief This diagnostic is a note that should be attached to the
4155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * previous (non-note) diagnostic.
4165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
4175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Note    = 1,
4185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
4205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * \brief This diagnostic indicates suspicious code that may not be
4215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * wrong.
4225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
4235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Warning = 2,
4245352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4255352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
4265352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * \brief This diagnostic indicates that the code is ill-formed.
4275352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
4285352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Error   = 3,
4295352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4305352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
4315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * \brief This diagnostic indicates that the code is ill-formed such
4325352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * that future parser recovery is unlikely to produce useful
4335352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * results.
4345352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
4355352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Fatal   = 4
4365352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor};
4375352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4385352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
4395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief A single diagnostic, containing the diagnostic's severity,
4405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * location, text, source ranges, and fix-it hints.
4415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
4425352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregortypedef void *CXDiagnostic;
4435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
445a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Determine the number of diagnostics produced for the given
446a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * translation unit.
447a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */
448a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
449a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor
450a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/**
451a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Retrieve a diagnostic associated with the given translation unit.
4525352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
453a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Unit the translation unit to query.
454a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Index the zero-based diagnostic number to retrieve.
4555352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
456a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \returns the requested diagnostic. This diagnostic must be freed
457a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * via a call to \c clang_disposeDiagnostic().
4585352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
459a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
460a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                                unsigned Index);
461a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor
462a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/**
463a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Destroy a diagnostic.
464a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */
465a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
4665352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4675352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
4680a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Options to control the display of diagnostics.
4690a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
4700a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * The values in this enum are meant to be combined to customize the
4710a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * behavior of \c clang_displayDiagnostic().
4720a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */
4730a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregorenum CXDiagnosticDisplayOptions {
4740a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  /**
4750a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \brief Display the source-location information where the
4760a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * diagnostic was located.
4770a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
4780a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * When set, diagnostics will be prefixed by the file, line, and
4790a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * (optionally) column to which the diagnostic refers. For example,
4800a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
4810a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \code
4820a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * test.c:28: warning: extra tokens at end of #endif directive
4830a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \endcode
4840a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
4850a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * This option corresponds to the clang flag \c -fshow-source-location.
4860a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   */
4870a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  CXDiagnostic_DisplaySourceLocation = 0x01,
4880a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
4890a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  /**
4900a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \brief If displaying the source-location information of the
4910a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * diagnostic, also include the column number.
4920a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
4930a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * This option corresponds to the clang flag \c -fshow-column.
4940a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   */
4950a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  CXDiagnostic_DisplayColumn = 0x02,
4960a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
4970a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  /**
4980a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \brief If displaying the source-location information of the
4990a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * diagnostic, also include information about source ranges in a
5000a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * machine-parsable format.
5010a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
502896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek   * This option corresponds to the clang flag
5030a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \c -fdiagnostics-print-source-range-info.
5040a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   */
5050a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  CXDiagnostic_DisplaySourceRanges = 0x04
5060a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor};
5070a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
5080a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/**
509274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * \brief Format the given diagnostic in a manner that is suitable for display.
5100a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
511274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * This routine will format the given diagnostic to a string, rendering
512896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * the diagnostic according to the various options given. The
513896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
5140a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * options that most closely mimics the behavior of the clang compiler.
5150a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
5160a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \param Diagnostic The diagnostic to print.
5170a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
518896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \param Options A set of options that control the diagnostic display,
5190a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * created by combining \c CXDiagnosticDisplayOptions values.
520274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor *
521274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * \returns A new string containing for formatted diagnostic.
5220a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */
523274f1906f12ebf8fcc179701deeda6d3271120c1Douglas GregorCINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
524274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor                                               unsigned Options);
5250a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
5260a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/**
5270a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Retrieve the set of display options most similar to the
5280a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * default behavior of the clang compiler.
5290a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
5300a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \returns A set of display options suitable for use with \c
5310a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * clang_displayDiagnostic().
5320a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */
5330a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
5340a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
5350a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/**
5360a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Print a diagnostic to the given file.
5370a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */
5380a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
5390a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/**
5405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Determine the severity of the given diagnostic.
5415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
542896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE enum CXDiagnosticSeverity
5435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getDiagnosticSeverity(CXDiagnostic);
5445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
5465352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the source location of the given diagnostic.
5475352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
5485352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * This location is where Clang would print the caret ('^') when
5495352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * displaying the diagnostic on the command line.
5505352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
5515352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
5525352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
5545352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the text of the given diagnostic.
5555352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
5565352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
557a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor
558a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor/**
559a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \brief Determine the number of source ranges associated with the given
560a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * diagnostic.
561a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor */
562a3890baf1256ff26081306c7fef70202f8223f41Douglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
563896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
5645352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
565a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \brief Retrieve a source range associated with the diagnostic.
5665352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
567a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * A diagnostic's source ranges highlight important elements in the source
5685352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * code. On the command line, Clang displays source ranges by
569896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * underlining them with '~' characters.
5705352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
571a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \param Diagnostic the diagnostic whose range is being extracted.
5725352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
573896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \param Range the zero-based index specifying which range to
5745352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
575a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \returns the requested source range.
5765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
577896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
578a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor                                                      unsigned Range);
5795352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
5815352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Determine the number of fix-it hints associated with the
5825352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * given diagnostic.
5835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
5845352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
5855352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5865352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
587473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \brief Retrieve the replacement information for a given fix-it.
5885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
589473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * Fix-its are described in terms of a source range whose contents
590473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * should be replaced by a string. This approach generalizes over
591473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * three kinds of operations: removal of source code (the range covers
592473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * the code to be removed and the replacement string is empty),
593473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replacement of source code (the range covers the code to be
594473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced and the replacement string provides the new code), and
595473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insertion (both the start and end of the range point at the
596473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insertion location, and the replacement string provides the text to
597473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insert).
5985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
599473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param Diagnostic The diagnostic whose fix-its are being queried.
6005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
601473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param FixIt The zero-based index of the fix-it.
6025352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
603473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param ReplacementRange The source range whose contents will be
604473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced with the returned replacement string. Note that source
605473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * ranges are half-open ranges [a, b), so the source code should be
606473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced from a and up to (but not including) b.
6075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
608473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \returns A string containing text that should be replace the source
609473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * code indicated by the \c ReplacementRange.
6105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
611896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
612473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor                                                 unsigned FixIt,
613473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor                                               CXSourceRange *ReplacementRange);
6145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
6155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
6165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @}
6175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
6185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
6195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
6205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
6215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * The routines in this group provide the ability to create and destroy
6235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * translation units from files, either by parsing the contents of the files or
6245352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * by reading in a serialized representation of a translation unit.
6255352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6265352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @{
6275352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
628896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
6295352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
6305352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Get the original translation unit source file name.
6315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
6325352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString
6335352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
6345352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
6355352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
6365352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Return the CXTranslationUnit for a given source file and the provided
6375352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * command line arguments one would pass to the compiler.
6385352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * Note: The 'source_filename' argument is optional.  If the caller provides a
6405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * NULL pointer, the name of the source file is expected to reside in the
6415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * specified command line arguments.
6425352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * Note: When encountered in 'clang_command_line_args', the following options
6445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * are ignored:
6455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6465352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *   '-c'
6475352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *   '-emit-ast'
6485352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *   '-fsyntax-only'
6495352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *   '-o <output file>'  (both '-o' and '<output file>' are ignored)
6505352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6511ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * \param CIdx The index object with which the translation unit will be
6521ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * associated.
6535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6545352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param source_filename - The name of the source file to load, or NULL if the
6551ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * source file is included in \p clang_command_line_args.
6561ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek *
6571ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * \param num_clang_command_line_args The number of command-line arguments in
6581ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * \p clang_command_line_args.
6591ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek *
6601ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * \param clang_command_line_args The command-line arguments that would be
6611ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * passed to the \c clang executable if it were being invoked out-of-process.
6621ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * These command-line options will be parsed and will affect how the translation
6631ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * unit is parsed. Note that the following options are ignored: '-c',
6641ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
6655352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6665352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p
6675352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * unsaved_files.
6685352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6695352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk
6705352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * but may be required for code completion, including the contents of
671c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * those files.  The contents and name of these files (as specified by
672c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * CXUnsavedFile) are copied when necessary, so the client only needs to
673c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * guarantee their validity until the call to this function returns.
6745352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
6755352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
6765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         CXIndex CIdx,
6775352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         const char *source_filename,
6785352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         int num_clang_command_line_args,
6792ef6944d529c94824f5bf96f65665f5bee30f5a2Douglas Gregor                                   const char * const *clang_command_line_args,
6805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         unsigned num_unsaved_files,
681a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                         struct CXUnsavedFile *unsaved_files);
682896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
6835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
6845352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Create a translation unit from an AST file (-emit-ast).
6855352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
686896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
687a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                             const char *ast_filename);
6885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
68944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor/**
69044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * \brief Flags that control the creation of translation units.
69144c181aec37789f25f6c15543c164416f72e562aDouglas Gregor *
69244c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * The enumerators in this enumeration type are meant to be bitwise
69344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * ORed together to specify which options should be used when
69444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * constructing the translation unit.
69544c181aec37789f25f6c15543c164416f72e562aDouglas Gregor */
6965a43021ac491bf091494167127772a20d9a9bb48Douglas Gregorenum CXTranslationUnit_Flags {
6975a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor  /**
6985a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * \brief Used to indicate that no special translation-unit options are
6995a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * needed.
7005a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   */
7015a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor  CXTranslationUnit_None = 0x0,
7025a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor
7035a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor  /**
7045a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * \brief Used to indicate that the parser should construct a "detailed"
7055a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * preprocessing record, including all macro definitions and instantiations.
7065a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   *
7075a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * Constructing a detailed preprocessing record requires more memory
7085a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * and time to parse, since the information contained in the record
7095a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * is usually not retained. However, it can be useful for
7105a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * applications that require more detailed information about the
7115a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * behavior of the preprocessor.
7125a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   */
71344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor  CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
71444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor
71544c181aec37789f25f6c15543c164416f72e562aDouglas Gregor  /**
716b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * \brief Used to indicate that the translation unit is incomplete.
71744c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   *
718b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * When a translation unit is considered "incomplete", semantic
719b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * analysis that is typically performed at the end of the
720b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * translation unit will be suppressed. For example, this suppresses
721b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * the completion of tentative declarations in C and of
722b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * instantiation of implicitly-instantiation function templates in
723b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * C++. This option is typically used when parsing a header with the
724b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * intent of producing a precompiled header.
72544c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   */
726b1c031be513705d924038f497279b9b599868ba1Douglas Gregor  CXTranslationUnit_Incomplete = 0x02,
72744c181aec37789f25f6c15543c164416f72e562aDouglas Gregor
72844c181aec37789f25f6c15543c164416f72e562aDouglas Gregor  /**
72944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * \brief Used to indicate that the translation unit should be built with an
73044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * implicit precompiled header for the preamble.
73144c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   *
73244c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * An implicit precompiled header is used as an optimization when a
73344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * particular translation unit is likely to be reparsed many times
73444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * when the sources aren't changing that often. In this case, an
73544c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * implicit precompiled header will be built containing all of the
73644c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * initial includes at the top of the main file (what we refer to as
73744c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * the "preamble" of the file). In subsequent parses, if the
73844c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * preamble or the files in it have not changed, \c
73944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * clang_reparseTranslationUnit() will re-use the implicit
74044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * precompiled header to improve parsing performance.
74144c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   */
742e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  CXTranslationUnit_PrecompiledPreamble = 0x04,
743e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor
744e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  /**
745e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * \brief Used to indicate that the translation unit should cache some
746e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * code-completion results with each reparse of the source file.
747e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   *
748e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * Caching of code-completion results is a performance optimization that
749e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * introduces some overhead to reparsing but improves the performance of
750e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * code-completion operations.
751e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   */
75299ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor  CXTranslationUnit_CacheCompletionResults = 0x08,
75399ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor  /**
75499ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   * \brief Enable precompiled preambles in C++.
75599ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   *
75699ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   * Note: this is a *temporary* option that is available only while
75799ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   * we are testing C++ precompiled preamble support.
75899ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   */
75999ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor  CXTranslationUnit_CXXPrecompiledPreamble = 0x10,
76099ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor
76199ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor  /**
76299ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   * \brief Enabled chained precompiled preambles in C++.
76399ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   *
76499ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   * Note: this is a *temporary* option that is available only while
76599ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   * we are testing C++ precompiled preamble support.
76699ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor   */
76799ba202f659e1885fa5ee114f97c97cf6a857491Douglas Gregor  CXTranslationUnit_CXXChainedPCH = 0x20
7685a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor};
7695a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor
7705a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor/**
771b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * \brief Returns the set of flags that is suitable for parsing a translation
772b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * unit that is being edited.
773b1c031be513705d924038f497279b9b599868ba1Douglas Gregor *
774b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * The set of flags returned provide options for \c clang_parseTranslationUnit()
775b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * to indicate that the translation unit is likely to be reparsed many times,
776b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
777b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
778b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * set contains an unspecified set of optimizations (e.g., the precompiled
779b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * preamble) geared toward improving the performance of these routines. The
780b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * set of optimizations enabled may change from one version to the next.
781b1c031be513705d924038f497279b9b599868ba1Douglas Gregor */
782e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas GregorCINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
783b1c031be513705d924038f497279b9b599868ba1Douglas Gregor
784b1c031be513705d924038f497279b9b599868ba1Douglas Gregor/**
7855a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \brief Parse the given source file and the translation unit corresponding
7865a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * to that file.
7875a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7885a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * This routine is the main entry point for the Clang C API, providing the
7895a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * ability to parse a source file into a translation unit that can then be
7905a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * queried by other functions in the API. This routine accepts a set of
7915a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * command-line arguments so that the compilation can be configured in the same
7925a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * way that the compiler is configured on the command line.
7935a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7945a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param CIdx The index object with which the translation unit will be
7955a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * associated.
7965a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7975a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param source_filename The name of the source file to load, or NULL if the
7981ddb02cabd4374bcbe9afdff5123be0be8e32d12Ted Kremenek * source file is included in \p command_line_args.
7995a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
8005a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param command_line_args The command-line arguments that would be
8015a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * passed to the \c clang executable if it were being invoked out-of-process.
8025a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * These command-line options will be parsed and will affect how the translation
8035a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * unit is parsed. Note that the following options are ignored: '-c',
8045a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
8055a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
8065a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param num_command_line_args The number of command-line arguments in
8075a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \p command_line_args.
8085a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
8095a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk
8101abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * but may be required for parsing, including the contents of
8115a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * those files.  The contents and name of these files (as specified by
8125a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * CXUnsavedFile) are copied when necessary, so the client only needs to
8135a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * guarantee their validity until the call to this function returns.
8145a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
8155a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p
8165a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * unsaved_files.
8175a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
8185a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param options A bitmask of options that affects how the translation unit
8195a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * is managed but not its compilation. This should be a bitwise OR of the
8205a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * CXTranslationUnit_XXX flags.
8215a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
8225a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \returns A new translation unit describing the parsed code and containing
8235a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * any diagnostics produced by the compiler. If there is a failure from which
8245a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * the compiler cannot recover, returns NULL.
8255a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor */
8265a43021ac491bf091494167127772a20d9a9bb48Douglas GregorCINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
8275a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                    const char *source_filename,
8282ef6944d529c94824f5bf96f65665f5bee30f5a2Douglas Gregor                                         const char * const *command_line_args,
8295a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                      int num_command_line_args,
8305a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                            struct CXUnsavedFile *unsaved_files,
8315a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                     unsigned num_unsaved_files,
8325a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                            unsigned options);
8335a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor
8345352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
8351999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \brief Flags that control how translation units are saved.
8361999844e7a18786e61e619e1dc6c789827541863Douglas Gregor *
8371999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * The enumerators in this enumeration type are meant to be bitwise
8381999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * ORed together to specify which options should be used when
8391999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * saving the translation unit.
8401999844e7a18786e61e619e1dc6c789827541863Douglas Gregor */
8411999844e7a18786e61e619e1dc6c789827541863Douglas Gregorenum CXSaveTranslationUnit_Flags {
8421999844e7a18786e61e619e1dc6c789827541863Douglas Gregor  /**
8431999844e7a18786e61e619e1dc6c789827541863Douglas Gregor   * \brief Used to indicate that no special saving options are needed.
8441999844e7a18786e61e619e1dc6c789827541863Douglas Gregor   */
8451999844e7a18786e61e619e1dc6c789827541863Douglas Gregor  CXSaveTranslationUnit_None = 0x0
8461999844e7a18786e61e619e1dc6c789827541863Douglas Gregor};
8471999844e7a18786e61e619e1dc6c789827541863Douglas Gregor
8481999844e7a18786e61e619e1dc6c789827541863Douglas Gregor/**
8491999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \brief Returns the set of flags that is suitable for saving a translation
8501999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * unit.
8511999844e7a18786e61e619e1dc6c789827541863Douglas Gregor *
8521999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * The set of flags returned provide options for
8531999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \c clang_saveTranslationUnit() by default. The returned flag
8541999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * set contains an unspecified set of options that save translation units with
8551999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * the most commonly-requested data.
8561999844e7a18786e61e619e1dc6c789827541863Douglas Gregor */
8571999844e7a18786e61e619e1dc6c789827541863Douglas GregorCINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
8581999844e7a18786e61e619e1dc6c789827541863Douglas Gregor
8591999844e7a18786e61e619e1dc6c789827541863Douglas Gregor/**
8607ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \brief Saves a translation unit into a serialized representation of
8617ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * that translation unit on disk.
8627ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor *
8637ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * Any translation unit that was parsed without error can be saved
8647ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * into a file. The translation unit can then be deserialized into a
8657ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
8667ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * if it is an incomplete translation unit that corresponds to a
8677ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * header, used as a precompiled header when parsing other translation
8687ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * units.
8697ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor *
8707ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \param TU The translation unit to save.
8711999844e7a18786e61e619e1dc6c789827541863Douglas Gregor *
8727ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \param FileName The file to which the translation unit will be saved.
8737ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor *
8741999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \param options A bitmask of options that affects how the translation unit
8751999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * is saved. This should be a bitwise OR of the
8761999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * CXSaveTranslationUnit_XXX flags.
8771999844e7a18786e61e619e1dc6c789827541863Douglas Gregor *
8787ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \returns Zero if the translation unit was saved successfully, a
8797ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * non-zero value otherwise.
8807ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor */
8817ae2faafd30524ef5f863bb3b8701977888839bbDouglas GregorCINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
8821999844e7a18786e61e619e1dc6c789827541863Douglas Gregor                                             const char *FileName,
8831999844e7a18786e61e619e1dc6c789827541863Douglas Gregor                                             unsigned options);
8847ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor
8857ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor/**
8865352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Destroy the specified CXTranslationUnit object.
8875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
8885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
889896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
8905352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
891e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \brief Flags that control the reparsing of translation units.
892e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor *
893e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The enumerators in this enumeration type are meant to be bitwise
894e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * ORed together to specify which options should be used when
895e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * reparsing the translation unit.
896e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor */
897e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregorenum CXReparse_Flags {
898e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  /**
899e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * \brief Used to indicate that no special reparsing options are needed.
900e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   */
901e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  CXReparse_None = 0x0
902e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor};
903e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor
904e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor/**
905e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \brief Returns the set of flags that is suitable for reparsing a translation
906e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * unit.
907e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor *
908e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The set of flags returned provide options for
909e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \c clang_reparseTranslationUnit() by default. The returned flag
910e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * set contains an unspecified set of optimizations geared toward common uses
911e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * of reparsing. The set of optimizations enabled may change from one version
912e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * to the next.
913e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor */
914e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas GregorCINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
915e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor
916e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor/**
917abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \brief Reparse the source files that produced this translation unit.
918abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
919abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * This routine can be used to re-parse the source files that originally
920abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * created the given translation unit, for example because those source files
921abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * have changed (either on disk or as passed via \p unsaved_files). The
922abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * source code will be reparsed with the same command-line options as it
923abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * was originally parsed.
924abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
925abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * Reparsing a translation unit invalidates all cursors and source locations
926abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * that refer into that translation unit. This makes reparsing a translation
927abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unit semantically equivalent to destroying the translation unit and then
928abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * creating a new translation unit with the same command-line arguments.
929abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * However, it may be more efficient to reparse a translation
930abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unit using this routine.
931abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
932abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param TU The translation unit whose contents will be re-parsed. The
933abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * translation unit must originally have been built with
934abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \c clang_createTranslationUnitFromSourceFile().
935abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
936abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param num_unsaved_files The number of unsaved file entries in \p
937abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unsaved_files.
938abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
939abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param unsaved_files The files that have not yet been saved to disk
940abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * but may be required for parsing, including the contents of
941abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * those files.  The contents and name of these files (as specified by
942abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * CXUnsavedFile) are copied when necessary, so the client only needs to
943abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * guarantee their validity until the call to this function returns.
944abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
945e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \param options A bitset of options composed of the flags in CXReparse_Flags.
946e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The function \c clang_defaultReparseOptions() produces a default set of
947e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * options recommended for most uses, based on the translation unit.
948e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor *
949abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \returns 0 if the sources could be reparsed. A non-zero value will be
950abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * returned if reparsing was impossible, such that the translation unit is
951abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * invalid. In such cases, the only valid call for \p TU is
952abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \c clang_disposeTranslationUnit(TU).
953abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor */
954abc563f554951259bbe0315055cad92ee14d87e4Douglas GregorCINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
955abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor                                                unsigned num_unsaved_files,
956e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor                                          struct CXUnsavedFile *unsaved_files,
957e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor                                                unsigned options);
958abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor
959abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor/**
9605352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @}
9615352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
962896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
9635352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
964c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Describes the kind of entity that a cursor refers to.
965c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
966c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregorenum CXCursorKind {
967c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* Declarations */
9681efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
969c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief A declaration whose specific kind is not exposed via this
9701efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * interface.
971c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
972c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * Unexposed declarations have the same operations as any other kind
973c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * of declaration; one can extract their location information,
974c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * spelling, find their definitions, etc. However, the specific kind
975c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * of the declaration is not reported.
976c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
977c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_UnexposedDecl                 = 1,
978c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A C or C++ struct. */
9791efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  CXCursor_StructDecl                    = 2,
980c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A C or C++ union. */
981c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_UnionDecl                     = 3,
982c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A C++ class. */
983c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ClassDecl                     = 4,
984c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An enumeration. */
985c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_EnumDecl                      = 5,
9861efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
987c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief A field (in C) or non-static data member (in C++) in a
988c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * struct, union, or C++ class.
989c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
990c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FieldDecl                     = 6,
991c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An enumerator constant. */
992c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_EnumConstantDecl              = 7,
993c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A function. */
994c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FunctionDecl                  = 8,
995c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A variable. */
996c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_VarDecl                       = 9,
997c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A function or method parameter. */
998c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ParmDecl                      = 10,
999c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @interface. */
1000c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCInterfaceDecl             = 11,
1001c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @interface for a category. */
1002c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCCategoryDecl              = 12,
1003c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @protocol declaration. */
1004c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCProtocolDecl              = 13,
1005c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @property declaration. */
1006c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCPropertyDecl              = 14,
1007c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C instance variable. */
1008c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCIvarDecl                  = 15,
1009c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C instance method. */
1010c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCInstanceMethodDecl        = 16,
1011c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C class method. */
1012c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCClassMethodDecl           = 17,
1013c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @implementation. */
1014c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCImplementationDecl        = 18,
1015c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @implementation for a category. */
1016c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCCategoryImplDecl          = 19,
1017c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A typedef */
1018c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_TypedefDecl                   = 20,
10198bd5a69999cfd06b6b5a58fdd04e4f802b2df5a4Ted Kremenek  /** \brief A C++ class method. */
10208bd5a69999cfd06b6b5a58fdd04e4f802b2df5a4Ted Kremenek  CXCursor_CXXMethod                     = 21,
10218f06e0e9fec3ca501e5fb129f413adbfc88e82f8Ted Kremenek  /** \brief A C++ namespace. */
10228f06e0e9fec3ca501e5fb129f413adbfc88e82f8Ted Kremenek  CXCursor_Namespace                     = 22,
1023a0536d8dd900bb48ea886bd68d777b03b061c068Ted Kremenek  /** \brief A linkage specification, e.g. 'extern "C"'. */
1024a0536d8dd900bb48ea886bd68d777b03b061c068Ted Kremenek  CXCursor_LinkageSpec                   = 23,
102501829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  /** \brief A C++ constructor. */
102601829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  CXCursor_Constructor                   = 24,
102701829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  /** \brief A C++ destructor. */
102801829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  CXCursor_Destructor                    = 25,
102901829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  /** \brief A C++ conversion function. */
103001829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  CXCursor_ConversionFunction            = 26,
1031fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  /** \brief A C++ template type parameter. */
1032fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  CXCursor_TemplateTypeParameter         = 27,
1033fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  /** \brief A C++ non-type template parameter. */
1034fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  CXCursor_NonTypeTemplateParameter      = 28,
1035fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  /** \brief A C++ template template parameter. */
1036fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  CXCursor_TemplateTemplateParameter     = 29,
1037fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  /** \brief A C++ function template. */
1038fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  CXCursor_FunctionTemplate              = 30,
103939d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor  /** \brief A C++ class template. */
104039d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor  CXCursor_ClassTemplate                 = 31,
104174dbe640021d96a8dbb85c592471c04449ade81cDouglas Gregor  /** \brief A C++ class template partial specialization. */
104274dbe640021d96a8dbb85c592471c04449ade81cDouglas Gregor  CXCursor_ClassTemplatePartialSpecialization = 32,
10436931900f43cea558c6974075256c07728dbfecc6Douglas Gregor  /** \brief A C++ namespace alias declaration. */
10446931900f43cea558c6974075256c07728dbfecc6Douglas Gregor  CXCursor_NamespaceAlias                = 33,
10450a35bceb7768fc0be62cb644a4e31d8bfd9fb44aDouglas Gregor  /** \brief A C++ using directive. */
10460a35bceb7768fc0be62cb644a4e31d8bfd9fb44aDouglas Gregor  CXCursor_UsingDirective                = 34,
10477e24256c95afb64b4d5abf201a0f9f0527cb4cf3Douglas Gregor  /** \brief A using declaration. */
10487e24256c95afb64b4d5abf201a0f9f0527cb4cf3Douglas Gregor  CXCursor_UsingDeclaration              = 35,
104950aa6acd0b8d40c8956372a69e0a73f0802a5494Ted Kremenek  CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
10507e24256c95afb64b4d5abf201a0f9f0527cb4cf3Douglas Gregor  CXCursor_LastDecl                      = CXCursor_UsingDeclaration,
10511efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1052c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* References */
1053c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FirstRef                      = 40, /* Decl references */
10541efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  CXCursor_ObjCSuperClassRef             = 40,
1055c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCProtocolRef               = 41,
1056c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCClassRef                  = 42,
1057c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1058c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief A reference to a type declaration.
1059c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1060c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * A type reference occurs anywhere where a type is named but not
1061c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * declared. For example, given:
1062c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1063c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \code
1064c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * typedef unsigned size_type;
1065c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * size_type size;
1066c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \endcode
1067c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1068c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1069c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * while the type of the variable "size" is referenced. The cursor
1070c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * referenced by the type of size is the typedef for size_type.
1071c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1072c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_TypeRef                       = 43,
10733064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CXCursor_CXXBaseSpecifier              = 44,
10740b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor  /**
1075a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor   * \brief A reference to a class template, function template, template
1076a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor   * template parameter, or class template partial specialization.
10770b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor   */
10780b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor  CXCursor_TemplateRef                   = 45,
10796931900f43cea558c6974075256c07728dbfecc6Douglas Gregor  /**
10806931900f43cea558c6974075256c07728dbfecc6Douglas Gregor   * \brief A reference to a namespace or namespace alias.
10816931900f43cea558c6974075256c07728dbfecc6Douglas Gregor   */
10826931900f43cea558c6974075256c07728dbfecc6Douglas Gregor  CXCursor_NamespaceRef                  = 46,
1083a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor  /**
108436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * \brief A reference to a member of a struct, union, or class that occurs in
108536897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * some non-expression context, e.g., a designated initializer.
1086a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor   */
1087a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor  CXCursor_MemberRef                     = 47,
108836897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor  /**
108936897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * \brief A reference to a labeled statement.
109036897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *
109136897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * This cursor kind is used to describe the jump to "start_over" in the
109236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * goto statement in the following example:
109336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *
109436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * \code
109536897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *   start_over:
109636897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *     ++counter;
109736897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *
109836897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *     goto start_over;
109936897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * \endcode
110036897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *
110136897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * A label reference cursor refers to a label statement.
110236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   */
110336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor  CXCursor_LabelRef                      = 48,
110436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor
11051f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor  /**
11061f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * \brief A reference to a set of overloaded functions or function templates
11071f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * that has not yet been resolved to a specific function or function template.
11081f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *
11091f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * An overloaded declaration reference cursor occurs in C++ templates where
11101f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * a dependent name refers to a function. For example:
11111f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *
11121f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * \code
11131f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * template<typename T> void swap(T&, T&);
11141f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *
11151f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * struct X { ... };
11161f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * void swap(X&, X&);
11171f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *
11181f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * template<typename T>
11191f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * void reverse(T* first, T* last) {
11201f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *   while (first < last - 1) {
11211f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *     swap(*first, *--last);
11221f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *     ++first;
11231f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *   }
11241f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * }
11251f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *
11261f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * struct Y { };
11271f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * void swap(Y&, Y&);
11281f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * \endcode
11291f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *
11301f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * Here, the identifier "swap" is associated with an overloaded declaration
11311f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * reference. In the template definition, "swap" refers to either of the two
11321f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * "swap" functions declared above, so both results will be available. At
11331f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * instantiation time, "swap" may also refer to other functions found via
11341f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * argument-dependent lookup (e.g., the "swap" function at the end of the
11351f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * example).
11361f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   *
11371f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * The functions \c clang_getNumOverloadedDecls() and
11381f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * \c clang_getOverloadedDecl() can be used to retrieve the definitions
11391f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   * referenced by this cursor.
11401f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor   */
11411f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor  CXCursor_OverloadedDeclRef             = 49,
11421f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor
11431f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor  CXCursor_LastRef                       = CXCursor_OverloadedDeclRef,
11441efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1145c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* Error conditions */
1146c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FirstInvalid                  = 70,
1147c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_InvalidFile                   = 70,
1148c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_NoDeclFound                   = 71,
1149c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_NotImplemented                = 72,
1150ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek  CXCursor_InvalidCode                   = 73,
1151ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek  CXCursor_LastInvalid                   = CXCursor_InvalidCode,
11521efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1153c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* Expressions */
1154c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FirstExpr                     = 100,
11551efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1156c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1157c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief An expression whose specific kind is not exposed via this
11581efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * interface.
1159c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1160c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * Unexposed expressions have the same operations as any other kind
1161c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * of expression; one can extract their location information,
1162c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * spelling, children, etc. However, the specific kind of the
1163c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * expression is not reported.
1164c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1165c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_UnexposedExpr                 = 100,
11661efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1167c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1168c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief An expression that refers to some value declaration, such
1169c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * as a function, varible, or enumerator.
1170c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1171c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_DeclRefExpr                   = 101,
11721efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1173c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1174c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief An expression that refers to a member of a struct, union,
1175c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * class, Objective-C class, etc.
1176c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1177c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_MemberRefExpr                 = 102,
11781efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1179c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An expression that calls a function. */
1180c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_CallExpr                      = 103,
11811efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1182c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An expression that sends a message to an Objective-C
1183c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   object or class. */
1184c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCMessageExpr               = 104,
11851ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek
11861ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek  /** \brief An expression that represents a block literal. */
11871ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek  CXCursor_BlockExpr                     = 105,
11881ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek
11891ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek  CXCursor_LastExpr                      = 105,
11901efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1191c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* Statements */
1192c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FirstStmt                     = 200,
1193c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1194c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief A statement whose specific kind is not exposed via this
1195c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * interface.
1196c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1197c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * Unexposed statements have the same operations as any other kind of
1198c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * statement; one can extract their location information, spelling,
1199c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * children, etc. However, the specific kind of the statement is not
1200c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * reported.
1201c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1202c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_UnexposedStmt                 = 200,
120336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor
120436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor  /** \brief A labelled statement in a function.
120536897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *
120636897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * This cursor kind is used to describe the "start_over:" label statement in
120736897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * the following example:
120836897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *
120936897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * \code
121036897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *   start_over:
121136897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *     ++counter;
121236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   * \endcode
121336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   *
121436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor   */
121536897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor  CXCursor_LabelStmt                     = 201,
121636897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor
121736897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor  CXCursor_LastStmt                      = CXCursor_LabelStmt,
12181efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1219c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1220c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief Cursor that represents the translation unit itself.
1221c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1222c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * The translation unit cursor exists primarily to act as the root
1223c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * cursor for traversing the contents of a translation unit.
1224c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1225e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_TranslationUnit               = 300,
1226e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek
1227e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  /* Attributes */
1228e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_FirstAttr                     = 400,
1229e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  /**
1230e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek   * \brief An attribute whose specific kind is not exposed via this
1231e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek   * interface.
1232e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek   */
1233e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_UnexposedAttr                 = 400,
1234e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek
1235e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_IBActionAttr                  = 401,
1236e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_IBOutletAttr                  = 402,
1237857e918a8a40deb128840308a318bf623d68295fTed Kremenek  CXCursor_IBOutletCollectionAttr        = 403,
1238857e918a8a40deb128840308a318bf623d68295fTed Kremenek  CXCursor_LastAttr                      = CXCursor_IBOutletCollectionAttr,
12399f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor
12409f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor  /* Preprocessing */
12419f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor  CXCursor_PreprocessingDirective        = 500,
1242572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor  CXCursor_MacroDefinition               = 501,
1243572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor  CXCursor_MacroInstantiation            = 502,
1244ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor  CXCursor_InclusionDirective            = 503,
12459f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor  CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
1246ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor  CXCursor_LastPreprocessing             = CXCursor_InclusionDirective
1247c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor};
1248c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1249c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1250c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A cursor representing some element in the abstract syntax tree for
1251c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * a translation unit.
1252c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
12531efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The cursor abstraction unifies the different kinds of entities in a
1254c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * program--declaration, statements, expressions, references to declarations,
1255c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * etc.--under a single "cursor" abstraction with a common set of operations.
1256c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Common operation for a cursor include: getting the physical location in
1257c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * a source file where the cursor points, getting the name associated with a
1258c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor, and retrieving cursors for any child nodes of a particular cursor.
1259c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1260c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Cursors can be produced in two specific ways.
1261c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
1262c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * from which one can use clang_visitChildren() to explore the rest of the
1263c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * translation unit. clang_getCursor() maps from a physical source location
1264c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to the entity that resides at that location, allowing one to map from the
1265c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * source code into the AST.
1266c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1267c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregortypedef struct {
1268c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  enum CXCursorKind kind;
1269c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  void *data[3];
12701efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar} CXCursor;
1271c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1272c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1273c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
1274c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1275c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
1276c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
12771efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1278c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1279c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the NULL cursor, which represents no entity.
1280c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1281c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXCursor clang_getNullCursor(void);
12821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1283c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1284c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the cursor that represents the given translation unit.
1285c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1286c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The translation unit cursor can be used to start traversing the
1287c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * various declarations within the given translation unit.
1288c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1289c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
1290c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1291c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1292c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether two cursors are equivalent.
1293c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1294c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
12951efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1296c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1297c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the kind of the given cursor.
1298c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1299c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
1300c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1301c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1302c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a declaration.
1303c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1304c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
1305c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1306c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1307c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a simple
1308c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * reference.
1309c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1310c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Note that other kinds of cursors (such as expressions) can also refer to
1311c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * other cursors. Use clang_getCursorReferenced() to determine whether a
1312c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * particular cursor refers to another entity.
1313c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1314c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
1315c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1316c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1317c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents an expression.
1318c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1319c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
1320c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1321c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1322c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a statement.
1323c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1324c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
1325c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1326c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
13271efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Determine whether the given cursor kind represents an invalid
1328c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor.
13291efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar */
1330c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
1331c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1332c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
13331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Determine whether the given cursor kind represents a translation
13341efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * unit.
1335c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1336c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
13371efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1338ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek/***
13399f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor * \brief Determine whether the given cursor represents a preprocessing
13409f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor * element, such as a preprocessor directive or macro instantiation.
13419f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor */
13429f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas GregorCINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
13439f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor
13449f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor/***
1345ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek * \brief Determine whether the given cursor represents a currently
1346ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
1347ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek */
1348ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted KremenekCINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
1349ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek
1350c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
135116b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek * \brief Describe the linkage of the entity referred to by a cursor.
135216b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek */
135316b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenekenum CXLinkageKind {
135416b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /** \brief This value indicates that no linkage information is available
135516b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   * for a provided CXCursor. */
135616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_Invalid,
135716b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /**
135816b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   * \brief This is the linkage for variables, parameters, and so on that
135916b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   *  have automatic storage.  This covers normal (non-extern) local variables.
136016b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   */
136116b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_NoLinkage,
136216b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /** \brief This is the linkage for static variables and static functions. */
136316b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_Internal,
136416b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /** \brief This is the linkage for entities with external linkage that live
136516b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   * in C++ anonymous namespaces.*/
136616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_UniqueExternal,
136716b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /** \brief This is the linkage for entities with true, external linkage. */
136816b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_External
136916b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek};
137016b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek
137116b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek/**
137245e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Determine the linkage of the entity referred to by a given cursor.
137316b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek */
137416b4259aecaa22b642d35d36fd89965ed700c1e0Ted KremenekCINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
137516b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek
137616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek/**
137758ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \brief Determine the availability of the entity that this cursor refers to.
137858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor *
137958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \param cursor The cursor to query.
138058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor *
138158ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \returns The availability of the cursor.
138258ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor */
138358ddb60f409125eda5436c4a1f070f7fa4744295Douglas GregorCINDEX_LINKAGE enum CXAvailabilityKind
138458ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorclang_getCursorAvailability(CXCursor cursor);
138558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor
138658ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor/**
138745e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Describe the "language" of the entity referred to by a cursor.
138845e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek */
138945e1dae500bba7a9ef5b8206263a5609c07c6f03Ted KremenekCINDEX_LINKAGE enum CXLanguageKind {
13906cd1e7cb04d1da66e8b5675062152ff60bbc354fTed Kremenek  CXLanguage_Invalid = 0,
139145e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek  CXLanguage_C,
139245e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek  CXLanguage_ObjC,
13936cd1e7cb04d1da66e8b5675062152ff60bbc354fTed Kremenek  CXLanguage_CPlusPlus
139445e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek};
139545e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek
139645e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek/**
139745e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Determine the "language" of the entity referred to by a given cursor.
139845e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek */
139945e1dae500bba7a9ef5b8206263a5609c07c6f03Ted KremenekCINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
140045e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek
14012be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor
14022be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor/**
14032be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \brief Determine the semantic parent of the given cursor.
14042be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14052be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * The semantic parent of a cursor is the cursor that semantically contains
14062be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the given \p cursor. For many declarations, the lexical and semantic parents
14072be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * are equivalent (the lexical parent is returned by
14082be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \c clang_getCursorLexicalParent()). They diverge when declarations or
14092be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * definitions are provided out-of-line. For example:
14102be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14112be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \code
14122be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * class C {
14132be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *  void f();
14142be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * };
14152be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14162be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * void C::f() { }
14172be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \endcode
14182be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14192be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * In the out-of-line definition of \c C::f, the semantic parent is the
14202be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the class \c C, of which this function is a member. The lexical parent is
14212be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the place where the declaration actually occurs in the source code; in this
14222be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * case, the definition occurs in the translation unit. In general, the
14232be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * lexical parent for a given entity can change without affecting the semantics
14242be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * of the program, and the lexical parent of different declarations of the
14252be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * same entity may be different. Changing the semantic parent of a declaration,
14262be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * on the other hand, can have a major impact on semantics, and redeclarations
14272be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * of a particular entity should all have the same semantic context.
14282be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14292be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * In the example above, both declarations of \c C::f have \c C as their
14302be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * semantic context, while the lexical context of the first \c C::f is \c C
14312be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * and the lexical context of the second \c C::f is the translation unit.
14322be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor */
14332be5bc9ad3981347a000742f81b91ab3080f1214Douglas GregorCINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor);
14342be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor
14352be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor/**
14362be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \brief Determine the lexical parent of the given cursor.
14372be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14382be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * The lexical parent of a cursor is the cursor in which the given \p cursor
14392be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * was actually written. For many declarations, the lexical and semantic parents
14402be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * are equivalent (the semantic parent is returned by
14412be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \c clang_getCursorSemanticParent()). They diverge when declarations or
14422be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * definitions are provided out-of-line. For example:
14432be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14442be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \code
14452be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * class C {
14462be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *  void f();
14472be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * };
14482be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14492be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * void C::f() { }
14502be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * \endcode
14512be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14522be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * In the out-of-line definition of \c C::f, the semantic parent is the
14532be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the class \c C, of which this function is a member. The lexical parent is
14542be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * the place where the declaration actually occurs in the source code; in this
14552be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * case, the definition occurs in the translation unit. In general, the
14562be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * lexical parent for a given entity can change without affecting the semantics
14572be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * of the program, and the lexical parent of different declarations of the
14582be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * same entity may be different. Changing the semantic parent of a declaration,
14592be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * on the other hand, can have a major impact on semantics, and redeclarations
14602be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * of a particular entity should all have the same semantic context.
14612be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor *
14622be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * In the example above, both declarations of \c C::f have \c C as their
14632be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * semantic context, while the lexical context of the first \c C::f is \c C
14642be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor * and the lexical context of the second \c C::f is the translation unit.
14652be5bc9ad3981347a000742f81b91ab3080f1214Douglas Gregor */
14662be5bc9ad3981347a000742f81b91ab3080f1214Douglas GregorCINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor);
14679f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor
14689f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor/**
14699f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \brief Determine the set of methods that are overridden by the given
14709f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * method.
14719f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor *
14729f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * In both Objective-C and C++, a method (aka virtual member function,
14739f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * in C++) can override a virtual method in a base class. For
14749f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * Objective-C, a method is said to override any method in the class's
14759f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * interface (if we're coming from an implementation), its protocols,
14769f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * or its categories, that has the same selector and is of the same
14779f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * kind (class or instance). If no such method exists, the search
14789f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * continues to the class's superclass, its protocols, and its
14799f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * categories, and so on.
14809f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor *
14819f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * For C++, a virtual member function overrides any virtual member
14829f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * function with the same signature that occurs in its base
14839f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * classes. With multiple inheritance, a virtual member function can
14849f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * override several virtual member functions coming from different
14859f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * base classes.
14869f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor *
14879f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * In all cases, this function determines the immediate overridden
14889f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * method, rather than all of the overridden methods. For example, if
14899f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * a method is originally declared in a class A, then overridden in B
14909f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * (which in inherits from A) and also in C (which inherited from B),
14919f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * then the only overridden method returned from this function when
14929f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * invoked on C's method will be B's method. The client may then
14939f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * invoke this function again, given the previously-found overridden
14949f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * methods, to map out the complete method-override set.
14959f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor *
14969f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \param cursor A cursor representing an Objective-C or C++
14979f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * method. This routine will compute the set of methods that this
14989f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * method overrides.
14999f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor *
15009f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \param overridden A pointer whose pointee will be replaced with a
15019f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * pointer to an array of cursors, representing the set of overridden
15029f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * methods. If there are no overridden methods, the pointee will be
15039f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * set to NULL. The pointee must be freed via a call to
15049f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \c clang_disposeOverriddenCursors().
15059f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor *
15069f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \param num_overridden A pointer to the number of overridden
15079f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * functions, will be set to the number of overridden functions in the
15089f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * array pointed to by \p overridden.
15099f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor */
15109f59234a91d057cee7c5e3cee91da8696858c692Douglas GregorCINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor,
15119f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor                                               CXCursor **overridden,
15129f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor                                               unsigned *num_overridden);
15139f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor
15149f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor/**
15159f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * \brief Free the set of overridden cursors returned by \c
15169f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor * clang_getOverriddenCursors().
15179f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor */
15189f59234a91d057cee7c5e3cee91da8696858c692Douglas GregorCINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden);
15199f59234a91d057cee7c5e3cee91da8696858c692Douglas Gregor
152045e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek/**
1521ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor * \brief Retrieve the file that is included by the given inclusion directive
1522ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor * cursor.
1523ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor */
1524ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas GregorCINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor);
1525ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor
1526ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor/**
1527c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
1528c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
15291efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1530c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1531c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
1532c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1533c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Cursors represent a location within the Abstract Syntax Tree (AST). These
1534c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * routines help map between cursors and the physical locations where the
1535c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * described entities occur in the source code. The mapping is provided in
1536c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * both directions, so one can map from source code to the AST and back.
1537c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1538c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
153950398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff */
15401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
15416a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff/**
1542b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Map a source location to the cursor that describes the entity at that
1543b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * location in the source code.
1544b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
1545b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * clang_getCursor() maps an arbitrary source location within a translation
1546b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * unit down to the most specific cursor that describes the entity at that
15471efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * location. For example, given an expression \c x + y, invoking
1548b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * clang_getCursor() with a source location pointing to "x" will return the
15491efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * cursor for "x"; similarly for "y". If the cursor points anywhere between
1550b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
1551b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * will return a cursor referring to the "+" expression.
1552b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
1553b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns a cursor representing the entity at the given source location, or
1554b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * a NULL cursor if no such entity can be found.
15556a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff */
1556b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
15571efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
155898258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor/**
155998258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * \brief Retrieve the physical location of the source constructor referenced
156098258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * by the given cursor.
156198258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor *
156298258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * The location of a declaration is typically the location of the name of that
15631efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * declaration, where the name of that declaration would occur if it is
15641efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * unnamed, or some keyword that introduces that particular declaration.
15651efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The location of a reference is where that reference occurs within the
156698258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * source code.
156798258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor */
156898258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
1569c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1570b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor/**
1571b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief Retrieve the physical extent of the source construct referenced by
1572a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * the given cursor.
1573a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor *
1574a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * The extent of a cursor starts with the file/line/column pointing at the
1575a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * first character within the source construct that the cursor refers to and
15761efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * ends with the last character withinin that source construct. For a
1577a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * declaration, the extent covers the declaration itself. For a reference,
1578a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * the extent covers the location of the reference (e.g., where the referenced
1579a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * entity was actually used).
1580a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor */
1581a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
1582c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor
1583c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1584c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
1585c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
158695f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
1587c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
15888e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \defgroup CINDEX_TYPES Type information for CXCursors
15898e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
15908e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * @{
15918e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
15928e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
15938e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
15948e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Describes the kind of type
15958e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
15968e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenekenum CXTypeKind {
15978e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  /**
15988e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   * \brief Reprents an invalid type (e.g., where no type is available).
15998e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   */
16008e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Invalid = 0,
16018e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16028e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  /**
16038e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   * \brief A type whose specific kind is not exposed via this
16048e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   * interface.
16058e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   */
16068e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Unexposed = 1,
16078e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16088e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  /* Builtin types */
16098e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Void = 2,
16108e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Bool = 3,
16118e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Char_U = 4,
16128e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_UChar = 5,
16138e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Char16 = 6,
16148e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Char32 = 7,
16158e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_UShort = 8,
16168e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_UInt = 9,
16178e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ULong = 10,
16188e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ULongLong = 11,
16198e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_UInt128 = 12,
16208e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Char_S = 13,
16218e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_SChar = 14,
16228e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_WChar = 15,
16238e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Short = 16,
16248e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Int = 17,
16258e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Long = 18,
16268e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_LongLong = 19,
16278e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Int128 = 20,
16288e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Float = 21,
16298e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Double = 22,
16308e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_LongDouble = 23,
16318e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_NullPtr = 24,
16328e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Overload = 25,
16338e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Dependent = 26,
16348e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ObjCId = 27,
16358e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ObjCClass = 28,
16368e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ObjCSel = 29,
16378e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_FirstBuiltin = CXType_Void,
16388e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_LastBuiltin  = CXType_ObjCSel,
16398e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16408e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Complex = 100,
16418e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Pointer = 101,
16428e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_BlockPointer = 102,
16438e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_LValueReference = 103,
16448e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_RValueReference = 104,
16458e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Record = 105,
16468e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Enum = 106,
16478e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Typedef = 107,
16488e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ObjCInterface = 108,
164904c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek  CXType_ObjCObjectPointer = 109,
165004c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek  CXType_FunctionNoProto = 110,
165104c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek  CXType_FunctionProto = 111
16528e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek};
16538e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16548e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
16558e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief The type of an element in the abstract syntax tree.
16568e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
16578e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
16588e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenektypedef struct {
16598e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  enum CXTypeKind kind;
16608e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  void *data[2];
16618e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek} CXType;
16628e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16638e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
16648e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Retrieve the type of a CXCursor (if any).
16658e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
16668e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
16678e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16688e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
16698e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \determine Determine whether two CXTypes represent the same type.
16708e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
16718e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \returns non-zero if the CXTypes represent the same type and
16728e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek            zero otherwise.
16738e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
16748e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
16758e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16768e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
16778e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Return the canonical type for a CXType.
16788e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
16798e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * Clang's type system explicitly models typedefs and all the ways
16808e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * a specific type can be represented.  The canonical type is the underlying
16818e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * type with all the "sugar" removed.  For example, if 'T' is a typedef
16828e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * for 'int', the canonical type for 'T' would be 'int'.
16838e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
16848e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
16858e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16868e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
16878e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief For pointer types, returns the type of the pointee.
16888e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
16898e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
16908e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
16918e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16928e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
16938e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Return the cursor for the declaration of the given type.
16948e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
16958e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
16968e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16978e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
16988e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
16998e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Retrieve the spelling of a given CXTypeKind.
17008e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
17018e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
17028e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
17038e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
17049a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek * \brief Retrieve the result type associated with a function type.
170504c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek */
170604c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted KremenekCINDEX_LINKAGE CXType clang_getResultType(CXType T);
170704c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek
170804c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek/**
17099a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek * \brief Retrieve the result type associated with a given cursor.  This only
17109a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek *  returns a valid type of the cursor refers to a function or method.
17119a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek */
17129a140845438c2fc31e7d48a6dedbc695f4c83c68Ted KremenekCINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
17139a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek
17149a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek/**
17153ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
17163ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek *  otherwise.
17173ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek */
17183ce9e7d270e7df86c09c8126b4412d55be7c123bTed KremenekCINDEX_LINKAGE unsigned clang_isPODType(CXType T);
17193ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek
17203ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek/**
17213064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Returns 1 if the base class specified by the cursor with kind
17223064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek *   CX_CXXBaseSpecifier is virtual.
17233064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */
17243064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
17253064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek
17263064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/**
17273064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Represents the C++ access control level to a base class for a
17283064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * cursor with kind CX_CXXBaseSpecifier.
17293064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */
17303064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenekenum CX_CXXAccessSpecifier {
17313064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CX_CXXInvalidAccessSpecifier,
17323064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CX_CXXPublic,
17333064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CX_CXXProtected,
17343064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CX_CXXPrivate
17353064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek};
17363064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek
17373064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/**
17383064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Returns the access control level for the C++ base specifier
17393064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek *  represented by a cursor with kind CX_CXXBaseSpecifier.
17403064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */
17413064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
17423064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek
17433064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/**
17441f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \brief Determine the number of overloaded declarations referenced by a
17451f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \c CXCursor_OverloadedDeclRef cursor.
17461f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor *
17471f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \param cursor The cursor whose overloaded declarations are being queried.
17481f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor *
17491f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \returns The number of overloaded declarations referenced by \c cursor. If it
17501f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0.
17511f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor */
17521f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas GregorCINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor);
17531f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor
17541f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor/**
17551f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \brief Retrieve a cursor for one of the overloaded declarations referenced
17561f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * by a \c CXCursor_OverloadedDeclRef cursor.
17571f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor *
17581f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \param cursor The cursor whose overloaded declarations are being queried.
17591f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor *
17601f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \param index The zero-based index into the set of overloaded declarations in
17611f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * the cursor.
17621f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor *
17631f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \returns A cursor representing the declaration referenced by the given
17641f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * \c cursor at the specified \c index. If the cursor does not have an
17651f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * associated set of overloaded declarations, or if the index is out of bounds,
17661f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor * returns \c clang_getNullCursor();
17671f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor */
17681f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas GregorCINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor,
17691f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor                                                unsigned index);
17701f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor
17711f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor/**
17728e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * @}
17738e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
177495f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
177595f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/**
1776ad72f4dad4cf0fd2b71eb8f4704d2fe7ac58fb44Ted Kremenek * \defgroup CINDEX_ATTRIBUTES Information for attributes
177795f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek *
177895f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * @{
177995f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */
178095f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
178195f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
178295f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/**
178395f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * \brief For cursors representing an iboutletcollection attribute,
178495f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek *  this function returns the collection element type.
178595f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek *
178695f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */
178795f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted KremenekCINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
178895f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
178995f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/**
179095f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * @}
179195f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */
17928e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
17938e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
1794c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
1795c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1796c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * These routines provide the ability to traverse the abstract syntax tree
1797c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * using cursors.
1798c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1799c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
1800c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
18011efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1802c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1803c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Describes how the traversal of the children of a particular
1804c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor should proceed after visiting a particular child cursor.
1805c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1806c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A value of this enumeration type should be returned by each
1807c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
1808c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1809c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregorenum CXChildVisitResult {
1810c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
18111efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * \brief Terminates the cursor traversal.
1812c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1813c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXChildVisit_Break,
18141efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
1815c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief Continues the cursor traversal with the next sibling of
1816c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * the cursor just visited, without visiting its children.
1817c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1818c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXChildVisit_Continue,
1819c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1820c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief Recursively traverse the children of this cursor, using
1821c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * the same visitor and client data.
1822c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1823c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXChildVisit_Recurse
1824c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor};
1825c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1826c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1827c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Visitor invoked for each cursor found by a traversal.
1828c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1829c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * This visitor function will be invoked for each cursor found by
1830c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_visitCursorChildren(). Its first argument is the cursor being
1831c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * visited, its second argument is the parent visitor for that cursor,
1832c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * and its third argument is the client data provided to
1833c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_visitCursorChildren().
1834c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1835c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The visitor should return one of the \c CXChildVisitResult values
1836c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to direct clang_visitCursorChildren().
1837c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
18381efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbartypedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
18391efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar                                                   CXCursor parent,
1840c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor                                                   CXClientData client_data);
1841c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1842c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1843c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Visit the children of a particular cursor.
1844c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1845c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * This function visits all the direct children of the given cursor,
1846c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * invoking the given \p visitor function with the cursors of each
1847c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * visited child. The traversal may be recursive, if the visitor returns
1848c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
1849c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * the visitor returns \c CXChildVisit_Break.
1850c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1851c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param parent the cursor whose child may be visited. All kinds of
1852a57259e9d7b30bcce93f0a62eee0488738026172Daniel Dunbar * cursors can be visited, including invalid cursors (which, by
1853c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * definition, have no children).
1854c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1855c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param visitor the visitor function that will be invoked for each
1856c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * child of \p parent.
1857c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1858c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param client_data pointer data supplied by the client, which will
1859c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * be passed to the visitor each time it is invoked.
1860c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1861c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \returns a non-zero value if the traversal was terminated
1862c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * prematurely by the visitor returning \c CXChildVisit_Break.
1863c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
18641efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
1865c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor                                            CXCursorVisitor visitor,
1866c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor                                            CXClientData client_data);
18673387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall#ifdef __has_feature
18683387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall#  if __has_feature(blocks)
18693387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall/**
18703387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * \brief Visitor invoked for each cursor found by a traversal.
18713387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall *
18723387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * This visitor block will be invoked for each cursor found by
18733387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * clang_visitChildrenWithBlock(). Its first argument is the cursor being
18743387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * visited, its second argument is the parent visitor for that cursor.
18753387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall *
18763387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * The visitor should return one of the \c CXChildVisitResult values
18773387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * to direct clang_visitChildrenWithBlock().
18783387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall */
18793387c65a094a02b2a94c05111d035a97d3d5c794David Chisnalltypedef enum CXChildVisitResult
18803387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall     (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
18813387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall
18823387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall/**
18833387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * Visits the children of a cursor using the specified block.  Behaves
18843387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall * identically to clang_visitChildren() in all other respects.
18853387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall */
18863387c65a094a02b2a94c05111d035a97d3d5c794David Chisnallunsigned clang_visitChildrenWithBlock(CXCursor parent,
18873387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall                                      CXCursorVisitorBlock block);
18883387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall#  endif
18893387c65a094a02b2a94c05111d035a97d3d5c794David Chisnall#endif
18901efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1891c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1892c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
1893c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
18941efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1895c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1896c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
1897c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
18981efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * These routines provide the ability to determine references within and
1899c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * across translation units, by providing the names of the entities referenced
1900c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * by cursors, follow reference cursors to the declarations they reference,
1901c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * and associate declarations with their definitions.
1902c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1903c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
1904c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
19051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1906c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1907c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
1908c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * by the given cursor.
1909c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1910c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A Unified Symbol Resolution (USR) is a string that identifies a particular
1911c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * entity (function, class, variable, etc.) within a program. USRs can be
1912c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * compared across translation units to determine, e.g., when references in
1913c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * one translation refer to an entity defined in another translation unit.
1914c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1915c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
1916c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1917c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1918896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C class.
1919896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1920896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
1921896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1922896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1923896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C category.
1924896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1925896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString
192666ccaec73706f3623d2e7d191fe2c944feedcc2bTed Kremenek  clang_constructUSR_ObjCCategory(const char *class_name,
1927896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                 const char *category_name);
1928896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1929896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1930896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C protocol.
1931896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1932896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString
1933896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek  clang_constructUSR_ObjCProtocol(const char *protocol_name);
1934896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1935896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1936896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1937896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C instance variable and
1938896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek *   the USR for its containing class.
1939896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1940896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
1941896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                                    CXString classUSR);
1942896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1943896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1944896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C method and
1945896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek *   the USR for its containing class.
1946896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1947896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
1948896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                                      unsigned isInstanceMethod,
1949896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                                      CXString classUSR);
1950896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1951896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1952896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C property and the USR
1953896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek *  for its containing class.
1954896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1955896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
1956896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                                        CXString classUSR);
1957896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1958896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1959c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve a name for the entity referenced by this cursor.
1960c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1961c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
1962c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1963358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor/**
1964358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * \brief Retrieve the display name for the entity referenced by this cursor.
1965358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor *
1966358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * The display name contains extra information that helps identify the cursor,
1967358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * such as the parameters of a function or template or the arguments of a
1968358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor * class template specialization.
1969358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor */
1970358559d8d7b458c5f64941842383a16e61f0828dDouglas GregorCINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor);
1971358559d8d7b458c5f64941842383a16e61f0828dDouglas Gregor
1972c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor/** \brief For a cursor that is a reference, retrieve a cursor representing the
1973c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * entity that it references.
1974c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor *
1975c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * Reference cursors refer to other entities in the AST. For example, an
1976c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * Objective-C superclass reference cursor refers to an Objective-C class.
19771efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * This function produces the cursor for the Objective-C class from the
1978c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * cursor for the superclass reference. If the input cursor is a declaration or
1979c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * definition, it returns that declaration or definition unchanged.
19801efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * Otherwise, returns the NULL cursor.
1981c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor */
1982c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas GregorCINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
1983b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor
19841efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/**
1985b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  \brief For a cursor that is either a reference to or a declaration
1986b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  of some entity, retrieve a cursor that describes the definition of
1987b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  that entity.
1988b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *
1989b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  Some entities can be declared multiple times within a translation
1990b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  unit, but only one of those declarations can also be a
1991b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  definition. For example, given:
1992b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *
1993b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  \code
1994b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  int f(int, int);
1995b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  int g(int x, int y) { return f(x, y); }
1996b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  int f(int a, int b) { return a + b; }
1997b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  int f(int, int);
1998b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  \endcode
1999b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *
2000b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  there are three declarations of the function "f", but only the
2001b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  second one is a definition. The clang_getCursorDefinition()
2002b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  function will take any cursor pointing to a declaration of "f"
2003b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  (the first or fourth lines of the example) or a cursor referenced
2004b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  that uses "f" (the call to "f' inside "g") and will return a
2005b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  declaration cursor pointing to the definition (the second "f"
2006b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  declaration).
2007b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *
2008b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  If given a cursor for which there is no corresponding definition,
2009b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  e.g., because there is no definition of that entity within this
2010b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  translation unit, returns a NULL cursor.
2011b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor */
2012b699866820102a69d83d6ac6941985c5ef4e8c40Douglas GregorCINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
2013b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor
20141efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/**
2015b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief Determine whether the declaration pointed to by this cursor
2016b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * is also a definition of that entity.
2017b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor */
2018b699866820102a69d83d6ac6941985c5ef4e8c40Douglas GregorCINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
2019b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor
2020c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
2021c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
2022c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
20231efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2024c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
20259ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * \defgroup CINDEX_CPP C++ AST introspection
20269ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek *
20279ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * The routines in this group provide access information in the ASTs specific
20289ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * to C++ language features.
20299ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek *
20309ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * @{
20319ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */
20329ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek
20339ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/**
203449f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \brief Determine if a C++ member function or member function template is
203549f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * declared 'static'.
20369ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */
20379ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed KremenekCINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
20389ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek
20399ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/**
204049f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \brief Given a cursor that represents a template, determine
204149f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * the cursor kind of the specializations would be generated by instantiating
204249f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * the template.
204349f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor *
204449f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * This routine can be used to determine what flavor of function template,
204549f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * class template, or class template partial specialization is stored in the
204649f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * cursor. For example, it can describe whether a class template cursor is
204749f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * declared with "struct", "class" or "union".
204849f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor *
204949f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \param C The cursor to query. This cursor should represent a template
205049f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * declaration.
205149f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor *
205249f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \returns The cursor kind of the specializations that would be generated
205349f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * by instantiating the template \p C. If \p C is not a template, returns
205449f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor * \c CXCursor_NoDeclFound.
205549f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor */
205649f6f5489483beaffc7ce48dfc000af4e65b9216Douglas GregorCINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C);
205749f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor
205849f6f5489483beaffc7ce48dfc000af4e65b9216Douglas Gregor/**
2059e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * \brief Given a cursor that may represent a specialization or instantiation
2060e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * of a template, retrieve the cursor that represents the template that it
2061e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * specializes or from which it was instantiated.
2062e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor *
2063e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * This routine determines the template involved both for explicit
2064e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * specializations of templates and for implicit instantiations of the template,
2065e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * both of which are referred to as "specializations". For a class template
2066e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * specialization (e.g., \c std::vector<bool>), this routine will return
2067e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * either the primary template (\c std::vector) or, if the specialization was
2068e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * instantiated from a class template partial specialization, the class template
2069e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * partial specialization. For a class template partial specialization and a
2070e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * function template specialization (including instantiations), this
2071e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * this routine will return the specialized template.
2072e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor *
2073e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * For members of a class template (e.g., member functions, member classes, or
2074e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * static data members), returns the specialized or instantiated member.
2075e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * Although not strictly "templates" in the C++ language, members of class
2076e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * templates have the same notions of specializations and instantiations that
2077e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * templates do, so this routine treats them similarly.
2078e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor *
2079e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * \param C A cursor that may be a specialization of a template or a member
2080e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * of a template.
2081e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor *
2082e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * \returns If the given cursor is a specialization or instantiation of a
2083e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * template or a member thereof, the template or member that it specializes or
2084e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor * from which it was instantiated. Otherwise, returns a NULL cursor.
2085e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor */
2086e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas GregorCINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
2087e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor
2088e0329acf5c9437e2086a2fb2bf7a95ae2ac96505Douglas Gregor/**
20899ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * @}
20909ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */
20919ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek
20929ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/**
20930045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * \defgroup CINDEX_LEX Token extraction and manipulation
20940045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *
20950045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * The routines in this group provide access to the tokens within a
20960045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * translation unit, along with a semantic mapping of those tokens to
20970045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * their corresponding cursors.
2098fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2099fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * @{
2100fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2101fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor
2102fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2103fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Describes a kind of token.
2104fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2105fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregortypedef enum CXTokenKind {
2106fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
2107fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   * \brief A token that contains some kind of punctuation.
2108fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
2109fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Punctuation,
2110896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2111fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
21120045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor   * \brief A language keyword.
2113fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
2114fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Keyword,
2115896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2116fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
2117fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   * \brief An identifier (that is not a keyword).
2118fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
2119fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Identifier,
2120896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2121fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
2122fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   * \brief A numeric, string, or character literal.
2123fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
2124fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Literal,
2125896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2126fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
2127fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   * \brief A comment.
2128fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
2129fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Comment
2130fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor} CXTokenKind;
2131fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor
2132fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2133fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Describes a single preprocessing token.
2134fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2135fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregortypedef struct {
2136fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  unsigned int_data[4];
2137fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  void *ptr_data;
2138fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor} CXToken;
2139fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor
2140fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2141fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Determine the kind of the given token.
2142fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2143fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
2144896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2145fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2146fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Determine the spelling of the given token.
2147fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2148fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * The spelling of a token is the textual representation of that token, e.g.,
2149fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * the text of an identifier or keyword.
2150fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2151fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
2152896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2153fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2154fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Retrieve the source location of the given token.
2155fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2156896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
2157fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                                       CXToken);
2158896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2159fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2160fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Retrieve a source range that covers the given token.
2161fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2162fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
2163fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor
2164fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2165fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Tokenize the source code described by the given range into raw
2166fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * lexical tokens.
2167fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2168fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param TU the translation unit whose text is being tokenized.
2169fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2170fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Range the source range in which text should be tokenized. All of the
2171fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * tokens produced by tokenization will fall within this source range,
2172fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2173fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Tokens this pointer will be set to point to the array of tokens
2174fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * that occur within the given source range. The returned pointer must be
2175fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * freed with clang_disposeTokens() before the translation unit is destroyed.
2176fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2177fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param NumTokens will be set to the number of tokens in the \c *Tokens
2178fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * array.
2179fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2180fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2181fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
2182fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                   CXToken **Tokens, unsigned *NumTokens);
2183896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2184fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2185fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Annotate the given set of tokens by providing cursors for each token
2186fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * that can be mapped to a specific entity within the abstract syntax tree.
2187fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
21880045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * This token-annotation routine is equivalent to invoking
21890045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * clang_getCursor() for the source locations of each of the
21900045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * tokens. The cursors provided are filtered, so that only those
21910045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * cursors that have a direct correspondence to the token are
21920045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * accepted. For example, given a function call \c f(x),
21930045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * clang_getCursor() would provide the following cursors:
21940045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *
21950045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
21960045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
21970045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
21980045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *
21990045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * Only the first and last of these cursors will occur within the
22000045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * annotate, since the tokens "f" and "x' directly refer to a function
22010045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * and a variable, respectively, but the parentheses are just a small
22020045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * part of the full syntax of the function call expression, which is
22030045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * not provided as an annotation.
2204fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2205fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param TU the translation unit that owns the given tokens.
2206fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2207fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Tokens the set of tokens to annotate.
2208fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2209fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param NumTokens the number of tokens in \p Tokens.
2210fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
2211fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Cursors an array of \p NumTokens cursors, whose contents will be
2212fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * replaced with the cursors corresponding to each token.
2213fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2214fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
2215fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                         CXToken *Tokens, unsigned NumTokens,
2216fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                         CXCursor *Cursors);
2217896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2218fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2219fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Free the given set of tokens.
2220fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2221896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
2222fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                        CXToken *Tokens, unsigned NumTokens);
2223896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2224fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2225fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * @}
2226fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
2227896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2228fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
2229c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_DEBUG Debugging facilities
2230c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
2231c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * These routines are used for testing and debugging, only, and should not
2232c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * be relied upon.
2233c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
2234c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
2235c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
22361efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
22374ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff/* for debug/testing */
2238e68fff6fc083c6270d835216a3de0b82c6ef0310Ted KremenekCINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
22391efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
22401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar                                          const char **startBuf,
22414ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          const char **endBuf,
22424ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          unsigned *startLine,
22434ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          unsigned *startColumn,
22444ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          unsigned *endLine,
22454ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          unsigned *endColumn);
22460a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE void clang_enableStackTraces(void);
2247995aaf9c8f0131bef0215a9a0bc794b83a49e0b7Daniel DunbarCINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
2248995aaf9c8f0131bef0215a9a0bc794b83a49e0b7Daniel Dunbar                                          unsigned stack_size);
2249995aaf9c8f0131bef0215a9a0bc794b83a49e0b7Daniel Dunbar
22500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
2251c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
2252c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
22531efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2254c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
2255c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CODE_COMPLET Code completion
2256c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
2257c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Code completion involves taking an (incomplete) source file, along with
2258c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * knowledge of where the user is actively editing that file, and suggesting
2259c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * syntactically- and semantically-valid constructs that the user might want to
2260c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * use at that particular point in the source code. These data structures and
2261c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * routines provide support for code completion.
2262c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
2263c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
2264c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
22651efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2266c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
22670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A semantic string that describes a code-completion result.
22680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
22690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A semantic string that describes the formatting of a code-completion
22700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * result as a single "template" of text that should be inserted into the
22710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * source buffer when a particular code-completion result is selected.
22720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Each semantic string is made up of some number of "chunks", each of which
22730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * contains some text along with a description of what that text means, e.g.,
22740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the name of the entity being referenced, whether the text chunk is part of
22750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the template, or whether it is a "placeholder" that the user should replace
22760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
22771efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * description of the different kinds of chunks.
22780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
22790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef void *CXCompletionString;
22801efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
22810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
22820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A single result of code completion.
22830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
22840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef struct {
22850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
22861efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * \brief The kind of entity that this completion refers to.
22870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
22881efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * The cursor kind will be a macro, keyword, or a declaration (one of the
22890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * *Decl cursor kinds), describing the entity that the completion is
22900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * referring to.
22910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
22920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \todo In the future, we would like to provide a full cursor, to allow
22930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * the client to extract additional information from declaration.
22940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
22950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  enum CXCursorKind CursorKind;
22961efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
22971efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
22980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief The code-completion string that describes how to insert this
22990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * code-completion result into the editing buffer.
23000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
23010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionString CompletionString;
23020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor} CXCompletionResult;
23030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor
23040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
23050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Describes a single piece of text within a code-completion string.
23060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
23071efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * Each "chunk" within a code-completion string (\c CXCompletionString) is
23081efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * either a piece of text with a specific "kind" that describes how that text
23090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * should be interpreted by the client or is another completion string.
23100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
23110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorenum CXCompletionChunkKind {
23120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
23130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A code-completion string that describes "optional" text that
23140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * could be a part of the template (but is not required).
23150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * The Optional chunk is the only kind of chunk that has a code-completion
23171efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * string for its representation, which is accessible via
23180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \c clang_getCompletionChunkCompletionString(). The code-completion string
23190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * describes an additional part of the template that is completely optional.
23200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * For example, optional chunks can be used to describe the placeholders for
23210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * arguments that match up with defaulted function parameters, e.g. given:
23220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \code
23240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * void f(int x, float y = 3.14, double z = 2.71828);
23250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \endcode
23260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * The code-completion string for this function would contain:
23280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - a TypedText chunk for "f".
23290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - a LeftParen chunk for "(".
23300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - a Placeholder chunk for "int x"
23310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
23320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *       - a Comma chunk for ","
233371570182471d502a97f7f175aa527152544c75f2Daniel Dunbar   *       - a Placeholder chunk for "float y"
23340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *       - an Optional chunk containing the last defaulted argument:
23350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *           - a Comma chunk for ","
23360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *           - a Placeholder chunk for "double z"
23370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - a RightParen chunk for ")"
23380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
233971570182471d502a97f7f175aa527152544c75f2Daniel Dunbar   * There are many ways to handle Optional chunks. Two simple approaches are:
23400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - Completely ignore optional chunks, in which case the template for the
23410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *     function "f" would only include the first parameter ("int x").
23420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - Fully expand all optional chunks, in which case the template for the
23430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *     function "f" would have all of the parameters.
23440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
23450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_Optional,
23460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
23470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Text that a user would be expected to type to get this
23481efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * code-completion result.
23490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23501efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * There will be exactly one "typed text" chunk in a semantic string, which
23511efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * will typically provide the spelling of a keyword or the name of a
23520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * declaration that could be used at the current code point. Clients are
23530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * expected to filter the code-completion results based on the text in this
23540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * chunk.
23550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
23560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_TypedText,
23570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
23580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Text that should be inserted as part of a code-completion result.
23590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * A "text" chunk represents text that is part of the template to be
23610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * inserted into user code should this particular code-completion result
23620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * be selected.
23630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
23640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_Text,
23650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
23660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Placeholder text that should be replaced by the user.
23670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * A "placeholder" chunk marks a place where the user should insert text
23690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * into the code-completion template. For example, placeholders might mark
23700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * the function parameters for a function declaration, to indicate that the
23710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * user should provide arguments for each of those parameters. The actual
23720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * text in a placeholder is a suggestion for the text to display before
23730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * the user replaces the placeholder with real code.
23740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
23750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_Placeholder,
23760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
23770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Informative text that should be displayed but never inserted as
23780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * part of the template.
23791efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   *
23800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * An "informative" chunk contains annotations that can be displayed to
23810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * help the user decide whether a particular code-completion result is the
23820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * right option, but which is not part of the actual template to be inserted
23830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * by code completion.
23840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
23850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_Informative,
23860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
23870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Text that describes the current parameter when code-completion is
23880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * referring to function call, message send, or template specialization.
23890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * A "current parameter" chunk occurs when code-completion is providing
23910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * information about a parameter corresponding to the argument at the
23920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * code-completion point. For example, given a function
23930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \code
23950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * int add(int x, int y);
23960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \endcode
23970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
23980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * and the source code \c add(, where the code-completion point is after the
23990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * "(", the code-completion string will contain a "current parameter" chunk
24000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * for "int x", indicating that the current argument will initialize that
24010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * parameter. After typing further, to \c add(17, (where the code-completion
24021efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * point is after the ","), the code-completion string will contain a
24030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * "current paremeter" chunk to "int y".
24040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_CurrentParameter,
24060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A left parenthesis ('('), used to initiate a function call or
24080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * signal the beginning of a function parameter list.
24090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_LeftParen,
24110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A right parenthesis (')'), used to finish a function call or
24130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * signal the end of a function parameter list.
24140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_RightParen,
24160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A left bracket ('[').
24180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_LeftBracket,
24200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A right bracket (']').
24220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_RightBracket,
24240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A left brace ('{').
24260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_LeftBrace,
24280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A right brace ('}').
24300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_RightBrace,
24320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A left angle bracket ('<').
24340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_LeftAngle,
24360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A right angle bracket ('>').
24380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
24390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_RightAngle,
24400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
24410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A comma separator (',').
24420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
2443ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor  CXCompletionChunk_Comma,
2444ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor  /**
24451efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * \brief Text that specifies the result type of a given result.
2446ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor   *
2447ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor   * This special kind of informative chunk is not meant to be inserted into
24481efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * the text buffer. Rather, it is meant to illustrate the type that an
2449ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor   * expression using the given completion string would have.
2450ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor   */
245101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_ResultType,
245201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
245301dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * \brief A colon (':').
245401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
245501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_Colon,
245601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
245701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * \brief A semicolon (';').
245801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
245901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_SemiColon,
246001dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
246101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * \brief An '=' sign.
246201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
246301dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_Equal,
246401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
246501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * Horizontal space (' ').
246601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
246701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_HorizontalSpace,
246801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
246901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * Vertical space ('\n'), after which it is generally a good idea to
247001dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * perform indentation.
247101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
247201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_VerticalSpace
24730c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor};
24741efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
24750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
24760c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Determine the kind of a particular chunk within a completion string.
24770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
24780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query.
24790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
24800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string.
24810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
24820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the kind of the chunk at the index \c chunk_number.
24830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
24841efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE enum CXCompletionChunkKind
24850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkKind(CXCompletionString completion_string,
24860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor                             unsigned chunk_number);
24871efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
24880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
24891efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve the text associated with a particular chunk within a
24900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * completion string.
24910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
24920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query.
24930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
24940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string.
24950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
24960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the text associated with the chunk at index \c chunk_number.
24970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
24982ef6f8f5a35a60870594c5b04e0aa2bf22c6886fTed KremenekCINDEX_LINKAGE CXString
24990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkText(CXCompletionString completion_string,
25000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor                             unsigned chunk_number);
25010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor
25020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
25031efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve the completion string associated with a particular chunk
25040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * within a completion string.
25050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
25060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query.
25070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
25080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string.
25090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
25100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the completion string associated with the chunk at index
25110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \c chunk_number, or NULL if that chunk is not represented by a completion
25120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * string.
25130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
25140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE CXCompletionString
25150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkCompletionString(CXCompletionString completion_string,
25160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor                                         unsigned chunk_number);
25171efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
25180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
25190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Retrieve the number of chunks in the given code-completion string.
25200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
25210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE unsigned
25220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getNumCompletionChunks(CXCompletionString completion_string);
25230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor
25240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
252512e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \brief Determine the priority of this code completion.
252612e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor *
252712e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * The priority of a code completion indicates how likely it is that this
252812e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * particular completion is the completion that the user will select. The
252912e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * priority is selected by various internal heuristics.
253012e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor *
253112e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \param completion_string The completion string to query.
253212e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor *
253312e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \returns The priority of this completion string. Smaller values indicate
253412e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * higher-priority (more likely) completions.
253512e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor */
253612e131385e892e3723483a1081a89bcad29c8a84Douglas GregorCINDEX_LINKAGE unsigned
253712e131385e892e3723483a1081a89bcad29c8a84Douglas Gregorclang_getCompletionPriority(CXCompletionString completion_string);
253812e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor
253912e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor/**
254058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \brief Determine the availability of the entity that this code-completion
254158ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * string refers to.
254258ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor *
254358ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \param completion_string The completion string to query.
254458ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor *
254558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \returns The availability of the completion string.
254658ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor */
254758ddb60f409125eda5436c4a1f070f7fa4744295Douglas GregorCINDEX_LINKAGE enum CXAvailabilityKind
254858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorclang_getCompletionAvailability(CXCompletionString completion_string);
254958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor
255058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor/**
2551ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief Contains the results of code-completion.
2552ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor *
2553ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * This data structure contains the results of code completion, as
2554e0cc52ef8afc8d1cba9c534191b5f0ddaff1d694Douglas Gregor * produced by \c clang_codeCompleteAt(). Its contents must be freed by
2555ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \c clang_disposeCodeCompleteResults.
2556ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */
2557ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregortypedef struct {
2558ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor  /**
2559ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   * \brief The code-completion results.
2560ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   */
2561ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor  CXCompletionResult *Results;
2562ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor
2563ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor  /**
2564ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   * \brief The number of code-completion results stored in the
2565ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   * \c Results array.
2566ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   */
2567ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor  unsigned NumResults;
2568ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor} CXCodeCompleteResults;
2569ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor
2570ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor/**
2571cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \brief Flags that can be passed to \c clang_codeCompleteAt() to
2572cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * modify its behavior.
2573cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor *
2574cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * The enumerators in this enumeration can be bitwise-OR'd together to
2575cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * provide multiple options to \c clang_codeCompleteAt().
2576cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor */
2577cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregorenum CXCodeComplete_Flags {
2578cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor  /**
2579cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   * \brief Whether to include macros within the set of code
2580cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   * completions returned.
2581cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   */
2582cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor  CXCodeComplete_IncludeMacros = 0x01,
2583cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor
2584cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor  /**
2585cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   * \brief Whether to include code patterns for language constructs
2586cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   * within the set of code completions, e.g., for loops.
2587cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   */
2588cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor  CXCodeComplete_IncludeCodePatterns = 0x02
2589cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor};
2590cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor
2591cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor/**
2592cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \brief Returns a default set of code-completion options that can be
2593cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * passed to\c clang_codeCompleteAt().
2594cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor */
2595cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas GregorCINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
2596cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor
2597cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor/**
25981abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \brief Perform code completion at a given location in a translation unit.
25991abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
26001abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * This function performs code completion at a particular file, line, and
26011abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * column within source code, providing results that suggest potential
26021abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * code snippets based on the context of the completion. The basic model
26031abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * for code completion is that Clang will parse a complete source file,
26041abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * performing syntax checking up to the location where code-completion has
26051abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * been requested. At that point, a special code-completion token is passed
26061abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * to the parser, which recognizes this token and determines, based on the
26071abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * current location in the C/Objective-C/C++ grammar and the state of
26081abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * semantic analysis, what completions to provide. These completions are
26091abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * returned via a new \c CXCodeCompleteResults structure.
26101abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
26111abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * Code completion itself is meant to be triggered by the client when the
26121abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * user types punctuation characters or whitespace, at which point the
26131abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * code-completion location will coincide with the cursor. For example, if \c p
26141abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * is a pointer, code-completion might be triggered after the "-" and then
26151abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * after the ">" in \c p->. When the code-completion location is afer the ">",
26161abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the completion results will provide, e.g., the members of the struct that
26171abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * "p" points to. The client is responsible for placing the cursor at the
26181abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * beginning of the token currently being typed, then filtering the results
26191abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * based on the contents of the token. For example, when code-completing for
26201abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the expression \c p->get, the client should provide the location just after
26211abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
26221abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * client can filter the results based on the current token text ("get"), only
26231abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * showing those results that start with "get". The intent of this interface
26241abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * is to separate the relatively high-latency acquisition of code-completion
26251abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * results from the filtering of results on a per-character basis, which must
26261abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * have a lower latency.
26271abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
26281abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param TU The translation unit in which code-completion should
26291abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * occur. The source files for this translation unit need not be
26301abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completely up-to-date (and the contents of those source files may
26311abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * be overridden via \p unsaved_files). Cursors referring into the
26321abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * translation unit may be invalidated by this invocation.
26331abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
26341abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_filename The name of the source file where code
26351abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completion should be performed. This filename may be any file
26361abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * included in the translation unit.
26371abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
26381abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_line The line at which code-completion should occur.
26391abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
26401abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_column The column at which code-completion should occur.
26411abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * Note that the column should point just after the syntactic construct that
26421abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * initiated code completion, and not in the middle of a lexical token.
26431abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
26441abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param unsaved_files the Tiles that have not yet been saved to disk
26451abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * but may be required for parsing or code completion, including the
26461abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * contents of those files.  The contents and name of these files (as
26471abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * specified by CXUnsavedFile) are copied when necessary, so the
26481abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * client only needs to guarantee their validity until the call to
26491abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * this function returns.
26501abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
26511abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param num_unsaved_files The number of unsaved file entries in \p
26521abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * unsaved_files.
26531abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
2654cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \param options Extra options that control the behavior of code
2655cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * completion, expressed as a bitwise OR of the enumerators of the
2656cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * CXCodeComplete_Flags enumeration. The
2657cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \c clang_defaultCodeCompleteOptions() function returns a default set
2658cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * of code-completion options.
2659cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor *
26601abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \returns If successful, a new \c CXCodeCompleteResults structure
26611abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * containing code-completion results, which should eventually be
26621abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * freed with \c clang_disposeCodeCompleteResults(). If code
26631abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completion fails, returns NULL.
26641abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor */
26651abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas GregorCINDEX_LINKAGE
26661abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas GregorCXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
26671abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor                                            const char *complete_filename,
26681abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor                                            unsigned complete_line,
26691abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor                                            unsigned complete_column,
26701abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor                                            struct CXUnsavedFile *unsaved_files,
2671cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor                                            unsigned num_unsaved_files,
2672cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor                                            unsigned options);
26731abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor
26741abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor/**
26751e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \brief Sort the code-completion results in case-insensitive alphabetical
26761e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * order.
26771e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor *
26781e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \param Results The set of results to sort.
26791e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \param NumResults The number of results in \p Results.
26801e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor */
26811e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas GregorCINDEX_LINKAGE
26821e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregorvoid clang_sortCodeCompletionResults(CXCompletionResult *Results,
26831e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor                                     unsigned NumResults);
26841e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor
26851e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor/**
2686ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief Free the given set of code-completion results.
26870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
26881efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE
2689ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregorvoid clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
269058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor
269120d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor/**
2692a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Determine the number of diagnostics produced prior to the
2693a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * location where code completion was performed.
2694a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */
2695896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE
2696a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregorunsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
2697a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor
2698a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/**
2699a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Retrieve a diagnostic associated with the given code completion.
2700a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor *
2701a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Result the code completion results to query.
2702a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Index the zero-based diagnostic number to retrieve.
2703a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor *
2704a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \returns the requested diagnostic. This diagnostic must be freed
2705a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * via a call to \c clang_disposeDiagnostic().
2706a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */
2707896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE
2708a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
2709a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                             unsigned Index);
2710a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor
2711a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/**
271220d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * @}
271320d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor */
27141efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
27151efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
271604bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek/**
271704bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * \defgroup CINDEX_MISC Miscellaneous utility functions
271804bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek *
271904bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * @{
272004bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek */
272123e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek
272223e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek/**
272323e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek * \brief Return a version string, suitable for showing to a user, but not
272423e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek *        intended to be parsed (the format is not guaranteed to be stable).
272523e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek */
2726a2a9d6e4e5b6001b86b7dfc5db1ea296ce29a3d3Ted KremenekCINDEX_LINKAGE CXString clang_getClangVersion();
272704bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek
272816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek /**
2729896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek  * \brief Visitor invoked for each file in a translation unit
273016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  *        (used with clang_getInclusions()).
273116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  *
273216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * This visitor function will be invoked by clang_getInclusions() for each
273316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * file included (either at the top-level or by #include directives) within
273416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * a translation unit.  The first argument is the file being included, and
273516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * the second and third arguments provide the inclusion stack.  The
273616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * array is sorted in order of immediate inclusion.  For example,
273716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * the first element refers to the location that included 'included_file'.
273816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  */
273916b55a71695a33c094383295cc7b7a2080e098daTed Kremenektypedef void (*CXInclusionVisitor)(CXFile included_file,
274016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                   CXSourceLocation* inclusion_stack,
274116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                   unsigned include_len,
274216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                   CXClientData client_data);
274316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek
274416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek/**
274516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * \brief Visit the set of preprocessor inclusions in a translation unit.
274616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek *   The visitor function is called with the provided data for every included
274716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek *   file.  This does not include headers included by the PCH file (unless one
274816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek *   is inspecting the inclusions in the PCH file itself).
274916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek */
275016b55a71695a33c094383295cc7b7a2080e098daTed KremenekCINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
275116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                        CXInclusionVisitor visitor,
275216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                        CXClientData client_data);
275316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek
275416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek/**
275504bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * @}
275604bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek */
27571efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2758c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
2759c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
2760c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
27611efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2762d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus
2763d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek}
2764d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif
2765d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif
2766d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek
2767