Граф коммитов

293 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 0268810a46 Introduce a new code-completion context for a parenthesized
expression, e.g., after the '(' that could also be a type cast. Here,
we provide types as code-completion results in C/Objective-C (C++
already had them), although we wouldn't in a normal expression context.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113904 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-14 23:59:36 +00:00
Douglas Gregor 424668cc90 The two libclang crash-recovery tests that involve precompiled
preambles end up leaving the precompiled preambles around. This is by
design, since we do minimal cleanup during crash recovery. However,
it's unfortunate for testing, so introduce a hook that allows these
two tests to put the precompiled preamble somewhere where we can
delete them after testing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113698 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-11 18:05:19 +00:00
Douglas Gregor 2cd4fd4b75 If we fail to create a temporary file for the precompiled preamble,
just abort creation of the precompiled preamble rather than doing
silly things. This is the second part of the fix for the weird
preamble-related failures on Windows. Big thanks to Francois Pichet
for the great detective work!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113697 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-11 17:56:52 +00:00
Douglas Gregor c6cb2b02f0 Tweak GetPreamblePCHPath() to more closely match the behavior of the
Windows GetTempPath() function, and be sure to create the directory in
which the precompiled preamble will reside before creating the
temporary file itself.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113695 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-11 17:51:16 +00:00
Douglas Gregor 1a480c403a Suggest "const" and "volatile" code completions after a function
declarator, the very definition of "low-hanging fruit".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112274 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-27 17:35:51 +00:00
Douglas Gregor 458433d2f0 Implement code completion for @selector expressions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112186 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 15:07:07 +00:00
Douglas Gregor 1e5e6684b0 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112180 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 13:48:20 +00:00
Daniel Dunbar 1cb237fbf9 Revert r112149, "Move the sorting of code-completion results out of the main
path and ...", it is failing tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112161 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 03:53:50 +00:00
Douglas Gregor be13afea6d 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112149 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 02:23:45 +00:00
Douglas Gregor 9214819c7d 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?


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112121 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 00:30:24 +00:00
Douglas Gregor c7ed372ec7 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112095 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 22:15:42 +00:00
Douglas Gregor 721f359a35 When combining the code-completion results from Sema long with the
code-completion results cached by ASTUnit, sort the resulting result
set. This makes testing far, far easier, so this commit also includes
tests for the previous few fixes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112070 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 18:41:16 +00:00
Douglas Gregor 59a66946aa Add a missing case
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112065 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 18:04:30 +00:00
Douglas Gregor c9c29a8d7a Fix an off-by-one error when computing the precompiled preamble for
code completion. We were allowing the preamble to include the line
that we're code-completing on. Again, testcase is forthcoming.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112064 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 18:04:15 +00:00
Douglas Gregor 4125c37c71 Make the cursor kind of macro-name-only completions produced by
ASTUnit match those produced directly by code completion. Test case is
forthcoming.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112063 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 18:03:13 +00:00
John McCall 0a2c5e256a Teach Sema to live without CodeCompleteConsumer.h.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112028 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 06:19:51 +00:00
Douglas Gregor f29c523308 Implement code completion for preprocessor expressions and in macro
arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111976 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-24 22:20:20 +00:00
Douglas Gregor 1fbb447e9d Implement preprocessor code completion where a macro name is expected,
e.g., after #ifdef/#ifndef or #undef, or inside a defined <macroname>
expression in a preprocessor conditional.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111954 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-24 20:21:13 +00:00
Douglas Gregor 58ddb60f40 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111858 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 23:00:57 +00:00
Douglas Gregor 6d72cbedba Don't include macro results when we're completing a declarator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111830 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 19:33:40 +00:00
Douglas Gregor 2ccccb3ff4 Introduce a new code-completion point when we're parsing a
declarator. Here, we can only see a few things (e.g., cvr-qualifiers,
nested name specifiers) and we do not want to provide other non-macro
completions. Previously, we would end up in recovery mode and would
provide a large number of non-relevant completions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111818 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 18:23:48 +00:00
John McCall 875ab10245 Abstract out member-pointer creation. I'm really unhappy about the current
duplication between the constant and non-constant paths in all of this.

