r302969 - Add LangOptions method to query whether we are tracking the owning module for a local declaration.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri May 12 17:00:16 PDT 2017
Author: rsmith
Date: Fri May 12 19:00:16 2017
New Revision: 302969
URL: http://llvm.org/viewvc/llvm-project?rev=302969&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=302969&r1=302968&r2=302969&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Fri May 12 19:00:16 2017
@@ -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;
}
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=302969&r1=302968&r2=302969&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri May 12 19:00:16 2017
@@ -75,7 +75,7 @@ void *Decl::operator new(std::size_t Siz
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() cons
}
bool Decl::hasLocalOwningModuleStorage() const {
- return getASTContext().getLangOpts().ModulesLocalVisibility;
+ return getASTContext().getLangOpts().trackLocalOwningModule();
}
const char *Decl::getDeclKindName() const {
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=302969&r1=302968&r2=302969&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri May 12 19:00:16 2017
@@ -16038,7 +16038,7 @@ void Sema::ActOnModuleBegin(SourceLocati
// 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<Decl>(CurContext)->setHidden(true);
cast<Decl>(CurContext)->setLocalOwningModule(Mod);
}
@@ -16072,7 +16072,7 @@ void Sema::ActOnModuleEnd(SourceLocation
BuildModuleInclude(DirectiveLoc, Mod);
// Any further declarations are in whatever module we returned to.
- if (getLangOpts().ModulesLocalVisibility) {
+ if (getLangOpts().trackLocalOwningModule()) {
cast<Decl>(CurContext)->setLocalOwningModule(getCurrentModule());
if (!getCurrentModule())
cast<Decl>(CurContext)->setHidden(false);
More information about the cfe-commits
mailing list