Commit Graph

328 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 2cb4e3c554 [libclang]
-Allow cursor visitation of an attribute using its source range
-Add C++ 'final' and 'override' attributes as cursor kinds
-Simplify the logic that marks 'final' and 'override' attributes as tokens.

llvm-svn: 139609
2011-09-13 17:39:31 +00:00
Chandler Carruth 4aa01ef19c Update libclang to have APIs corresponding to the new 'expansion' naming
system for macro-backed source locations. The old APIs are preserved for
legacy users.

This was intended to land with the main work of instantiation ->
expansion, but despite running it by Doug over a month ago, I forgot to
commit it. Very sorry for that...

llvm-svn: 138860
2011-08-31 16:53:37 +00:00
Douglas Gregor 2ed0ee1ace Eliminate the -chained-pch flag and all of the frontend and libclang options associated with it. Chained PCH is the only way to build a PCH file that includes another PCH file
llvm-svn: 138597
2011-08-25 22:54:01 +00:00
Douglas Gregor 3f35bb2d15 Add a new libclang API to return a CXCompletionString for an arbitrary
cursor, from Connor Wakamo! Addresses <rdar://problem/9087798>.

llvm-svn: 136911
2011-08-04 20:04:59 +00:00
Ted Kremenek fbcce6fba3 clang_getCXTUResourceUsage: report memory used by HeaderSearch.
This required converting the StringMaps to use a BumpPtrAllocator.  I measured the
compile time and saw no observable regression.

llvm-svn: 136190
2011-07-26 23:46:11 +00:00
Ted Kremenek 120992ad81 clang_getCXTUResourceUsage: Report memory used by data structures in SourceManager.
llvm-svn: 136189
2011-07-26 23:46:06 +00:00
Douglas Gregor ea777403f9 Add new libclang API, clang_codeCompleteGetObjCSelector(), which
provides the partial Objective-C selector used in a code
completion. From Connor Wakamo!

llvm-svn: 136084
2011-07-26 15:24:30 +00:00
Francois Pichet ece689f336 Fix the MSVC build. 2 problems:
- buildPieces was return a C++ object from inside an extern "C". (MSVC didn't like that)
   - clang_getCursorReferenceNameRange was missing a CINDEX_LINKAGE causing a link error.

llvm-svn: 135983
2011-07-25 22:00:44 +00:00
Douglas Gregor c1679ecf3b Added clang_getCursorReferenceNameRange to libclang to to retrieve parts of
a cursor reference, from Erik Verbruggen!

llvm-svn: 135920
2011-07-25 17:48:11 +00:00
Douglas Gregor 757e38b47e Extend libclang with clang_equalRanges, from Erik Verbruggen!
llvm-svn: 135860
2011-07-23 19:35:14 +00:00
Douglas Gregor 63745d5935 New libclang API to expose container type for code completion, from
Connor Wakamo!

llvm-svn: 135651
2011-07-21 01:05:26 +00:00
Chandler Carruth 6d900dff2d Clean up some comments I missed when switching from
NestedMacroInstantiations -> NestedMacroExpansions.

With this change, libclang should be completely converted except for
uses of SourceManger and SourceLocation APIs, and the C bindings for
those APIs.

llvm-svn: 135149
2011-07-14 16:08:00 +00:00
Chandler Carruth de81fc8557 NestedMacroInstantiations -> NestedMacroExpansions
This is switches all the interfaces points (and most of the commenst
/ local variables I saw on my way through) regarding the
NestedMacroInstantiations bit.

The libclang enums corresponding to this state were renamed, but
a legacy enum was added with the old name, and the same value to keep
existing clients working. I've added a documentation blurb for it, but
let me know if there is a canonical way to document legacy elemenst of
the libclang interface.

No functionality changed here, even in tests.

llvm-svn: 135141
2011-07-14 09:02:10 +00:00
Chandler Carruth 9e4704ab07 Update all of the libclang code corresponding to the preprocessor
MacroInstantiation -> MacroExpansion rename. Internally, everything is
switched.

Introduce a new cursor kind enum with the new name, but retain the old
name as an alias so that we don't break backwards compatibility.

Also update the debug printing routine to use 'macro expansions' as its
explicitly not guaranteed to be stable, and mechanically switch the test
cases over to that.

llvm-svn: 135140
2011-07-14 08:41:15 +00:00
Argyrios Kyrtzidis f89cc69eac [arcmt] Move the remapping functions to clang-c/Index.h and change 'arcmt_' prefix to 'clang_'.
llvm-svn: 134916
2011-07-11 20:15:00 +00:00
Douglas Gregor 2132584d36 Introduce a new libclang aPI function,
clang_codeCompleteGetContexts(), that provides the client with
information about the context in which code completion has occurred
and what kinds of entities make sense as completions at that
point. Patch by Connor Wakamo!

llvm-svn: 134615
2011-07-07 16:03:39 +00:00
Douglas Gregor 30c80fa3eb libclang: Allow callers of clang_saveTranslationUnit() to distinguish
between different classes of errors. Addresses most of
<rdar://problem/9660328>.

llvm-svn: 134495
2011-07-06 16:43:36 +00:00
Douglas Gregor a98034a25e Improve the Python bindings for libclang in a few ways, from Eli
Bendersky. Specifically: 

* Implemented a new function in libclang: clang_isAttribute

* Fixing TranslationUnit.get_includes to only go through the argument
* buffer when it contains something. This fixed a crash on Windows 

* clang_getFileName returns CXString, not char*. Made appropriate
* fixes in cindex.py - now the relevant tests pass and we can see the
* full locations correctly again (previously there was garbage in
* place of the file name) 
* Exposed clang_getCursorDisplayName to the python bindings

llvm-svn: 134460
2011-07-06 03:00:34 +00:00
Douglas Gregor 4cd65962dc Expose @synthesize and @dynamic via their own cursor kinds in
libclang. Fixes <rdar://problem/9537904>.

llvm-svn: 132603
2011-06-03 23:08:58 +00:00
Douglas Gregor 9519d92ef6 Add clang_CXXMethod_isVirtual() to libclang, from Erik Verbruggen!
llvm-svn: 131230
2011-05-12 15:17:24 +00:00
Douglas Gregor 998caead70 Introduce a new libclang parsing flag,
CXTranslationUnit_NestedMacroInstantiations, which indicates whether
we want to see "nested" macro instantiations (e.g., those that occur
inside other macro instantiations) within the detailed preprocessing
record. Many clients (e.g., those that only care about visible tokens)
don't care about this information, and in code that uses preprocessor
metaprogramming, this information can have a very high cost.

Addresses <rdar://problem/9389320>.

llvm-svn: 130990
2011-05-06 16:33:08 +00:00
Ted Kremenek 2160a0d3d7 Enhance clang_getCXTUResourceUsage() to return the amount of memory used by the Preprocessor's bump allocator as well as those from the PreprocessingRecord.
llvm-svn: 130823
2011-05-04 01:38:46 +00:00
Douglas Gregor 37aa4938c8 Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),
which determines whether a particular file is actually a header that
is intended to be guarded from multiple inclusions within the same
translation unit.

