[clang] [Wunsafe-buffer-usage] Fix false positives in handling enums (PR #117370)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 20:48:50 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) {
----------------
mxms0 wrote:
Yeeep. Good catch, should be fixed :)
https://github.com/llvm/llvm-project/pull/117370
More information about the cfe-commits
mailing list