Skip to content

Commit

Permalink
[clang-tidy][NFC] Change ArrayRef into std::vector in modernize-use-s…
Browse files Browse the repository at this point in the history
…td-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.
  • Loading branch information
PiotrZSL committed Dec 6, 2023
1 parent 0eb7d53 commit e1fa2fe
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -61,8 +60,8 @@ AST_MATCHER(clang::QualType, isFloating) {
return !Node.isNull() && Node->isFloatingType();
}

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

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

Finder->addMatcher(
expr(
anyOfExhaustive(ConstantMatchers),
anyOfExhaustive(std::move(ConstantMatchers)),
unless(hasParent(explicitCastExpr(hasDestinationType(isFloating())))),
hasType(qualType(hasCanonicalTypeUnqualified(
anyOf(qualType(asString("float")).bind("float"),
Expand Down

0 comments on commit e1fa2fe

Please sign in to comment.