summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-05-12 23:27:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-05-12 23:27:00 +0000
commitfc8c57cc5ba561e5d12794399d15aae35929b56d (patch)
tree8b6066fb88bd29ca847706857a674163385a196d /clang/lib/AST/DeclBase.cpp
parent2a735421d1aace9d64c4ee7adc1f905974311db3 (diff)
downloadbcm5719-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/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 5c2c9cbd018..97b7465b428 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -83,7 +83,9 @@ void *Decl::operator new(std::size_t Size, const ASTContext &Ctx,
char *Buffer = reinterpret_cast<char *>(
::operator new(ExtraAlign + sizeof(Module *) + Size + Extra, Ctx));
Buffer += ExtraAlign;
- return new (Buffer) Module*(nullptr) + 1;
+ auto *ParentModule =
+ Parent ? cast<Decl>(Parent)->getOwningModule() : nullptr;
+ return new (Buffer) Module*(ParentModule) + 1;
}
return ::operator new(Size + Extra, Ctx);
}
@@ -273,6 +275,11 @@ void Decl::setLexicalDeclContext(DeclContext *DC) {
getMultipleDC()->LexicalDC = DC;
}
Hidden = cast<Decl>(DC)->Hidden;
+ if (Hidden && !isFromASTFile()) {
+ assert(hasLocalOwningModuleStorage() &&
+ "hidden local declaration without local submodule visibility?");
+ setLocalOwningModule(cast<Decl>(DC)->getOwningModule());
+ }
}
void Decl::setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC,
OpenPOWER on IntegriCloud