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 | ||
---|---|---|
1453 | ||
1454–1456 | The comment says that it would work with both - and ~. | |
1457–1458 | ||
1464 | This SymMgr is acquired multiple times. We could hoist it and use it everywhere. | |
clang/test/Analysis/constraint_manager_negate.c | ||
16–20 | We can probably spare the unimportant stuff. | |
23–24 | Why don't you use assert(-a > 0) here? It should be equivalent. Same for the rest. | |
27–29 | 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. | |
46 | Let's also assert a == INT_MIN just for the symmetry. | |
69–73 | Sweet!! | |
76 | Well, this is the third form of expressing constraints.
Please, settle on one method. | |
87–88 | Add an equality comparison which results in TRUE. | |
92–98 | 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. | |
100–105 | I believe the eval query can be sharper than this. |
No worries, thank you for being assiduous.
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | ||
---|---|---|
1454–1456 | 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 | ||
27–29 | 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}} | |
46 | That would be superfluous in my opinion, since I have changed the if to an assert(a == INT_MIN); | |
76 | Ok, I changed to assert everywhere. | |
87–88 | Sure. | |
100–105 | Ok. |