llvm-svn: 130808
2011-05-04 00:14:37 +00:00
Ted Kremenek 5e1ed7b8dd Enhance clang_getCXTUResourceUsage() to report the sizes of the memory buffers used by PCH.
llvm-svn: 130460
2011-04-28 23:46:20 +00:00
Ted Kremenek 8d58790019 Enhance clang_getCXTUResourceUsage() to report how much memory is used by SourceManager's memory buffers.
llvm-svn: 130433
2011-04-28 20:36:42 +00:00
Ted Kremenek f5df0ce949 Enhance clang_getCXTUResourceUsage() to report the amount of memory used by ASTContext's side tables.
llvm-svn: 130383
2011-04-28 04:53:38 +00:00
Ted Kremenek 21735e608d Enhance clang_getCXTUResourceUsage() to report the amount of memory used by SourceManager's content cache allocator.
llvm-svn: 130380
2011-04-28 04:10:31 +00:00
Ted Kremenek 23324124e4 Rename 'CXTUMemoryUsage…' to 'CXTUResourceUsage…'.
llvm-svn: 129857
2011-04-20 16:41:07 +00:00
Ted Kremenek 11d1a42e84 Report memory usage for global code completion results in CXTUMemoryUsage.
llvm-svn: 129733
2011-04-18 23:42:53 +00:00
Ted Kremenek 83f642e54a Add libclang API to query how much memory is used by a CXTranslationUnit. This is a WIP. Currently we report
the amount used for expressions, types, identifiers, and selectors.

llvm-svn: 129730
2011-04-18 22:47:10 +00:00
Richard Smith dda56e4b4a Support for C++11 (non-template) alias declarations.
llvm-svn: 129567
2011-04-15 14:24:37 +00:00
Ted Kremenek 1ec7b33079 Add libclang hook 'clang_toggleCrashRecovery()', which provides a mechanism for a client to enable/disable CrashRecovery within libclang function calls.
llvm-svn: 127920
2011-03-18 23:05:39 +00:00
Douglas Gregor 4a4e0eb782 Mention libclang in the Doxygen documentation
llvm-svn: 126316
2011-02-23 17:45:25 +00:00
Douglas Gregor 56a6380cb7 Add libclang functions to determine the const/volatile/restrict
qualifiers on a CXType. Patch from Stefan Seefeld, test by me.

llvm-svn: 124377
2011-01-27 16:27:11 +00:00
David Chisnall 50e4ebaeb8 Expose Objective-C type encodings of declarations to libclang users. This also adds a method in ASTContext which encodes FunctionDecls using the same encoding format that is used for Objective-C methods.
llvm-svn: 122639
2010-12-30 14:05:53 +00:00
Douglas Gregor 7ecd19ecde Teach clang_getCursorSemanticParent() and
clang_getCursorLexicalParent() to cope with class and function
templates, along with the parent of the translation unit. Fixes PR8761
and PR8766.

