diff options
| -rw-r--r-- | clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp | 3 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp (renamed from clang-tools-extra/clang-tidy/misc/IncorrectRoundings.cpp) | 12 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.h (renamed from clang-tools-extra/clang-tidy/misc/IncorrectRoundings.h) | 10 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/misc/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp | 3 | ||||
| -rw-r--r-- | clang-tools-extra/docs/ReleaseNotes.rst | 3 | ||||
| -rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/bugprone-incorrect-roundings.rst (renamed from clang-tools-extra/docs/clang-tidy/checks/misc-incorrect-roundings.rst) | 6 | ||||
| -rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/list.rst | 2 | ||||
| -rw-r--r-- | clang-tools-extra/test/clang-tidy/bugprone-incorrect-roundings.cpp (renamed from clang-tools-extra/test/clang-tidy/misc-incorrect-roundings.cpp) | 4 |
10 files changed, 24 insertions, 21 deletions
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp index d17eb27c4fb..3b7314298d7 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -18,6 +18,7 @@ #include "FoldInitTypeCheck.h" #include "ForwardDeclarationNamespaceCheck.h" #include "InaccurateEraseCheck.h" +#include "IncorrectRoundingsCheck.h" #include "IntegerDivisionCheck.h" #include "MisplacedOperatorInStrlenInAllocCheck.h" #include "MoveForwardingReferenceCheck.h" @@ -51,6 +52,8 @@ public: "bugprone-forward-declaration-namespace"); CheckFactories.registerCheck<InaccurateEraseCheck>( "bugprone-inaccurate-erase"); + CheckFactories.registerCheck<IncorrectRoundingsCheck>( + "bugprone-incorrect-roundings"); CheckFactories.registerCheck<IntegerDivisionCheck>( "bugprone-integer-division"); CheckFactories.registerCheck<MisplacedOperatorInStrlenInAllocCheck>( diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt index dab77bda3c4..11b66c64da3 100644 --- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt @@ -10,6 +10,7 @@ add_clang_library(clangTidyBugproneModule FoldInitTypeCheck.cpp ForwardDeclarationNamespaceCheck.cpp InaccurateEraseCheck.cpp + IncorrectRoundingsCheck.cpp IntegerDivisionCheck.cpp MisplacedOperatorInStrlenInAllocCheck.cpp MoveForwardingReferenceCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/IncorrectRoundings.cpp b/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp index 7f9b90b8320..ab7b28d69f4 100644 --- a/clang-tools-extra/clang-tidy/misc/IncorrectRoundings.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp @@ -1,4 +1,4 @@ -//===--- IncorrectRoundings.cpp - clang-tidy ------------------------------===// +//===--- IncorrectRoundingsCheck.cpp - clang-tidy ------------------------------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "IncorrectRoundings.h" +#include "IncorrectRoundingsCheck.h" #include "clang/AST/DeclBase.h" #include "clang/AST/Type.h" #include "clang/ASTMatchers/ASTMatchFinder.h" @@ -18,7 +18,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace bugprone { namespace { AST_MATCHER(FloatingLiteral, floatHalf) { @@ -31,7 +31,7 @@ AST_MATCHER(FloatingLiteral, floatHalf) { } } // namespace -void IncorrectRoundings::registerMatchers(MatchFinder *MatchFinder) { +void IncorrectRoundingsCheck::registerMatchers(MatchFinder *MatchFinder) { // Match a floating literal with value 0.5. auto FloatHalf = floatLiteral(floatHalf()); @@ -59,13 +59,13 @@ void IncorrectRoundings::registerMatchers(MatchFinder *MatchFinder) { this); } -void IncorrectRoundings::check(const MatchFinder::MatchResult &Result) { +void IncorrectRoundingsCheck::check(const MatchFinder::MatchResult &Result) { const auto *CastExpr = Result.Nodes.getNodeAs<ImplicitCastExpr>("CastExpr"); diag(CastExpr->getLocStart(), "casting (double + 0.5) to integer leads to incorrect rounding; " "consider using lround (#include <cmath>) instead"); } -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/IncorrectRoundings.h b/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.h index 7b5f6a0a203..652cb52082c 100644 --- a/clang-tools-extra/clang-tidy/misc/IncorrectRoundings.h +++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.h @@ -1,4 +1,4 @@ -//===--- IncorrectRoundings.h - clang-tidy ----------------------*- C++ -*-===// +//===--- IncorrectRoundingsCheckCheck.h - clang-tidy -----------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,7 +14,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace bugprone { /// \brief Checks the usage of patterns known to produce incorrect rounding. /// Programmers often use @@ -24,15 +24,15 @@ namespace misc { /// 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. -class IncorrectRoundings : public ClangTidyCheck { +class IncorrectRoundingsCheck : public ClangTidyCheck { public: - IncorrectRoundings(StringRef Name, ClangTidyContext *Context) + IncorrectRoundingsCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context) {} void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace bugprone } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt index 9d679582507..ecb071f9269 100644 --- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt @@ -6,7 +6,6 @@ add_clang_library(clangTidyMiscModule MisplacedConstCheck.cpp UnconventionalAssignOperatorCheck.cpp DefinitionsInHeadersCheck.cpp - IncorrectRoundings.cpp MacroParenthesesCheck.cpp MacroRepeatedSideEffectsCheck.cpp MiscTidyModule.cpp diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp index ef99fafa218..3e25f01d3dd 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp @@ -12,7 +12,6 @@ #include "../ClangTidyModuleRegistry.h" #include "DefinitionsInHeadersCheck.h" #include "ForwardingReferenceOverloadCheck.h" -#include "IncorrectRoundings.h" #include "LambdaFunctionNameCheck.h" #include "MacroParenthesesCheck.h" #include "MacroRepeatedSideEffectsCheck.h" @@ -56,8 +55,6 @@ public: "misc-unconventional-assign-operator"); CheckFactories.registerCheck<DefinitionsInHeadersCheck>( "misc-definitions-in-headers"); - CheckFactories.registerCheck<IncorrectRoundings>( - "misc-incorrect-roundings"); CheckFactories.registerCheck<MacroParenthesesCheck>( "misc-macro-parentheses"); CheckFactories.registerCheck<MacroRepeatedSideEffectsCheck>( diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 3a67dc317e5..fb5536c2670 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -57,6 +57,9 @@ The improvements are... Improvements to clang-tidy -------------------------- +- The 'misc-incorrect-roundings' check was renamed to `bugprone-incorrect-roundings + <http://clang.llvm.org/extra/clang-tidy/checks/bugprone-incorrect-roundings.html>`_ + - The 'misc-string-compare' check was renamed to `readability-string-compare <http://clang.llvm.org/extra/clang-tidy/checks/readability-string-compare.html>`_ diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-incorrect-roundings.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-incorrect-roundings.rst index be04f6cf1e1..0a5047a9f0f 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-incorrect-roundings.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-incorrect-roundings.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-incorrect-roundings +.. title:: clang-tidy - bugprone-incorrect-roundings -misc-incorrect-roundings -======================== +bugprone-incorrect-roundings +============================ Checks the usage of patterns known to produce incorrect rounding. Programmers often use:: diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index f7616bc6e0d..7bc1dbd5ea3 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -25,6 +25,7 @@ Clang-Tidy Checks bugprone-fold-init-type bugprone-forward-declaration-namespace bugprone-inaccurate-erase + bugprone-incorrect-roundings bugprone-integer-division bugprone-misplaced-operator-in-strlen-in-alloc bugprone-move-forwarding-reference @@ -126,7 +127,6 @@ Clang-Tidy Checks llvm-twine-local misc-definitions-in-headers misc-forwarding-reference-overload - misc-incorrect-roundings misc-lambda-function-name misc-macro-parentheses misc-macro-repeated-side-effects diff --git a/clang-tools-extra/test/clang-tidy/misc-incorrect-roundings.cpp b/clang-tools-extra/test/clang-tidy/bugprone-incorrect-roundings.cpp index ae8638db02c..7ada0616cc8 100644 --- a/clang-tools-extra/test/clang-tidy/misc-incorrect-roundings.cpp +++ b/clang-tools-extra/test/clang-tidy/bugprone-incorrect-roundings.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-incorrect-roundings %t +// RUN: %check_clang_tidy %s bugprone-incorrect-roundings %t void b(int x) {} @@ -9,7 +9,7 @@ void f1() { int x; x = (d + 0.5); - // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead [misc-incorrect-roundings] + // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead [bugprone-incorrect-roundings] x = (d + 0.5f); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5) x = (f + 0.5); |

