diff options
| author | Gabor Horvath <xazax.hun@gmail.com> | 2016-04-06 12:04:51 +0000 |
|---|---|---|
| committer | Gabor Horvath <xazax.hun@gmail.com> | 2016-04-06 12:04:51 +0000 |
| commit | 5273f615c40de3158330eaf0e160ecd4c4d154f4 (patch) | |
| tree | 5fd904297cef10f0e8ec48bfb863d8d742a86d25 /clang-tools-extra/docs/clang-tidy | |
| parent | 9c24ebfa6de98e78d38318216dfc972e562a0939 (diff) | |
| download | bcm5719-llvm-5273f615c40de3158330eaf0e160ecd4c4d154f4.tar.gz bcm5719-llvm-5273f615c40de3158330eaf0e160ecd4c4d154f4.zip | |
[clang-tidy] Extension of checker misc-misplaced-widening-cast
Summary:
Existing checker misc-misplaced-widening-cast was extended:
- New use cases: casted expression as lhs or rhs of a logical comparison or function argument
- New types: beside int, long and long long various char types, short and int128 added
- New option to check implicit casts: forgetting a cast is at least as common and as dangerous as misplacing it. This option can be disabled.
This patch depends on AST Matcher patches D17986 and D18243 and also contains fix for checker misc-bool-pointer-implicit-conversion needed because of the fix in the AST Matcher patch.
Reviewers: hokein, alexfh
Subscribers: o.gyorgy, xazax.hun, cfe-commits
Differential Revision: http://reviews.llvm.org/D17987
llvm-svn: 265532
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy')
| -rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst index 648d8d10abe..824f939e2ff 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst @@ -3,10 +3,10 @@ misc-misplaced-widening-cast ============================ -This check 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. +This check will warn when there is a 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. Example code:: @@ -28,6 +28,17 @@ for instance:: return (long)x * 1000; } +Implicit casts +-------------- + +Forgetting to place the cast at all is at least as dangerous and at least as +common as misplacing it. If option ``CheckImplicitCasts`` is enabled (default) +the checker also detects these cases, for instance:: + + long f(int x) { + return x * 1000; + } + Floating point -------------- |

