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 | c9a4074665759d11149bd1f7a59def506b9147c6 (patch) | |
tree | 0e39809a71235f5d5a041b025d482d1413e78a5f /lib/AST/DeclBase.cpp | |
parent | 2dac30a6d7668a1de94f2509b6e533e16b3117a7 (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302965 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 5c2c9cbd01..97b7465b42 100644 --- a/lib/AST/DeclBase.cpp +++ b/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, |