Skip to content

Commit e1fa2fe

Browse files
committed
[clang-tidy][NFC] Change ArrayRef into std::vector in modernize-use-std-numbers
To avoid compiler errors on some platforms introduced by #66583, now using std::vector to pass list of matchers into main matcher, and removed static variable as it could introduce some other issues.
1 parent 0eb7d53 commit e1fa2fe

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "clang/Basic/SourceLocation.h"
2424
#include "clang/Basic/SourceManager.h"
2525
#include "clang/Lex/Lexer.h"
26-
#include "llvm/ADT/ArrayRef.h"
2726
#include "llvm/ADT/STLExtras.h"
2827
#include "llvm/ADT/SmallVector.h"
2928
#include "llvm/ADT/StringRef.h"
@@ -61,8 +60,8 @@ AST_MATCHER(clang::QualType, isFloating) {
6160
return !Node.isNull() && Node->isFloatingType();
6261
}
6362

64-
AST_MATCHER_P(clang::Expr, anyOfExhaustive,
65-
llvm::ArrayRef<Matcher<clang::Stmt>>, Exprs) {
63+
AST_MATCHER_P(clang::Expr, anyOfExhaustive, std::vector<Matcher<clang::Stmt>>,
64+
Exprs) {
6665
bool FoundMatch = false;
6766
for (const auto &InnerMatcher : Exprs) {
6867
clang::ast_matchers::internal::BoundNodesTreeBuilder Result = *Builder;
@@ -304,7 +303,7 @@ UseStdNumbersCheck::UseStdNumbersCheck(const StringRef Name,
304303

305304
void UseStdNumbersCheck::registerMatchers(MatchFinder *const Finder) {
306305
const auto Matches = MatchBuilder{DiffThreshold};
307-
static const auto ConstantMatchers = {
306+
std::vector<Matcher<clang::Stmt>> ConstantMatchers = {
308307
Matches.matchLog2Euler(), Matches.matchLog10Euler(),
309308
Matches.matchEulerTopLevel(), Matches.matchEgamma(),
310309
Matches.matchInvSqrtPi(), Matches.matchInvPi(),
@@ -316,7 +315,7 @@ void UseStdNumbersCheck::registerMatchers(MatchFinder *const Finder) {
316315

317316
Finder->addMatcher(
318317
expr(
319-
anyOfExhaustive(ConstantMatchers),
318+
anyOfExhaustive(std::move(ConstantMatchers)),
320319
unless(hasParent(explicitCastExpr(hasDestinationType(isFloating())))),
321320
hasType(qualType(hasCanonicalTypeUnqualified(
322321
anyOf(qualType(asString("float")).bind("float"),

0 commit comments

Comments
 (0)