haoNoQ wrote: Welcome!!
I completely agree that the message sounds a bit too much like "your code is garbage" and that's not very nice. Here's a tangent suggestion to get a better wording out of this. You can exploit the fact that the static analyzer usually catches undefined values _very early_. In other words, undefined values typically _very short-lived_. In particular, they don't travel from one variable to another. Because, well, assigning an undefined value to a variable produces one of those warnings that you're about to patch. And when it does, it terminates the exploration of that execution path entirely. Additionally, if an arithmetic expression produces an undefined value (eg. division by zero), that's an immediate warning too, and this also terminates the execution path immediately. With that in mind, whenever you actually see an undefined value in a checker, you can safely assume that it was never "computed" or "stored" there. It was simply always there from the start. This is a sufficiently strong contract in the static analyzer; I'm not aware of any long-lived undefined values and I'd consider it a bug if I ever see a long-lived undefined value. I'm pretty sure there are a few assertions that would crash if this ever happened. So you can try to rely on this implicit contract to send a stronger message. For example: ```diff - ++x; // expected-warning{{The expression is an uninitialized value. The computed value will also be garbage}} + ++x; // expected-warning{{Uninitialized variable incremented}} ``` ```diff - int y = x; // expected-warning@-1{{Assigned value is garbage or undefined}} + int y = x; // expected-warning@-1{{Value of uninitialized variable assigned}} ``` ```diff - b.x |= 1; // expected-warning{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}} + b.x |= 1; // expected-warning{{Uninitialized variable used in compound assignment}} ``` ```diff - b.x |= 1; // expected-warning{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}} + b.x |= 1; // expected-warning{{Uninitialized variable used in compound assignment}} ``` (You might want to make a distinction between variables and fields. But even if you don't, I'm reasonably certain that you don't run into an object of any other nature. You can use the word "location" if you're worried about locations of exotic nature. But you can be fairly certain that it's always going to be *a* location, not any other source of values.) https://github.com/llvm/llvm-project/pull/126596 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits