[PATCH] D33672: [analyzer] INT50-CPP. Do not cast to an out-of-range enumeration checker

Endre Fülöp via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 05:16:24 PDT 2017


gamesh411 updated this revision to Diff 112154.
gamesh411 added a comment.

I have implemented the std::transform. The previous version used std::for_each because the iterator for enum declarations was not a random access iterator, but it turned out that I can solve this problem via std::distance. Thanks for sticking to your opinion on this one, because I could learn something new.

As for the type size checking problem: I have noticed that there is already a generic overflow checker, and that would detect the the 'assigning invalid value to an enum' problem. The only advantage of doing it here is that we could probably give a more specific error diagnostic (then again this could be done in the overflow checker as well). So in my opinion that concern belongs there, and this checker should nevertheless belong in the generic optin package, because of the c-style cast is also checked in it.


https://reviews.llvm.org/D33672

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp
  test/Analysis/enum-cast-out-of-range.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33672.112154.patch
Type: text/x-patch
Size: 21991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170822/2a488816/attachment-0001.bin>


More information about the cfe-commits mailing list