diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-16 02:10:38 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-16 02:10:38 +0000 |
commit | 797105a45a838a7c1cefd05dec3fd0cbaeb0a215 (patch) | |
tree | f0361e639ff11efe45c97b6f0a7333a4ed69fae7 /lib/AST/Decl.cpp | |
parent | 7d24e289bea2accaaed79c6ca3e5cdd0c204ddc1 (diff) |
Fix the visibility of instantiations of static data members.
Fixes pr12835.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 21405d223d..d31cf0f010 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -633,9 +633,19 @@ LinkageInfo NamedDecl::getLinkageAndVisibility() const { llvm::Optional<Visibility> NamedDecl::getExplicitVisibility() const { // Use the most recent declaration of a variable. - if (const VarDecl *var = dyn_cast<VarDecl>(this)) - return getVisibilityOf(var->getMostRecentDecl()); + if (const VarDecl *Var = dyn_cast<VarDecl>(this)) { + if (llvm::Optional<Visibility> V = + getVisibilityOf(Var->getMostRecentDecl())) + return V; + + if (Var->isStaticDataMember()) { + VarDecl *InstantiatedFrom = Var->getInstantiatedFromStaticDataMember(); + if (InstantiatedFrom) + return getVisibilityOf(InstantiatedFrom); + } + return llvm::Optional<Visibility>(); + } // Use the most recent declaration of a function, and also handle // function template specializations. if (const FunctionDecl *fn = dyn_cast<FunctionDecl>(this)) { |