summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-06-09 00:35:49 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-06-09 00:35:49 +0000
commit87bb56984427bdc6cb9c951f06deceb5f8e3f795 (patch)
tree25f41d4fa70be21b481f6b0437b6cb1fe9003fff /clang/lib/Sema/SemaLookup.cpp
parent8b643559d46a03cba2617d3d60aa89f257ca0357 (diff)
downloadbcm5719-llvm-87bb56984427bdc6cb9c951f06deceb5f8e3f795.tar.gz
bcm5719-llvm-87bb56984427bdc6cb9c951f06deceb5f8e3f795.zip
[modules] Fix some visibility issues with default template arguments.
There are still problems here, but this is a better starting point. The main part of the change is: when doing a lookup that would accept visible or hidden declarations, prefer to produce the latest visible declaration if there are any visible declarations, rather than always producing the latest declaration. Thus, when we inherit default arguments (and other properties) from a previous declaration, we inherit them from the previous visible declaration; if the previous declaration is hidden, we already suppress inheritance of default arguments. There are a couple of other changes here that fix latent bugs exposed by this change. llvm-svn: 239371
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 2600e8e44d6..d0a55b57c61 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -1180,6 +1180,16 @@ Module *Sema::getOwningModule(Decl *Entity) {
assert(!Entity->isFromASTFile() &&
"hidden entity from AST file has no owning module");
+ if (!getLangOpts().ModulesLocalVisibility) {
+ // If we're not tracking visibility locally, the only way a declaration
+ // can be hidden and local is if it's hidden because it's parent is (for
+ // instance, maybe this is a lazily-declared special member of an imported
+ // class).
+ auto *Parent = cast<NamedDecl>(Entity->getDeclContext());
+ assert(Parent->isHidden() && "unexpectedly hidden decl");
+ return getOwningModule(Parent);
+ }
+
// It's local and hidden; grab or compute its owning module.
M = Entity->getLocalOwningModule();
if (M)
@@ -1218,9 +1228,11 @@ Module *Sema::getOwningModule(Decl *Entity) {
}
void Sema::makeMergedDefinitionVisible(NamedDecl *ND, SourceLocation Loc) {
- auto *M = PP.getModuleContainingLocation(Loc);
- assert(M && "hidden definition not in any module");
- Context.mergeDefinitionIntoModule(ND, M);
+ if (auto *M = PP.getModuleContainingLocation(Loc))
+ Context.mergeDefinitionIntoModule(ND, M);
+ else
+ // We're not building a module; just make the definition visible.
+ ND->setHidden(false);
}
/// \brief Find the module in which the given declaration was defined.
OpenPOWER on IntegriCloud