diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-12 23:27:00 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-12 23:27:00 +0000 |
commit | fc8c57cc5ba561e5d12794399d15aae35929b56d (patch) | |
tree | 8b6066fb88bd29ca847706857a674163385a196d /clang/lib/Sema/SemaDecl.cpp | |
parent | 2a735421d1aace9d64c4ee7adc1f905974311db3 (diff) | |
download | bcm5719-llvm-fc8c57cc5ba561e5d12794399d15aae35929b56d.tar.gz bcm5719-llvm-fc8c57cc5ba561e5d12794399d15aae35929b56d.zip |
[modules] When creating a declaration, cache its owning module immediately
rather than waiting until it's queried.
Currently this is only applied to local submodule visibility mode, as we don't
yet allocate storage for the owning module in non-local-visibility modules
compilations.
llvm-svn: 302965
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index fb5f56e0523..cd404c60199 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -16034,6 +16034,14 @@ void Sema::ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod) { ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules); VisibleModules.setVisible(Mod, DirectiveLoc); + + // The enclosing context is now part of this module. + // FIXME: Consider creating a child DeclContext to hold the entities + // lexically within the module. + if (getLangOpts().ModulesLocalVisibility) { + cast<Decl>(CurContext)->setHidden(true); + cast<Decl>(CurContext)->setLocalOwningModule(Mod); + } } void Sema::ActOnModuleEnd(SourceLocation EomLoc, Module *Mod) { @@ -16062,6 +16070,13 @@ void Sema::ActOnModuleEnd(SourceLocation EomLoc, Module *Mod) { DirectiveLoc = EomLoc; } BuildModuleInclude(DirectiveLoc, Mod); + + // Any further declarations are in whatever module we returned to. + if (getLangOpts().ModulesLocalVisibility) { + cast<Decl>(CurContext)->setLocalOwningModule(getCurrentModule()); + if (!getCurrentModule()) + cast<Decl>(CurContext)->setHidden(false); + } } void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc, |