[clang] [clang][CodeGen] Drop debug location on the if-then exit branch (PR #212942)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 30 00:29:43 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Jim Lin (tclin914)
<details>
<summary>Changes</summary>
In EmitIfStmt, the branch from the 'then' block to the continuation block inherited the debug location of the block's closing brace, adding a spurious is_stmt line-table entry on the '}'. Guard it with ApplyDebugLocation::CreateEmpty, as the 'else' branch already is.
---
Full diff: https://github.com/llvm/llvm-project/pull/212942.diff
1 Files Affected:
- (modified) clang/lib/CodeGen/CGStmt.cpp (+5-1)
``````````diff
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 27e74d966eca1..f937f739cc681 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -975,7 +975,11 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
RunCleanupsScope ThenScope(*this);
EmitStmt(S.getThen());
}
- EmitBranch(ContBlock);
+ {
+ // There is no need to emit line number for an unconditional branch.
+ auto NL = ApplyDebugLocation::CreateEmpty(*this);
+ EmitBranch(ContBlock);
+ }
// Emit the 'else' code if present.
if (Else) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/212942
More information about the cfe-commits
mailing list