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

293 Коммитов

Автор SHA1 Сообщение Дата
Ted Kremenek b547eebdff Use CrashRecoveryContextCleanup objects to recover an ASTUnit if we crash in ASTUnit::LoadFromCommandLine() and ASTUnit::LoadFromCompilerInvocation().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127851 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-18 02:06:56 +00:00
Argyrios Kyrtzidis b0f4b9a558 Introduce '-chain-include' option to specify headers that will be converted to chained PCHs in memory
without having to use multiple runs and intermediate files.

Intended for testing & debugging of chained PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127339 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-09 17:21:42 +00:00
Argyrios Kyrtzidis 299a4a967b Add 'OverridenFilesKeepOriginalName' field in SourceManager which if true the SourceManager
should report the original file name for contents of files that were overriden by other files,
otherwise it should report the name of the new file. Default is true.

Also add similar field in PreprocessorOptions and pass similar parameter in ASTUnit::LoadFromCommandLine.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127289 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-08 23:35:24 +00:00
Argyrios Kyrtzidis 4e03c2b9d7 Allow passing '-###' to ASTUnit::LoadFromCommandLine to print out the cc1 options.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127183 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-07 22:45:01 +00:00
Argyrios Kyrtzidis b1c86492f9 Currently we can only remap a file by creating a MemoryBuffer and replacing the file contents with it.
Allow remapping a file by specifying another filename whose contents should be loaded if the original
file gets loaded. This allows to override files without having to create & load buffers in advance.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127052 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-05 01:03:53 +00:00
Argyrios Kyrtzidis 15727ddb11 Introduce OwnsRemappedFileBuffers field in ASTUnit, indicating whether the ASTUnit should delete the remapped buffers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127051 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-05 01:03:48 +00:00
Nick Lewycky 277a6e7525 Preserve what the user passed to -include when emitting .d files. Fixes PR8974!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126334 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-23 21:16:44 +00:00
Douglas Gregor 5c722c7020 When code-completing a case statement for a switch on a value of
enumeration type, prioritize the enumeration constants and don't
provide completions for any other expressions. Fixes <rdar://problem/7283668>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125991 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-18 23:30:37 +00:00
Douglas Gregor 48601b3232 Teach the CXCodeCompleteResults results structure, which stores
code-completion results accessed via libclang, to extend the lifetime
of the allocator used for cached global code-completion results at
least until these completion results are destroyed. Fixes
<rdar://problem/8997369>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125678 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 19:08:06 +00:00
Douglas Gregor 9b7db6200d Improve the invalidation logic for the cache of global code
completions. We now compute a hash of the names of all top-level
declarations and macro definitions, and invalidate the cache when the
hash value changes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125670 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 18:16:54 +00:00
Argyrios Kyrtzidis 8e3df4d086 Allow resolving headers from a PCH even after headers+PCH were moved to another path.
Store in PCH the directory that the PCH was originally created in.
If a header file is not found at the path that we expect it to be and the PCH file
was moved from its original location, try to resolve the file by assuming that
header+PCH were moved together and the header is in the same place relative to the PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 17:54:22 +00:00
Douglas Gregor 0a480293f7 Rename the operation that loads a preprocessed entity from a given offset to indicate that we're loading from an offset, not an index, lest one be confused. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125394 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-11 19:46:30 +00:00
Douglas Gregor 8ef6c8cb6c Improve our uniquing of file entries when files are re-saved or are
overridden via remapping. Thus, when we create a "virtual" file in the
file manager, we still stat() the real file that lives behind it so
that we can provide proper uniquing based on inodes. This helps keep
the file manager much more consistent.

To take advantage of this when reparsing files in libclang, we disable
the use of the stat() cache when reparsing or performing code
completion, since the stat() cache is very likely to be out of date in
this use case.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124971 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-05 19:42:43 +00:00
Douglas Gregor dae6875750 Create a special allocator class for code completion, so that all of
the string copying goes through a single place that can have
associated state.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124698 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-01 22:57:45 +00:00
Douglas Gregor 218937c13e Allocate CodeCompletionString and all of its components in a
BumpPtrAllocator, rather than manually new/delete'ing them. This
optimization also allows us to avoid allocating memory for and copying
constant strings (e.g., "return", "class").

