Commit Graph

424 Commits

Author SHA1 Message Date
Richard Smith e842a47452 [modules] Initial support for explicitly loading .pcm files.
Implicit module builds are not well-suited to a lot of build systems. In
particular, they fare badly in distributed build systems, and they lead to
build artifacts that are not tracked as part of the usual dependency management
process. This change allows explicitly-built module files (which are already
supported through the -emit-module flag) to be explicitly loaded into a build,
allowing build systems to opt to manage module builds and dependencies
themselves.

This is only the first step in supporting such configurations, and it should
be considered experimental and subject to change or removal for now.

llvm-svn: 220359
2014-10-22 02:05:46 +00:00
Richard Smith 32952e1e42 [modules] Merging for class-scope using-declarations.
llvm-svn: 219657
2014-10-14 02:00:47 +00:00
Richard Smith 337f7c9716 [modules] Delay loading the field declared with an anonymous tag declaration
until after we've had a chance to merge that tag.

llvm-svn: 219539
2014-10-10 22:37:41 +00:00
John McCall c90c1498f0 Change how we distinguish bitfield widths, in-class
initializers, and captured VLA types so that we can
answer questions like "is this a bit-field" without
looking at the enclosing DeclContext.  NFC.

llvm-svn: 219522
2014-10-10 18:44:34 +00:00
Richard Smith f463436d9c [modules] Make NamespaceAliasDecl redeclarable, as it should be. This fixes
merging of namespace aliases across modules and improves source fidelity.
Incidentally also fixes PR20816.

llvm-svn: 217103
2014-09-03 23:11:22 +00:00
Richard Smith 70d5850955 [modules] Fix deserialization cycle when loading a tag declaration with a typedef name for linkage purposes. When loading the type, delay loading its typedef until we've finished loading and merging the type. In its place, save out the name of the typedef, which we need for merging purposes.
llvm-svn: 216806
2014-08-30 00:04:23 +00:00
Alexey Bataev 39c81e2816 [C++11] Support for capturing of variable length arrays in lambda expression.
Differential Revision: http://reviews.llvm.org/D4368

llvm-svn: 216649
2014-08-28 04:28:19 +00:00
Richard Smith d08aeb6b57 [modules] Number anonymous declarations that are lexically within mergeable
contexts, so that we can merge them when we merge the surrounding context.

llvm-svn: 216639
2014-08-28 01:33:39 +00:00
Richard Smith 2c38164737 [modules] Add an assert that we properly manage the IsCompleteDefinition flag
on CXXRecordDecls when merging definitions, and make it pass by not trying to
save and restore this flag across AST serialization/deserialization. For
CXXRecordDecls, we have a separate mechanism to manage this.

llvm-svn: 216633
2014-08-27 23:11:59 +00:00
Richard Smith b1108739e4 [modules] Don't assert when merging virtual functions that override other
functions. Also don't needlessly pull in non-canonical declarations of the
overridden virtual functions.

llvm-svn: 216503
2014-08-26 23:29:11 +00:00
Richard Smith 43ccec8e53 [modules] Track the described template in an alias declaration that is the
pattern of an alias template declaration. Use this to merge alias templates
properly when they're members of class template specializations.

llvm-svn: 216437
2014-08-26 03:52:16 +00:00
Richard Smith 87dacc7922 Fix typo.
llvm-svn: 216417
2014-08-25 23:33:46 +00:00
Richard Smith 88126a25eb [modules] Fix false report of an ODR violation when merging friend
declarations. We can't expect to find them in the canonical definition
of the class, because that's not where they live.

This means we no longer reject real ODR violations with friend declarations,
but we weren't consistently doing so anyway.

llvm-svn: 216369
2014-08-25 02:10:01 +00:00
Richard Smith 88ebade8d9 [modules] When merging a tag declaration that has a typedef name for linkage
purposes, look for other typedefs with that same name and merge into their
named tag declaration if there is one.

llvm-svn: 216312
2014-08-23 01:45:27 +00:00
Ben Langmuir e13fd1c430 Fix the rececl chain for redeclarations of predefined decls
Predefined decls like 'Protocol' in objc are not loaded from AST files,
so we cannot rely on loading the canonical decl to complete the redecl
chain for redeclarations of these decls.  The broken redecl chain was
non-circular, so looping over redecls() would hang.

llvm-svn: 215929
2014-08-18 19:32:45 +00:00
Craig Topper 4dd9b43c8d Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size.
llvm-svn: 215869
2014-08-17 23:49:53 +00:00
Richard Smith 462b6fc6dc [modules] Turn off a broken optimization: we need to pick up implicit special
members from all redefinitions of a class that have them, in case the special
member is defined in one module but only declared in another.

llvm-svn: 215675
2014-08-14 20:30:52 +00:00
Richard Smith 72544f875b [modules] Don't assert if the same imported class template specialization
declaration has its definition instantiated in two sibling modules and they use
a partial specialization.

