[PATCH] D135920: [clang][Sema] Use correct array size for diagnostic
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 13 15:49:07 PDT 2022
shafik added a comment.
Thank you for this fix, I have some comments.
================
Comment at: clang/lib/Sema/SemaChecking.cpp:16068
DiagRuntimeBehavior(BaseExpr->getBeginLoc(), BaseExpr,
PDiag(DiagID) << toString(index, 10, true)
- << toString(size, 10, true)
----------------
`index` is also wrong as you can see from the diagnostic below `array index 32768 is past`.
I think what you want is `index.getNumWords()` and `size.getNumWords()`.
================
Comment at: clang/lib/Sema/SemaChecking.cpp:16070
- << toString(size, 10, true)
+ << toString(ArrayTy->getSize(), 10, true)
<< (unsigned)size.getLimitedValue(~0U)
<< IndexExpr->getSourceRange());
----------------
It is not clear what this is for.
If we look at `warn_array_index_exceeds_bounds` in `DiagnosticSemaKinds.td` we can see that `element%s2` which I believe is a typo and means that this argument is lost.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135920/new/
https://reviews.llvm.org/D135920
More information about the cfe-commits
mailing list