Skip to content

Commit 0eb7d53

Browse files
5chmidtiPiotrZSL
authored andcommitted
[clang-tidy] add modernize-use-std-numbers (#66583)
Finds constants and function calls to math functions that can be replaced with c++20's mathematical constants from the 'numbers' header and offers fix-it hints. Does not match the use of variables with that value, and instead, offers a replacement at the definition of those variables.
1 parent b4e1915 commit 0eb7d53

File tree

8 files changed

+1077
-0
lines changed

8 files changed

+1077
-0
lines changed

clang-tools-extra/clang-tidy/modernize/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ add_clang_library(clangTidyModernizeModule
3939
UseNullptrCheck.cpp
4040
UseOverrideCheck.cpp
4141
UseStartsEndsWithCheck.cpp
42+
UseStdNumbersCheck.cpp
4243
UseStdPrintCheck.cpp
4344
UseTrailingReturnTypeCheck.cpp
4445
UseTransparentFunctorsCheck.cpp

clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "UseNullptrCheck.h"
4141
#include "UseOverrideCheck.h"
4242
#include "UseStartsEndsWithCheck.h"
43+
#include "UseStdNumbersCheck.h"
4344
#include "UseStdPrintCheck.h"
4445
#include "UseTrailingReturnTypeCheck.h"
4546
#include "UseTransparentFunctorsCheck.h"
@@ -69,6 +70,8 @@ class ModernizeModule : public ClangTidyModule {
6970
CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");
7071
CheckFactories.registerCheck<UseStartsEndsWithCheck>(
7172
"modernize-use-starts-ends-with");
73+
CheckFactories.registerCheck<UseStdNumbersCheck>(
74+
"modernize-use-std-numbers");
7275
CheckFactories.registerCheck<UseStdPrintCheck>("modernize-use-std-print");
7376
CheckFactories.registerCheck<RawStringLiteralCheck>(
7477
"modernize-raw-string-literal");

0 commit comments

Comments
 (0)