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

714 Коммитов

Автор SHA1 Сообщение Дата
David Blaikie eb2d1f1c88 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
2011-09-23 20:26:49 +00:00
Douglas Gregor 61e813cc1d Eliminate an MSVC comparison warning, from Aaron Ballman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140388 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-23 16:57:55 +00:00
David Blaikie b219cfc4d7 Switch assert(0/false) llvm_unreachable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140367 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-23 05:06:16 +00:00
Argyrios Kyrtzidis 4cd06348a8 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
2011-09-22 21:17:02 +00:00
Argyrios Kyrtzidis 71a7605977 Don't use TemplateArgumentListInfo inside AST nodes because it may leak.
Use ASTTemplateArgumentListInfo instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140331 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-22 20:07:09 +00:00
Argyrios Kyrtzidis b0c3e0909b Rename ExplicitTemplateArgumentList -> ASTTemplateArgumentListInfo, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140330 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-22 20:07:03 +00:00
David Blaikie 4278c654b6 ArrayRef-ifying Function/BlockDecl's setParams
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140268 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-21 18:16:56 +00:00
Benjamin Kramer 88df12521e 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
2011-09-21 06:42:26 +00:00
Argyrios Kyrtzidis 8f958f14ea [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
2011-09-20 23:27:41 +00:00
Argyrios Kyrtzidis 290ad8c8eb [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
2011-09-20 23:27:38 +00:00
Argyrios Kyrtzidis de4e0a8e57 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
2011-09-20 22:14:48 +00:00
Argyrios Kyrtzidis 92ddef1bf8 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
2011-09-19 20:40:48 +00:00
Argyrios Kyrtzidis b6441ef9b7 Introduce local_begin()/local_end() methods in PreprocessingRecord which
return iterators for local, non-loaded, preprocessed entities.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140062 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-19 20:40:42 +00:00
Argyrios Kyrtzidis 507097ec40 [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
2011-09-19 20:40:35 +00:00
Argyrios Kyrtzidis 2dbaca748b 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
2011-09-19 20:40:25 +00:00
Argyrios Kyrtzidis a64ccefdf0 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
2011-09-19 20:40:19 +00:00
Argyrios Kyrtzidis 1f6d225501 Const-ify some methods in ASTReader.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140054 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-19 20:40:02 +00:00
Argyrios Kyrtzidis ac1ffcc55b [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
2011-09-19 20:39:54 +00:00
Douglas Gregor 61c5e340c2 With modules, we can end up loading a new module after we've seen an
arbitrary amount of code. This forces us to stage the AST writer more
strictly, ensuring that we don't assign a declaration ID to a
declaration until after we're certain that no more modules will get
loaded.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139974 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-17 00:05:03 +00:00
Douglas Gregor 1a995ddaa5 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
2011-09-15 18:47:32 +00:00
Argyrios Kyrtzidis e24692b30a [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
2011-09-15 18:02:56 +00:00
Douglas Gregor ce835df930 Don't try to write a macro offset for an identifier that names a non-exported macro, for real this time
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139745 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 22:14:14 +00:00
Douglas Gregor 5ed6277d2e Revert my exported-macro hackery. Something is amiss
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139734 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 20:57:14 +00:00
Douglas Gregor ec42f5d407 Make sure that we actually keep the key length and data length in sync when dealing with non-exported macros
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139731 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 20:51:12 +00:00
Douglas Gregor 0c129afcfb Don't try to write a macro offset for an identifier that names a non-exported macro
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139728 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-14 20:36:30 +00:00
Argyrios Kyrtzidis 144b38a799 [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
2011-09-13 21:35:00 +00:00
Douglas Gregor 7d5e81bf24 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
2011-09-13 18:26:39 +00:00
Douglas Gregor e289d81369 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
2011-09-13 17:21:33 +00:00
Argyrios Kyrtzidis 768d6cae40 Keep the source range of attributes. Depends on a llvm tablegen commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139600 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 16:05:58 +00:00
Argyrios Kyrtzidis 26d43cd3a0 [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
2011-09-12 18:09:38 +00:00
Chris Lattner a2f4ae8cfa remove pedantic ;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139472 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-10 16:13:42 +00:00
Douglas Gregor 02a5e875cc 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
2011-09-10 00:30:18 +00:00
Douglas Gregor 94da1587f7 Clean up our handling of Objective-C definitions in AST files. Rather
than having CodeGen check whether a declaration comes from an AST file
(which it shouldn't know or care about), make sure that the AST writer and
reader pass along "interesting" declarations that CodeGen needs to
know about.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139441 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-10 00:22:34 +00:00
Douglas Gregor 08e0bc16b3 Kill of the Decl::PCHLevel field entirely. We now only need to know
whether a Decl was deserialized from an AST file (any AST file).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139438 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-10 00:09:20 +00:00
Douglas Gregor 530b14ad27 Eliminate all but one caller of Decl::getPCHLevel()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139430 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 23:07:59 +00:00
Douglas Gregor 919814def9 Introduce a new predicate Decl::isFromASTFile() to determine whether a
declaration was deserialized from an AST file. Use this instead of
Decl::getPCHLevel() wherever possible. This is a simple step toward
killing off Decl::getPCHLevel().



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139427 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 23:01:35 +00:00
Douglas Gregor 712f2fcb70 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
2011-09-09 22:02:16 +00:00
Douglas Gregor 3594277947 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
change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139413 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 21:34:22 +00:00
Douglas Gregor 5db255e02f 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
2011-09-09 21:09:37 +00:00
Douglas Gregor 5181ad023c 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
CodeGen.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139408 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 21:05:56 +00:00
Argyrios Kyrtzidis 84ef0b5f6b [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
2011-09-09 06:44:17 +00:00
Douglas Gregor 8d267c57af Modules: introduce the __module_private__ declaration specifier, which
indicates that a declaration is only visible within the module it is
declared in.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139348 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-09 02:06:17 +00:00
Argyrios Kyrtzidis 8f7c540ac4 [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
2011-09-08 17:18:41 +00:00
Douglas Gregor e97179c675 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
<rdar://problem/9267640>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139275 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 01:46:34 +00:00
Douglas Gregor 58e9797d00 Finish implementing (de-)serialization of the CXXDefinitionData bits
needed for implicit move constructors and move assignment
operators. Fixes PR10847.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139144 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 16:38:46 +00:00
Douglas Gregor f8a1e51c48 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
2011-09-02 00:26:20 +00:00
Douglas Gregor bcfd1f55bf Extend the ASTContext constructor to delay the initialization of
builtin types (When requested). This is another step toward making
ASTUnit build the ASTContext as needed when loading an AST file,
rather than doing so after the fact. No actual functionality change (yet).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138985 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 00:18:52 +00:00
Argyrios Kyrtzidis e2ca828119 Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This fails
in the face of buffering C++/ObjC method bodies.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138972 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 21:53:45 +00:00
Douglas Gregor 7143aab97c 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
2011-09-01 17:04:32 +00:00
Argyrios Kyrtzidis fa77cbab63 Fix "multi-line comment" compiler error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138936 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 03:07:11 +00:00
Argyrios Kyrtzidis e6b8d68a92 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
2011-09-01 00:58:55 +00:00
Sebastian Redl 14c3633a0b Serialize the new bits in CXXRecordDecl::DefinitionData.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138855 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-31 13:59:56 +00:00
Douglas Gregor e5a54b600f When writing out the entries in a lookup table for a DeclContext, make
sure that all of the CXXConversionDecls go into the same
bucket. Otherwise, name lookup might not find them all. Fixes
<rdar://problem/10041960>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138824 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 20:49:19 +00:00
Argyrios Kyrtzidis 955fadbdfe Remove a few mutating ObjCCategoryDecl methods.
Remove
  -setClassInterface
  -setNextClassCategory
  -insertNextClassCategory

and combine them in the Create function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138817 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 19:43:26 +00:00
Argyrios Kyrtzidis 45118d8f2b In ASTWriter::WriteDeclContextVisibleBlock, don't write empty lookups.
Empty lookups can occur in the DeclContext map when we are chaining PCHs, where
the empty lookup indicates that we already looked in ExternalASTSource.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138816 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 19:43:23 +00:00
Jordy Rose 3b84ab9f2a 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
2011-08-30 01:51:13 +00:00
Fariborz Jahanian 95ed7784a3 objective-c: Treat top-level objective-c declarations
, such as list of forward @class decls, in a DeclGroup
node. Deal with its consequence throught clang. This
is in preparation for more Sema work ahead. // rdar://8843851.
Feel free to reverse if it breaks something important
and I am unavailable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138709 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-27 20:50:59 +00:00
Benjamin Kramer 74cfb23d44 Remove unused variables noticed by GCC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138707 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-27 17:54:32 +00:00
Douglas Gregor 2ea054fbc5 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
2011-08-26 22:04:51 +00:00
Douglas Gregor 9293ba8e26 Remove the Chaining argument from the PCH/module generator. It's no longer used
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138596 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 22:35:51 +00:00
Douglas Gregor 467dc88512 Introduce a -cc1 option "-emit-module", that creates a binary module
from the given source. -emit-module behaves similarly to -emit-pch,
except that Sema is somewhat more strict about the contents of
-emit-module. In the future, there are likely to be more interesting
differences.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138595 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 22:30:56 +00:00
Douglas Gregor 46c03c3e74 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
2011-08-25 21:19:59 +00:00
Douglas Gregor f249bf3b9f 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
2011-08-25 21:09:44 +00:00
Douglas Gregor c69a292f9f 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
2011-08-25 20:58:51 +00:00
Douglas Gregor 98339b96a8 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
2011-08-25 20:47:51 +00:00
Douglas Gregor d10a381d92 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
2011-08-25 18:14:34 +00:00
Douglas Gregor b95cd09db9 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
2011-08-25 18:03:05 +00:00
Douglas Gregor 1b59e9c3e1 Remove a bogus assertion from the AST reader, which assumed that
redeclarations of a particular entity would occur in source
order. Friend declarations that occur within class templates (or
member classes thereof) do not follow this, nor would modules. Big
thanks to Erik Verbruggen for reducing this problem from the Very
Large Qt preamble testcase he found.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138557 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 15:28:26 +00:00
Douglas Gregor 3d15ab8d08 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
2011-08-25 14:51:20 +00:00
Douglas Gregor c266de97e2 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
2011-08-24 21:56:08 +00:00
Douglas Gregor 851c75a279 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
2011-08-24 21:27:34 +00:00
Douglas Gregor 0d95f77ba1 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
"chain"). 

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
2011-08-24 19:03:07 +00:00
Argyrios Kyrtzidis d9d2b679d0 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
2011-08-21 23:33:04 +00:00
Douglas Gregor 0c02adaa4d 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
2011-08-20 05:09:43 +00:00
Douglas Gregor 90115a3788 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
2011-08-20 04:58:43 +00:00
Douglas Gregor 211f6e8948 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
2011-08-20 04:39:52 +00:00
Douglas Gregor a3a0cf07fe Remove unused function ModuleManager::exportLookup()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138079 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 21:12:29 +00:00
Douglas Gregor fac4ece118 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
2011-08-19 02:29:29 +00:00
Chad Rosier 870d1fee3c 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
2011-08-18 19:06:24 +00:00
Douglas Gregor a4c189f435 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
2011-08-18 04:41:58 +00:00
Douglas Gregor 10bc00fd45 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
2011-08-18 04:12:04 +00:00
Argyrios Kyrtzidis 28fc50c70f Remove an unnecessary assignment (to InstFromD).
Caught by the static analyzer!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137878 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 21:35:28 +00:00
Douglas Gregor e95b9198b8 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
2011-08-17 21:07:30 +00:00
Francois Pichet bc84532e76 Add serialization support for ClassScopeFunctionSpecializationDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137799 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 01:06:54 +00:00
Argyrios Kyrtzidis d21683cdc0 [PCH] When writing out ExpansionInfo, make sure we don't lose track if it's a macro arg expansion or not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137792 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 00:31:14 +00:00
Richard Smith af1fc7af35 Track in the AST whether a function is constexpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137653 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 21:04:07 +00:00
Francois Pichet af0f4d0b2e Implement function template specialization at class scope extension in Microsoft mode. A new AST node is introduced: ClassScopeFunctionSpecialization. This node holds a FunctionDecl that is not yet specialized; then during the class template instantiation the ClassScopeFunctionSpecialization will spawn the actual function specialization.
Example:
template <class T>
class A {
public:
  template <class U> void f(U p) {  }
  template <> void f(int p) {  } // <== class scope specialization
};

This extension is necessary to parse MSVC standard C++ headers, MFC and ATL code.
BTW, with this feature in, clang can parse (-fsyntax-only) all the MSVC 2010 standard header files without any error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137573 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-14 03:52:19 +00:00
Douglas Gregor 772eeaefef Switch the __int128_t and __uint128_t types over to predefined types
in the AST format, which are built lazily by the ASTContext when
requested.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137437 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 06:49:56 +00:00
Douglas Gregor 7a27ea52b7 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
2011-08-12 06:17:30 +00:00
Douglas Gregor 79d6726921 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
2011-08-12 05:59:41 +00:00
Douglas Gregor 4dfd02a17c 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
2011-08-12 05:46:01 +00:00
Douglas Gregor b7c324f858 Collapse ASTWriter::WriteASTChain into ASTWriter::WriteASTCore,
eliminating a pile of redundant code (and probably some bugs in the
process). The variation between chained and non-chained PCH is fairly
small now anyway.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137410 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 01:39:19 +00:00
Douglas Gregor 6bf2b9fbd3 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
2011-08-12 00:15:20 +00:00
Argyrios Kyrtzidis 63ab2c54dc 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
2011-08-11 23:26:42 +00:00
Douglas Gregor 5f95728e0d 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
2011-08-11 22:18:49 +00:00
Douglas Gregor 30403a611d 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
2011-08-11 22:04:35 +00:00
Richard Smith 6b8bc0707f Renamings to consistently use 'Constexpr' not 'ConstExpr' when referring to the C++0x 'constexpr' keyword.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137230 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 18:11:37 +00:00
Douglas Gregor 0815b579b3 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
2011-08-09 17:23:49 +00:00
Douglas Gregor 5c0d3d66bf 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
2011-08-09 16:24:26 +00:00
Douglas Gregor 45c4ea75b2 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
2011-08-09 15:54:21 +00:00
Douglas Gregor 3b8043b49a 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
2011-08-09 15:13:55 +00:00
Jonathan D. Turner de91db51c1 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
2011-08-05 23:07:10 +00:00
Douglas Gregor ca109e5665 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
output.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136903 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 19:00:50 +00:00
Douglas Gregor 272b6bc6a6 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
2011-08-04 18:56:47 +00:00
Douglas Gregor 3b2257ca05 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
2011-08-04 18:09:14 +00:00
Douglas Gregor 7338a922dd 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
2011-08-04 17:06:18 +00:00
Douglas Gregor 837593fec8 Add some missing record names to the AST output. No functionality change, but llvm-bcanalyzer will be a little more informative now for AST files
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136883 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 16:39:39 +00:00
Douglas Gregor fb2d9e092f 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
2011-08-04 16:36:56 +00:00
Douglas Gregor d631d0e74d 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
2011-08-04 15:46:00 +00:00
Douglas Gregor e92b8a1dbb 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
2011-08-04 00:01:48 +00:00
Douglas Gregor b18b1fd33f 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
2011-08-03 23:28:44 +00:00
Douglas Gregor 6ec60e00ee 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
2011-08-03 21:49:18 +00:00
Jonathan D. Turner 43fd9388d3 Fix a few typos
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136792 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 17:36:09 +00:00
Douglas Gregor 0a14e4bf60 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
2011-08-03 16:05:40 +00:00
Douglas Gregor 496c709a6f 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
module. 

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
2011-08-03 15:48:04 +00:00
Douglas Gregor e36050111e 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
  bullet.

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
complicated. 

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
2011-08-02 18:32:54 +00:00
Jonathan D. Turner c24a1eef40 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
2011-08-02 17:40:32 +00:00
Douglas Gregor a119da0761 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
2011-08-02 16:26:37 +00:00
Douglas Gregor 8df5c9b5d6 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
offsets.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136687 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 11:12:41 +00:00
Douglas Gregor f33740efdb 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
IDs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136686 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 10:56:51 +00:00
Douglas Gregor 69a9e01785 Move the serialization of the MODULE_OFFSET_MAP out of the source-manager-writing code and into the general chained-PCH writing code
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136624 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 16:54:33 +00:00
Douglas Gregor 5d51a1d22d 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
2011-08-01 16:01:55 +00:00
Jonathan D. Turner 2e09163890 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
2011-07-29 18:09:09 +00:00
Douglas Gregor eda6158412 Remove unused debug function
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136442 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 00:59:35 +00:00
Douglas Gregor 9827a8049a 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
2011-07-29 00:56:45 +00:00
Douglas Gregor 1e849b6f43 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
2011-07-29 00:21:44 +00:00
Jonathan D. Turner b4ae29ced8 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
2011-07-28 23:15:22 +00:00
Douglas Gregor 86c67d8802 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
2011-07-28 22:39:26 +00:00
Douglas Gregor e144c70d07 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
2011-07-28 22:16:57 +00:00
Douglas Gregor 2d2689ab78 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
2011-07-28 21:16:51 +00:00
Douglas Gregor 95eab176f5 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
2011-07-28 20:55:49 +00:00
Douglas Gregor 6e4a3f5c59 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
2011-07-28 19:49:54 +00:00
Douglas Gregor f2abb52acb 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
2011-07-28 19:26:52 +00:00
Douglas Gregor dfe6543e12 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
2011-07-28 19:11:31 +00:00
Douglas Gregor 31e37b2d7b Make Sema::WeakUndeclaredIdentifiers lazily deserialized.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136368 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 18:09:57 +00:00
Jonathan D. Turner 1afb661bc5 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
2011-07-28 17:20:23 +00:00
Douglas Gregor 5b9dc7caae Make Sema::ReferencedSelectors lazily deserialized.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136357 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 14:54:22 +00:00
Douglas Gregor 8451ec7e70 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
2011-07-28 14:41:43 +00:00
Douglas Gregor ec12ce2f6d 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
2011-07-28 14:20:37 +00:00
Douglas Gregor b4dc485a2b 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
2011-07-28 04:50:02 +00:00
Douglas Gregor 1e5b6f60e2 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
2011-07-28 00:57:24 +00:00
Douglas Gregor a126f17ca8 Switch Sema::DynamicClasses over to LazyVector
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136317 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 00:53:40 +00:00
Douglas Gregor d58a0a55e6 Switch Sema::ExtVectorDecls over to LazyVector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136314 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 00:39:29 +00:00
Douglas Gregor 0129b561a1 Turn Sema::DelegatingCtorDecls into a LazyVector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136273 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 21:57:17 +00:00
Douglas Gregor a2ee20aa96 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
  eliminate.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136270 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 21:45:57 +00:00
Douglas Gregor a862320972 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
independently.

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
2011-07-27 20:58:46 +00:00
Douglas Gregor a7d445a718 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
2011-07-27 16:30:06 +00:00
Douglas Gregor 5cee119558 Add support for C++0x unicode string and character literals, from Craig Topper!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136210 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 05:40:30 +00:00
Jonathan D. Turner 48d2c3f7c3 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
2011-07-26 18:21:30 +00:00
Chandler Carruth 1728762d5a Migrate 'Instantiation' data and API bits of SLocEntry to 'Expansion'
etc. With this I think essentially all of the SourceManager APIs are
converted. Comments and random other bits of cleanup should be all thats
left.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136057 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 04:56:51 +00:00
Chandler Carruth 78df836808 Convert InstantiationInfo and much of the related code to ExpansionInfo
and various other 'expansion' based terms. I've tried to reformat where
appropriate and catch as many references in comments but I'm going to do
several more passes. Also I've tried to expand parameter names to be
more clear where appropriate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136056 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-26 04:41:47 +00:00
Chandler Carruth bf340e4523 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
2011-07-26 03:03:05 +00:00
Jonathan D. Turner 5d6d89fef8 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
2011-07-25 20:32:21 +00:00
Chris Lattner 5f9e272e63 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
2011-07-23 10:55:15 +00:00
Jonathan D. Turner 9461fccd05 Remove prepending of '$' to module names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135775 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 17:25:03 +00:00
Douglas Gregor 832d620b4a 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
2011-07-22 16:35:34 +00:00
Douglas Gregor 72a9ae1855 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
2011-07-22 16:00:58 +00:00
Douglas Gregor 8f1231b70c 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
2011-07-22 06:10:01 +00:00
Douglas Gregor 4947e25dd9 Fix an embarrassing bug in relocatable PCH support, where we were
passing a temporary const char* down as the "isysroot" parameter and
then accessing it later. Fixes <rdar://problem/9035180>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135749 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 06:03:18 +00:00
Douglas Gregor 393f249399 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
2011-07-22 00:38:23 +00:00
Douglas Gregor f5bb9ae23d 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
2011-07-21 23:29:11 +00:00
Douglas Gregor 409448c832 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
2011-07-21 22:35:25 +00:00
Jonathan D. Turner 1da901467f 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
2011-07-21 21:15:19 +00:00
Douglas Gregor 23d7df5ce3 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
2011-07-21 19:50:14 +00:00
Douglas Gregor 0cdd798dba 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
2011-07-21 18:46:38 +00:00
Douglas Gregor 4c30bb148b 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
2011-07-21 00:47:40 +00:00
Jonathan D. Turner e9b76c11a8 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
2011-07-20 21:31:32 +00:00
Douglas Gregor 14ad03b6f4 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
2011-07-20 01:29:15 +00:00
Douglas Gregor 96958cbe6f 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
2011-07-20 01:10:58 +00:00
Douglas Gregor 67268d0238 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
2011-07-20 00:59:32 +00:00
Douglas Gregor 96e973f2be 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
2011-07-20 00:27:43 +00:00
Douglas Gregor f62d43d2af 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
2011-07-19 16:10:42 +00:00
Douglas Gregor ba6ffaf21e 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
recursion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135306 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 21:46:17 +00:00
Chandler Carruth f70d12dbd4 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
2011-07-15 07:25:21 +00:00
John McCall 7110fd6c32 Add serialization support for SubstNonTypeTemplateParmExpr.
Also add the missing serialization support for SEHTryStmt,
SEHFinallyStmt, and SEHExceptStmt, and fix and finish the
serialization support for AsTypeExpr.  In addition, change
the code so that it will no longer link if a Stmt subclass
is missing serialization support.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135258 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 07:00:14 +00:00
Chris Lattner 1e5f83ba51 StringMap::first() is about to start returning a StringRef, adapt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135166 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-14 18:24:21 +00:00
Chandler Carruth 9e5bb85ac8 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
2011-07-14 08:20:46 +00:00
Douglas Gregor bca01b4685 Properly implement the scope restriction on the NRVO for
throw-expressions, such that we don't consider the NRVO when the
non-volatile automatic object comes from outside the innermost try
scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were
incorrect but it didn't matter because IR generation doesn't actually
apply the NRVO here. In C++0x, however, we were moving from an object
when in fact we should have copied from it. Fixes PR10142 /
<rdar://problem/9714312>.





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134548 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-06 22:04:06 +00:00
Douglas Gregor 561f81243f Introduce the notion of instantiation dependence into Clang's AST. A
type/expression/template argument/etc. is instantiation-dependent if
it somehow involves a template parameter, even if it doesn't meet the
requirements for the more common kinds of dependence (dependent type,
type-dependent expression, value-dependent expression).

When we see an instantiation-dependent type, we know we always need to
perform substitution into that instantiation-dependent type. This
keeps us from short-circuiting evaluation in places where we
shouldn't, and lets us properly implement C++0x [temp.type]p2.

In theory, this would also allow us to properly mangle
instantiation-dependent-but-not-dependent decltype types per the
Itanium C++ ABI, but we aren't quite there because we still mangle
based on the canonical type in cases like, e.g.,

  template<unsigned> struct A { };
  template<typename T>
    void f(A<sizeof(sizeof(decltype(T() + T())))>) { }
  template void f<int>(A<sizeof(sizeof(int))>);

and therefore get the wrong answer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134225 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 01:22:09 +00:00
John McCall 146060435c 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
2011-06-30 08:33:18 +00:00
Douglas Gregor d8bba9c152 Add support for C++ namespace-aware typo correction, e.g., correcting
vector<int>

to

  std::vector<int>

Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes
PR5776/<rdar://problem/8652971>.

Thanks Kaelyn!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134007 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 16:20:02 +00:00
Douglas Gregor 03e8003051 Introduce a new AST node describing reference binding to temporaries.
MaterializeTemporaryExpr captures a reference binding to a temporary
value, making explicit that the temporary value (a prvalue) needs to
be materialized into memory so that its address can be used. The
intended AST invariant here is that a reference will always bind to a
glvalue, and MaterializeTemporaryExpr will be used to convert prvalues
into glvalues for that binding to happen. For example, given

  const int& r = 1.0;

The initializer of "r" will be a MaterializeTemporaryExpr whose
subexpression is an implicit conversion from the double literal "1.0"
to an integer value. 

IR generation benefits most from this new node, since it was
previously guessing (badly) when to materialize temporaries for the
purposes of reference binding. There are likely more refactoring and
cleanups we could perform there, but the introduction of
MaterializeTemporaryExpr fixes PR9565, a case where IR generation
would effectively bind a const reference directly to a bitfield in a
struct. Addresses <rdar://problem/9552231>.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133521 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 17:03:29 +00:00
Jay Foad 65aa688581 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
2011-06-21 15:13:30 +00:00
John McCall 7acddacc92 Objective-C fast enumeration loop variables are not retained in ARC, but
they should still be officially __strong for the purposes of errors, 
block capture, etc.  Make a new bit on variables, isARCPseudoStrong(),
and set this for 'self' and these enumeration-loop variables.  Change
the code that was looking for the old patterns to look for this bit,
and change IR generation to find this bit and treat the resulting         
variable as __unsafe_unretained for the purposes of init/destroy in
the two places it can come up.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133243 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:42:21 +00:00
John McCall f85e193739 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
2011-06-15 23:02:42 +00:00
Douglas Gregor 74da19fc3a 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
2011-06-14 23:20:43 +00:00
Douglas Gregor 4c4efee6d3 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
2011-06-13 16:42:53 +00:00
Richard Smith 7a614d8380 Implement support for C++11 in-class initialization of non-static data members.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132878 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-11 17:19:42 +00:00
Douglas Gregor 926df6cfab 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];
         ^       ~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1:
note: 
      instance method 'init' is assumed to return an instance of its
      receiver
      type ('NSArray *')
- (id)init;
^

It also means that we get decent type inference when writing code in
Objective-C++0x:

  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
2011-06-11 01:09:30 +00:00
Jonathan D. Turner 8e1b80c692 Touchup to comments that weren't quite in sync with code
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132679 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-06 16:22:39 +00:00
Tanya Lattner 61eee0ca33 Add support for builtin astype:
__builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types.
Added test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132612 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 00:47:47 +00:00
Jonathan D. Turner 953c564288 Improvements to abbreviations for PCH which add support for EnumDecl, ObjCIvarDecl, TypedefDecl, VarDecl and FieldDecl and improve support for ParmVarDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132604 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 23:11:16 +00:00
Jonathan D. Turner 2808757182 Test of commit access.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132596 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 21:46:44 +00:00
Douglas Gregor a72d8c4556 Introduce additional abbreviations into the AST writer for
DeclRefExprs, IntegerLiterals, and others, reducing Cocoa PCH size by
~1% and C++ header size by ~2.5%. From Jonathan Turner!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132528 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 02:27:19 +00:00
Argyrios Kyrtzidis 4cdb0e2a2e [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!
(rdar://9530587)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132481 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-02 20:01:46 +00:00
Argyrios Kyrtzidis b68ffb107a [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
2011-06-01 05:43:53 +00:00
Sean Hunt ca63c20034 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
2011-05-24 22:41:36 +00:00
Douglas Gregor 2bb110125e When determining whether we can make a declaration into a global
constant, also consider whether it's a class type that has any mutable
fields. If so, it can't be a global constant.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131276 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-13 01:05:07 +00:00
Sean Hunt 2be7e90b81 Implement defaulting of destructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131260 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-12 22:46:29 +00:00
Sean Hunt cdee3fee8c Implement implicit deletion of default constructors.
Yes, I'm aware that the diagnostics are awful.

Tests to follow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131203 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-11 22:34:38 +00:00