================
@@ -2419,12 +2498,24 @@ void SemaHLSL::handleResourceBindingAttr(Decl *TheDecl,
const ParsedAttr &AL) {
Diag(SlotLoc, diag::warn_hlsl_deprecated_register_type_i);
return;
}
- StringRef SlotNumStr = Slot.substr(1);
+ const StringRef SlotNumStr = Slot.substr(1);
+
unsigned N;
- if (SlotNumStr.getAsInteger(10, N)) {
+
+ // validate that the slot number is a non-empty number
+ if (SlotNumStr.empty() || !llvm::all_of(SlotNumStr, llvm::isDigit)) {
Diag(SlotLoc, diag::err_hlsl_unsupported_register_number);
return;
}
+
+ // Validate register number. It should not exceed UINT32_MAX,
+ // including if the resource type is an array that starts
+ // before UINT32_MAX, but ends afterwards.
+ if (ValidateRegisterNumber(SlotNumStr, TheDecl, getASTContext(), N)) {
----------------
inbelic wrote:
Take it or leave it nit:
```suggestion
uint64_t N;
if (SlotNumStr.getAsInteger(10, N) || ValidateRegisterNumber(N, TheDecl,
getASTContext())) {
...
}
SlotNum = (uint32_t)N;
```
https://github.com/llvm/llvm-project/pull/174028
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits