[clang] [clang][CodeGen] Drop debug location on the if-then exit branch (PR #212942)
Jim Lin via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 30 00:29:08 PDT 2026
https://github.com/tclin914 created https://github.com/llvm/llvm-project/pull/212942
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.
>From bd2615f602ed0a21fbda11339cc7e5a733d9b01f Mon Sep 17 00:00:00 2001
From: Jim Lin <jim at andestech.com>
Date: Tue, 28 Jul 2026 13:55:01 +0800
Subject: [PATCH] [clang][CodeGen] Drop debug location on the if-then exit
branch
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.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply at anthropic.com>
---
clang/lib/CodeGen/CGStmt.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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) {
More information about the cfe-commits
mailing list