[clang-tools-extra] e1fa2fe - [clang-tidy][NFC] Change ArrayRef into std::vector in modernize-use-std-numbers
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 6 12:51:02 PST 2023
Author: Piotr Zegar
Date: 2023-12-06T20:50:48Z
New Revision: e1fa2fea03ff94627008054267a244744d76b5c2
URL: https://github.com/llvm/llvm-project/commit/e1fa2fea03ff94627008054267a244744d76b5c2
DIFF: https://github.com/llvm/llvm-project/commit/e1fa2fea03ff94627008054267a244744d76b5c2.diff
LOG: [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.
Added:
Modified:
clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
index 1f2b034713ecf..b299afd540b9a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
@@ -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"
@@ -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;
@@ -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(),
@@ -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"),
More information about the cfe-commits
mailing list