llvm-svn: 122324
2010-12-21 07:55:45 +00:00
Ted Kremenek bbedd062c9 Add new libclang hooks for CXCursorSet, a
DenseMap-backed hashtable for doing client-side
management of CXCursors within a set.

llvm-svn: 121318
2010-12-08 23:43:14 +00:00
Douglas Gregor 06a3f30be9 Implement a simple hash function for libclang cursors
llvm-svn: 119876
2010-11-20 00:09:34 +00:00
Douglas Gregor fec4dc9418 Implement clang_getCanonicalCursor() in libclang, which does the obvious thing.
llvm-svn: 119874
2010-11-19 23:44:15 +00:00
Douglas Gregor a750e8e6d8 Extend the libclang diagnostic API to provide information about the
option name, category ID, and category name corresponding to a diagnostic.

llvm-svn: 119802
2010-11-19 16:18:16 +00:00
Ted Kremenek 7df92ae92b Make definition of CXTranslationUnitImpl private
to libclang.

llvm-svn: 119585
2010-11-17 23:24:11 +00:00
Ted Kremenek 915542850b Change CXTranslationUnit to not directly cast to an ASTUnit*,
but to wrap both an ASTUnit and a "string pool"
that will be used for fast USR generation.

This requires a bunch of mechanical changes, as
there was a ton of code that assumed that CXTranslationUnit
and ASTUnit* were the same.

Along with this change, introduce CXStringBuf,
which provides an llvm::SmallVector<char> backing
for repeatedly generating CXStrings without a huge
amount of malloc() traffic.  This requires making
some changes to the representation of CXString
by renaming a few fields (but keeping the size
of the object the same).

llvm-svn: 119337
2010-11-16 08:15:36 +00:00
Ted Kremenek 4b4f36990d Move CXString creation/management routines into
their own .cpp file and make the interpretation
of its flags private.

llvm-svn: 119319
2010-11-16 01:56:27 +00:00
Douglas Gregor 229bebdeb5 ntroduce clang_getSpellingLocation() into libclang, to provide the
location where we're spelling a token even within a
macro. clang_getInstantiationLocation() tells where we instantiated
the macro.

I'm still not thrilled with the CXSourceLocation/CXSourceRange APIs,
since they gloss over macro-instantiation information.

Take 2: this time, adjusted tests appropriately and used a "simple"
approach to the spelling location.

llvm-svn: 118495
2010-11-09 06:24:54 +00:00
Douglas Gregor 12a610d1fa Revert r118492, which didn't update all of its tests accordingly
llvm-svn: 118494
2010-11-09 05:52:02 +00:00
Douglas Gregor d1ea3f0d29 Introduce clang_getSpellingLocation() into libclang, to provide the
location where we're spelling a token even within a
macro. clang_getInstantiationLocation() tells where we instantiated
the macro.

I'm still not thrilled with the CXSourceLocation/CXSourceRange APIs,
since they gloss over macro-instantiation information.

llvm-svn: 118492
2010-11-09 05:28:47 +00:00
Ted Kremenek bd497244a1 Clean up some of the comments in Index.h (e.g., misnamed or extra parameters in comments).
Patch by Chris Pick!

llvm-svn: 118403
2010-11-08 04:28:51 +00:00
Daniel Dunbar 234206554b libclang: Add clang_executeOnThread, for use in c-index-test (and only there,
preferably). Good thing c-index-test is written in C!!!!

llvm-svn: 118223
2010-11-04 01:26:29 +00:00
David Chisnall b2aa0ef310 Added cursor visitor that takes a block as an argument. Tested compiling
libclang with both clang -fblocks and gcc (no blocks support).  Only exposed in
the header to compilers that do have blocks support.

llvm-svn: 118170
2010-11-03 14:12:26 +00:00
Douglas Gregor f5a1854655 Introduce libclang-level options for C++ precompiled preambles,
separating out chaining precompiled preambles from non-chaining ones.

llvm-svn: 117457
2010-10-27 17:24:53 +00:00
Douglas Gregor 796d76a663 Extend the preprocessing record and libclang with support for
inclusion directives, keeping track of every #include, #import,
etc. in the translation unit. We keep track of the source location and
kind of the inclusion, how the file name was spelled, and the
underlying file to which the inclusion resolved.

llvm-svn: 116952
2010-10-20 22:00:55 +00:00
David Chisnall 2e16ac52e1 Add clang_getLocationForOffset() to libclang, for gives a source location from a character index into a file.
llvm-svn: 116587
2010-10-15 17:07:39 +00:00
Douglas Gregor 6a95802893 Eliminate clang_codeComplete(). libclang clients should be using the
faster, in-process, more-configurable clang_codeCompleteAt(). 

llvm-svn: 116245
2010-10-11 21:51:20 +00:00
Douglas Gregor 7845f1e80e Eliminate clang_setUseExternalASTGeneration() from libclang. Between
improvements to the compiler and the introduction of crash recovery,
it no longer makes sense to allow this mode. Moreover, this eliminates
one use of the "clang" executable from within libclang; we'd like them
all to go away.

