[clang] Implement resource binding type prefix mismatch errors (PR #87578)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 4 14:06:35 PDT 2024
================
@@ -7403,41 +7403,36 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D,
}
switch (RC) {
case llvm::hlsl::ResourceClass::SRV: {
- if (Slot.substr(0, 1) != "t")
+ if (Slot[0] != 't')
S.Diag(ArgLoc, diag::err_hlsl_mismatching_register_type_and_name)
<< Slot.substr(0, 1) << varTy << "t";
break;
}
case llvm::hlsl::ResourceClass::UAV: {
- if (Slot.substr(0, 1) != "u")
+ if (Slot[0] != 'u')
S.Diag(ArgLoc, diag::err_hlsl_mismatching_register_type_and_name)
<< Slot.substr(0, 1) << varTy << "u";
break;
}
case llvm::hlsl::ResourceClass::CBuffer: {
- if (Slot.substr(0, 1) != "b")
+ if (Slot[0] != 'b')
S.Diag(ArgLoc, diag::err_hlsl_mismatching_register_type_and_name)
<< Slot.substr(0, 1) << varTy << "b";
break;
}
case llvm::hlsl::ResourceClass::Sampler: {
- if (Slot.substr(0, 1) != "s")
+ if (Slot[0] != 's')
S.Diag(ArgLoc, diag::err_hlsl_mismatching_register_type_and_name)
<< Slot.substr(0, 1) << varTy << "s";
break;
}
- case llvm::hlsl::ResourceClass::Invalid: {
+ default: {
----------------
llvm-beanz wrote:
It would be better to have this be the Invalid case. Then the compiler will warn if new enum values get added that aren't handled.
https://github.com/llvm/llvm-project/pull/87578
More information about the cfe-commits
mailing list