Implement ARM ABI semantics for member pointer constants and conversion.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111772 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 06:43:33 +00:00
Douglas Gregor 2283d79155 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111597 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-20 00:59:43 +00:00
Douglas Gregor f128fed9c2 When we decide not to reuse a precompiled preamble, clear out the
previous precompiled preamble completely. Fixes <rdar://problem/8330950>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111590 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-20 00:02:33 +00:00
Daniel Dunbar c1cf1586f7 Fix a loop overrun in ComputePreamble when the last remapped file was erased,
and reenable crash recovery test.
 - Reparsing is still very crashy / weird, so I had to sprinkle random code into
   the remapped input to get it to do what I want (i.e., crash!).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111550 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 19:40:40 +00:00
Douglas Gregor 671947b18d Plug a leak when precompiling the preamble in ASTUnit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111504 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 01:33:06 +00:00
Douglas Gregor 8b1540c159 Make sure to initialize ASTUnit::UnsafeToFree
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111490 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 00:45:44 +00:00
Sebastian Redl 6ab7cd853e Rename the ASTReader header files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111474 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 23:57:17 +00:00
Sebastian Redl 3c7f413460 More PCH -> AST renaming.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111472 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 23:57:06 +00:00
Sebastian Redl 571db7f0cb Rename various classes from PCH to AST.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111471 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 23:56:56 +00:00
Sebastian Redl c43b54cbc1 Rename PCHReader to ASTReader.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111467 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 23:56:43 +00:00
Sebastian Redl 7faa2ec03a Rename PCHWriter.h to ASTWriter.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111466 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 23:56:37 +00:00
Sebastian Redl a4232eb646 Rename PCHWriter to ASTWriter
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111463 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 23:56:21 +00:00
Douglas Gregor f421089b73 When creating an ASTUnit by parsing source code, set DisableFree to
false (not true), so that the CompilerInstance will actually free data
structures when it's done. This fixes a major leak with libclang's
in-process code completion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111457 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 23:38:21 +00:00
Douglas Gregor bdbb004f38 Simplify the ownership model for DiagnosticClients, which was really
convoluted and a bit leaky. Now, the Diagnostic object owns its
DiagnosticClient.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111437 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 22:29:43 +00:00
Sebastian Redl 857281328f Reintroduce the serialization library, with fixed dependencies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111279 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-17 20:43:28 +00:00
Douglas Gregor 4557e473c9 Revert Sebastian's build-breaking patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111265 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-17 18:31:01 +00:00
Sebastian Redl 93c972945b 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111258 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-17 17:55:49 +00:00
Douglas Gregor 727d93ef49 When the # of top-level declarations changes after reparsing a
translation unit, refresh code-completion results because they've
probably changed. However, enforce a cooldown period between
refreshes, to avoid thrashing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111218 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-17 00:40:40 +00:00
Douglas Gregor 349d38cef0 Move include to the proper place. No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111204 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 23:08:34 +00:00
Douglas Gregor a5fb7c3b56 Implement support for cached code completions for
nested-name-specifiers. Also includes fixes to the generation of
nested-name-specifier result in the non-cached case; we were producing
lame results for namespaces and namespace aliases, which (1) didn't
always have nested-name-specifiers when we want them, and (2) did not
have the necessary "::" as part of the completion.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111203 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 23:05:20 +00:00
Douglas Gregor 5535d5721b Formatting fixes. No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111186 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 21:23:13 +00:00
Douglas Gregor 5f808c2bfe Implement name hiding of cached global code-completion results.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111184 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 21:18:39 +00:00
Douglas Gregor 697ca6dc94 Move some code out-of-line which has long since grown too large to be
inlined. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111176 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 20:01:48 +00:00
Douglas Gregor f5586f6b31 When caching code completions for global declarations, keep track of
the usage type of each declaration result, then compare those types to
the preferred type of the completion. This provides parity in the
priority calculation between the code-completion results produced
directly from Sema and those cached by ASTUnit. 