llvm-svn: 116207
2010-10-11 16:52:23 +00:00
Douglas Gregor 97c7571ef3 Introduce a new libclang function, clang_getCursorDisplayName(), which
produces a simple "display" name that captures the
arguments/parameters for a function, function template, class
template, or class template specialization.

llvm-svn: 115428
2010-10-02 22:49:11 +00:00
Douglas Gregor 99a26afd49 Extend libclang with an API that determines, given a C++ virtual
member function or an Objective-C method, which other member
functions/methods it overrides.

llvm-svn: 115338
2010-10-01 20:25:15 +00:00
Douglas Gregor 0576ce730a Implement libclang API functions for retrieving the lexical and
semantic parents of the given cursor.

llvm-svn: 114587
2010-09-22 21:22:29 +00:00
Douglas Gregor 16a2bdd6b0 Introduce a new kind of cursor into libclang, which covers a reference
to an "overloaded" set of declarations. This cursor kind works for
unresolved references to functions/templates (e.g., a call within a
template), using declarations, and Objective-C class and protocol
forward declarations.

llvm-svn: 113805
2010-09-13 22:52:57 +00:00
Douglas Gregor a93ab66331 Add libclang support for label statements, gotos, and taking the
address of a label (GNU extension).

llvm-svn: 113564
2010-09-10 00:22:18 +00:00
Douglas Gregor f3af311382 Teach libclang to walk the base and member initializers of a
constructor, in source order. Also introduces a new reference kind for
class members, which is used here (for member initializers) and will
also be used for designated initializers and offsetof.

llvm-svn: 113545
2010-09-09 21:42:20 +00:00
Douglas Gregor d3f48bd3be Introduce a new libclang function,
clang_getSpecializedCursorTemplate(), which determines the template
(or member thereof) that the given cursor specializes or from which it
was instantiated. This routine can be used to establish a link between
templates and their instantiations/specializations.

llvm-svn: 112780
2010-09-02 00:07:54 +00:00
Douglas Gregor a9aa29cf0b Implement libclang support for using declarations. Clang actually uses
three different kinds of AST nodes to represent using declarations:
UsingDecl, UnresolvedUsingValueDecl, and
UnresolvedUsingTypenameDecl. These three are collapsed into a single
cursor kind for using declarations, since libclang clients don't need
the distinction.

Several related changes here:
  - Cursor visitation of the three AST nodes for using declarations
  - Proper source-range computation for these AST nodes
  - Using declarations have no USRs, since they don't actually declare
    any entities.

llvm-svn: 112730
2010-09-01 19:52:22 +00:00
Douglas Gregor 57879faf91 Make it clear that libclang does not modify the command-line arguments
it is given.

llvm-svn: 112717
2010-09-01 16:43:19 +00:00
Douglas Gregor 01a430134f Implement libclang support for using directives (cursor + visitation +
suppressing USRs). Also, fix up the source location information for
using directives so that the declaration location refers to the
namespace name.

llvm-svn: 112693
2010-09-01 03:07:18 +00:00
Douglas Gregor a89314e396 Add libclang support for namespace aliases (visitation + USRs) along
with a new cursor kind for a reference to a namespace. 

There's still some oddities in the source location information for
NamespaceAliasDecl that I'll address with a separate commit, so the
source locations displayed in the load-namespaces.cpp test will
change.

llvm-svn: 112676
2010-08-31 23:48:11 +00:00
Douglas Gregor f11309e194 Add a new libclang function clang_getTemplateCursorKind(), which
determines the kind of declaration that would be generated if the
given template were instantiated. This allows a client to distinguish
among class/struct/union templates and function/member function/static
member function templates.

Also, teach clang_CXXMethod_isStatic() about function templates.

llvm-svn: 112655
2010-08-31 22:12:17 +00:00
Douglas Gregor a23e8f7a0f Extend libclang with a new cursor kind that indicates a reference to a
template. Such cursors occur, for example, in template specialization
types such as vector<int>. Note that we do not handle the
super-interesting case where the template name is unresolved, e.g.,
within a template.

llvm-svn: 112636
2010-08-31 20:37:03 +00:00
Douglas Gregor f96abb293a Add libclang support for class template partial specializations,
including a cursor kind, visitation, and USRs.

llvm-svn: 112629
2010-08-31 19:31:58 +00:00
Douglas Gregor 1fbaeb196b Add a libclang cursor kind, visitation support and USR support for C++
class templates. 

llvm-svn: 112627
2010-08-31 19:02:00 +00:00
Douglas Gregor 713602bb09 Implement basic support for indexing function templates in
libclang. This includes:
  - Cursor kind for function templates, with visitation logic
  - Cursor kinds for template parameters, with visitation logic
  - Visitation logic for template specialization types, qualified type
  locations
  - USR generation for function templates, template specialization
  types, template parameter types.

Also happens to fix PR7804, which I tripped across while testing.

