History log of /external/clang/lib/Serialization/ASTReader.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ef8225444452a1486bd721f3285301fe84643b00 21-Jul-2014 Stephen Hines <srhines@google.com> Update Clang for rebase to r212749.

This also fixes a small issue with arm_neon.h not being generated always.

Includes a cherry-pick of:
r213450 - fixes mac-specific header issue
r213126 - removes a default -Bsymbolic on Android

Change-Id: I2a790a0f5d3b2aab11de596fc3a74e7cbc99081d
6bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89 29-May-2014 Stephen Hines <srhines@google.com> Update Clang for 3.5 rebase (r209713).

Change-Id: I8c9133b0f8f776dc915f270b60f94962e771bc83
651f13cea278ec967336033dd032faef0e9fc2ec 24-Apr-2014 Stephen Hines <srhines@google.com> Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
86250895597e288c86ef08c2e824956ea9835fed 04-Nov-2013 Dmitri Gribenko <gribozavr@gmail.com> Include non-explicit submodules in exported module list

This change fixes Richard's testcase for r193815. Now we include non-explicit
submodules into the list of exports.

The test failed previously because:
- recursive_visibility_a1.inner is not imported (only recursive_visibility_a1 is),
- thus the 'inner' submodule is not showing up in any of the import lists,
- and because of this getExportedModules() is not returning the
correct module set -- it only considers modules that are imported.

The fix is to make Module::getExportedModules() include non-explicit submodules
into the list of exports.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194018 91177308-0d34-0410-b5e6-96231b3b80d8
5794b53ad5b38b53c9eaf3a172354e63081ceb2f 28-Oct-2013 Richard Smith <richard-llvm@metafoo.co.uk> Allow a new syntax in a module requires-declaration:

requires ! feature

The purpose of this is to allow (for instance) the module map for /usr/include
to exclude <tgmath.h> and <complex.h> when building in C++ (these headers are
instead provided by the C++ standard library in this case, and the glibc C
<tgmath.h> header would otherwise try to include <complex.h>, resulting in a
module cycle).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193549 91177308-0d34-0410-b5e6-96231b3b80d8
87bcee88d9b49de8214aa23d07c96f7bec3198e0 19-Oct-2013 Rafael Espindola <rafael.espindola@gmail.com> Simplify some implementations of get*Decl.

* NamedDecl and CXXMethodDecl were missing getMostRecentDecl.
* The const version can just forward to the non const.
* getMostRecentDecl can use cast instead of cast_or_null.

This then removes some casts from the callers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193039 91177308-0d34-0410-b5e6-96231b3b80d8
9b6711873cbba149dd50cedcfdf31f9dd254df50 18-Oct-2013 Richard Smith <richard-llvm@metafoo.co.uk> C++ modules: don't lose track of a 'namespace std' that is imported from a module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192951 91177308-0d34-0410-b5e6-96231b3b80d8
3c40a28aa3dde7c5f7e1520c32e7515eda830fef 18-Oct-2013 Richard Smith <richard-llvm@metafoo.co.uk> Basic ODR checking for C++ modules:

If we have multiple definitions of the same entity from different modules, we
nominate the first definition which we see as being the canonical definition.
If we load a declaration from a different definition and we can't find a
corresponding declaration in the canonical definition, issue a diagnostic.

This is insufficient to prevent things from going horribly wrong in all cases
-- we might be in the middle of emitting IR for a function when we trigger some
deserialization and discover that it refers to an incoherent piece of the AST,
by which point it's probably too late to bail out -- but we'll at least produce
a diagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192950 91177308-0d34-0410-b5e6-96231b3b80d8
ddd2dfc1d3f4a36cbe8cd775c588623a17049f9f 24-Sep-2013 Daniel Jasper <djasper@google.com> Module use declarations (II)

Review: http://llvm-reviews.chandlerc.com/D1546.

I have picked up this patch form Lawrence
(http://llvm-reviews.chandlerc.com/D1063) and did a few changes.

From the original change description (updated as appropriate):
This patch adds a check that ensures that modules only use modules they
have so declared. To this end, it adds a statement on intended module
use to the module.map grammar:

use module-id

A module can then only use headers from other modules if it 'uses' them.
This enforcement is off by default, but may be turned on with the new
option -fmodules-decluse.

When enforcing the module semantics, we also need to consider a source
file part of a module. This is achieved with a compiler option


The compiler at present only applies restrictions to the module directly
being built.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191283 91177308-0d34-0410-b5e6-96231b3b80d8
c2d775714f79af977672e4f1dbc16ee9e02d1dea 30-Aug-2013 Richard Smith <richard-llvm@metafoo.co.uk> Don't eagerly load all conversion operators when loading a class declaration
from a PCH/module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189646 91177308-0d34-0410-b5e6-96231b3b80d8
344472ebeded2fca2ed5013b9e87f81d09bfa908 23-Aug-2013 Robert Wilhelm <robert.wilhelm@gmx.net> Use pop_back_val() instead of both back() and pop_back().
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189112 91177308-0d34-0410-b5e6-96231b3b80d8
152b4e4652baedfceba1cd8115515629225e713f 22-Aug-2013 Manuel Klimek <klimek@google.com> Revert "Implement a rudimentary form of generic lambdas."

This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189004 91177308-0d34-0410-b5e6-96231b3b80d8
ecb5819a9e64fb654d46a3b270a286cc570c58ff 22-Aug-2013 Faisal Vali <faisalv@yahoo.com> Implement a rudimentary form of generic lambdas.

Specifically, the following features are not included in this commit:
- any sort of capturing within generic lambdas
- nested lambdas
- conversion operator for captureless lambdas
- ensuring all visitors are generic lambda aware

As an example of what compiles:

template <class F1, class F2>
struct overload : F1, F2 {
using F1::operator();
using F2::operator();
overload(F1 f1, F2 f2) : F1(f1), F2(f2) { }

auto Recursive = [](auto Self, auto h, auto ... rest) {
return 1 + Self(Self, rest...);
auto Base = [](auto Self, auto h) {
return 1;
overload<decltype(Base), decltype(Recursive)> O(Base, Recursive);
int num_params = O(O, 5, 3, "abc", 3.14, 'a');

Please see attached tests for more examples.

Some implementation notes:

- Add a new Declarator context => LambdaExprParameterContext to
clang::Declarator to allow the use of 'auto' in declaring generic
lambda parameters

- Augment AutoType's constructor (similar to how variadic
template-type-parameters ala TemplateTypeParmDecl are implemented) to
accept an IsParameterPack to encode a generic lambda parameter pack.

- Add various helpers to CXXRecordDecl to facilitate identifying
and querying a closure class

- LambdaScopeInfo (which maintains the current lambda's Sema state)
was augmented to house the current depth of the template being
parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth)
so that Sema::ActOnLambdaAutoParameter may use it to create the
appropriate list of corresponding TemplateTypeParmDecl for each
auto parameter identified within the generic lambda (also stored
within the current LambdaScopeInfo). Additionally,
a TemplateParameterList data-member was added to hold the invented
TemplateParameterList AST node which will be much more useful
once we teach TreeTransform how to transform generic lambdas.

- SemaLambda.h was added to hold some common lambda utility
functions (this file is likely to grow ...)

- Teach Sema::ActOnStartOfFunctionDef to check whether it
is being called to instantiate a generic lambda's call
operator, and if so, push an appropriately prepared
LambdaScopeInfo object on the stack.

- Teach Sema::ActOnStartOfLambdaDefinition to set the
return type of a lambda without a trailing return type
to 'auto' in C++1y mode, and teach the return type
deduction machinery in SemaStmt.cpp to process either
C++11 and C++14 lambda's correctly depending on the flag.

- various tests were added - but much more will be needed.

A greatful thanks to all reviewers including Eli Friedman,
James Dennett and the ever illuminating Richard Smith. And
yet I am certain that I have allowed unidentified bugs to creep in;
bugs, that I will do my best to slay, once identified!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188977 91177308-0d34-0410-b5e6-96231b3b80d8
c1cef0892e049fcd31084f02d1efdd9985d4dfa4 10-Aug-2013 Enea Zaffanella <zaffanella@cs.unipr.it> Added source locs for angled parentheses in class/var template partial specs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188134 91177308-0d34-0410-b5e6-96231b3b80d8
ac32d9044b9c1e7492cef929a322d23ce899d276 07-Aug-2013 Richard Smith <richard-llvm@metafoo.co.uk> PR9992: Serialize and deserialize the token sequence for a function template in
-fdelayed-template-parsing mode. Patch by Will Wilson!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187916 91177308-0d34-0410-b5e6-96231b3b80d8
afb90df95223a2b48f22a3d950328d1d915691f5 31-Jul-2013 Richard Smith <richard-llvm@metafoo.co.uk> Fix read of uninitialized enum value in test, caught by UBSan. No functionality
change, other than removal of undefined behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187465 91177308-0d34-0410-b5e6-96231b3b80d8
6b9240e058bf3451685df73fc8ce181b3046e92b 05-Jul-2013 Craig Topper <craig.topper@gmail.com> Use SmallVectorImpl& for function arguments instead of SmallVector.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185715 91177308-0d34-0410-b5e6-96231b3b80d8
8ae63875f4b078f5303ca7a19cba82fbc8a603c2 05-Jul-2013 Craig Topper <craig.topper@gmail.com> Use typedef for Densemap contraining SmallVector passed to a function to avoid repeating SmallVector size.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185683 91177308-0d34-0410-b5e6-96231b3b80d8
ee0a47998ca7db5d31291a397aca38219d3dfd7d 05-Jul-2013 Craig Topper <craig.topper@gmail.com> Add typedefs for Densemaps containing SmallVectors to avoid repeating the SmallVector size when creating iterators for the DenseMap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185682 91177308-0d34-0410-b5e6-96231b3b80d8
12df246d6dea2ee1f92c186f922f1afcf499647a 24-Jun-2013 Reid Kleckner <reid@kleckner.net> [AST] Introduce a new DecayedType sugar node

The goal of this sugar node is to be able to look at an arbitrary
FunctionType and tell if any of the parameters were decayed from an
array or function type. Ultimately this is necessary to implement
Microsoft's C++ name mangling scheme, which mangles decayed arrays
differently from normal pointers.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1014

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184763 91177308-0d34-0410-b5e6-96231b3b80d8
bc3f628815b3841dc99109e7f67f9afa7793bc94 20-Jun-2013 Lawrence Crowl <crowl@google.com> This patch adds new private headers to the module map. Private
headers may be included from within the module, but not from outside
the module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184471 91177308-0d34-0410-b5e6-96231b3b80d8
f9dbae754bba75df78b8e73ab35d04134c1fed17 08-Jun-2013 Douglas Gregor <dgregor@apple.com> Loosen r178109 even further, to assume that all redefined macros in system headers and system modules are equivalent.

Fixes <rdar://problem/14025673>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183588 91177308-0d34-0410-b5e6-96231b3b80d8
f8f480ff1cba08ce7e93160546168f729c95804c 31-May-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Fix crash with valid code, related to anonymous field initializers.

In a certain code-path we were not deserializing an anonymous field initializer correctly,
leading to a crash when trying to IRGen it.

This is a simpler version of a patch by Yunzhong Gao!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182974 91177308-0d34-0410-b5e6-96231b3b80d8
3b7deda7137e62810a810ce25b062927a9fc7c71 24-May-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [modules] If we hit a failure while loading a PCH/module, abort parsing instead of trying to continue in an invalid state.

Also don't let libclang create a PCH with such an error.

Fixes rdar://13953768

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182629 91177308-0d34-0410-b5e6-96231b3b80d8
c1478618363083486679fc8325b88fc30bd5aac7 11-May-2013 Douglas Gregor <dgregor@apple.com> [Modules] When things go horribly wrong when reading a module, point at the module cache.

Sometimes people hack on their system headers. In such cases, they'll
need to delete their module cache, but may not know where it is. Add a
note to show them where it is.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181638 91177308-0d34-0410-b5e6-96231b3b80d8
f9ba851c9b5db8ea30846215e737702a1cc2c194 09-May-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Remove the ASTReaderListener::ReadHeaderFileInfo callback.

This made sense in pre-module era, before merging of HeaderFileInfos was introduced.

Final part of rdar://13840148.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181490 91177308-0d34-0410-b5e6-96231b3b80d8
bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9b 06-May-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> Modify ASTReaderListener to allow visiting the input files of an AST file.

We can pass such an input-file-visiting ASTReaderListener to ASTReader::readASTFileControlBlock.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181238 91177308-0d34-0410-b5e6-96231b3b80d8
aeeacf725c9e0ddd64ea9764bd008e5b6873ce51 03-May-2013 John McCall <rjmccall@apple.com> Move parsing of identifiers in MS-style inline assembly into
the actual parser and support arbitrary id-expressions.

We're actually basically set up to do arbitrary expressions here
if we wanted to.

Assembly operands permit things like A::x to be written regardless
of language mode, which forces us to embellish the evaluation
context logic somewhat. The logic here under template instantiation
is incorrect; we need to preserve the fact that an expression was
unevaluated. Of course, template instantiation in general is fishy
here because we have no way of delaying semantic analysis in the
MC parser. It's all just fishy.

I've also fixed the serialization of MS asm statements.

This commit depends on an LLVM commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180976 91177308-0d34-0410-b5e6-96231b3b80d8
dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998 30-Apr-2013 Richard Smith <richard-llvm@metafoo.co.uk> Don't treat a non-deduced 'auto' type as being type-dependent. Instead, there
are now two distinct canonical 'AutoType's: one is the undeduced 'auto'
placeholder type, and the other is a deduced-but-dependent type. All
deduced-to-a-non-dependent-type cases are still non-canonical.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180789 91177308-0d34-0410-b5e6-96231b3b80d8
65110caf70bc6c07c3bc223acf03643af47a6643 26-Apr-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH/modules] Require the preprocessing record option to match the used PCH, if modules are enabled.

The preprocessing record becomes important when modules are enabled, since it is used to calculate the
module cache hash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180635 91177308-0d34-0410-b5e6-96231b3b80d8
0532df02a72a32a6042e961b71989db73d0d0a22 26-Apr-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Modules] Fix an issue where the reconstructed redeclaration chain was incomplete, missing the definition from a module.

-Make sure that a deserialized external decl gets added to the TU scope.
-When associating an identifier with a set of decls, use the most recent local ones,
if they exist, otherwise associating decls from modules (that came after a local one)
will lead to an incomplete reconstructed re-declaration chain.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180634 91177308-0d34-0410-b5e6-96231b3b80d8
a2c3646c35dd09d21b74826240aa916545b1873f 26-Apr-2013 Richard Smith <richard-llvm@metafoo.co.uk> Implement C++1y decltype(auto).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180610 91177308-0d34-0410-b5e6-96231b3b80d8
87f9d81d0ab806dcf6ca50a0c068dcb2ba7f51b3 18-Apr-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Modules] Use global index to improve typo correction performance

Typo correction for an unqualified name needs to walk through all of the identifier tables of all modules.
When we have a global index, just walk its identifier table only.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179730 91177308-0d34-0410-b5e6-96231b3b80d8
2e3d8c0815acaf1bc5995ebe56cea07471e5c9c7 17-Apr-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> Enhance the ObjC global method pool to record whether there were 0, 1, or >= 2 methods (with a particular selector) inside categories.

This is done by extending ObjCMethodList (which is only used by the global method pool) to have 2 extra bits of information.
We will later take advantage of this info in global method pool for the overridden methods calculation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179652 91177308-0d34-0410-b5e6-96231b3b80d8
7332ae49671762239c9986c8f30f291c3a13d27e 12-Apr-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/13643854> Only emit ambiguous-expansion warnings when at least one of the macro definitions comes from a non-system header.

This slightly weakens the heuristic introduced in r178109.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179411 91177308-0d34-0410-b5e6-96231b3b80d8
6fd7d3067dd06584ef3940e88e31fea1a0e83588 10-Apr-2013 Dmitri Gribenko <gribozavr@gmail.com> Add an option to parse all comments as documentation comments

Patch by Amin Shali.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179180 91177308-0d34-0410-b5e6-96231b3b80d8
4382867f04549f9bfcd33a08342f4f74ab13841c 04-Apr-2013 Richard Smith <richard-llvm@metafoo.co.uk> Pare back r164351 somewhat. The problem that change was addressing was that we
don't serialize a lookup map for the translation unit outside C++ mode, so we
can't tell when lookup within the TU needs to look within modules. Only apply
the fix outside C++ mode, and only to the translation unit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178706 91177308-0d34-0410-b5e6-96231b3b80d8
bd25ff8632e18bb3af761369fd3b0f1b48fdf061 03-Apr-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [preprocessor] Allow comparing two macro definitions syntactically instead of only lexically.

Syntactically means the function macro parameter names do not need to use the same
identifiers in order for the definitions to be considered identical.

Syntactic equivalence is a microsoft extension for macro redefinitions and we'll also
use this kind of comparison to check for ambiguous macros coming from modules.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178671 91177308-0d34-0410-b5e6-96231b3b80d8
c544ba09695e300f31355af342258bd57619e737 27-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/13509689> Introduce -module-file-info option that provides information about a particular module file.

This option can be useful for end users who want to know why they
ended up with a ton of different variants of the "std" module in their
module cache. This problem should go away over time, as we reduce the
need for module variants, but it will never go away entirely.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178148 91177308-0d34-0410-b5e6-96231b3b80d8
52151fd57eaf40603fa8f1cd34dcb4ad5f7701b3 27-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [modules] Before marking the module imported macros as ambiguous, check if this is a case where
the system macro uses a not identical definition compared to a macro from the clang headers.

For example (these come from different modules):
\#define LONG_MAX __LONG_MAX__ (clang's limits.h)
\#define LONG_MAX 0x7fffffffffffffffL (system's limits.h)
in which case don't mark them ambiguous to avoid the "ambiguous macro expansion" warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178109 91177308-0d34-0410-b5e6-96231b3b80d8
89b8f06ed79ddca7f8f8064525781eb3434ac166 27-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH/modules] Remove HiddenName::MacroUndef

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178107 91177308-0d34-0410-b5e6-96231b3b80d8
d560ce3b66325ff22cd3aca23c6de3143bd74d24 27-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Preprocessor] Remove PPMutationListener.

It's not used anymore.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178106 91177308-0d34-0410-b5e6-96231b3b80d8
c56fff7fd231aebf4b152f60f8f11ef91835c48a 26-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Preprocessor/Modules] Separate the macro directives kinds into their own MacroDirective's subclasses.

For each macro directive (define, undefine, visibility) have a separate object that gets chained
to the macro directive history. This has several benefits:

-No need to mutate a MacroDirective when there is a undefine/visibility directive. Stuff like
PPMutationListener become unnecessary.
-No need to keep extra source locations for the undef/visibility locations for the define directive object
(which is the majority of the directives)
-Much easier to hide/unhide a section in the macro directive history.
-Easier to track the effects of the directives across different submodules.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178037 91177308-0d34-0410-b5e6-96231b3b80d8
9317ab94bb68122ba6fc728eb73c1308fb913cd1 22-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH/Modules] De/Serialize MacroInfos separately than MacroDirectives.

-Serialize the macro directives history into its own section
-Get rid of the macro updates section
-When de/serializing an identifier from a module, associate only one macro per
submodule that defined+exported it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177761 91177308-0d34-0410-b5e6-96231b3b80d8
baa74bd3968028d8e5b10ee9b50d0dceb41e85a9 22-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [modules] When a MacroInfo object is deserialized, allocate and store its submodule ID.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177760 91177308-0d34-0410-b5e6-96231b3b80d8
fa69fc19121da3fc5673ccc00d4e8afa5b540a4f 22-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/13479539> Simplify ModuleManager/GlobalModuleIndex interaction to eliminate a pile of extraneous stats().

The refactoring in r177367 introduced a serious performance bug where
the "lazy" resolution of module file names in the global module index
to actual module file entries in the module manager would perform
repeated negative stats(). The new interaction requires the module
manager to inform the global module index when a module file has been
loaded, eliminating the extraneous stat()s and a bunch of bookkeeping
on both sides.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177750 91177308-0d34-0410-b5e6-96231b3b80d8
906d66acc5cf2679453e10a4f0a67feedd765b21 20-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/12368093> Extend module maps with a 'conflict' declaration, and warn when a newly-imported module conflicts with an already-imported module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177577 91177308-0d34-0410-b5e6-96231b3b80d8
970e441671be130c9a12b7eda2a0b795008812a5 20-Mar-2013 Douglas Gregor <dgregor@apple.com> Make sure that Module::ConfigMacrosExhaustive gets initialized and deserialized correctly.

This fixes regressions introduced in r177466 that caused several
module tests to fail sporadically.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177481 91177308-0d34-0410-b5e6-96231b3b80d8
63a726870b486e0470c3a4b11cf62bab8be00b73 20-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/10796651> Introduce configuration macros into module maps.

Configuration macros are macros that are intended to alter how a
module works, such that we need to build different module variants
for different values of these macros. A module can declare its
configuration macros, in which case we will complain if the definition
of a configation macro on the command line (or lack thereof) differs
from the current preprocessor state at the point where the module is
imported. This should eliminate some surprises when enabling modules,
because "#define CONFIG_MACRO ..." followed by "#include
<module/header.h>" would silently ignore the CONFIG_MACRO setting. At
least it will no longer be silent about it.

Configuration macros are eventually intended to help reduce the number
of module variants that need to be built. When the list of
configuration macros for a module is exhaustive, we only need to
consider the settings for those macros when building/finding the
module, which can help isolate modules for various project-specific -D
flags that should never affect how modules are build (but currently do).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177466 91177308-0d34-0410-b5e6-96231b3b80d8
ac39f135ea0d45bc37d1154fa8380d46aac0547d 19-Mar-2013 Douglas Gregor <dgregor@apple.com> Minor optimization to r177367 to treat a module with missing dependencies as out-of-date rather than missing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177369 91177308-0d34-0410-b5e6-96231b3b80d8
677e15ffee2ecc9c1c8f46fd77cab4b5afb59640 19-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/13363214> Eliminate race condition between module rebuild and the global module index.

The global module index was querying the file manager for each of the
module files it knows about at load time, to prune out any out-of-date
information. The file manager would then cache the results of the
stat() falls used to find that module file.

Later, the same translation unit could end up trying to import one of the
module files that had previously been ignored by the module cache, but
after some other Clang instance rebuilt the module file to bring it
up-to-date. The stale stat() results in the file manager would
trigger a second rebuild of the already-up-to-date module, causing
failures down the line.

The global module index now lazily resolves its module file references
to actual AST reader module files only after the module file has been
loaded, eliminating the stat-caching race. Moreover, the AST reader
can communicate to its caller that a module file is missing (rather
than simply being out-of-date), allowing us to simplify the
module-loading logic and allowing the compiler to recover if a
dependent module file ends up getting deleted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177367 91177308-0d34-0410-b5e6-96231b3b80d8
55ea75bf61a5d76f6453513d937944ce68181c6a 13-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Modules] Don't eagerly load and associate all the module header files.

In a module-enabled Cocoa PCH file, we spend a lot of time stat'ing the headers
in order to associate the FileEntries with their modules and support implicit
module import.

Use a more lazy scheme by enhancing HeaderInfoTable to store extra info about
the module that a header belongs to, and associate it with its module only when
there is a request for loading the header info for a particular file.

Part of rdar://13391765

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176976 91177308-0d34-0410-b5e6-96231b3b80d8
c1d22393628a145e54396c0ac66e9625d13a7658 13-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Modules] Resolve top-headers of modules lazily.

This allows resolving top-header filenames of modules to FileEntries when
we need them, not eagerly.

Note that that this breaks ABI for libclang functions
clang_Module_getTopLevelHeader / clang_Module_getNumTopLevelHeaders
but this is fine because they are experimental and not widely used yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176975 91177308-0d34-0410-b5e6-96231b3b80d8
bea522ff43a3f11c7a2bc7949119dbb9fce19e39 08-Mar-2013 Jordan Rose <jordan_rose@apple.com> ArrayRef-ize ASTContext::getFunctionType and Sema::BuildFunctionType.

No (intended) functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176726 91177308-0d34-0410-b5e6-96231b3b80d8
f8f373f47210b88bdf71acb5579b129b665235ab 08-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] When complaining that a header from the PCH was modified, also mention
the filename of the PCH file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176717 91177308-0d34-0410-b5e6-96231b3b80d8
ee2d5fd7a3bd42bce387db094d27a479617c3e67 08-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] Introduce clang_findIncludesInFile, that can be used to retrieve all #import/#include directives in a specific file.

It passes to the visitor, that the caller provides, CXCursor_InclusionDirective cursors for
all the include directives in a particular file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176682 91177308-0d34-0410-b5e6-96231b3b80d8
398253ab0e0dedc6f5ddb1bad2ac6a084d0d88a8 06-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] When pre-validating the headers from the PCH, only validate non-system headers.

Stat'ing all the headers from the PCH to make sure they are up-to-date takes significant time.
In a particular source file (whose PCH file included Cocoa.h) from total -fsyntax-only time
12% was just stat calls. Change pre-validation to only check non-system headers.

There are some notable disadvantages:

-If a system header, that is not include-guarded, changes after the PCH was created, we will not
find it in the header info table and we will #import it, effectively #importing it twice, thus
we will emit some error due to a multiple definition and after that the "header was modified" error will likely
be emitted, for example something like:

NSDictionary.h:12:1: error: duplicate interface definition for class 'NSDictionary'
@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration>
NSDictionary.h:12:12: note: previous definition is here
@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration>
fatal error: file 'NSDictionary.h' has been modified since the precompiled header was built

Though we get the "header was modified" error, this is a bit confusing.

-Theoretically it is possible that such a system header will cause no errors but it will just cause an
unfortunate semantic change, though I find this rather unlikely.

The advantages:

-Reduces compilation time when using a huge PCH like the Cocoa ones
-System headers change very infrequent and when they do, users/build systems should be able to know that
re-building from scratch is needed.

Addresses rdar://13056262

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176567 91177308-0d34-0410-b5e6-96231b3b80d8
ed3802e5da6e7d41975b1cb3d7ae3a3b9e855d10 06-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] For HeaderFileInfoTrait, hash the key using size & time of the file.

Previously the hash would be the filename portion of the path, which could be
different for a filename with different case or a symbolic link with a different
name completely.
This did not actually create any issue so far because by validating all headers
in the PCH we created uniqued FileEntries based on inodes, so an #include of
a symbolic link (refering to a file from the PCH) would end up with a FileEntry
with filename same as the one recorded in the PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176566 91177308-0d34-0410-b5e6-96231b3b80d8
36592b1fa381a978b1b6d4b97c66fb274915fe50 06-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] We don't need to instantiate HeaderFileInfoTrait in ASTReader more than once.

We can just re-use the one from HeaderFileInfoLookupTable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176565 91177308-0d34-0410-b5e6-96231b3b80d8
8bd50b169c567e5da12b1f8e91af4ab3840202f2 06-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Remove a couple of fields from serialization::reader::HeaderFileInfoTrait that are not used for anything.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176564 91177308-0d34-0410-b5e6-96231b3b80d8
1c1508b37bc2a9419b2e22beef9e788eb74203f4 04-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] In HeaderFileInfoTrait::EqualKey(), use FileManager::getFile() to compare two filenames, instead of llvm::sys::fs::equivalent().

llvm::sys::fs::equivalent() does 2 stat calls every time it's called. Use FileManager::getFile() to take advantage
of the stat caching that FileManager is providing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176450 91177308-0d34-0410-b5e6-96231b3b80d8
8504b7b8102a52b2a16231d459fb3cfab4784c38 01-Mar-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Enhance InputFile to also include whether the file is out-of-date.

Previously we would return null for an out-of-date file. This inhibited ASTReader::ReadSLocEntry
from creating a FileID to recover gracefully in such a case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176332 91177308-0d34-0410-b5e6-96231b3b80d8
1ebefc72e80cc880be376a8704e6936d2746cb35 27-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] When deserializing an IdentifierInfo, call IdentifierInfo::RevertTokenIDToIdentifier() only when it's not already an identifier.

Fixes an assertion hit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176148 91177308-0d34-0410-b5e6-96231b3b80d8
0b849d34b3a9574615e98e108db4e8099e9032e0 22-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [preprocessing record] Have the MacroDefinitions map point to the MacroDefinition object instead
its index in the preprocessed entities vector.

This is because the order of the entities in the vector can change in some (uncommon) cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175907 91177308-0d34-0410-b5e6-96231b3b80d8
6ebf09130479bc7605aa09a3e6c4dc2ba3513495 22-Feb-2013 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: add CommentOptions to allow specifying custom comment block commands

Add an ability to specify custom documentation block comment commands via a new
class CommentOptions. The intention is that this class will hold future
customizations for comment parsing, including defining documentation comments
with specific numbers of parameters, etc.

CommentOptions instance is a member of LangOptions.

CommentOptions is controlled by a new command-line parameter

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175892 91177308-0d34-0410-b5e6-96231b3b80d8
dc84cd5efdd3430efb22546b4ac656aa0540b210 20-Feb-2013 David Blaikie <dblaikie@gmail.com> Include llvm::Optional in clang/Basic/LLVM.h

Post-commit CR feedback from Jordan Rose regarding r175594.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175679 91177308-0d34-0410-b5e6-96231b3b80d8
9818a1d443e97677dd3422305de9cc2b1fb2a8c1 20-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [preprocessor] Split the MacroInfo class into two separate concepts, MacroInfo class
for the data specific to a macro definition (e.g. what the tokens are), and
MacroDirective class which encapsulates the changes to the "macro namespace"
(e.g. the location where the macro name became active, the location where it was undefined, etc.)