This also required embedding the priority and availability of results
within the code completion string, to avoid extra memory allocation
within libclang.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124673 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-01 19:23:04 +00:00
Douglas Gregor 1aa27307c4 Teach ASTUnit to save the specified target features, since
TargetInfo::CreateTargetInfo() mangles the target options in a way
that is not idempotent. Fixes <rdar://problem/8807535>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124382 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 18:02:58 +00:00
Douglas Gregor 0b53cf8343 Don't silently drop warning flags passed in to
clang_createTranslationUnitFromSourceFile().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123793 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-19 01:02:47 +00:00
Douglas Gregor d64f4c1402 Gather cached code completions after the first reparse, not after the
second reparse.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121413 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-09 21:27:43 +00:00
Douglas Gregor 1fd9e0def6 Use atomic operations for libclang's object count tracking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121073 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 00:05:48 +00:00
Douglas Gregor 89d9980bbc When using a precompiled preamble with detailed preprocessing records,
trap the serialized preprocessing records (macro definitions, macro
instantiations, macro definitions) from the generation of the
precompiled preamble, then replay those when walking the list of
preprocessed entities. This eliminates a bug where clang_getCursor()
wasn't able to find preprocessed-entity cursors in the preamble.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120396 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 06:16:57 +00:00
Michael J. Spencer 03013fa9a0 Merge System into Support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120297 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-29 18:12:39 +00:00
Douglas Gregor 7f946ad408 When performing code completion within ASTUnit, allocate the AugmentedCodeCompleteConsumer on the heap, so it's always cleaned up properly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120290 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-29 16:13:56 +00:00
Chris Lattner 75dfb65c38 tidy up. Split FileManager::getBufferForFile into
two copies, since they are fundamentally different
operations and the StringRef one should go away
(it shouldn't be part of FileManager at least).

Remove some dead arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120013 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-23 09:19:42 +00:00
Chris Lattner 39b49bcaad now the FileManager has a FileSystemOpts ivar, stop threading
FileSystemOpts through a ton of apis, simplifying a lot of code.
This also fixes a latent bug in ASTUnit where it would invoke
methods on FileManager without creating one in some code paths
in cindextext.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120010 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-23 08:35:12 +00:00
Chris Lattner 7ad97ffa63 give FileManager a 'FileSystemOptions' ivar, which will be used
to simplify a bunch of code in it.  It should ultimately get inlined
into FileManager.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120007 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-23 07:51:02 +00:00
Chris Lattner 151466a186 Partially revert Doug's PCH validation patch (r98585).
This patch completely defeated the "passing in a prestat'd size 
to MemoryBuffer" optimization, leading to an extra fstat call for
every buffer opened, in order to find out if the datestamp and size 
of the file on disk matches what is in the stat cache.

I fully admit that I don't completely understand what is going on here:
why punish code when a stat cache isn't in use?  what is the point of a
stat cache if you have to turn around and stat stuff to validate it?

To resolve both these issues, just drop the modtime check and check the
file size, which is the important thing anyway.  This should also resolve
PR6812, because presumably windows is stable when it comes to file sizes.
If the modtime is actually important, we should get it and keep it on the
first stat.

This eliminates 833 fstat syscalls when processing Cocoa.h, speeding up
system time on -Eonly Cocoa.h  from 0.041 to 0.038s.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120001 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-23 06:09:11 +00:00
Argyrios Kyrtzidis f2224d89a6 Since multiple diagnostics can share one diagnostic client, have the client keeping track
of the total number of warnings/errors reported.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119731 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-18 20:06:46 +00:00
Douglas Gregor e3c60a7ce9 Fix source-range information for Objective-C properties. Previously,
we were just getting a range covering only the property name, which is
certainly not correct (and broke token annotation, among other
things). 

Also, teach libclang about the relationship between
@synthesize/@dynamic and @property, so we get property name and
cursor-reference information for @synthesize and @dynamic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119409 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-17 00:13:31 +00:00
Douglas Gregor 73fc91275a Use an OwningPtr for the preamble buffer in ASTUnit. This plugs a leak
where we failed to free this buffer along one of the paths, and
detangles the code a little.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119379 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-16 20:45:51 +00:00
Douglas Gregor 08bb4c622d Tweak libclang's heuristics for building precompiled preambles and
caching global code-completion results. In particular, don't perform
either operation the first time we parse, but do both after the first
reparse. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119285 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-15 23:00:34 +00:00
Douglas Gregor e47be3e968 Improve ASTUnit's capture of diagnostics so that the
diagnostic-capturing client lives as long as the ASTUnit itself
does. Otherwise, we can end up with crashes when we get a diagnostic
outside of parsing/code completion. The circumstances under which this
happen are really hard to reproduce, because a file needs to change
from under us.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118751 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-11 00:39:14 +00:00
Benjamin Kramer edfb7ecea0 Simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118619 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-09 20:00:56 +00:00
Ted Kremenek c198f6170f Change the StringSet used by CalculateHiddenNames() to use a BumpPtrAllocator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118372 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-07 06:11:36 +00:00
Argyrios Kyrtzidis 389db16c63 Implement -working-directory.
When -working-directory is passed in command line, file paths are resolved relative to the specified directory.
This helps both when using libclang (where we can't require the user to actually change the working directory)
and to help reproduce test cases when the reproduction work comes along.

--FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains
 the working directory value if set).
--FileSystemOptions are passed around to various interfaces that perform file operations.
--Opening & reading the content of files should be done only through FileManager. This is useful in general since
 file operations will be abstracted in the future for the reproduction mechanism.

FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same
FileManager but with different FileSystemOptions.

Addresses rdar://8583824.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118203 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-03 22:45:23 +00:00
Douglas Gregor 9dba61a1e4 Disable some timing code
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117910 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-01 13:48:43 +00:00
Douglas Gregor 213f18b3d6 Simplify ASTUnit's internal timers, by not trying to keep a pile of
timers to be dumped whenever the ASTUnit is destroyed. Instead, just
print the time elapsed for each operation after we perform the
operation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117550 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-28 15:44:59 +00:00
Douglas Gregor 99ba202f65 Introduce libclang-level options for C++ precompiled preambles,
separating out chaining precompiled preambles from non-chaining ones.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117457 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-27 17:24:53 +00:00
Douglas Gregor d54eb44103 Parse default arguments within member functions in source order, from
Manuel Klimek! Fixes PR7715.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116311 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-12 16:25:54 +00:00
Douglas Gregor 4cd912aa94 When we load an ASTUnit from command-line arguments, hold on to the
diagnostics produced by the driver itself. Previously, we were
allowing these to either be dropped or to slip through to stderr.

Fixes <rdar://problem/7595339>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116285 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-12 00:50:20 +00:00
Douglas Gregor 32be4a588f Switch c-index-test from clang_codeComplete() over to
clang_codeCompleteAt(). This uncovered a few issues with the latter:

  - ASTUnit wasn't saving/restoring diagnostic state appropriately between
    reparses and code completions.
  - "Overload" completions weren't being passed through to the client



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116241 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-11 21:37:58 +00:00
Douglas Gregor aa3e6babe6 Fix three related, wily issues with the recompilation of precompiled
preambles:

  - When we rebuild a precompiled preamble, make sure to disable
    skipping anything in the main file; we may have had leftover
    preamble-skipping values in the lexer, which leads to very empty
    preamble. This is a correctness issue.

  - When we rebuild a precompiled preamble, clear out any prior state
    in the Diagnostic object. Otherwise, we might think that there
    were errors when we were building the preamble itself, and
    therefore reject the resulting preamble. This is mainly a
    performance issue.

  - Don't remove old remappings when digging out the remapping for the
    main file. Having the old mappings around does not hurt in the
    common case (later remappings will just overwrite them), and is
    important when we fail to find a preamble: we don't want to have
    removed the remapping, because we'll need it later.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116041 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-08 04:03:57 +00:00
Douglas Gregor 3552f66f8a Don't force spell checking when code-completing. Let the client decide
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115931 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-07 18:03:24 +00:00
Douglas Gregor 37cf66350c Fix a double-free error that can occur in rare cases where loading
of the precompiled preamble (or any PCH file it depends on) fails
during reparsing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115838 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-06 21:11:08 +00:00
Sebastian Redl 1d9f1fe717 Give every file that ASTReader loads a type: module, PCH, precompiled preamble or main file. Base Decls' PCHLevel on this to make it more sane.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115626 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-05 16:15:19 +00:00
Douglas Gregor 85e5191934 Enable chained precompiled headers for use with precompiled preambles
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115260 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-01 01:05:22 +00:00
Douglas Gregor 06e5044620 Remove libclang logging code
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-27 16:43:25 +00:00
Douglas Gregor 76dc8890b6 When setting the globally-visible declarations for a particular
identifier, we may have a Sema object but no translation unit scope
(because parsing is finished). In this case, we still need to update
the IdResolver, which might still be used when writing a PCH
containing another PCH (without chaining). This bug manifested as a
failure with precompiled preambles.

Also, add a little environment-variable-sensitive logging for
libclang.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114774 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-24 23:29:12 +00:00
Douglas Gregor 8c8d5412cd Teach libclang to enable multithreading in LLVM, since libclang clients are likely to be multithreaded. Also move the printing of timers to somewhere better for multithreaded libclang clients
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114760 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-24 21:18:36 +00:00
Douglas Gregor 52779fb717 Synchronize globally-cached code completion results with the results
provided when the optimization is disabled. In particular, split
the completion context CCC_Other into two contexts: CCC_Other, which
means that it's an undisclosed context for which any other results are
unwelcome, and CCC_Recovery, which is used in recovery cases.

Since we're now using the completion context within the completion
results builder, make sure that it's always set to something.

Fixes <rdar://problem/8470644>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114704 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-23 23:01:17 +00:00
Douglas Gregor b05496dbd6 Tweak priorities for some types and macros:
- In Objective-C, we prefer BOOL to bool for historic reasons;
  slightly penalize "bool".
  - Treat Nil macro as a NULL pointer constant.
  - Treat YES, NO, true, and false macros as constants.
  - Treat the bool macro as a type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114356 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-20 21:11:48 +00:00
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