llvm-svn: 112604
2010-08-31 17:01:39 +00:00
Douglas Gregor 12bca22e91 libclang indexing support for C++ constructors, destructors, and
conversion functions. This introduces new cursor kinds for these three
C++ entities, and reworks visitation of function declarations so that
we get type-source information for the names.

llvm-svn: 112600
2010-08-31 14:41:23 +00:00
Ted Kremenek ae9e221513 Implement CXCursor support for walking C++ base specifiers. This includes adding the API hooks clang_isVirtualBase() and clang_getCXXAccessSpecifier() to query properties of the base specifier.
Implements <rdar://problem/8274883>.

llvm-svn: 112296
2010-08-27 21:34:58 +00:00
Ted Kremenek 2c2c5f3789 Fix copy-paste in doxygen comment.
llvm-svn: 112295
2010-08-27 21:34:51 +00:00
Douglas Gregor 49f67ce4b3 Move the sorting of code-completion results out of the main path and
into the clients, e.g., the printing code-completion consumer and
c-index-test. Clients may want to re-sort the results anyway.

Provide a libclang function that sorts the results.

3rd try. How embarrassing.

llvm-svn: 112180
2010-08-26 13:48:20 +00:00
Daniel Dunbar bef185c835 Revert r112149, "Move the sorting of code-completion results out of the main
path and ...", it is failing tests.

llvm-svn: 112161
2010-08-26 03:53:50 +00:00
Douglas Gregor 78ecc499eb Move the sorting of code-completion results out of the main path and
into the clients, e.g., the printing code-completion consumer and
c-index-test. Clients may want to re-sort the results anyway.

Provide a libclang function that sorts the results.

llvm-svn: 112149
2010-08-26 02:23:45 +00:00
Ted Kremenek a594082210 Add libclang API hook "clang_getIBOutletCollectionType" to query the collection type for iboutletcollection attributes.
llvm-svn: 112139
2010-08-26 01:42:22 +00:00
Peter Collingbourne 5caf5af421 Silence warning about C++-style comments.
llvm-svn: 111875
2010-08-24 00:31:37 +00:00
Douglas Gregor f757a12dfc Introduce new libclang API functions that determine the availability
of a cursor or code-completion result, e.g., whether that result
refers to an unavailable, deleted, or deprecated declaration.

llvm-svn: 111858
2010-08-23 23:00:57 +00:00
Douglas Gregor 6bb92ecc0a Add an options parameter to clang_saveTranslationUnit, because we'll want it later
llvm-svn: 111016
2010-08-13 15:35:05 +00:00
Douglas Gregor e938668003 Implement clang_saveTranslationUnit(), which saves a translation unit
into a PCH/AST file.

llvm-svn: 111006
2010-08-13 05:36:37 +00:00
Douglas Gregor de05118c84 Add a (currently unused) "options" parameter to
clang_reparseTranslationUnit(), along with a function to retrieve the
default recommended reparsing options for a translation unit.

Also, add the CXTranslationUnit_CacheCompletionResults flag, which is
also currently unused.

llvm-svn: 110811
2010-08-11 15:58:42 +00:00
Douglas Gregor 4a47bca47d Instead of having a specific CXTranslationUnit_* option flag for
"editing" mode, introduce a separate function
clang_defaultEditingTranslationUnitOptions() that retrieves the set of
options. No functionality change.

llvm-svn: 110613
2010-08-09 22:28:58 +00:00
Douglas Gregor 028d3e4d0f Use precompiled preambles for in-process code completion.
llvm-svn: 110596
2010-08-09 20:45:32 +00:00
Douglas Gregor b68bc59a2d Give clang_codeCompleteAt() an "options" parameter, and add a new
flags enumeration + default-generating function that allows
code-completion to be customized via the libclang API.

Plus, turn on spell-checking when performing code completion.

llvm-svn: 110319
2010-08-05 09:09:23 +00:00
Douglas Gregor 8e984da800 Add code-completion support directly to ASTUnit, which performs code
completion within the translation unit using the same command-line
arguments for parsing the translation unit. Eventually, we'll reuse
the precompiled preamble to improve code-completion performance, and
this also gives us a place to cache results.

Expose this function via the new libclang function
clang_codeCompleteAt(), which performs the code completion within a
CXTranslationUnit. The completion occurs in-process
(clang_codeCompletion() runs code completion out-of-process).

llvm-svn: 110210
2010-08-04 16:47:14 +00:00
Ted Kremenek 0c7476ad59 Add clang_isPODType() for querying if the CXType is POD. Implements <rdar://problem/8250669>.
llvm-svn: 109822
2010-07-30 00:14:11 +00:00
Douglas Gregor be2d8c6096 Basic plumbing for generating a precompiled preamble for an
ASTUnit/CXTranslationUnit. We can't actually use this preamble yet,
however.

llvm-svn: 109202
2010-07-23 00:33:23 +00:00
Douglas Gregor 99d2cf4838 Introduce a new C API function, clang_parseTranslationUnit(), which
will eventually replace
clang_createTranslationUnitFromSourceFile(). The only addition in
clang_parseTranslationUnit() is a set of flags that can control how
the translation unit is loaded. More interesting flags will be coming.

