diff options
| author | Adrian Prantl <aprantl@apple.com> | 2018-11-28 21:44:06 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2018-11-28 21:44:06 +0000 |
| commit | db9f93e7f33d4f8bfd5f60930cf14cbd467378fc (patch) | |
| tree | b67e01496bae5f7b57c86d5d3b6d1b87d9072de5 /lib/CodeGen/CGExpr.cpp | |
| parent | f1be5aeb5cea686c911f22318411f8b51527bcf7 (diff) | |
| download | clang-db9f93e7f33d4f8bfd5f60930cf14cbd467378fc.tar.gz | |
Ensure sanitizer check function calls have a !dbg location
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347810 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index f4b0f8fb67..17a75c0bb1 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2879,6 +2879,11 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF, CheckRecoverableKind RecoverKind, bool IsFatal, llvm::BasicBlock *ContBB) { assert(IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable); + Optional<ApplyDebugLocation> DL; + if (!CGF.Builder.getCurrentDebugLocation()) { + // Ensure that the call has at least an artificial debug location. + DL.emplace(CGF, SourceLocation()); + } bool NeedsAbortSuffix = IsFatal && RecoverKind != CheckRecoverableKind::Unrecoverable; bool MinimalRuntime = CGF.CGM.getCodeGenOpts().SanitizeMinimalRuntime; |
