[clang] Implement resource binding type prefix mismatch diagnostic infrastructure (PR #97103)
Damyan Pepper via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 16 10:19:54 PDT 2024
================
@@ -551,24 +541,21 @@ getHLSLResourceAttrFromEitherDecl(VarDecl *VD,
// the resource attr could be on the record decl itself or on one of
// its fields (the resource handle, most commonly)
- const auto *Attr = TheRecordDecl->getAttr<HLSLResourceAttr>();
+ const auto *Attr = TheRecordDecl->getAttr<T>();
if (!Attr) {
for (auto *FD : TheRecordDecl->fields()) {
- Attr = FD->getAttr<HLSLResourceAttr>();
+ Attr = FD->getAttr<T>();
if (Attr)
break;
}
}
return Attr;
- } else if (CBufferOrTBuffer) {
- const auto *Attr = CBufferOrTBuffer->getAttr<HLSLResourceAttr>();
- return Attr;
}
- llvm_unreachable("one of the two conditions should be true.");
+ llvm_unreachable("VD should not be null");
----------------
damyanp wrote:
How about removing the `if` and either have an `assert(VD);` at the beginning of the function. But really, I don't think you'd bother doing that if you wrote this function from scratch to just take the one parameter, it's just because this is left over from the previous version that had two arguments that these null checks were left behind.
https://github.com/llvm/llvm-project/pull/97103
More information about the cfe-commits
mailing list