[PATCH] D16310: new clang-tidy checker misc-long-cast

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 19 02:26:22 PST 2016


danielmarjamaki created this revision.
danielmarjamaki added subscribers: cfe-commits, alexfh.

This is a new checker for clang-tidy.

This checker will warn when there is a explicit redundant cast of a calculation
result to a bigger type. If the intention of the cast is to avoid loss of
precision then the cast is misplaced, and there can be loss of precision.
Otherwise the cast is ineffective.

No warning is written when it is seen that the cast is ineffective.

I tested this on debian projects.. and I see quite little noise. in 1212 projects I got 76 warnings. The cast is either ineffective or there is loss of precision in all these cases. I don't see warnings where I think the warning is wrong. But I don't want to warn when it can be determined that the cast is just ineffective, I think that the perfect checker would be better at determining this.


http://reviews.llvm.org/D16310

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/LongCastCheck.cpp
  clang-tidy/misc/LongCastCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-long-cast.rst
  test/clang-tidy/misc-long-cast.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16310.45235.patch
Type: text/x-patch
Size: 9872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160119/8bbb1df3/attachment.bin>


More information about the cfe-commits mailing list