For the standard Cocoa.h (+ others) example, there's a penalty of 3-4
hundredeths of a second when caching the global results (for ~31,000
results), because we need an ASTContext-agnostic representation of
types for the comparison, and therefore we use... strings. Eventually,
we'd like to implement a more efficient ASTContext-agnostic encoding
of types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111165 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 18:08:11 +00:00
Douglas Gregor c4421e966d Dereferencing NULL pointers is such poor form.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111150 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 16:46:30 +00:00
Douglas Gregor 1827e10051 When caching global completion results, keep track of the simplified
type class, so that we can adjust priorities appropriately when the
preferred type for the context and the actual type of the completion
are similar.

This gets us one step closer to parity of the cached completion
results with the non-cached completion results.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111139 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-16 16:18:59 +00:00
Benjamin Kramer 1395c5d005 Open AST/PCH files in binary mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111106 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-15 16:54:31 +00:00
Douglas Gregor 8071e4212a 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111093 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-15 06:18:01 +00:00
Douglas Gregor 87c08a5d6b 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111051 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-13 22:48:40 +00:00
Douglas Gregor 7ae2faafd3 Implement clang_saveTranslationUnit(), which saves a translation unit
into a PCH/AST file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111006 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-13 05:36:37 +00:00
Douglas Gregor 914ed9d30e Teach ASTUnit to hold on to the Sema object and ASTConsumer that are
used when parsing (or re-parsing) a file. Also, when loading a
precompiled header into ASTUnit, create a Sema object that holds onto
semantic-analysis information.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111003 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-13 03:15:25 +00:00
Sebastian Redl 27372b4f1f Reintroduce the ASTConsumer/ASTUnit fix from r110610, it has nothing to do with the breakage.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110840 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11 18:52:41 +00:00
Douglas Gregor 6bf1830875 Fix a thinko in the creation of temporary files for the precompiled preamble
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110804 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11 13:06:56 +00:00
Douglas Gregor deacbdca55 Speculatively revert r110610 " Make ObjCInterfaceDecl redeclarable,
and create separate decl nodes for forward declarations and the
definition," which appears to be causing significant Objective-C
breakage.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110803 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11 12:19:30 +00:00
Sebastian Redl 74c730ad1f - Make ObjCInterfaceDecl redeclarable, and create separate decl nodes for forward declarations and the definition.
- Eagerly create ObjCInterfaceTypes for declarations.
- The two above changes lead to a 0.5% increase in memory use and no speed regression when parsing Cocoa.h. On the other hand, now chained PCH works when there's a forward declaration in one PCH and the interface definition in another.
- Add HandleInterestingDecl to ASTConsumer. PCHReader passes the "interesting" decls it finds to this function instead of HandleTopLevelDecl. The default implementation forwards to HandleTopLevelDecl, but ASTUnit's handler for example ignores them. This fixes a potential crash when lazy loading of PCH data would cause ASTUnit's "top level" declaration collection to change while being iterated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110610 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-09 21:55:28 +00:00
Douglas Gregor df95a13ec7 Use precompiled preambles for in-process code completion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110596 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-09 20:45:32 +00:00
Sebastian Redl f65339e0f1 Add an environment variable that makes libclang use chaining for PCH.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110414 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-06 00:35:11 +00:00
Douglas Gregor cee235cdf0 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110319 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-05 09:09:23 +00:00
Douglas Gregor b75d3dfa4c 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110216 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-04 17:07:00 +00:00
Douglas Gregor 1abc6bca3d 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).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110210 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-04 16:47:14 +00:00
Douglas Gregor eababfbddb When we try (but fail) to build a precompiled preamble, wait for a
short "cooling off" period (defaulting to 5 reparses) before trying to
build a precompiled preamble again. Previously, if we failed to build
the precompiled preamble at any time, we just gave up the whole
charade any never tried again.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110187 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-04 05:53:38 +00:00
Douglas Gregor eb8837b88c 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110131 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-03 19:06:41 +00:00
Douglas Gregor 1d715ac14b Reshuffle the PCH generator action and consumer, so that we can re-use
it while generating precompiled preambles. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110108 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-03 08:14:03 +00:00
Douglas Gregor c0659ec614 When using a precompiled preamble, save the diagnostics produced when
creating the preamble and "replay" them when reusing the
preamble. Also, fix a thinko in the copying of the preamble when
building the precompiled preamble.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110061 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-02 20:51:39 +00:00
Douglas Gregor cc5888d833 Implement dependency analysis for the precompiled preamble. If any of
the files in the precompiled preamble have changed since it was build,
force the preamble to be rebuilt.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109937 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-31 00:40:00 +00:00
Douglas Gregor 385103b79c Add some timers to ASTUnit that are only enabled when the LIBCLANG_TIMING environment variable is set.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109890 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-30 20:58:08 +00:00
Douglas Gregor fd0b87006b Turn off precompiled preamble support for C++
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109680 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-28 22:12:37 +00:00
Douglas Gregor 28233428da Fix use-after-free with precompiled preambles
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109505 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-27 14:52:07 +00:00
Douglas Gregor fae3b2f474 Implement -fno-validate-pch at the -cc1 level, which suppresses most
of the usual consistency checks used to determine when a precompiled
header is incompatible with the translation unit it's being loaded
into.

