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 <[email protected]>
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) <[email protected]>
---
 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) {

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to