(A MacroDirective always points to a MacroInfo object.)

Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but
splitting the concepts allows us to better model the effect of modules to the macro namespace
(also as a bonus it allows better modeling of push_macro/pop_macro #pragmas).
Modules can have their own macro history, separate from the local (current translation unit)
macro history; MacroDirectives will be used to model the macro history (changes to macro namespace).

For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created
to indicate that "FOO" became active at the import location. Module "A" itself will contain another
MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives
will point to the same MacroInfo object.

Introducing the separation of macro concepts is the first part towards better modeling of module macros.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175585 91177308-0d34-0410-b5e6-96231b3b80d8
21a0004d80f50808ee343ae70092f6260a4c9477 19-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [modules] Refactor code from ASTReader::makeModuleVisible() into a new function,
Module::getExportedModules() so it can be reused.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175548 91177308-0d34-0410-b5e6-96231b3b80d8
cc9bdcb720931961bac55e321a3e51b9804ca900 19-Feb-2013 Douglas Gregor <dgregor@apple.com> Use MapVector::pop_back() per LLVM r175538.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175539 91177308-0d34-0410-b5e6-96231b3b80d8
aa945900d5438984bdcaac85c4f54868292231f4 18-Feb-2013 Douglas Gregor <dgregor@apple.com> Ensure that the identifier chains have the most recent declaration after module deserialization.

This commit introduces a set of related changes to ensure that the
declaration that shows up in the identifier chain after deserializing
declarations with a given identifier is, in fact, the most recent
declaration. The primary change involves waiting until after we
deserialize and wire up redeclaration chains before updating the
identifier chains. There is a minor optimization in here to avoid
recursively deserializing names as part of looking to see whether
top-level declarations for a given name exist.

A related change that became suddenly more urgent is to property
record a merged declaration when an entity first declared in the
current translation unit is later deserialized from a module (that had
not been loaded at the time of the original declaration). Since we key
off the canonical declaration (which is parsed, not from an AST file)
for emitted redeclarations, we simply record this as a merged
declaration during AST writing and let the readers merge them.

Re-fixes <rdar://problem/13189985>, presumably for good this time.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175447 91177308-0d34-0410-b5e6-96231b3b80d8
7640b02a561fd2b2c58a227b262b0c1ba93622ae 16-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Deserializing the DeclContext of a template parameter is not safe
until recursive loading is finished.

Otherwise we may end up with a template trying to deserialize a template
parameter that is in the process of getting loaded.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175329 91177308-0d34-0410-b5e6-96231b3b80d8
2cbd427ec533f022f612fed0dd93ef5fa214478a 13-Feb-2013 Douglas Gregor <dgregor@apple.com> Order the methods in the global method pool based on when they become visible, not when they become deserialized <rdar://problem/13203033>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175018 91177308-0d34-0410-b5e6-96231b3b80d8
f4e955b694be22926f5ceb41e55d319ce9ff4aab 11-Feb-2013 Douglas Gregor <dgregor@apple.com> [Modules] Cope better with top-level declarations loaded after being declared in the current translation unit <rdar://problem/13189985>.

These two related tweaks to keep the information associated with a
given identifier correct when the identifier has been given some
top-level information (say, a top-level declaration) and more
information is then loaded from a module. The first ensures that an
identifier that was "interesting" before being loaded from an AST is
considered to be different from its on-disk counterpart. Otherwise, we
lose such changes when writing the current translation unit as a

Second, teach the code that injects AST-loaded names into the
identifier chain for name lookup to keep the most recent declaration,
so that we don't end up confusing our declaration chains by having a
different declaration in there.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174895 91177308-0d34-0410-b5e6-96231b3b80d8
21f18c4fda167dc5f72feddbd6a7ac1b63200a0d 07-Feb-2013 Guy Benyei <guy.benyei@intel.com> Add OpenCL samplers as Clang builtin types and check sampler related restrictions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174601 91177308-0d34-0410-b5e6-96231b3b80d8
3646c68676c3c46a026b23d52188ef6e0d856178 07-Feb-2013 Richard Smith <richard-llvm@metafoo.co.uk> Simplify FindExternalVisibleDeclsByName by making it return a bool indicating
if it found any decls, rather than returning a list of found decls. This
removes a returning-ArrayRef-to-deleted-storage bug from
MultiplexExternalSemaSource (in code not exercised by any of the clang
binaries), reduces the work required in the found-no-decls case with PCH, and
importantly removes the need for DeclContext::lookup to be reentrant.

No functionality change intended!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174576 91177308-0d34-0410-b5e6-96231b3b80d8
8bf778eb9c0afb0a4c63a97ce504f50759c08d5f 06-Feb-2013 Douglas Gregor <dgregor@apple.com> Detect when we end up trying to load conflicting module files.

This can happen when one abuses precompiled headers by passing more -D
options when using a precompiled hedaer than when it was built. This
is intentionally permitted by precompiled headers (and is exploited by
some build environments), but causes problems for modules.

First part of <rdar://problem/13165109>, detecting when something when
horribly wrong.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174554 91177308-0d34-0410-b5e6-96231b3b80d8
4fd83a3813fde17d6077bb18363aa4339e38f641 05-Feb-2013 Ted Kremenek <kremenek@apple.com> Remove dead code related to the now defunct PCH stat cache.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174342 91177308-0d34-0410-b5e6-96231b3b80d8
f5cfc89ea46cf20b4d5b5c42568e9ba6a4bbdd80 02-Feb-2013 Douglas Gregor <dgregor@apple.com> Merge "special" types from different modules in the AST reader.

Different modules may have different views of the various "special"
types in the AST, such as the redefinition type for "id". Merge those
types rather than only considering the redefinition types for the
first AST file loaded.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174234 91177308-0d34-0410-b5e6-96231b3b80d8
8b136d85487ec3cc017470d97479159d93a14f91 01-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [modules] Introduce ModuleFile::DirectImportLoc which is the source location
where the module was explicitly or implicitly imported in the local translation unit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174192 91177308-0d34-0410-b5e6-96231b3b80d8
5ebcb20b0331a6e64c213f0bb5f4bed9a9e8eb34 01-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> For ModuleLoader::makeModuleVisible() also pass the source location where the
module import occurred.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174191 91177308-0d34-0410-b5e6-96231b3b80d8
cd0655b17249c4c4908ca91462657f62285017e6 01-Feb-2013 Nick Lewycky <nicholas@mxc.ca> Add a new -Wundefined-inline warning for inline functions which are used but not
defined. Fixes PR14993!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174158 91177308-0d34-0410-b5e6-96231b3b80d8
995e26b0523ac8e3b6199a509b871b81fa5df6ee 31-Jan-2013 Nick Lewycky <nicholas@mxc.ca> Remove elements from Sema.UndefinedInternals as functions are defined. Also
filter the elements before emitting them into a PCH. No user-visible
functionality change, except that PCH files may be smaller?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174034 91177308-0d34-0410-b5e6-96231b3b80d8
59fd63581d6d572f23e82e81a50e0b940c8d1089 30-Jan-2013 Daniel Dunbar <daniel@zuster.org> [Frontend] Remove HeaderSearchOptions::Entry::IsInternal, which is unused.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173866 91177308-0d34-0410-b5e6-96231b3b80d8
ef84554239d77cc52a14b42f2bff8c2d02e7630e 30-Jan-2013 Daniel Dunbar <daniel@zuster.org> [Frontend] Add an ExternCSystem include entry group.

- The only group where it makes sense for the "ExternC" bit is System, so this
simplifies having to have the extra isCXXAware (or ImplicitExternC, depending
on what code you talk to) bit caried around.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173859 91177308-0d34-0410-b5e6-96231b3b80d8
95fb36ebddcbdcd6b801c5d3d2d85dac315b4127 28-Jan-2013 Douglas Gregor <dgregor@apple.com> Add some more ASTReader statistics for global method pool lookups.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173702 91177308-0d34-0410-b5e6-96231b3b80d8
01a41140cd8ec9475ed0c33384310fbdd3b6de11 26-Jan-2013 Nick Lewycky <nicholas@mxc.ca> Preserve Sema::UndefinedInternals across PCH boundaries. Fixes
-Wundefined-internal warnings with PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173538 91177308-0d34-0410-b5e6-96231b3b80d8
188bdcd1aaf5e9f457cec6851707d7dc3e7bbb15 26-Jan-2013 Douglas Gregor <dgregor@apple.com> Improve coordination between the module manager and the global module
index, optimizing the operation that skips lookup in modules where we
know the identifier will not be found. This makes the global module
index optimization actually useful, providing an 8.5% speedup over
modules without the global module index for -fsyntax-only.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173529 91177308-0d34-0410-b5e6-96231b3b80d8
eab6652b7e417c8e46b21c7d340f3a7d41492d6e 25-Jan-2013 Daniel Dunbar <daniel@zuster.org> [Frontend] Remove another IsUserSpecified member variable that is now unused.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173412 91177308-0d34-0410-b5e6-96231b3b80d8
1a49d97d762570027863e9209af81d445e4f1502 25-Jan-2013 Douglas Gregor <dgregor@apple.com> Implement the reader of the global module index and wire it into the
AST reader.

The global module index tracks all of the identifiers known to a set
of module files. Lookup of those identifiers looks first in the global
module index, which returns the set of module files in which that
identifier can be found. The AST reader only needs to look into those
module files and any module files not known to the global index (e.g.,
because they were (re)built after the global index), reducing the
number of on-disk hash tables to visit. For an example source I'm
looking at, we go from 237844 total identifier lookups into on-disk
hash tables down to 126817.

Unfortunately, this does not translate into a performance advantage.
At best, it's a wash once the global module index has been built, but
that's ignore the cost of building the global module index (which
is itself fairly large). Profiles show that the global module index
code is far less efficient than it should be; optimizing it might give
enough of an advantage to justify its continued inclusion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173405 91177308-0d34-0410-b5e6-96231b3b80d8
f575d6e7c3b887ea4c5394d2c7e322c7a929a57e 25-Jan-2013 Douglas Gregor <dgregor@apple.com> Rename the -cc1 option "-generate-module-index" to
"-fmodules-global-index" and expand its behavior to include both the
use and generation of the global module index.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173404 91177308-0d34-0410-b5e6-96231b3b80d8
e169807aaea2464cbe68305f013ec7b41625af30 25-Jan-2013 Douglas Gregor <dgregor@apple.com> Track the number of lookups and hits into the on-disk hash tables for
identifiers within the AST file reader.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173403 91177308-0d34-0410-b5e6-96231b3b80d8
a6b00fc97669aa25d89ae9f202b05dfadfd0e324 23-Jan-2013 Douglas Gregor <dgregor@apple.com> Implement the writer side of the global module index.

The global module index is a "global" index for all of the module
files within a particular subdirectory in the module cache, which
keeps track of all of the "interesting" identifiers and selectors
known in each of the module files. One can perform a fast lookup in
the index to determine which module files will have more information
about entities with a particular name/selector. This information can
help eliminate redundant lookups into module files (a serious
performance problem) and help with creating auto-import/auto-include

The global module index is created or updated at the end of a
translation unit that has triggered a (re)build of a module by
scraping all of the .pcm files out of the module cache subdirectory,
so it catches everything. As with module rebuilds, we use the file
system's atomicity to synchronize.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173301 91177308-0d34-0410-b5e6-96231b3b80d8
479633ced74c887ee9ec5905b3cb0bb1a37349b0 23-Jan-2013 Douglas Gregor <dgregor@apple.com> Factor the trait for lookup into the on-based hash table of
identifiers into two parts: the part that involves dealing with the
key (which can be re-used) and the ASTReader-specific part that
creates the IdentifierInfos. While I'm at it, StringRef'ify this code,
which was using pair<const char*, unsigned>. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173283 91177308-0d34-0410-b5e6-96231b3b80d8
e0d2066ab8812cbaa16d79af5f2c9fb6bd52d2e2 22-Jan-2013 Douglas Gregor <dgregor@apple.com> Make getDefinitiveDeclContext() actually return a DeclContext, as one
would expect, and clean up the return/break inconsistencies. Thanks,

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173171 91177308-0d34-0410-b5e6-96231b3b80d8
9ec55f24b8f848bb37a9971100cf2fca379d5572 22-Jan-2013 Tim Northover <Tim.Northover@arm.com> Switch to APFloat constructor taking fltSemantics.

This change also makes the serialisation store the required semantics,
fixing an issue where PPC128 was always assumed when re-reading a
128-bit value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173139 91177308-0d34-0410-b5e6-96231b3b80d8
125eb3e3b6cc2f3e7b2e0e04e59c924f936520f5 21-Jan-2013 Chris Lattner <sabre@nondot.org> ReadSourceManagerBlock is skipping over records that can contain Blobs. Not passing
in a StringRef to bind to them forces them to be unpacked into the Record as individual
bytes. This is wasteful, but not likely to be measurable in this instance.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173066 91177308-0d34-0410-b5e6-96231b3b80d8
8222b8951da749d4f086d7b39de5ff0221297509 21-Jan-2013 Douglas Gregor <dgregor@apple.com> Revert r173056; it breaks one of the CodeGen-with-PCH tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173058 91177308-0d34-0410-b5e6-96231b3b80d8
c44cc015a8525e9b7d81a1f1cc1b6e827cfe6762 21-Jan-2013 Douglas Gregor <dgregor@apple.com> When loading an identifier from an AST file solely for the purpose of
forming the identifier, e.g., as part of a selector or a declaration
name, don't actually deserialize any information about the
identifier. Instead, simply mark it "out-of-date" and we'll load the
the information on demand. 2% speedup on the modules testcase I'm
looking at; should also help PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173056 91177308-0d34-0410-b5e6-96231b3b80d8
5a04f9fc2b000da98fd903c8156034304bdadb2f 21-Jan-2013 Douglas Gregor <dgregor@apple.com> Introduce a fast path for the ASTReader's name lookup within a
DeclContext. When the DeclContext is of a kind that can only be
defined once and never updated, we limit the search to the module file
that conatins the lookup table. Provides a 15% speedup in one
modules-heavy source file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173050 91177308-0d34-0410-b5e6-96231b3b80d8
e6b9d802fb7b16d93474c4f1c179ab36202e8a8b 20-Jan-2013 Guy Benyei <guy.benyei@intel.com> Implement OpenCL event_t as Clang builtin type, including event_t related OpenCL restrictions (OpenCL 1.2 spec 6.9)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172973 91177308-0d34-0410-b5e6-96231b3b80d8
b3ce35764adcc5749e8729709b1f3737227d90ec 20-Jan-2013 Chris Lattner <sabre@nondot.org> update to use the new BitcodeCursor readRecord that takes a StringRef blob parameter,
and adopt "advance" in more places.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172951 91177308-0d34-0410-b5e6-96231b3b80d8
e4e4a88eb67ce1cd32a5761f0601fc029d68832b 20-Jan-2013 Chris Lattner <sabre@nondot.org> add back a #include needed on some builders.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172938 91177308-0d34-0410-b5e6-96231b3b80d8
8f9a1eb6dd35737c6b3ff63a19c6c1a07c06111e 20-Jan-2013 Chris Lattner <sabre@nondot.org> finish converting the normal cases in ASTReader to use the new BitstreamCursor APIs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172937 91177308-0d34-0410-b5e6-96231b3b80d8
99a5af0088b6340540912921cd0008ac75051a33 20-Jan-2013 Chris Lattner <sabre@nondot.org> convert some more stuff over to use new cursor APIs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172932 91177308-0d34-0410-b5e6-96231b3b80d8
88bde50fa30ce10f5d554b36dda66b3231ccef54 19-Jan-2013 Chris Lattner <sabre@nondot.org> switch a bunch of ASTReader to use the new BitstreamCursor::advance* methods,
which hide a bunch of private details of the cursor from clients and simplify
their code. More to come.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172922 91177308-0d34-0410-b5e6-96231b3b80d8
dc1088f6201c3fb8f3f97f54c343f7d163fbec06 19-Jan-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH/Modules] Revert r172843, it caused a module to fail building.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172884 91177308-0d34-0410-b5e6-96231b3b80d8
8dc3c80c3f9401e32d68d2de83a04362c9d6f61a 18-Jan-2013 Matt Beaumont-Gay <matthewbg@google.com> Remove unused variable

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172862 91177308-0d34-0410-b5e6-96231b3b80d8
f953276b6165dc7e8f4679cce4d0e7c649cd4232 18-Jan-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH/Modules] Re-apply r172620 and r172629, now with 100% less infinite loops!

Makes sure that a deserialized macro is only added to the preprocessor macro definitions only once.
Unfortunately I couldn't get a reduced test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172843 91177308-0d34-0410-b5e6-96231b3b80d8
4f45bc099f2665bc6e4bcbb169aa452390dbf3fe 18-Jan-2013 Will Dietz <wdietz2@illinois.edu> [ubsan] Add support for -fsanitize-blacklist

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172808 91177308-0d34-0410-b5e6-96231b3b80d8
d3b036efdf0bf4ec216c701183a4b990cd041cd6 18-Jan-2013 Douglas Gregor <dgregor@apple.com> Revert Clang r172620 and r172629, which caused a hang when building
complicated modules (<rdar://problem/13038265>). Unfortunately, this
un-fixes <rdar://problem/13016031>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172783 91177308-0d34-0410-b5e6-96231b3b80d8
f7f12646e8f8a45abea3ebcb81928fbe08187f97 16-Jan-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH/Modules] The iterator may become invalidated because a new macro can be added
while deserializing a macro, make sure to copy/move what we need from it.

Fixes clang-x86_64-debian-fast bot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172629 91177308-0d34-0410-b5e6-96231b3b80d8
7f69b1ab4f63ded511dddd7fb7e1cd8860757016 16-Jan-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH/Modules] Change how macro [re]definitions are de/serialized.

Previously we would serialize the macro redefinitions as a list, part of
the identifier, and try to chain them together across modules individually
without having the info that they were already chained at definition time.

Change this by serializing the macro redefinition chain and then try
to synthesize the chain parts across modules. This allows us to correctly
pinpoint when 2 different definitions are ambiguous because they came from
unrelated modules.

Fixes bogus "ambiguous expansion of macro" warning when a macro in a PCH
is redefined without undef'ing it first.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172620 91177308-0d34-0410-b5e6-96231b3b80d8
b6cbe517237c3c223beb064d60d5b49e56d65c06 14-Jan-2013 Douglas Gregor <dgregor@apple.com> Implement parsing, AST, (de-)serialization, and placeholder global
metadata for linking against the libraries/frameworks for imported

The module map language is extended with a new "link" directive that
specifies what library or framework to link against when a module is
imported, e.g.,

link "clangAST"


link framework "MyFramework"

Importing the corresponding module (or any of its submodules) will
eventually link against the named library/framework.

For now, I've added some placeholder global metadata that encodes the
imported libraries/frameworks, so that we can test that this
information gets through to the IR. The format of the data is still
under discussion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172437 91177308-0d34-0410-b5e6-96231b3b80d8
cfa88f893915ceb8ae4ce2f17c46c24a4d67502f 12-Jan-2013 Dmitri Gribenko <gribozavr@gmail.com> Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172323 91177308-0d34-0410-b5e6-96231b3b80d8
ca2ab45341c448284cf93770018c717810575f86 12-Jan-2013 Douglas Gregor <dgregor@apple.com> Provide Decl::getOwningModule(), which determines the (sub)module in
which a particular declaration resides. Use this information to
customize the "definition of 'blah' must be imported from another
module" diagnostic with the module the user actually has to
import. Additionally, recover by importing that module, so we don't
complain about other names in that module.

Still TODO: coming up with decent Fix-Its for these cases, and expand
this recovery approach for other name lookup failures.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172290 91177308-0d34-0410-b5e6-96231b3b80d8
e8b61cfc0c9233b6983ad9ed052900800e7613d9 11-Jan-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Make the const_cast explicit to silence a compiler warning.

Patch by David Greene.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172262 91177308-0d34-0410-b5e6-96231b3b80d8
5ea6ef490547917426d5e2ed14c9f36521bbeacf 11-Jan-2013 Richard Smith <richard-llvm@metafoo.co.uk> Truth in advertising: LocallyScopedExternalDecls actually only contains
external declarations with C language linkage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172150 91177308-0d34-0410-b5e6-96231b3b80d8
8169b671974fc15b6059b1e9532f7f3207d79786 07-Jan-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] (De)serialize the end location of MacroInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171772 91177308-0d34-0410-b5e6-96231b3b80d8
ca40f30a20d0329900fa3d1e4b3252cece86ccc0 19-Dec-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH/Modules] In ASTReader::completeVisibleDeclsMap, make sure to visit all
modules when getting the decls for a namespace or translation unit.

Otherwise the code-completion results will not be complete.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170596 91177308-0d34-0410-b5e6-96231b3b80d8
b13621d08e20ac7aa550e05896de8a57ee99c1e8 18-Dec-2012 Guy Benyei <guy.benyei@intel.com> Re-commit r170428 changes with Linux style file endings.

Add OpenCL images as clang builtin types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170432 91177308-0d34-0410-b5e6-96231b3b80d8
7f92f2d8d9b7a07900c030183bc13a9ff60057cc 18-Dec-2012 Guy Benyei <guy.benyei@intel.com> Revert changes from r170428, as I accidentally changed the line endings of these files to Windows style.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170431 91177308-0d34-0410-b5e6-96231b3b80d8
736104a7619c53ef92553780273d7357a3cdde81 18-Dec-2012 Guy Benyei <guy.benyei@intel.com> Add OpenCL images as clang builtin types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170428 91177308-0d34-0410-b5e6-96231b3b80d8
5e24f2d83099bb557b1d39c6420787eeaf072a81 13-Dec-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Make the new PCH format (control block) backwards compatible and
don't crash when loading a PCH with the older format.

The introduction of the control block broke compatibility with PCHs from
older versions. This patch allows loading (and rejecting) PCHs from an older
version and allows newer PCHs to be rejected from older clang versions as well.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170150 91177308-0d34-0410-b5e6-96231b3b80d8
f64d25c633fc093528177c2e0fdd096d2f8706d2 11-Dec-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Remove redundant stat call when validating the input files.

This became redundant after we removed the stat cache.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169830 91177308-0d34-0410-b5e6-96231b3b80d8
55fc873017f10f6f566b182b70f6fc22aefa3464 04-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Sort all of Clang's files under 'lib', and fix up the broken headers

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
37ed12720a35b7bfa1c4de73ad6f1c6c1c88ee17 04-Dec-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Refactor recording the preprocessor conditional directive regions out of
PreprocessingRecord and into its own class, PPConditionalDirectiveRecord.

Decoupling allows a client to use the functionality of PPConditionalDirectiveRecord
without needing a PreprocessingRecord.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169229 91177308-0d34-0410-b5e6-96231b3b80d8
6c3254316de2d0d554b19702f4b10117ae46b77b 30-Nov-2012 Douglas Gregor <dgregor@apple.com> When we're emitting a diagnostic with a source location in an imported
module, provide a module import stack similar to what we would get for
an include stack, e.g.,

In module 'DependsOnModule' imported from build-fail-notes.m:4:
In module 'Module' imported from DependsOnModule.framework/Headers/DependsOnModule.h:1:
Inputs/Module.framework/Headers/Module.h:15:12: note: previous definition is here
@interface Module


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169042 91177308-0d34-0410-b5e6-96231b3b80d8
87e2cfcec7231daaa3f367dc32df74b411251e46 30-Nov-2012 Douglas Gregor <dgregor@apple.com> Actually keep track of the source locations at which particular module
files are loaded.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169027 91177308-0d34-0410-b5e6-96231b3b80d8
2a82ca255b0f99f6201a75ed52b91fc024f6e9cf 28-Nov-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Introduce ASTUnresolvedSet, an UnresolvedSet-like class, whose contents are
allocated using the allocator associated with an ASTContext.

Use this inside CXXRecordDecl::DefinitionData instead of an UnresolvedSet to
avoid a potential memory leak.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168771 91177308-0d34-0410-b5e6-96231b3b80d8
992d91742129c1f77563df0b3d0a40b36fd13e3e 15-Nov-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [modules] Use a memory buffer directly as input for the module includes,
instead of messing with virtual files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168062 91177308-0d34-0410-b5e6-96231b3b80d8
958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286 15-Nov-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [modules] Setup the import location of a module file and use it
as the include location of the main file of an imported module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168061 91177308-0d34-0410-b5e6-96231b3b80d8
4fa4b480270c14dfdcd0dfd4f76938e973082e3b 14-Nov-2012 Eli Friedman <eli.friedman@gmail.com> Suppress elided variadic macro argument extension diagnostic for macros using
the related comma pasting extension.

In certain cases, we used to get two diagnostics for what is essentially one
extension. This change suppresses the first diagnostic in certain cases
where we know we're going to print the second diagnostic. The
diagnostic is redundant, and it can't be suppressed in the definition
of the macro because it points at the use of the macro, so we want to
avoid printing it if possible.

The implementation works by detecting constructs which look like comma
pasting at the time of the definition of the macro; this information
is then used when the macro is used. (We can't actually detect
whether we're using the comma pasting extension until the macro is
actually used, but we can detecting constructs which will be comma
pasting if the varargs argument is elided.)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167907 91177308-0d34-0410-b5e6-96231b3b80d8
ecd27bf256c92f56c7c7ede6f40ec5d31a40b35e 09-Nov-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Add a FileCharacteristic parameter to SourceManager::createFileIDForMemBuffer
for completeness and use it in CompilerInstance::InitializeSourceManager if
the input is a memory buffer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167628 91177308-0d34-0410-b5e6-96231b3b80d8
7cdd28162dc7ade4b14bf237e87b4bbc17b2f023 07-Nov-2012 Douglas Gregor <dgregor@apple.com> When loading a module fails because it is out of date, rebuild that
module in place. <rdar://problem/10138913>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167539 91177308-0d34-0410-b5e6-96231b3b80d8
9e60371ba07faa2f173ab614ceaad0332518c8dc 07-Nov-2012 Douglas Gregor <dgregor@apple.com> Tease out the routine that reads the control block of an AST file from
the validation of an AST file against a specific set of options.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167504 91177308-0d34-0410-b5e6-96231b3b80d8
23de7cedc7cf09bdbcebc25c9be99ca84c6be1f7 06-Nov-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Take into account the 'include' source location of a SM_SLOC_BUFFER_ENTRY.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167426 91177308-0d34-0410-b5e6-96231b3b80d8
ce254928e9c7b0d7389a6baf4bf5052a19905eee 02-Nov-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] Correct how the index inside the local preprocessed entities array
is getting converted to a global PreprocessedEntityID.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167280 91177308-0d34-0410-b5e6-96231b3b80d8
4182ed686283b72736b287cbe28583cb641f8934 31-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Remove the stat cache from the PCH file.

The stat cache became essentially useless ever since we started
validating all file entries in the PCH.
But the motivating reason for removing it now is that it also affected
correctness in this situation:

-You have a header without include guards (using "#pragma once" or #import)
-When creating the PCH:
-The same header is referenced in an #include with different filename cases.
-In the PCH, of course, we record only one file entry for the header file
-But we cache in the PCH file the stat info for both filename cases

-Then the source files are updated and the header file is updated in a way that
its size and modification time are the same but its inode changes

-When using the PCH:
-We validate the headers, we check that header file and we create a file entry with its current inode
-There's another #include with a filename with different case than the previously created file entry
-In order to get its stat info we go through the cached stat info of the PCH and we receive the old inode
-because of the different inodes, we think they are different files so we go ahead and include its contents.

Removing the stat cache will potentially break clients that are attempting to use the stat cache
as a way of avoiding having the actual input files available. If that use case is important, patches are welcome
to bring it back in a way that will actually work correctly (i.e., emit a PCH that is self-contained, coping with
literal strings, line/column computations, etc.).

This fixes rdar://5502805

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167172 91177308-0d34-0410-b5e6-96231b3b80d8
848bc3a5db57fb267e2b2541cb55e71dba4bf228 30-Oct-2012 Rafael Espindola <rafael.espindola@gmail.com> getOriginalSourceFileName and getOriginalSourceFile can return a StringRef.
MaybeAddSystemRootToFilename doesn't need to return anything, it modifies
its argument.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166988 91177308-0d34-0410-b5e6-96231b3b80d8
33e1576ef88ae6fcc4ed8686f34ed28b1a41bcce 30-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] The diagnostic state points can refer to previously created
diagnostic states; make sure the ASTReader sets the diagnostic state
properly instead of always recreating it.

Fixes rdar://12581618 & http://llvm.org/PR14181

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166987 91177308-0d34-0410-b5e6-96231b3b80d8
0ca6e27138e2fe12e03284d4d820182702141a7d 25-Oct-2012 Douglas Gregor <dgregor@apple.com> Remove the old predefines-buffer diffing code completely. It's been
replaced by the more efficient, cleaner preprocessor-option version
that occurs earlier in PCH validation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166654 91177308-0d34-0410-b5e6-96231b3b80d8
a9b8da43077a78f9ab223caf4889e6c6eba2c4a3 25-Oct-2012 Douglas Gregor <dgregor@apple.com> Fix computation of predefines buffer from the preprocessor-option
checking, and disable the old predefines-buffer-diff'ing code path.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166653 91177308-0d34-0410-b5e6-96231b3b80d8
8769924c97ecf2af88f7f3aa6754d381b30d1c5f 25-Oct-2012 Douglas Gregor <dgregor@apple.com> The the preprocessor option validator to compute suggested
predefines. We're not quite ready to cut over to these suggested
predefines yet, however.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166648 91177308-0d34-0410-b5e6-96231b3b80d8
4c0c7e86645dfa1719d17d70e009ab49347aba62 25-Oct-2012 Douglas Gregor <dgregor@apple.com> Teach the PCH validator to check the preprocessor options, especially
the macros that are #define'd or #undef'd on the command line. This
checking happens much earlier than the current macro-definition
checking and is far cleaner, because it does a direct comparison
rather than a diff of the predefines buffers. Moreover, it allows us
to use the result of this check to skip over PCH files within a
directory that have non-matching -D's or -U's on the command
line. Finally, it improves the diagnostics a bit for mismatches,
fixing <rdar://problem/8612222>.

The old predefines-buffer diff'ing will go away in a subsequent commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166641 91177308-0d34-0410-b5e6-96231b3b80d8
a71a7d8a1ce4474e7bdb680658fb58b6caf391d3 24-Oct-2012 Douglas Gregor <dgregor@apple.com> (De-)serialize the preprocessor options, including macros defined,
-include'd files, etc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166614 91177308-0d34-0410-b5e6-96231b3b80d8
bbf38319edd4eddc55ec273934e990d7e84991de 24-Oct-2012 Douglas Gregor <dgregor@apple.com> (De-)serialize header search options.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166586 91177308-0d34-0410-b5e6-96231b3b80d8
1b2c3c0884e917ae5d59edde7d93b2af33c6a1b6 24-Oct-2012 Douglas Gregor <dgregor@apple.com> (De-)serialize the file system options.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166577 91177308-0d34-0410-b5e6-96231b3b80d8
5f3d8224af99ad0d9107601c0c31b74693371cc1 24-Oct-2012 Douglas Gregor <dgregor@apple.com> Serialize DiagnosticOptions to the AST file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166572 91177308-0d34-0410-b5e6-96231b3b80d8
27ffa6caf965ef20fdef5ae23b81cdc3d05e7afb 23-Oct-2012 Douglas Gregor <dgregor@apple.com> If the precompiled header named by "-include" is actually a directory,
check each of the files within that directory to determine if any of
them is an AST file that matches the language and target options. If
so, the first matching AST file is loaded. This fixes a longstanding
discrepency with GCC's precompiled header implementation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166469 91177308-0d34-0410-b5e6-96231b3b80d8
38295beb73db5f90bfcf31625fb81dbc3b96290a 23-Oct-2012 Douglas Gregor <dgregor@apple.com> Allow clients of the AST reader to specify what kinds of AST load
failures they know how to tolerate, e.g., out-of-date input files or
configuration/version mismatches. Suppress the corresponding
diagnostics if the client can handle it.

