summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs/clang-tidy
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2016-02-08 10:16:13 +0000
committerHaojian Wu <hokein@google.com>2016-02-08 10:16:13 +0000
commit25779e404b08eb92ff409a8f38080f3e46575bb7 (patch)
tree928d5a36135bccdab2938737b8cf487ba6d3d31e /clang-tools-extra/docs/clang-tidy
parente1bfc2e793d9f9b529031ca0e19f06a3340ee5fc (diff)
downloadbcm5719-llvm-25779e404b08eb92ff409a8f38080f3e46575bb7.tar.gz
bcm5719-llvm-25779e404b08eb92ff409a8f38080f3e46575bb7.zip
[clang-tidy] Move incorrect-roundings to upstream.
Summary: This is originally implemented by Jacques Pienaar. Reviewers: alexfh Subscribers: cfe-commits, jpienaar Differential Revision: http://reviews.llvm.org/D16764 llvm-svn: 260084
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy')
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst1
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/misc-incorrect-roundings.rst12
2 files changed, 13 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index aca429b0e43..42f7cf39022 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -49,6 +49,7 @@ Clang-Tidy Checks
misc-bool-pointer-implicit-conversion
misc-definitions-in-headers
misc-inaccurate-erase
+ misc-incorrect-roundings
misc-inefficient-algorithm
misc-macro-parentheses
misc-macro-repeated-side-effects
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-incorrect-roundings.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-incorrect-roundings.rst
new file mode 100644
index 00000000000..abe70b412b2
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc-incorrect-roundings.rst
@@ -0,0 +1,12 @@
+misc-incorrect-roundings
+========================
+
+Checks the usage of patterns known to produce incorrect rounding.
+Programmers often use
+ (int)(double_expression + 0.5)
+to round the double expression to an integer. The problem with this:
+
+1. It is unnecessarily slow.
+2. It is incorrect. The number 0.499999975 (smallest representable float
+ number below 0.5) rounds to 1.0. Even worse behavior for negative
+ numbers where both -0.5f and -1.4f both round to 0.0.
OpenPOWER on IntegriCloud