Commit Graph

1325 Commits

Author SHA1 Message Date
Ted Kremenek 378e93c210 Add source file I meant to include in my previous commit.
llvm-svn: 112303
2010-08-27 21:57:20 +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
Douglas Gregor 9704c75b1f Teach clang_codeComplete to always sort its code-completion results
llvm-svn: 112292
2010-08-27 21:13:41 +00:00
Douglas Gregor 67c692cc3d Implement code completion for @selector expressions
llvm-svn: 112186
2010-08-26 15:07:07 +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
Daniel Dunbar 60e3749181 Revert r112154, "Fix thinko in sorting operation", it depends on r112149 which
doth lay upon the chopping block.

llvm-svn: 112160
2010-08-26 03:53:44 +00:00
Douglas Gregor db967a58eb Fix thinko in sorting operation
llvm-svn: 112154
2010-08-26 02:54:05 +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
Douglas Gregor 1099865124 Revert "Move the sorting of code-completion results out of the main path and
into the clients", because the C standard library sucks. Where's my
stable sort, huh?

llvm-svn: 112121
2010-08-26 00:30:24 +00:00
Ted Kremenek 65b2cc061d When annotating tokens, don't fallback to annotating with a null cursor for cursors that come before a macro instantiation. Fixes <rdar://problem/7974151>.
llvm-svn: 112096
2010-08-25 22:16:02 +00:00
Douglas Gregor ebb7c84891 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.

