]> granicus.if.org Git - clang/commitdiff
Only apply -fvisibility-inlines-hidden to definitions. Apparently
authorJohn McCall <rjmccall@apple.com>
Mon, 1 Nov 2010 01:29:57 +0000 (01:29 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 1 Nov 2010 01:29:57 +0000 (01:29 +0000)
isInlined() just gives meaningless results for non-definitions.

Fixes rdar://problem/8614470

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117887 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/CodeGenCXX/visibility-inlines-hidden.cpp

index 7469e8b27fb65cb152201143f3c3fb776076d420..5eb9e8501ed76f3307db793a399013a118474dba 100644 (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.
index 69ce256025b3db3f1cd2edd50dcc271b1328d486..7f92be2abff8dcca8cbdd5c773d2826f6004fa07 100644 (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
+}