[llvm-branch-commits] [llvm] [DirectX] Improve error accumulation in root signature parsing (PR #144465)
Chris B via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jul 11 11:38:25 PDT 2025
================
@@ -699,19 +736,20 @@ static bool verifyBorderColor(uint32_t BorderColor) {
static bool verifyLOD(float LOD) { return !std::isnan(LOD); }
static bool validate(LLVMContext *Ctx, const mcdxbc::RootSignatureDesc &RSD) {
-
+ bool HasError = false;
if (!verifyVersion(RSD.Version)) {
- return reportValueError(Ctx, "Version", RSD.Version);
+ HasError = reportValueError(Ctx, "Version", RSD.Version) || HasError;
----------------
llvm-beanz wrote:
This pattern seems really awkward because the report functions always return `true`. That means that the `||` is always unnecessary, but also the assignment itself isn't really as clear to understand as it could be.
You could instead write this code as something like:
```
if (!verifyVersion(RSD.Version)) {
reportValueError(...);
HasError = true;
}
```
This is more verbose but a lot easier to see what is happening.
https://github.com/llvm/llvm-project/pull/144465
More information about the llvm-branch-commits
mailing list