Index.h revision 39d6f07b056c31e1e6b5946165ed4b23e7887f22
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 */
6650398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Narofftypedef void *CXTranslationUnit;  /* A translation unit instance. */
67600866cc7d6d9ec2e27d4b6d6ec461f6463b5ab6Steve Naroff
687f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
69c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Opaque pointer representing client data that will be passed through
70c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to various callbacks and visitors.
717f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
72c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregortypedef void *CXClientData;
731efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
74735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor/**
75735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \brief Provides the contents of a file that has not yet been saved to disk.
76735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor *
77735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * Each CXUnsavedFile instance provides the name of a file on the
78735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * system along with the current contents of that file that have not
79735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * yet been saved to disk.
80735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor */
81735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregorstruct CXUnsavedFile {
821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
831efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * \brief The file whose contents have not yet been saved.
84735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   *
85735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   * This file must already exist in the file system.
86735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   */
87735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor  const char *Filename;
88735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor
891efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
90c8dfe5ece04e683106eb96c58a2999f70b53ac21Douglas Gregor   * \brief A buffer containing the unsaved contents of this file.
91735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   */
92735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor  const char *Contents;
93735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor
94735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor  /**
95c8dfe5ece04e683106eb96c58a2999f70b53ac21Douglas Gregor   * \brief The length of the unsaved contents of this buffer.
96735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor   */
97735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor  unsigned long Length;
98735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor};
99735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor
100076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne/**
101076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * \brief Describes the availability of a particular entity, which indicates
102076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * whether the use of this entity will result in a warning or error due to
103076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne * it being deprecated or unavailable.
104076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne */
10558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorenum CXAvailabilityKind {
106076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne  /**
107076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   * \brief The entity is available.
108076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   */
10958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor  CXAvailability_Available,
110076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne  /**
111076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   * \brief The entity is available, but has been deprecated (and its use is
112076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   * not recommended).
113076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   */
11458ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor  CXAvailability_Deprecated,
115076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne  /**
116076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   * \brief The entity is not available; any use of it will be an error.
117076c22a99ed82e11b59e8fbf57d8467ceb3fec77Peter Collingbourne   */
11858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor  CXAvailability_NotAvailable
11958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor};
12058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor
1217f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1227f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \defgroup CINDEX_STRING String manipulation routines
1237f17376e0931a337d544b75d9030bc92763be287Douglas Gregor *
1247f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * @{
1257f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
1261efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1277f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1287f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief A character string.
1297f17376e0931a337d544b75d9030bc92763be287Douglas Gregor *
1307f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * The \c CXString type is used to return strings from the interface when
1317f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * the ownership of that string might different from one call to the next.
1327f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * Use \c clang_getCString() to retrieve the string data and, once finished
1337f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * with the string data, call \c clang_disposeString() to free the string.
134ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff */
135ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Narofftypedef struct {
136ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff  const char *Spelling;
137ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff  /* A 1 value indicates the clang_ indexing API needed to allocate the string
138ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff     (and it must be freed by clang_disposeString()). */
139ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff  int MustFreeString;
140ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff} CXString;
141ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff
1427f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1437f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief Retrieve the character data associated with the given string.
1447f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
145ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE const char *clang_getCString(CXString string);
146ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff
1477f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1487f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * \brief Free the given string,
1497f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
150ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve NaroffCINDEX_LINKAGE void clang_disposeString(CXString string);
151ef0cef6cec8de5fc60e469a93436eed7212e0dc2Steve Naroff
1527f17376e0931a337d544b75d9030bc92763be287Douglas Gregor/**
1537f17376e0931a337d544b75d9030bc92763be287Douglas Gregor * @}
1547f17376e0931a337d544b75d9030bc92763be287Douglas Gregor */
1551efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/**
157e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * \brief clang_createIndex() provides a shared context for creating
158e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * translation units. It provides two options:
159e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff *
160e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
161e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * declarations (when loading any new translation units). A "local" declaration
1621efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * is one that belongs in the translation unit itself and not in a precompiled
163e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * header that was used by the translation unit. If zero, all declarations
164e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff * will be enumerated.
165e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff *
166b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * Here is an example:
167b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
1680a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *   // excludeDeclsFromPCH = 1, displayDiagnostics=1
1690a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *   Idx = clang_createIndex(1, 1);
170b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
171b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // IndexTest.pch was produced with the following command:
172b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
173b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
174b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
175b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // This will load all the symbols from 'IndexTest.pch'
1761efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
177002a528ab0189fc60cfbf9328962c96ccbe567eeDouglas Gregor *                       TranslationUnitVisitor, 0);
178b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   clang_disposeTranslationUnit(TU);
179b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
180b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // This will load all the symbols from 'IndexTest.c', excluding symbols
181b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   // from 'IndexTest.pch'.
182fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar *   char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
183fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar *   TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
184fd9f23464bfd35314c87c4df410f3937d59eb96dDaniel Dunbar *                                                  0, 0);
185b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor *   clang_visitChildren(clang_getTranslationUnitCursor(TU),
186b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor *                       TranslationUnitVisitor, 0);
187b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *   clang_disposeTranslationUnit(TU);
188b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff *
189b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * This process of creating the 'pch', loading it separately, and using it (via
190b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
191b4ece6377d95e35a8df01cd010d910c34d690f67Steve Naroff * (which gives the indexer the same performance benefit as the compiler).
192e56b4baeba5097852e04bc41ca2e0396cf729955Steve Naroff */
1930a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
1940a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor                                         int displayDiagnostics);
195896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1960087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor/**
1970087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * \brief Destroy the given index.
1980087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor *
1990087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * The index must not be destroyed until all of the translation units created
2000087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor * within that index have been destroyed.
2010087e1a12b67b6bb032a72ea485a863daeccf55bDouglas Gregor */
2028506dde586459887b7e14e23a30af8ac5be5adb6Daniel DunbarCINDEX_LINKAGE void clang_disposeIndex(CXIndex index);
2031efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2041efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/**
2051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Request that AST's be generated externally for API calls which parse
2068506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * source code on the fly, e.g. \see createTranslationUnitFromSourceFile.
2078506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar *
2088506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * Note: This is for debugging purposes only, and may be removed at a later
2098506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * date.
2108506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar *
2118506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * \param index - The index to update.
2128506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * \param value - The new flag value.
2138506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar */
2148506dde586459887b7e14e23a30af8ac5be5adb6Daniel DunbarCINDEX_LINKAGE void clang_setUseExternalASTGeneration(CXIndex index,
2158506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar                                                      int value);
216f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
217c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_FILES File manipulation routines
218f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor *
219f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @{
220f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
2211efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
222f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
223f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief A particular source file that is part of a translation unit.
224f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
225f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregortypedef void *CXFile;
2261efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
227f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor
228f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
229f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief Retrieve the complete file and path name of the given file.
23088145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff */
23174844072411bae91d5dbb89955d200cbe1e0a1c8Ted KremenekCINDEX_LINKAGE CXString clang_getFileName(CXFile SFile);
2321efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
233f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
234f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \brief Retrieve the last modification time of the given file.
235f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
23608b0e8daeb683686b876d72674962ad96df21d45Douglas GregorCINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
23788145034694ed5267fa6fa5febc54fadc02bd479Steve Naroff
2383c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor/**
239b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a file handle within the given translation unit.
240b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
241b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \param tu the translation unit
2421efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar *
243b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \param file_name the name of the file.
244b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
245b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns the file handle for the named file in the translation unit \p tu,
246b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * or a NULL file handle if the file was not a part of this translation unit.
247b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
2481efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
249b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                    const char *file_name);
2501efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
251b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
252f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @}
253f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
254f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor
255f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
256f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * \defgroup CINDEX_LOCATIONS Physical source locations
257f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor *
258f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * Clang represents physical source locations in its abstract syntax tree in
259f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * great detail, with file, line, and column information for the majority of
260f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * the tokens parsed in the source code. These data types and functions are
261f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * used to represent source location information, either for a particular
262f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * point in the program or for a range of points in the program, and extract
263f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * specific location information from those data types.
264f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor *
265f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @{
266f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
2671efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
268f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
2691db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * \brief Identifies a specific source location within a translation
2701db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * unit.
2711db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
2721db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * Use clang_getInstantiationLocation() to map a source location to a
2731db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * particular file, line, and column.
2743c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor */
2753c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregortypedef struct {
2765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  void *ptr_data[2];
2771db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor  unsigned int_data;
2783c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor} CXSourceLocation;
279fe6fd3d41a7f48317d6856c9327b6cead32c3498Ted Kremenek
2803c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor/**
281d52864bd33c66aacc84133460d8c9c0dfcdd5c18Daniel Dunbar * \brief Identifies a half-open character range in the source code.
2823c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor *
2831db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
2841db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * starting and end locations from a source range, respectively.
2853c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor */
2863c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregortypedef struct {
2875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  void *ptr_data[2];
2881db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor  unsigned begin_int_data;
2891db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor  unsigned end_int_data;
2903c7313d96cd4a18cd8c1fcd3ddd8128c2fcbe58fDouglas Gregor} CXSourceRange;
291fe6fd3d41a7f48317d6856c9327b6cead32c3498Ted Kremenek
2921db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor/**
293b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a NULL (invalid) source location.
294b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
295b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getNullLocation();
2961efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
297b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
298b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \determine Determine whether two source locations, which must refer into
2991efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * the same translation unit, refer to exactly the same point in the source
300b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * code.
301b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
302b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns non-zero if the source locations refer to the same location, zero
303b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * if they refer to different locations.
304b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
305b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
306b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                             CXSourceLocation loc2);
3071efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
308b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
3091efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieves the source location associated with a given file/line/column
3101efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * in a particular translation unit.
311b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
312b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
313b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                                  CXFile file,
314b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                                  unsigned line,
315b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                                  unsigned column);
3161efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
317b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
3185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve a NULL (invalid) source range.
3195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
3205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getNullRange();
321896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
3225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
323b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Retrieve a source range given the beginning and ending source
324b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * locations.
325b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor */
326b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin,
327b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor                                            CXSourceLocation end);
3281efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
329b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor/**
33046766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * \brief Retrieve the file, line, column, and offset represented by
33146766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * the given source location.
3321db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
3331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param location the location within a source file that will be decomposed
3341efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * into its parts.
3351db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
3361efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param file [out] if non-NULL, will be set to the file to which the given
3371db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * source location points.
3381db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
3391efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param line [out] if non-NULL, will be set to the line to which the given
3401db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor * source location points.
3411db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor *
3421efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param column [out] if non-NULL, will be set to the column to which the given
3431efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source location points.
34446766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor *
34546766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * \param offset [out] if non-NULL, will be set to the offset into the
34646766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor * buffer to which the given source location points.
3471db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */
3481db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
3491db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor                                                   CXFile *file,
3501db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor                                                   unsigned *line,
35146766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor                                                   unsigned *column,
35246766dc31c09d89024de5aba9e22112a56eadbdfDouglas Gregor                                                   unsigned *offset);
353e69517ce61638f12c9abe4605753a45275ac4e37Douglas Gregor
354e69517ce61638f12c9abe4605753a45275ac4e37Douglas Gregor/**
3551efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve a source location representing the first character within a
3561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source range.
3571db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */
3581db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range);
3591db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor
3601db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor/**
3611efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve a source location representing the last character within a
3621efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source range.
3631db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor */
3641db19dea8d221f27be46332d668d1e2decb7f1abDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range);
3651db19dea8d221f27be46332d668d1e2decb7f1abDouglas Gregor
366f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor/**
367f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor * @}
368f55254472e496340cbb4f0a24cff398e441475b5Douglas Gregor */
369c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
370c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
3715352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \defgroup CINDEX_DIAG Diagnostic reporting
3725352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
3735352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @{
3745352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
3755352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
3765352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
3775352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Describes the severity of a particular diagnostic.
3785352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
3795352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorenum CXDiagnosticSeverity {
3805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
381896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek   * \brief A diagnostic that has been suppressed, e.g., by a command-line
3825352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * option.
3835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
3845352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Ignored = 0,
385896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
3865352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
3875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * \brief This diagnostic is a note that should be attached to the
3885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * previous (non-note) diagnostic.
3895352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
3905352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Note    = 1,
3915352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
3925352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
3935352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * \brief This diagnostic indicates suspicious code that may not be
3945352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * wrong.
3955352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
3965352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Warning = 2,
3975352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
3985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
3995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * \brief This diagnostic indicates that the code is ill-formed.
4005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
4015352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Error   = 3,
4025352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4035352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  /**
4045352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * \brief This diagnostic indicates that the code is ill-formed such
4055352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * that future parser recovery is unlikely to produce useful
4065352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   * results.
4075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor   */
4085352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor  CXDiagnostic_Fatal   = 4
4095352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor};
4105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4115352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
4125352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief A single diagnostic, containing the diagnostic's severity,
4135352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * location, text, source ranges, and fix-it hints.
4145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
4155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregortypedef void *CXDiagnostic;
4165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
418a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Determine the number of diagnostics produced for the given
419a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * translation unit.
420a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */
421a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit);
422a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor
423a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/**
424a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Retrieve a diagnostic associated with the given translation unit.
4255352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
426a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Unit the translation unit to query.
427a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Index the zero-based diagnostic number to retrieve.
4285352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
429a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \returns the requested diagnostic. This diagnostic must be freed
430a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * via a call to \c clang_disposeDiagnostic().
4315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
432a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
433a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                                unsigned Index);
434a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor
435a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/**
436a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Destroy a diagnostic.
437a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */
438a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic);
4395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
4405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
4410a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Options to control the display of diagnostics.
4420a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
4430a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * The values in this enum are meant to be combined to customize the
4440a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * behavior of \c clang_displayDiagnostic().
4450a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */
4460a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregorenum CXDiagnosticDisplayOptions {
4470a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  /**
4480a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \brief Display the source-location information where the
4490a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * diagnostic was located.
4500a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
4510a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * When set, diagnostics will be prefixed by the file, line, and
4520a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * (optionally) column to which the diagnostic refers. For example,
4530a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
4540a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \code
4550a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * test.c:28: warning: extra tokens at end of #endif directive
4560a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \endcode
4570a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
4580a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * This option corresponds to the clang flag \c -fshow-source-location.
4590a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   */
4600a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  CXDiagnostic_DisplaySourceLocation = 0x01,
4610a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
4620a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  /**
4630a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \brief If displaying the source-location information of the
4640a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * diagnostic, also include the column number.
4650a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
4660a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * This option corresponds to the clang flag \c -fshow-column.
4670a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   */
4680a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  CXDiagnostic_DisplayColumn = 0x02,
4690a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
4700a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  /**
4710a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \brief If displaying the source-location information of the
4720a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * diagnostic, also include information about source ranges in a
4730a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * machine-parsable format.
4740a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   *
475896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek   * This option corresponds to the clang flag
4760a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   * \c -fdiagnostics-print-source-range-info.
4770a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor   */
4780a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor  CXDiagnostic_DisplaySourceRanges = 0x04
4790a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor};
4800a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
4810a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/**
482274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * \brief Format the given diagnostic in a manner that is suitable for display.
4830a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
484274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * This routine will format the given diagnostic to a string, rendering
485896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * the diagnostic according to the various options given. The
486896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \c clang_defaultDiagnosticDisplayOptions() function returns the set of
4870a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * options that most closely mimics the behavior of the clang compiler.
4880a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
4890a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \param Diagnostic The diagnostic to print.
4900a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
491896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \param Options A set of options that control the diagnostic display,
4920a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * created by combining \c CXDiagnosticDisplayOptions values.
493274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor *
494274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor * \returns A new string containing for formatted diagnostic.
4950a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */
496274f1906f12ebf8fcc179701deeda6d3271120c1Douglas GregorCINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic,
497274f1906f12ebf8fcc179701deeda6d3271120c1Douglas Gregor                                               unsigned Options);
4980a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
4990a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/**
5000a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Retrieve the set of display options most similar to the
5010a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * default behavior of the clang compiler.
5020a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor *
5030a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \returns A set of display options suitable for use with \c
5040a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * clang_displayDiagnostic().
5050a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */
5060a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
5070a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
5080a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/**
5090a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor * \brief Print a diagnostic to the given file.
5100a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor */
5110a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor
5120a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas Gregor/**
5135352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Determine the severity of the given diagnostic.
5145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
515896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE enum CXDiagnosticSeverity
5165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getDiagnosticSeverity(CXDiagnostic);
5175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
5195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the source location of the given diagnostic.
5205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
5215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * This location is where Clang would print the caret ('^') when
5225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * displaying the diagnostic on the command line.
5235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
5245352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
5255352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5265352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
5275352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Retrieve the text of the given diagnostic.
5285352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
5295352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic);
530a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor
531a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor/**
532a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \brief Determine the number of source ranges associated with the given
533a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * diagnostic.
534a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor */
535a3890baf1256ff26081306c7fef70202f8223f41Douglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
536896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
5375352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
538a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \brief Retrieve a source range associated with the diagnostic.
5395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
540a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * A diagnostic's source ranges highlight important elements in the source
5415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * code. On the command line, Clang displays source ranges by
542896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * underlining them with '~' characters.
5435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
544a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \param Diagnostic the diagnostic whose range is being extracted.
5455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
546896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \param Range the zero-based index specifying which range to
5475352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
548a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor * \returns the requested source range.
5495352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
550896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
551a3890baf1256ff26081306c7fef70202f8223f41Douglas Gregor                                                      unsigned Range);
5525352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
5545352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Determine the number of fix-it hints associated with the
5555352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * given diagnostic.
5565352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
5575352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
5585352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5595352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
560473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \brief Retrieve the replacement information for a given fix-it.
5615352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
562473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * Fix-its are described in terms of a source range whose contents
563473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * should be replaced by a string. This approach generalizes over
564473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * three kinds of operations: removal of source code (the range covers
565473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * the code to be removed and the replacement string is empty),
566473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replacement of source code (the range covers the code to be
567473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced and the replacement string provides the new code), and
568473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insertion (both the start and end of the range point at the
569473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insertion location, and the replacement string provides the text to
570473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * insert).
5715352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
572473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param Diagnostic The diagnostic whose fix-its are being queried.
5735352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
574473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param FixIt The zero-based index of the fix-it.
5755352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
576473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \param ReplacementRange The source range whose contents will be
577473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced with the returned replacement string. Note that source
578473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * ranges are half-open ranges [a, b), so the source code should be
579473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * replaced from a and up to (but not including) b.
5805352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
581473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * \returns A string containing text that should be replace the source
582473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor * code indicated by the \c ReplacementRange.
5835352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
584896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
585473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor                                                 unsigned FixIt,
586473d7019bb54f8a2f0140dca9e9644a935cc6b20Douglas Gregor                                               CXSourceRange *ReplacementRange);
5875352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
5895352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @}
5905352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
5915352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
5925352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
5935352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation
5945352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
5955352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * The routines in this group provide the ability to create and destroy
5965352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * translation units from files, either by parsing the contents of the files or
5975352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * by reading in a serialized representation of a translation unit.
5985352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
5995352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @{
6005352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
601896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
6025352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
6035352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Get the original translation unit source file name.
6045352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
6055352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXString
6065352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregorclang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
6075352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
6085352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
6095352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Return the CXTranslationUnit for a given source file and the provided
6105352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * command line arguments one would pass to the compiler.
6115352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6125352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * Note: The 'source_filename' argument is optional.  If the caller provides a
6135352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * NULL pointer, the name of the source file is expected to reside in the
6145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * specified command line arguments.
6155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6165352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * Note: When encountered in 'clang_command_line_args', the following options
6175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * are ignored:
6185352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6195352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *   '-c'
6205352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *   '-emit-ast'
6215352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *   '-fsyntax-only'
6225352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *   '-o <output file>'  (both '-o' and '<output file>' are ignored)
6235352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6245352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6255352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param source_filename - The name of the source file to load, or NULL if the
6265352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * source file is included in clang_command_line_args.
6275352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6285352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p
6295352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * unsaved_files.
6305352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6315352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk
6325352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * but may be required for code completion, including the contents of
633c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * those files.  The contents and name of these files (as specified by
634c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * CXUnsavedFile) are copied when necessary, so the client only needs to
635c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * guarantee their validity until the call to this function returns.
6365352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6375352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param diag_callback callback function that will receive any diagnostics
6385352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * emitted while processing this source file. If NULL, diagnostics will be
6395352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * suppressed.
6405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor *
6415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \param diag_client_data client data that will be passed to the diagnostic
6425352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * callback function.
6435352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
6445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
6455352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         CXIndex CIdx,
6465352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         const char *source_filename,
6475352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         int num_clang_command_line_args,
6485352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         const char **clang_command_line_args,
6495352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor                                         unsigned num_unsaved_files,
650a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                         struct CXUnsavedFile *unsaved_files);
651896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
6525352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
6535352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Create a translation unit from an AST file (-emit-ast).
6545352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
655896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
656a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                             const char *ast_filename);
6575352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor
65844c181aec37789f25f6c15543c164416f72e562aDouglas Gregor/**
65944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * \brief Flags that control the creation of translation units.
66044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor *
66144c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * The enumerators in this enumeration type are meant to be bitwise
66244c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * ORed together to specify which options should be used when
66344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor * constructing the translation unit.
66444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor */
6655a43021ac491bf091494167127772a20d9a9bb48Douglas Gregorenum CXTranslationUnit_Flags {
6665a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor  /**
6675a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * \brief Used to indicate that no special translation-unit options are
6685a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * needed.
6695a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   */
6705a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor  CXTranslationUnit_None = 0x0,
6715a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor
6725a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor  /**
6735a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * \brief Used to indicate that the parser should construct a "detailed"
6745a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * preprocessing record, including all macro definitions and instantiations.
6755a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   *
6765a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * Constructing a detailed preprocessing record requires more memory
6775a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * and time to parse, since the information contained in the record
6785a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * is usually not retained. However, it can be useful for
6795a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * applications that require more detailed information about the
6805a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   * behavior of the preprocessor.
6815a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor   */
68244c181aec37789f25f6c15543c164416f72e562aDouglas Gregor  CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
68344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor
68444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor  /**
685b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * \brief Used to indicate that the translation unit is incomplete.
68644c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   *
687b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * When a translation unit is considered "incomplete", semantic
688b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * analysis that is typically performed at the end of the
689b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * translation unit will be suppressed. For example, this suppresses
690b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * the completion of tentative declarations in C and of
691b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * instantiation of implicitly-instantiation function templates in
692b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * C++. This option is typically used when parsing a header with the
693b1c031be513705d924038f497279b9b599868ba1Douglas Gregor   * intent of producing a precompiled header.
69444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   */
695b1c031be513705d924038f497279b9b599868ba1Douglas Gregor  CXTranslationUnit_Incomplete = 0x02,
69644c181aec37789f25f6c15543c164416f72e562aDouglas Gregor
69744c181aec37789f25f6c15543c164416f72e562aDouglas Gregor  /**
69844c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * \brief Used to indicate that the translation unit should be built with an
69944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * implicit precompiled header for the preamble.
70044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   *
70144c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * An implicit precompiled header is used as an optimization when a
70244c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * particular translation unit is likely to be reparsed many times
70344c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * when the sources aren't changing that often. In this case, an
70444c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * implicit precompiled header will be built containing all of the
70544c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * initial includes at the top of the main file (what we refer to as
70644c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * the "preamble" of the file). In subsequent parses, if the
70744c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * preamble or the files in it have not changed, \c
70844c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * clang_reparseTranslationUnit() will re-use the implicit
70944c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   * precompiled header to improve parsing performance.
71044c181aec37789f25f6c15543c164416f72e562aDouglas Gregor   */
711e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  CXTranslationUnit_PrecompiledPreamble = 0x04,
712e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor
713e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  /**
714e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * \brief Used to indicate that the translation unit should cache some
715e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * code-completion results with each reparse of the source file.
716e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   *
717e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * Caching of code-completion results is a performance optimization that
718e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * introduces some overhead to reparsing but improves the performance of
719e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * code-completion operations.
720e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   */
721e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  CXTranslationUnit_CacheCompletionResults = 0x08
7225a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor};
7235a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor
7245a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor/**
725b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * \brief Returns the set of flags that is suitable for parsing a translation
726b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * unit that is being edited.
727b1c031be513705d924038f497279b9b599868ba1Douglas Gregor *
728b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * The set of flags returned provide options for \c clang_parseTranslationUnit()
729b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * to indicate that the translation unit is likely to be reparsed many times,
730b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
731b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
732b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * set contains an unspecified set of optimizations (e.g., the precompiled
733b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * preamble) geared toward improving the performance of these routines. The
734b1c031be513705d924038f497279b9b599868ba1Douglas Gregor * set of optimizations enabled may change from one version to the next.
735b1c031be513705d924038f497279b9b599868ba1Douglas Gregor */
736e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas GregorCINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
737b1c031be513705d924038f497279b9b599868ba1Douglas Gregor
738b1c031be513705d924038f497279b9b599868ba1Douglas Gregor/**
7395a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \brief Parse the given source file and the translation unit corresponding
7405a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * to that file.
7415a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7425a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * This routine is the main entry point for the Clang C API, providing the
7435a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * ability to parse a source file into a translation unit that can then be
7445a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * queried by other functions in the API. This routine accepts a set of
7455a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * command-line arguments so that the compilation can be configured in the same
7465a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * way that the compiler is configured on the command line.
7475a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7485a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param CIdx The index object with which the translation unit will be
7495a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * associated.
7505a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7515a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param source_filename The name of the source file to load, or NULL if the
7525a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * source file is included in \p clang_command_line_args.
7535a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7545a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param command_line_args The command-line arguments that would be
7555a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * passed to the \c clang executable if it were being invoked out-of-process.
7565a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * These command-line options will be parsed and will affect how the translation
7575a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * unit is parsed. Note that the following options are ignored: '-c',
7585a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * '-emit-ast', '-fsyntex-only' (which is the default), and '-o <output file>'.
7595a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7605a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param num_command_line_args The number of command-line arguments in
7615a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \p command_line_args.
7625a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7635a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk
7641abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * but may be required for parsing, including the contents of
7655a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * those files.  The contents and name of these files (as specified by
7665a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * CXUnsavedFile) are copied when necessary, so the client only needs to
7675a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * guarantee their validity until the call to this function returns.
7685a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7695a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p
7705a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * unsaved_files.
7715a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7725a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \param options A bitmask of options that affects how the translation unit
7735a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * is managed but not its compilation. This should be a bitwise OR of the
7745a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * CXTranslationUnit_XXX flags.
7755a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor *
7765a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * \returns A new translation unit describing the parsed code and containing
7775a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * any diagnostics produced by the compiler. If there is a failure from which
7785a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor * the compiler cannot recover, returns NULL.
7795a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor */
7805a43021ac491bf091494167127772a20d9a9bb48Douglas GregorCINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
7815a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                    const char *source_filename,
7825a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                 const char **command_line_args,
7835a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                      int num_command_line_args,
7845a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                            struct CXUnsavedFile *unsaved_files,
7855a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                     unsigned num_unsaved_files,
7865a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor                                                            unsigned options);
7875a43021ac491bf091494167127772a20d9a9bb48Douglas Gregor
7885352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
7891999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \brief Flags that control how translation units are saved.
7901999844e7a18786e61e619e1dc6c789827541863Douglas Gregor *
7911999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * The enumerators in this enumeration type are meant to be bitwise
7921999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * ORed together to specify which options should be used when
7931999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * saving the translation unit.
7941999844e7a18786e61e619e1dc6c789827541863Douglas Gregor */
7951999844e7a18786e61e619e1dc6c789827541863Douglas Gregorenum CXSaveTranslationUnit_Flags {
7961999844e7a18786e61e619e1dc6c789827541863Douglas Gregor  /**
7971999844e7a18786e61e619e1dc6c789827541863Douglas Gregor   * \brief Used to indicate that no special saving options are needed.
7981999844e7a18786e61e619e1dc6c789827541863Douglas Gregor   */
7991999844e7a18786e61e619e1dc6c789827541863Douglas Gregor  CXSaveTranslationUnit_None = 0x0
8001999844e7a18786e61e619e1dc6c789827541863Douglas Gregor};
8011999844e7a18786e61e619e1dc6c789827541863Douglas Gregor
8021999844e7a18786e61e619e1dc6c789827541863Douglas Gregor/**
8031999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \brief Returns the set of flags that is suitable for saving a translation
8041999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * unit.
8051999844e7a18786e61e619e1dc6c789827541863Douglas Gregor *
8061999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * The set of flags returned provide options for
8071999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \c clang_saveTranslationUnit() by default. The returned flag
8081999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * set contains an unspecified set of options that save translation units with
8091999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * the most commonly-requested data.
8101999844e7a18786e61e619e1dc6c789827541863Douglas Gregor */
8111999844e7a18786e61e619e1dc6c789827541863Douglas GregorCINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
8121999844e7a18786e61e619e1dc6c789827541863Douglas Gregor
8131999844e7a18786e61e619e1dc6c789827541863Douglas Gregor/**
8147ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \brief Saves a translation unit into a serialized representation of
8157ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * that translation unit on disk.
8167ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor *
8177ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * Any translation unit that was parsed without error can be saved
8187ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * into a file. The translation unit can then be deserialized into a
8197ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * new \c CXTranslationUnit with \c clang_createTranslationUnit() or,
8207ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * if it is an incomplete translation unit that corresponds to a
8217ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * header, used as a precompiled header when parsing other translation
8227ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * units.
8237ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor *
8247ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \param TU The translation unit to save.
8251999844e7a18786e61e619e1dc6c789827541863Douglas Gregor *
8267ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \param FileName The file to which the translation unit will be saved.
8277ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor *
8281999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * \param options A bitmask of options that affects how the translation unit
8291999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * is saved. This should be a bitwise OR of the
8301999844e7a18786e61e619e1dc6c789827541863Douglas Gregor * CXSaveTranslationUnit_XXX flags.
8311999844e7a18786e61e619e1dc6c789827541863Douglas Gregor *
8327ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * \returns Zero if the translation unit was saved successfully, a
8337ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor * non-zero value otherwise.
8347ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor */
8357ae2faafd30524ef5f863bb3b8701977888839bbDouglas GregorCINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
8361999844e7a18786e61e619e1dc6c789827541863Douglas Gregor                                             const char *FileName,
8371999844e7a18786e61e619e1dc6c789827541863Douglas Gregor                                             unsigned options);
8387ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor
8397ae2faafd30524ef5f863bb3b8701977888839bbDouglas Gregor/**
8405352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * \brief Destroy the specified CXTranslationUnit object.
8415352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
8425352ac06d8f6194825bb2a99ffa009b61bafb503Douglas GregorCINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
843896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
8445352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
845e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \brief Flags that control the reparsing of translation units.
846e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor *
847e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The enumerators in this enumeration type are meant to be bitwise
848e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * ORed together to specify which options should be used when
849e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * reparsing the translation unit.
850e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor */
851e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregorenum CXReparse_Flags {
852e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  /**
853e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   * \brief Used to indicate that no special reparsing options are needed.
854e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor   */
855e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor  CXReparse_None = 0x0
856e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor};
857e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor
858e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor/**
859e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \brief Returns the set of flags that is suitable for reparsing a translation
860e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * unit.
861e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor *
862e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The set of flags returned provide options for
863e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \c clang_reparseTranslationUnit() by default. The returned flag
864e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * set contains an unspecified set of optimizations geared toward common uses
865e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * of reparsing. The set of optimizations enabled may change from one version
866e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * to the next.
867e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor */
868e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas GregorCINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
869e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor
870e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor/**
871abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \brief Reparse the source files that produced this translation unit.
872abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
873abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * This routine can be used to re-parse the source files that originally
874abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * created the given translation unit, for example because those source files
875abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * have changed (either on disk or as passed via \p unsaved_files). The
876abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * source code will be reparsed with the same command-line options as it
877abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * was originally parsed.
878abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
879abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * Reparsing a translation unit invalidates all cursors and source locations
880abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * that refer into that translation unit. This makes reparsing a translation
881abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unit semantically equivalent to destroying the translation unit and then
882abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * creating a new translation unit with the same command-line arguments.
883abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * However, it may be more efficient to reparse a translation
884abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unit using this routine.
885abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
886abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param TU The translation unit whose contents will be re-parsed. The
887abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * translation unit must originally have been built with
888abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \c clang_createTranslationUnitFromSourceFile().
889abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
890abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param num_unsaved_files The number of unsaved file entries in \p
891abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * unsaved_files.
892abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
893abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \param unsaved_files The files that have not yet been saved to disk
894abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * but may be required for parsing, including the contents of
895abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * those files.  The contents and name of these files (as specified by
896abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * CXUnsavedFile) are copied when necessary, so the client only needs to
897abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * guarantee their validity until the call to this function returns.
898abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor *
899e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * \param options A bitset of options composed of the flags in CXReparse_Flags.
900e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * The function \c clang_defaultReparseOptions() produces a default set of
901e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor * options recommended for most uses, based on the translation unit.
902e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor *
903abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \returns 0 if the sources could be reparsed. A non-zero value will be
904abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * returned if reparsing was impossible, such that the translation unit is
905abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * invalid. In such cases, the only valid call for \p TU is
906abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor * \c clang_disposeTranslationUnit(TU).
907abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor */
908abc563f554951259bbe0315055cad92ee14d87e4Douglas GregorCINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
909abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor                                                unsigned num_unsaved_files,
910e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor                                          struct CXUnsavedFile *unsaved_files,
911e1e13bf568a7e37c95eda6fcfa626659a06e67b1Douglas Gregor                                                unsigned options);
912abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor
913abc563f554951259bbe0315055cad92ee14d87e4Douglas Gregor/**
9145352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor * @}
9155352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor */
916896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
9175352ac06d8f6194825bb2a99ffa009b61bafb503Douglas Gregor/**
918c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Describes the kind of entity that a cursor refers to.
919c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
920c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregorenum CXCursorKind {
921c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* Declarations */
9221efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
923c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief A declaration whose specific kind is not exposed via this
9241efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * interface.
925c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
926c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * Unexposed declarations have the same operations as any other kind
927c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * of declaration; one can extract their location information,
928c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * spelling, find their definitions, etc. However, the specific kind
929c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * of the declaration is not reported.
930c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
931c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_UnexposedDecl                 = 1,
932c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A C or C++ struct. */
9331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  CXCursor_StructDecl                    = 2,
934c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A C or C++ union. */
935c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_UnionDecl                     = 3,
936c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A C++ class. */
937c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ClassDecl                     = 4,
938c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An enumeration. */
939c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_EnumDecl                      = 5,
9401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
941c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief A field (in C) or non-static data member (in C++) in a
942c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * struct, union, or C++ class.
943c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
944c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FieldDecl                     = 6,
945c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An enumerator constant. */
946c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_EnumConstantDecl              = 7,
947c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A function. */
948c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FunctionDecl                  = 8,
949c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A variable. */
950c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_VarDecl                       = 9,
951c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A function or method parameter. */
952c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ParmDecl                      = 10,
953c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @interface. */
954c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCInterfaceDecl             = 11,
955c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @interface for a category. */
956c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCCategoryDecl              = 12,
957c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @protocol declaration. */
958c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCProtocolDecl              = 13,
959c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @property declaration. */
960c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCPropertyDecl              = 14,
961c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C instance variable. */
962c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCIvarDecl                  = 15,
963c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C instance method. */
964c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCInstanceMethodDecl        = 16,
965c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C class method. */
966c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCClassMethodDecl           = 17,
967c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @implementation. */
968c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCImplementationDecl        = 18,
969c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An Objective-C @implementation for a category. */
970c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCCategoryImplDecl          = 19,
971c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief A typedef */
972c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_TypedefDecl                   = 20,
9738bd5a69999cfd06b6b5a58fdd04e4f802b2df5a4Ted Kremenek  /** \brief A C++ class method. */
9748bd5a69999cfd06b6b5a58fdd04e4f802b2df5a4Ted Kremenek  CXCursor_CXXMethod                     = 21,
9758f06e0e9fec3ca501e5fb129f413adbfc88e82f8Ted Kremenek  /** \brief A C++ namespace. */
9768f06e0e9fec3ca501e5fb129f413adbfc88e82f8Ted Kremenek  CXCursor_Namespace                     = 22,
977a0536d8dd900bb48ea886bd68d777b03b061c068Ted Kremenek  /** \brief A linkage specification, e.g. 'extern "C"'. */
978a0536d8dd900bb48ea886bd68d777b03b061c068Ted Kremenek  CXCursor_LinkageSpec                   = 23,
97901829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  /** \brief A C++ constructor. */
98001829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  CXCursor_Constructor                   = 24,
98101829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  /** \brief A C++ destructor. */
98201829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  CXCursor_Destructor                    = 25,
98301829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  /** \brief A C++ conversion function. */
98401829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor  CXCursor_ConversionFunction            = 26,
985fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  /** \brief A C++ template type parameter. */
986fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  CXCursor_TemplateTypeParameter         = 27,
987fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  /** \brief A C++ non-type template parameter. */
988fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  CXCursor_NonTypeTemplateParameter      = 28,
989fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  /** \brief A C++ template template parameter. */
990fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  CXCursor_TemplateTemplateParameter     = 29,
991fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  /** \brief A C++ function template. */
992fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor  CXCursor_FunctionTemplate              = 30,
99339d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor  /** \brief A C++ class template. */
99439d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor  CXCursor_ClassTemplate                 = 31,
99539d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor
99650aa6acd0b8d40c8956372a69e0a73f0802a5494Ted Kremenek  CXCursor_FirstDecl                     = CXCursor_UnexposedDecl,
99739d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor  CXCursor_LastDecl                      = CXCursor_ClassTemplate,
9981efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
999c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* References */
1000c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FirstRef                      = 40, /* Decl references */
10011efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  CXCursor_ObjCSuperClassRef             = 40,
1002c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCProtocolRef               = 41,
1003c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCClassRef                  = 42,
1004c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1005c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief A reference to a type declaration.
1006c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1007c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * A type reference occurs anywhere where a type is named but not
1008c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * declared. For example, given:
1009c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1010c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \code
1011c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * typedef unsigned size_type;
1012c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * size_type size;
1013c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \endcode
1014c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1015c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * The typedef is a declaration of size_type (CXCursor_TypedefDecl),
1016c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * while the type of the variable "size" is referenced. The cursor
1017c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * referenced by the type of size is the typedef for size_type.
1018c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1019c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_TypeRef                       = 43,
10203064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CXCursor_CXXBaseSpecifier              = 44,
10213064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CXCursor_LastRef                       = CXCursor_CXXBaseSpecifier,
10221efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1023c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* Error conditions */
1024c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FirstInvalid                  = 70,
1025c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_InvalidFile                   = 70,
1026c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_NoDeclFound                   = 71,
1027c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_NotImplemented                = 72,
1028ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek  CXCursor_InvalidCode                   = 73,
1029ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek  CXCursor_LastInvalid                   = CXCursor_InvalidCode,
10301efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1031c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* Expressions */
1032c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FirstExpr                     = 100,
10331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1034c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1035c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief An expression whose specific kind is not exposed via this
10361efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * interface.
1037c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1038c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * Unexposed expressions have the same operations as any other kind
1039c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * of expression; one can extract their location information,
1040c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * spelling, children, etc. However, the specific kind of the
1041c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * expression is not reported.
1042c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1043c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_UnexposedExpr                 = 100,
10441efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1045c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1046c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief An expression that refers to some value declaration, such
1047c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * as a function, varible, or enumerator.
1048c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1049c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_DeclRefExpr                   = 101,
10501efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1051c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1052c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief An expression that refers to a member of a struct, union,
1053c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * class, Objective-C class, etc.
1054c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1055c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_MemberRefExpr                 = 102,
10561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1057c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An expression that calls a function. */
1058c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_CallExpr                      = 103,
10591efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1060c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /** \brief An expression that sends a message to an Objective-C
1061c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   object or class. */
1062c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_ObjCMessageExpr               = 104,
10631ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek
10641ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek  /** \brief An expression that represents a block literal. */
10651ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek  CXCursor_BlockExpr                     = 105,
10661ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek
10671ee6cad59f017601ea54fbb4f62a6e8d69897e3eTed Kremenek  CXCursor_LastExpr                      = 105,
10681efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1069c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /* Statements */
1070c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_FirstStmt                     = 200,
1071c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1072c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief A statement whose specific kind is not exposed via this
1073c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * interface.
1074c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1075c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * Unexposed statements have the same operations as any other kind of
1076c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * statement; one can extract their location information, spelling,
1077c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * children, etc. However, the specific kind of the statement is not
1078c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * reported.
1079c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1080c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_UnexposedStmt                 = 200,
1081c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXCursor_LastStmt                      = 200,
10821efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1083c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1084c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief Cursor that represents the translation unit itself.
1085c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   *
1086c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * The translation unit cursor exists primarily to act as the root
1087c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * cursor for traversing the contents of a translation unit.
1088c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1089e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_TranslationUnit               = 300,
1090e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek
1091e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  /* Attributes */
1092e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_FirstAttr                     = 400,
1093e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  /**
1094e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek   * \brief An attribute whose specific kind is not exposed via this
1095e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek   * interface.
1096e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek   */
1097e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_UnexposedAttr                 = 400,
1098e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek
1099e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_IBActionAttr                  = 401,
1100e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek  CXCursor_IBOutletAttr                  = 402,
1101857e918a8a40deb128840308a318bf623d68295fTed Kremenek  CXCursor_IBOutletCollectionAttr        = 403,
1102857e918a8a40deb128840308a318bf623d68295fTed Kremenek  CXCursor_LastAttr                      = CXCursor_IBOutletCollectionAttr,
11039f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor
11049f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor  /* Preprocessing */
11059f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor  CXCursor_PreprocessingDirective        = 500,
1106572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor  CXCursor_MacroDefinition               = 501,
1107572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor  CXCursor_MacroInstantiation            = 502,
11089f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor  CXCursor_FirstPreprocessing            = CXCursor_PreprocessingDirective,
11094807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor  CXCursor_LastPreprocessing             = CXCursor_MacroInstantiation
1110c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor};
1111c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1112c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1113c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief A cursor representing some element in the abstract syntax tree for
1114c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * a translation unit.
1115c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
11161efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The cursor abstraction unifies the different kinds of entities in a
1117c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * program--declaration, statements, expressions, references to declarations,
1118c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * etc.--under a single "cursor" abstraction with a common set of operations.
1119c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Common operation for a cursor include: getting the physical location in
1120c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * a source file where the cursor points, getting the name associated with a
1121c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor, and retrieving cursors for any child nodes of a particular cursor.
1122c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1123c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Cursors can be produced in two specific ways.
1124c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_getTranslationUnitCursor() produces a cursor for a translation unit,
1125c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * from which one can use clang_visitChildren() to explore the rest of the
1126c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * translation unit. clang_getCursor() maps from a physical source location
1127c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to the entity that resides at that location, allowing one to map from the
1128c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * source code into the AST.
1129c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1130c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregortypedef struct {
1131c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  enum CXCursorKind kind;
1132c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  void *data[3];
11331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar} CXCursor;
1134c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1135c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1136c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations
1137c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1138c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
1139c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
11401efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1141c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1142c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the NULL cursor, which represents no entity.
1143c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1144c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXCursor clang_getNullCursor(void);
11451efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1146c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1147c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the cursor that represents the given translation unit.
1148c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1149c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The translation unit cursor can be used to start traversing the
1150c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * various declarations within the given translation unit.
1151c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1152c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit);
1153c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1154c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1155c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether two cursors are equivalent.
1156c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1157c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor);
11581efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1159c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1160c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve the kind of the given cursor.
1161c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1162c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor);
1163c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1164c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1165c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a declaration.
1166c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1167c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
1168c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1169c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1170c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a simple
1171c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * reference.
1172c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1173c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Note that other kinds of cursors (such as expressions) can also refer to
1174c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * other cursors. Use clang_getCursorReferenced() to determine whether a
1175c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * particular cursor refers to another entity.
1176c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1177c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind);
1178c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1179c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1180c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents an expression.
1181c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1182c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind);
1183c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1184c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1185c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Determine whether the given cursor kind represents a statement.
1186c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1187c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind);
1188c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1189c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
11901efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Determine whether the given cursor kind represents an invalid
1191c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor.
11921efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar */
1193c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind);
1194c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1195c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
11961efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Determine whether the given cursor kind represents a translation
11971efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * unit.
1198c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1199c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind);
12001efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1201ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek/***
12029f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor * \brief Determine whether the given cursor represents a preprocessing
12039f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor * element, such as a preprocessor directive or macro instantiation.
12049f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor */
12059f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas GregorCINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind);
12069f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor
12079f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor/***
1208ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek * \brief Determine whether the given cursor represents a currently
1209ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek *  unexposed piece of the AST (e.g., CXCursor_UnexposedStmt).
1210ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek */
1211ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted KremenekCINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind);
1212ad6eff611a4391f89fd6c458db16993f76e7f5d0Ted Kremenek
1213c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
121416b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek * \brief Describe the linkage of the entity referred to by a cursor.
121516b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek */
121616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenekenum CXLinkageKind {
121716b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /** \brief This value indicates that no linkage information is available
121816b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   * for a provided CXCursor. */
121916b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_Invalid,
122016b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /**
122116b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   * \brief This is the linkage for variables, parameters, and so on that
122216b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   *  have automatic storage.  This covers normal (non-extern) local variables.
122316b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   */
122416b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_NoLinkage,
122516b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /** \brief This is the linkage for static variables and static functions. */
122616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_Internal,
122716b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /** \brief This is the linkage for entities with external linkage that live
122816b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek   * in C++ anonymous namespaces.*/
122916b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_UniqueExternal,
123016b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  /** \brief This is the linkage for entities with true, external linkage. */
123116b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek  CXLinkage_External
123216b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek};
123316b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek
123416b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek/**
123545e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Determine the linkage of the entity referred to by a given cursor.
123616b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek */
123716b4259aecaa22b642d35d36fd89965ed700c1e0Ted KremenekCINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor);
123816b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek
123916b4259aecaa22b642d35d36fd89965ed700c1e0Ted Kremenek/**
124058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \brief Determine the availability of the entity that this cursor refers to.
124158ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor *
124258ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \param cursor The cursor to query.
124358ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor *
124458ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \returns The availability of the cursor.
124558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor */
124658ddb60f409125eda5436c4a1f070f7fa4744295Douglas GregorCINDEX_LINKAGE enum CXAvailabilityKind
124758ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorclang_getCursorAvailability(CXCursor cursor);
124858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor
124958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor/**
125045e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Describe the "language" of the entity referred to by a cursor.
125145e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek */
125245e1dae500bba7a9ef5b8206263a5609c07c6f03Ted KremenekCINDEX_LINKAGE enum CXLanguageKind {
12536cd1e7cb04d1da66e8b5675062152ff60bbc354fTed Kremenek  CXLanguage_Invalid = 0,
125445e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek  CXLanguage_C,
125545e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek  CXLanguage_ObjC,
12566cd1e7cb04d1da66e8b5675062152ff60bbc354fTed Kremenek  CXLanguage_CPlusPlus
125745e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek};
125845e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek
125945e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek/**
126045e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek * \brief Determine the "language" of the entity referred to by a given cursor.
126145e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek */
126245e1dae500bba7a9ef5b8206263a5609c07c6f03Ted KremenekCINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
126345e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek
126445e1dae500bba7a9ef5b8206263a5609c07c6f03Ted Kremenek/**
1265c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
1266c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
12671efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1268c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1269c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code
1270c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1271c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Cursors represent a location within the Abstract Syntax Tree (AST). These
1272c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * routines help map between cursors and the physical locations where the
1273c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * described entities occur in the source code. The mapping is provided in
1274c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * both directions, so one can map from source code to the AST and back.
1275c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1276c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
127750398199fb10e196a8d92fbf7a062dbe42ed88fdSteve Naroff */
12781efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
12796a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff/**
1280b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \brief Map a source location to the cursor that describes the entity at that
1281b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * location in the source code.
1282b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
1283b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * clang_getCursor() maps an arbitrary source location within a translation
1284b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * unit down to the most specific cursor that describes the entity at that
12851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * location. For example, given an expression \c x + y, invoking
1286b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * clang_getCursor() with a source location pointing to "x" will return the
12871efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * cursor for "x"; similarly for "y". If the cursor points anywhere between
1288b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor()
1289b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * will return a cursor referring to the "+" expression.
1290b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor *
1291b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * \returns a cursor representing the entity at the given source location, or
1292b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas Gregor * a NULL cursor if no such entity can be found.
12936a6de8b4fc944ca1bfa4e47c516d049a0d627b0eSteve Naroff */
1294b979034b100be14de2223f2b8f6cc7a3275cbe4fDouglas GregorCINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation);
12951efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
129698258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor/**
129798258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * \brief Retrieve the physical location of the source constructor referenced
129898258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * by the given cursor.
129998258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor *
130098258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * The location of a declaration is typically the location of the name of that
13011efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * declaration, where the name of that declaration would occur if it is
13021efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * unnamed, or some keyword that introduces that particular declaration.
13031efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * The location of a reference is where that reference occurs within the
130498258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor * source code.
130598258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas Gregor */
130698258afae66bab39b0c57a3efb6b20d4fbb5746cDouglas GregorCINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor);
1307c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1308b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor/**
1309b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief Retrieve the physical extent of the source construct referenced by
1310a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * the given cursor.
1311a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor *
1312a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * The extent of a cursor starts with the file/line/column pointing at the
1313a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * first character within the source construct that the cursor refers to and
13141efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * ends with the last character withinin that source construct. For a
1315a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * declaration, the extent covers the declaration itself. For a reference,
1316a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * the extent covers the location of the reference (e.g., where the referenced
1317a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor * entity was actually used).
1318a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas Gregor */
1319a7bde20f8c6334ccc3a7ef4dd77243d0921a8497Douglas GregorCINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor);
1320c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor
1321c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1322c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
1323c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
132495f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
1325c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
13268e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \defgroup CINDEX_TYPES Type information for CXCursors
13278e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
13288e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * @{
13298e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
13308e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
13318e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
13328e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Describes the kind of type
13338e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
13348e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenekenum CXTypeKind {
13358e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  /**
13368e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   * \brief Reprents an invalid type (e.g., where no type is available).
13378e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   */
13388e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Invalid = 0,
13398e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
13408e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  /**
13418e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   * \brief A type whose specific kind is not exposed via this
13428e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   * interface.
13438e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek   */
13448e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Unexposed = 1,
13458e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
13468e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  /* Builtin types */
13478e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Void = 2,
13488e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Bool = 3,
13498e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Char_U = 4,
13508e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_UChar = 5,
13518e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Char16 = 6,
13528e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Char32 = 7,
13538e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_UShort = 8,
13548e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_UInt = 9,
13558e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ULong = 10,
13568e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ULongLong = 11,
13578e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_UInt128 = 12,
13588e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Char_S = 13,
13598e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_SChar = 14,
13608e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_WChar = 15,
13618e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Short = 16,
13628e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Int = 17,
13638e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Long = 18,
13648e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_LongLong = 19,
13658e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Int128 = 20,
13668e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Float = 21,
13678e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Double = 22,
13688e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_LongDouble = 23,
13698e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_NullPtr = 24,
13708e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Overload = 25,
13718e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Dependent = 26,
13728e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ObjCId = 27,
13738e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ObjCClass = 28,
13748e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ObjCSel = 29,
13758e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_FirstBuiltin = CXType_Void,
13768e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_LastBuiltin  = CXType_ObjCSel,
13778e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
13788e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Complex = 100,
13798e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Pointer = 101,
13808e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_BlockPointer = 102,
13818e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_LValueReference = 103,
13828e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_RValueReference = 104,
13838e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Record = 105,
13848e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Enum = 106,
13858e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_Typedef = 107,
13868e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  CXType_ObjCInterface = 108,
138704c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek  CXType_ObjCObjectPointer = 109,
138804c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek  CXType_FunctionNoProto = 110,
138904c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek  CXType_FunctionProto = 111
13908e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek};
13918e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
13928e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
13938e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief The type of an element in the abstract syntax tree.
13948e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
13958e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
13968e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenektypedef struct {
13978e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  enum CXTypeKind kind;
13988e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek  void *data[2];
13998e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek} CXType;
14008e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
14018e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
14028e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Retrieve the type of a CXCursor (if any).
14038e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
14048e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getCursorType(CXCursor C);
14058e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
14068e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
14078e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \determine Determine whether two CXTypes represent the same type.
14088e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
14098e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \returns non-zero if the CXTypes represent the same type and
14108e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek            zero otherwise.
14118e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
14128e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B);
14138e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
14148e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
14158e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Return the canonical type for a CXType.
14168e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
14178e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * Clang's type system explicitly models typedefs and all the ways
14188e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * a specific type can be represented.  The canonical type is the underlying
14198e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * type with all the "sugar" removed.  For example, if 'T' is a typedef
14208e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * for 'int', the canonical type for 'T' would be 'int'.
14218e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
14228e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getCanonicalType(CXType T);
14238e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
14248e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
14258e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief For pointer types, returns the type of the pointee.
14268e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek *
14278e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
14288e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
14298e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
14308e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
14318e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Return the cursor for the declaration of the given type.
14328e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
14338e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T);
14348e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
14358e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
14368e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
14378e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * \brief Retrieve the spelling of a given CXTypeKind.
14388e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
14398e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted KremenekCINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K);
14408e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
14418e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
14429a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek * \brief Retrieve the result type associated with a function type.
144304c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek */
144404c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted KremenekCINDEX_LINKAGE CXType clang_getResultType(CXType T);
144504c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek
144604c3cf35a80c09ab78e519f2e71ecccd5c5d8da0Ted Kremenek/**
14479a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek * \brief Retrieve the result type associated with a given cursor.  This only
14489a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek *  returns a valid type of the cursor refers to a function or method.
14499a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek */
14509a140845438c2fc31e7d48a6dedbc695f4c83c68Ted KremenekCINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
14519a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek
14529a140845438c2fc31e7d48a6dedbc695f4c83c68Ted Kremenek/**
14533ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek * \brief Return 1 if the CXType is a POD (plain old data) type, and 0
14543ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek *  otherwise.
14553ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek */
14563ce9e7d270e7df86c09c8126b4412d55be7c123bTed KremenekCINDEX_LINKAGE unsigned clang_isPODType(CXType T);
14573ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek
14583ce9e7d270e7df86c09c8126b4412d55be7c123bTed Kremenek/**
14593064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Returns 1 if the base class specified by the cursor with kind
14603064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek *   CX_CXXBaseSpecifier is virtual.
14613064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */
14623064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor);
14633064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek
14643064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/**
14653064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Represents the C++ access control level to a base class for a
14663064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * cursor with kind CX_CXXBaseSpecifier.
14673064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */
14683064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenekenum CX_CXXAccessSpecifier {
14693064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CX_CXXInvalidAccessSpecifier,
14703064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CX_CXXPublic,
14713064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CX_CXXProtected,
14723064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek  CX_CXXPrivate
14733064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek};
14743064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek
14753064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/**
14763064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek * \brief Returns the access control level for the C++ base specifier
14773064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek *  represented by a cursor with kind CX_CXXBaseSpecifier.
14783064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek */
14793064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
14803064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek
14813064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek/**
14828e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek * @}
14838e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek */
148495f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
148595f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/**
1486ad72f4dad4cf0fd2b71eb8f4704d2fe7ac58fb44Ted Kremenek * \defgroup CINDEX_ATTRIBUTES Information for attributes
148795f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek *
148895f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * @{
148995f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */
149095f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
149195f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
149295f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/**
149395f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * \brief For cursors representing an iboutletcollection attribute,
149495f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek *  this function returns the collection element type.
149595f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek *
149695f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */
149795f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted KremenekCINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor);
149895f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek
149995f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek/**
150095f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek * @}
150195f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek */
15028e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek
15038e0ac174c8c8c980927b3e1447f16f62fbe2a2e4Ted Kremenek/**
1504c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors
1505c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1506c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * These routines provide the ability to traverse the abstract syntax tree
1507c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * using cursors.
1508c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1509c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
1510c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
15111efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1512c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1513c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Describes how the traversal of the children of a particular
1514c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * cursor should proceed after visiting a particular child cursor.
1515c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1516c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A value of this enumeration type should be returned by each
1517c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \c CXCursorVisitor to indicate how clang_visitChildren() proceed.
1518c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1519c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregorenum CXChildVisitResult {
1520c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
15211efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * \brief Terminates the cursor traversal.
1522c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1523c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXChildVisit_Break,
15241efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
1525c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief Continues the cursor traversal with the next sibling of
1526c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * the cursor just visited, without visiting its children.
1527c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1528c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXChildVisit_Continue,
1529c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  /**
1530c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * \brief Recursively traverse the children of this cursor, using
1531c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   * the same visitor and client data.
1532c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor   */
1533c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor  CXChildVisit_Recurse
1534c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor};
1535c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1536c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1537c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Visitor invoked for each cursor found by a traversal.
1538c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1539c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * This visitor function will be invoked for each cursor found by
1540c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_visitCursorChildren(). Its first argument is the cursor being
1541c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * visited, its second argument is the parent visitor for that cursor,
1542c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * and its third argument is the client data provided to
1543c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * clang_visitCursorChildren().
1544c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1545c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * The visitor should return one of the \c CXChildVisitResult values
1546c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * to direct clang_visitCursorChildren().
1547c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
15481efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbartypedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
15491efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar                                                   CXCursor parent,
1550c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor                                                   CXClientData client_data);
1551c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1552c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1553c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Visit the children of a particular cursor.
1554c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1555c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * This function visits all the direct children of the given cursor,
1556c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * invoking the given \p visitor function with the cursors of each
1557c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * visited child. The traversal may be recursive, if the visitor returns
1558c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if
1559c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * the visitor returns \c CXChildVisit_Break.
1560c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1561c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param parent the cursor whose child may be visited. All kinds of
1562a57259e9d7b30bcce93f0a62eee0488738026172Daniel Dunbar * cursors can be visited, including invalid cursors (which, by
1563c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * definition, have no children).
1564c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1565c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param visitor the visitor function that will be invoked for each
1566c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * child of \p parent.
1567c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1568c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \param client_data pointer data supplied by the client, which will
1569c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * be passed to the visitor each time it is invoked.
1570c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1571c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \returns a non-zero value if the traversal was terminated
1572c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * prematurely by the visitor returning \c CXChildVisit_Break.
1573c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
15741efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
1575c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor                                            CXCursorVisitor visitor,
1576c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor                                            CXClientData client_data);
15771efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1578c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1579c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
1580c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
15811efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1582c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1583c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST
1584c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
15851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * These routines provide the ability to determine references within and
1586c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * across translation units, by providing the names of the entities referenced
1587c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * by cursors, follow reference cursors to the declarations they reference,
1588c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * and associate declarations with their definitions.
1589c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1590c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
1591c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
15921efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1593c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1594c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced
1595c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * by the given cursor.
1596c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1597c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * A Unified Symbol Resolution (USR) is a string that identifies a particular
1598c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * entity (function, class, variable, etc.) within a program. USRs can be
1599c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * compared across translation units to determine, e.g., when references in
1600c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * one translation refer to an entity defined in another translation unit.
1601c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1602c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor);
1603c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1604c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1605896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C class.
1606896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1607896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
1608896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1609896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1610896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C category.
1611896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1612896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString
161366ccaec73706f3623d2e7d191fe2c944feedcc2bTed Kremenek  clang_constructUSR_ObjCCategory(const char *class_name,
1614896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                 const char *category_name);
1615896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1616896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1617896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C protocol.
1618896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1619896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString
1620896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek  clang_constructUSR_ObjCProtocol(const char *protocol_name);
1621896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1622896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1623896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1624896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C instance variable and
1625896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek *   the USR for its containing class.
1626896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1627896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name,
1628896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                                    CXString classUSR);
1629896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1630896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1631896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C method and
1632896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek *   the USR for its containing class.
1633896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1634896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name,
1635896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                                      unsigned isInstanceMethod,
1636896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                                      CXString classUSR);
1637896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1638896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1639896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek * \brief Construct a USR for a specified Objective-C property and the USR
1640896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek *  for its containing class.
1641896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek */
1642896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property,
1643896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek                                                        CXString classUSR);
1644896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1645896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek/**
1646c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \brief Retrieve a name for the entity referenced by this cursor.
1647c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
1648c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas GregorCINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
1649c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor
1650c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor/** \brief For a cursor that is a reference, retrieve a cursor representing the
1651c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * entity that it references.
1652c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor *
1653c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * Reference cursors refer to other entities in the AST. For example, an
1654c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * Objective-C superclass reference cursor refers to an Objective-C class.
16551efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * This function produces the cursor for the Objective-C class from the
1656c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * cursor for the superclass reference. If the input cursor is a declaration or
1657c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor * definition, it returns that declaration or definition unchanged.
16581efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * Otherwise, returns the NULL cursor.
1659c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas Gregor */
1660c5d1e9375d71e66d22456e7cc52cc7c0a5c65c3fDouglas GregorCINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor);
1661b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor
16621efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/**
1663b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  \brief For a cursor that is either a reference to or a declaration
1664b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  of some entity, retrieve a cursor that describes the definition of
1665b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  that entity.
1666b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *
1667b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  Some entities can be declared multiple times within a translation
1668b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  unit, but only one of those declarations can also be a
1669b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  definition. For example, given:
1670b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *
1671b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  \code
1672b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  int f(int, int);
1673b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  int g(int x, int y) { return f(x, y); }
1674b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  int f(int a, int b) { return a + b; }
1675b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  int f(int, int);
1676b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  \endcode
1677b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *
1678b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  there are three declarations of the function "f", but only the
1679b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  second one is a definition. The clang_getCursorDefinition()
1680b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  function will take any cursor pointing to a declaration of "f"
1681b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  (the first or fourth lines of the example) or a cursor referenced
1682b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  that uses "f" (the call to "f' inside "g") and will return a
1683b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  declaration cursor pointing to the definition (the second "f"
1684b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  declaration).
1685b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *
1686b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  If given a cursor for which there is no corresponding definition,
1687b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  e.g., because there is no definition of that entity within this
1688b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor *  translation unit, returns a NULL cursor.
1689b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor */
1690b699866820102a69d83d6ac6941985c5ef4e8c40Douglas GregorCINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor);
1691b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor
16921efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar/**
1693b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * \brief Determine whether the declaration pointed to by this cursor
1694b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor * is also a definition of that entity.
1695b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor */
1696b699866820102a69d83d6ac6941985c5ef4e8c40Douglas GregorCINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
1697b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor
1698c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1699c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
1700c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
17011efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1702c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
17039ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * \defgroup CINDEX_CPP C++ AST introspection
17049ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek *
17059ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * The routines in this group provide access information in the ASTs specific
17069ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * to C++ language features.
17079ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek *
17089ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * @{
17099ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */
17109ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek
17119ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/**
17129ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * \brief Determine if a C++ member function is declared 'static'.
17139ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */
17149ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed KremenekCINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
17159ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek
17169ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/**
17179ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek * @}
17189ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek */
17199ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek
17209ada39a4ac82ff5f5087b0a7fa9ed0d32be55a3bTed Kremenek/**
17210045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * \defgroup CINDEX_LEX Token extraction and manipulation
17220045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *
17230045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * The routines in this group provide access to the tokens within a
17240045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * translation unit, along with a semantic mapping of those tokens to
17250045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * their corresponding cursors.
1726fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1727fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * @{
1728fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1729fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor
1730fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1731fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Describes a kind of token.
1732fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1733fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregortypedef enum CXTokenKind {
1734fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
1735fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   * \brief A token that contains some kind of punctuation.
1736fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
1737fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Punctuation,
1738896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1739fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
17400045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor   * \brief A language keyword.
1741fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
1742fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Keyword,
1743896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1744fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
1745fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   * \brief An identifier (that is not a keyword).
1746fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
1747fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Identifier,
1748896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1749fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
1750fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   * \brief A numeric, string, or character literal.
1751fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
1752fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Literal,
1753896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1754fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  /**
1755fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   * \brief A comment.
1756fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor   */
1757fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  CXToken_Comment
1758fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor} CXTokenKind;
1759fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor
1760fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1761fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Describes a single preprocessing token.
1762fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1763fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregortypedef struct {
1764fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  unsigned int_data[4];
1765fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor  void *ptr_data;
1766fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor} CXToken;
1767fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor
1768fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1769fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Determine the kind of the given token.
1770fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1771fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken);
1772896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1773fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1774fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Determine the spelling of the given token.
1775fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1776fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * The spelling of a token is the textual representation of that token, e.g.,
1777fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * the text of an identifier or keyword.
1778fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1779fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken);
1780896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1781fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1782fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Retrieve the source location of the given token.
1783fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1784896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit,
1785fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                                       CXToken);
1786896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1787fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1788fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Retrieve a source range that covers the given token.
1789fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1790fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken);
1791fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor
1792fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1793fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Tokenize the source code described by the given range into raw
1794fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * lexical tokens.
1795fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1796fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param TU the translation unit whose text is being tokenized.
1797fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1798fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Range the source range in which text should be tokenized. All of the
1799fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * tokens produced by tokenization will fall within this source range,
1800fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1801fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Tokens this pointer will be set to point to the array of tokens
1802fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * that occur within the given source range. The returned pointer must be
1803fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * freed with clang_disposeTokens() before the translation unit is destroyed.
1804fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1805fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param NumTokens will be set to the number of tokens in the \c *Tokens
1806fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * array.
1807fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1808fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1809fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
1810fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                   CXToken **Tokens, unsigned *NumTokens);
1811896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1812fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1813fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Annotate the given set of tokens by providing cursors for each token
1814fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * that can be mapped to a specific entity within the abstract syntax tree.
1815fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
18160045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * This token-annotation routine is equivalent to invoking
18170045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * clang_getCursor() for the source locations of each of the
18180045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * tokens. The cursors provided are filtered, so that only those
18190045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * cursors that have a direct correspondence to the token are
18200045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * accepted. For example, given a function call \c f(x),
18210045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * clang_getCursor() would provide the following cursors:
18220045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *
18230045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *   * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'.
18240045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *   * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'.
18250045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *   * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'.
18260045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor *
18270045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * Only the first and last of these cursors will occur within the
18280045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * annotate, since the tokens "f" and "x' directly refer to a function
18290045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * and a variable, respectively, but the parentheses are just a small
18300045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * part of the full syntax of the function call expression, which is
18310045e9fe1f7dfc37f1ea7bdb9b70bcdb6700f0c0Douglas Gregor * not provided as an annotation.
1832fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1833fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param TU the translation unit that owns the given tokens.
1834fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1835fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Tokens the set of tokens to annotate.
1836fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1837fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param NumTokens the number of tokens in \p Tokens.
1838fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor *
1839fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \param Cursors an array of \p NumTokens cursors, whose contents will be
1840fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * replaced with the cursors corresponding to each token.
1841fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1842fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas GregorCINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
1843fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                         CXToken *Tokens, unsigned NumTokens,
1844fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                         CXCursor *Cursors);
1845896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1846fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1847fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * \brief Free the given set of tokens.
1848fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1849896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
1850fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor                                        CXToken *Tokens, unsigned NumTokens);
1851896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1852fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1853fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor * @}
1854fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor */
1855896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
1856fc8ea23eb6cbaaa5046f2abb4c033e24c8659efdDouglas Gregor/**
1857c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_DEBUG Debugging facilities
1858c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1859c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * These routines are used for testing and debugging, only, and should not
1860c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * be relied upon.
1861c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1862c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
1863c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
18641efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
18654ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff/* for debug/testing */
1866e68fff6fc083c6270d835216a3de0b82c6ef0310Ted KremenekCINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
18671efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
18681efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar                                          const char **startBuf,
18694ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          const char **endBuf,
18704ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          unsigned *startLine,
18714ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          unsigned *startColumn,
18724ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          unsigned *endLine,
18734ade6d6eae934f796ca43c81a5aa185e456dde9bSteve Naroff                                          unsigned *endColumn);
18740a812cf707da15dadd19fdeb0178b9707f4e01a6Douglas GregorCINDEX_LINKAGE void clang_enableStackTraces(void);
18750c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
1876c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
1877c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
18781efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1879c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
1880c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * \defgroup CINDEX_CODE_COMPLET Code completion
1881c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1882c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * Code completion involves taking an (incomplete) source file, along with
1883c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * knowledge of where the user is actively editing that file, and suggesting
1884c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * syntactically- and semantically-valid constructs that the user might want to
1885c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * use at that particular point in the source code. These data structures and
1886c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * routines provide support for code completion.
1887c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor *
1888c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @{
1889c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
18901efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
1891c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
18920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A semantic string that describes a code-completion result.
18930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
18940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * A semantic string that describes the formatting of a code-completion
18950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * result as a single "template" of text that should be inserted into the
18960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * source buffer when a particular code-completion result is selected.
18970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Each semantic string is made up of some number of "chunks", each of which
18980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * contains some text along with a description of what that text means, e.g.,
18990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the name of the entity being referenced, whether the text chunk is part of
19000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the template, or whether it is a "placeholder" that the user should replace
19010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * with actual code,of a specific kind. See \c CXCompletionChunkKind for a
19021efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * description of the different kinds of chunks.
19030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
19040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef void *CXCompletionString;
19051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
19060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
19070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief A single result of code completion.
19080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
19090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregortypedef struct {
19100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
19111efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * \brief The kind of entity that this completion refers to.
19120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
19131efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * The cursor kind will be a macro, keyword, or a declaration (one of the
19140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * *Decl cursor kinds), describing the entity that the completion is
19150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * referring to.
19160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
19170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \todo In the future, we would like to provide a full cursor, to allow
19180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * the client to extract additional information from declaration.
19190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
19200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  enum CXCursorKind CursorKind;
19211efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
19221efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar  /**
19230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief The code-completion string that describes how to insert this
19240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * code-completion result into the editing buffer.
19250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
19260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionString CompletionString;
19270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor} CXCompletionResult;
19280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor
19290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
19300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Describes a single piece of text within a code-completion string.
19310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
19321efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * Each "chunk" within a code-completion string (\c CXCompletionString) is
19331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * either a piece of text with a specific "kind" that describes how that text
19340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * should be interpreted by the client or is another completion string.
19350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
19360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorenum CXCompletionChunkKind {
19370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
19380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A code-completion string that describes "optional" text that
19390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * could be a part of the template (but is not required).
19400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
19410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * The Optional chunk is the only kind of chunk that has a code-completion
19421efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * string for its representation, which is accessible via
19430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \c clang_getCompletionChunkCompletionString(). The code-completion string
19440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * describes an additional part of the template that is completely optional.
19450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * For example, optional chunks can be used to describe the placeholders for
19460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * arguments that match up with defaulted function parameters, e.g. given:
19470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
19480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \code
19490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * void f(int x, float y = 3.14, double z = 2.71828);
19500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \endcode
19510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
19520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * The code-completion string for this function would contain:
19530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - a TypedText chunk for "f".
19540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - a LeftParen chunk for "(".
19550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - a Placeholder chunk for "int x"
19560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - an Optional chunk containing the remaining defaulted arguments, e.g.,
19570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *       - a Comma chunk for ","
195871570182471d502a97f7f175aa527152544c75f2Daniel Dunbar   *       - a Placeholder chunk for "float y"
19590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *       - an Optional chunk containing the last defaulted argument:
19600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *           - a Comma chunk for ","
19610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *           - a Placeholder chunk for "double z"
19620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - a RightParen chunk for ")"
19630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
196471570182471d502a97f7f175aa527152544c75f2Daniel Dunbar   * There are many ways to handle Optional chunks. Two simple approaches are:
19650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - Completely ignore optional chunks, in which case the template for the
19660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *     function "f" would only include the first parameter ("int x").
19670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *   - Fully expand all optional chunks, in which case the template for the
19680c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *     function "f" would have all of the parameters.
19690c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
19700c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_Optional,
19710c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
19720c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Text that a user would be expected to type to get this
19731efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * code-completion result.
19740c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
19751efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * There will be exactly one "typed text" chunk in a semantic string, which
19761efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * will typically provide the spelling of a keyword or the name of a
19770c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * declaration that could be used at the current code point. Clients are
19780c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * expected to filter the code-completion results based on the text in this
19790c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * chunk.
19800c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
19810c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_TypedText,
19820c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
19830c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Text that should be inserted as part of a code-completion result.
19840c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
19850c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * A "text" chunk represents text that is part of the template to be
19860c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * inserted into user code should this particular code-completion result
19870c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * be selected.
19880c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
19890c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_Text,
19900c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
19910c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Placeholder text that should be replaced by the user.
19920c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
19930c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * A "placeholder" chunk marks a place where the user should insert text
19940c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * into the code-completion template. For example, placeholders might mark
19950c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * the function parameters for a function declaration, to indicate that the
19960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * user should provide arguments for each of those parameters. The actual
19970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * text in a placeholder is a suggestion for the text to display before
19980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * the user replaces the placeholder with real code.
19990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_Placeholder,
20010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Informative text that should be displayed but never inserted as
20030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * part of the template.
20041efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   *
20050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * An "informative" chunk contains annotations that can be displayed to
20060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * help the user decide whether a particular code-completion result is the
20070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * right option, but which is not part of the actual template to be inserted
20080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * by code completion.
20090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_Informative,
20110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief Text that describes the current parameter when code-completion is
20130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * referring to function call, message send, or template specialization.
20140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
20150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * A "current parameter" chunk occurs when code-completion is providing
20160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * information about a parameter corresponding to the argument at the
20170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * code-completion point. For example, given a function
20180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
20190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \code
20200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * int add(int x, int y);
20210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \endcode
20220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   *
20230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * and the source code \c add(, where the code-completion point is after the
20240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * "(", the code-completion string will contain a "current parameter" chunk
20250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * for "int x", indicating that the current argument will initialize that
20260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * parameter. After typing further, to \c add(17, (where the code-completion
20271efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * point is after the ","), the code-completion string will contain a
20280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * "current paremeter" chunk to "int y".
20290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_CurrentParameter,
20310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A left parenthesis ('('), used to initiate a function call or
20330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * signal the beginning of a function parameter list.
20340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_LeftParen,
20360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A right parenthesis (')'), used to finish a function call or
20380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * signal the end of a function parameter list.
20390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_RightParen,
20410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A left bracket ('[').
20430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_LeftBracket,
20450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A right bracket (']').
20470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_RightBracket,
20490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20500c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A left brace ('{').
20510c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20520c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_LeftBrace,
20530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A right brace ('}').
20550c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20560c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_RightBrace,
20570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A left angle bracket ('<').
20590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_LeftAngle,
20610c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A right angle bracket ('>').
20630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
20640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  CXCompletionChunk_RightAngle,
20650c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor  /**
20660c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   * \brief A comma separator (',').
20670c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor   */
2068ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor  CXCompletionChunk_Comma,
2069ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor  /**
20701efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * \brief Text that specifies the result type of a given result.
2071ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor   *
2072ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor   * This special kind of informative chunk is not meant to be inserted into
20731efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar   * the text buffer. Rather, it is meant to illustrate the type that an
2074ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor   * expression using the given completion string would have.
2075ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aaDouglas Gregor   */
207601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_ResultType,
207701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
207801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * \brief A colon (':').
207901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
208001dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_Colon,
208101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
208201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * \brief A semicolon (';').
208301dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
208401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_SemiColon,
208501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
208601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * \brief An '=' sign.
208701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
208801dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_Equal,
208901dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
209001dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * Horizontal space (' ').
209101dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
209201dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_HorizontalSpace,
209301dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  /**
209401dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * Vertical space ('\n'), after which it is generally a good idea to
209501dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   * perform indentation.
209601dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor   */
209701dfea02d1da297e8b53db8eea3d3cc652acda8dDouglas Gregor  CXCompletionChunk_VerticalSpace
20980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor};
20991efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
21000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
21010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Determine the kind of a particular chunk within a completion string.
21020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query.
21040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string.
21060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21070c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the kind of the chunk at the index \c chunk_number.
21080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
21091efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE enum CXCompletionChunkKind
21100c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkKind(CXCompletionString completion_string,
21110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor                             unsigned chunk_number);
21121efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
21130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
21141efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve the text associated with a particular chunk within a
21150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * completion string.
21160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query.
21180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string.
21200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the text associated with the chunk at index \c chunk_number.
21220c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
21232ef6f8f5a35a60870594c5b04e0aa2bf22c6886fTed KremenekCINDEX_LINKAGE CXString
21240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkText(CXCompletionString completion_string,
21250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor                             unsigned chunk_number);
21260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor
21270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
21281efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \brief Retrieve the completion string associated with a particular chunk
21290c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * within a completion string.
21300c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21310c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param completion_string the completion string to query.
21320c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21330c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param chunk_number the 0-based index of the chunk in the completion string.
21340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \returns the completion string associated with the chunk at index
21360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \c chunk_number, or NULL if that chunk is not represented by a completion
21370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * string.
21380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
21390c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE CXCompletionString
21400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getCompletionChunkCompletionString(CXCompletionString completion_string,
21410c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor                                         unsigned chunk_number);
21421efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
21430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
21440c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Retrieve the number of chunks in the given code-completion string.
21450c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
21460c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas GregorCINDEX_LINKAGE unsigned
21470c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregorclang_getNumCompletionChunks(CXCompletionString completion_string);
21480c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor
21490c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor/**
215012e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \brief Determine the priority of this code completion.
215112e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor *
215212e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * The priority of a code completion indicates how likely it is that this
215312e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * particular completion is the completion that the user will select. The
215412e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * priority is selected by various internal heuristics.
215512e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor *
215612e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \param completion_string The completion string to query.
215712e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor *
215812e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * \returns The priority of this completion string. Smaller values indicate
215912e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor * higher-priority (more likely) completions.
216012e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor */
216112e131385e892e3723483a1081a89bcad29c8a84Douglas GregorCINDEX_LINKAGE unsigned
216212e131385e892e3723483a1081a89bcad29c8a84Douglas Gregorclang_getCompletionPriority(CXCompletionString completion_string);
216312e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor
216412e131385e892e3723483a1081a89bcad29c8a84Douglas Gregor/**
216558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \brief Determine the availability of the entity that this code-completion
216658ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * string refers to.
216758ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor *
216858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \param completion_string The completion string to query.
216958ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor *
217058ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor * \returns The availability of the completion string.
217158ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor */
217258ddb60f409125eda5436c4a1f070f7fa4744295Douglas GregorCINDEX_LINKAGE enum CXAvailabilityKind
217358ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregorclang_getCompletionAvailability(CXCompletionString completion_string);
217458ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor
217558ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor/**
2176ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief Contains the results of code-completion.
2177ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor *
2178ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * This data structure contains the results of code completion, as
21791efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * produced by \c clang_codeComplete. Its contents must be freed by
2180ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \c clang_disposeCodeCompleteResults.
2181ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */
2182ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregortypedef struct {
2183ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor  /**
2184ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   * \brief The code-completion results.
2185ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   */
2186ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor  CXCompletionResult *Results;
2187ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor
2188ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor  /**
2189ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   * \brief The number of code-completion results stored in the
2190ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   * \c Results array.
2191ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor   */
2192ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor  unsigned NumResults;
2193ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor} CXCodeCompleteResults;
2194ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor
2195ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor/**
21960c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \brief Perform code completion at a given location in a source file.
21970c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
21980c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * This function performs code completion at a particular file, line, and
21990c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * column within source code, providing results that suggest potential
22000c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code snippets based on the context of the completion. The basic model
22010c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * for code completion is that Clang will parse a complete source file,
22020c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * performing syntax checking up to the location where code-completion has
22030c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * been requested. At that point, a special code-completion token is passed
22040c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * to the parser, which recognizes this token and determines, based on the
22051efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * current location in the C/Objective-C/C++ grammar and the state of
22060c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * semantic analysis, what completions to provide. These completions are
2207ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * returned via a new \c CXCodeCompleteResults structure.
22080c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
22090c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Code completion itself is meant to be triggered by the client when the
22101efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * user types punctuation characters or whitespace, at which point the
22110c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion location will coincide with the cursor. For example, if \c p
22120c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * is a pointer, code-completion might be triggered after the "-" and then
22130c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * after the ">" in \c p->. When the code-completion location is afer the ">",
22140c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the completion results will provide, e.g., the members of the struct that
22150c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * "p" points to. The client is responsible for placing the cursor at the
22160c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * beginning of the token currently being typed, then filtering the results
22170c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * based on the contents of the token. For example, when code-completing for
22180c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the expression \c p->get, the client should provide the location just after
22190c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
22200c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * client can filter the results based on the current token text ("get"), only
22210c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * showing those results that start with "get". The intent of this interface
2222ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * is to separate the relatively high-latency acquisition of code-completion
22230c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * results from the filtering of results on a per-character basis, which must
22240c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * have a lower latency.
22250c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
22260c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param CIdx the \c CXIndex instance that will be used to perform code
22270c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * completion.
22280c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
22298506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * \param source_filename the name of the source file that should be parsed to
22308506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * perform code-completion. This source file must be the same as or include the
22318506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * filename described by \p complete_filename, or no code-completion results
22328506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * will be produced.  NOTE: One can also specify NULL for this argument if the
22338506dde586459887b7e14e23a30af8ac5be5adb6Daniel Dunbar * source file is included in command_line_args.
22340c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
22350c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param num_command_line_args the number of command-line arguments stored in
22360c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \p command_line_args.
22370c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
22380c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param command_line_args the command-line arguments to pass to the Clang
22391efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * compiler to build the given source file. This should include all of the
22400c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * necessary include paths, language-dialect switches, precompiled header
22411efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * includes, etc., but should not include any information specific to
22420c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code completion.
22430c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
2244735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \param num_unsaved_files the number of unsaved file entries in \p
2245735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * unsaved_files.
2246735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor *
2247735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * \param unsaved_files the files that have not yet been saved to disk
2248735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor * but may be required for code completion, including the contents of
2249c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * those files.  The contents and name of these files (as specified by
2250c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * CXUnsavedFile) are copied when necessary, so the client only needs to
2251c6f530defd937faa1c00998e60deea6368526961Ted Kremenek * guarantee their validity until the call to this function returns.
2252735df88a38e80c1ca70daa889aa516b8b9f54b50Douglas Gregor *
22530c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param complete_filename the name of the source file where code completion
22540c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * should be performed. In many cases, this name will be the same as the
22551efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * source filename. However, the completion filename may also be a file
22561efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * included by the source file, which is required when producing
22570c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * code-completion results for a header.
22580c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
22590c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * \param complete_line the line at which code-completion should occur.
22600c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
22611efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar * \param complete_column the column at which code-completion should occur.
22620c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * Note that the column should point just after the syntactic construct that
22630c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor * initiated code completion, and not in the middle of a lexical token.
22640c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor *
2265936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * \param diag_callback callback function that will receive any diagnostics
2266936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * emitted while processing this source file. If NULL, diagnostics will be
2267936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * suppressed.
2268936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor *
2269936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * \param diag_client_data client data that will be passed to the diagnostic
2270936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor * callback function.
2271936ea3b590117d2cd73b1b92621d06c4a7edbe60Douglas Gregor *
2272ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \returns if successful, a new CXCodeCompleteResults structure
2273ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * containing code-completion results, which should eventually be
2274ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * freed with \c clang_disposeCodeCompleteResults(). If code
2275ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * completion fails, returns NULL.
2276ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor */
22771efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE
22781efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
2279ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor                                          const char *source_filename,
22801efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar                                          int num_command_line_args,
2281ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor                                          const char **command_line_args,
2282ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor                                          unsigned num_unsaved_files,
2283ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor                                          struct CXUnsavedFile *unsaved_files,
2284ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor                                          const char *complete_filename,
2285ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor                                          unsigned complete_line,
2286a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                          unsigned complete_column);
22871efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2288ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor/**
2289cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \brief Flags that can be passed to \c clang_codeCompleteAt() to
2290cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * modify its behavior.
2291cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor *
2292cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * The enumerators in this enumeration can be bitwise-OR'd together to
2293cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * provide multiple options to \c clang_codeCompleteAt().
2294cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor */
2295cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregorenum CXCodeComplete_Flags {
2296cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor  /**
2297cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   * \brief Whether to include macros within the set of code
2298cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   * completions returned.
2299cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   */
2300cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor  CXCodeComplete_IncludeMacros = 0x01,
2301cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor
2302cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor  /**
2303cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   * \brief Whether to include code patterns for language constructs
2304cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   * within the set of code completions, e.g., for loops.
2305cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor   */
2306cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor  CXCodeComplete_IncludeCodePatterns = 0x02
2307cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor};
2308cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor
2309cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor/**
2310cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \brief Returns a default set of code-completion options that can be
2311cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * passed to\c clang_codeCompleteAt().
2312cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor */
2313cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas GregorCINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
2314cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor
2315cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor/**
23161abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \brief Perform code completion at a given location in a translation unit.
23171abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
23181abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * This function performs code completion at a particular file, line, and
23191abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * column within source code, providing results that suggest potential
23201abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * code snippets based on the context of the completion. The basic model
23211abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * for code completion is that Clang will parse a complete source file,
23221abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * performing syntax checking up to the location where code-completion has
23231abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * been requested. At that point, a special code-completion token is passed
23241abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * to the parser, which recognizes this token and determines, based on the
23251abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * current location in the C/Objective-C/C++ grammar and the state of
23261abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * semantic analysis, what completions to provide. These completions are
23271abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * returned via a new \c CXCodeCompleteResults structure.
23281abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
23291abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * Code completion itself is meant to be triggered by the client when the
23301abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * user types punctuation characters or whitespace, at which point the
23311abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * code-completion location will coincide with the cursor. For example, if \c p
23321abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * is a pointer, code-completion might be triggered after the "-" and then
23331abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * after the ">" in \c p->. When the code-completion location is afer the ">",
23341abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the completion results will provide, e.g., the members of the struct that
23351abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * "p" points to. The client is responsible for placing the cursor at the
23361abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * beginning of the token currently being typed, then filtering the results
23371abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * based on the contents of the token. For example, when code-completing for
23381abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the expression \c p->get, the client should provide the location just after
23391abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the
23401abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * client can filter the results based on the current token text ("get"), only
23411abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * showing those results that start with "get". The intent of this interface
23421abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * is to separate the relatively high-latency acquisition of code-completion
23431abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * results from the filtering of results on a per-character basis, which must
23441abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * have a lower latency.
23451abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
23461abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param TU The translation unit in which code-completion should
23471abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * occur. The source files for this translation unit need not be
23481abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completely up-to-date (and the contents of those source files may
23491abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * be overridden via \p unsaved_files). Cursors referring into the
23501abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * translation unit may be invalidated by this invocation.
23511abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
23521abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_filename The name of the source file where code
23531abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completion should be performed. This filename may be any file
23541abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * included in the translation unit.
23551abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
23561abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_line The line at which code-completion should occur.
23571abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
23581abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param complete_column The column at which code-completion should occur.
23591abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * Note that the column should point just after the syntactic construct that
23601abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * initiated code completion, and not in the middle of a lexical token.
23611abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
23621abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param unsaved_files the Tiles that have not yet been saved to disk
23631abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * but may be required for parsing or code completion, including the
23641abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * contents of those files.  The contents and name of these files (as
23651abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * specified by CXUnsavedFile) are copied when necessary, so the
23661abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * client only needs to guarantee their validity until the call to
23671abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * this function returns.
23681abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
23691abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \param num_unsaved_files The number of unsaved file entries in \p
23701abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * unsaved_files.
23711abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor *
2372cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \param options Extra options that control the behavior of code
2373cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * completion, expressed as a bitwise OR of the enumerators of the
2374cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * CXCodeComplete_Flags enumeration. The
2375cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * \c clang_defaultCodeCompleteOptions() function returns a default set
2376cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor * of code-completion options.
2377cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor *
23781abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * \returns If successful, a new \c CXCodeCompleteResults structure
23791abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * containing code-completion results, which should eventually be
23801abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * freed with \c clang_disposeCodeCompleteResults(). If code
23811abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor * completion fails, returns NULL.
23821abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor */
23831abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas GregorCINDEX_LINKAGE
23841abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas GregorCXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
23851abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor                                            const char *complete_filename,
23861abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor                                            unsigned complete_line,
23871abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor                                            unsigned complete_column,
23881abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor                                            struct CXUnsavedFile *unsaved_files,
2389cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor                                            unsigned num_unsaved_files,
2390cee235cdf0b8047761ffac598c4c3a32ab7411a2Douglas Gregor                                            unsigned options);
23911abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor
23921abc6bca3d7fb0e7b1e40fbcad6cfb5e10594548Douglas Gregor/**
23931e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \brief Sort the code-completion results in case-insensitive alphabetical
23941e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * order.
23951e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor *
23961e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \param Results The set of results to sort.
23971e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor * \param NumResults The number of results in \p Results.
23981e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor */
23991e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas GregorCINDEX_LINKAGE
24001e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregorvoid clang_sortCodeCompletionResults(CXCompletionResult *Results,
24011e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor                                     unsigned NumResults);
24021e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor
24031e5e6684b0f27701e6f7c65f8c6a32a10cbcc3edDouglas Gregor/**
2404ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregor * \brief Free the given set of code-completion results.
24050c8296dfb495f41d6f0de6fe1d03014ffd063674Douglas Gregor */
24061efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel DunbarCINDEX_LINKAGE
2407ec6762c709726bf2ee5f76c21df81e71a56e6f81Douglas Gregorvoid clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results);
240858ddb60f409125eda5436c4a1f070f7fa4744295Douglas Gregor
240920d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor/**
2410a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Determine the number of diagnostics produced prior to the
2411a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * location where code completion was performed.
2412a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */
2413896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE
2414a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregorunsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results);
2415a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor
2416a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/**
2417a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \brief Retrieve a diagnostic associated with the given code completion.
2418a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor *
2419a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Result the code completion results to query.
2420a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \param Index the zero-based diagnostic number to retrieve.
2421a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor *
2422a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * \returns the requested diagnostic. This diagnostic must be freed
2423a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor * via a call to \c clang_disposeDiagnostic().
2424a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor */
2425896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted KremenekCINDEX_LINKAGE
2426a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas GregorCXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
2427a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor                                             unsigned Index);
2428a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor
2429a88084b78fd4ca5d3d858c14b02414f8cc399f02Douglas Gregor/**
243020d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor * @}
243120d416c36b46dd19ee0b1ea2d0266ae43be86e51Douglas Gregor */
24321efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
24331efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
243404bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek/**
243504bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * \defgroup CINDEX_MISC Miscellaneous utility functions
243604bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek *
243704bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * @{
243804bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek */
243923e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek
244023e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek/**
244123e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek * \brief Return a version string, suitable for showing to a user, but not
244223e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek *        intended to be parsed (the format is not guaranteed to be stable).
244323e1ad09bb68f929212e0ff51206258d06e7f6cfTed Kremenek */
2444a2a9d6e4e5b6001b86b7dfc5db1ea296ce29a3d3Ted KremenekCINDEX_LINKAGE CXString clang_getClangVersion();
244504bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek
244604bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek/**
244716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * \brief Return a version string, suitable for showing to a user, but not
244816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek *        intended to be parsed (the format is not guaranteed to be stable).
244916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek */
2450896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
2451896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek
245216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek /**
2453896b70ffc348f6e2c680b5fb5841984d5785b7b5Ted Kremenek  * \brief Visitor invoked for each file in a translation unit
245416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  *        (used with clang_getInclusions()).
245516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  *
245616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * This visitor function will be invoked by clang_getInclusions() for each
245716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * file included (either at the top-level or by #include directives) within
245816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * a translation unit.  The first argument is the file being included, and
245916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * the second and third arguments provide the inclusion stack.  The
246016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * array is sorted in order of immediate inclusion.  For example,
246116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  * the first element refers to the location that included 'included_file'.
246216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek  */
246316b55a71695a33c094383295cc7b7a2080e098daTed Kremenektypedef void (*CXInclusionVisitor)(CXFile included_file,
246416b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                   CXSourceLocation* inclusion_stack,
246516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                   unsigned include_len,
246616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                   CXClientData client_data);
246716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek
246816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek/**
246916b55a71695a33c094383295cc7b7a2080e098daTed Kremenek * \brief Visit the set of preprocessor inclusions in a translation unit.
247016b55a71695a33c094383295cc7b7a2080e098daTed Kremenek *   The visitor function is called with the provided data for every included
247116b55a71695a33c094383295cc7b7a2080e098daTed Kremenek *   file.  This does not include headers included by the PCH file (unless one
247216b55a71695a33c094383295cc7b7a2080e098daTed Kremenek *   is inspecting the inclusions in the PCH file itself).
247316b55a71695a33c094383295cc7b7a2080e098daTed Kremenek */
247416b55a71695a33c094383295cc7b7a2080e098daTed KremenekCINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
247516b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                        CXInclusionVisitor visitor,
247616b55a71695a33c094383295cc7b7a2080e098daTed Kremenek                                        CXClientData client_data);
247716b55a71695a33c094383295cc7b7a2080e098daTed Kremenek
247816b55a71695a33c094383295cc7b7a2080e098daTed Kremenek/**
247904bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek * @}
248004bb716aea8fd2372ac10b0c640cabc5e5caa615Ted Kremenek */
24811efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2482c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor/**
2483c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor * @}
2484c42fefa51f7555bb3644a7cde2ca4bfd0d848d74Douglas Gregor */
24851efcf3d137c11fb6b21c385911e0d2ca59ca94c3Daniel Dunbar
2486d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#ifdef __cplusplus
2487d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek}
2488d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif
2489d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek#endif
2490d2fa56687f8bd5ac6ebf9d9468d0efd714986a54Ted Kremenek
2491