clang-tidy/rename_check.py misc-incorrect-roundings bugprone-incorrect-roundings
More specifically,
clang-tidy/rename_check.py misc-incorrect-roundings \
bugprone-incorrect-roundings --check_class_name IncorrectRoundings
llvm-svn: 323768
GitOrigin-RevId: 4256fd0b4b85598f9b47308d15715a5b4f1e1813
diff --git a/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tidy/bugprone/BugproneTidyModule.cpp
index d17eb27..3b73142 100644
--- a/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/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 @@
"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-tidy/bugprone/CMakeLists.txt b/clang-tidy/bugprone/CMakeLists.txt
index dab77bd..11b66c6 100644
--- a/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tidy/bugprone/CMakeLists.txt
@@ -10,6 +10,7 @@
FoldInitTypeCheck.cpp
ForwardDeclarationNamespaceCheck.cpp
InaccurateEraseCheck.cpp
+ IncorrectRoundingsCheck.cpp
IntegerDivisionCheck.cpp
MisplacedOperatorInStrlenInAllocCheck.cpp
MoveForwardingReferenceCheck.cpp
diff --git a/clang-tidy/misc/IncorrectRoundings.cpp b/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp
similarity index 86%
rename from clang-tidy/misc/IncorrectRoundings.cpp
rename to clang-tidy/bugprone/IncorrectRoundingsCheck.cpp
index 7f9b90b..ab7b28d 100644
--- a/clang-tidy/misc/IncorrectRoundings.cpp
+++ b/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 @@
namespace clang {
namespace tidy {
-namespace misc {
+namespace bugprone {
namespace {
AST_MATCHER(FloatingLiteral, floatHalf) {
@@ -31,7 +31,7 @@
}
} // 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 @@
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-tidy/misc/IncorrectRoundings.h b/clang-tidy/bugprone/IncorrectRoundingsCheck.h
similarity index 82%
rename from clang-tidy/misc/IncorrectRoundings.h
rename to clang-tidy/bugprone/IncorrectRoundingsCheck.h
index 7b5f6a0..652cb52 100644
--- a/clang-tidy/misc/IncorrectRoundings.h
+++ b/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 @@
/// 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-tidy/misc/CMakeLists.txt b/clang-tidy/misc/CMakeLists.txt
index 9d67958..ecb071f 100644
--- a/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tidy/misc/CMakeLists.txt
@@ -6,7 +6,6 @@
MisplacedConstCheck.cpp
UnconventionalAssignOperatorCheck.cpp
DefinitionsInHeadersCheck.cpp
- IncorrectRoundings.cpp
MacroParenthesesCheck.cpp
MacroRepeatedSideEffectsCheck.cpp
MiscTidyModule.cpp
diff --git a/clang-tidy/misc/MiscTidyModule.cpp b/clang-tidy/misc/MiscTidyModule.cpp
index ef99faf..3e25f01 100644
--- a/clang-tidy/misc/MiscTidyModule.cpp
+++ b/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 @@
"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/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index 3a67dc3..fb5536c 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -57,6 +57,9 @@
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/docs/clang-tidy/checks/misc-incorrect-roundings.rst b/docs/clang-tidy/checks/bugprone-incorrect-roundings.rst
similarity index 79%
rename from docs/clang-tidy/checks/misc-incorrect-roundings.rst
rename to docs/clang-tidy/checks/bugprone-incorrect-roundings.rst
index be04f6c..0a5047a 100644
--- a/docs/clang-tidy/checks/misc-incorrect-roundings.rst
+++ b/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/docs/clang-tidy/checks/list.rst b/docs/clang-tidy/checks/list.rst
index f7616bc..7bc1dbd 100644
--- a/docs/clang-tidy/checks/list.rst
+++ b/docs/clang-tidy/checks/list.rst
@@ -25,6 +25,7 @@
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 @@
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/test/clang-tidy/misc-incorrect-roundings.cpp b/test/clang-tidy/bugprone-incorrect-roundings.cpp
similarity index 96%
rename from test/clang-tidy/misc-incorrect-roundings.cpp
rename to test/clang-tidy/bugprone-incorrect-roundings.cpp
index ae8638d..7ada061 100644
--- a/test/clang-tidy/misc-incorrect-roundings.cpp
+++ b/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 @@
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);