No clients actually use this functionality, yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166449 91177308-0d34-0410-b5e6-96231b3b80d8
8b53d141ee5a91da92c4196ed7ad4142e1009d6f 23-Oct-2012 Douglas Gregor <dgregor@apple.com> Collapse ASTReader::ReadSLocEntryRecord() into its only caller,
ReadSLocEntry(). No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166447 91177308-0d34-0410-b5e6-96231b3b80d8
4825fd7fbb3fe87cdf8da9bccc1361fac45bdf2d 23-Oct-2012 Douglas Gregor <dgregor@apple.com> Distinguish the various kinds of AST file loading failures:
file corruption, compiler version mismatch, target/language
configuration mismatch, out-of-date AST file. No functionality change

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166446 91177308-0d34-0410-b5e6-96231b3b80d8
6b8194e4d7ca980087a3a5e1addb74090be990ff 22-Oct-2012 NAKAMURA Takumi <geek4civic@gmail.com> ASTReader.cpp: Fix a warning. [-Wunused-variable]

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166442 91177308-0d34-0410-b5e6-96231b3b80d8
a930dc9b46572cb6e5bb54f3d724e8fe23a6b66e 22-Oct-2012 Douglas Gregor <dgregor@apple.com> Eliminate the redundancy between source-file information in the source
manager block and input-file information in the control block. The
source manager entries now point back into the control block. Input
files are now lazily deserialized (if validation is disabled). Reduces
Cocoa's PCH by the ~70k I added when I introduced the redundancy in

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166429 91177308-0d34-0410-b5e6-96231b3b80d8
745e6f168d0276c15fb72f3d90e3d93d60282b1b 19-Oct-2012 Douglas Gregor <dgregor@apple.com> Move the set of files to be validated in an AST file into the control
block, so the input files are validated early on, before we've
committed to loading the AST file. This (accidentally) fixed a but
wherein the main file used to generate the AST file would *not* be
validated by the existing validation logic.

At the moment, this leads to some duplication of filenames between the
source manager block and input-file blocks, as well as validation
logic. This will be handled via an upcoming patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166251 91177308-0d34-0410-b5e6-96231b3b80d8
69e160869dc10567a878601e98987079ad984c64 18-Oct-2012 Douglas Gregor <dgregor@apple.com> Move OriginalDir from ASTReader to ModuleFile.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166233 91177308-0d34-0410-b5e6-96231b3b80d8
caed060d38f404c3a7650dbd236c25ec356bc5a3 18-Oct-2012 Douglas Gregor <dgregor@apple.com> Move the "RelocatablePCH" bit from the ASTReader to the module file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166229 91177308-0d34-0410-b5e6-96231b3b80d8
11407b89c9d7ce8bc31869b0a7aae06add49e3dc 18-Oct-2012 Douglas Gregor <dgregor@apple.com> Move information about the "original file" from the ASTReader into the
module files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166228 91177308-0d34-0410-b5e6-96231b3b80d8
0ec56b7add7be643f490ea9b430823570f01b4e2 18-Oct-2012 Axel Naumann <Axel.Naumann@cern.ch> From Vassil Vassilev: enable Sema to deal with multiple ExternalSemaSources.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166208 91177308-0d34-0410-b5e6-96231b3b80d8
39c497b6d5e99acecbe03ee173249ee21933e855 18-Oct-2012 Douglas Gregor <dgregor@apple.com> Collapse the original file name and original file ID records into a
single record.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166206 91177308-0d34-0410-b5e6-96231b3b80d8
7ae467f02b0f2ba3897ee03e0d011433789b5434 18-Oct-2012 Douglas Gregor <dgregor@apple.com> Collapse the "version control revision/tag" AST file record into the
metadata record, which already had other version information. Clean up
the block info block along the way.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166204 91177308-0d34-0410-b5e6-96231b3b80d8
ee097c1a3f5e02605dd585c0a9bf22976f09ccc2 18-Oct-2012 Douglas Gregor <dgregor@apple.com> Split the target options out into their own record within the AST
file's control block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166195 91177308-0d34-0410-b5e6-96231b3b80d8
1d9d9898ce2b338314161d92f39561a09a2a8b6f 18-Oct-2012 Douglas Gregor <dgregor@apple.com> Start factoring the on-disk records for an AST file into a control
block, which stores information about how the AST file to generated,
from the AST block, which stores the actual serialized AST. The
information in the control block should be enough to determine whether
the AST file is up-to-date and compatible with the current translation
unit, and reading it should not cause any side effects that aren't
easy to undo. That way, we can back out from an attempt to read an
incompatible or out-of-date AST file.

Note that there is still more factoring to do. In particular,
information about the source files used to generate the AST file
(along with their time stamps, sizes, etc.) still resides in the
source manager block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166166 91177308-0d34-0410-b5e6-96231b3b80d8
57016dda61498294120b1a881d9e6606337b29d9 17-Oct-2012 Douglas Gregor <dgregor@apple.com> Serialize TargetOptions into an AST file, and make sure that we keep
target options around so they can be accessed at any point (rather
than keeping them transient).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166072 91177308-0d34-0410-b5e6-96231b3b80d8
2b49d1f0ad790a8a5d514af1be211591a746cb73 15-Oct-2012 Douglas Gregor <dgregor@apple.com> Introduce the notion of excluded headers into the module map
description. Previously, one could emulate this behavior by placing
the header in an always-unavailable submodule, but Argyrios guilted me
into expressing this idea properly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165921 91177308-0d34-0410-b5e6-96231b3b80d8
54c8a40ed658676b1f3f983728feae488c501477 12-Oct-2012 Douglas Gregor <dgregor@apple.com> Track which particular submodule #undef's a macro, so that the actual
#undef only occurs if that submodule is imported.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165773 91177308-0d34-0410-b5e6-96231b3b80d8
e8219a655128b98d0573658a139de5d848451fda 11-Oct-2012 Douglas Gregor <dgregor@apple.com> Diagnose the expansion of ambiguous macro definitions. This can happen
only with modules, when two disjoint modules #define the same
identifier to different token sequences.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165746 91177308-0d34-0410-b5e6-96231b3b80d8
3ab50fe3fc8311fb68c4f5eb97e9bb3d0041bf1a 11-Oct-2012 Douglas Gregor <dgregor@apple.com> Introduce a simple "hint" scheme to eliminate the quadratic behavior
associated with deserializing macro history for an identifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165729 91177308-0d34-0410-b5e6-96231b3b80d8
e9652bf15246d6e08e953b52cdb7812ddb8a43e0 11-Oct-2012 Douglas Gregor <dgregor@apple.com> Make the deserialization of PendingMacroIDs deterministic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165727 91177308-0d34-0410-b5e6-96231b3b80d8
4145228b758892afd3545835a4caaea722f20510 11-Oct-2012 Douglas Gregor <dgregor@apple.com> Remove the ASTDeserializationListener's MacroVisible() callback, which
is no longer necessary, as well as the little bit of infrastructure in
the AST writer that used it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165684 91177308-0d34-0410-b5e6-96231b3b80d8
7097be90d3549c30438b7a94b35577003d0a434f 11-Oct-2012 Douglas Gregor <dgregor@apple.com> Remove an unused bit from the serialized IdentifierInfo

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165683 91177308-0d34-0410-b5e6-96231b3b80d8
6c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462 11-Oct-2012 Douglas Gregor <dgregor@apple.com> Deserialize macro history when we deserialize an identifier that has
macro history.

When deserializing macro history, we arrange history such that the
macros that have definitions (that haven't been #undef'd) and are
visible come at the beginning of the list, which is what the
preprocessor and other clients of Preprocessor::getMacroInfo()
expect. If additional macro definitions become visible later, they'll
be moved toward the front of the list. Note that it's possible to have
ambiguities, but we don't diagnose them yet.

There is a partially-implemented design decision here that, if a
particular identifier has been defined or #undef'd within the
translation unit, that definition (or #undef) hides any macro
definitions that come from imported modules. There's still a little
work to do to ensure that the right #undef'ing happens.

Additionally, we'll need to scope the update records for #undefs, so
they only kick in when the submodule containing that update record
becomes visible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165682 91177308-0d34-0410-b5e6-96231b3b80d8
62288edde26ff4af9fc079c979a0e1bdc577ce9d 10-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> When indexing a module file, for the ppIncludedFile callback give
an invalid location if the location points to the synthetic buffer
for the module input.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165592 91177308-0d34-0410-b5e6-96231b3b80d8
2a857180050fb78b356c17931e311eef7f2daf3e 10-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [modules] Consistently construct a buffer as input to build the module.
This means the main file for modules will always be a virtual one.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165591 91177308-0d34-0410-b5e6-96231b3b80d8
a8235d6c4093cd38dcf742909651f867de62e55b 10-Oct-2012 Douglas Gregor <dgregor@apple.com> Rework the (de-)serialization of macros, as stored in
MacroInfo*. Instead of simply dumping an offset into the current file,
give each macro definition a proper ID with all of the standard
modules-remapping facilities. Additionally, when a macro is modified
in a subsequent AST file (e.g., #undef'ing a macro loaded from another
module or from a precompiled header), provide a macro update record
rather than rewriting the entire macro definition. This gives us
greater consistency with the way we handle declarations, and ties
together macro definitions much more cleanly.

Note that we're still not actually deserializing macro history (we
never were), but it's far easy to do properly now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165560 91177308-0d34-0410-b5e6-96231b3b80d8
ce12d2f8863588d408897602089d17c4d3c3d0e5 09-Oct-2012 Douglas Gregor <dgregor@apple.com> Make the order of visitation of the pending bodies in the AST reader

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165515 91177308-0d34-0410-b5e6-96231b3b80d8
5456b0fe40714a78cd0ba7c1a5b7dc34eda385af 09-Oct-2012 Douglas Gregor <dgregor@apple.com> When we load a function or method body from an AST file, we check
whether that function/method already has a body (loaded from some
other AST file), as introduced in r165137. Delay this check until
after the redeclaration chains have been wired up.

While I'm here, make the loading of method bodies lazy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165513 91177308-0d34-0410-b5e6-96231b3b80d8
3644d970095d9c638c658cfd17f8e19fc333aadc 09-Oct-2012 Douglas Gregor <dgregor@apple.com> If a macro has been #undef'd in a precompiled header, we still need to
write out the macro history for that macro. Similarly, we need to cope
with reading a macro definition that has been #undef'd.

Take advantage of this new ability so that global code-completion
results can refer to #undef'd macros, rather than losing them
entirely. For multiply defined/#undef'd macros, we will still get the
wrong result, but it's better than getting no result.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165502 91177308-0d34-0410-b5e6-96231b3b80d8
c7782d96c657eeb767bfea5117db49dc40e6356c 05-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Modules] Introduce Module::TopHeaders which is a set of top-level headers
that are associated with a (sub)module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165279 91177308-0d34-0410-b5e6-96231b3b80d8
59c0a818a79be850f7ae8fdafd57a1710e5b809a 04-Oct-2012 Abramo Bagnara <abramo.bagnara@bugseng.com> Fixed FunctionTypeLoc source range.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165259 91177308-0d34-0410-b5e6-96231b3b80d8
e5fa3c26919c0fa9817fbbb967f1a418e2fd3140 03-Oct-2012 Douglas Gregor <dgregor@apple.com> Revert most of the functionality in r165001. Instead, make sure that
the ASTReader doesn't attach a body to a function that is already
defined elsewhere.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165137 91177308-0d34-0410-b5e6-96231b3b80d8
d64c26f6676eef69d1713f353ca8a3c2fe963f17 03-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Set the file entry for a Module* that was created during deserialization
of a module file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165086 91177308-0d34-0410-b5e6-96231b3b80d8
2093e0bc4e436b1b2791d5423fb3274dd37231b8 02-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] When indexing an AST file, only deserialize the file level
declarations of the current primary module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165046 91177308-0d34-0410-b5e6-96231b3b80d8
632dcc92f60ab7f806a89c5bca3a0951763a9219 02-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] When indexing an AST file, only deserialize the preprocessing record
entities of the current primary module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165023 91177308-0d34-0410-b5e6-96231b3b80d8
8dd927cf03e85b942f323eebb42e06c839887ebb 02-Oct-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Add info in the preprocessing record whether an inclusion directive
resulted in an automatic module import.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165022 91177308-0d34-0410-b5e6-96231b3b80d8
38c3bb40c2cef630c236f3f455ea98999990b8ee 02-Oct-2012 Axel Naumann <Axel.Naumann@cern.ch> Only those InterestingDecls that got added to the AST should be passed to the ASTConsumer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165001 91177308-0d34-0410-b5e6-96231b3b80d8
39d26c3e499470cd80a3e6f26f11ac681cd9712c 02-Oct-2012 Axel Naumann <Axel.Naumann@cern.ch> Merge pending instantiations instead of overwriting existing ones.
Check whether a pending instantiation needs to be instantiated (or whether an instantiation already exists).
Verify the size of the PendingInstantiations record (was only checking size of existing PendingInstantiations).

Migrate Obj-C++ part of redecl-merge into separate test, now that this is growing.
templates.mm: test that CodeGen has seen exactly one definition of template instantiations.
redecl-merge.m: use "@" specifier for expected-diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164993 91177308-0d34-0410-b5e6-96231b3b80d8
3dd82f7f01a9ba995bea3027a934df85850cab58 01-Oct-2012 Axel Naumann <Axel.Naumann@cern.ch> The Redeclarable part of named decls is read before their name.
Lookup can nevertheless find them due to the serialized lookup table.
For instance when reading a template decl's templatedDecl, it will search for existing decls that it could be a redeclaration of, and find the half-read template decl.
Thus there is no point in asserting the names of decls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164932 91177308-0d34-0410-b5e6-96231b3b80d8
d7a6b1640e565487d163023a6a2e83f55476ae96 26-Sep-2012 Eli Friedman <eli.friedman@gmail.com> Fix the AST representation for non-type template arguments to encode
enough information so we can mangle them correctly in cases involving
dependent parameter types. (This specifically impacts cases involving
null pointers and cases involving parameters of reference type.)
Fix the mangler to use this information instead of trying to scavenge
it out of the parameter declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164656 91177308-0d34-0410-b5e6-96231b3b80d8
4d7e0ced7f16a04aabe2d8d91cbbb52fb1162810 25-Sep-2012 Alexander Kornienko <alexfh@google.com> Macro history (de-)serialization. Deserialization currently reads only the latest macro definition. Needs more work.

Summary: Passes all tests (+ the new one with code completion), but needs a thorough review in part related to modules.

Reviewers: doug.gregor

Reviewed By: alexfh

CC: cfe-commits, rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D41

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164610 91177308-0d34-0410-b5e6-96231b3b80d8
c12906ee78e006df6a71acf52ca9dd3171ddbf07 24-Sep-2012 Douglas Gregor <dgregor@apple.com> Make sure that we don't end up making an #undef'd macro visible after
the fact. Test cases will come when we're actually (de-)serializing
macro history.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164549 91177308-0d34-0410-b5e6-96231b3b80d8
1f94124b76680211f3585ac8c3b24b247f46fac3 21-Sep-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] After deserializing a DeclContext, if it has external lexical decls but not
external visible decls, call DeclContext::setMustBuildLookupTable so that the
"lazy decls" bit of the LookupPtr is set.

Previously, in non-C++, if there were no new declarations causing the "lazy decls" bit
to be set, then DeclContext::lookups_begin() would fail to return the decls from the PCH.

Fixes rdar://12316296.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164351 91177308-0d34-0410-b5e6-96231b3b80d8
a6c66cedc022c9e5d45a937d6b8cff491a6bf81b 31-Aug-2012 Eli Friedman <eli.friedman@gmail.com> Change the representation of builtin functions in the AST
(__builtin_* etc.) so that it isn't possible to take their address.
Specifically, introduce a new type to represent a reference to a builtin
function, and a new cast kind to convert it to a function pointer in the
operand of a call. Fixes PR13195.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162962 91177308-0d34-0410-b5e6-96231b3b80d8
d48bcb2f4dedf8e7b654cb017968b3d7b6663a57 22-Aug-2012 Benjamin Kramer <benny.kra@googlemail.com> Reduce duplicated hash map lookups.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162361 91177308-0d34-0410-b5e6-96231b3b80d8
9fbf327cfdd27ddb5d845042c95f2299ac95b143 15-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> Remove trailing return flag from FunctionTypeLoc, since we now carry that
information on FunctionProtoType. (This also fixes one of *many* misalignment
problems in the TypeLoc hierarchy...)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161901 91177308-0d34-0410-b5e6-96231b3b80d8
b9d0b76e42fd2d4cdfd135220302458d03ad09fe 27-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> Final piece of core issue 1330: delay computing the exception specification of
a defaulted special member function until the exception specification is needed
(using the same criteria used for the delayed instantiation of exception
specifications for function temploids).

EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like
EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to
resolve the exception specification.

This is enabled for all C++ modes: it's a little faster in the case where the
exception specification isn't used, allows our C++11-in-C++98 extensions to
work, and is still correct for C++98, since in that mode the computation of the
exception specification can't fail.

The diagnostics here aren't great (in particular, we should include implicit
evaluation of exception specifications for defaulted special members in the
template instantiation backtraces), but they're not much worse than before.

Our approach to the problem of cycles between in-class initializers and the
exception specification for a defaulted default constructor is modified a
little by this change -- we now reject any odr-use of a defaulted default
constructor if that constructor uses an in-class initializer and the use is in
an in-class initialzer which is declared lexically earlier. This is a closer
approximation to the current draft solution in core issue 1351, but isn't an
exact match (but the current draft wording isn't reasonable, so that's to be

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160847 91177308-0d34-0410-b5e6-96231b3b80d8
ff398965a5abfaf5bc47bc022876f56a28e5b9a7 11-Jul-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Introduce a flag in SourceManager to treat non-system source files
as "volatile", meaning there's a high enough chance that they may
change while we are trying to use them.

This flag is only enabled by libclang.
Currently "volatile" source files will be stat'ed immediately
before opening them, because the file size stat info
may not be accurate since when we got it (e.g. from the PCH).
This avoids crashes when trying to reference mmap'ed memory
from a file whose size is not what we expect.

Note that there's still a window for a racing issue to occur
but the window for it should be way smaller than before.
We can consider later on to avoid mmap completely on such files.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160074 91177308-0d34-0410-b5e6-96231b3b80d8
811c820257746b1799b790b6adc7804f44154011 06-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Don't store pointers into a std::vector (RawCommentList::Comments). Although
currently we take address of std::vector's contents only after we finished
adding all comments (so no reallocation can happen), this will change in

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159845 91177308-0d34-0410-b5e6-96231b3b80d8
7518b3784ed2176aad8dcabe0685c6e02c5f1043 02-Jul-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Make sure that all newly introduced visible decls in a DeclContext
coming from an AST file are registered for serialization.

A static data member instantiation of in a chained PCH could be missed
when serializing decls; the result was that when emitting the visible decls
map of its DeclContext, we would use a DeclID that was not actually emitted,
leading to crashes or hangs.

Fix this by making sure such decls are always registered for serialization.
Also introduce extra sanity checks to make sure we don't register new
declarations or types after we have serialized the types/decls block.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159550 91177308-0d34-0410-b5e6-96231b3b80d8
fb40e3f10ccef93c4f8fb6bd4fe5a108fa6cd369 01-Jul-2012 Meador Inge <meadori@codesourcery.com> PR13189: va_list broken with precompiled headers

For some targets a structure named __va_list_tag is built to help define
the __builtin_va_list type. However, __va_list_tag was not being treated as a
predefined type thus causing problems when serializing the AST. This commit
fixes that oversight by adding the necessary support to treat __va_list_tag
as a predefined type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159508 91177308-0d34-0410-b5e6-96231b3b80d8
13691bba2423e404b3efc0dfc5206d04ef33dcc6 20-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Fix a warning on a fully covered switch with a default:

../tools/clang/lib/Serialization/ASTReader.cpp:6316:9: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]

Also fix the indentation here to match the coding conventions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158794 91177308-0d34-0410-b5e6-96231b3b80d8
260611a32535c851237926bfcf78869b13c07d5b 20-Jun-2012 John McCall <rjmccall@apple.com> Restructure how the driver communicates information about the
target Objective-C runtime down to the frontend: break this
down into a single target runtime kind and version, and compute
all the relevant information from that. This makes it
relatively painless to add support for new runtimes to the
compiler. Make the new -cc1 flag, -fobjc-runtime=blah-x.y.z,
available at the driver level as a better and more general
alternative to -fgnu-runtime and -fnext-runtime. This new
concept of an Objective-C runtime also encompasses what we
were previously separating out as the "Objective-C ABI", so
fragile vs. non-fragile runtimes are now really modelled as
different kinds of runtime, paving the way for better overall

As a sort of special case, continue to accept the -cc1 flag
-fobjc-runtime-has-weak, as a sop to PLCompatibilityWeak.

I won't go so far as to say "no functionality change", even
ignoring the new driver flag, but subtle changes in driver
semantics are almost certainly not intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158793 91177308-0d34-0410-b5e6-96231b3b80d8
da01f62cdfb0995db355c61d96d45b0f1d790b3d 20-Jun-2012 Kaelyn Uhrain <rikka@google.com> Add the PCH file name to the message about not being able to read the PCH.

Also add a couple of unit tests to check the invalid-PCH error messages
to satisfy PR4568 and for the assertion (introduced in r149918 and fixed
in r158769) that would cause clang to crash when given an empty PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158772 91177308-0d34-0410-b5e6-96231b3b80d8
aa0cd85838f2a024e589ea4e8c2094130065af21 20-Jun-2012 Dmitri Gribenko <gribozavr@gmail.com> Structured comment parsing, first step.

* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158771 91177308-0d34-0410-b5e6-96231b3b80d8
c5613b26a24a33d7450e3d0bf315c6ccc920ce7b 16-Jun-2012 Meador Inge <meadori@codesourcery.com> Explicitly build __builtin_va_list.

The target specific __builtin_va_list types are now explicitly built instead
of injecting strings into the preprocessor input.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158592 91177308-0d34-0410-b5e6-96231b3b80d8
47d9de678162202786aa5f8aa153a7c58a4cebd4 08-Jun-2012 Douglas Gregor <dgregor@apple.com> Switch LineTableInfo to use FileID instead of int for file references,
from Tom Honermann!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158211 91177308-0d34-0410-b5e6-96231b3b80d8
855243789cb44799c03f4c7216d3d6308805f549 07-Jun-2012 Benjamin Kramer <benny.kra@googlemail.com> Plug a long standing memory leak in TemplateArgument.

The integral APSInt value is now stored in a decomposed form and the backing
store for large values is allocated via the ASTContext. This way its not
leaked as TemplateArguments are never destructed when they are allocated in
the ASTContext. Since the integral data is immutable it is now shared between
instances, making copying TemplateArguments a trivial operation.

Currently getting the integral data out of a TemplateArgument requires creating
a new APSInt object. This is cheap when the value is small but can be expensive
if it's not. If this turns out to be an issue a more efficient accessor could
be added.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158150 91177308-0d34-0410-b5e6-96231b3b80d8
581deb3da481053c4993c7600f97acf7768caac5 06-Jun-2012 David Blaikie <dblaikie@gmail.com> Revert Decl's iterators back to pointer value_type rather than reference value_type

In addition, I've made the pointer and reference typedef 'void' rather than T*
just so they can't get misused. I would've omitted them entirely but
std::distance likes them to be there even if it doesn't use them.

This rolls back r155808 and r155869.

Review by Doug Gregor incorporating feedback from Chandler Carruth.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158104 91177308-0d34-0410-b5e6-96231b3b80d8
facde171ae4b8926622a1bffa833732a06f1875b 06-Jun-2012 Benjamin Kramer <benny.kra@googlemail.com> Remove unused private member variables found by clang's new -Wunused-private-field.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158086 91177308-0d34-0410-b5e6-96231b3b80d8
b88acb018a0d5e897ce291da2664edfd7bd58f5c 04-May-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Really, pinky swear, fix for PR12689


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156145 91177308-0d34-0410-b5e6-96231b3b80d8
d54dff026b02303a35147224de72bb44cbb53c79 03-May-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] When validating that the files coming from PCH did not change, also
validate that we didn't override the contents of any of such files.

If this is detected, emit a diagnostic error and recover gracefully
by using the contents of the original file that the PCH was built from.

Part of rdar://11305263

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156107 91177308-0d34-0410-b5e6-96231b3b80d8
262bc18e32500558af7cb0afa205b34bd37bafed 30-Apr-2012 David Blaikie <dblaikie@gmail.com> Remove the ref/value inconsistency in filter_decl_iterator.

filter_decl_iterator had a weird mismatch where both op* and op-> returned T*
making it difficult to generalize this filtering behavior into a reusable
library of any kind.

This change errs on the side of value, making op-> return T* and op* return

(reviewed by Richard Smith)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155808 91177308-0d34-0410-b5e6-96231b3b80d8
394e5392febc66a5511003fd24d540c51beffdd9 26-Apr-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] In ASTReader::completeVisibleDeclsMap, after we loaded all visible decls, mark
the declaration context as not having external visible storage any more.

This should improve performance as we won't needlessly reload the visible decls multiple times
and seems to fix the i386 crash in rdar://11327522.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155649 91177308-0d34-0410-b5e6-96231b3b80d8
7bb698aa054de4c0e0aa23973b2c62dac9611262 21-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix serialization of uninstantiated exception specifications. Patch by Li Kan,
test by me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155289 91177308-0d34-0410-b5e6-96231b3b80d8
b346d2f419ec7d7ce6b20780d518490338efa7de 16-Apr-2012 Nick Lewycky <nicholas@mxc.ca> Implement the all_lookups_iterator for PCH as a follow-up to r153970. This
includes a patch from Matthias Kleine with a regression testcase!

Adds a new iterator 'data_iterator' to OnDiskHashTable which doesn't try to
reconstruct the external_key from the internal_key, which is useful for traits
that don't store enough information to do that mapping in their key. Also
deletes the 'item_iterator' from OnDiskHashTable as dead code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154784 91177308-0d34-0410-b5e6-96231b3b80d8
b1758c662524e18d65d260188fdcbbdee6a9316b 15-Apr-2012 Benjamin Kramer <benny.kra@googlemail.com> Use forward declarations for ASTDeclContextNameLookupTable and add a missing delete.

It would be nice to use OwningPtr here, but DeclContextInfo is stored in a DenseMap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154763 91177308-0d34-0410-b5e6-96231b3b80d8
6c656c3d89523d8ddd143f96e11f6bc16c10c60b 04-Apr-2012 Ted Kremenek <kremenek@apple.com> Remove dead assignment to local variable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153985 91177308-0d34-0410-b5e6-96231b3b80d8
b0d06e2e6b340c198892fa0389fde906903a47ec 04-Apr-2012 Douglas Gregor <dgregor@apple.com> Eliminate obvious use-after-free. Fixes PR12433 / <rdar://problem/11168333>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153982 91177308-0d34-0410-b5e6-96231b3b80d8
643586fe4fcd42b0978efd3566832ab4dce50367 22-Mar-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] When we are replacing a decl in a chained PCH that is also a DeclContext,
make sure to fully load its external lexical and visible declarations before
re-writing it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153254 91177308-0d34-0410-b5e6-96231b3b80d8
4e4d08403ca5cfd4d558fa2936215d3a4e5a528d 11-Mar-2012 David Blaikie <dblaikie@gmail.com> Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).

The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
29f98b40caabca1ec820d546c5c08206a1d4f520 08-Mar-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] Fix a crash when serializing a preprocessing record that contains
an #include entry that did not resolve to header file.

Part of rdar://11007039

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152275 91177308-0d34-0410-b5e6-96231b3b80d8
bef35c91b594f66216f4aab303b71a6c5ab7abcf 07-Mar-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Mark a PCH file with a flag to indicate if the serialized AST had
compiler errors or not.

-Control whether ASTReader should reject such a PCH by a boolean flag at ASTReader's creation time.
By default, such a PCH file will be rejected with an error when trying to load it.

[libclang] Allow clang_saveTranslationUnit to create a PCH file even if compiler errors
-Have libclang API calls accept a PCH that had compiler errors.

The general idea is that we want libclang to stay functional even if a PCH had a compiler error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152192 91177308-0d34-0410-b5e6-96231b3b80d8
c6c54521f95760a5eaf29b668d4bf41fe2af49d7 05-Mar-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [preprocessor] Enhance PreprocessingRecord to keep track of locations of conditional directives.

Introduce PreprocessingRecord::rangeIntersectsConditionalDirective() which returns
true if a given range intersects with a conditional directive block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152018 91177308-0d34-0410-b5e6-96231b3b80d8
b2c60b04a597cc5ba4154837cf8e0a155a376fd7 01-Mar-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Move llvm/ADT/SaveAndRestore.h -> llvm/Support/SaveAndRestore.h.

Needs llvm update.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151829 91177308-0d34-0410-b5e6-96231b3b80d8
d45d361f2ce5c37824052357e2218e8a5509eba5 27-Feb-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Move "clang/Analysis/Support/SaveAndRestore.h" to "llvm/ADT/SaveAndRestore.h"
to make it more widely available.

Depends on llvm commit r151564

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151566 91177308-0d34-0410-b5e6-96231b3b80d8
e1d4330adaaa7faf093e725c9c993207eb2d778a 25-Feb-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Don't record nested macro expansions in the preprocessing record,
it can only bring pain when dealing with preprocessor abuse (see: boost).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151427 91177308-0d34-0410-b5e6-96231b3b80d8
a4c29b6e55c9d4ef44a51c45c6785e8b4fe9deed 21-Feb-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Recover gracefully if the ASTReader detects that a file is different
from the one stored in the PCH/AST, while trying to load a SLocEntry.

We verify that all files of the PCH did not change before loading it but this is not enough because:

- The AST may have been 1) kept around, 2) to do queries on it.
- We may have 1) verified the PCH and 2) started parsing.

Between 1) and 2) files may change and we are going to have crashes because the rest of clang
cannot deal with the ASTReader failing to read a SLocEntry.

Handle this by recovering gracefully in such a case, by initializing the SLocEntry
with the info from the PCH/AST as well as reporting failure by the ASTReader.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151004 91177308-0d34-0410-b5e6-96231b3b80d8
f8af98286022f72157d84951b48fde5fb369ab29 12-Feb-2012 Douglas Gregor <dgregor@apple.com> Within the body of a lambda expression, decltype((x)) for an
id-expression 'x' will compute the type based on the assumption that
'x' will be captured, even if it isn't captured, per C++11
[expr.prim.lambda]p18. There are two related refactors that go into
implementing this:

