diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-07-20 19:10:16 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-07-20 19:10:16 +0000 |
commit | dc1f042171d93709952aeaa1c83bf91c0cf8a1be (patch) | |
tree | a504aefcca00d128754cdcfb479bf7cabd423e87 /clang/lib/Sema/SemaLookup.cpp | |
parent | 62ae568bbb9c4d22d341a71d12ab0bc74506476c (diff) | |
download | bcm5719-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.cpp | 5 |
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); } |