[PATCH] D92634: [Analyzer] Diagnose signed integer overflow

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 5 04:55:46 PST 2021


steakhal added a comment.

In D92634#2478503 <https://reviews.llvm.org/D92634#2478503>, @OikawaKirie wrote:

> Besides, as far as I am thinking, the compiler optimizes the expression as it is literally inferable, i.e. the result should be determinable literally during compilation. Otherwise, it will be computed during runtime. Therefore I suggest you can do a similar check with the ASTMatcher, since the `and` and `or` conjunctions will be removed in the CFG.

I disagree on this.
You can never be sure if a given function gets inlined or not, thus the context does matter for compiler optimizations. The given value might get constant folded and get the comparison/branch optimized away.
In a path sensitive way, we will always suffer from the limitations of the constraint solver.

> BTW, I cannot optimize function f to returning zero directly with GCC-10.2.1 and Clang-10.0.1 under -O3. Should I add any other flags? Or it is version specific?

I don't think we should depend on implementation details.
The only flag I would consider though if the `-fwarpv` as that defines the concrete semantics.

---

I also agree with @NoQ's D92634#2478703 <https://reviews.llvm.org/D92634#2478703> comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92634/new/

https://reviews.llvm.org/D92634



More information about the cfe-commits mailing list