Commit Graph

1307 Commits

Author SHA1 Message Date
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
Douglas Gregor e68aaca766 Teach the libclang cursor visitor to walk into the type information
provided by __builtin_types_compatible_p and __builtin_va_arg
expressions, now that Abramo has added proper type-source information
to those expressions.

llvm-svn: 110681
2010-08-10 15:02:34 +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
Daniel Dunbar 8a37147ce2 Fix mixed declarations and code warning.
llvm-svn: 110602
2010-08-09 21:06:06 +00:00
Douglas Gregor 8ef4c807a1 Minor libclang tweaks
llvm-svn: 110599
2010-08-09 21:00:09 +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 efcc6da97d Don't pass -avoid-version to Darwin linker
llvm-svn: 110438
2010-08-06 11:08:45 +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 d8a5dba9c2 When performing in-process code completion, don't free the remapped
file buffers until the code completion results are destroyed;
diagnostics may end up referring into the source.

llvm-svn: 110216
2010-08-04 17:07:00 +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
Douglas Gregor e9db88f991 When using a precompiled preamble, keep track of the top-level
declarations that we saw when creating the precompiled preamble, and
provide those declarations in addition to the declarations parsed in
the main source file when traversing top-level declarations. This
makes the use of precompiled preambles a pure optimization, rather
than changing the semantics of the parsed translation unit.

llvm-svn: 110131
2010-08-03 19:06:41 +00:00
Douglas Gregor b1cf1ca19a Add Darwin dylib versioning support to libclang when build with CMake.
llvm-svn: 110062
2010-08-02 20:52:32 +00:00
Daniel Dunbar 2be96746b4 Frontend: Change PluginASTAction::ParseArgs to take a CompilerInstance object
for use in reporting diagnostics.
 - We don't want to use the Action's own CompilerInstance, because that is only
   initialized during file processing and I like that invariant.

Also, if ParseArgs returns false then abandon execution.

Also, remove unused PluginASTAction::PrintHelp virtual method.

llvm-svn: 110039
2010-08-02 15:31:28 +00:00
Daniel Dunbar 88979914d7 Driver: Keep track of a separate "install dir", which is the path where clang
was invoked from (which may not be where the executable itself is).
 - This allows having e.g., /Developer/usr/bin/clang be a symlink to some other
   location, while still making sure the Driver finds 'as', 'ld', etc. relative
   to itself.

llvm-svn: 109989
2010-08-01 22:29:51 +00:00
Daniel Dunbar 5863fa5215 Simplify.
llvm-svn: 109988
2010-08-01 22:29:47 +00:00
Daniel Dunbar b6ab76b82f build: Don't pass -avoid-version or -no-undefined on Darwin, they don't do
anything.

llvm-svn: 109958
2010-07-31 21:33:01 +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
Benjamin Kramer 4b5de0d6a3 Prepare for upcoming ownership change.
llvm-svn: 109766
2010-07-29 17:48:03 +00:00
Ted Kremenek 1e589f2124 Check for an invalid SourceLocation in clang_getCursor(). This avoids a possible assertion failure in SourceManager in the call to Lexer::GetBeginningOfToken(). Fixes <rdar://problem/8244873>.
llvm-svn: 109713
2010-07-29 00:52:07 +00:00