summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-02-05 23:37:13 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-02-05 23:37:13 +0000
commit520a37f52ff159636e25eb30178aa14f0499bddc (patch)
tree577816c71a89f0fbd74d65d5c04071f9d39635e7 /clang/lib/Serialization/ASTReaderDecl.cpp
parent53ae55a207ad3c9b94297bcc2682db1ec0f8b43b (diff)
downloadbcm5719-llvm-520a37f52ff159636e25eb30178aa14f0499bddc.tar.gz
bcm5719-llvm-520a37f52ff159636e25eb30178aa14f0499bddc.zip
[modules] Fix handling of initializers for templated global variables.
For global variables with unordered initialization that are instantiated within a module, we previously did not emit the global (or its initializer) at all unless it was used in the importing translation unit (and sometimes not even then!), leading to misbehavior and link errors. We now emit the initializer for an instantiated global variable with unordered initialization with side-effects in a module into every translation unit that imports the module. This is unfortunate, but mostly matches the behavior of a non-modular compilation and seems to be the best that we can reasonably do. llvm-svn: 353240
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 1c56cdbf948..6d02f4d1121 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2779,7 +2779,7 @@ static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) {
// An ImportDecl or VarDecl imported from a module map module will get
// emitted when we import the relevant module.
- if (isa<ImportDecl>(D) || isa<VarDecl>(D)) {
+ if (isPartOfPerModuleInitializer(D)) {
auto *M = D->getImportedOwningModule();
if (M && M->Kind == Module::ModuleMapModule &&
Ctx.DeclMustBeEmitted(D))
OpenPOWER on IntegriCloud