Enable this option when loading a precompiled preamble, because the
preamble loader will be performing all of this checking itself. Enable
the preamble-based test now that it's working.

This option is also useful for debugging Clang's PCH
(<rdar://problem/7532213>).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109475 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-27 00:27:13 +00:00
Douglas Gregor f4f6c9db68 Introduce basic support for loading a precompiled preamble while
reparsing an ASTUnit. When saving a preamble, create a buffer larger
than the actual file we're working with but fill everything from the
end of the preamble to the end of the file with spaces (so the lexer
will quickly skip them). When we load the file, create a buffer of the
same size, filling it with the file and then spaces. Then, instruct
the lexer to start lexing after the preamble, therefore continuing the
parse from the spot where the preamble left off.

It's now possible to perform a simple preamble build + parse (+
reparse) with ASTUnit. However, one has to disable a bunch of checking
in the PCH reader to do so. That part isn't committed; it will likely
be handled with some other kind of flag (e.g., -fno-validate-pch).

As part of this, fix some issues with null termination of the memory
buffers created for the preamble; we were trying to explicitly
NULL-terminate them, even though they were also getting implicitly
NULL terminated, leading to excess warnings about NULL characters in
source files.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109445 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-26 21:36:20 +00:00
Douglas Gregor 63fe86bee6 Make ASTContext always use the BumpPtrAllocator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109375 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-25 17:53:33 +00:00
Douglas Gregor 592508ed99 Put a newline at the end of the padded buffers used for the
precompiled preamble. This will suppress the -pedantic "no newline at
end of file" warning.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109301 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-24 00:42:07 +00:00
Douglas Gregor 754f3490c5 Once we've built (or reused) a precompiled preamble, create the
appropriately-padded main file buffer (that has spaces in the extra
"reserved" space) and thread that buffer through to the parsing
function. This still does nothing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109299 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-24 00:38:13 +00:00
Douglas Gregor 175c4a9aa6 Once we've built a precompiled preamble, keep track of the details of
that preamble (the preamble text, preamble file, reserved main file
size). Check these details when we try to rebuild the precompiled
preamble, and when nothing has changed, re-use the precompiled
preamble.

