From: Richard Smith Date: Sat, 13 May 2017 00:00:16 +0000 (+0000) Subject: Add LangOptions method to query whether we are tracking the owning module for a local... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab2094bec03b5d0c32f484bd3730e1f47846e3e8;p=clang Add LangOptions method to query whether we are tracking the owning module for a local declaration. In preparation for expanding this behavior to cover additional cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302969 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index 20a0e58456..ceaedf5857 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -166,6 +166,11 @@ public: return getCompilingModule() != CMK_None; } + /// Do we need to track the owning module for a local declaration? + bool trackLocalOwningModule() const { + return ModulesLocalVisibility; + } + bool isSignedOverflowDefined() const { return getSignedOverflowBehavior() == SOB_Defined; } diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 97b7465b42..e0c626c585 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -75,7 +75,7 @@ void *Decl::operator new(std::size_t Size, const ASTContext &Ctx, assert(!Parent || &Parent->getParentASTContext() == &Ctx); // With local visibility enabled, we track the owning module even for local // declarations. - if (Ctx.getLangOpts().ModulesLocalVisibility) { + if (Ctx.getLangOpts().trackLocalOwningModule()) { // Ensure required alignment of the resulting object by adding extra // padding at the start if required. size_t ExtraAlign = @@ -96,7 +96,7 @@ Module *Decl::getOwningModuleSlow() const { } bool Decl::hasLocalOwningModuleStorage() const { - return getASTContext().getLangOpts().ModulesLocalVisibility; + return getASTContext().getLangOpts().trackLocalOwningModule(); } const char *Decl::getDeclKindName() const { diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index cd404c6019..fb3922d572 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -16038,7 +16038,7 @@ void Sema::ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod) { // 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) { + if (getLangOpts().trackLocalOwningModule()) { cast(CurContext)->setHidden(true); cast(CurContext)->setLocalOwningModule(Mod); } @@ -16072,7 +16072,7 @@ void Sema::ActOnModuleEnd(SourceLocation EomLoc, Module *Mod) { BuildModuleInclude(DirectiveLoc, Mod); // Any further declarations are in whatever module we returned to. - if (getLangOpts().ModulesLocalVisibility) { + if (getLangOpts().trackLocalOwningModule()) { cast(CurContext)->setLocalOwningModule(getCurrentModule()); if (!getCurrentModule()) cast(CurContext)->setHidden(false);