summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp3
-rw-r--r--clang/test/CodeGenCXX/ubsan-check-debuglocs.cpp17
2 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 55fa4551167..8a8f38678f6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2867,6 +2867,9 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF,
CheckRecoverableKind RecoverKind, bool IsFatal,
llvm::BasicBlock *ContBB) {
assert(IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable);
+ auto *DI = CGF.getDebugInfo();
+ SourceLocation Loc = DI ? DI->getLocation() : SourceLocation();
+ auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
bool NeedsAbortSuffix =
IsFatal && RecoverKind != CheckRecoverableKind::Unrecoverable;
bool MinimalRuntime = CGF.CGM.getCodeGenOpts().SanitizeMinimalRuntime;
diff --git a/clang/test/CodeGenCXX/ubsan-check-debuglocs.cpp b/clang/test/CodeGenCXX/ubsan-check-debuglocs.cpp
new file mode 100644
index 00000000000..96a697aca5e
--- /dev/null
+++ b/clang/test/CodeGenCXX/ubsan-check-debuglocs.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited \
+// RUN: -fsanitize=null %s -o - | FileCheck %s
+
+// Check that santizer check calls have a !dbg location.
+// CHECK: define {{.*}}acquire{{.*}} !dbg
+// CHECK-NOT: define
+// CHECK: call void {{.*}}@__ubsan_handle_type_mismatch_v1
+// CHECK-SAME: !dbg
+
+struct SourceLocation {
+ SourceLocation acquire() {};
+};
+extern "C" void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc);
+static void handleTypeMismatchImpl(SourceLocation *Loc) { Loc->acquire(); }
+void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc) {
+ handleTypeMismatchImpl(Loc);
+}
OpenPOWER on IntegriCloud