Details
- Reviewers
aaron.ballman jdoerfert erichkeane
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for working on this fix! A few things:
- Please add a summary description to the patch, and be sure to include a reference to the github issue in the summary.
- All functional changes (e.g., not typo fixes, fixes to comments, or other NFC changes) need test coverage that demonstrates the issue has been resolved.
- All functional changes should have a release note in clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclAttr.cpp | ||
---|---|---|
3764–3767 | Did you look into fixing this within checkFunctionOrMethodParameterIndex() instead? That way, all callers of the API get the correct behavior instead of having to find individual attributes to check the logic (I believe there are other attributes with the same underlying problem). |
clang/lib/Sema/SemaDeclAttr.cpp | ||
---|---|---|
3764–3767 | I would also expect any such issue to diagnose. Also, isn't there an off-by-one error here in the case of variadic args? |
clang/lib/Sema/SemaDeclAttr.cpp | ||
---|---|---|
3764–3767 | handleFormatAttr() has: if (Idx < 1 || Idx > NumArgs) { S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) << AL << 2 << IdxExpr->getSourceRange(); return; } which is also what I'd expect to see here. |
clang/lib/Sema/SemaDeclAttr.cpp | ||
---|---|---|
3764–3767 | I agree w/ @aaron.ballman here we should handle this in checkFunctionOrMethodParameterIndex it is used in many places and AFAICT they all have the same issue, none diagnose this case but paper it over. There is definitely a bigger clean-up here but we can do a targeted fix now and remove a crash bug and leave the larger fixing for a follow-up. |
For the benefit of those who have not seen the bug report: https://github.com/llvm/llvm-project/issues/61635
Did you look into fixing this within checkFunctionOrMethodParameterIndex() instead? That way, all callers of the API get the correct behavior instead of having to find individual attributes to check the logic (I believe there are other attributes with the same underlying problem).