llvm-svn: 215616
2014-08-14 03:30:27 +00:00
Richard Smith bb853c79c0 [modules] When performing a lookup into a namespace, ensure that any later
redefinitions of that namespace have already been loaded. When writing out the
names in a namespace, if we see a name that is locally declared and had
imported declarations merged on top of it, export the local declaration as the
lookup result, because it will be the most recent declaration of that entity in
the redeclaration chain of an importer of the module.

llvm-svn: 215518
2014-08-13 01:23:33 +00:00
Richard Smith d6db68c181 [modules] Don't defer performing updates if we have incomplete redecl chains.
Instead, perform them carefully immediately.

llvm-svn: 215147
2014-08-07 20:58:41 +00:00
Richard Smith 4d2357948b [modules] When emitting an update record containing the body of a destructor,
also emit the updated 'operator delete' looked up for that destructor. Switch
from UpdateDecl to an actual update record when this happens due to implicitly
defining a special member function and unify this code path and the one for
instantiating a function definition.

llvm-svn: 215132
2014-08-07 18:53:08 +00:00
Richard Smith 46bb581a03 [modules] Remove IRGen special case for emitting implicit special members if
they're somehow missing a body. Looks like this was left behind when the loop
was generalized, and it's not been problematic before because without modules,
a used, implicit special member function declaration must be a definition.

This was resulting in us trying to emit a constructor declaration rather than
a definition, and producing a constructor missing its member initializers.

llvm-svn: 214473
2014-08-01 01:56:39 +00:00
Richard Smith 24d166ca77 Fix buildbot: work around missing GCC C++11 feature.
llvm-svn: 214459
2014-07-31 23:52:38 +00:00
Richard Smith 6de7a24782 [modules] Maintain an AST invariant across module load/save: if any declaration
of a function has a resolved exception specification, then all declarations of
the function do.

We should probably improve the AST representation to make this implicit (perhaps
only store the exception specification on the canonical declaration), but this
fixes things for now.

The testcase for this (which used to assert) also exposes the actual bug I was
trying to reduce here: we sometimes fail to emit the body of an imported
special member function definition. Fix for that to follow.

llvm-svn: 214458
2014-07-31 23:46:44 +00:00
Richard Smith 8acb4280c5 Factor out exception specification information from
FunctionProtoType::ExtProtoInfo. Most of the users of these fields don't care
about the other ExtProtoInfo bits and just want to talk about the exception
specification.

