[clang] [HLSL] Remove variables that are used only in assert (PR #107299)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 4 13:00:32 PDT 2024
https://github.com/hekota created https://github.com/llvm/llvm-project/pull/107299
Changes the assert to test the same condition without using the variables.
This change is done in response to a comment [here](https://github.com/llvm/llvm-project/pull/106657#issuecomment-2327493439).
>From 038e47d8ec75c03b895eb8bb5540f1fee9f4b936 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Wed, 4 Sep 2024 12:55:43 -0700
Subject: [PATCH] [HLSL] Remove variables used only in assert
---
clang/lib/Sema/SemaHLSL.cpp | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 778d524a005482..aa41a7c809880b 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -834,17 +834,10 @@ static void ValidateMultipleRegisterAnnotations(Sema &S, Decl *TheDecl,
static void DiagnoseHLSLRegisterAttribute(Sema &S, SourceLocation &ArgLoc,
Decl *TheDecl, RegisterType regType) {
- // Samplers, UAVs, and SRVs are VarDecl types
- VarDecl *TheVarDecl = dyn_cast<VarDecl>(TheDecl);
- // Cbuffers and Tbuffers are HLSLBufferDecl types
- HLSLBufferDecl *CBufferOrTBuffer = dyn_cast<HLSLBufferDecl>(TheDecl);
-
// exactly one of these two types should be set
- assert(((TheVarDecl && !CBufferOrTBuffer) ||
- (!TheVarDecl && CBufferOrTBuffer)) &&
+ assert(((isa<VarDecl>(TheDecl) && !isa<HLSLBufferDecl>(TheDecl)) ||
+ (!isa<VarDecl>(TheDecl) && isa<HLSLBufferDecl>(TheDecl))) &&
"either TheVarDecl or CBufferOrTBuffer should be set");
- (void)TheVarDecl;
- (void)CBufferOrTBuffer;
RegisterBindingFlags Flags = HLSLFillRegisterBindingFlags(S, TheDecl);
assert((int)Flags.Other + (int)Flags.Resource + (int)Flags.Basic +
More information about the cfe-commits
mailing list