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/AST | |
| 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/AST')
| -rw-r--r-- | clang/lib/AST/ASTDumper.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/AST/DeclBase.cpp | 9 |
3 files changed, 12 insertions, 7 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp index ef491ab06f8..d89be0d9e6f 100644 --- a/clang/lib/AST/ASTDumper.cpp +++ b/clang/lib/AST/ASTDumper.cpp @@ -1038,10 +1038,10 @@ void ASTDumper::dumpDecl(const Decl *D) { dumpSourceRange(D->getSourceRange()); OS << ' '; dumpLocation(D->getLocation()); - if (Module *M = D->getImportedOwningModule()) + if (D->isFromASTFile()) + OS << " imported"; + if (Module *M = D->getOwningModule()) OS << " in " << M->getFullModuleName(); - else if (Module *M = D->getLocalOwningModule()) - OS << " in (local) " << M->getFullModuleName(); if (auto *ND = dyn_cast<NamedDecl>(D)) for (Module *M : D->getASTContext().getModulesWithMergedDefinition( const_cast<NamedDecl *>(ND))) diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 0f2558e24ba..a1342f477b6 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -47,9 +47,7 @@ bool Decl::isOutOfLine() const { TranslationUnitDecl::TranslationUnitDecl(ASTContext &ctx) : Decl(TranslationUnit, nullptr, SourceLocation()), - DeclContext(TranslationUnit), Ctx(ctx), AnonymousNamespace(nullptr) { - Hidden = Ctx.getLangOpts().ModulesLocalVisibility; -} + DeclContext(TranslationUnit), Ctx(ctx), AnonymousNamespace(nullptr) {} //===----------------------------------------------------------------------===// // NamedDecl Implementation 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, |

