Skip to content

Commit 41c11ea

Browse files
authored
[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](#106657 (comment)).
1 parent ad89e61 commit 41c11ea

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -837,17 +837,10 @@ static void ValidateMultipleRegisterAnnotations(Sema &S, Decl *TheDecl,
837837
static void DiagnoseHLSLRegisterAttribute(Sema &S, SourceLocation &ArgLoc,
838838
Decl *TheDecl, RegisterType regType) {
839839

840-
// Samplers, UAVs, and SRVs are VarDecl types
841-
VarDecl *TheVarDecl = dyn_cast<VarDecl>(TheDecl);
842-
// Cbuffers and Tbuffers are HLSLBufferDecl types
843-
HLSLBufferDecl *CBufferOrTBuffer = dyn_cast<HLSLBufferDecl>(TheDecl);
844-
845840
// exactly one of these two types should be set
846-
assert(((TheVarDecl && !CBufferOrTBuffer) ||
847-
(!TheVarDecl && CBufferOrTBuffer)) &&
848-
"either TheVarDecl or CBufferOrTBuffer should be set");
849-
(void)TheVarDecl;
850-
(void)CBufferOrTBuffer;
841+
assert(((isa<VarDecl>(TheDecl) && !isa<HLSLBufferDecl>(TheDecl)) ||
842+
(!isa<VarDecl>(TheDecl) && isa<HLSLBufferDecl>(TheDecl))) &&
843+
"expecting VarDecl or HLSLBufferDecl");
851844

852845
RegisterBindingFlags Flags = HLSLFillRegisterBindingFlags(S, TheDecl);
853846
assert((int)Flags.Other + (int)Flags.Resource + (int)Flags.Basic +

0 commit comments

Comments
 (0)