Author: rsmith Date: Sun Aug 23 22:38:11 2015 New Revision: 245822 URL: http://llvm.org/viewvc/llvm-project?rev=245822&view=rev Log: [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.
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp Modified: cfe/trunk/lib/Sema/SemaLookup.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=245822&r1=245821&r2=245822&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaLookup.cpp (original) +++ cfe/trunk/lib/Sema/SemaLookup.cpp Sun Aug 23 22:38:11 2015 @@ -1410,22 +1410,22 @@ bool Sema::hasVisibleDefaultArgument(con /// 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 &S 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits