[clang] [Wunsafe-buffer-usage] Fix false positives in handling enums (PR #117370)
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 15:37:35 PST 2024
================
@@ -463,6 +463,13 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
return true;
}
+ // Array index wasn't an integer literal, let's see if it was an enum or
+ // something similar
+ const auto IntConst = Node.getIdx()->getIntegerConstantExpr(Finder->getASTContext());
+ if (IntConst && *IntConst > 0 && *IntConst < size) {
----------------
rnk wrote:
Should it be `>= 0`?
https://github.com/llvm/llvm-project/pull/117370
More information about the cfe-commits
mailing list