MaskRay updated this revision to Diff 457625.
MaskRay marked an inline comment as done.
MaskRay added a comment.

rename test to dllstorage-visibility.cpp
use -fdeclspec instead of -fms-extensions


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133180/new/

https://reviews.llvm.org/D133180

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/dllstorage-visibility.cpp
  clang/test/CodeGenCXX/hidden-dllimport.cpp


Index: clang/test/CodeGenCXX/hidden-dllimport.cpp
===================================================================
--- clang/test/CodeGenCXX/hidden-dllimport.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc 
-emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s
-
-// We used to declare this hidden dllimport, which is contradictory.
-
-// CHECK: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo* {{[^,]*}})
-
-struct __attribute__((dllimport)) foo {
-  void bar() {}
-};
-void zed(foo *p) { p->bar(); }
Index: clang/test/CodeGenCXX/dllstorage-visibility.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/dllstorage-visibility.cpp
@@ -0,0 +1,26 @@
+/// dllimport and dllexport express non-hidden intention. Don't apply hidden 
visibility.
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility hidden -o - %s | FileCheck %s --check-prefix=GNU
+
+#define CONCAT2(x, y) x##y
+#define CONCAT(x, y) CONCAT2(x, y)
+#define USE(func) void CONCAT(use, __LINE__)() { func(); }
+
+// MSVC-DAG: declare dllimport void @"?bar@foo@@QEAAXXZ"(
+// GNU-DAG: define linkonce_odr hidden void @_ZN3foo3barEv(
+
+struct __attribute__((dllimport)) foo {
+  void bar() {}
+};
+void zed(foo *p) { p->bar(); }
+
+// MSVC-DAG: define dso_local dllexport void @"?exported@@YAXXZ"(
+// GNU-DAG: define dso_local dllexport void @_Z8exportedv(
+__attribute__((dllexport)) void exported() {}
+
+// MSVC-DAG: define weak_odr dso_local dllexport void 
@"?exported_inline@@YAXXZ"(
+// GNU-DAG: define weak_odr dso_local dllexport void @_Z15exported_inlinev(
+__declspec(dllexport) inline void exported_inline() {}
+USE(exported_inline)
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1099,7 +1099,7 @@
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
                                         const NamedDecl *D) const {
-  if (GV->hasDLLImportStorageClass())
+  if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass())
     return;
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {


Index: clang/test/CodeGenCXX/hidden-dllimport.cpp
===================================================================
--- clang/test/CodeGenCXX/hidden-dllimport.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc -emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s
-
-// We used to declare this hidden dllimport, which is contradictory.
-
-// CHECK: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo* {{[^,]*}})
-
-struct __attribute__((dllimport)) foo {
-  void bar() {}
-};
-void zed(foo *p) { p->bar(); }
Index: clang/test/CodeGenCXX/dllstorage-visibility.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/dllstorage-visibility.cpp
@@ -0,0 +1,26 @@
+/// dllimport and dllexport express non-hidden intention. Don't apply hidden visibility.
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-msvc -fdeclspec -fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec -fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=GNU
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec -fvisibility hidden -o - %s | FileCheck %s --check-prefix=GNU
+
+#define CONCAT2(x, y) x##y
+#define CONCAT(x, y) CONCAT2(x, y)
+#define USE(func) void CONCAT(use, __LINE__)() { func(); }
+
+// MSVC-DAG: declare dllimport void @"?bar@foo@@QEAAXXZ"(
+// GNU-DAG: define linkonce_odr hidden void @_ZN3foo3barEv(
+
+struct __attribute__((dllimport)) foo {
+  void bar() {}
+};
+void zed(foo *p) { p->bar(); }
+
+// MSVC-DAG: define dso_local dllexport void @"?exported@@YAXXZ"(
+// GNU-DAG: define dso_local dllexport void @_Z8exportedv(
+__attribute__((dllexport)) void exported() {}
+
+// MSVC-DAG: define weak_odr dso_local dllexport void @"?exported_inline@@YAXXZ"(
+// GNU-DAG: define weak_odr dso_local dllexport void @_Z15exported_inlinev(
+__declspec(dllexport) inline void exported_inline() {}
+USE(exported_inline)
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1099,7 +1099,7 @@
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
                                         const NamedDecl *D) const {
-  if (GV->hasDLLImportStorageClass())
+  if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass())
     return;
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to