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

Aiden Grossman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 06:52:26 PDT 2026


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

Inline the variable definition into the assert given it is side effect
free and the variable name does not make the code much more clear.

>From f60afb8a3ff166a77dfffb62f78c14b7b38f9b71 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Mon, 27 Apr 2026 13:50:43 +0000
Subject: [PATCH] [Clang][HLSL] Fix -Wunused-variable

Inline the variable definition into the assert given it is side effect
free and the variable name does not make the code much more clear.
---
 clang/lib/CodeGen/CGHLSLRuntime.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index f2db4114c0798..a134f6aab9490 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -1658,10 +1658,9 @@ class HLSLBufferCopyEmitter {
                             llvm::ArrayType *DstTy) {
     // Those assumptions are checked by isBufferLayoutArray.
     auto *SrcPaddedArrayTy = cast<llvm::ArrayType>(SrcTy->getElementType(0));
-    auto *SrcPaddedEltTy =
-        cast<llvm::StructType>(SrcPaddedArrayTy->getElementType());
     assert(SrcPaddedArrayTy->getNumElements() + 1 == DstTy->getNumElements());
-    assert(SrcPaddedEltTy->getElementType(0) == SrcTy->getElementType(1));
+    assert(cast<llvm::StructType>(SrcPaddedArrayTy->getElementType())
+               ->getElementType(0) == SrcTy->getElementType(1));
 
     auto *SrcDataTy = SrcTy->getElementType(1);
     auto Zero = llvm::ConstantInt::get(CGF.IntTy, 0);



More information about the cfe-commits mailing list