summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp3
-rw-r--r--clang/test/CodeGenObjC/initialize-function-static.m12
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 61fb8fa384c..86e02d2d7e4 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -366,7 +366,8 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
emitter.finalize(GV);
- if (D.needsDestruction(getContext()) && HaveInsertPoint()) {
+ if (D.needsDestruction(getContext()) == QualType::DK_cxx_destructor &&
+ HaveInsertPoint()) {
// We have a constant initializer, but a nontrivial destructor. We still
// need to perform a guarded "initialization" in order to register the
// destructor.
diff --git a/clang/test/CodeGenObjC/initialize-function-static.m b/clang/test/CodeGenObjC/initialize-function-static.m
new file mode 100644
index 00000000000..21ad320f782
--- /dev/null
+++ b/clang/test/CodeGenObjC/initialize-function-static.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.15 -emit-llvm -fobjc-arc -o - %s | FileCheck %s
+
+@interface I
+@end
+
+I *i() {
+ static I *i = ((void *)0);
+ return i;
+}
+
+// CHECK-NOT: __cxa_guard_acquire
+// CHECK-NOT: __cxa_guard_release
OpenPOWER on IntegriCloud