llvm-svn: 109027
2010-07-21 18:52:53 +00:00
Douglas Gregor aa21cc401b Introduce a new libclang API, clang_reparseTranslationUnit(), which
reparses an already-parsed translation unit. At the moment it's just a
convenience function, but we hope to use it for performance
optimizations.

llvm-svn: 108756
2010-07-19 21:46:24 +00:00
Ted Kremenek c62ab8d064 Add CXType support for querying the return type of Objective-C methods. This is done by
adding a clang_getCursorResultType() function (which complements clang_getResultType()).

llvm-svn: 106473
2010-06-21 20:48:56 +00:00
Ted Kremenek c150887fef Add CXType support for FunctionNoProto and FunctionProto types. This includes adding a new
function, clang_getResultType(), which returns the result type of the function type.

llvm-svn: 106459
2010-06-21 20:15:39 +00:00
Ted Kremenek 31729162bc Remove clang_isFromMainFile(). It doesn't work correctly with CXDiagnostics, and we shouldn't
have an API around that cannot be implemented correctly yet.

llvm-svn: 104849
2010-05-27 16:57:42 +00:00
Douglas Gregor a2db793ff0 Introduce priorities into the code-completion results.
llvm-svn: 104751
2010-05-26 22:00:08 +00:00
Ted Kremenek 76a434840a Add libclang function 'clang_isFromMainFile()' (which just wraps SourceManager::isFromMainFile()).
llvm-svn: 104208
2010-05-20 02:59:19 +00:00
Ted Kremenek 08de5c1418 Move CXCursor_FirstDecl definition later to make the results more readable in the debugger.
llvm-svn: 104171
2010-05-19 21:51:10 +00:00
Ted Kremenek 84d2bd759f Remove clang_isDeclarationADefinition() since its functionality is already provided by clang_isCursorDefinition().
llvm-svn: 104138
2010-05-19 18:36:55 +00:00
Ted Kremenek 26bde774df Add clang support for IBOutletCollection.
llvm-svn: 104135
2010-05-19 17:38:06 +00:00
Ted Kremenek a10f12829f Add function 'clang_isTagDeclDefinition()' to allow clients of libclang to distinguish between
forward declarations and definitions of structs/classes/enums.

llvm-svn: 104075
2010-05-18 22:32:15 +00:00
Ted Kremenek 9cfe9e6a4a Add libclang function 'clang_CXXMethod_isStatic' to query of a C++ method
is declared static.

llvm-svn: 103963
2010-05-17 20:06:56 +00:00
Ted Kremenek 6bca984b54 Add CXType and an initial set of supporting functions to libclang. This exposes details of
Clang's representation of the C type system to clients.  It is nowhere near complete, and will
be expanded on demand.

llvm-svn: 103809
2010-05-14 21:29:26 +00:00
Ted Kremenek b80cba5d7d Add CXCursor support for LinkageSpecDecl (e.g., 'extern "C"').
llvm-svn: 103224
2010-05-07 01:04:29 +00:00
Ted Kremenek bd67fb208d Add CXCursor support for C++ namespaces.
llvm-svn: 103211
2010-05-06 23:38:21 +00:00
Ted Kremenek ee457516e6 Make CXLanguage_Invalid the first enum value (with '0' as its value) in CXLanguageKind.
llvm-svn: 101287
2010-04-14 20:58:32 +00:00
Ted Kremenek 225b8e39f1 Add cursor kind for C++ methods.
llvm-svn: 101193
2010-04-13 23:39:06 +00:00
Ted Kremenek 4ed2925b91 Add 'clang_getCursorLanguage' to return the "language" of the AST element (e.g., distinguish between C and Objective-C language features). Currently this only returns results for declarations.
llvm-svn: 101070
2010-04-12 21:22:16 +00:00
Ted Kremenek de24a940a7 Update doxygen comments about lifetime requirements of CXUnsaveFile data arguments.
llvm-svn: 101054
2010-04-12 18:47:26 +00:00
Ted Kremenek 33b9a42f41 Add CIndex support for blocks.
llvm-svn: 100989
2010-04-11 21:47:37 +00:00
Ted Kremenek e184ac5a66 Make the CIndex API more resilient to being used on invalid code.
llvm-svn: 98981
2010-03-19 20:39:03 +00:00
Douglas Gregor 06d6d32762 Expose macro definitions as CIndex cursors. These can still only be
generated by clang_annotateTokens().

llvm-svn: 98837
2010-03-18 18:04:21 +00:00
Douglas Gregor 02ded2a56c More token-annotation experimentation, preprocessing the annotated
token sequence to detect macro instantiations (that produce at least
token). WIP.

llvm-svn: 98826
2010-03-18 15:23:44 +00:00
Douglas Gregor 92a524fd47 Experimental stab at using relexing to identify preprocessor
directives while annotating tokens in CIndex. This functionality
should probably be factored out of this routine, but we're not there
yet. 

