summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-08-24 03:38:11 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-08-24 03:38:11 +0000
commit5196a17d3c3e8d9ac3f96800eb803edd0348e995 (patch)
treede70d22ca8cdddb62814d30cf373ec850a21d909 /clang/lib/Sema/SemaLookup.cpp
parent79bf92055219324f3777a71faedfb2ccdd8f9599 (diff)
downloadbcm5719-llvm-5196a17d3c3e8d9ac3f96800eb803edd0348e995.tar.gz
bcm5719-llvm-5196a17d3c3e8d9ac3f96800eb803edd0348e995.zip
[modules] If local submodule visibility is disabled, don't bother checking
whether the owning module of a hidden declaration is visible -- it can't be. llvm-svn: 245822
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 1c6256eb917..dc23c13fbb3 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -1410,22 +1410,22 @@ bool Sema::hasVisibleDefaultArgument(const NamedDecl *D,
/// your module can see, including those later on in your module).
bool LookupResult::isVisibleSlow(Sema &SemaRef, NamedDecl *D) {
assert(D->isHidden() && "should not call this: not in slow case");
- Module *DeclModule = SemaRef.getOwningModule(D);
- if (!DeclModule) {
- // getOwningModule() may have decided the declaration should not be hidden.
- assert(!D->isHidden() && "hidden decl not from a module");
- return true;
- }
-
- // If the owning module is visible, and the decl is not module private,
- // then the decl is visible too. (Module private is ignored within the same
- // top-level module.)
- if (!D->isFromASTFile() || !D->isModulePrivate()) {
- if (SemaRef.isModuleVisible(DeclModule))
+ Module *DeclModule = nullptr;
+
+ if (SemaRef.getLangOpts().ModulesLocalVisibility) {
+ DeclModule = SemaRef.getOwningModule(D);
+ if (!DeclModule) {
+ // getOwningModule() may have decided the declaration should not be hidden.
+ assert(!D->isHidden() && "hidden decl not from a module");
return true;
- // Also check merged definitions.
- if (SemaRef.getLangOpts().ModulesLocalVisibility &&
- SemaRef.hasVisibleMergedDefinition(D))
+ }
+
+ // If the owning module is visible, and the decl is not module private,
+ // then the decl is visible too. (Module private is ignored within the same
+ // top-level module.)
+ if ((!D->isFromASTFile() || !D->isModulePrivate()) &&
+ (SemaRef.isModuleVisible(DeclModule) ||
+ SemaRef.hasVisibleMergedDefinition(D)))
return true;
}
@@ -1457,6 +1457,11 @@ bool LookupResult::isVisibleSlow(Sema &SemaRef, NamedDecl *D) {
if (LookupModules.empty())
return false;
+ if (!DeclModule) {
+ DeclModule = SemaRef.getOwningModule(D);
+ assert(DeclModule && "hidden decl not from a module");
+ }
+
// If our lookup set contains the decl's module, it's visible.
if (LookupModules.count(DeclModule))
return true;
OpenPOWER on IntegriCloud