diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-04-14 15:21:19 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-04-14 15:21:19 +0000 |
commit | 0aec8ece5248adb718bd7ac800c314a390383eca (patch) | |
tree | 0a7047e8d696c3e018944457ebdd3fa5cab017c9 /clang/lib/AST | |
parent | e2980636697634ff99af77f01a34f890c84ad13d (diff) | |
download | bcm5719-llvm-0aec8ece5248adb718bd7ac800c314a390383eca.tar.gz bcm5719-llvm-0aec8ece5248adb718bd7ac800c314a390383eca.zip |
Consider visibility attributes last, so that they take precedence.
I am working on a cleaner fix, but this gets the case in PR12552 passing.
llvm-svn: 154749
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 399f2e48abe..7d608a3ba87 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -281,27 +281,6 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVFlags F) { LinkageInfo LV; LV.mergeVisibility(Context.getLangOpts().getVisibilityMode()); - if (F.ConsiderVisibilityAttributes) { - if (llvm::Optional<Visibility> Vis = D->getExplicitVisibility()) { - LV.setVisibility(*Vis, true); - F.ConsiderGlobalVisibility = false; - } else { - // If we're declared in a namespace with a visibility attribute, - // use that namespace's visibility, but don't call it explicit. - for (const DeclContext *DC = D->getDeclContext(); - !isa<TranslationUnitDecl>(DC); - DC = DC->getParent()) { - const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC); - if (!ND) continue; - if (llvm::Optional<Visibility> Vis = ND->getExplicitVisibility()) { - LV.setVisibility(*Vis, true); - F.ConsiderGlobalVisibility = false; - break; - } - } - } - } - // C++ [basic.link]p4: // A name having namespace scope has external linkage if it is the @@ -478,6 +457,27 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVFlags F) { return LinkageInfo::none(); } + if (F.ConsiderVisibilityAttributes) { + if (llvm::Optional<Visibility> Vis = D->getExplicitVisibility()) { + LV.setVisibility(*Vis, true); + F.ConsiderGlobalVisibility = false; + } else { + // If we're declared in a namespace with a visibility attribute, + // use that namespace's visibility, but don't call it explicit. + for (const DeclContext *DC = D->getDeclContext(); + !isa<TranslationUnitDecl>(DC); + DC = DC->getParent()) { + const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC); + if (!ND) continue; + if (llvm::Optional<Visibility> Vis = ND->getExplicitVisibility()) { + LV.setVisibility(*Vis, true); + F.ConsiderGlobalVisibility = false; + break; + } + } + } + } + // If we ended up with non-external linkage, visibility should // always be default. if (LV.linkage() != ExternalLinkage) |