================ @@ -0,0 +1,284 @@ +//===--- UseStdNumbersCheck.cpp - clang_tidy ------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX_License_Identifier: Apache_2.0 WITH LLVM_exception +// +//===----------------------------------------------------------------------===// + +#include "UseStdNumbersCheck.h" +#include "../ClangTidyDiagnosticConsumer.h" +#include "../utils/TransformerClangTidyCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/Stmt.h" +#include "clang/AST/Type.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/ASTMatchers/ASTMatchersInternal.h" +#include "clang/ASTMatchers/ASTMatchersMacros.h" +#include "clang/Basic/LLVM.h" +#include "clang/Tooling/Transformer/RewriteRule.h" +#include "clang/Tooling/Transformer/Stencil.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/MathExtras.h" +#include <cstdint> +#include <cstdlib> +#include <string> +#include <utility> + +namespace { +using namespace clang::ast_matchers; +using clang::ast_matchers::internal::Matcher; +using clang::transformer::addInclude; +using clang::transformer::applyFirst; +using clang::transformer::ASTEdit; +using clang::transformer::cat; +using clang::transformer::changeTo; +using clang::transformer::edit; +using clang::transformer::EditGenerator; +using clang::transformer::flattenVector; +using clang::transformer::RewriteRuleWith; +using llvm::StringRef; + +constexpr auto DiffThreshold = 0.001; + +AST_MATCHER_P(clang::FloatingLiteral, near, double, Value) { + return std::abs(Node.getValueAsApproximateDouble() - Value) < DiffThreshold; +} + +AST_MATCHER_P(clang::QualType, hasCanonicalTypeUnqualified, + Matcher<clang::QualType>, InnerMatcher) { + return InnerMatcher.matches(Node->getCanonicalTypeUnqualified(), Finder, + Builder); +} + +AST_MATCHER(clang::QualType, isArithmetic) { return Node->isArithmeticType(); } ---------------- 5chmidti wrote:
done https://github.com/llvm/llvm-project/pull/66583 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits