aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-04-19 05:50:08 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-04-19 05:50:08 +0000
commitc7e606086a8d44c4e84ac3d47289288534c79bc6 (patch)
tree3151eaf97133cc018c81b439e5fa599e7378c5cb /lib/AST/Decl.cpp
parent1c7eed7e6ea2b357aa94581a90018ddbdcb41cbf (diff)
In mergeVisibility, if we already have an explicit visibility, keep it.
This fixes the included testcase and lets us simplify the code a bit. It does require using mergeWithMin when merging class information to its members. Expand the comments to explain why that works. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155103 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index f4c0aa3c6b..8649ba2696 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -490,8 +490,10 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, LVFlags F) {
if (llvm::Optional<Visibility> Vis = D->getExplicitVisibility())
LV.mergeVisibility(*Vis, true);
}
- // Ignore both global visibility and attributes when computing our
- // parent's visibility if we already have an explicit one.
+
+ // If this class member has an explicit visibility attribute, the only
+ // thing that can change its visibility is the template arguments, so
+ // only look for them when processing the the class.
LVFlags ClassF = LV.visibilityExplicit() ?
LVFlags::CreateOnlyDeclLinkage() : F;
@@ -523,9 +525,12 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, LVFlags F) {
LV.mergeVisibility(HiddenVisibility, true);
}
- // Class members only have linkage if their class has external
- // linkage.
- LV.merge(getLVForDecl(cast<RecordDecl>(D->getDeclContext()), ClassF));
+ // If this member has an visibility attribute, ClassF will exclude
+ // attributes on the class or command line options, keeping only information
+ // about the template instantiation. If the member has no visibility
+ // attributes, mergeWithMin behaves like merge, so in both cases mergeWithMin
+ // produces the desired result.
+ LV.mergeWithMin(getLVForDecl(cast<RecordDecl>(D->getDeclContext()), ClassF));
if (!isExternalLinkage(LV.linkage()))
return LinkageInfo::none();
@@ -579,8 +584,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, LVFlags F) {
LinkageInfo TypeLV = getLVForType(VD->getType());
if (TypeLV.linkage() != ExternalLinkage)
LV.mergeLinkage(UniqueExternalLinkage);
- if (!LV.visibilityExplicit())
- LV.mergeVisibility(TypeLV);
+ LV.mergeVisibility(TypeLV);
}
return LV;