This code is still very much a WIP, and can't even properly be tested
because we have no way to use the precompiled preamble yet. "Trust me"



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109294 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-23 23:58:40 +00:00
Zhongxing Xu ad23ebe22b Fix build on Ubuntu 10.04.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109208 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-23 02:15:08 +00:00
Douglas Gregor 44c181aec3 Basic plumbing for generating a precompiled preamble for an
ASTUnit/CXTranslationUnit. We can't actually use this preamble yet,
however.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109202 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-23 00:33:23 +00:00
Douglas Gregor abc563f554 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108756 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-19 21:46:24 +00:00
Daniel Dunbar 0bbad519aa Driver: Change the driver to take the path to the main executable, instead of
taking it in pieces.
 - Fixes a problem where the Clang executable path was not initialized properly
   on Win32, because sys::Path::getBasename() doesn't do what I always think it
   does. Imagine that, a sys::Path interface that is confusing!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108667 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-19 00:44:04 +00:00
Sebastian Redl cb481aacdc There is another implementation of PCHReaderListener around. Update it to the new interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108377 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-14 23:29:55 +00:00
Charles Davis 98b7c5c496 Add an option to specify the target C++ ABI to the frontend. Use it to
select either the default Itanium ABI or the new, experimental Microsoft ABI.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105804 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11 01:06:47 +00:00
Daniel Dunbar faddc3e53a Frontend: Add FrontendAction support for handling LLVM IR inputs.
- These inputs follow an abbreviated execution path, but are still worth handling by FrontendAction so they reuse all the other clang -cc1 features.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105582 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-07 23:26:47 +00:00
Daniel Dunbar 2056048f0f Frontend: Move some initialization from CompilerInstance to FrontendAction, to parallel what is done for AST inputs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105579 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-07 23:23:50 +00:00
Daniel Dunbar d3598a6571 Frontend: Change FrontendAction::BeginSourceFile to take the input kind instead of an IsAST bool.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105578 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-07 23:23:06 +00:00
Daniel Dunbar c34ce3fa61 Frontend: Lift InputKind enumeration to top level.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105577 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-07 23:22:09 +00:00
Ted Kremenek da5a428bf3 Workaround: Don't add ObjCMethodDecls to the vector of TopLevelDecls since they don't go in
the DeclContext for the translation unit.  This is to workaround a fundamental issue in how
ObjC decls (within an @implementation) are parsed before the ObjCContainerDecl is available.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102944 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-03 20:16:35 +00:00
Dan Gohman cb421fa690 Fix -Wcast-qual warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101786 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 16:39:44 +00:00
Douglas Gregor 28019772db Make Diagnostic reference-counted, which is simpler than juggling
maybe-ownership vs. ownership.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05 23:52:57 +00:00
Douglas Gregor 3687e9d3a5 Clarify the ownership semantics of the Diagnostic object used by
ASTUnit. Previously, we would end up with use-after-free errors
because the Diagnostic object would be creating in one place (say,
CIndex) and its ownership would not be transferred into the
ASTUnit. Fixes <rdar://problem/7818608>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100464 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05 21:10:19 +00:00
Douglas Gregor 405634b215 Minor ASTUnit cleanups:
- Rename "Diagnostics" and related to "StoredDiagnostics", to better
  capture what we're actually storing.
  - Move SourceManager and FileManager to the heap.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100441 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05 18:10:21 +00:00
Daniel Dunbar 5d93ed3c7a Driver: Add support for a CLANGXX_IS_PRODUCTION build variable, which enable
Clang++ support, even in "Production" mode (for testing purposes).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100119 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-01 18:21:41 +00:00
Douglas Gregor 94dc8f640e Optionally store a PreprocessingRecord in the preprocessor itself, and
tie its creation to a CC1 flag -detailed-preprocessing-record.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98963 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 16:15:56 +00:00
Douglas Gregor 4ae8f298b1 Introduce the notion of a "preprocessing record", which keeps track of
the macro definitions and macro instantiations that are found
during preprocessing. Preprocessing records are *not* generated by
default; rather, we provide a PPCallbacks subclass that hooks into the
existing callback mechanism to record this activity.

