summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CodeGenCXX')
-rw-r--r--clang/test/CodeGenCXX/catch-undef-behavior.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/catch-undef-behavior.cpp b/clang/test/CodeGenCXX/catch-undef-behavior.cpp
index 50a05a06bf6..0e8d4fa51a0 100644
--- a/clang/test/CodeGenCXX/catch-undef-behavior.cpp
+++ b/clang/test/CodeGenCXX/catch-undef-behavior.cpp
@@ -520,6 +520,49 @@ void upcast_to_vbase() {
}
}
+struct nothrow {};
+void *operator new[](__SIZE_TYPE__, nothrow) noexcept;
+
+namespace NothrowNew {
+ struct X { X(); };
+
+ // CHECK-LABEL: define{{.*}}nothrow_new_trivial
+ void *nothrow_new_trivial() {
+ // CHECK: %[[is_null:.*]] = icmp eq i8*{{.*}}, null
+ // CHECK: br i1 %[[is_null]], label %[[null:.*]], label %[[nonnull:.*]]
+
+ // CHECK: [[nonnull]]:
+ // CHECK: llvm.objectsize
+ // CHECK: br i1
+ //
+ // CHECK: call {{.*}}__ubsan_handle_type_mismatch
+ //
+ // CHECK: [[null]]:
+ // CHECK-NOT: {{ }}br{{ }}
+ // CHECK: ret
+ return new (nothrow{}) char[123456];
+ }
+
+ // CHECK-LABEL: define{{.*}}nothrow_new_nontrivial
+ void *nothrow_new_nontrivial() {
+ // CHECK: %[[is_null:.*]] = icmp eq i8*{{.*}}, null
+ // CHECK: br i1 %[[is_null]], label %[[null:.*]], label %[[nonnull:.*]]
+
+ // CHECK: [[nonnull]]:
+ // CHECK: llvm.objectsize
+ // CHECK: br i1
+ //
+ // CHECK: call {{.*}}__ubsan_handle_type_mismatch
+ //
+ // CHECK: call {{.*}}_ZN10NothrowNew1XC1Ev
+ //
+ // CHECK: [[null]]:
+ // CHECK-NOT: {{ }}br{{ }}
+ // CHECK: ret
+ return new (nothrow{}) X[123456];
+ }
+}
+
struct ThisAlign {
void this_align_lambda();
void this_align_lambda_2();
OpenPOWER on IntegriCloud