summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-07-20 19:10:16 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-07-20 19:10:16 +0000
commitdc1f042171d93709952aeaa1c83bf91c0cf8a1be (patch)
treea504aefcca00d128754cdcfb479bf7cabd423e87 /clang/lib/Sema/SemaLookup.cpp
parent62ae568bbb9c4d22d341a71d12ab0bc74506476c (diff)
downloadbcm5719-llvm-dc1f042171d93709952aeaa1c83bf91c0cf8a1be.tar.gz
bcm5719-llvm-dc1f042171d93709952aeaa1c83bf91c0cf8a1be.zip
[modules] Don't emit initializers for VarDecls within a module eagerly whenever
we first touch any part of that module. Instead, defer them until the first time that module is (transitively) imported. The initializer step for a module then recursively initializes modules that its own headers imported. For example, this avoids running the <iostream> global initializer in programs that don't actually use iostreams, but do use other parts of the standard library. llvm-svn: 276159
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index a41eef39edf..19df1e30423 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -1367,8 +1367,9 @@ Module *Sema::getOwningModule(Decl *Entity) {
auto &SrcMgr = PP.getSourceManager();
SourceLocation StartLoc =
SrcMgr.getLocForStartOfFile(SrcMgr.getMainFileID());
- auto &TopLevel =
- VisibleModulesStack.empty() ? VisibleModules : VisibleModulesStack[0];
+ auto &TopLevel = ModuleScopes.empty()
+ ? VisibleModules
+ : ModuleScopes[0].OuterVisibleModules;
TopLevel.setVisible(CachedFakeTopLevelModule, StartLoc);
}
OpenPOWER on IntegriCloud