The only client of preprocessing records is CIndex, which keeps track
of macro definitions and instantations so that they can be exposed via
cursors. At present, only token annotation uses these facilities, and
only for macro instantiations; both will change in the near
future. However, with this change, token annotation properly annotates
macro instantiations that do not produce any tokens and instantiations
of macros that are later undef'd, improving our consistency.

Preprocessing directives that are not macro definitions are still
handled by clang_annotateTokens() via re-lexing, so that we don't have
to track every preprocessing directive in the preprocessing record.

Performance impact of preprocessing records is still TBD, although it
is limited to CIndex and therefore out of the path of the main compiler.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 17:52:52 +00:00
Douglas Gregor 19b43e1ba9 Don't "take" the file manager and source manager when
ASTUnit::LoadFromCompilerInvocation() fails to create target
information.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98697 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-17 00:32:06 +00:00
Douglas Gregor ec1afbfd8e Make sure we actually override ReadHeaderFileInfo when we meant to
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98655 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-16 19:09:18 +00:00
Douglas Gregor f715ca12bf Give SourceManager a Diagnostic object with which to report errors,
and start simplifying the interfaces in SourceManager that can fail.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98594 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-16 00:06:06 +00:00
Douglas Gregor 667514d92a The Windows build is just too weird; there's no real cost to doing the concurrency checks for ASTUnit in all builds
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97840 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 22:19:41 +00:00
Douglas Gregor 12312b807e Switch from NDEBUG to _DEBUG, since our Windows build is funny
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97835 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 21:48:53 +00:00
Douglas Gregor bdf6062bc1 A little hack to identify unwanted concurrency in CIndex
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97831 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05 21:16:25 +00:00
Douglas Gregor c8dfe5ece0 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.). 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97296 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 01:32:48 +00:00
Douglas Gregor 313e26c4e8 Teach ASTUnit to keep track of temporary files, then delete them when
the ASTUnit itself is destroyed. Fixes <rdar://problem/7649385>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96628 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 23:35:40 +00:00
Douglas Gregor a88084b78f 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96592 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 18:08:43 +00:00
Daniel Dunbar b26d483a9f ASTUnit: Constant fold UseBumpAllocator to true, we don't care to support this as an argument.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96316 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 01:55:04 +00:00
Daniel Dunbar f7acc37450 ASTUnit::LoadFromCompilerInvocation - Take ownership of the provided invocation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96315 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 01:54:54 +00:00
Daniel Dunbar 807b06157a ASTUnit: Ensure the CompilerInvocation object used in LoadFromCommandLine is
live as long as the ASTUnit. This is useful for clients which want to maintain
pointers to the LangOptions object which ultimately lives in the
CompilerInvocation, although it would be nice to make all of this ownership
stuff more explicit and obvious.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94924 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 21:47:16 +00:00
Benjamin Kramer 7297c18c84 PCHReader doesn't implement classof so dyn_casting it will do really weird stuff. Use a static_cast instead.
I don't know if this hack is the right fix. Doug, please take a look.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94895 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 16:23:25 +00:00
Daniel Dunbar 3bd54cc562 ASTUnit: Don't check that input files exist when parsing ASTs from the command
line -- they may be remapped (fake) files. This is useful for testing parsing
entirely from memory.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94395 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 00:44:02 +00:00
Douglas Gregor 4db64a461c Extend clang_createTranslationUnitFromSourceFile() to support creating
translation units that include unsaved files.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94258 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 00:14:00 +00:00
Daniel Dunbar 8b9adfea5e Add -resource-dir to clang -cc1, this allows the base directory for compiler
resources (e.g., /usr/lib/clang/1.1) to be passed on the command line instead of
computed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91370 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 00:06:45 +00:00
Daniel Dunbar 869824e879 Lift builtin-include-path logic out of ASTUnit::LoadFromCommandLine and fix CIndex to pass in the right directory (previously it was using the path to the main executable, which generally is wrong).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91238 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-13 03:46:13 +00:00
Daniel Dunbar 1e69fe3a9f CompilerInvocation: Move builtin-include-path logic out of CompilerInvocation::CreateFromArgs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91237 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-13 03:45:58 +00:00
Jeffrey Yasskin e3fdca2ee0 Remove several .c_str() to be forward-compatible with StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90822 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-08 01:46:24 +00:00
Daniel Dunbar f772d1e2a5 ASTUnit/CIndex: Explicitly track the top-level decls when using an ASTUnit made
from a source file.
 - This allows CIndex to avoid iterating over all the top-level decls when using
   a PCH, which means we deserialize far fewer decls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90559 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-04 08:17:33 +00:00
