Only apply -fvisibility-inlines-hidden to definitions. Apparently

isInlined() just gives meaningless results for non-definitions.

Fixes rdar://problem/8614470

llvm-svn: 117887
This commit is contained in:
John McCall 2010-11-01 01:29:57 +00:00
parent 25d9c7fa2e
commit e6e622e789
2 changed files with 24 additions and 3 deletions

View File

@ -459,9 +459,15 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D,
// about whether containing classes have visibility attributes,
// and that's intentional.
if (TSK != TSK_ExplicitInstantiationDeclaration &&
ConsiderGlobalVisibility && MD->isInlined() &&
MD->getASTContext().getLangOptions().InlineVisibilityHidden)
LV.setVisibility(HiddenVisibility);
ConsiderGlobalVisibility &&
MD->getASTContext().getLangOptions().InlineVisibilityHidden) {
// InlineVisibilityHidden only applies to definitions, and
// isInlined() only gives meaningful answers on definitions
// anyway.
const FunctionDecl *Def = 0;
if (MD->hasBody(Def) && Def->isInlined())
LV.setVisibility(HiddenVisibility);
}
// Note that in contrast to basically every other situation, we
// *do* apply -fvisibility to method declarations.

View File

@ -64,3 +64,18 @@ void use(X0 *x0, X1<int> *x1, X2 *x2, X1<float> *x3) {
// CHECK: define available_externally void @_ZN2X1IfE2f2Ev
x3->f2();
}
// rdar://problem/8614470
namespace test1 {
struct __attribute__((visibility("default"))) A {
inline void foo();
~A();
};
void test() {
A a;
a.foo();
}
// CHECK: declare void @_ZN5test11A3fooEv
// CHECK: declare void @_ZN5test11AD1Ev
}