llvm-svn: 98786
2010-03-18 00:42:48 +00:00
Ted Kremenek bc1a67bee3 Rename clang_constructUSR_ObjCategory to clang_constructUSR_ObjCCategory.
(there was a missing 'C').

llvm-svn: 98554
2010-03-15 17:38:58 +00:00
Ted Kremenek d071c6019a Implement several CIndex functions for constructing USRs from C-strings instead of AST elements.
llvm-svn: 98421
2010-03-13 02:50:34 +00:00
Ted Kremenek ff9021b675 Implement clang_isUnexposed(), a predicate function to simplify filtering out
unexposed AST elements.

llvm-svn: 97985
2010-03-08 21:17:29 +00:00
Ted Kremenek fb4961dfd0 Add clang_getCursorLinkage(), which returns the
underlying linkage for the entity referred to by a
CXCursor.

llvm-svn: 97646
2010-03-03 06:36:57 +00:00
Douglas Gregor 89a56c561f When given unsaved files in clang_createTranslationUnitFromSourceFile,
copy the source buffers provided rather than referencing them
directly, so that the caller can free those buffers immediately after
calling clang_createTranslationUnitFromSourceFile(). Otherwise, we
risk hitting those buffers later (when building source ranges, forming
diagnostics, etc.). 

llvm-svn: 97296
2010-02-27 01:32:48 +00:00
Douglas Gregor d770f73fac Rework the CIndex API for displaying diagnostics. Instead of printing
the diagnostics to a FILE*, return a CXString containing the formatted
diagnostic.

llvm-svn: 96823
2010-02-22 23:17:23 +00:00
Douglas Gregor 836ec94c8e Simplify the CIndex fix-it API, now that we have half-open CXSourceRanges.
llvm-svn: 96685
2010-02-19 18:16:06 +00:00
Douglas Gregor 1e21cc7d19 Re-apply my diagnostics-capture patch for CIndex, with some tweaks to
try to address the msvc failures.

llvm-svn: 96624
2010-02-18 23:07:20 +00:00
Douglas Gregor 9773e3d077 Revert my CIndex diagnostic changes (r96603, 96606, 96607), which were
breaking the msvc9 builder for unknown reasons.

llvm-svn: 96618
2010-02-18 22:27:07 +00:00
Douglas Gregor 81d53769b5 Introduce debugging/testing hook clang_enableStackTraces() into
CIndex, so that c-index-test to use it to call
lvm::sys::PrintStackTraceOnErrorSignal().

llvm-svn: 96607
2010-02-18 20:22:25 +00:00
Douglas Gregor 707cf72cb8 Resurrect the displayDiagnostics parameter to clang_createIndex(), and
display captured diagnostics when we can't return an invalid
CXTranslationUnit.

llvm-svn: 96606
2010-02-18 20:11:31 +00:00
Douglas Gregor 06dcf0375b Introduce CIndex API functions for displaying a diagnostic, with some
knobs to control formatting. Eventually, I'd like to merge the
implementation of this code with the TextDiagnosticPrinter, so that
it's easy for CIndex clients to produce beautiful diagnostics like the
clang compiler does.

Use this new function to display diagnostics within c-index-test.

llvm-svn: 96603
2010-02-18 19:08:21 +00:00
Douglas Gregor 33cdd81064 Rework how CIndex handles diagnostics. Rather than using a callback,
we attach diagnostics to translation units and code-completion
results, so they can be queried at any time.

To facilitate this, the new StoredDiagnostic class stores a diagnostic
in a serializable/deserializable form, and ASTUnit knows how to
capture diagnostics in this stored form. CIndex's CXDiagnostic is a
thin wrapper around StoredDiagnostic, providing a C interface to
stored or de-serialized diagnostics.

I've XFAIL'd one test case temporarily, because currently we end up
storing diagnostics in an ASTUnit that's never returned to the user
(because it contains errors). I'll introduce a temporary fix for this
soon; the real fix will be to allow us to return and query invalid ASTs.

llvm-svn: 96592
2010-02-18 18:08:43 +00:00
Ted Kremenek bff31437ef Start adding cursor kinds for attributes, with first exposing
IBActionAttr and IBOutletAttr respectively.

llvm-svn: 96563
2010-02-18 03:09:07 +00:00
Daniel Dunbar 4053faef8e Fix comment.
llvm-svn: 96468
2010-02-17 08:07:44 +00:00
Ted Kremenek f602f96e60 Convert clang_getCompletionChunkText() to return a CXString.
llvm-svn: 96439
2010-02-17 01:42:24 +00:00
Ted Kremenek 29004673f7 Change clang_getCursorKindSpelling() to return a CXString
instead of a 'const char *'.

llvm-svn: 96425
2010-02-17 00:41:32 +00:00
Ted Kremenek c560b6835e Change clang_getFileName() to return a 'CXString' instead of 'const char *'.
llvm-svn: 96424
2010-02-17 00:41:20 +00:00
Daniel Dunbar 02968e53cf CIndex: Switch CXSourceRange to proper half-open intervals.
- Doug, please review.

