[llvm] Wrap ifndef NDEBUG around assertion-only code (PR #142227)

Walter Lee via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 15:39:57 PDT 2025


https://github.com/googlewalt created https://github.com/llvm/llvm-project/pull/142227

Otherwise we get unused variable warnings.

>From c965709fb06971a0679a81863d2df9ddb467ec05 Mon Sep 17 00:00:00 2001
From: Walter Lee <waltl at google.com>
Date: Fri, 30 May 2025 22:33:10 +0000
Subject: [PATCH] Wrap ifndef NDEBUG around assertion-only code

Otherwise we get unused variable warnings.
---
 llvm/unittests/SandboxIR/RegionTest.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/unittests/SandboxIR/RegionTest.cpp b/llvm/unittests/SandboxIR/RegionTest.cpp
index 7d998b147e37c..5d7283fa1024f 100644
--- a/llvm/unittests/SandboxIR/RegionTest.cpp
+++ b/llvm/unittests/SandboxIR/RegionTest.cpp
@@ -437,10 +437,10 @@ define void @foo(i8 %v) {
 }
 !0 = !{i32 0}
 )IR");
+#ifndef NDEBUG
   llvm::Function *LLVMF = &*M->getFunction("foo");
   sandboxir::Context Ctx(C);
   auto *F = Ctx.createFunction(LLVMF);
-#ifndef NDEBUG
   EXPECT_DEATH(sandboxir::Region::createRegionsFromMD(*F, *TTI), "No region.*");
 #endif
 }



More information about the llvm-commits mailing list