Daniel Dunbar 5262fda30b Fix ASTUnit to allows require a (persistent) Diagnostic object be provided; propogate and simplify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90379 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03 01:45:44 +00:00
Daniel Dunbar c7822dbf3c ASTUnit: Explicitly track whether the ASTUnit came from an actual AST or not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90349 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 21:47:43 +00:00
Daniel Dunbar 68ea2ac7fd ASTUnit: Fix initialization of OnlyLocalDecls variable, and honor UseBumpAllocator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90348 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 21:47:32 +00:00
Daniel Dunbar 68d40e2d16 Fix ASTUnit::getOriginalSourceFileName() when using ASTUnit's derived from
source files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90311 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 08:44:16 +00:00
Daniel Dunbar cb6dda1a7a ASTUnit: Don't create an LLVMContext, it shouldn't be needed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90310 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 08:43:56 +00:00
Daniel Dunbar 7b55668db7 Add ASTUnit::LoadFromCommandLine, which creates an ASTUnit out of a list of
(clang/driver) command line arguments (including the source file).
 - The arguments are expected to include the source file.

 - The idea is that even though this is a somewhat odd API, its the form which
   many tools can most easily use (for example, by interposing with the compiler).

Also, switch index-test's -ast-from-source to use this entry point, and provide
a -arg command line argument which can be used to test that the command line
arguments are handled correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90288 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02 03:23:45 +00:00
Daniel Dunbar 64a32baec6 ASTUnit: Make sure to preserve the TargetInfo for later use.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90263 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01 21:57:33 +00:00
Daniel Dunbar 521bf9c529 Add ASTUnit::LoadFromCompilerInvocation, which does what it says.
Also, add an -ast-from-source option to index-test which allows index-test to
run on source files directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90223 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01 09:51:01 +00:00
Benjamin Kramer bd21828179 Remove VISIBILITY_HIDDEN from anonymous namespaces in libFrontend.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90033 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-28 10:07:24 +00:00
Daniel Dunbar d58c03f42e Add TargetOptions and use it when constructing targets.
- This ended up being hard to factor, sorry for the large diff.

 - Some post-commit cleanup to come.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88833 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-15 06:48:46 +00:00
Daniel Dunbar 7b5a1210d9 Redo how PCH handles its implicit include. Instead of treating this specially in
the front-end (as far as the preprocessor goes), follow the usual logic of
inserting the (original include path) name into the predefines buffer. This
pushes the responsibility for handling this to PCH instead of the front-end.  In
PCH this requires being a little more clever when we diff the predefines
buffers.

Neither of these solutions are particularly great, I think what we eventually
should do is something like gcc where we insert a special marker to indicate the
PCH file, but then run the preprocessor as usual. This would be clearer and
would allow us to drop the overly clever predefines handling.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86806 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 05:29:04 +00:00
Daniel Dunbar dc3c0d2037 StringRefify some PCH interfaces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86775 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 00:52:11 +00:00
Ted Kremenek fc0622155f The constructor for ASTUnit now takes a DiagnosticClient*, allowing uses of ASTUnit to specify
alternate DiagnosticClients. To match this API, ASTUnit::LoadFromPCHFile() now takes a corresponding
DiagnosticClient* argument as well. The DiagnosticClient object is destroyed when the ASTUnit object
is destroyed.