1) Split out the check that determines whether we should capture a
particular variable reference, along with the computation of the
type of the field, from the actual act of capturing the
2) Always compute the result of decltype() within Sema, rather than
AST, because the decltype() computation is now context-sensitive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150347 91177308-0d34-0410-b5e6-96231b3b80d8
eefb3d5b49c844347f212073a7e975b8118fe8e9 10-Feb-2012 Richard Smith <richard-llvm@metafoo.co.uk> Track whether a function type has a trailing return type as type sugar. Use this
to pretty-print such function types better, and to fix a case where we were not
instantiating templates in lexical order. In passing, move the Variadic bit from
Type's bitfields to FunctionProtoType to get the Type bitfields down to 32 bits.
Also ensure that we always substitute the return type of a function when
substituting explicitly-specified arguments, since that can cause us to bail
out with a SFINAE error before we hit a hard error in parameter substitution.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150241 91177308-0d34-0410-b5e6-96231b3b80d8
44d2dbdce49d1fca3826d543ba875bb82f759091 09-Feb-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix ASTReader::FinishedDeserializing().

We were passing a decl to the consumer after all pending deserializations were finished
but this was not enough; due to processing by the consumer we may end up into yet another
deserialization process but the way FinishedDeserializing() was setup we would not ensure
that everything was fully deserialized before returning to the consumer.

Separate ASTReader::FinishedDeserializing() into two semantic actions.
The first is ensuring that a deserialization process ends up will fully deserialized decls/types even
if the process is started by the consumer.
The second is pushing "interesting" decls to the consumer; we make sure that we don't re-enter this
section recursively be checking a variable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150160 91177308-0d34-0410-b5e6-96231b3b80d8
66581d41527628d4b37f7b05c288f77be7415d7d 06-Feb-2012 Abramo Bagnara <abramo.bagnara@gmail.com> Added source location for the template keyword in DependentTemplateSpecializationTypeLoc nodes (DTSTLoc).

The new info is propagated to TSTLoc on template instantiation, getting rid of 3 FIXMEs in TreeTransform.h and another one Parser.cpp.

Simplified code in TypeSpecLocFiller visitor methods for DTSTLoc and DependentNameTypeLoc by removing what now seems to be dead code (adding corresponding assertions).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149923 91177308-0d34-0410-b5e6-96231b3b80d8
38a42916cb07fd368d9e2ae1e7915fa896f9ec06 06-Feb-2012 Abramo Bagnara <abramo.bagnara@gmail.com> Removed redundant location info from ElaboratedTypeLoc / DependentNameLoc / DependentTSTLoc. Uniformed names referencing elaborated keyword. No intended functionality changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149889 91177308-0d34-0410-b5e6-96231b3b80d8
55d23c925b058be29b792008ddb7d68f6c4fa9a0 06-Feb-2012 Abramo Bagnara <abramo.bagnara@gmail.com> Added location for template keyword in TemplateSpecializationTypeLoc. In the process removed some naming ambiguities.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149870 91177308-0d34-0410-b5e6-96231b3b80d8
f7ccbad5d9949e7ddd1cbef43d482553b811e026 05-Feb-2012 Dylan Noblesmith <nobled@dreamwidth.org> Basic: import SmallString<> into clang namespace

(I was going to fix the TODO about DenseMap too, but
that would break self-host right now. See PR11922.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149799 91177308-0d34-0410-b5e6-96231b3b80d8
6f42b62b6194f53bcbc349f5d17388e1936535d7 05-Feb-2012 Dylan Noblesmith <nobled@dreamwidth.org> Basic: import OwningPtr<> into clang namespace

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149798 91177308-0d34-0410-b5e6-96231b3b80d8
dc58aa71026cce539ca9b5c2c52cc4efc7bd77fe 30-Jan-2012 Douglas Gregor <dgregor@apple.com> Thread a TargetInfo through to the module map; we'll need it for
target-specific module requirements.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149224 91177308-0d34-0410-b5e6-96231b3b80d8
a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6f 27-Jan-2012 Douglas Gregor <dgregor@apple.com> Introduce module attributes into the module map grammar, along with a
single attribute ("system") that allows us to mark a module as being a
"system" module. Each of the headers that makes up a system module is
considered to be a system header, so that we (for example) suppress
warnings there.

If a module is being inferred for a framework, and that framework
directory is within a system frameworks directory, infer it as a
system framework.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149143 91177308-0d34-0410-b5e6-96231b3b80d8
cff9f26ce0ed76d555cd33b3dca84dd5cdf376af 27-Jan-2012 Douglas Gregor <dgregor@apple.com> Reimplement (de-)serialization of Objective-C categories to eliminate
the direct serialization of the linked-list structure. Instead, use a
scheme similar to how we handle redeclarations, with redeclaration
lists on the side. This addresses several issues:
- In cases involving mixing and matching of many categories across
many modules, the linked-list structure would not be consistent
across different modules, and categories would get lost.
- If a module is loaded after the class definition and its other
categories have already been loaded, we wouldn't see any categories
in the newly-loaded module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149112 91177308-0d34-0410-b5e6-96231b3b80d8
8efca6bb688d32fd7c0d91b504ef3307f97ee66a 25-Jan-2012 Douglas Gregor <dgregor@apple.com> Introduce a generation number for selector lookups in the global
method pool, so that we don't perform the same lookups into the same
PCH/module file repeatedly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148895 91177308-0d34-0410-b5e6-96231b3b80d8
5ac4b6917aa34fae6da64036539023a6155a3d48 25-Jan-2012 Douglas Gregor <dgregor@apple.com> Rework the external Sema source's ReadMethodPool() so that it doesn't
return pre-built lists. Instead, it feeds the methods it deserializes
to Sema so that Sema can unique them, which keeps the chains shorter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148889 91177308-0d34-0410-b5e6-96231b3b80d8
5d5051f3e79bf754134ccdf7a1dc7778cd80c73e 24-Jan-2012 Douglas Gregor <dgregor@apple.com> Only mark an IdentifierInfo as having changed since deserialization
when it actually has changed (and not, e.g., when we've simply attached a
deserialized macro definition). Good for ~1.5% reduction in module
file size, mostly in the identifier table.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148808 91177308-0d34-0410-b5e6-96231b3b80d8
057df20b3107cef764052d271c89b8591b98b3ce 18-Jan-2012 Douglas Gregor <dgregor@apple.com> Optimize unqualified/global name lookup in modules by introducing a
generational scheme for identifiers that avoids searching the hash
tables of a given module more than once for a given
identifier. Previously, loading any new module invalidated all of the
previous lookup results for all identifiers, causing us to perform the
lookups repeatedly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148412 91177308-0d34-0410-b5e6-96231b3b80d8
56ca8a9c0fabd65418e9b2fd85140f4ed7d3c187 17-Jan-2012 Douglas Gregor <dgregor@apple.com> Rework the way in which we (de-)serialize the declarations
corresponding to TagType and ObjCInterfaceType. Previously, we would
serialize the definition (if available) or the canonical declaration
(if no definition was available). However, this can end up forcing the
deserialization of the definition even through we might not want to

Instead, always serialize the canonical declaration reference in the
TagType/ObjCInterfaceType entry, and as part of loading a pending
definition, update the "decl" pointer within the type node to point at
the definition. This is more robust in hard-to-isolate cases
where the *Type gets built and filled in before we see the definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148323 91177308-0d34-0410-b5e6-96231b3b80d8
a6ea10e22b600d92e084f6b11b9b9a92d0eb2412 17-Jan-2012 Douglas Gregor <dgregor@apple.com> Delay the creation of the built-in Objective-C class 'Protocol' by
moving it from a "special type" to a predefined declaration, as we do
for id, Class, and SEL.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148313 91177308-0d34-0410-b5e6-96231b3b80d8
7530c034c0c71a64c5a9173206d9742ae847af8b 17-Jan-2012 David Blaikie <dblaikie@gmail.com> Remove unreachable code in Clang. (replace with llvm_unreachable where appropriate or when GCC requires it)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148292 91177308-0d34-0410-b5e6-96231b3b80d8
2171bf1caba4d4b9eeb6a91efac4300b41f38b07 15-Jan-2012 Douglas Gregor <dgregor@apple.com> Completely re-implement (de-)serialization of redeclaration
chains, again. The prior implementation was very linked-list oriented, and
the list-splicing logic was both fairly convoluted (when loading from
multiple modules) and failed to preserve a reasonable ordering for the
redeclaration chains.

This new implementation uses a simpler strategy, where we store the
ordered redeclaration chains in an array-like structure (indexed based
on the first declaration), and use that ordering to add individual
deserialized declarations to the end of the existing chain. That way,
the chain mimics the ordering from its modules, and a bug somewhere is
far less likely to result in a broken linked list.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148222 91177308-0d34-0410-b5e6-96231b3b80d8
7c99bb5c4901c39460818ff8c00840218c48251f 14-Jan-2012 Douglas Gregor <dgregor@apple.com> Reimplement RedeclarableTemplateDecl in terms of
Redeclarable<RedeclarableTemplateDecl>, eliminating a bunch of
redeclaration-chain logic both in RedeclarableTemplateDecl and
especially in its (de-)serialization.

As part of this, eliminate the RedeclarableTemplate<> class template,
which was an abstraction that didn't actually save anything.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148181 91177308-0d34-0410-b5e6-96231b3b80d8
c6c8e0ec96bb64f1b9f543d7c8317c6090f80a30 09-Jan-2012 Douglas Gregor <dgregor@apple.com> Implement redeclaration merging for namespaces defined in distinct
modules. Teach name lookup into namespaces to search in each of the
merged DeclContexts as well as the (now-primary) DeclContext. This
supports the common case where two different modules put something
into the same namespace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147778 91177308-0d34-0410-b5e6-96231b3b80d8
f143ffc4a9af79ac1d822fea6995af4bf45d17dc 06-Jan-2012 Douglas Gregor <dgregor@apple.com> Introduce a "Hidden" bit into Decl, to track whether that declaration
is hidden from name lookup. The previous hack of tweaking the
ModulePrivate bit when loading a declaration from a hidden submodule
was brittle.

Note that we now have 34 bits in Decl. I'll fix that next.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147658 91177308-0d34-0410-b5e6-96231b3b80d8
9b8b20f7a4e2d2557fc49149ebd0df7a7b2c57dd 06-Jan-2012 Douglas Gregor <dgregor@apple.com> Teach DeclContext deserialization to pay attention to endianness, from
David Fang and Takumi Nakamura. Fixes many PCH failures on PowerPC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147657 91177308-0d34-0410-b5e6-96231b3b80d8
b8c879a5363f36bdae8831112b563333e3c05acb 05-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> When loading an AST file, set SourceManager::MainFileID to the main file of the AST file,
as suggested by Tom Honermann.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147612 91177308-0d34-0410-b5e6-96231b3b80d8
b7a7819473709c01ea024a2dc15e99d38f0f8760 05-Jan-2012 Douglas Gregor <dgregor@apple.com> Store the submodules of a module in source order, as they are stored
in the module map. This provides a bit more predictability for the
user, as well as eliminating the need to sort the submodules when
serializing them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147564 91177308-0d34-0410-b5e6-96231b3b80d8
1d784b277cdfd4eba03680715d2a082b3f28d295 01-Jan-2012 Douglas Gregor <dgregor@apple.com> Introduce the core infrastructure needed to model redeclaration chains
for Objective-C protocols, including:
- Using the first declaration as the canonical declaration
- Using the definition as the primary DeclContext
- Making sure that all declarations have a pointer to the definition
data, and that we know which declaration is the definition
- Serialization support for redeclaration chains and for adding
definitions to already-serialized declarations.

However, note that we're not taking advantage of much of this code
yet, because we're still re-using ObjCProtocolDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147410 91177308-0d34-0410-b5e6-96231b3b80d8
51f564f80d9f71e175635b452ffeeeff899e9bf1 31-Dec-2011 Douglas Gregor <dgregor@apple.com> Implement support for module requirements, which indicate the language
features needed for a particular module to be available. This allows
mixed-language modules, where certain headers only work under some
language variants (e.g., in C++, std.tuple might only be available in
C++11 mode).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147387 91177308-0d34-0410-b5e6-96231b3b80d8
c3cfd2ab3338d47861ece597212f21b972ebe727 22-Dec-2011 Douglas Gregor <dgregor@apple.com> Serialize the AST reader's mapping from canonical declarations to the
set of (previously-canonical) declaration IDs to the module file, so
that future AST reader instances that load the module know which
declarations are merged. This is important in the fairly tricky case
where a declaration of an entity, e.g.,

@class X;

occurs before the import of a module that also declares that
entity. We merge the declarations, and record the fact that the
declaration of X loaded from the module was merged into the (now
canonical) declaration of X that we parsed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147181 91177308-0d34-0410-b5e6-96231b3b80d8
0f75323264b93a318ac9007eb5ec5b233c444068 22-Dec-2011 Douglas Gregor <dgregor@apple.com> When deserializing an Objective-C class, check whether we have another
declaration of that same class that either came from some other module
or occurred in the translation unit loading the module. In this case,
we need to merge the two redeclaration chains immediately so that all
such declarations have the same canonical declaration in the resulting
AST (even though they don't in the module files we've imported).

Focusing on Objective-C classes until I'm happy with the design, then
I'll both (1) extend this notion to other kinds of declarations, and
(2) optimize away this extra checking when we're not dealing with
modules. For now, doing this checking for PCH files/preambles gives us
better testing coverage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147123 91177308-0d34-0410-b5e6-96231b3b80d8
1d4c1137c314cfb9ced32006cacdb80deffb66d4 20-Dec-2011 Douglas Gregor <dgregor@apple.com> When we make a previously-deserialized module definition visible,
notify the AST deserialization listener so that the AST writer knows
that it can write the macro definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146994 91177308-0d34-0410-b5e6-96231b3b80d8
2fbf373a56b762e274af187bcb193634815ba1d2 20-Dec-2011 Richard Smith <richard-llvm@metafoo.co.uk> Fix off-by-one error in an assert condition. No functionality change, but better
error detection.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146962 91177308-0d34-0410-b5e6-96231b3b80d8
305dc3ebaa0bea5f3b789e4b54afc79c25907615 20-Dec-2011 Douglas Gregor <dgregor@apple.com> Detect when mapping a #include/#import over to a submodule ends up
hitting a submodule that was never actually created, e.g., because
that header wasn't parsed. In such cases, complain (because the
module's umbrella headers don't cover everything) and fall back to
including the header.

Later, we'll add a warning at module-build time to catch all such
cases. However, this fallback is important to eliminate assertions in
the ASTWriter when this happens.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146933 91177308-0d34-0410-b5e6-96231b3b80d8
a126651270acf17c434f60f86a3ab3687f87813a 19-Dec-2011 Douglas Gregor <dgregor@apple.com> Eliminate the first->last redeclaration map from the AST file
format. It's no longer being used, now that we have a new
implementation of redeclaration chains.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146905 91177308-0d34-0410-b5e6-96231b3b80d8
21cf08b7e0c03266f37f436c2afd8521c643b31a 19-Dec-2011 Douglas Gregor <dgregor@apple.com> Remove ASTReader's PendingForwardRefs, which is now handled by the
(more general) fix-up of definition data pointers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146903 91177308-0d34-0410-b5e6-96231b3b80d8
fc529f7fcafe7da0b8a32621e13685891e8ce52a 19-Dec-2011 Douglas Gregor <dgregor@apple.com> Once we have fully deserialized a redeclaration chain for something
with a definition pointer (e.g., C++ and Objective-C classes), zip
through the redeclaration chain to make sure that all of the
declarations point to the definition data.

As part of this, realized again why the first redeclaration of an
entity in a file is important, and brought back that idea.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146886 91177308-0d34-0410-b5e6-96231b3b80d8
adafc2edc0dc4fa25ea6f0a136f599a6ac279081 19-Dec-2011 Douglas Gregor <dgregor@apple.com> The submodule offset map can introduce "empty" remapping entries for
imported modules that don't introduce any new entities of a particular
kind. Allow these entries to be replaced with entries for another
loaded module.

In the included test case, selectors exhibit this behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146870 91177308-0d34-0410-b5e6-96231b3b80d8
925be547b163675b312e3cac0cc7f37f31d787c1 19-Dec-2011 Craig Topper <craig.topper@gmail.com> Begin adding AVX2 intrinsics. Necessitated increasing the number of bits used to store builtinID when serializing identifier table.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146855 91177308-0d34-0410-b5e6-96231b3b80d8
a1be278c4f3a234ff61f04018d26c6beecde1654 18-Dec-2011 Douglas Gregor <dgregor@apple.com> Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration
chain being stored as a (circular) linked list on disk, as it is in
memory. However, when deserializing from multiple modules, the
different chains could get mixed up, leading to broken declaration chains.

The new solution keeps track of the first and last declarations in the
chain for each module file. When we load a declaration, we search all
of the module files for redeclarations of that declaration, then
splice together all of the lists into a coherent whole (along with any
redeclarations that were actually parsed).

As a drive-by fix, (de-)serialize the redeclaration chains of
TypedefNameDecls, which had somehow gotten missed previously. Add a
test of this serialization.

This new scheme creates a redeclaration table that is fairly large in
the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The
table is mmap'd in and searched via a binary search, but it's still
quite large. A future tweak will eliminate entries for declarations
that have no redeclarations anywhere, and should
drastically reduce the size of this table.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146841 91177308-0d34-0410-b5e6-96231b3b80d8
917078386b9b5113f33c093e296e10927b00b37e 17-Dec-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Don't deserialize bodies of interesting decls while iterating
over them because more interesting decls can be added during body

Should fix msvc build tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146824 91177308-0d34-0410-b5e6-96231b3b80d8
71168330e25fdce4c1a3bf46484a2d81e2e21011 17-Dec-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] In ASTReader::FinishedDeserializing fully load the interesting decls,
including deserializing their bodies, so that any other declarations that
get referenced in the body will be fully deserialized by the time we pass them to the consumer.

Could not reduce to a test case unfortunately. rdar://10587158.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146817 91177308-0d34-0410-b5e6-96231b3b80d8
fd002a7027e47ddd4bc9f32b158b18ab0ebd29c7 16-Dec-2011 Douglas Gregor <dgregor@apple.com> Make sure we're always setting the previous declaration of an ObjCInterfaceDecl

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146763 91177308-0d34-0410-b5e6-96231b3b80d8
99a922b6da21a474f8ed35f2b1a3bfd627900d1a 09-Dec-2011 Douglas Gregor <dgregor@apple.com> Use llvm::sys::fs::equivalent rather than comparing inodes, because
comparing inodes doesn't actually work on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146260 91177308-0d34-0410-b5e6-96231b3b80d8
cb381eac84e5a14a8c7e7654eadbe1d3d54d795c 09-Dec-2011 Chandler Carruth <chandlerc@gmail.com> Move a free function from the Frontend library into the Lex library as
part of HeaderSearch. This function just normalizes filenames for use
inside of a synthetic include directive, but it is used in both the
Frontend and Serialization libraries so it needs a common home.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146227 91177308-0d34-0410-b5e6-96231b3b80d8
a2398d7da920b896001f385587e7f7d3366e5b17 09-Dec-2011 Chandler Carruth <chandlerc@gmail.com> Separate the serialization library's diagnostics from the frontend's
diagnostics. Conflating them was highly confusing and makes it harder to
establish a firm layering separation between these two libraries.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146207 91177308-0d34-0410-b5e6-96231b3b80d8
77d029f6a24dbf70d97e61757945df53fb250ea0 08-Dec-2011 Douglas Gregor <dgregor@apple.com> Implement umbrella directories for modules, which are similar to
umbrella headers in the sense that all of the headers within that
directory (and eventually its subdirectories) are considered to be
part of the module with that umbrella directory. However, unlike
umbrella headers, which are expected to include all of the headers
within their subdirectories, Clang will automatically include all of
the headers it finds in the named subdirectory.

The intent here is to allow a module map to trivially turn a
subdirectory into a module, where the module's structure can mimic the
directory structure.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146165 91177308-0d34-0410-b5e6-96231b3b80d8
10694cee2588442bee1e717f5042c58ffee25279 08-Dec-2011 Douglas Gregor <dgregor@apple.com> Within the module representation, generalize the notion of an umbrella
header to also support umbrella directories. The umbrella directory
for an umbrella header is the directory in which the umbrella header

No functionality change yet, but it's coming.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146158 91177308-0d34-0410-b5e6-96231b3b80d8
84fa05ef805ecfb8b264d4c1984d1d48eec821b5 07-Dec-2011 Benjamin Kramer <benny.kra@googlemail.com> Remove unused-but-set variable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146034 91177308-0d34-0410-b5e6-96231b3b80d8
e209e5026892cb07294f733c72bd51359c0f0e72 06-Dec-2011 Douglas Gregor <dgregor@apple.com> Implement inferred submodules support, which (when requested)
implicitly generates submodules corresponding to the headers that fall
within a module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145887 91177308-0d34-0410-b5e6-96231b3b80d8
1e12368db12005ddd92fd9188c86383fe30ef443 05-Dec-2011 Douglas Gregor <dgregor@apple.com> Parse inferred submodules in module maps, track their contents in
Module, and (de-)serialize this information. Semantics of inferred
submodules to follow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145864 91177308-0d34-0410-b5e6-96231b3b80d8
0adaa880993ad23186c87c7f98e7a3fd2697742c 05-Dec-2011 Douglas Gregor <dgregor@apple.com> Implement support for wildcard exports in modules, allowing a module
to re-export anything that it imports. This opt-in feature makes a
module behave more like a header, because it can be used to re-export
the transitive closure of a (sub)module's dependencies.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145811 91177308-0d34-0410-b5e6-96231b3b80d8
55988680ece66b8e505ee136b35e74fcb1173aee 05-Dec-2011 Douglas Gregor <dgregor@apple.com> When writing a module file, keep track of the set of (sub)modules that
it imports, establishing dependencies at the (sub)module
granularity. This is not a user-visible change (yet).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145808 91177308-0d34-0410-b5e6-96231b3b80d8
f6137e4d15cb6bbd10547267babfc699c1945873 03-Dec-2011 Douglas Gregor <dgregor@apple.com> Implement support for precompiled headers, preambles, and serialized
"main" files that import modules. When loading any of these kinds of
AST files, we make the modules that were imported visible into the
translation unit that loaded the PCH file or preamble.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145737 91177308-0d34-0410-b5e6-96231b3b80d8
6236a29f5082d4736c4593ca1a04595037db1685 02-Dec-2011 Douglas Gregor <dgregor@apple.com> Only perform checking of the predefines buffer when loading a
precompiled header. Previously, we were trying to gather predefines
buffers from all kinds of AST files (which doesn't make sense) and
were performing some validation when AST files were loaded as main

With these tweaks, using PCH files that import modules no longer fails
immediately (due to mismatched predefines buffers). However, module
visibility is lost, so this feature does not yet work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145709 91177308-0d34-0410-b5e6-96231b3b80d8
07165b9e3b78ed76a7db561f392335e4a54c9e51 02-Dec-2011 Douglas Gregor <dgregor@apple.com> When making a module visible, also make any of its exported modules
visible, allowing one to create modules that import (and then
re-export) other modules.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145696 91177308-0d34-0410-b5e6-96231b3b80d8
af13bfc3b40aa4a46f4e71d200ecfb10f45297fc 02-Dec-2011 Douglas Gregor <dgregor@apple.com> Implement (de-)serialization of the set of exported modules in a
module map.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145695 91177308-0d34-0410-b5e6-96231b3b80d8
a015cab273705d1198d13e8389c2f4775f539a8b 02-Dec-2011 Douglas Gregor <dgregor@apple.com> Notify the AST writer (via ASTDeserializationListener) when a
(sub)module is read from an AST file. This makes sure that the AST
writer knows how to map all modules to their global IDs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145685 91177308-0d34-0410-b5e6-96231b3b80d8
1329264ce0922b3cec8c8c599108f082105fa0e1 02-Dec-2011 Douglas Gregor <dgregor@apple.com> Implement name hiding for macro definitions within modules, such that
only the macro definitions from visible (sub)modules will actually be
visible. This provides the same behavior for macros that r145640
provided for declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145683 91177308-0d34-0410-b5e6-96231b3b80d8
ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0 01-Dec-2011 Douglas Gregor <dgregor@apple.com> Implement name hiding for declarations deserialized from a non-visible
module. When that module becomes visible, so do those declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145640 91177308-0d34-0410-b5e6-96231b3b80d8
5e35693721364673f8196e4f5a370f56b92e6053 01-Dec-2011 Douglas Gregor <dgregor@apple.com> Introduce the notion of name visibility into modules. For a given
(sub)module, all of the names may be hidden, just the macro names may
be exposed (for example, after the preprocessor has seen the import of
the module but the parser has not), or all of the names may be
exposed. Importing a module makes its names, and the names in any of
its non-explicit submodules, visible to name lookup (transitively).

This commit only introduces the notion of name visible and marks
modules and submodules as visible when they are imported. The actual
name-hiding logic in the AST reader will follow (along with test cases).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145586 91177308-0d34-0410-b5e6-96231b3b80d8
26ced127b7d443fcf3472463c9f39c2376bd9d70 01-Dec-2011 Douglas Gregor <dgregor@apple.com> Switch the ID numbers used for submodule IDs in the AST reader over to
a standard global/local scheme, so that submodule definitions will
eventually be able to refer to submodules in other top-level
modules. We'll need this functionality soonish.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145549 91177308-0d34-0410-b5e6-96231b3b80d8
1a4761edca58c6b559de825b9abfb66f7f1ba94a 01-Dec-2011 Douglas Gregor <dgregor@apple.com> Promote ModuleMap::Module to a namespace-scope class in the Basic
library, since modules cut across all of the libraries. Rename
serialization::Module to serialization::ModuleFile to side-step the
annoying naming conflict. Prune a bunch of ModuleMap.h includes that
are no longer needed (most files only needed the Module type).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145538 91177308-0d34-0410-b5e6-96231b3b80d8
8d39c3ddfc17d9e768a17eb0ce9f11c33bf9d50a 01-Dec-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] In ASTReader::FinishedDeserializing, after we do PassInterestingDeclsToConsumer
we may end up having added more pending stuff to do, so go in a loop until everything
is cleared out.

This fixes the error in rdar://10278815 which has a certain David Lynch-esque quality..

error: unknown type name 'BOOL'; did you mean 'BOOL'?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145536 91177308-0d34-0410-b5e6-96231b3b80d8
392ed2b717d86ebdd202cb9bb58d18d8b3b4cd87 30-Nov-2011 Douglas Gregor <dgregor@apple.com> Implement (de-)serialization of the description of a module and its
submodules. This information will eventually be used for name hiding
when dealing with submodules. For now, we only use it to ensure that
the module "key" returned when loading a module will always be a
module (rather than occasionally being a FileEntry).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145497 91177308-0d34-0410-b5e6-96231b3b80d8
c14a03dffff69b5e1c55cc118fc52d8fd9f3a28d 23-Nov-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] Fix operations (token annotation, getting cursor, etc.) with a file region
inside an objc container that "contains" other file-level declarations.

When getting the array of file-level declarations that overlap with a file region,
we failed to report that the region overlaps with an objc container, if
the container had other file-level declarations declared lexically inside it.

Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST
and handling them appropriately.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145109 91177308-0d34-0410-b5e6-96231b3b80d8
a4581a120cbcc373b02f13ef744591679f0c2d8c 17-Nov-2011 Douglas Gregor <dgregor@apple.com> If we're dealing with an overridden buffer in the AST reader, load the
file as a virtual file with the stored modification time and size.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144916 91177308-0d34-0410-b5e6-96231b3b80d8
35f9ae6dd221bd403299a895e97aaaf63507287a 17-Nov-2011 Douglas Gregor <dgregor@apple.com> Try to appease the failing buildbot where I can't reproduce the problem

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144879 91177308-0d34-0410-b5e6-96231b3b80d8
a081da5e44600d02983d6562bed1b4fd61e410fd 16-Nov-2011 Douglas Gregor <dgregor@apple.com> Implement (de-)serialization of the buffer contents for an overridden
file in the source manager. This allows us to properly create and use
modules described by module map files without umbrella headers (or
with incompletely umbrella headers). More generally, we can actually
build a PCH file that makes use of file -> buffer remappings, which
could be useful in libclang in the future.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144830 91177308-0d34-0410-b5e6-96231b3b80d8
b86b8dc7ef89405205f94635c1073cdb1a7093eb 15-Nov-2011 Douglas Gregor <dgregor@apple.com> Add a -cc1-level option -fmodule-name=<name>, which will be used when
building modules.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144680 91177308-0d34-0410-b5e6-96231b3b80d8
5a174990e84b33b20761f2fde51169400dd87f2e 14-Nov-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Load the chained objc categories only after recursive loading is finished
otherwise we may crash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144524 91177308-0d34-0410-b5e6-96231b3b80d8
e2d4f4ed44a32f179c6d48cd1dba8346ab2129d9 13-Nov-2011 Rafael Espindola <rafael.espindola@gmail.com> Fix the signature of the getcontext builtin. Patch by Dimitry Andric.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144505 91177308-0d34-0410-b5e6-96231b3b80d8
72cd7a0e94629dc200aa97f88c4788ac2e923b48 11-Nov-2011 Douglas Gregor <dgregor@apple.com> Rename SPECIAL_TYPE_jmp_buf and SPECIAL_TYPE_sigjmp_buf to follow the
convention of SPECIAL_TYPE*.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144403 91177308-0d34-0410-b5e6-96231b3b80d8
87429a05ff66fe6460eaa4855fd0da574e26bf7b 09-Nov-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Fix reading from PCH of diagnostic pragmas.

In certain cases ASTReader would call the normal DiagnosticsEngine API to initialize
the state of diagnostic pragmas but DiagnosticsEngine would try to compare source locations
leading to crash because the main FileID was not yet initialized.

Yet another case of the ASTReader trying to use the normal APIs and inadvertently breaking
invariants. Fix this by having the ASTReader set up the internal state directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144153 91177308-0d34-0410-b5e6-96231b3b80d8
dfb332d0081c6641d1dbae6a2aeff757c99cc740 03-Nov-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] Add infrastructure to be able to only deserialize decls in a file region and
use it for clang_getCursor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143605 91177308-0d34-0410-b5e6-96231b3b80d8
76852c218a207ef43583515cb835b6e855353a0f 01-Nov-2011 Douglas Gregor <dgregor@apple.com> Rework the AST for the initializer of a delegating constructor, so
that it retains source location information for the type. Aside from
general goodness (being able to walk the types described in that
information), we now have a proper representation for dependent
delegating constructors. Fixes PR10457 (for real).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143410 91177308-0d34-0410-b5e6-96231b3b80d8
ef23b6001e8d9715246ca23bd8c3a6887d7844cb 31-Oct-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Now that we store the location of a decl outside its record
make sure that we keep track of locations of replaced decls as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143341 91177308-0d34-0410-b5e6-96231b3b80d8
9d128d04578c62675eeb0cce83066052f9c19c9a 31-Oct-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] For ASTReader's FileDeclIDs also associate the Module that the
local DeclIDs came from.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143340 91177308-0d34-0410-b5e6-96231b3b80d8
10f3df54486385e6497c9e5f229ff816e5a6c511 29-Oct-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Keep track of file-level declarations that are contained by files.

