[PATCH] D41816: [analyzer] Model and check unrepresentable left shifts

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 03:01:13 PST 2018


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 cases symbolically, but I believe it is perfectly fine to have that in a separate patch.



================
Comment at: lib/StaticAnalyzer/Core/BasicValueFactory.cpp:238
 
+      if (V1.isSigned() && (unsigned) Amt > V1.countLeadingZeros())
+          return nullptr;
----------------
Do you get a warning if you remove the cast above? I am not sure that we actually want to have the cast here.


https://reviews.llvm.org/D41816





More information about the cfe-commits mailing list