summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-05-18 19:34:55 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-05-18 19:34:55 +0000
commitf4f62003f452ff49894fc9fa44b93d7a1b1a8b19 (patch)
treedffe40a25585b81d2ae63318482b62ba632cfb65 /clang/lib/Sema/SemaDecl.cpp
parentaf3b3256270ca41eb0ab5e8d0af1ba2e0d698689 (diff)
downloadbcm5719-llvm-f4f62003f452ff49894fc9fa44b93d7a1b1a8b19.tar.gz
bcm5719-llvm-f4f62003f452ff49894fc9fa44b93d7a1b1a8b19.zip
When we enter a module within a linkage specification, switch the linkage
specification and the TU to the new module. This is necessary to get the module ownership correct for entities that we temporarily hang off the TranslationUnitDecl, such as template parameters and function parameters. llvm-svn: 303373
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ba1e97b33d6..5e937aa6996 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16048,8 +16048,10 @@ void Sema::ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod) {
// FIXME: Consider creating a child DeclContext to hold the entities
// lexically within the module.
if (getLangOpts().trackLocalOwningModule()) {
- cast<Decl>(CurContext)->setHidden(true);
- cast<Decl>(CurContext)->setLocalOwningModule(Mod);
+ for (auto *DC = CurContext; DC; DC = DC->getLexicalParent()) {
+ cast<Decl>(DC)->setHidden(true);
+ cast<Decl>(DC)->setLocalOwningModule(Mod);
+ }
}
}
@@ -16082,9 +16084,13 @@ void Sema::ActOnModuleEnd(SourceLocation EomLoc, Module *Mod) {
// Any further declarations are in whatever module we returned to.
if (getLangOpts().trackLocalOwningModule()) {
- cast<Decl>(CurContext)->setLocalOwningModule(getCurrentModule());
- if (!getCurrentModule())
- cast<Decl>(CurContext)->setHidden(false);
+ // The parser guarantees that this is the same context that we entered
+ // the module within.
+ for (auto *DC = CurContext; DC; DC = DC->getLexicalParent()) {
+ cast<Decl>(DC)->setLocalOwningModule(getCurrentModule());
+ if (!getCurrentModule())
+ cast<Decl>(DC)->setHidden(false);
+ }
}
}
OpenPOWER on IntegriCloud