[clang] 41c11ea - [HLSL] Remove variables that are used only in assert (#107299)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 4 21:15:51 PDT 2024
Author: Helena Kotas
Date: 2024-09-04T21:15:48-07:00
New Revision: 41c11ea2af743051013dfcc0fced5a450e2dc9b8
URL: https://github.com/llvm/llvm-project/commit/41c11ea2af743051013dfcc0fced5a450e2dc9b8
DIFF: https://github.com/llvm/llvm-project/commit/41c11ea2af743051013dfcc0fced5a450e2dc9b8.diff
LOG: [HLSL] Remove variables that are used only in assert (#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).
Added:
Modified:
clang/lib/Sema/SemaHLSL.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 65aeda4b7b613e..d5ccd3815eb668 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -837,17 +837,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)) &&
- "either TheVarDecl or CBufferOrTBuffer should be set");
- (void)TheVarDecl;
- (void)CBufferOrTBuffer;
+ assert(((isa<VarDecl>(TheDecl) && !isa<HLSLBufferDecl>(TheDecl)) ||
+ (!isa<VarDecl>(TheDecl) && isa<HLSLBufferDecl>(TheDecl))) &&
+ "expecting VarDecl or HLSLBufferDecl");
RegisterBindingFlags Flags = HLSLFillRegisterBindingFlags(S, TheDecl);
assert((int)Flags.Other + (int)Flags.Resource + (int)Flags.Basic +
More information about the cfe-commits
mailing list