aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGExprConstant.cpp3
-rw-r--r--test/CodeGen/sanitize-init-order.cpp24
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index e3e5d66605..faaf6468f1 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -1018,8 +1018,7 @@ llvm::Constant *CodeGenModule::EmitConstantInit(const VarDecl &D,
if (const CXXConstructExpr *E =
dyn_cast_or_null<CXXConstructExpr>(D.getInit())) {
const CXXConstructorDecl *CD = E->getConstructor();
- if (CD->isTrivial() && CD->isDefaultConstructor() &&
- Ty->getAsCXXRecordDecl()->hasTrivialDestructor())
+ if (CD->isTrivial() && CD->isDefaultConstructor())
return EmitNullConstant(D.getType());
}
}
diff --git a/test/CodeGen/sanitize-init-order.cpp b/test/CodeGen/sanitize-init-order.cpp
new file mode 100644
index 0000000000..3e94620193
--- /dev/null
+++ b/test/CodeGen/sanitize-init-order.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsanitize=address,init-order -emit-llvm -o - %s | FileCheck %s
+
+struct PODStruct {
+ int x;
+};
+PODStruct s1;
+
+struct PODWithDtor {
+ ~PODWithDtor() { }
+ int x;
+};
+PODWithDtor s2;
+
+struct PODWithCtorAndDtor {
+ PODWithCtorAndDtor() { }
+ ~PODWithCtorAndDtor() { }
+ int x;
+};
+PODWithCtorAndDtor s3;
+
+// Check that ASan init-order checking ignores structs with trivial default
+// constructor.
+// CHECK: !llvm.asan.dynamically_initialized_globals = !{[[GLOB:![0-9]+]]}
+// CHECK: [[GLOB]] = metadata !{%struct.PODWithCtorAndDtor