Introduce a FILE_SORTED_DECLS [de]serialization record that contains
a file sorted array of file-level DeclIDs in a PCH/Module.
The rationale is to allow "targeted" deserialization of decls inside
a range of a source file.

Cocoa PCH increased by 0.8%
Difference of creation time for Cocoa PCH is below the noise level.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143238 91177308-0d34-0410-b5e6-96231b3b80d8
9d31fa75bc05fe4cb903a7701550f22cfb73ea8b 27-Oct-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Pull the location out of the serialized declarations and put it in the array
of decl bit offsets.

This allows us to easily get at the location of a decl without deserializing it.
It increases size of Cocoa PCH by only 0.2%.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143123 91177308-0d34-0410-b5e6-96231b3b80d8
eee242ff426bf79149f221798966e58688383c1e 27-Oct-2011 Douglas Gregor <dgregor@apple.com> Make the loading of information attached to an IdentifierInfo from an
AST file more lazy, so that we don't eagerly load that information for
all known identifiers each time a new AST file is loaded. The eager
reloading made some sense in the context of precompiled headers, since
very few identifiers were defined before PCH load time. With modules,
however, a huge amount of code can get parsed before we see an
@import, so laziness becomes important here.

The approach taken to make this information lazy is fairly simple:
when we load a new AST file, we mark all of the existing identifiers
as being out-of-date. Whenever we want to access information that may
come from an AST (e.g., whether the identifier has a macro definition,
or what top-level declarations have that name), we check the
out-of-date bit and, if it's set, ask the AST reader to update the
IdentifierInfo from the AST files. The update is a merge, and we now
take care to merge declarations before/after imports with declarations
from multiple imports.

The results of this optimization are fairly dramatic. On a small
application that brings in 14 non-trivial modules, this takes modules
from being > 3x slower than a "perfect" PCH file down to 30% slower
for a full rebuild. A partial rebuild (where the PCH file or modules
can be re-used) is down to 7% slower. Making the PCH file just a
little imperfect (e.g., adding two smallish modules used by a bunch of
.m files that aren't in the PCH file) tips the scales in favor of the
modules approach, with 24% faster partial rebuilds.

This is just a first step; the lazy scheme could possibly be improved
by adding versioning, so we don't search into modules we already
searched. Moreover, we'll need similar lazy schemes for all of the
other lookup data structures, such as DeclContexts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143100 91177308-0d34-0410-b5e6-96231b3b80d8
3c3b7f90a863af43fa63043d396553ecf205351c 25-Oct-2011 John McCall <rjmccall@apple.com> Restore r142914 and r142915, now with missing file and apparent
GCC compiler workaround.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142931 91177308-0d34-0410-b5e6-96231b3b80d8
327a50f46449c946c42d50d97689bcb30e2af7d9 25-Oct-2011 NAKAMURA Takumi <geek4civic@gmail.com> Revert r142914 and r142915, due to possibly missing file.

r142914: "Introduce a placeholder type for "pseudo object""
r142915: "Pull the pseudo-object stuff into its own file."

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142921 91177308-0d34-0410-b5e6-96231b3b80d8
a1b852f8e1bee5ed3604ee483803cef39ce57a20 25-Oct-2011 John McCall <rjmccall@apple.com> Introduce a placeholder type for "pseudo object"
expressions: expressions which refer to a logical rather
than a physical l-value, where the logical object is
actually accessed via custom getter/setter code.
A subsequent patch will generalize the AST for these
so that arbitrary "implementing" sub-expressions can
be provided.

Right now the only client is ObjC properties, but
this should be generalizable to similar language
features, e.g. Managed C++'s __property methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142914 91177308-0d34-0410-b5e6-96231b3b80d8
f226ff9fe8c8db6c5b74a61ce649eda1491c3502 25-Oct-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] When visiting preprocessed entities, make it possible to avoid deserializing
preprocessed entities that are #included in the range that we are interested.

This is useful when we are interested in preprocessed entities of a specific file, e.g
when we are annotating tokens. There is also an optimization where we cache the last
result of PreprocessingRecord::getPreprocessedEntitiesInRange and we re-use it if
there is a call with the same range as before.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142887 91177308-0d34-0410-b5e6-96231b3b80d8
541ba16defc1b89630cbdecdf1c09487bafd969f 17-Oct-2011 Douglas Gregor <dgregor@apple.com> Controlling macros are identifiers, not declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142225 91177308-0d34-0410-b5e6-96231b3b80d8
0ddaeb9b031070ec64afe92d9892875ac44df427 17-Oct-2011 John McCall <rjmccall@apple.com> Add a new placeholder type to represent "unbridged"
casts in ARC.

No semantic analysis yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142208 91177308-0d34-0410-b5e6-96231b3b80d8
aa93a875605536d72a10359a0098396192b7d4ec 17-Oct-2011 Douglas Gregor <dgregor@apple.com> For modules, all macros that aren't include guards are implicitly
public. Add a __private_macro__ directive to hide a macro, similar to
the __module_private__ declaration specifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142188 91177308-0d34-0410-b5e6-96231b3b80d8
aa4a99b4a62615db243f7a5c433169f2fc704420 15-Oct-2011 Anton Korobeynikov <asl@math.spbu.ru> Provide half floating point support as a storage only type.
Lack of half FP was a regression compared to llvm-gcc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142016 91177308-0d34-0410-b5e6-96231b3b80d8
b001de7458d17c17e6d8b8034c7cfcefd3b70c00 07-Oct-2011 Eli Friedman <eli.friedman@gmail.com> Support for C1x _Atomic specifier (see testcase). This is primarily being committed at the moment to help support C++0x <atomic>, but it should be a solid base for implementing the full specification of C1x _Atomic.

Thanks to Jeffrey Yasskin for the thorough review!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141330 91177308-0d34-0410-b5e6-96231b3b80d8
eabdd6716dfe777a28435276fe6c89af77608b11 27-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Add a comment in ASTReader::ReadPragmaDiagnosticMappings that the user bit
is set by the setDiagnosticMapping call.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140578 91177308-0d34-0410-b5e6-96231b3b80d8
d6471f7c1921c7802804ce3ff6fe9768310f72b9 26-Sep-2011 David Blaikie <dblaikie@gmail.com> Rename Diagnostic to DiagnosticsEngine as per issue 5397

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140478 91177308-0d34-0410-b5e6-96231b3b80d8
eb2d1f1c88836bd5382e5d7aa8f6b85148a88b27 23-Sep-2011 David Blaikie <dblaikie@gmail.com> Removing a bunch of dead returns/breaks after llvm_unreachables.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140407 91177308-0d34-0410-b5e6-96231b3b80d8
b219cfc4d75f0a03630b7c4509ef791b7e97b2c8 23-Sep-2011 David Blaikie <dblaikie@gmail.com> Switch assert(0/false) llvm_unreachable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140367 91177308-0d34-0410-b5e6-96231b3b80d8
4cd06348a8c7b3559e9f437439dfc75ff7a04e88 22-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Do manual binary search for preprocessing entities because their end locations
may be unordered and MSVC's debug-mode doesn't like it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140337 91177308-0d34-0410-b5e6-96231b3b80d8
88df12521ed20adce83652ba207d39475b7ece71 21-Sep-2011 Benjamin Kramer <benny.kra@googlemail.com> Fix MSVC9 build by providing a full comparator object to lower_bound.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140238 91177308-0d34-0410-b5e6-96231b3b80d8
8f958f14eadb9ae2019bcca6ecd6ad7520cde5ea 21-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Don't store the source range for each preprocessed entity since
we already have the range in the PPEntityOffsets array.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140209 91177308-0d34-0410-b5e6-96231b3b80d8
290ad8c8eb1546692b20c4095ee441023f2f1005 21-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Merge ASTReader::LoadPreprocessedEntity with ReadPreprocessedEntity
and don't store the ID for each preprocessed entity.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140208 91177308-0d34-0410-b5e6-96231b3b80d8
de4e0a8e57e643bbe78ad37ad6023c45a8a9f7e2 21-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> The location of the name in MacroDefinition is the beginning of its range,
don't store an extra location for it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140190 91177308-0d34-0410-b5e6-96231b3b80d8
92ddef1bf843e1e18c040d69f48a6bf0bc7c776a 19-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> In libclang, when visiting preprocessed entities in a source range, use
PreprocessingRecord's getPreprocessedEntitiesInRange.

Also remove all the stuff that were added in ASTUnit that are unnecessary now
that we do a binary search for preprocessed entities and deserialize only
what is necessary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140063 91177308-0d34-0410-b5e6-96231b3b80d8
507097ec40105ed927cb5a744fad98f5875aacac 19-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] When getting a source location from a file:line:col triplet
check whether the requested location points inside the precompiled preamble,
in which case the returned source location will be a "loaded" one.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140060 91177308-0d34-0410-b5e6-96231b3b80d8
2dbaca748bc3eb6539f417bd8354c930bdf88fa4 19-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Introduce PreprocessingRecord::getPreprocessedEntitiesInRange()
which will do a binary search and return a pair of iterators
for preprocessed entities in the given source range.

Source ranges of preprocessed entities are stored twice currently in
the PCH/Module file but this will be fixed in a subsequent commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140058 91177308-0d34-0410-b5e6-96231b3b80d8
a64ccefdf0ea4e03ec88805d71b0af74950c7472 19-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.

It already works (and is useful with) macro locs as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140057 91177308-0d34-0410-b5e6-96231b3b80d8
1f6d22550161fffbe82ea9a8a143b2c1247f5f3c 19-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Const-ify some methods in ASTReader.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140054 91177308-0d34-0410-b5e6-96231b3b80d8
ac1ffcc55b861737ba2466cd1ca1accd8eafceaa 19-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Preload the PreloadSLocEntries through the SourceManager and
don't call ReadSLocEntryRecord() directly because the entry may have
already been loaded in which case calling ReadSLocEntryRecord()
directly would trigger an assertion in SourceManager.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140052 91177308-0d34-0410-b5e6-96231b3b80d8
1a995ddaa53a20dcd063ea47eb1f533ecb0d243a 15-Sep-2011 Douglas Gregor <dgregor@apple.com> When we load the first module, make sure that we wire up the ASTConsumer to the newly-created ASTReader. This makes sure that CodeGen sees the declarations it is interested in

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139824 91177308-0d34-0410-b5e6-96231b3b80d8
e24692b30adbe8144597678a0e3354912e99c747 15-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Overhaul how preprocessed entities are [de]serialized.

-Use an array of offsets for all preprocessed entities
-Get rid of the separate array of offsets for just macro definitions;
for references to macro definitions use an index inside the preprocessed
entities array.
-Deserialize each preprocessed entity lazily, at first request; not in bulk.

Paves the way for binary searching of preprocessed entities that will offer
efficiency and will simplify things on the libclang side a lot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139809 91177308-0d34-0410-b5e6-96231b3b80d8
144b38a7995cbe0928e34fbcc865bb2d2be4f7a3 13-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Fix a regression that r139441 introduced (decls were getting passed
to the consumer without being fully deserialized).

The regression was on compiling boost.python and it was too difficult to get a reduced
test case unfortunately.

Also modify the logic of how objc methods are getting passed to the consumer;
codegen depended on receiving objc methods before the implementation decl.
Since the interesting objc methods are ones with a body and such methods only
exist inside an ObjCImplDecl, deserialize and pass to consumer all the methods
of ObCImplDecl when we see one.

Fixes http://llvm.org/PR10922 & rdar://10117105.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139644 91177308-0d34-0410-b5e6-96231b3b80d8
7d5e81bf24dbfd334a7c62a7ae51043c79a69aa9 13-Sep-2011 Douglas Gregor <dgregor@apple.com> Switch the serialization of LangOptions over to use the .def file. We
should no longer have the serialization of LangOptions out of sync
with the structure itself (yay).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139613 91177308-0d34-0410-b5e6-96231b3b80d8
e289d81369914678db386f6aa86faf8f178e245d 13-Sep-2011 Douglas Gregor <dgregor@apple.com> Switch LangOptions over to a .def file that describes header of the
language options. Use that .def file to declare the LangOptions class
and initialize all of its members, eliminating a source of annoying
initialization bugs.

AST serialization changes are next up.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139605 91177308-0d34-0410-b5e6-96231b3b80d8
26d43cd3a088d4f1f1645328db3b73afbc7eaa61 12-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] In ASTUnit::Parse copy the CompilerInvocation object instead of
modifying directly for the preamble.

This avoids an awful, hard to find, bug where "PreprocessorOpts.DisablePCHValidation = true"
would be persistent for subsequent reparses of the translation unit which would result
in defines, present in command-line but not in the PCH, being ignored.

