[llvm-branch-commits] [cfe-branch] r117913 - in /cfe/branches/Apple/whitney: lib/AST/Decl.cpp test/CodeGenCXX/visibility-inlines-hidden.cpp

Daniel Dunbar daniel at zuster.org
Mon Nov 1 08:09:38 PDT 2010


Author: ddunbar
Date: Mon Nov  1 10:09:38 2010
New Revision: 117913

URL: http://llvm.org/viewvc/llvm-project?rev=117913&view=rev
Log:
Merge r117887:
--
Author: John McCall <rjmccall at apple.com>
Date:   Mon Nov 1 01:29:57 2010 +0000

    Only apply -fvisibility-inlines-hidden to definitions.  Apparently
    isInlined() just gives meaningless results for non-definitions.

    Fixes rdar://problem/8614470

Modified:
    cfe/branches/Apple/whitney/lib/AST/Decl.cpp
    cfe/branches/Apple/whitney/test/CodeGenCXX/visibility-inlines-hidden.cpp

Modified: cfe/branches/Apple/whitney/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/AST/Decl.cpp?rev=117913&r1=117912&r2=117913&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/AST/Decl.cpp (original)
+++ cfe/branches/Apple/whitney/lib/AST/Decl.cpp Mon Nov  1 10:09:38 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/branches/Apple/whitney/test/CodeGenCXX/visibility-inlines-hidden.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGenCXX/visibility-inlines-hidden.cpp?rev=117913&r1=117912&r2=117913&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGenCXX/visibility-inlines-hidden.cpp (original)
+++ cfe/branches/Apple/whitney/test/CodeGenCXX/visibility-inlines-hidden.cpp Mon Nov  1 10:09:38 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 llvm-branch-commits mailing list