llvm-svn: 96162
2010-02-14 10:02:57 +00:00
Ted Kremenek a3e657064b Make the following functions thread-safe but having them return an std::string that is reconstructed
every time they are called:

getClangRevision()
getClangFullRepositoryVersion()
getClangFullVersion()

llvm-svn: 96033
2010-02-12 22:54:40 +00:00
Douglas Gregor 4b8fd6d3d3 Clean up the CIndex interface to diagnostic ranges. Thanks, Daniel!
llvm-svn: 95602
2010-02-08 23:11:56 +00:00
Douglas Gregor 408bb74ae6 Note that a CXIndex cannot be destroyed until after all of its translation units have been destroyed
llvm-svn: 95598
2010-02-08 23:03:06 +00:00
Douglas Gregor ba965fb2a7 Switch the remaining diagnostic printing in CIndex over to the
diagnostic callback mechanism, so all diagnostics now go through that
callback. Also, eliminate the displayDiagnostics flag to
clang_createIndex(), since it is no longer necessary: the client
determines whether to display diagnostics or not.

llvm-svn: 94714
2010-01-28 00:56:43 +00:00
Douglas Gregor 4f9c376570 Implement a diagnostics callback for the C interface to Clang, so that
clients can format diagnostics as they wish rather than having to
parse standard error. All of the important parts of the front end's
diagnostics are exposed: text, severity, location, source ranges, and
fix-its. The diagnostics callback is now available with
clang_createTranslationUnitFromSource() and
clang_createTranslationUnit().

As part of this change, CXSourceLocation and CXSourceRange got one
pointer larger, since we need to hold on to the SourceManager and
LangOptions structures in the source location. This is the minimum
amount of information needed for the functions that operate on source
locations and ranges (as implemented now). Previously we held on to
the ASTContext, but the diagnostics callback can end up with source
locations when there is no ASTContext (or preprocessor).

Still to do:
  - Code completion needs to support the diagnostics callback, once we
  have the ability to (de-)serialize diagnostics.
  - Eliminate the "displayDiagnostics" argument to createIndex; we'll
  always pass diagnostics to the callback and let it deal with display.

llvm-svn: 94709
2010-01-28 00:27:43 +00:00
Ted Kremenek 0b86e3a72d Implement 'clang_getInclusions()' in CIndex. This API allows clients to walk the set of files included in a translation unit via the C API.
llvm-svn: 94575
2010-01-26 19:31:51 +00:00
Douglas Gregor 9bd6db5834 Eliminate clang_getInstantiationLocationOffset(), and instead add an
offset parameter to clang_getInstantiationLocation(). 

llvm-svn: 94573
2010-01-26 19:19:08 +00:00
Douglas Gregor 6165611986 Implement clang_annotateTokens(), which associates cursors with each
of the tokens within a raw token stream. This does not even attempt to
handle macros yet.

llvm-svn: 94561
2010-01-26 18:31:56 +00:00
Douglas Gregor 27b4fa994d Introduce a CIndex API for lexing the raw tokens within a given source
range. The token-annotation function does nothing, yet.

llvm-svn: 94551
2010-01-26 17:06:03 +00:00
Douglas Gregor 47751d6c21 Introduce clang_getInstantiationLocationOffset(), which decomposes a
source location in file + offset.

llvm-svn: 94497
2010-01-26 03:07:15 +00:00
Daniel Dunbar d01592617f Update comment.
llvm-svn: 94393
2010-01-25 00:43:14 +00:00
Daniel Dunbar b9999fdc67 Tweak clang_visitChildren comment.
llvm-svn: 94360
2010-01-24 04:10:31 +00:00
Daniel Dunbar 62ebf25f44 Index.h: Tweak comments, delete trailing whitespace, fix a few typos, etc.
llvm-svn: 94351
2010-01-24 02:54:26 +00:00
Ted Kremenek 3e315a28b1 Add doxygen comment to clang_getClangVersion().
llvm-svn: 94311
2010-01-23 17:51:23 +00:00
Douglas Gregor aa98ed9a07 Extend clang_createTranslationUnitFromSourceFile() to support creating
translation units that include unsaved files.

llvm-svn: 94258
2010-01-23 00:14:00 +00:00
Ted Kremenek c0f3f72fa4 Add 'clang_getClangVersion()' function to CIndex. This exposes the full Clang version string through the CIndex API.
llvm-svn: 94242
2010-01-22 22:44:15 +00:00
Douglas Gregor 6007cf2e9e Improve content and structure of the Doxygen documentation for the
CIndex API. No functionality change.

llvm-svn: 94234
2010-01-22 22:29:16 +00:00
Douglas Gregor 816fd36316 Yet more CIndex API cleanup:
- Added more routines to manipulate/compare source locations and ranges
  - Switched clang_getCursor() over to take a CXSourceLocation rather
  than file/line/column.

llvm-svn: 94226
2010-01-22 21:44:22 +00:00
Douglas Gregor 93f899509d Introduce type references into the C API, capturing references to
typedefs only (for now).

llvm-svn: 94078
2010-01-21 16:28:34 +00:00