Fixes rdar://9615399.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139512 91177308-0d34-0410-b5e6-96231b3b80d8
02a5e875cca1ce2f471dad06fb5557346d99c164 10-Sep-2011 Douglas Gregor <dgregor@apple.com> Don't crash when we fail to load a module. It's unbecoming of a
well-bred compiler like Clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139442 91177308-0d34-0410-b5e6-96231b3b80d8
712f2fcb70ae2eb0cb684d565e7d2cb76881006b 10-Sep-2011 Douglas Gregor <dgregor@apple.com> In the ASTReader, replace the never-NULL Preprocessor pointer with a
Preprocessor reference. Simplify some code along the way, so there is
no separate "initialize the preprocessor" step.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139418 91177308-0d34-0410-b5e6-96231b3b80d8
359427794704666ff7a5a933ace11c5256fa3af7 09-Sep-2011 Douglas Gregor <dgregor@apple.com> In ASTReader, replace the never-NULL ASTContext pointer with an
ASTContext reference. Remove all of the extra checking and logic that
was used to cope with a NULL ASTContext. No effective functionality

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139413 91177308-0d34-0410-b5e6-96231b3b80d8
5db255e02fde04cbfec65e4596a217591933a76b 09-Sep-2011 Douglas Gregor <dgregor@apple.com> Mark the translation unit as having lexical/visible storage only when we actually have data for that lexical or visible storage

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139409 91177308-0d34-0410-b5e6-96231b3b80d8
5181ad023c32f4f13a842e41ed7f8e3c2e23a38e 09-Sep-2011 Douglas Gregor <dgregor@apple.com> Back out r139358 "[PCH] When loading the decls linked to an
identifier, also make them visible in the translation unit," which
isn't needed now that John's eliminated the AST dependency in blocks

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139408 91177308-0d34-0410-b5e6-96231b3b80d8
84ef0b5f6bd307b1d7cf08cafd68cfcf5facf6e3 09-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] When loading the decls linked to an identifier, also make them visible
in the translation unit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139358 91177308-0d34-0410-b5e6-96231b3b80d8
8f7c540ac42370c40ebcdc4b69018c938faf94ec 08-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [libclang] Fix annotation and getting a "macro expansion" cursor
for a builtin macro expansion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139298 91177308-0d34-0410-b5e6-96231b3b80d8
e97179c675b341927807c718be215c8d1aab8acb 08-Sep-2011 Douglas Gregor <dgregor@apple.com> Implement the Objective-C 'instancetype' type, which is an alias of
'id' that can be used (only!) via a contextual keyword as the result
type of an Objective-C message send. 'instancetype' then gives the
method a related result type, which we have already been inferring for
a variety of methods (new, alloc, init, self, retain). Addresses

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139275 91177308-0d34-0410-b5e6-96231b3b80d8
f8a1e51c48761ee1d7803c3fa35ac94f42ebb55e 02-Sep-2011 Douglas Gregor <dgregor@apple.com> Always construct an ASTReader with a non-NULL ASTContext and
Preprocessor, eliminating the constructor that was used by ASTUnit
(which didn't provide an ASTContext or Prepreprocessor). Ensuring that
both objects are non-NULL will simplify module loading (but none of
that is done yet).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138986 91177308-0d34-0410-b5e6-96231b3b80d8
7143aab97c6e849a5a5005b7853b8c7d5af008ed 01-Sep-2011 Douglas Gregor <dgregor@apple.com> Modules hide macro definitions by default, so that silly things like
include guards don't show up as macro definitions in every translation
unit that imports a module. Macro definitions can, however, be
exported with the intentionally-ugly #__export_macro__
directive. Implement this feature by not even bothering to serialize
non-exported macros to a module, because clients of that module need
not (should not) know that these macros even exist.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138943 91177308-0d34-0410-b5e6-96231b3b80d8
e6b8d68a927368b06ac06cc9ac9e7f60aa966d5f 01-Sep-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Support importing of ObjC categories from modules.

The initial incentive was to fix a crash when PCH chaining categories
to an interface, but the fix was done in the "modules way" that I hear
is popular with the kids these days.

Each module stores the local chain of categories and we combine them
when the interface is loaded. We also warn if non-dependent modules
introduce duplicate named categories.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138926 91177308-0d34-0410-b5e6-96231b3b80d8
3b84ab9f2adff42dcae3509c854a446b95917a10 30-Aug-2011 Jordy Rose <jediknil@belkadan.com> Remove obsolete ObjCInferRelatedReturnType from LangOptions...the correct option is ObjCInferRelatedResultType.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138793 91177308-0d34-0410-b5e6-96231b3b80d8
74cfb23d44de82f1932f0229b742805b0b3c3719 27-Aug-2011 Benjamin Kramer <benny.kra@googlemail.com> Remove unused variables noticed by GCC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138707 91177308-0d34-0410-b5e6-96231b3b80d8
2ea054fbc59ed19b8e3304e7e7cbdd56a5a5120f 27-Aug-2011 Douglas Gregor <dgregor@apple.com> Teach the ASTReader how to avoid cycles when loading declarations that
are lexically within a particular DeclContext. Test forthcoming.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138668 91177308-0d34-0410-b5e6-96231b3b80d8
46c03c3e7482660fcc0c9f461ca4e40da2cda01b 25-Aug-2011 Douglas Gregor <dgregor@apple.com> Clean up the reloading of identifier information following the load of
a top-level module. This code is still horrible and should go away,
but we're not there yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138586 91177308-0d34-0410-b5e6-96231b3b80d8
f249bf3b9f8bd3af711ffe9de411fc435871a4f6 25-Aug-2011 Douglas Gregor <dgregor@apple.com> Preload source location entries as soon as we've loaded a particular
AST file, rather than waiting until we finish loading the top-level
AST file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138585 91177308-0d34-0410-b5e6-96231b3b80d8
c69a292f9f7bee2a7359df18d1db501d8717f0b2 25-Aug-2011 Douglas Gregor <dgregor@apple.com> Move file validation in the ASTReader from "top of chain" validation
to "when loading a particular module" validation, since it was only
validating local information anyway. This shouldn't change anything.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138583 91177308-0d34-0410-b5e6-96231b3b80d8
98339b96a8089a6da715487e432c5abfca0ca0df 25-Aug-2011 Douglas Gregor <dgregor@apple.com> Factor the Module and ModuleManager classes out into separate headers
and .cpp files, since ASTReader.cpp was getting way too large. No
functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138582 91177308-0d34-0410-b5e6-96231b3b80d8
d10a381d92a60d4f4c126c4e81045c8ad4636a0b 25-Aug-2011 Douglas Gregor <dgregor@apple.com> Switch ASTReader::GetHeaderFileInfo() from a walk over the module
chain to a proper search.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138574 91177308-0d34-0410-b5e6-96231b3b80d8
b95cd09db90317121b107ac2a7ff88bff746e264 25-Aug-2011 Douglas Gregor <dgregor@apple.com> Switch the forward walk through the module chain over to a depth-first
search in ASTReader::ReadPreprocessedEntities().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138572 91177308-0d34-0410-b5e6-96231b3b80d8
3d15ab8d0822637ff5e39594c4f34172241cad2e 25-Aug-2011 Douglas Gregor <dgregor@apple.com> Use the module manager's search facility to look for methods with a
given selector, rather than walking the chain backwards. Teach its
visitor how to merge multiple result sets into a single result set,
combining the results of selector lookup in several different modules
into a single result set.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138556 91177308-0d34-0410-b5e6-96231b3b80d8
c266de97e269c3747ffc2d122fe53185b541cb37 24-Aug-2011 Douglas Gregor <dgregor@apple.com> Don't force the complete deserialization of the visible-declarations
table when serializing an AST file. This was a holdover from the days
before chained PCH, and is a complete waste of time and storage
now. It's a good thing it's useless, because I have no idea how I
would have implemented MaterializeVisibleDecls efficiently in the
presence of modules.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138496 91177308-0d34-0410-b5e6-96231b3b80d8
851c75a279bb4441bc6802d0258ceb4ab64738d4 24-Aug-2011 Douglas Gregor <dgregor@apple.com> Introduce a depth-first search of modules into the module manager,
which supports both pre-order and post-order traversal via a visitor
mechanism. Use this depth-first search with a post-order traversal to
give predictable ordering semantics when walking all of the lexical
declarations in the translation unit.

Eventually, module imports will occur in the source code rather than
at the beginning, and we'll have to revisit this walk.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138490 91177308-0d34-0410-b5e6-96231b3b80d8
0d95f77ba180aee35b74f3bf9f8543477f3af543 24-Aug-2011 Douglas Gregor <dgregor@apple.com> In the AST reader, switch name lookup within a DeclContect over to the
module DAG-based lookup scheme. This required some reshuffling, so
that each module stores its own mapping from DeclContexts to their
lexical and visible sets for those DeclContexts (rather than one big

Overall, this allows simple qualified name lookup into the translation
unit to gather results from multiple modules, with the lookup results
in module B shadowing the lookup results in module A when B imports A.

Walking all of the lexical declarations in a module DAG is still a
mess; we'll end up walking the loaded module list backwards, which
works fine for chained PCH but doesn't make sense in a DAG. I'll
tackle this issue as a separate commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138463 91177308-0d34-0410-b5e6-96231b3b80d8
d9d2b679d0728ea7f539f38aaea38e26b8b08043 22-Aug-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Boost the efficiency of SourceManager::getMacroArgExpandedLocation.

Currently getMacroArgExpandedLocation is very inefficient and for the case
of a location pointing at the main file it will end up checking almost all of
the SLocEntries. Make it faster:

-Use a map of macro argument chunks to their expanded source location. The map
is for a single source file, it's stored in the file's ContentCache and lazily
computed, like the source lines cache.
-In SLocEntry's FileInfo add an 'unsigned NumCreatedFIDs' field that keeps track
of the number of FileIDs (files and macros) that were created during preprocessing
of that particular file SLocEntry. This is useful when computing the macro argument
map in skipping included files while scanning for macro arg FileIDs that lexed from
a specific source file. Due to padding, the new field does not increase the size
of SLocEntry.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138225 91177308-0d34-0410-b5e6-96231b3b80d8
0c02adaa4da1d87495ca6a6d394f78740fa475c4 20-Aug-2011 Douglas Gregor <dgregor@apple.com> Make the loading of multiple records for the same identifier (from
different modules) more robust. It already handled (simple) merges of
the set of declarations attached to that identifier, so add a test
case that shows us getting two different declarations for the same
identifier (one struct, one function) from different modules, and are
able to use both of them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138189 91177308-0d34-0410-b5e6-96231b3b80d8
90115a378811842bf311d8fccff9201c940f178c 20-Aug-2011 Douglas Gregor <dgregor@apple.com> Clean out some minor cruft in the AST reader; no functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138188 91177308-0d34-0410-b5e6-96231b3b80d8
211f6e894895f552e0a98421b2f6e931ca4a8c11 20-Aug-2011 Douglas Gregor <dgregor@apple.com> Introduce a module visitation function that starts at the top-level
modules (those that no other module depends on) and performs a search
over all of the modules, visiting a new module only when all of the
modules that depend on it have already been visited. The visitor can
abort the search for all modules that a module depends on, which
allows us to minimize the number of lookups necessary when performing
a search.

Switch identifier lookup from a linear walk over the set of modules to
this module visitation operation. The behavior is the same for simple
PCH and chained PCH, but provides the proper search order for
modules. Verified with printf debugging, since we don't have enough in
place to actually test this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138187 91177308-0d34-0410-b5e6-96231b3b80d8
a3a0cf07fea63c020b0a261cb765ffdb5af991e6 19-Aug-2011 Douglas Gregor <dgregor@apple.com> Remove unused function ModuleManager::exportLookup()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138079 91177308-0d34-0410-b5e6-96231b3b80d8
fac4ece118d43e43e625c6d2b9a98905b1372d51 19-Aug-2011 Douglas Gregor <dgregor@apple.com> Teach ModuleManager::addModule() to check whether a particular module
has already been loaded before allocating a new Module structure. If
the module has already been loaded (uniquing based on file name), then
just return the existing module rather than trying to load it again.

This allows us to load a DAG of modules. Introduce a simple test case
that forms a diamond-shaped module graph, and illustrates that a
source file importing the bottom of the diamond can see declarations
in all four of the modules that make up the diamond.

Note that this version moves the file-opening logic into the module
manager, rather than splitting it between the module manager and the
AST reader. More importantly, it properly handles the
weird-but-possibly-useful case of loading an AST file from "-".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138030 91177308-0d34-0410-b5e6-96231b3b80d8
870d1fee3c5027efe7fd23d6935952bc1f419f99 18-Aug-2011 Chad Rosier <mcrosier@apple.com> Temporarily revert r137925 to appease buildbots. Original commit message:

Teach ModuleManager::addModule() to check whether a particular module
has already been loaded before allocating a new Module structure. If
the module has already been loaded (uniquing based on file name), then
just return the existing module rather than trying to load it again.

This allows us to load a DAG of modules. Introduce a simple test case
that forms a diamond-shaped module graph, and illustrates that a
source file importing the bottom of the diamond can see declarations
in all four of the modules that make up the diamond.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137971 91177308-0d34-0410-b5e6-96231b3b80d8
a4c189f4356f24d984aac781d7762b8c55082b7e 18-Aug-2011 Douglas Gregor <dgregor@apple.com> Teach ModuleManager::addModule() to check whether a particular module
has already been loaded before allocating a new Module structure. If
the module has already been loaded (uniquing based on file name), then
just return the existing module rather than trying to load it again.

This allows us to load a DAG of modules. Introduce a simple test case
that forms a diamond-shaped module graph, and illustrates that a
source file importing the bottom of the diamond can see declarations
in all four of the modules that make up the diamond.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137925 91177308-0d34-0410-b5e6-96231b3b80d8
10bc00fd45824f9b5cd139d63af8b0f6d28aadda 18-Aug-2011 Douglas Gregor <dgregor@apple.com> Keep track of which modules have been loaded directly (e.g., via
-import-module) vs. loaded because some other module depends on
them. As part of doing this, pass down the module that caused a module
to be loaded directly, rather than assuming that we're loading a
chain. Finally, write out all of the directly-loaded modules when
serializing an AST file (using the new IMPORTS record), so that an AST
file can depend on more than one other AST file, all of which will be
loaded when that AST file is loaded. This allows us to form and load a
tree of modules, but we can't yet load a DAG of modules.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137923 91177308-0d34-0410-b5e6-96231b3b80d8
e95b9198b8b70ce0219cfb89483b41102e02dbf5 17-Aug-2011 Douglas Gregor <dgregor@apple.com> In the AST file format, eliminate the CHAINED_METADATA record. Instead,
all AST files have a normal METADATA record that has the same form
regardless of whether we refer to a chained PCH or any other kind of
AST file.

Introduce the IMPORTS record, which describes all of the AST files
that are imported by this AST file, and how (as a module, a PCH file,
etc.). Currently, we emit at most one entry to this record, to support
chained PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137869 91177308-0d34-0410-b5e6-96231b3b80d8
772eeaefef2c883aabe35caf4543e7e32d290183 12-Aug-2011 Douglas Gregor <dgregor@apple.com> Switch the __int128_t and __uint128_t types over to predefined types
in the AST format, which are built lazily by the ASTContext when

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137437 91177308-0d34-0410-b5e6-96231b3b80d8
7a27ea52b7bd635c89bec5a9c521a3bf7d204238 12-Aug-2011 Douglas Gregor <dgregor@apple.com> Switch the Objective-C 'SEL' type over to a predefined type in the
AST file format, lazily generating the actual declaration in
ASTContext as needed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137434 91177308-0d34-0410-b5e6-96231b3b80d8
79d6726921897811232554ed94c5d77b5b7b3fc0 12-Aug-2011 Douglas Gregor <dgregor@apple.com> Switch the Objective-C 'Class' type over to a predefined type in the
AST file format, lazily generating the actual declaration in
ASTContext as needed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137431 91177308-0d34-0410-b5e6-96231b3b80d8
4dfd02a17c6d604c72e6936527c5e1c56d3ecb7a 12-Aug-2011 Douglas Gregor <dgregor@apple.com> Move the creation of the predefined typedef for Objective-C's 'id'
type over into the AST context, then make that declaration a
predefined declaration in the AST format. This ensures that different
AST files will at least agree on the (global) declaration ID for 'id',
and eliminates one of the "special" types in the AST file format.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137429 91177308-0d34-0410-b5e6-96231b3b80d8
6bf2b9fbd3e3adc38d4712de79aeaa81d651aa08 12-Aug-2011 Douglas Gregor <dgregor@apple.com> In the serialized AST format, make the translation unit a "predefined"
declaration that never actually gets serialized. Instead, serialize
the various kinds of update records (lexical decls, visible decls, the
addition of an anonymous namespace) for the translation unit, even if
we're not chaining. This way, we won't have to deal with multiple
loaded translation unit declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137395 91177308-0d34-0410-b5e6-96231b3b80d8
63ab2c54dc641d4f3d28841aa86affbfdf805d32 12-Aug-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix a PCH crash bug where we kept a reference inside a DenseMap while the map was getting modified.

No test case, sorry. It's one of those bugs where it's really really hard to make one. rdar://9910862.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137383 91177308-0d34-0410-b5e6-96231b3b80d8
5f95728e0d37709402ab83abe085f40686a4007b 12-Aug-2011 Douglas Gregor <dgregor@apple.com> When initializing a context from a particular AST file, check whether
either "special" type has already been initialized. Previously, we did
this check based on just the first special type (__builtin_va_list),
but now we have some NULL special type entries to content with.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137373 91177308-0d34-0410-b5e6-96231b3b80d8
30403a611d6648099e7ad43ab82e3ba8e62bf00e 12-Aug-2011 Douglas Gregor <dgregor@apple.com> The AST reader and writer don't need accessors for poking at the predefined Objective-C types

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137366 91177308-0d34-0410-b5e6-96231b3b80d8
0815b579b31cb3129f732bb7ea36fd6ba6949e98 09-Aug-2011 Douglas Gregor <dgregor@apple.com> Move the creation of the record type for the state of Objective-C fast
enumerations from the ASTContext into CodeGen, so that we don't need
to serialize it to AST files. This appears to be the last of the
low-hanging fruit for SpecialTypes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137124 91177308-0d34-0410-b5e6-96231b3b80d8
5c0d3d66bf06213009802876a14e6298efc1e0b0 09-Aug-2011 Douglas Gregor <dgregor@apple.com> Don't serialize the block descriptor or block extended descriptor
types to AST files; they're only used by debug info generation anyway,
and shouldn't ever exist in the AST anyway.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137122 91177308-0d34-0410-b5e6-96231b3b80d8
45c4ea75b235de94f44bf96843624e6a559e4c00 09-Aug-2011 Douglas Gregor <dgregor@apple.com> Move the construction of the RecordDecl representing the runtime
layout of a constant NSString from the ASTContext over to CodeGen,
since this is solely CodeGen's responsibility. Eliminates one of the
unnecessary "special" types that we serialize.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137121 91177308-0d34-0410-b5e6-96231b3b80d8
3b8043b49aff6e5d70f29ef5684214ce2473763c 09-Aug-2011 Douglas Gregor <dgregor@apple.com> Migrate the serialization of ASTContext's AutoDeduceTy and
AutoRRefDeductTy from the "special types" block to predefined
types. The latter behaves better when loading multiple AST files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137120 91177308-0d34-0410-b5e6-96231b3b80d8
de91db51c1488b14a7a23b24d8a81dce1ec63f4f 06-Aug-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Add workaround for built va list (and other builtins) so that running ReadAST multiple times does not immediately throw an error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136995 91177308-0d34-0410-b5e6-96231b3b80d8
ca109e5665db544321106592aa6b80d20c3fdbe1 04-Aug-2011 Douglas Gregor <dgregor@apple.com> Clean up the debug dump for a Module, so the local->global maps are
clearly called out, and add the missing local -> global selector map

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136903 91177308-0d34-0410-b5e6-96231b3b80d8
272b6bc6a6c8fc04f951ad850df68c44d137f513 04-Aug-2011 Douglas Gregor <dgregor@apple.com> Introduce local -> global mapping for preprocessed entity IDs. This is
the last of the ID/offset/index mappings that I know
of. Unfortunately, the "gap" method of testing doesn't work here due
to the way the preprocessing record performs iteration. We'll do more
testing once multi-AST loading is possible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136902 91177308-0d34-0410-b5e6-96231b3b80d8
3b2257ca054aa0b7d0150a294f184e9349cda433 04-Aug-2011 Douglas Gregor <dgregor@apple.com> Remove the unset, unused return value of
ASTReader::ReadMacroRecord(). No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136893 91177308-0d34-0410-b5e6-96231b3b80d8
7338a922dd1164002922163200b18a2c24eb0209 04-Aug-2011 Douglas Gregor <dgregor@apple.com> In the AST reader and writer, slide the preprocessed entity IDs by +1
so that we use ID zero as a sentinel for "no result". This matches the
convention set by all of the other global IDs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136885 91177308-0d34-0410-b5e6-96231b3b80d8
fb2d9e092f19cfcdd11ebd5ceac40456c090c7db 04-Aug-2011 Douglas Gregor <dgregor@apple.com> Implement the local -> global remapping for macro definition IDs in
the detailed preprocessing record. Tested with the standard "gaps" method.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136882 91177308-0d34-0410-b5e6-96231b3b80d8
d631d0e74d9ad5c13b51250881bf3cee750ecb67 04-Aug-2011 Douglas Gregor <dgregor@apple.com> The AST reader was forgetting to parse ObjCInferRelatedReturnType

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136879 91177308-0d34-0410-b5e6-96231b3b80d8
e92b8a1dbba150e213c4980710fcb59ec5c5c570 04-Aug-2011 Douglas Gregor <dgregor@apple.com> Don't introduce a local -> global mapping for CXXBaseSpecifiers. The
IDs will never cross module boundaries, since they're tied to the
CXXDefinitionData, so just use a local mapping throughout. Eliminate
the global -> local tables and supporting data.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136847 91177308-0d34-0410-b5e6-96231b3b80d8
b18b1fd33f958264630fbae2602c81275bae8c9a 04-Aug-2011 Douglas Gregor <dgregor@apple.com> Introduce local -> global selector ID mapping into the AST
reader. Tested with the usual "gaps" method.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136839 91177308-0d34-0410-b5e6-96231b3b80d8
6ec60e00eeaaed78d98c85ce962d6f328094ca14 03-Aug-2011 Douglas Gregor <dgregor@apple.com> Introduce a local-to-global remapping for identifiers in the AST
reader, and fix up the one (!) place where we were improperly mapping
a local ID to a global ID. Tested via the usual "gaps" trick.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136817 91177308-0d34-0410-b5e6-96231b3b80d8
43fd9388d374f29e908e611a686c6137553efa79 03-Aug-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Fix a few typos

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136792 91177308-0d34-0410-b5e6-96231b3b80d8
0a14e4bf604a91b035a479235adf4c2f6c9128a2 03-Aug-2011 Douglas Gregor <dgregor@apple.com> Introduce a constant for the number of predefined declarations in an
AST file, along with an enumeration naming those predefined
declarations. No functionality change, but this will make it easier to
introduce new predefined declarations, when/if we need them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136781 91177308-0d34-0410-b5e6-96231b3b80d8
496c709a6f08f5c502b6f592ddd9ed40f953a5e5 03-Aug-2011 Douglas Gregor <dgregor@apple.com> Introduce the local -> global declaration ID mapping into the AST
reader, to allow AST files to be loaded with their declarations
remapped to different ID numbers. Fix a number of places where we were
either failing to map local declaration IDs into global declaration
IDs or where interpreting the local declaration IDs within the wrong

I've tested this via the usual "random gaps" method. It works well
except for the preamble tests, because our handling of the precompiled
preamble requires declaration and preprocessed entity to be stable
when parsing code and then loading that back into memory. This
property will hold in general, but my randomized testing naturally
breaks this property to get more coverage. In the future, I expect
that the precompiled preamble logic won't need this property.

I am very unhappy with the current handling of the translation unit,
which is a rather egregious hack. We're going to have to do something
very different here for loading multiple AST files, because we don't
want to have to cope with merging two translation units. Likely, we'll
just handle translation units entirely via "update" records, and
predefine a single, fixed declaration ID for the translation
unit. That will come later.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136779 91177308-0d34-0410-b5e6-96231b3b80d8
e36050111e2bdb7efc014af9dd7f0009b492ac36 02-Aug-2011 Douglas Gregor <dgregor@apple.com> Change the hashing function for DeclContext lookup within an AST file
by eliminating the type ID from constructor, destructor, and
conversion function names. There are several reasons for this change:
- A given type (say, int*) isn't guaranteed to have a single, unique
type ID within a chain of PCH files. Hence, we could end up hashing
based on the wrong type ID, causing name lookup to fail.

- The mapping from types back to type IDs required one DenseMap
entry for every type that was ever deserialized, which was an
unacceptable cost to support just the name lookup of constructors,
destructors, and conversion functions. Plus, this mapping could
never actually work with chained or multiple PCH, based on the first

Once we have eliminated the type from the hash function, these
problems go away, as does my horrible "reverse type remap" hack, which
was doomed from the start (see bullet #1 above) and far too

However, note that removing the type from the hash function means that
all constructors, destructors, and conversion functions have the same
hash key, so I've updated the caller to double-check that the
declarations found have the appropriate name.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136708 91177308-0d34-0410-b5e6-96231b3b80d8
c24a1eef40207457692a1ad597cefdd0dc8fa149 02-Aug-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Following up the earlier refactoring/cleanup work by fixing up how we manage the virtual files the ASTReader has to handle. Specifically, this occurs when the reader is reading AST files that were created in memory and not written to disk. For example, when a user creates a chained PCH using command line flags. These virtual files are stored in MemoryBuffers in ChainIncludeSource.cpp, and then read back in by the ASTReader. This patch moves the management of these buffers into the ModuleManager, so that it becomes the authority on where these buffers are located.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136697 91177308-0d34-0410-b5e6-96231b3b80d8
a119da0761cb6b85f53857eaee50f6ad8c5ea0a0 02-Aug-2011 Douglas Gregor <dgregor@apple.com> Implement a proper local -> global type ID remapping scheme in the AST
reader. This scheme permits an AST file to be loaded with its type IDs
shifted anywhere in the type ID space.

At present, the type indices are still allocated in the same boring
way they always have been, just by adding up the number of types in
each PCH file within the chain. However, I've done testing with this
patch by randomly sliding the base indices at load time, to ensure
that remapping is occurring as expected. I may eventually formalize
this in some testing flag, but loading multiple (non-chained) AST
files at once will eventually exercise the same code.

There is one known problem with this patch, which involves name lookup
of operator names (e.g., "x.operator int*()") in cases where multiple
PCH files in the chain. The hash function itself depends on having a
stable type ID, which doesn't happen with chained PCH and *certainly*
doesn't happen when sliding type IDs around. We'll need another
approach. I'll tackle that next.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136693 91177308-0d34-0410-b5e6-96231b3b80d8
8df5c9b5d65beec807e4e77dae2813dd193f77dd 02-Aug-2011 Douglas Gregor <dgregor@apple.com> Add a debugging dump for Module (also emitted as part of the AST
reader statistics), to show the local-to-global mappings. The only
such mapping we have (at least, for now) is for source location

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136687 91177308-0d34-0410-b5e6-96231b3b80d8
f33740efdb2d836a96ba97ca3004d46404401439 02-Aug-2011 Douglas Gregor <dgregor@apple.com> Generalize the module offset map to include mapping information for
all of the kinds of IDs that can be offset. No effectively
functionality change; this is preparation for adding remapping for

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136686 91177308-0d34-0410-b5e6-96231b3b80d8
5d51a1d22d862dfae44eaa098af4e09bbfebae72 01-Aug-2011 Douglas Gregor <dgregor@apple.com> Rename the AST file's SOURCE_LOCATION_MAP to MODULE_OFFSET_MAP, to indicate the greater role it will soon play in remapping.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136619 91177308-0d34-0410-b5e6-96231b3b80d8
2e09163890b51aa8766564780154531451a3cf0b 29-Jul-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Renamed Loaded member to ImportedBy, as it's easier to read. Added another set to represent the modules a module imports.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136476 91177308-0d34-0410-b5e6-96231b3b80d8
eda61584120f59a35d4493b0af4bed717494e826 29-Jul-2011 Douglas Gregor <dgregor@apple.com> Remove unused debug function

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136442 91177308-0d34-0410-b5e6-96231b3b80d8
9827a8049a793f23c62ade8f24f0c66c2dbf6741 29-Jul-2011 Douglas Gregor <dgregor@apple.com> In the ASTReader, replace the continuous range maps whose value types
were (Module*, Offset) with equivalent maps whose value type is just a
Module*. The offsets have moved into corresponding "Base" fields
within the Module itself, where they will also be helpful for
local->global translation (eventually).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136441 91177308-0d34-0410-b5e6-96231b3b80d8
1e849b6f43a6aded51466978d826e938859130db 29-Jul-2011 Douglas Gregor <dgregor@apple.com> Move the base type ID from the ASTReader's global type map into the
Module itself, which makes more sense. This pattern to be repeated
several more times.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136436 91177308-0d34-0410-b5e6-96231b3b80d8
b4ae29ced808ae77914754a9e966513aa26b580b 29-Jul-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Some documentation fixes so that we are explicit about which iteration order is source-order. Also, removing unused NextInSource field of Module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136423 91177308-0d34-0410-b5e6-96231b3b80d8
86c67d8802a9e0887c31c850188991465ac3c1bd 29-Jul-2011 Douglas Gregor <dgregor@apple.com> Introduce the local-global mapping for preprocessed entities, and use
it appropriately. Also, patch up a place where we were failing to map
local macro definition IDs into global macro definition IDs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136411 91177308-0d34-0410-b5e6-96231b3b80d8
e144c70d07bf7af6c0337000ac4c4e805fc6d842 29-Jul-2011 Douglas Gregor <dgregor@apple.com> Use local-to-global mapping appropriately for macro definitions in the ASTReader

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136410 91177308-0d34-0410-b5e6-96231b3b80d8
2d2689ab787c6d54cb985c28ff3f16370bc01b0f 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Use the local -> global mapping functions for selectors more
consistently in the ASTReader.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136395 91177308-0d34-0410-b5e6-96231b3b80d8
95eab176f51beed44a9bc14c0dcdd37844b23740 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Teach the ASTReader to perform local and global mapping of identifier
IDs properly, although the mapping itself is still trivial.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136391 91177308-0d34-0410-b5e6-96231b3b80d8
6e4a3f5c59664af13e02e9bb58c2810b830e3b96 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Make the deserialization of Sema::PendingInstantiations lazy. At this
point, ASTReader::InitializeSema() has very little interesting work,
*except* issues stemming from preloaded declarations. That's something
we'll still need to cope with.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136378 91177308-0d34-0410-b5e6-96231b3b80d8
f2abb52acbba25ad93a1ecdc24d994b9694803a1 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Promote the deserialized PendingInstantiations vector from being a
Module member to being an ASTReader member; we want it to be
centralized for lazy deserialization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136373 91177308-0d34-0410-b5e6-96231b3b80d8
dfe6543e12eca5c79421378b7fa6b3e8fc403e63 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Lazily deserialize Sema::VTableUses. Plus, fix the utterly and
completely broken deserialization mapping code we had for VTableUses,
which would have broken horribly as soon as our local-to-global ID
mapping became interesting.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136371 91177308-0d34-0410-b5e6-96231b3b80d8
31e37b2d7b4815fdea6a35d49f33005562f0d494 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Make Sema::WeakUndeclaredIdentifiers lazily deserialized.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136368 91177308-0d34-0410-b5e6-96231b3b80d8
1afb661bc5444462a246cefa0effa61ef25fab29 28-Jul-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Switch the ModuleManager over to using a FileManager and FileEntry* as part of its lookup instead of the filename. This is a more correct unique identifier, as symlinks can be handled by the FileManager.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136363 91177308-0d34-0410-b5e6-96231b3b80d8
5b9dc7caaef0469babc45dd8e713727a136ce517 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Make Sema::ReferencedSelectors lazily deserialized.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136357 91177308-0d34-0410-b5e6-96231b3b80d8
8451ec7e709baf777bec07dc70653e0c523dd120 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Move a Module's ReferencedSelectorsData into the ASTReader itself, so
that it accumulates referenced selectors from each of the modules/PCH
files as they are loaded. No actual functionality change, yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136356 91177308-0d34-0410-b5e6-96231b3b80d8
ec12ce2f6da44bfc9048772327a3924498099d60 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Make Sema::LocallyScopedExternalDecls lazily deserialized. In theory,
we could turn this into an on-disk hash table so we don't load the
whole thing the first time we need it. However, it tends to be very,
very small (i.e., empty) for most precompiled headers, so it isn't all
that interesting.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136352 91177308-0d34-0410-b5e6-96231b3b80d8
b4dc485a2b38ea98ba7da01596fd0e8438120346 28-Jul-2011 Douglas Gregor <dgregor@apple.com> AST serialization support for the Framework in IndexHeaderMapHeader
fields of HeaderFileInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136332 91177308-0d34-0410-b5e6-96231b3b80d8
1e5b6f60e2e09addd2f2e915c87d8bd74d40c369 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Don't set Sema's StdNamespace or StdBadAlloc if they've already been set

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136318 91177308-0d34-0410-b5e6-96231b3b80d8
a126f17ca83b985300c1f65cee647bea108db657 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Switch Sema::DynamicClasses over to LazyVector

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136317 91177308-0d34-0410-b5e6-96231b3b80d8
d58a0a55e64a7c410a80e9d6dcd899e61e99cc4d 28-Jul-2011 Douglas Gregor <dgregor@apple.com> Switch Sema::ExtVectorDecls over to LazyVector.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136314 91177308-0d34-0410-b5e6-96231b3b80d8
0129b561a1452bf057f6b18b6a1de815d487ab81 27-Jul-2011 Douglas Gregor <dgregor@apple.com> Turn Sema::DelegatingCtorDecls into a LazyVector.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136273 91177308-0d34-0410-b5e6-96231b3b80d8
a2ee20aa9660851080135219cac5b31fbac08b78 27-Jul-2011 Douglas Gregor <dgregor@apple.com> Switch Sema::UnusedFileScopedDecls over to a LazyVector.
- Added LazyVector::erase() to support this use case.
- Factored out the LazyDecl-of-Decls to RecordData translation in
the ASTWriter. There is still a pile of code duplication here to

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136270 91177308-0d34-0410-b5e6-96231b3b80d8
a862320972e63349524dc9aa744dec1b95f54ba1 27-Jul-2011 Douglas Gregor <dgregor@apple.com> Introduce a new data structure, LazyVector, which is a vector whose
contents are lazily loaded on demand from an external source (e.g., an
ExternalASTSource or ExternalSemaSource). The "loaded" entities are
kept separate from the "local" entities, so that the two can grow

Switch Sema::TentativeDefinitions from a normal vector that is eagerly
populated by the ASTReader into one of these LazyVectors, making the
ASTReader a bit more like me (i.e., lazy).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136262 91177308-0d34-0410-b5e6-96231b3b80d8
a7d445a718906820bf275fbfaedce269a407a6c5 27-Jul-2011 Douglas Gregor <dgregor@apple.com> Modules don't require validation of the predefines buffer

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136224 91177308-0d34-0410-b5e6-96231b3b80d8
48d2c3f7c3ca48da05436afdc8426a245294ee65 26-Jul-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> This patch extends the previous patch by starting to incorporate more functionality, like lookup-by-name and exporting lookup tables, into the module manager. Methods now have documentation. A few more functions have been switched over to the new iterator style and away from manual/explicit iteration. Ultimately we want to move away from name lookup here, as symlinks make filenames not a safe unique value, but we use it here as a stopgap before better measures are in place (namely instead using FileEntry* from a global FileManager).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136107 91177308-0d34-0410-b5e6-96231b3b80d8
bf340e452339e374ea6eef78c1f0a2abdd16c5a3 26-Jul-2011 Chandler Carruth <chandlerc@gmail.com> Rename create(MacroArg)InstantiationLoc to create(MacroArg)ExpansionLoc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136054 91177308-0d34-0410-b5e6-96231b3b80d8
5d6d89fef8c7fff8b1a67c943fb5557a2a803468 25-Jul-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Refactor of how modules are handled in ASTReader to remove explicit uses of a chain of AST files, instead redirect calls through a module manager. This should help move toward a DAG and the potential of loading multiple, unrelated PCH files. It's still early in development.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135957 91177308-0d34-0410-b5e6-96231b3b80d8
5f9e272e632e951b1efe824cd16acb4d96077930 23-Jul-2011 Chris Lattner <sabre@nondot.org> remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
9461fccd05bde8458710ba367be10b6e4efe2ec7 22-Jul-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Remove prepending of '$' to module names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135775 91177308-0d34-0410-b5e6-96231b3b80d8
832d620b4ae0fc5fe28561b885b4cfc65cf5c9ab 22-Jul-2011 Douglas Gregor <dgregor@apple.com> Switch all of the "isysroot" const char*'s throughout the AST reader
and writer to StringRef or std::string, as appropriate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135769 91177308-0d34-0410-b5e6-96231b3b80d8
72a9ae18553bf8b6bdad84d2c54f73741a47e275 22-Jul-2011 Douglas Gregor <dgregor@apple.com> Rename ASTReader::PerFileData to serialization::Module, pulling it out
of ASTReader so it can become its own full-fledged class
(eventually). No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135767 91177308-0d34-0410-b5e6-96231b3b80d8
8f1231b70c2b1f6fe0cee097b447487b26810301 22-Jul-2011 Douglas Gregor <dgregor@apple.com> Introduce a global bit-offset continuous range map into the ASTReader,
so that we have one, simple way to map from global bit offsets to
local bit offsets. Eliminates a number of loops over the chain, and
generalizes for more interesting bit remappings.

Also, as an amusing oddity, we were computing global bit offsets
*backwards* for preprocessed entities (e.g., the directly included PCH
file in the chain would start at offset zero, rather than the original
PCH that occurs first in translation unit). Even more amusingly, it
made precompiled preambles work, because we were forgetting to adjust
the local bit offset to a global bit offset when storing preprocessed
entity offsets in the ASTUnit. Two wrongs made a right, and now
they're both right.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135750 91177308-0d34-0410-b5e6-96231b3b80d8
393f249399fe30e9580e1529a7479489e90f3a57 22-Jul-2011 Douglas Gregor <dgregor@apple.com> In the AST reader, factor out the mapping of local type IDs to global
type IDs into a single place, and make sure that all of the callers
use the appropriate functions to do the mapping. Since the mapping is
still the identity function, this is essentially a no-op.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135733 91177308-0d34-0410-b5e6-96231b3b80d8
f5bb9ae23d68ffb1e1c37b05fc8d943bc6bff12e 22-Jul-2011 Douglas Gregor <dgregor@apple.com> Clean up the rest of the local -> global declaration ID mappings
within the ASTReader (I hope).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135720 91177308-0d34-0410-b5e6-96231b3b80d8
409448c832d27703146b70a1137d86b020f29863 22-Jul-2011 Douglas Gregor <dgregor@apple.com> In the ASTReader, factor out the loading of (local) declaration IDs,
such that every declaration ID loaded from an AST file will go through
a central local -> global mapping function. At present, this change
does nothing, since the local -> global mapping function is the
identity function.

This is the mechanical part of the refactoring; a follow-up patch will
address a few remaining areas where it's not obvious whether we're
dealing with local or global IDs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135711 91177308-0d34-0410-b5e6-96231b3b80d8
1da901467f72d1733704b068e22089813a1962fd 21-Jul-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Cleaning up more of the ID situation in the AST reader. This patch relaxes and generalizes how CXX base specifiers are identified and loaded by using a ContinuousRangeMap. This also adds a global bit offset (or base) to the PerFileData.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135705 91177308-0d34-0410-b5e6-96231b3b80d8
23d7df5ce30f4a068e13ad6cb81d473365d260db 21-Jul-2011 Douglas Gregor <dgregor@apple.com> Add some debugging output to the AST reader, so we can see the global remappings we generate

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135701 91177308-0d34-0410-b5e6-96231b3b80d8
0cdd798dbaadd959d3e97ea16993efbdccbbe642 21-Jul-2011 Douglas Gregor <dgregor@apple.com> In the AST reader, keep track of the total number of source locations
entries incrementally, rather than iterating over the chain when
loading a single AST file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135692 91177308-0d34-0410-b5e6-96231b3b80d8
4c30bb148b53c8063e940ca3e049ba4d270dc9d5 21-Jul-2011 Douglas Gregor <dgregor@apple.com> Rework the detailed preprocessing record to separate preprocessing
entities generated directly by the preprocessor from those loaded from
the external source (e.g., the ASTReader). By separating these two
sets of entities into different vectors, we allow both to grow
independently, and eliminate the need for preallocating all of the
loaded preprocessing entities. This is similar to the way the recent
SourceManager refactoring treats FileIDs and the source location
address space.

As part of this, switch over to building a continuous range map to
track preprocessing entities.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135646 91177308-0d34-0410-b5e6-96231b3b80d8
e9b76c11a88d0af98f32d11a6668d03d45be3123 20-Jul-2011 Jonathan D. Turner <jonathan.d.turner@gmail.com> Continuing to improve and generalize how IDs are handled in ASTReader. This patch cleans up and generalizes TypeID loading and uses a similar table-lookup to Doug's previous Decl patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135622 91177308-0d34-0410-b5e6-96231b3b80d8
14ad03b6f4350f062256757efc4149a7df94bdf9 20-Jul-2011 Douglas Gregor <dgregor@apple.com> Use a ContinuousRangeMap to map from the global macro definition ID in
the AST reader down to the AST file + local ID, rather than walking
the PCH chain. More cleanup/generalization, although there is more
work to do for preprocessed entities. In particular, the
"preallocation" scheme for preprocessed entities is not going to work
well with late loading of PCH files, and it's likely we'll have to do
something akin to the SourceManager's negative/positive loading.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135556 91177308-0d34-0410-b5e6-96231b3b80d8
96958cbe6fb423ab2446629ead5f1b138398433c 20-Jul-2011 Douglas Gregor <dgregor@apple.com> Use a ContinuousRangeMap to map from the global selector ID in the AST
reader down to the AST file + local ID, rather than walking the PCH
chain. No functionality change; this is generalization and cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135554 91177308-0d34-0410-b5e6-96231b3b80d8
67268d02388d3d25107fa9cf4998c35246255a65 20-Jul-2011 Douglas Gregor <dgregor@apple.com> Use a ContinuousRangeMap to map from the global identifier ID in the
AST reader down to the AST file + local ID, rather than walking the
PCH chain. No functionality change; this is generalization and cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135551 91177308-0d34-0410-b5e6-96231b3b80d8
96e973f2be14c9b82136f74b4108465d24894fea 20-Jul-2011 Douglas Gregor <dgregor@apple.com> Use a ContinuousRangeMap to map from the global declaration ID in the
AST reader down to the AST file + local ID within that file, rather
than lamely walking the PCH chain. There's no actual functionality
change now, but this is cleaner and more general.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135548 91177308-0d34-0410-b5e6-96231b3b80d8
f62d43d2afe1960755a1b5813cae1e5983bcac1b 19-Jul-2011 Douglas Gregor <dgregor@apple.com> Revamp the SourceManager to separate the representation of parsed
source locations from source locations loaded from an AST/PCH file.

Previously, loading an AST/PCH file involved carefully pre-allocating
space at the beginning of the source manager for the source locations
and FileIDs that correspond to the prefix, and then appending the
source locations/FileIDs used for parsing the remaining translation
unit. This design forced us into loading PCH files early, as a prefix,
whic has become a rather significant limitation.

This patch splits the SourceManager space into two parts: for source
location "addresses", the lower values (growing upward) are used to
describe parsed code, while upper values (growing downward) are used
for source locations loaded from AST/PCH files. Similarly, positive
FileIDs are used to describe parsed code while negative FileIDs are
used to file/macro locations loaded from AST/PCH files. As a result,
we can load PCH/AST files even during parsing, making various
improvemnts in the future possible, e.g., teaching #include <foo.h> to
look for and load <foo.h.gch> if it happens to be already available.

This patch was originally written by Sebastian Redl, then brought
forward to the modern age by Jonathan Turner, and finally
polished/finished by me to be committed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135484 91177308-0d34-0410-b5e6-96231b3b80d8
ba6ffaf21e465c0926d7fc5fa294ea52f8d45faf 15-Jul-2011 Douglas Gregor <dgregor@apple.com> Augment the interface of ExternalASTSource::FindExternalLexicalDecls()
to allow clients to specify that they've already (correctly) loaded
declarations, and that no further action is needed.

Also, make sure that we clear the "has external lexical declarations"
bit before calling FindExternalLexicalDecls(), to avoid infinite

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135306 91177308-0d34-0410-b5e6-96231b3b80d8
f70d12dbd49fcc25f1dfc0127217112ae76bcb8f 15-Jul-2011 Chandler Carruth <chandlerc@gmail.com> Move the Serialization library from 'instantiation' to 'expansion', with
the exception of its uses of SourceManager and SourceLocation APIs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135260 91177308-0d34-0410-b5e6-96231b3b80d8
9e5bb85ac899eeab7c21b5ff9030c3da6ff4837b 14-Jul-2011 Chandler Carruth <chandlerc@gmail.com> Move the rest of the preprocessor terminology from 'instantiate' and
variants to 'expand'. This changed a couple of public APIs, including
one public type "MacroInstantiation" which is now "MacroExpansion". The
rest of the codebase was updated to reflect this, especially the
libclang code. Two of the C++ (and thus easily changed) libclang APIs
were updated as well because they pertained directly to the old
MacroInstantiation class.

No functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135139 91177308-0d34-0410-b5e6-96231b3b80d8
146060435c3efce95c95a092c7a1eb651cfb9ae0 30-Jun-2011 John McCall <rjmccall@apple.com> Preserve that a TemplateName was arrived at by substituting
for a template template parameter.

Uses to follow.

I've also made the uniquing of SubstTemplateTemplateParmPacks
use a ContextualFoldingSet as a minor space efficiency.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134137 91177308-0d34-0410-b5e6-96231b3b80d8
d8bba9c15230d2b1b3893e272106aa79efc50251 28-Jun-2011 Douglas Gregor <dgregor@apple.com> Add support for C++ namespace-aware typo correction, e.g., correcting




Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes

Thanks Kaelyn!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134007 91177308-0d34-0410-b5e6-96231b3b80d8
65aa6885818d4b4eea2e5a9d12085b2398148662 21-Jun-2011 Jay Foad <jay.foad@gmail.com> Make more use of llvm::StringRef in various APIs. In particular, don't
use the deprecated forms of llvm::StringMap::GetOrCreateValue().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133515 91177308-0d34-0410-b5e6-96231b3b80d8
f85e193739c953358c865005855253af4f68a497 16-Jun-2011 John McCall <rjmccall@apple.com> Automatic Reference Counting.

Language-design credit goes to a lot of people, but I particularly want
to single out Blaine Garst and Patrick Beard for their contributions.

Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself,
in no particular order.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133103 91177308-0d34-0410-b5e6-96231b3b80d8
74da19fc3a52d7e3005eeb7a7833859da84fd12a 15-Jun-2011 Douglas Gregor <dgregor@apple.com> Introduce a -cc1-level option to turn off related result type
inference, to be used (only) by the Objective-C rewriter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133025 91177308-0d34-0410-b5e6-96231b3b80d8
4c4efee6d3113f20b41efaeec08934332d2ea40e 13-Jun-2011 Douglas Gregor <dgregor@apple.com> Eliminate the -f[no]objc-infer-related-result-type flags; there's no
reason to allow the user to control these semantics through a flag.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132919 91177308-0d34-0410-b5e6-96231b3b80d8
926df6cfabf3eaa4afc990c097fa4619b76a9b57 11-Jun-2011 Douglas Gregor <dgregor@apple.com> Implement Objective-C Related Result Type semantics.

Related result types apply Cocoa conventions to the type of message
sends and property accesses to Objective-C methods that are known to
always return objects whose type is the same as the type of the
receiving class (or a subclass thereof), such as +alloc and
-init. This tightens up static type safety for Objective-C, so that we
now diagnose mistakes like this:

t.m:4:10: warning: incompatible pointer types initializing 'NSSet *'
with an
expression of type 'NSArray *' [-Wincompatible-pointer-types]
NSSet *array = [[NSArray alloc] init];
^ ~~~~~~~~~~~~~~~~~~~~~~
instance method 'init' is assumed to return an instance of its
type ('NSArray *')
- (id)init;

It also means that we get decent type inference when writing code in

auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil];
// ^ now infers NSMutableArray* rather than id

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132868 91177308-0d34-0410-b5e6-96231b3b80d8
4cdb0e2a2e9d93805e5ceaf8bc7018bdd166aec1 02-Jun-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Store the offsets of source location file entries and go through them
in ASTReader::validateFileEntries().

This avoids going through all source location entries and fixes the performance regression.
Many thanks to Doug for the hint!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132481 91177308-0d34-0410-b5e6-96231b3b80d8
b68ffb107a86f5e3851e8108c712b64dd16ba258 01-Jun-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Be conservative and check all the files the PCH references to see if
a file was modified since the time the PCH was created.

The parser is not fit to deal with stale PCHs, too many invariants do not hold up. rdar://9530587.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132389 91177308-0d34-0410-b5e6-96231b3b80d8
ca63c200346c0ca9e00194ec6e34a5a7b0ed9321 25-May-2011 Sean Hunt <scshunt@csclub.uwaterloo.ca> Implement a new type node, UnaryTransformType, designed to represent a
type that turns one type into another. This is used as the basis to
implement __underlying_type properly - with TypeSourceInfo and proper
behavior in the face of templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132017 91177308-0d34-0410-b5e6-96231b3b80d8
31d375f056447d4e2418275d4913661d3bfedb3e 06-May-2011 Douglas Gregor <dgregor@apple.com> Keep track of the file ID corresponding to the original file used to
build a precompiled header. Use this information to eliminate the call
to SourceManager::getLocation() while loading a precompiled preamble,
since SourceManager::getLocation() itself causes unwanted

Fixed <rdar://problem/9399352>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131021 91177308-0d34-0410-b5e6-96231b3b80d8
dca8ee8b7bc86076916a3a80f553f7a4e98c14af 06-May-2011 Douglas Gregor <dgregor@apple.com> Introduce a new libclang parsing flag,
CXTranslationUnit_NestedMacroInstantiations, which indicates whether
we want to see "nested" macro instantiations (e.g., those that occur
inside other macro instantiations) within the detailed preprocessing
record. Many clients (e.g., those that only care about visible tokens)
don't care about this information, and in code that uses preprocessor
metaprogramming, this information can have a very high cost.

Addresses <rdar://problem/9389320>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130990 91177308-0d34-0410-b5e6-96231b3b80d8
3e4c6c4c79a03f5cb0c4671d7c282d623c6dc35e 05-May-2011 Richard Smith <richard-llvm@metafoo.co.uk> Implement support for C++0x alias templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130953 91177308-0d34-0410-b5e6-96231b3b80d8
ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5 05-May-2011 Sean Hunt <scshunt@csclub.uwaterloo.ca> there i fixed it

Increase robustness of the delegating constructor cycle detection
mechanism. No more infinite loops on invalid or logic errors leading to
false results. Ensure that this is maintained correctly accross

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130887 91177308-0d34-0410-b5e6-96231b3b80d8
156b640c67300f2b70eb11102aa393a610798cc6 04-May-2011 Sean Hunt <scshunt@csclub.uwaterloo.ca> Implement serialization of delegating constructors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130822 91177308-0d34-0410-b5e6-96231b3b80d8
dd3e5549e3c11e217078938aacf72f042eea5343 04-May-2011 Douglas Gregor <dgregor@apple.com> Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),
which determines whether a particular file is actually a header that
is intended to be guarded from multiple inclusions within the same
translation unit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130808 91177308-0d34-0410-b5e6-96231b3b80d8
4fb86f8c4585e53c21c847ad3de9e3b2de123cd9 01-May-2011 Chandler Carruth <chandlerc@gmail.com> Re-applies the patch first applied way back in r106099, with
accompanying fixes to make it work today.

The core of this patch is to provide a link from a TemplateTypeParmType
back to the TemplateTypeParmDecl node which declared it. This in turn
provides much more precise information about the type, where it came
from, and how it functions for AST consumers.

To make the patch work almost a year after its first attempt, it needed
serialization support, and it now retains the old getName() interface.
Finally, it requires us to not attempt to instantiate the type in an
unsupported friend decl -- specifically those coming from template
friend decls but which refer to a specific type through a dependent

A cleaner representation of the last item would be to build
FriendTemplateDecl nodes for these, storing their template parameters
etc, and to perform proper instantation of them like any other template
declaration. They can still be flagged as unsupported for the purpose of
access checking, etc.

This passed an asserts-enabled bootstrap for me, and the reduced test
case mentioned in the original review thread no longer causes issues,
likely fixed at somewhere amidst the 24k revisions that have elapsed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130628 91177308-0d34-0410-b5e6-96231b3b80d8
e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3 29-Apr-2011 Ted Kremenek <kremenek@apple.com> Enhance clang_getCXTUResourceUsage() to report the sizes of the memory buffers used by PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130460 91177308-0d34-0410-b5e6-96231b3b80d8
864c041e118155c2b1ce0ba36942a3da5a4a055e 26-Apr-2011 John McCall <rjmccall@apple.com> Make yet another placeholder type, this one marking that an expression is a bound
member function, i.e. something of the form 'x.f' where 'f' is a non-static
member function. Diagnose this in the general case. Some of the new diagnostics
are probably worse than the old ones, but we now get this right much more
universally, and there's certainly room for improvement in the diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130239 91177308-0d34-0410-b5e6-96231b3b80d8
8d8f2c20f3e21c7516e5d27293f08283913904d1 26-Apr-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix a crash when ASTReader emits diagnostic when another one is in flight. Fixes rdar//9334563.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130162 91177308-0d34-0410-b5e6-96231b3b80d8
c1d3ffbbad742c90f22198d7909b0a98865bfefa 24-Apr-2011 Sebastian Redl <sebastian.redl@getdesigned.at> Store the full list of pending instantiations in a chained PCH. Previously we attempted to store only new pending instantiations, but our filter was incorrect, dropping implicit instantiations of class template members. It's just not worth coming up with a complex filter that is correct, when the only cost is PCH files that are a few hundred bytes (at most) larger.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130098 91177308-0d34-0410-b5e6-96231b3b80d8
0d2d1bcef51993ca3fd957e45fb7ec85e45016e5 23-Apr-2011 Chandler Carruth <chandlerc@gmail.com> Teach the AST reader and writer to preserve the __DEPRECATED bit in
language options, and warn when reading an AST with a different value
for the bit.

There doesn't appear to be a good way to test this (commenting out
similar other language options doesn't break anything) but if folks have
suggestions on tests I'm happy to add them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130071 91177308-0d34-0410-b5e6-96231b3b80d8
e23ac65af568ffe611b0990818ac3a57c856a4d8 20-Apr-2011 Douglas Gregor <dgregor@apple.com> Teach SourceManager::getSLocEntry() that it can fail due to problems
during deserialization from a precompiled header, and update all of
its callers to note when this problem occurs and recover (more)
gracefully. Fixes <rdar://problem/9119249>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129839 91177308-0d34-0410-b5e6-96231b3b80d8
162e1c1b487352434552147967c3dd296ebee2f7 15-Apr-2011 Richard Smith <richard-llvm@metafoo.co.uk> Support for C++11 (non-template) alias declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129567 91177308-0d34-0410-b5e6-96231b3b80d8
7e7fbd05a5dfdb0addfc8b5af2fcbed8c7b5fb87 15-Apr-2011 Peter Collingbourne <peter@pcc.me.uk> C1X: add a language standard

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129553 91177308-0d34-0410-b5e6-96231b3b80d8
ad762fcdc16b9e4705b12b09d92b8c026212b906 15-Apr-2011 Richard Smith <richard-llvm@metafoo.co.uk> Add support for C++0x's range-based for loops, as specified by the C++11 draft standard (N3291).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129541 91177308-0d34-0410-b5e6-96231b3b80d8
5655837683843a526da9d5af1eb0edbed8c0bc94 14-Apr-2011 Sebastian Redl <sebastian.redl@getdesigned.at> The ASTReader created by -chain-include used the generated PCH buffers in the wrong order. The effect was that all but the first chain-include files was ignored for subsequent compilations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129513 91177308-0d34-0410-b5e6-96231b3b80d8
df1550fc59b51681d37225934fe4e3acac321621 12-Apr-2011 Richard Smith <richard-llvm@metafoo.co.uk> Fix AST serialization of reference-to-reference types. This previously caused
a crash when deserializing the AST for this:

typedef char (&R);
extern R &r;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129358 91177308-0d34-0410-b5e6-96231b3b80d8
a49218e17bcbb1acde0245773173e2c0c42f4f19 09-Apr-2011 Eli Friedman <eli.friedman@gmail.com> PR8369: make __attribute((regparm(0))) work correctly. Original patch by
pageexec@freemail.hu, tweaks by me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129206 91177308-0d34-0410-b5e6-96231b3b80d8
1de4d4e8cb2e9c88809fea8092bc6e835a5473d2 07-Apr-2011 John McCall <rjmccall@apple.com> Basic, untested implementation for an "unknown any" type requested by LLDB.
The idea is that you can create a VarDecl with an unknown type, or a
FunctionDecl with an unknown return type, and it will still be valid to
access that object as long as you explicitly cast it at every use. I'm
still going back and forth about how I want to test this effectively, but
I wanted to go ahead and provide a skeletal implementation for the LLDB
folks' benefit and because it also improves some diagnostic goodness for
placeholder expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129065 91177308-0d34-0410-b5e6-96231b3b80d8
0a0d2b179085a52c10402feebeb6db8b4d96a140 23-Mar-2011 Douglas Gregor <dgregor@apple.com> Implement a new 'availability' attribute, that allows one to specify
which versions of an OS provide a certain facility. For example,

void foo()

says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:

- If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
will result in a deprecation warning, as if we had placed
attribute((deprecated)) on it (but with a better diagnostic)
- If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
will result in an "unavailable" warning (in C)/error (in C++), as
if we had placed attribute((unavailable)) on it
- If we choose a deployment target prior to 10.2, foo() is
weak-imported (if it is a kind of entity that can be weak
imported), as if we had placed the weak_import attribute on it.

Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.

The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.

Addresses <rdar://problem/6690412>.

As a drive-by bug-fix, if an entity is both deprecated and
unavailable, we only emit the "unavailable" diagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128127 91177308-0d34-0410-b5e6-96231b3b80d8
60618fa7f88d5162bb5b40988b6b38d4d75d6fc6 12-Mar-2011 Sebastian Redl <sebastian.redl@getdesigned.at> Propagate the new exception information to FunctionProtoType.
Change the interface to expose the new information and deal with the enormous fallout.
Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications.
Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127537 91177308-0d34-0410-b5e6-96231b3b80d8
796aa443ab5ed036f42ef33fed629e1b4b34871b 12-Mar-2011 Abramo Bagnara <abramo.bagnara@gmail.com> Forgotten part of previous commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127536 91177308-0d34-0410-b5e6-96231b3b80d8
b0f4b9a558933b307073f7cd7753602f94354ae9 09-Mar-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> 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
f25330bd88f921b6e4cae965932681f213d9d544 09-Mar-2011 Anders Carlsson <andersca@mac.com> When deserializing CXXBaseSpecifiers (and offsets), make sure to walk the chain in the correct order.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127315 91177308-0d34-0410-b5e6-96231b3b80d8
8b5b4099c61a136e9a1714c4d8a593febe942268 06-Mar-2011 Sebastian Redl <sebastian.redl@getdesigned.at> Reinstate r127112, "Propagate new-style exception spec information to ExtProtoInfo.", this time with the missing header.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127118 91177308-0d34-0410-b5e6-96231b3b80d8
708a86690469474f0a8149abca71aa4c62bf9710 06-Mar-2011 NAKAMURA Takumi <geek4civic@gmail.com> Revert r127112, "Propagate new-style exception spec information to ExtProtoInfo."

It seems missing "clang/Basic/ExceptionSpecificationType.h".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127115 91177308-0d34-0410-b5e6-96231b3b80d8
06bfa84588658d721094f383d6950e75100c4c4c 05-Mar-2011 Sebastian Redl <sebastian.redl@getdesigned.at> Propagate new-style exception spec information to ExtProtoInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127112 91177308-0d34-0410-b5e6-96231b3b80d8
b6ab6c1ca733fda2302a1c5066bdfc6218c89e41 05-Mar-2011 Abramo Bagnara <abramo.bagnara@gmail.com> Improved MemberPointerType source locations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127085 91177308-0d34-0410-b5e6-96231b3b80d8
b6744efecba58792cce20d2d7b9ee39927c5422e 02-Mar-2011 Douglas Gregor <dgregor@apple.com> Push nested-name-specifier source location information into template
template arguments. I believe that this is the last place in the AST
where we were storing a source range for a nested-name-specifier
rather than a proper nested-name-specifier location structure. (Yay!)

There is still a lot of cleanup to do in the TreeTransform, which
doesn't take advantage of nested-name-specifiers with source-location
information everywhere it could.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126844 91177308-0d34-0410-b5e6-96231b3b80d8
94fdffa4a572fc14ac296f5f1aae9db3734c72f1 01-Mar-2011 Douglas Gregor <dgregor@apple.com> Push nested-name-specifier source-location information into dependent
template specialization types. There are still a few rough edges to
clean up with some of the parser actions dropping
nested-name-specifiers too early.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126776 91177308-0d34-0410-b5e6-96231b3b80d8
9e876876afc13aa671cc11a17c19907c599b9ab9 01-Mar-2011 Douglas Gregor <dgregor@apple.com> Reinstate the introduction of source-location information for
nested-name-speciciers within elaborated type names, e.g.,

enum clang::NestedNameSpecifier::SpecifierKind

Fixes in this iteration include:

(1) Compute the type-source range properly for a dependent template
specialization type that starts with "template template-id ::", as
in a member access expression

dep->template f<T>::f()

This is a latent bug I triggered with this change (because now we're
checking the computed source ranges for dependent template
specialization types). But the real problem was...

(2) Make sure to set the qualifier range on a dependent template
specialization type appropriately. This will go away once we push
nested-name-specifier locations into dependent template
specialization types, but it was the source of the
valgrind errors on the buildbots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126765 91177308-0d34-0410-b5e6-96231b3b80d8
cfe9af250f466e7e38becea4428990448ae07737 01-Mar-2011 Roman Divacky <rdivacky@freebsd.org> Implement -mrtd which sets the StdCall calling convention to be the default

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126756 91177308-0d34-0410-b5e6-96231b3b80d8
1c51b1ca1fb835d8ee172b5804d66864ab3a0167 01-Mar-2011 Roman Divacky <rdivacky@freebsd.org> Add missing options.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126755 91177308-0d34-0410-b5e6-96231b3b80d8
2786864406af0f3ec65b300675c6f3c809c22fd7 01-Mar-2011 Douglas Gregor <dgregor@apple.com> Revert r126748, my second attempt at nested-name-specifier source
location information for elaborated types. *sigh*

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126753 91177308-0d34-0410-b5e6-96231b3b80d8
be38c5f5d8fa7c43c52fafddee054b8fe8c2b964 01-Mar-2011 Douglas Gregor <dgregor@apple.com> Reinstate r126737, extending the generation of type-source location
information for qualifier type names throughout the parser to address
several problems.

The commit message from r126737:

Push nested-name-specifier source location information into elaborated
name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind".

Aside from the normal changes, this also required some tweaks to the
parser. Essentially, when we're looking at a type name (via
getTypeName()) specifically for the purpose of creating an annotation
token, we pass down the flag that asks for full type-source location
information to be stored within the returned type. That way, we retain
source-location information involving nested-name-specifiers rather
than trying to reconstruct that information later, long after it's
been lost in the parser.