llvm-svn: 214450
2014-07-31 21:57:55 +00:00
Richard Smith f59b735a80 [modules] PR20475: merging support for alias template declarations.
llvm-svn: 214124
2014-07-28 21:16:37 +00:00
Richard Smith 5e9e56a0a1 [modules] Rearrange and unify the way we determine if we need to pull in
redeclaration chains when pulling in a declaration. We need the redecl chain
unless we know some other declaration will trigger it to be pulled in; that
happens if our originally-canonical declaration had all the knowledge that
we have (and isn't us).

llvm-svn: 213043
2014-07-15 03:37:06 +00:00
Richard Smith 547864d26a [modules] When merging a class template, also merge the definition of its pattern.
llvm-svn: 212836
2014-07-11 18:22:58 +00:00
Richard Smith dc5523d38f [modules] Don't try to merge template specializations by performing name lookup
into their container; we won't find them there. These things are already being
merged when they're added to their primary template's folding set, so this
merging is redundant (and causes us to reject-valid because we think we've
found an odr violation).

llvm-svn: 212788
2014-07-11 00:20:06 +00:00
Richard Smith a9a1c68a1b Fix an iterator invalidation issue: deserializing a key function can write to
the key functions table. Don't hold references to anything within that table
across such an access.

llvm-svn: 212437
2014-07-07 06:38:20 +00:00
Craig Topper 7e0daca110 Convert some function arguments to use ArrayRef.
llvm-svn: 211764
2014-06-26 04:58:53 +00:00
Richard Smith 675d279af4 [modules] When we merge redecl chains or mark a decl used with an update
record, mark all subsequent decls as 'used' too, to maintain the AST invariant
that getPreviousDecl()->Used implies this->Used.

llvm-svn: 211050
2014-06-16 20:26:19 +00:00
Richard Smith 195d8ef452 When merging functions across modules (and in particular, instantiations of
member functions), ensure that the redecl chain never transitions from 'inline'
to 'not inline', since that violates an AST invariant.

llvm-svn: 209794
2014-05-29 03:15:31 +00:00
Richard Smith a1406fa513 Recompute the injected class name type for a class template specialization
rather than saving and restoring it.

llvm-svn: 209557
2014-05-23 21:31:59 +00:00
Richard Smith 64c0630585 Avoid allocating extra memory to handle the lazy definition data pointer for
CXXRecordDecls when modules is enabled.

llvm-svn: 209482
2014-05-22 23:19:02 +00:00
Richard Smith df3520581a If a class template specialization from one module has its definition
instantiated in another module, and the instantiation uses a partial
specialization, include the partial specialization and its template arguments
in the update record. We'll need them if someone imports the second module and
tries to instantiate a member of the template.

llvm-svn: 209472
2014-05-22 20:59:29 +00:00
Craig Topper a13603a247 [C++11] Use 'nullptr'. Serialization edition.
llvm-svn: 209392
2014-05-22 05:54:18 +00:00
Richard Smith 851072efb7 If two sibling modules declare the same entity, and we indirectly pull a
declaration of that entity in from one of those modules, keep track of the fact
that we've not completed the redeclaration chain yet so that we can pull the
remaining declarations in from the other module if they're needed.

llvm-svn: 209161
2014-05-19 20:59:20 +00:00
Richard Smith 053f6c6c9e If a declaration is loaded, and then a module import adds a redeclaration, then
ensure that querying the first declaration for its most recent declaration
checks for redeclarations from the imported module.

This works as follows:
 * The 'most recent' pointer on a canonical declaration grows a pointer to the
   external AST source and a generation number (space- and time-optimized for
   the case where there is no external source).
 * Each time the 'most recent' pointer is queried, if it has an external source,
   we check whether it's up to date, and update it if not.
 * The ancillary data stored on the canonical declaration is allocated lazily
   to avoid filling it in for declarations that end up being non-canonical.
   We'll still perform a redundant (ASTContext) allocation if someone asks for
   the most recent declaration from a decl before setPreviousDecl is called,
   but such cases are probably all bugs, and are now easy to find.

Some finessing is still in order here -- in particular, we use a very general
mechanism for handling the DefinitionData pointer on CXXRecordData, and a more
targeted approach would be more compact.

Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was
addressing only a corner of the full problem space here. That's not covered
by this patch.

Early performance benchmarks show that this makes no measurable difference to 
Clang performance without modules enabled (and fixes a major correctness issue
with modules enabled). I'll revert if a full performance comparison shows any
problems.

llvm-svn: 209046
2014-05-16 23:01:30 +00:00
Richard Smith b321ecbdcf Refactor to avoid explicitly listing all the different flavours of redeclarable
declarations, and duplicating code between them.

llvm-svn: 208662
2014-05-13 01:15:00 +00:00
Benjamin Kramer f3ca269839 Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.
Required pulling LambdaExpr::Capture into its own header.
No functionality change.

llvm-svn: 208470
2014-05-10 16:31:55 +00:00
Alexey Bataev 9959db5fa9 [OPENMP] Initial codegen for '#pragma omp parallel'
llvm-svn: 208077
2014-05-06 10:08:46 +00:00
Richard Smith d1c4674603 Defer loading any pending update records until we've finished deserializing.
This fixes a bug where an update record causes us to load an entity that refers
to an entity we've not finished loading yet, resulting in badness.

llvm-svn: 207603
2014-04-30 02:24:17 +00:00
Richard Smith f17fdbd791 When two templates get merged together, also merge their pattern declarations
together. This is extremely hairy, because in general we need to have loaded
both the template and the pattern before we can determine whether either should
be merged, so we temporarily violate the rule that all merging happens before
reading a decl ends, but *only* in the case where a template's pattern is being
loaded while loading the template itself.

In order to accomodate this for class templates, delay loading the injected
class name type for the pattern of the template until after we've loaded the
template itself, if we happen to load the template first.

llvm-svn: 207063
2014-04-24 02:25:27 +00:00
Richard Smith cd45dbc5f2 When a module completes the definition of a class template specialization imported from another module, emit an update record, rather than using the broken decl rewriting mechanism. If multiple modules do this, merge the definitions together, much as we would if they were separate declarations.
llvm-svn: 206680
2014-04-19 03:48:30 +00:00
Richard Smith b45a6f72b6 Add missing serialization code for one of the CXXRecordDecl definition flags.
llvm-svn: 206493
2014-04-17 20:33:01 +00:00
Stephan Tolksdorf a6a0863470 Fix PR18307: Properly (de)serialize inherited constructors and their using declarations
Reviewed in http://llvm-reviews.chandlerc.com/D3102

llvm-svn: 204951
2014-03-27 19:22:19 +00:00
Richard Smith 399a6035e0 Remove redundant and misleading check. This could also lead to painful cyclic
deserialization.

llvm-svn: 204695
2014-03-25 01:22:22 +00:00
Richard Smith 04d05b5fa7 If an update record makes a declaration interesting, pass it to the consumer.
llvm-svn: 204550
2014-03-23 00:27:18 +00:00
Richard Smith d28ac5b998 Emit an update record if we instantiate the definition of a function template
specialization from a module. (This can also happen for function template
specializations in PCHs if they're instantiated eagerly, because they're
constexpr or have a deduced return type.)

llvm-svn: 204547
2014-03-22 23:33:22 +00:00