summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-01-24 18:58:32 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-01-24 18:58:32 +0000
commit123ce97fac78bc4519afd5d2aba17c59c5717aad (patch)
tree8279da2927fcac8cfd8a0b7498aaebc7a90eac4b /clang
parent7c2031fb958cdb70bb8081ec68f038ad13d99322 (diff)
downloadbcm5719-llvm-123ce97fac78bc4519afd5d2aba17c59c5717aad.tar.gz
bcm5719-llvm-123ce97fac78bc4519afd5d2aba17c59c5717aad.zip
Don't create hidden dllimport global values.
Hidden visibility is almost the opposite of dllimport. We were producing them before (dllimport wins in the existing llvm implementation), but now the llvm verifier produces an error. llvm-svn: 323361
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp2
-rw-r--r--clang/test/CodeGenCXX/hidden-dllimport.cpp10
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 68c82870846..641c99119bd 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -694,6 +694,8 @@ llvm::ConstantInt *CodeGenModule::getSize(CharUnits size) {
void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
const NamedDecl *D,
ForDefinition_t IsForDefinition) const {
+ if (GV->hasDLLImportStorageClass())
+ return;
// Internal definitions always have default visibility.
if (GV->hasLocalLinkage()) {
GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
diff --git a/clang/test/CodeGenCXX/hidden-dllimport.cpp b/clang/test/CodeGenCXX/hidden-dllimport.cpp
new file mode 100644
index 00000000000..9de0d71084f
--- /dev/null
+++ b/clang/test/CodeGenCXX/hidden-dllimport.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -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 @"\01?bar@foo@@QEAAXXZ"(%struct.foo*)
+
+struct __attribute__((dllimport)) foo {
+ void bar() {}
+};
+void zed(foo *p) { p->bar(); }
OpenPOWER on IntegriCloud