diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-04-19 05:50:08 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-04-19 05:50:08 +0000 |
| commit | 53cf219367ffa19ba35c75a7f477916429926b1c (patch) | |
| tree | e53366ae674bb8932e32e33159ea6c24598c7e0c /clang/lib | |
| parent | 1280fe62450b482392661771d838232a89896328 (diff) | |
| download | bcm5719-llvm-53cf219367ffa19ba35c75a7f477916429926b1c.tar.gz bcm5719-llvm-53cf219367ffa19ba35c75a7f477916429926b1c.zip | |
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.
llvm-svn: 155103
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index f4c0aa3c6be..8649ba26961 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/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; |

