[clang-tools-extra] [NFC] Fix potential underflow constant. (PR #118528)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 4 10:21:40 PST 2024
================
@@ -58,10 +58,10 @@ getDerivedParameter(const ClassTemplateSpecializationDecl *CRTP,
Arg.getAsType()->getAsCXXRecordDecl() == Derived;
});
- return AnyOf ? CRTP->getSpecializedTemplate()
- ->getTemplateParameters()
- ->getParam(Idx - 1)
- : nullptr;
+ return AnyOf && Idx > 0 ? CRTP->getSpecializedTemplate()
----------------
AaronBallman wrote:
I don't think it's possible for `AnyOf` to be `true` and `Idx` to be `0` at the same time. `Idx` starts as zero, but the call to `any_of` on line 54 has a lambda which explicitly does `++Idx`, so `any_of` cannot return `true` without incrementing `Idx`.
If this came from a static analysis tool, I would claim it's a false positive that doesn't require changes.
https://github.com/llvm/llvm-project/pull/118528
More information about the cfe-commits
mailing list