The CIndex library now uses this API to create a 'IgnoreDiagnosticsClient' that simply silences
diagnostics when using the clang_createTranslationUnitFromSourceFile() function. This fixes
<rdar://problem/7312058>. This API can change in the future as we add more flexibility for clients.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84539 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 21:44:57 +00:00
Steve Naroff 36c4464ba6 Move Diagnostic/DiagClient/FileManager from Indexer => ASTUnit.
Removing this shared data should enable clang_createTranslationUnit/clang_createTranslationUnitFromSourceFile to be run from multiple threads (related to <rdar://problem/7303432>).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84499 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 14:34:22 +00:00
Benjamin Kramer 4a630d30cd Use sys::Path::eraseFromDisk instead of unlink as suggested by Chris.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 11:34:14 +00:00
Ted Kremenek 5cf48766d6 Add 'UseBumpPtrAllocator' flag to ASTUnit::LoadFromPCHFile() to cause the created ASTContext to use
its own BumpPtrAllocator to allocate ASTs.

Change clang_createTranslationUnit (CIndex) to pass 'UseBumpPtrAllocator = true' to
ASTUnit::LoadFromPCHFile().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84296 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 00:34:24 +00:00
Douglas Gregor 7d1d49d297 Keep track of whether declararions were loaded from a precompiled
header or not via a new "PCHLevel" field in Decl. We currently use
this information to help CIndex filter out declarations that came from
a precompiled header (rather than from an AST file). Further down the
road, it can be used to help implement multi-level precompiled
headers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84267 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-16 20:01:17 +00:00
Steve Naroff e19944c939 Make sure temporary files get unlinked.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84208 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 22:23:48 +00:00
Daniel Dunbar d5b6126389 Change ASTUnit to only initialize the predefines buffer to the suggested predefines.
- It isn't really clear what to do with the preprocessor here, but this is more sensible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82431 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 03:03:47 +00:00
Daniel Dunbar 31b87d8006 Change ASTUnit to take the Diagnostic as an argument, the client should have control of this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82430 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 03:03:39 +00:00
Mike Stump 1eb4433ac4 Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 15:08:12 +00:00
Steve Naroff 9efa767be8 Implement accessors clang_getCursorKind(), clang_getCursorDecl().
Implement clang_getCursor() - wired up to Argiris's work.
Implement callbacks for CXCursor_ObjCProtocolRef.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81004 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-04 15:44:05 +00:00
Steve Naroff 77accc11f0 Add ASTUnit::getOriginalSourceFileName() and use in clang_getTranslationUnitSpelling().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80932 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 18:19:54 +00:00
Daniel Dunbar bce6f62ae7 Revert "Visit function/method bodies and issue callback for parameters and local
variables.", this is breaking x86_64-apple-darwin10 and Linux tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80896 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 05:59:50 +00:00
Daniel Dunbar cc318939da Revert "Remove redundant local variable (use newly created instance data).", the
previous commit this depends on is breaking x86_64-apple-darwin10 and Linux tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80895 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 05:59:35 +00:00
Steve Naroff bbff6990ac Remove redundant local variable (use newly created instance data).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80861 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 00:43:52 +00:00
Steve Naroff 23d8bea705 Visit function/method bodies and issue callback for parameters and local variables.
Add clang_getTranslationUnitSpelling().



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80859 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-03 00:32:06 +00:00
Argyrios Kyrtzidis 106c9981f1 Handle PCHReader::IgnorePCH, it gets returned for when the file does not exist.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 18:22:30 +00:00
Argyrios Kyrtzidis 4b562cf889 Add the license part to the new source files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73825 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 08:27:14 +00:00
Argyrios Kyrtzidis 0853a02c3b Introduce the ASTUnit class.
ASTUnit is a helper class to allow easy loading of an ASTContext from a PCH file. No users for now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73819 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 08:08:23 +00:00