mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-10 02:16:08 +00:00

Function calls without a !dbg location inside a function that has a DISubprogram make it impossible to construct inline information and are rejected by the verifier. This patch ensures that sanitizer check function calls have a !dbg location, by carrying forward the location of the preceding instruction or by inserting an artificial location if necessary. This fixes a crash when compiling the attached testcase with -Os. rdar://problem/45311226 Differential Revision: https://reviews.llvm.org/D53459 Note: This reapllies r344915, modified to reuse the IRBuilder's DebugLoc if one exists instead of picking the one from CGDebugInfo since the latter may get reset when emitting thunks such as block helpers in the middle of emitting another function. llvm-svn: 347810
18 lines
604 B
C++
18 lines
604 B
C++
// 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);
|
|
}
|