Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Great content!
I've got a long list of nits though. Nothing personal :D
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | ||
---|---|---|
1462–1463 | This SymMgr is acquired multiple times. We could hoist it and use it everywhere. | |
1463 | ||
1464–1466 | The comment says that it would work with both - and ~. | |
1467–1468 | ||
clang/test/Analysis/constraint_manager_negate.c | ||
17–21 | We can probably spare the unimportant stuff. | |
24–25 | Why don't you use assert(-a > 0) here? It should be equivalent. Same for the rest. | |
28–30 | You can also query if the bound is sharp, by asking the same question but with a slightly different value and expect UNKNOWN. clang_analyzer_eval(a < 0); // expected-warning{{TRUE}} clang_analyzer_eval(a < -1); // expected-warning{{UNKNOWN}} I also believe that a >= INT_MIN is TRUE for all a anyway, thus it can be omitted. | |
47 | Let's also assert a == INT_MIN just for the symmetry. | |
70–74 | Sweet!! | |
77 | Well, this is the third form of expressing constraints.
Please, settle on one method. | |
88–89 | Add an equality comparison which results in TRUE. | |
93–99 | Leave a comment here that this is the only value besides zero where the negated is equal to the original value in the unsigned int domain. | |
101–106 | I believe the eval query can be sharper than this. |
No worries, thank you for being assiduous.
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | ||
---|---|---|
1464–1466 | Unfortunately, the complement operation is not implemented on the RangeSet. So, yes, in this sense the comment is misleading, I've changed it. | |
clang/test/Analysis/constraint_manager_negate.c | ||
28–30 | Okay, I changed it to something very obvious: clang_analyzer_eval(a < 0); // expected-warning{{TRUE}} clang_analyzer_eval(a > INT_MIN); // expected-warning{{TRUE}} | |
47 | That would be superfluous in my opinion, since I have changed the if to an assert(a == INT_MIN); | |
77 | Ok, I changed to assert everywhere. | |
88–89 | Sure. | |
101–106 | Ok. |