With this change, test/Index/recursive-cxx-member-calls.cpp is showing
much improved results again, since that code has lots of

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126748 91177308-0d34-0410-b5e6-96231b3b80d8
44cd9f9d686dfdb9ad16113c41c2dca1da35a646 01-Mar-2011 Douglas Gregor <dgregor@apple.com> Revert r126737, the most recent nested-name-specifier location change, for buildbot breakage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126746 91177308-0d34-0410-b5e6-96231b3b80d8
239cbb023c8da689e7722f7146914eed9755e368 01-Mar-2011 Douglas Gregor <dgregor@apple.com> Push nested-name-specifier source location information into elaborated
name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind".

Aside from the normal changes, this also required some tweaks to the
parser. Essentially, when we're looking at a type name (via
getTypeName()) specifically for the purpose of creating an annotation
token, we pass down the flag that asks for full type-source location
information to be stored within the returned type. That way, we retain
source-location information involving nested-name-specifiers rather
than trying to reconstruct that information later, long after it's
been lost in the parser.

With this change, test/Index/recursive-cxx-member-calls.cpp is showing
much improved results again, since that code has lots of

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126737 91177308-0d34-0410-b5e6-96231b3b80d8
2494dd024b392b8def58bf067cc94b51c214cf77 01-Mar-2011 Douglas Gregor <dgregor@apple.com> Push nested-name-specifier source location information into
DependentNameTypeLoc. Teach the recursive AST visitor and libclang how to
walk DependentNameTypeLoc nodes.

Also, teach libclang about TypedefDecl source ranges, so that we get
those. The massive churn in test/Index/recursive-cxx-member-calls.cpp
is a good thing: we're annotating a lot more of this test correctly

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126729 91177308-0d34-0410-b5e6-96231b3b80d8
5f791bb44417ecc201ed57a85d0fe02001d8a615 01-Mar-2011 Douglas Gregor <dgregor@apple.com> Refactor the construction of nested-name-specifiers with
source-location information into a NestedNameSpecifierLocBuilder
class, which lives within the AST library and centralize all knowledge
of the format of nested-name-specifier location information here.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126716 91177308-0d34-0410-b5e6-96231b3b80d8
c22b5fff39a7520207f165fb16a27a34b944bd9c 25-Feb-2011 Douglas Gregor <dgregor@apple.com> Use NestedNameSpecifierLoc within out-of-line variables, function, and
tag definitions. Also, add support for template instantiation of

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126470 91177308-0d34-0410-b5e6-96231b3b80d8
dc355713be51fcb4ee52d9fd6b4548ceff47fadf 25-Feb-2011 Douglas Gregor <dgregor@apple.com> Update UsingDecl, UnresolvedUsingTypenameDecl, and
UnresolvedUsingValueDecl to use NestedNameSpecifierLoc rather than the
extremely-lossy NestedNameSpecifier/SourceRange pair it used to use,
improving source-location information.

