]> granicus.if.org Git - clang/commitdiff
Revert r154749 for now at John McCall's request.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 16 Apr 2012 18:46:26 +0000 (18:46 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 16 Apr 2012 18:46:26 +0000 (18:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154846 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/CodeGenCXX/visibility.cpp

index ef833d8c7db5980dc1333961eab3856f434a2648..a3196b22f07c60e3239d4d0d4f1381c49f9d9e5c 100644 (file)
@@ -273,6 +273,25 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVFlags F) {
   LinkageInfo LV;
   LV.mergeVisibility(Context.getLangOpts().getVisibilityMode());
 
+  if (F.ConsiderVisibilityAttributes) {
+    if (llvm::Optional<Visibility> Vis = D->getExplicitVisibility()) {
+      LV.setVisibility(*Vis, true);
+    } else {
+      // If we're declared in a namespace with a visibility attribute,
+      // use that namespace's visibility, but don't call it explicit.
+      for (const DeclContext *DC = D->getDeclContext();
+           !isa<TranslationUnitDecl>(DC);
+           DC = DC->getParent()) {
+        const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC);
+        if (!ND) continue;
+        if (llvm::Optional<Visibility> Vis = ND->getExplicitVisibility()) {
+          LV.setVisibility(*Vis, true);
+          break;
+        }
+      }
+    }
+  }
+
   // C++ [basic.link]p4:
 
   //   A name having namespace scope has external linkage if it is the
@@ -443,25 +462,6 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVFlags F) {
     return LinkageInfo::none();
   }
 
-  if (F.ConsiderVisibilityAttributes) {
-    if (llvm::Optional<Visibility> Vis = D->getExplicitVisibility()) {
-      LV.setVisibility(*Vis, true);
-    } else {
-      // If we're declared in a namespace with a visibility attribute,
-      // use that namespace's visibility, but don't call it explicit.
-      for (const DeclContext *DC = D->getDeclContext();
-           !isa<TranslationUnitDecl>(DC);
-           DC = DC->getParent()) {
-        const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC);
-        if (!ND) continue;
-        if (llvm::Optional<Visibility> Vis = ND->getExplicitVisibility()) {
-          LV.setVisibility(*Vis, true);
-          break;
-        }
-      }
-    }
-  }
-
   // If we ended up with non-external linkage, visibility should
   // always be default.
   if (LV.linkage() != ExternalLinkage)
index 88a456fe57115536e597ae574d0e9259e44daae9..59fd7c26f0d5cf71b28a9ba0c8c250e62b37233e 100644 (file)
@@ -28,18 +28,6 @@ namespace test28 {
   // CHECK-HIDDEN: @_ZN6test285myvecE = hidden global
 }
 
-namespace test29 {
-#pragma GCC visibility push(hidden)
-  struct RECT {
-    int top;
-  };
-  __attribute__ ((visibility ("default"))) extern RECT data_rect;
-  RECT data_rect = { -1};
-#pragma GCC visibility pop
-  // CHECK: @_ZN6test299data_rectE = global
-  // CHECK-HIDDEN: @_ZN6test299data_rectE = global
-}
-
 // CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10
 // CHECK: @_ZN5Test71aE = hidden global
 // CHECK: @_ZN5Test71bE = global