This revision was automatically updated to reflect the committed changes.
Closed by commit rC323115: [analyzer] Model and check unrepresentable left
shifts (authored by xazax, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D41816?vs=129905&id=130868#toc
Repository:
rC Clan
dcoughlin accepted this revision.
dcoughlin added a comment.
Looks good to me, thanks!
https://reviews.llvm.org/D41816
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
rnkovacs added inline comments.
Comment at: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp:150
+SB.getKnownValue(state, C.getSVal(B->getRHS()));
+if ((unsigned) RHS->getZExtValue() > LHS->countLeadingZeros()) {
+ OS << "The result of the left shif
rnkovacs updated this revision to Diff 129905.
rnkovacs marked an inline comment as done.
https://reviews.llvm.org/D41816
Files:
lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
lib/StaticAnalyzer/Core/BasicValueFactory.cpp
test/Analysis/bitwise-ops.c
Index: test/Analysis/bitwise-ops.c
dcoughlin added a comment.
The diagnostic text looks to me, but I do have a comment about the nested 'if'
inline.
Comment at: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp:150
+SB.getKnownValue(state, C.getSVal(B->getRHS()));
+if ((unsigned) RHS->getZE
rnkovacs updated this revision to Diff 129448.
rnkovacs added a comment.
I extended the warning message to include more information. What do you think?
https://reviews.llvm.org/D41816
Files:
lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
lib/StaticAnalyzer/Core/BasicValueFactory.cpp
t
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.
Looks great. @dcoughlin: would you approve the warning message text?
Maybe actually we could print out the exact numbers that cause the bit shift to
overflow, since we do have them when we check.
rnkovacs added a comment.
In https://reviews.llvm.org/D41816#970845, @xazax.hun wrote:
> Overall looks good to me, one comment inline. I think it is good to have
> these checks to prevent the analyzer executing undefined behavior. Maybe this
> would make it more feasible to run the analyzer wit
rnkovacs updated this revision to Diff 129071.
rnkovacs marked an inline comment as done.
https://reviews.llvm.org/D41816
Files:
lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
lib/StaticAnalyzer/Core/BasicValueFactory.cpp
test/Analysis/bitwise-ops.c
Index: test/Analysis/bitwise-ops.c
xazax.hun added a comment.
Overall looks good to me, one comment inline. I think it is good to have these
checks to prevent the analyzer executing undefined behavior. Maybe this would
make it more feasible to run the analyzer with ubsan :)
In the future, it would be great to also look for these
rnkovacs created this revision.
rnkovacs added reviewers: NoQ, dcoughlin, xazax.hun.
Herald added subscribers: a.sidorin, szepet, baloghadamsoftware, whisperity.
Left shifting a signed positive value is undefined if the result is not
representable in the unsigned version of the return type.
The
11 matches
Mail list logo