diff options
| author | Hiroshi Inoue <inouehrs@jp.ibm.com> | 2018-08-22 05:43:27 +0000 |
|---|---|---|
| committer | Hiroshi Inoue <inouehrs@jp.ibm.com> | 2018-08-22 05:43:27 +0000 |
| commit | 03ff37ddabeb066d5f7915b3cfb89612c7fdb7eb (patch) | |
| tree | 2a05d2322b4f656b7ac16f4b4283fbd345cbf9c2 /clang/lib | |
| parent | 934e9a3976db9d3535c9443e8dbbf96eca06c9a7 (diff) | |
| download | bcm5719-llvm-03ff37ddabeb066d5f7915b3cfb89612c7fdb7eb.tar.gz bcm5719-llvm-03ff37ddabeb066d5f7915b3cfb89612c7fdb7eb.zip | |
[AST] correct the behavior of -fvisibility-inlines-hidden option (don't make static local variables hidden)
The command line option -fvisibility-inlines-hidden makes inlined method hidden, but it is expected not to affect the visibility of static local variables in the function.
However, Clang makes the static local variables in the function also hidden as reported in PR37595. This problem causes LLVM bootstarp failure on Fedora 28 if configured with -DBUILD_SHARED_LIBS=ON.
This patch makes the behavior of -fvisibility-inlines-hidden option to be consistent with that of gcc; the option does not change the visibility of the static local variables if the containing function does not associated with explicit visibility attribute and becomes hidden due to this option.
Differential Revision: https://reviews.llvm.org/D50968
llvm-svn: 340386
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index b6d35f4260c..272e49a7997 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1262,6 +1262,16 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D, !isTemplateInstantiation(FD->getTemplateSpecializationKind())) return LinkageInfo::none(); + // If a function is hidden by -fvisibility-inlines-hidden option and + // is not explicitly attributed as a hidden function, + // we should not make static local variables in the function hidden. + if (isa<VarDecl>(D) && useInlineVisibilityHidden(FD) && + !(!hasExplicitVisibilityAlready(computation) && + getExplicitVisibility(FD, computation))) { + assert(cast<VarDecl>(D)->isStaticLocal()); + return LinkageInfo(VisibleNoLinkage, DefaultVisibility, false); + } + LV = getLVForDecl(FD, computation); } if (!isExternallyVisible(LV.getLinkage())) |