llvm-svn: 112095
2010-08-25 22:15:42 +00:00
John McCall 276321a9ec Teach Sema to live without CodeCompleteConsumer.h.
llvm-svn: 112028
2010-08-25 06:19:51 +00:00
Ted Kremenek cc7f215872 USRs for class extensions should "mangle" in the location of the extension. (<rdar://problem/8350262>)
llvm-svn: 111991
2010-08-24 23:13:41 +00:00
Peter Collingbourne 85dd0bd18d Move ExecuteCompilerInvocation to a new library FrontendTool
r110903 introduced a dependency from Frontend to every library that
declared an Action by introducing Action references that previously
resided in the driver in the file ExecuteCompilerInvocation.cpp.
This patch moves ExecuteCompilerInvocation to a new library named
FrontendTool which is intended to bear these dependencies.

llvm-svn: 111873
2010-08-24 00:31:22 +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
Daniel Dunbar f10f9bec83 libclang: Print more information when recovering from crashes in
clang_parseTranslationUnit.

llvm-svn: 111855
2010-08-23 22:35:34 +00:00
Eli Friedman 04831926ec Detabify.
llvm-svn: 111768
2010-08-22 01:00:03 +00:00
John McCall 8b0666cf79 Another step in the process of making the parser depend on Sema:
- move DeclSpec &c into the Sema library
  - move ParseAST into the Parse library
Reflect this change in a thousand different includes.
Reflect this change in the link orders.

llvm-svn: 111667
2010-08-20 18:27:03 +00:00
Douglas Gregor b97b666c47 When performing code-completion in the presence of a preamble, make
sure to (1) actually use the remapped files we were given rather
than old data, and (2) keep the remapped files alive until the
code-completion results are destroyed. Big thanks to Daniel for the
test case.

llvm-svn: 111597
2010-08-20 00:59:43 +00:00
Daniel Dunbar 77af1c564e libclang: Execute clang_codeCompleteAt() inside a crash recovery context.
- Test case is disabled for now, because something isn't write with file
   remapping.

llvm-svn: 111581
2010-08-19 23:44:10 +00:00
Daniel Dunbar 186f74215f c-index-test: Diagnose parse / completion failures in -code-completion-at=.
llvm-svn: 111580
2010-08-19 23:44:06 +00:00
Daniel Dunbar ffc11e2a53 c-index-test: As with reparse, only honor remapped false during the code
completion step with -code-completion-at=, to allow testing simulated source
changes.

llvm-svn: 111579
2010-08-19 23:44:04 +00:00
Daniel Dunbar ce26b3ff2b libclang/Darwin: Always set the compatibility version in the dylib.
llvm-svn: 111578
2010-08-19 23:44:02 +00:00
Douglas Gregor 0e3da27c51 Fix a c-index-test leak with file remapping
llvm-svn: 111559
2010-08-19 20:50:29 +00:00
Sebastian Redl d44cd6adba More PCH -> AST renaming.
llvm-svn: 111472
2010-08-18 23:57:06 +00:00
Alexis Hunt dcfba7b35b Generate Attr subclasses with TableGen.
Now all classes derived from Attr are generated from TableGen.
Additionally, Attr* is no longer its own linked list; SmallVectors or
Attr* are used. The accompanying LLVM commit contains the updates to
TableGen necessary for this.

Some other notes about newly-generated attribute classes:

 - The constructor arguments are a SourceLocation and a Context&,
   followed by the attributes arguments in the order that they were
   defined in Attr.td

 - Every argument in Attr.td has an appropriate accessor named getFoo,
   and there are sometimes a few extra ones (such as to get the length
   of a variadic argument).

Additionally, specific_attr_iterator has been introduced, which will
iterate over an AttrVec, but only over attributes of a certain type. It
can be accessed through either Decl::specific_attr_begin/end or
the global functions of the same name.

llvm-svn: 111455
2010-08-18 23:23:40 +00:00
Daniel Dunbar 79acdd9402 libclang: Put clang_reparseTranslationUnit inside a crash recovery context.
llvm-svn: 111451
2010-08-18 23:09:31 +00:00
Daniel Dunbar ec29d712d4 c-index-test: Change -test-load-source-repase to only use remapped files for the
reparse, to allow testing distinct inputs.

llvm-svn: 111448
2010-08-18 23:09:16 +00:00
Douglas Gregor 2dd19f1d5f Simplify the ownership model for DiagnosticClients, which was really
convoluted and a bit leaky. Now, the Diagnostic object owns its
DiagnosticClient.

llvm-svn: 111437
2010-08-18 22:29:43 +00:00
Dan Gohman b37af7de47 Call llvm::remove_fatal_error_handler before deallocating objects
which are used by the error handling functions.

llvm-svn: 111427
2010-08-18 21:23:17 +00:00
Daniel Dunbar 583c3b775e libclang: Put clang_parseTranslationUnit inside a crash recovery context.
llvm-svn: 111387
2010-08-18 18:43:17 +00:00
Daniel Dunbar c91f2fff98 libclang: Implicitly enable crash recovery when using the libclang APIs. We may need to add an explicit API call, but hopefully we can make the crash recovery seamless enough that it doesn't make sense to turn it off.
llvm-svn: 111386
2010-08-18 18:43:14 +00:00
Douglas Gregor b13f5d99af Simplify FixItHint by eliminated the unnecessary InsertionLoc
location. Patch by Eelis van der Weegen!

llvm-svn: 111362
2010-08-18 14:24:02 +00:00
Sebastian Redl 135bcc791b Reintroduce the serialization library, with fixed dependencies.
llvm-svn: 111279
2010-08-17 20:43:28 +00:00
Douglas Gregor 600c4f6d84 Remove the last bit of the Clang Serialization library, for now
llvm-svn: 111267
2010-08-17 19:00:27 +00:00
Douglas Gregor 256a7282e4 Revert Sebastian's build-breaking patch.
llvm-svn: 111265
2010-08-17 18:31:01 +00:00
Dan Gohman b1e20869a2 Add the clangSerialization library to libclang.
llvm-svn: 111261
2010-08-17 18:07:30 +00:00
Sebastian Redl 52ce9bb2fb Create a new Serialization module that contains all the PCH code, and will contain all the module code in the future. Update the Makefiles, CMake projects and the Xcode project. I hope I did everything right for Xcode. No functionality change.
llvm-svn: 111258
2010-08-17 17:55:49 +00:00
Douglas Gregor 3998219789 Extend the code-completion caching infrastructure to include global
declarations (in addition to macros). Each kind of declaration maps to
a certain set of completion contexts, and the ASTUnit completion logic
introduces the completion strings for those declarations if the actual
code-completion occurs in one of the contexts where it matters. 

There are a few new code-completion-context kinds. Without these,
certain completions (e.g., after "using namespace") would need to
suppress all global completions, which would be unfortunate.

Note that we don't get the priorities right for global completions,
because we don't have enough type information. We'll need a way to
compare types in an ASTContext-agnostic way before this can be
implemented.

llvm-svn: 111093
2010-08-15 06:18:01 +00:00
Ted Kremenek aa01481d78 Always recurse into sub-cursors when annotating tokens, as this information is used for annotating macro arguments. This finishes up <rdar://problem/8044584>.
llvm-svn: 111066
2010-08-14 02:50:46 +00:00
Ted Kremenek f4ade0ae3f As a heuristic, annotate tokens (via clang_annotateTokens) that are the arguments of a macro instantiation using the closest cursor with the same spelling location. Because macro arguments can get token pasted in any arbitrary order, we use the annotation map to paper over the token -> cursor annotations during our post-processing stage. This fixes most of <rdar://problem/8044584>, but still doesn't work for assert().
llvm-svn: 111062
2010-08-14 01:14:06 +00:00
Douglas Gregor b14904c4a8 Implement caching of code-completion results for macro definitions
when the CXTranslationUnit_CacheCompletionResults option is given to
clang_parseTranslationUnit(). Essentially, we compute code-completion
results for macro definitions after we have parsed the file, then
store an ASTContext-agnostic version of those results (completion
string, cursor kind, priority, and active contexts) in the
ASTUnit. When performing code completion in that ASTUnit, we splice 
the macro definition results into the results provided by the actual
code-completion (which has had macros turned off) before libclang gets
those results. We use completion context information to only splice in
those results that make sense for that context.

With a completion involving all of the macros from Cocoa.h and a few other
system libraries (totally ~8500 macro definitions) living in a
precompiled header, we get about a 9% performance improvement from
code completion, since we no longer have to deserialize all of the
macro definitions from the precompiled header. 

Note that macro definitions are merely the canary; the cache is
designed to also support other top-level declarations, which should be
a bigger performance win. That optimization will be next.

Note also that there is no mechanism for determining when to throw
away the cache and recompute its contents.

llvm-svn: 111051
2010-08-13 22:48:40 +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
Daniel Dunbar e9e91b0597 Frontend: Move the bulk of the cc1_main() processing into
ExecuteCompilerInvocation in libFrontend.

llvm-svn: 110903
2010-08-12 02:53:12 +00:00
Daniel Dunbar 1cdf04c193 clang -cc1: Move real diagnostics client initialization to earlier.
llvm-svn: 110902
2010-08-12 02:53:07 +00:00
Douglas Gregor 00c37ef021 Once code completion has completed, pass a "completion context" on to
the code-completion consumer. The consumer can use this information to
augument, filter, or display the code-completion results.

llvm-svn: 110858
2010-08-11 21:23:17 +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