[clang] [clang-tools-extra] [clang-tidy] bugprone-implicit-widening ignores unsigned consts (PR #101073)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 11:08:37 PDT 2024
https://github.com/AaronBallman commented:
Thank you for this, I think the clang-tidy portions make a lot of sense. However, I do have concerns about the changes to Clang. I don't think we want constant expression evaluation to fail based on an input parameter. For one, it's a bit odd because the constant expression is valid. But also, I don't think it will scale well if we want to add additional constraints on the evaluation in the future.
I think a better approach would be a new interface which doesn't return the `APValue`/`APSInt` directly, but instead returns something more like:
```
struct EvalResult {
APValue Value;
unsigned UnsignedWraparoundOccurred : 1;
unsigned VLAWasUsed : 1; // Just an example, not a real suggestion
unsigned DidSomeOtherQuestionableThing : 1; // Also an example :-)
};
```
This way, we can track whatever interesting details we want regarding the computation of the resulting value in a more extensible way, and we don't need to fail the constant expression evaluation itself.
CC @tbaederr who may also have opinions on constant expression evaluations or alternative ideas to consider
https://github.com/llvm/llvm-project/pull/101073
More information about the cfe-commits
mailing list