[cfe-commits] r154846 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/visibility.cpp
Rafael Espindola
rafael.espindola at gmail.com
Mon Apr 16 11:46:27 PDT 2012
Author: rafael
Date: Mon Apr 16 13:46:26 2012
New Revision: 154846
URL: http://llvm.org/viewvc/llvm-project?rev=154846&view=rev
Log:
Revert r154749 for now at John McCall's request.
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGenCXX/visibility.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=154846&r1=154845&r2=154846&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon Apr 16 13:46:26 2012
@@ -273,6 +273,25 @@
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 @@
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)
Modified: cfe/trunk/test/CodeGenCXX/visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility.cpp?rev=154846&r1=154845&r2=154846&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility.cpp Mon Apr 16 13:46:26 2012
@@ -28,18 +28,6 @@
// 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
More information about the cfe-commits
mailing list