[clang] [Clang][HLSL] Fix -Wunused-variable (PR #196445)

Aiden Grossman via cfe-commits cfe-commits at lists.llvm.org
Thu May 7 16:01:26 PDT 2026


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/196445

LookupSucceeded is only used in an assertion. Mark it [[maybe_unused]]
so we do not get -Wunused-variable in non-assertions builds.

>From 2e5bf1e0eeab867a3dbe7c6a8ec58581c1d365ad Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Thu, 7 May 2026 22:59:26 +0000
Subject: [PATCH] [Clang][HLSL] Fix -Wunused-variable

LookupSucceeded is only used in an assertion. Mark it [[maybe_unused]]
so we do not get -Wunused-variable in non-assertions builds.
---
 clang/lib/Sema/SemaHLSL.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 717dfdcb36048..594a18f0b8c78 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -3188,7 +3188,8 @@ NamedDecl *SemaHLSL::getConstantBufferConversionFunction(QualType Type,
           CanQualType::CreateUnsafe(ReturnTy));
   LookupResult ConvR(SemaRef, ConvName, SourceLocation(),
                      Sema::LookupOrdinaryName);
-  bool LookupSucceeded = SemaRef.LookupQualifiedName(ConvR, RD);
+  [[maybe_unused]] bool LookupSucceeded =
+      SemaRef.LookupQualifiedName(ConvR, RD);
   assert(LookupSucceeded);
 
   for (NamedDecl *D : ConvR) {



More information about the cfe-commits mailing list