summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-05-13 00:00:16 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-05-13 00:00:16 +0000
commit3533397a3aa5a0986f0941323d15142cfe40479d (patch)
tree1a904539940c891d343f010527143fcee9883411
parent66bdfca77a5ecf1abe45b2db20ea2deda610b96b (diff)
downloadbcm5719-llvm-3533397a3aa5a0986f0941323d15142cfe40479d.tar.gz
bcm5719-llvm-3533397a3aa5a0986f0941323d15142cfe40479d.zip
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. llvm-svn: 302969
-rw-r--r--clang/include/clang/Basic/LangOptions.h5
-rw-r--r--clang/lib/AST/DeclBase.cpp4
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
3 files changed, 9 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 20a0e584560..ceaedf58574 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/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/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 97b7465b428..e0c626c585b 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/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/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index cd404c60199..fb3922d5721 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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<Decl>(CurContext)->setHidden(true);
cast<Decl>(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<Decl>(CurContext)->setLocalOwningModule(getCurrentModule());
if (!getCurrentModule())
cast<Decl>(CurContext)->setHidden(false);
OpenPOWER on IntegriCloud