Various infrastructure updates to support NestedNameSpecifierLoc:
- AST/PCH (de-)serialization
- Recursive AST visitor
- libclang traversal (including the first tests of this

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126459 91177308-0d34-0410-b5e6-96231b3b80d8
14aba76042e041b2c5e439bf4ae353a0a3c7fd73 24-Feb-2011 Douglas Gregor <dgregor@apple.com> Teach NestedNameSpecifier to keep track of namespace aliases the same
way it keeps track of namespaces. Previously, we would map from the
namespace alias to its underlying namespace when building a
nested-name-specifier, losing source information in the process.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126358 91177308-0d34-0410-b5e6-96231b3b80d8
277a6e752512cff286190d35cb353ce717e86b18 23-Feb-2011 Nick Lewycky <nicholas@mxc.ca> 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
7da99b05aa9482e76b2954223b5652469004aec2 23-Feb-2011 Anders Carlsson <andersca@mac.com> Add a CXXExceptions flag to LangOptions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126299 91177308-0d34-0410-b5e6-96231b3b80d8
34b41d939a1328f484511c6002ba2456db879a29 20-Feb-2011 Richard Smith <richard-llvm@metafoo.co.uk> Implement the C++0x deduced 'auto' feature.

This fixes PR 8738, 9060 and 9132.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126069 91177308-0d34-0410-b5e6-96231b3b80d8
da4b7cf09ebfd4e4098b516081fa9dae2f5c99e0 20-Feb-2011 Anders Carlsson <andersca@mac.com> Add a new ObjCExceptions member variable to LangOptions. This controls whether Objective-C exceptions are enabled or not (they are by default).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126061 91177308-0d34-0410-b5e6-96231b3b80d8
ad8dcf4a9df0e24051dc31bf9e6f3cd138a34298 17-Feb-2011 Chris Lattner <sabre@nondot.org> Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt. There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself. This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.

This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.

This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.

Review appreciated, particularly for the cindex and template bits.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125733 91177308-0d34-0410-b5e6-96231b3b80d8
84bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbc 15-Feb-2011 Peter Collingbourne <peter@pcc.me.uk> Serialization/deserialization support for floating point #pragma
options, enabled OpenCL extensions and default FP_CONTRACT setting.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125589 91177308-0d34-0410-b5e6-96231b3b80d8
8e3df4d0864f0a966c20088ca1a29c3398b7639d 15-Feb-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> 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
0895d1513772eca5a20c552976209fd7f58b993f 12-Feb-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> When reading the AST, delay loading of the redeclaration chain to avoid deeply nested calls.
Temporarily set the first (canonical) declaration as the previous one, which is the one that
matters, and mark the real previous DeclID to be loaded & attached later on.

Fixes rdar://8956193.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125434 91177308-0d34-0410-b5e6-96231b3b80d8
0a480293f726508ad9aed0be39e8c9779e84f2f2 11-Feb-2011 Douglas Gregor <dgregor@apple.com> 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
cfbf1c7536e016dc275139dd842d4a5f059a749f 10-Feb-2011 Douglas Gregor <dgregor@apple.com> Implement two related optimizations that make de-serialization of
AST/PCH files more lazy:
- Don't preload all of the file source-location entries when reading
the AST file. Instead, load them lazily, when needed.
- Only look up header-search information (whether a header was already
#import'd, how many times it's been included, etc.) when it's needed
by the preprocessor, rather than pre-populating it.

Previously, we would pre-load all of the file source-location entries,
which also populated the header-search information structure. This was
a relatively minor performance issue, since we would end up stat()'ing
all of the headers stored within a AST/PCH file when the AST/PCH file
was loaded. In the normal PCH use case, the stat()s were cached, so
the cost--of preloading ~860 source-location entries in the Cocoa.h
case---was relatively low.

However, the recent optimization that replaced stat+open with
open+fstat turned this into a major problem, since the preloading of
source-location entries would now end up opening those files. Worse,
those files wouldn't be closed until the file manager was destroyed,
so just opening a Cocoa.h PCH file would hold on to ~860 file
descriptors, and it was easy to blow through the process's limit on
the number of open file descriptors.

By eliminating the preloading of these files, we neither open nor stat
the headers stored in the PCH/AST file until they're actually needed
for something. Concretely, we went from

*** HeaderSearch Stats:
835 files tracked.
364 #import/#pragma once files.
823 included exactly once.
6 max times a file is included.
3 #include/#include_next/#import.
0 #includes skipped due to the multi-include optimization.
1 framework lookups.
0 subframework lookups.

*** Source Manager Stats:
835 files mapped, 3 mem buffers mapped.
37460 SLocEntry's allocated, 11215575B of Sloc address space used.
62 bytes of files mapped, 0 files with line #'s computed.

with a trivial program that uses a chained PCH including a Cocoa PCH

*** HeaderSearch Stats:
4 files tracked.
1 #import/#pragma once files.
3 included exactly once.
2 max times a file is included.
3 #include/#include_next/#import.
0 #includes skipped due to the multi-include optimization.
1 framework lookups.
0 subframework lookups.

*** Source Manager Stats:
3 files mapped, 3 mem buffers mapped.
37460 SLocEntry's allocated, 11215575B of Sloc address space used.
62 bytes of files mapped, 0 files with line #'s computed.

for the same program.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125286 91177308-0d34-0410-b5e6-96231b3b80d8
14b6ba77710d6431794d65c7d58c6f29c3dc956e 09-Feb-2011 Peter Collingbourne <peter@pcc.me.uk> AST, Sema, Serialization: keep track of cudaConfigureCall

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125216 91177308-0d34-0410-b5e6-96231b3b80d8
4800a5c79023271408af49797e09be32aca93232 08-Feb-2011 Douglas Gregor <dgregor@apple.com> Split the serialized representation for the detailed preprocessing
record away from the core processor record. The tangling of these two
data structures led to some inefficiencies (e.g., deserializing all
of the detailed preprocessing record when we didn't need it, such as
while performing code completion) along with some unnecessary

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125117 91177308-0d34-0410-b5e6-96231b3b80d8
8ef6c8cb6c5627240e2339fd7062c9873f821d7e 05-Feb-2011 Douglas Gregor <dgregor@apple.com> 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
f677ea3cc9598d9952ad7ffab5fb322ba4c5be31 05-Feb-2011 Sebastian Redl <sebastian.redl@getdesigned.at> Basic implementation of inherited constructors. Only generates declarations, and probably only works for very basic use cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124970 91177308-0d34-0410-b5e6-96231b3b80d8
f9997a0834e0e0298b04ef044ad2699c727a7979 01-Feb-2011 Douglas Gregor <dgregor@apple.com> Fix a thinko where I didn't update a consistency check for
PackExpansionType in the AST reader. We need more testing for variadic
templates + PCH, but this fixes PR9073.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124662 91177308-0d34-0410-b5e6-96231b3b80d8
6f75550e40a9177db9979fc130ce3ece026b137d 01-Feb-2011 Douglas Gregor <dgregor@apple.com> Basic support for -mms-bitfields, from Carl Norum!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124661 91177308-0d34-0410-b5e6-96231b3b80d8
04331169f04198eb769925fa17696a21989c9d8b 27-Jan-2011 Axel Naumann <Axel.Naumann@cern.ch> TextDiagnosticPrinter.cpp: Show diagnostics as far as possible even with invalid PresomedLoc, instead of just silencing it.

FileManager.cpp: Allow virtual files in nonexistent directories.
FileManager.cpp: Close FileDescriptor for virtual files that correspond to actual files.
FileManager.cpp: Enable virtual files to be created even for files that were flagged as NON_EXISTENT_FILE, e.g. by a prior (unsuccessful) addFile().

ASTReader.cpp: Read a PCH even if the original source files cannot be found.

Add a test for reading a PCH of a file that has been removed and diagnostics referencing that file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124374 91177308-0d34-0410-b5e6-96231b3b80d8
c938c1668b4fd12af154e965dd935a89e4801a70 26-Jan-2011 Douglas Gregor <dgregor@apple.com> Rvalue references for *this:

- Add ref-qualifiers to the type system; they are part of the
canonical type. Print & profile ref-qualifiers
- Translate the ref-qualifier from the Declarator chunk for
functions to the function type.
- Diagnose mis-uses of ref-qualifiers w.r.t. static member
functions, free functions, constructors, destructors, etc.
- Add serialization and deserialization of ref-qualifiers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124281 91177308-0d34-0410-b5e6-96231b3b80d8
f4c7371fb1d3cebcfb40abad4537bb82515704ea 19-Jan-2011 John McCall <rjmccall@apple.com> Change QualType::getTypePtr() to return a const pointer, then change a
thousand other things which were (generally inadvertantly) relying on that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123814 91177308-0d34-0410-b5e6-96231b3b80d8
1aee05d08b2184acadeb36de300e216390780d6c 15-Jan-2011 Douglas Gregor <dgregor@apple.com> Introduce a new kind of TemplateName that captures a substituted
template template parameter pack that cannot be fully expanded because
its enclosing pack expansion could not be expanded. This form of
TemplateName plays the same role as SubstTemplateTypeParmPackType and
SubstNonTypeTemplateParmPackExpr do for template type parameter packs
and non-type template parameter packs, respectively.

We should now handle these multi-level pack expansion substitutions
anywhere. The largest remaining gap in our variadic-templates support
is that we cannot cope with non-type template parameter packs whose
type is a pack expansion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123521 91177308-0d34-0410-b5e6-96231b3b80d8
b1bdced5967c54d029cd12907e8939c78decf14c 15-Jan-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Store/retrieve -fshort-enums for PCH, fixes rdar://8854933.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123510 91177308-0d34-0410-b5e6-96231b3b80d8
2be29f423acad3bbe39099a78db2805acb5bdf17 15-Jan-2011 Douglas Gregor <dgregor@apple.com> Teach template template argument pack expansions to keep track of the
number of expansions, when we know it, and propagate that information
through Sema.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123493 91177308-0d34-0410-b5e6-96231b3b80d8
3efd52cf8f4e57c5571bd8cc3168264c3bc46a1e 14-Jan-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Properly propagate #pragma diagnostic mappings from PCH but not command-line warning flags.
Addresses rdar://8435969&8852495

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123462 91177308-0d34-0410-b5e6-96231b3b80d8
cded4f649cd4b7ba7d461c25c6482ef52b8d3a2a 14-Jan-2011 Douglas Gregor <dgregor@apple.com> Keep track of the number of expansions to be produced from a type pack
expansion, when it is known due to the substitution of an out
parameter pack. This allows us to properly handle substitution into
pack expansions that involve multiple parameter packs at different
template parameter levels, even when this substitution happens one
level at a time (as with partial specializations of member class
templates and the signatures of member function templates).

Note that the diagnostic we provide when there is an arity mismatch
between an outer parameter pack and an inner parameter pack in this
case isn't as clear as the normal diagnostic for an arity
mismatch. However, this doesn't matter because these cases are very,
very rare and (even then) only typically occur in a SFINAE context.

The other kinds of pack expansions (expression, template, etc.) still
need to support optional tracking of the number of expansions, and we
need the moral equivalent of SubstTemplateTypeParmPackType for
substituted argument packs of template template and non-type template

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123448 91177308-0d34-0410-b5e6-96231b3b80d8
c3069d618f4661d923cb1b5c4525b082fce73b04 14-Jan-2011 Douglas Gregor <dgregor@apple.com> Start implementing support for substitution into pack expansions that
involve template parameter packs at multiple template levels that
occur within the signatures members of class templates (and partial
specializations thereof). This is a work-in-progress that is deficient
in several ways, notably:
- It only works for template type parameter packs, but we need to
also support non-type template parameter packs and template template
parameter packs.
- It doesn't keep track of the lengths of the substituted argument
packs in the expansion, so it can't properly diagnose length

However, this is a concrete step in the right direction.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123425 91177308-0d34-0410-b5e6-96231b3b80d8
cbb67480094b3bcb5b715acd827cbad55e2a204c 08-Jan-2011 Sean Hunt <scshunt@csclub.uwaterloo.ca> Renamed CXXBaseOrMemberInitializer to CXXCtorInitializer. This is both shorter,
more accurate, and makes it make sense for it to hold a delegating constructor

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123084 91177308-0d34-0410-b5e6-96231b3b80d8
f84109ee6aeffb09366bd70c8593ce1b7818b1ad 07-Jan-2011 Fariborz Jahanian <fjahanian@apple.com> Update AST reader/writer to handle new AppleKext.
Fix an unexpected hickup caused by exceeding size of
generated table (and a misleading comment). Improve
on help message for -fapple-kext.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123003 91177308-0d34-0410-b5e6-96231b3b80d8
9d156a7b1b2771e191f2f5a45a7b7a694129463b 06-Jan-2011 John McCall <rjmccall@apple.com> Introduce an AttributedType, but don't actually use it anywhere yet.
The initial TreeTransform is a cop-out, but it's more-or-less equivalent
to what we were doing before, or rather what we're doing now and might
eventually stop doing in favor of using this type.
I am simultaneously intrigued by the possibilities of rebuilding a
dependent Attri

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122942 91177308-0d34-0410-b5e6-96231b3b80d8
a7fc901a2e39bfe55bfcff5934b2d9fdf9656491 05-Jan-2011 Douglas Gregor <dgregor@apple.com> Replace the representation of template template argument pack
expansions with something that is easier to use correctly: a new
template argment kind, rather than a bit on an existing kind. Update
all of the switch statements that deal with template arguments, fixing
a few latent bugs in the process. I"m happy with this representation,

And, oh look! Template instantiation and deduction work for template
template argument pack expansions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122896 91177308-0d34-0410-b5e6-96231b3b80d8
ba68eca7582a62e3e2ff4b0eba1b2b73a6b80895 05-Jan-2011 Douglas Gregor <dgregor@apple.com> Add semantic analysis for the creation of and an AST representation
for template template argument pack expansions. This allows fun such

template<template<class> class ...> struct apply_impl { /*...*/ };
template<template<class> class ...Metafunctions> struct apply {
typedef typename apply_impl<Metafunctions...>::type type;

However, neither template argument deduction nor template
instantiation is implemented for template template argument packs, so
this functionality isn't useful yet.

I'll probably replace the encoding of template template
argument pack expansions in TemplateArgument so that it's harder to
accidentally forget about the expansion. However, this is a step in
the right general direction.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122890 91177308-0d34-0410-b5e6-96231b3b80d8
3fb9e4b89f72823f162096086f0f964e6dcf66d6 04-Jan-2011 Douglas Gregor <dgregor@apple.com> Implement pack expansion of base initializers, so that we can
initialize those lovely mixins that come from pack expansions of base

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122793 91177308-0d34-0410-b5e6-96231b3b80d8
f90b27ad077c3339b62befc892382845339f9490 03-Jan-2011 Douglas Gregor <dgregor@apple.com> Implement pack expansions whose pattern is a base-specifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122782 91177308-0d34-0410-b5e6-96231b3b80d8
c32647d111e516593b9ba242cad7b8ff4016c155 23-Dec-2010 Ted Kremenek <kremenek@apple.com> Add -fobjc-default-synthesized-properties flag
to allow us to explicitly control whether or
not Objective-C properties are default synthesized.
Currently this feature only works when using
the -fobjc-non-fragile-abi2 flag (so there is
no functionality change), but we can now turn
off this feature without turning off all the features
coupled with -fobjc-non-fragile-abi2.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122519 91177308-0d34-0410-b5e6-96231b3b80d8
7536dd5e6c99584481b7dab68b7e7d8df9c54054 20-Dec-2010 Douglas Gregor <dgregor@apple.com> Introduce a new type, PackExpansionType, to capture types that are
pack expansions, e.g. given

template<typename... Types> struct tuple;

template<typename... Types>
struct tuple_of_refs {
typedef tuple<Types&...> types;

the type of the "types" typedef is a PackExpansionType whose pattern
is Types&.

This commit introduces support for creating pack expansions for
template type arguments, as above, but not for any other kind of pack
expansion, nor for any form of instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122223 91177308-0d34-0410-b5e6-96231b3b80d8
256053b31e697fdf0cc48f17d621c82fc3b8dff0 17-Dec-2010 Michael J. Spencer <bigcheesegs@gmail.com> Replace all uses of PathV1::isAbsolute with PathV2::is_{absolute,relative}.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122087 91177308-0d34-0410-b5e6-96231b3b80d8
4eeebc464e1f968d9968a4786c82558f18ac2ed8 16-Dec-2010 Michael J. Spencer <bigcheesegs@gmail.com> MemoryBuffer API update.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121956 91177308-0d34-0410-b5e6-96231b3b80d8
0827408865e32789e0ec4b8113a302ccdc531423 15-Dec-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix diagnostic pragmas.

Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state.
Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect
a lot of places, like C++ inline methods, template instantiations, the lexer, etc.

Fix the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location.

Fixes rdar://8365684.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121873 91177308-0d34-0410-b5e6-96231b3b80d8
e23cf437fe76b1ed02d63c3f61b456fd48a915f5 14-Dec-2010 John McCall <rjmccall@apple.com> Restore r121752 without modification.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121763 91177308-0d34-0410-b5e6-96231b3b80d8
5bfe232d1f07a6fd160fcf82c277c055a412a1c0 14-Dec-2010 John McCall <rjmccall@apple.com> Pull out r121752 in case it's causing the selfhost breakage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121759 91177308-0d34-0410-b5e6-96231b3b80d8
0e88aa7100da32acc63bc8a4dcb946ed517868f1 14-Dec-2010 John McCall <rjmccall@apple.com> Factor out most of the extra state in a FunctionProtoType into a separate
class to be passed around. The line between argument and return types and
everything else is kindof vague, but I think it's justifiable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121752 91177308-0d34-0410-b5e6-96231b3b80d8
1ab55e9bb87d98bff1d42c7a0ee502c64755d9f5 10-Dec-2010 Douglas Gregor <dgregor@apple.com> Eliminate the branching in QualType::getTypePtr() by providing a
common base for ExtQuals and Type that stores the underlying type
pointer. This results in a 2% performance win for -emit-llvm on a
typical C file, with 1% memory growth in the AST.

Note that there is an API change in this optimization:
QualType::getTypePtr() can no longer be invoked on a NULL
QualType. If the QualType might be NULL, use
QualType::getTypePtrOrNull(). I've audited all uses of getTypePtr() in
the code base and changed the appropriate uses over to

A future optimization opportunity would be to distinguish between
cast/dyn_cast and cast_or_null/dyn_cast_or_null; for the former, we
could use getTypePtr() rather than getTypePtrOrNull(), to take another
branch out of the cast/dyn_cast implementation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121489 91177308-0d34-0410-b5e6-96231b3b80d8
075f8f1b6bed4d1b224c74f87508534cc6392ce6 10-Dec-2010 Abramo Bagnara <abramo.bagnara@gmail.com> Added ParenType type node.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121488 91177308-0d34-0410-b5e6-96231b3b80d8
3a321e23f66128dbb986343927456ff6702af617 09-Dec-2010 Michael J. Spencer <bigcheesegs@gmail.com> Use error_code instead of std::string* for MemoryBuffer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121378 91177308-0d34-0410-b5e6-96231b3b80d8
00eb3f9c5b33e3d99aee1f8b75dd9c9678fdd66b 04-Dec-2010 Francois Pichet <pichet2000@gmail.com> More anonymous struct/union redesign. This one deals with anonymous field used in a constructor initializer list:

struct X {
X() : au_i1(123) {}
union {
int au_i1;
float au_f1;

clang will now deal with au_i1 explicitly as an IndirectFieldDecl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120900 91177308-0d34-0410-b5e6-96231b3b80d8
08a53269b1f8241e2e6797e845abbe640fb18253 01-Dec-2010 Peter Collingbourne <peter@pcc.me.uk> Serialization: support for CUDA language extensions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120588 91177308-0d34-0410-b5e6-96231b3b80d8
89d9980bbc2e4a4ac86673e6ec16fb9f5babb63b 30-Nov-2010 Douglas Gregor <dgregor@apple.com> 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
414cb64f09ce48a36377458ce5e5a90c3ad41d00 30-Nov-2010 Douglas Gregor <dgregor@apple.com> When loading a precompiled preamble, use the file ID of the
precompiled preamble as the "main" source file's file ID within the
source manager. This makes compiling with a precompiled preamble
produce the same source locations as when compiling without the
precompiled preamble; prior to this change, we ended up with different
file IDs for source locations within the precompiled preamble
vs. those after the precompiled preamble, even for entities (e.g.,
preprocessing entities) in the same file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120390 91177308-0d34-0410-b5e6-96231b3b80d8
03013fa9a0bf1ef4b907f5fec006c8f4000fdd21 29-Nov-2010 Michael J. Spencer <bigcheesegs@gmail.com> Merge System into Support.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120297 91177308-0d34-0410-b5e6-96231b3b80d8
54353f48939327a4aa41ea3f3ec07b936bd02ef5 25-Nov-2010 Benjamin Kramer <benny.kra@googlemail.com> Hide a bunch of symbols.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120153 91177308-0d34-0410-b5e6-96231b3b80d8
898a061f69e1145bf89a987c08203132b9922a3c 23-Nov-2010 Chris Lattner <sabre@nondot.org> change the 'is directory' indicator to be a null-or-not
pointer that is passed down through the APIs, and make
FileSystemStatCache::get be the one that filters out
directory lookups that hit files. This also paves the
way to have stat queries be able to return opened files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120060 91177308-0d34-0410-b5e6-96231b3b80d8
d6f611198089b78e32d3a15fe8bc986204aee1aa 23-Nov-2010 Chris Lattner <sabre@nondot.org> simplify the cache miss handling code, eliminating CacheMissing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120038 91177308-0d34-0410-b5e6-96231b3b80d8
74e976ba4b0d407bb798ea26476f618e256fc8c7 23-Nov-2010 Chris Lattner <sabre@nondot.org> PCH files only cache successful stats. Remove the code that reads/writes
the result code of the stat to/from the PCH file since it is always 0.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120031 91177308-0d34-0410-b5e6-96231b3b80d8
10e286aa8d39fb51a21412850265d9dae74613ee 23-Nov-2010 Chris Lattner <sabre@nondot.org> rework the stat cache, pulling it out of FileManager.h into
its own header and giving it some more structure. No
functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120030 91177308-0d34-0410-b5e6-96231b3b80d8
75dfb65c38d51772df9a00ce2d2feeefd55667ad 23-Nov-2010 Chris Lattner <sabre@nondot.org> 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
39b49bcaaddb1049234fca9500c0ac02c088e23d 23-Nov-2010 Chris Lattner <sabre@nondot.org> 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
6538227d51df249b07c8ab80ae376f5c1d14403c 21-Nov-2010 Chris Lattner <sabre@nondot.org> remove old compatibility APIs, use StringRef versions instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119935 91177308-0d34-0410-b5e6-96231b3b80d8
33e4e70c8c0a17e0ccb7465d96556b077a68ecb1 18-Nov-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Refactoring of Diagnostic class.

-Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class.
-DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units.
-The rest of the state in Diagnostic object is considered related and tied to one translation unit.
-Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a
SourceLocation instead of a FullSourceLoc.
-Reflect the changes to various interfaces.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119730 91177308-0d34-0410-b5e6-96231b3b80d8
e86d78cf4754a6aef2cf9a33d847aa15338e276f 10-Nov-2010 Bob Wilson <bob.wilson@apple.com> Add a variant of GCC-style vector types for ARM NEON.
NEON vector types need to be mangled in a special way to comply with ARM's ABI,
similar to some of the AltiVec-specific vector types. This patch is mostly
just renaming a bunch of "AltiVecSpecific" things, since they will no longer
be specific to AltiVec. Besides that, it just adds the new "NeonVector" enum.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118724 91177308-0d34-0410-b5e6-96231b3b80d8
910f8008fea79120489a53593fe971b0b8a4a740 08-Nov-2010 Douglas Gregor <dgregor@apple.com> Remove broken support for variadic templates, along with the various
abstractions (e.g., TemplateArgumentListBuilder) that were designed to
support variadic templates. Only a few remnants of variadic templates
remain, in the parser (parsing template type parameter packs), AST
(template type parameter pack bits and TemplateArgument::Pack), and
Sema; these are expected to be used in a future implementation of
variadic templates.

But don't get too excited about that happening now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118385 91177308-0d34-0410-b5e6-96231b3b80d8
f41d3be39980d40849850d3fb90403623cc8459e 05-Nov-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Read/write from/to PCH the diagnostic mappings that the user set so that e.g. #pragma clang diagnostic can be used in a PCH.
Fixes rdar://8435969.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118303 91177308-0d34-0410-b5e6-96231b3b80d8
389db16c63eec6ecfa9b235155252d8da766e94e 03-Nov-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> 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
4ab829c2a229dc20ecb9f35e7337bbfa95bf4026 01-Nov-2010 Douglas Gregor <dgregor@apple.com> Plug a leak in the preprocessing record's handling of inclusion
directives. We had a std::string in an object that was allocated via a

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117912 91177308-0d34-0410-b5e6-96231b3b80d8
295a2a617ac335f590e430ab7fcd98f8ce109251 30-Oct-2010 Douglas Gregor <dgregor@apple.com> Make the deserialization of macro definitions lazy, so that we can
load identifiers without loading their corresponding macro
definitions. This is likely to improve PCH performance slightly, and
reduces deserialization stack depth considerably when using
preprocessor metaprogramming.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117750 91177308-0d34-0410-b5e6-96231b3b80d8
7c789c1a3f77f24032aa0bed2afacdb9e094e952 30-Oct-2010 Douglas Gregor <dgregor@apple.com> Make the deserialization of C++ base class specifiers lazy, improving
the performance of C++ PCH and reducing stack depth in the reader.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117732 91177308-0d34-0410-b5e6-96231b3b80d8
e09a275444576deb2c8d9e2255554242f65d7c00 28-Oct-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Switch case IDs conflict between chained PCHs; since there is no need to be global, make them local to a decl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117540 91177308-0d34-0410-b5e6-96231b3b80d8
bef1a7b9c175d37e4a727e6ce68bd05232fa6970 28-Oct-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Use the ASTMutationListener to track added template specializations in a chained PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117533 91177308-0d34-0410-b5e6-96231b3b80d8
32adc8bd6f05d1e26cc221102e48609da2c446ba 26-Oct-2010 Douglas Gregor <dgregor@apple.com> When de-serializing a type that is supposed to be canonical, call
getCanonicalType() to make sure that the type we got back is actually
canonical. This is the case for most types, which always build a
canonical type when given canonical components. However, some types that
involve expressions in their canonicalization (e.g., array types with
dependent sizes) don't always build canonical types from canonical
components, because there is no such thing as a "canonical"
expression. Therefore, we do this extra mapping to ensure that the
canonical types we store are actually canonical.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117344 91177308-0d34-0410-b5e6-96231b3b80d8
7b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8 24-Oct-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Put the mechanism in place to track modifications in an AST entity that were committed after
its initial creation/deserialization and store the changes in a chained PCH.

The idea is that the AST entities call methods on the ASTMutationListener to give notifications
of changes; the PCHWriter implements the ASTMutationListener interface and stores the incremental changes
of the updated entity. WIP

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117235 91177308-0d34-0410-b5e6-96231b3b80d8
134db1fff5653c164ef41c898943521c49f6ebab 24-Oct-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Simplify and "robust-ify" the way that CXXRecord references point to the definition data when loaded from PCH.

Temporary disable 'test/PCH/chain-cxx.cpp' until a better way to fix it is in place.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117234 91177308-0d34-0410-b5e6-96231b3b80d8
1fb0caaa7bef765b85972274e3b434af2572c141 22-Oct-2010 John McCall <rjmccall@apple.com> Substantially revise how clang computes the visibility of a declaration to
more closely parallel the computation of linkage. This gets us to a state
much closer to what gcc emits, modulo bugs, which will undoubtedly arise in

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117147 91177308-0d34-0410-b5e6-96231b3b80d8
dae4ac4fe56ec60fc93b3e3c9f51e79e682084b9 21-Oct-2010 Michael J. Spencer <bigcheesegs@gmail.com> Reorganize predefined macros for all Windows targets.

This adds an option to set the _MSC_VER macro without
recompiling. This is very useful when testing compatibility
with the Windows SDK and c++stdlib headers.

-fmsc-version=<version> (defaults to VS2003 (1300))

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116999 91177308-0d34-0410-b5e6-96231b3b80d8
20249a1af2e462dcafdd6a350f1c7967b264ff25 21-Oct-2010 Michael J. Spencer <bigcheesegs@gmail.com> Fix Whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116990 91177308-0d34-0410-b5e6-96231b3b80d8
ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0ed 21-Oct-2010 Douglas Gregor <dgregor@apple.com> Extend the preprocessing record and libclang with support for
inclusion directives, keeping track of every #include, #import,
etc. in the translation unit. We keep track of the source location and
kind of the inclusion, how the file name was spelled, and the
underlying file to which the inclusion resolved.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116952 91177308-0d34-0410-b5e6-96231b3b80d8
4045107b7384fd68eed5e3e2f06fc2a47e7be0a6 15-Oct-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Read/write to/from PCH DeclarationNameLocs, DeclarationNameInfos and QualifierInfos (rdar://8513756).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116598 91177308-0d34-0410-b5e6-96231b3b80d8
95f4292cc526c629fead321c7fcfd4fe0f3bc66e 15-Oct-2010 Douglas Gregor <dgregor@apple.com> When performing typo correction, look through the set of known
identifiers to determine good typo-correction candidates. Once we've
identified those candidates, we perform name lookup on each of them
and the consider the results.

This optimization makes typo correction > 2x faster on a benchmark
example using a single typo (NSstring) in a tiny file that includes
Cocoa.h from a precompiled header, since we are deserializing far less
information now during typo correction.

There is a semantic change here, which is interesting. The presence of
a similarly-named entity that is not visible can now affect typo
correction. This is both good (you won't get weird corrections if the
thing you wanted isn't in scope) and bad (you won't get good
corrections if there is a similarly-named-but-completely-unrelated
thing). Time will tell whether it was a good choice or not.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116528 91177308-0d34-0410-b5e6-96231b3b80d8
b870b88df784c2940efce448ebfaf54dece14666 14-Oct-2010 John McCall <rjmccall@apple.com> At Fariborz's request, a somewhat cleaner bit-combining hack.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116524 91177308-0d34-0410-b5e6-96231b3b80d8
eb5e9986e577b1e2bff3cca5973a2494fb593fbb 14-Oct-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Allow deserialization of just the fields of a record, when we want to iterate over them,
instead of deserializing the complete declaration context of the record.

Iterating over the fields of a record is very common (e.g to determine the layout), unfortunately we needlessly deserialize every declaration
that the declaration context of the record contains; this can be bad for large C++ classes that contain a lot of methods.
Fix this by allow deserialization of just the fields when we want to iterate over them.
Progress for rdar://7260160.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116507 91177308-0d34-0410-b5e6-96231b3b80d8
9a2b9d794bdf349b517ff799170f4409f45d147c 08-Oct-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Implement -fshort-enums (rdar://8490496).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116020 91177308-0d34-0410-b5e6-96231b3b80d8
97475834207bf5abb5b58534f783c9b71d4b9df1 05-Oct-2010 Douglas Gregor <dgregor@apple.com> Fix a marvelous chained AST writing bug, where we end up with the
following amusing sequence:
- AST writing schedules writing a type X* that it had never seen
- AST writing starts writing another declaration, ends up
deserializing X* from a prior AST file. Now we have two type IDs for
the same type!
- AST writer tries to write X*. It only has the lower-numbered ID
from the the prior AST file, so references to the higher-numbered ID
that was scheduled for writing go off into lalaland.

To fix this, keep the higher-numbered ID so we end up writing the type
twice. Since this issue occurs so rarely, and type records are
generally rather small, I deemed this better than the alternative: to
keep a separate mapping from the higher-numbered IDs to the
lower-numbered IDs, which we would end up having to check whenever we
want to deserialize any type.

Fixes <rdar://problem/8511624>, I think.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115647 91177308-0d34-0410-b5e6-96231b3b80d8
1d9f1fe7173e3084325f43c78af812a36d8a2a7c 05-Oct-2010 Sebastian Redl <sebastian.redl@getdesigned.at> 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
c3632730cc83ed7b51f0ab5c38997ae5a9439b0c 05-Oct-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Thread PerFileData through the ASTReader again, this time with the LLVM changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115625 91177308-0d34-0410-b5e6-96231b3b80d8
77424bc3794f569816dba52e423b57486a98e5ba 02-Oct-2010 Douglas Gregor <dgregor@apple.com> Implement chained PCH support for the macro definitions stored within
the "detailed" preprocessing record.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115417 91177308-0d34-0410-b5e6-96231b3b80d8
b1a7d9a21bcfc295d1d899a42c0d14d617058c29 01-Oct-2010 Douglas Gregor <dgregor@apple.com> Revert r115336 ("Thread PerFileData through everything."), because
we're missing the corresponding changes in the LLVM repository.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115340 91177308-0d34-0410-b5e6-96231b3b80d8
dc928191a33be17f3b921c0616e6463312f439db 01-Oct-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Thread PerFileData through everything. This allows us to remap stuff later.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115336 91177308-0d34-0410-b5e6-96231b3b80d8
a866e652875c61f09ac29c2f44009ce9f2a25cf2 01-Oct-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Record module loaders and module source order.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115334 91177308-0d34-0410-b5e6-96231b3b80d8
dab60ad68a3a98d687305941a3852e793705f945 01-Oct-2010 Douglas Gregor <dgregor@apple.com> Implement the C++0x "trailing return type" feature, e.g.,

auto f(int) -> int

from Daniel Wallin!

(With a few minor bug fixes from me).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115322 91177308-0d34-0410-b5e6-96231b3b80d8
3747ee72e1751a4996711b9ae5e14f2ca5d4516f 01-Oct-2010 Douglas Gregor <dgregor@apple.com> If we get a TU_CONTEXT update from a chained PCH file before we
actually have an ASTContext, delay the processing of that
update. Patch by Sebastian Redl! Fixes <rdar://problem/8499034>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115263 91177308-0d34-0410-b5e6-96231b3b80d8
297c706f219701b4c9464cccf527f3fe833afc95 30-Sep-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Support implicit includes when generating a PCH and allow the user to pass a -include on the command line following the PCH include.
Fixes rdar://7382084.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115159 91177308-0d34-0410-b5e6-96231b3b80d8
edadecc012dd6bc0bb008a89f0eaccd5c4c1ff64 28-Sep-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Fix a bug in loading macro records. Fixes yet another crash in libclang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114940 91177308-0d34-0410-b5e6-96231b3b80d8
4a9eb26500086f913c4683bb360b14f8ce662fb4 28-Sep-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Fix a use of an invalidated reference due to a hash map reallocating.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114937 91177308-0d34-0410-b5e6-96231b3b80d8
b57a624f22b1efa873e0abac78128b69fba3d486 28-Sep-2010 Sebastian Redl <sebastian.redl@getdesigned.at> When chaining PCHs, only write PPRecords that don't come from PCH, and give them the correct IDs. Fixes a crash in XCode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114913 91177308-0d34-0410-b5e6-96231b3b80d8
76dc8890b6c5223de80be8284adbfc63ceeb3a55 25-Sep-2010 Douglas Gregor <dgregor@apple.com> 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114774 91177308-0d34-0410-b5e6-96231b3b80d8
8db9faed418ea743f55c31e1ccecadbb23bd55b7 22-Sep-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Change source manager serialization to be less tied to the PCH model.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114575 91177308-0d34-0410-b5e6-96231b3b80d8
4ee5a6f9bd82ab3c1a4bdacc0caefe7d5f8bd37a 22-Sep-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Only preload SLocEntries after the entire PCH chain was loaded.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114518 91177308-0d34-0410-b5e6-96231b3b80d8
301c9b0b6722293f1b9d870815ae11e1ffc3245d 22-Sep-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Reshuffle PerFileData's members to make more sense.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114517 91177308-0d34-0410-b5e6-96231b3b80d8
f73c93fea0d4b447585bc7459499ba6b822e045c 15-Sep-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Macro definitions in AST files have their own IDs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114014 91177308-0d34-0410-b5e6-96231b3b80d8
4ea884b429445aa6f1af5bc6e51d0b65a4043e24 07-Sep-2010 Benjamin Kramer <benny.kra@googlemail.com> Replace loops with SmallVector::append.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113185 91177308-0d34-0410-b5e6-96231b3b80d8
f84cde1cbc6a6e6c29f20b164af38dffab60366a 06-Sep-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix a C++ PCH problem which was exposed by r113019. CXXBaseOrMemberInitializer's IsWritten and source order is not set.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113161 91177308-0d34-0410-b5e6-96231b3b80d8
62c78d54bee499dd87f768f48b21c9b5ec15e516 25-Aug-2010 Chandler Carruth <chandlerc@gmail.com> Rename *PendingImplicitInstantiations to *PendingInstantiations. No
functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112040 91177308-0d34-0410-b5e6-96231b3b80d8
2a7fb27913999d132cf9e10e03dc5271faa2e9d3 25-Aug-2010 John McCall <rjmccall@apple.com> Move more stuff out of Sema.h.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112026 91177308-0d34-0410-b5e6-96231b3b80d8
6e50e00c2fe6a04b2c35592588a4b10a2c269416 25-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> AST reader support for having specializations of templates from earlier in the chain.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111985 91177308-0d34-0410-b5e6-96231b3b80d8
5f1e0942a32657b625702aa52f82430d0120f424 24-Aug-2010 John McCall <rjmccall@apple.com> More header elimination. The goal of all this is to allow Parser to
#include Sema.h while keeping all the AST declarations opaque. That may
not be reasonably attainable, though.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111907 91177308-0d34-0410-b5e6-96231b3b80d8
7a1fad38256eb4c5129359be85ba1ea1678eb5c9 24-Aug-2010 John McCall <rjmccall@apple.com> Remove a header dependency from Sema.h at the cost of some type safety.
If someone wants to fix this some other way....

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111905 91177308-0d34-0410-b5e6-96231b3b80d8
5967d6228f183a5fa384f2f1918df679ed2d8666 24-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Add testcase for C++ chained PCH and fix the bugs it uncovered in name lookup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111882 91177308-0d34-0410-b5e6-96231b3b80d8
e1dde811b38e779894150cb1093d57f8411a84f7 24-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Read the UPDATE_VISIBLE record, and add its visible decls to the lookup tables. Also, free the lookup tables when destructing the ASTReader.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111880 91177308-0d34-0410-b5e6-96231b3b80d8
0ea8f7f5a4eba47ae226dd47c6dce39eef0c554c 24-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Correctly initialize the visible decls pointer if there are no visible decls for a record.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111879 91177308-0d34-0410-b5e6-96231b3b80d8
8b12273c86ede439edf52d35b170fd32b2ed49d4 24-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Baby step towards supporting namespaces in chained PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111878 91177308-0d34-0410-b5e6-96231b3b80d8
d226f65006733ed7f709c3174f22ce33391cb58f 21-Aug-2010 John McCall <rjmccall@apple.com> DeclPtrTy -> Decl *

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111733 91177308-0d34-0410-b5e6-96231b3b80d8
a60786b46eaa4766bb57fb3ca4e0191b3f73e42a 21-Aug-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix an issue with writing to PCH another included PCH, introduced by the "using an AST on-disk hash table for name lookup" commit.

When including a PCH and later re-emitting to another PCH, the name lookup tables of DeclContexts
may be incomplete, since we now lazily deserialize the visible decls of a particular name.
Fix the issue by iterating over the un-deserialized visible decls and completing the lookup tables
of DeclContexts before writing them out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111698 91177308-0d34-0410-b5e6-96231b3b80d8
074dcc8ef8c5df7a155c85648e8eae786bee6cab 20-Aug-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Use the AST on-disk hash table for name lookup inside a DeclContext.

*Huge* improvement over the amount of deserializing that we do for C++ lookup.
e.g, if he have the Carbon header precompiled and include it on a file containing this:

int x;

these are the before/after stats:


*** AST File Statistics:
578 stat cache hits
4 stat cache misses
548/30654 source location entries read (1.787695%)
15907/16501 types read (96.400223%)
53525/59955 declarations read (89.275291%)
33993/43525 identifiers read (78.099945%)
41516/51891 statements read (80.006165%)
77/5317 macros read (1.448185%)
0/6335 lexical declcontexts read (0.000000%)
1/5424 visible declcontexts read (0.018437%)

AFTER using the on-disk table:

*** AST File Statistics:
578 stat cache hits
4 stat cache misses
548/30654 source location entries read (1.787695%)
10/16501 types read (0.060602%)
9/59955 declarations read (0.015011%)
161/43525 identifiers read (0.369902%)
20/51891 statements read (0.038542%)
6/5317 macros read (0.112846%)
0/6335 lexical declcontexts read (0.000000%)
2/5424 visible declcontexts read (0.036873%)

There's only one issue affecting mostly the precompiled preambles which I will address soon.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111636 91177308-0d34-0410-b5e6-96231b3b80d8
5d26768e2661faa7ce0b55ffff4be8b3969fbbf5 20-Aug-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Introduce the mechanism for building an AST on-disk hash table for name lookup inside a DeclContext but don't use it yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111635 91177308-0d34-0410-b5e6-96231b3b80d8
c8e5d51f51e46c6f7717761537c6609ef9daf57c 20-Aug-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> serialization::TypeID is used with or without qualifiers, both as index and as index + qualifiers.
Disambiguate and provide some type safety by using a new class TypeIdx for the "TypeID as index" semantics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111630 91177308-0d34-0410-b5e6-96231b3b80d8
0eca89e9890db4d8336ce762a5b359a1d58ca02b 20-Aug-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Share the common code of ComputeHash(Selector Sel) instead of keeping 2 copies in PCHReader and PCHWriter.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111629 91177308-0d34-0410-b5e6-96231b3b80d8
501c1036560bb407f9be6834931253f0929cca86 19-Aug-2010 Douglas Gregor <dgregor@apple.com> Make sure to deallocate the identifier lookup tables and selector tables
when destroying an ASTReader. Plugs a leak that shows up in libclang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111488 91177308-0d34-0410-b5e6-96231b3b80d8
8538e8d43a3a9bd439c987c0de37bcbf035dd391 19-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Rename pch namespace to serialization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111478 91177308-0d34-0410-b5e6-96231b3b80d8
f29f0a28c4d9599b389bbb6d186e14af753dc5a3 19-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Rename stuff in PCHBitCodes.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111475 91177308-0d34-0410-b5e6-96231b3b80d8
6ab7cd853e9c15cf986a8a7c3db1f8d20e275409 19-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Rename the ASTReader header files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111474 91177308-0d34-0410-b5e6-96231b3b80d8
904c9c8389b65ee93a706ede911accd11e0b9d8e 19-Aug-2010 Sebastian Redl <sebastian.redl@getdesigned.at> Rename the ASTReader implementation files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111473 91177308-0d34-0410-b5e6-96231b3b80d8