[cfe-commits] r117887 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/visibility-inlines-hidden.cpp
John McCall
rjmccall at apple.com
Sun Oct 31 18:29:57 PDT 2010
Author: rjmccall
Date: Sun Oct 31 20:29:57 2010
New Revision: 117887
URL: http://llvm.org/viewvc/llvm-project?rev=117887&view=rev
Log:
Only apply -fvisibility-inlines-hidden to definitions. Apparently
isInlined() just gives meaningless results for non-definitions.
Fixes rdar://problem/8614470
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=117887&r1=117886&r2=117887&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sun Oct 31 20:29:57 2010
@@ -459,9 +459,15 @@
// 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.
Modified: cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp?rev=117887&r1=117886&r2=117887&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp Sun Oct 31 20:29:57 2010
@@ -64,3 +64,18 @@
// 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
+}
More information about the cfe-commits
mailing list