#include "OperatorsRepresentationCheck.h"
#include "../utils/OptionsUtils.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/STLExtras.h"
#include <array>
#include <utility>
usingnamespaceclang::ast_matchers;
namespace clang::tidy::readability {
static StringRef getOperatorSpelling(SourceLocation Loc, ASTContext &Context) { … }
namespace {
AST_MATCHER_P2(BinaryOperator, hasInvalidBinaryOperatorRepresentation,
BinaryOperatorKind, Kind, llvm::StringRef,
ExpectedRepresentation) { … }
AST_MATCHER_P2(UnaryOperator, hasInvalidUnaryOperatorRepresentation,
UnaryOperatorKind, Kind, llvm::StringRef,
ExpectedRepresentation) { … }
AST_MATCHER_P2(CXXOperatorCallExpr, hasInvalidOverloadedOperatorRepresentation,
OverloadedOperatorKind, Kind, llvm::StringRef,
ExpectedRepresentation) { … }
}
constexpr std::array<std::pair<llvm::StringRef, llvm::StringRef>, 2U>
UnaryRepresentation{ … };
constexpr std::array<std::pair<llvm::StringRef, llvm::StringRef>, 9U>
OperatorsRepresentation{ … };
static llvm::StringRef translate(llvm::StringRef Value) { … }
static bool isNotOperatorStr(llvm::StringRef Value) { … }
static bool isSeparator(char C) noexcept { … }
static bool needEscaping(llvm::StringRef Operator) { … }
static llvm::StringRef
getRepresentation(const std::vector<llvm::StringRef> &Config,
llvm::StringRef Traditional, llvm::StringRef Alternative) { … }
template <typename T>
static bool isAnyOperatorEnabled(const std::vector<llvm::StringRef> &Config,
const T &Operators) { … }
OperatorsRepresentationCheck::OperatorsRepresentationCheck(
StringRef Name, ClangTidyContext *Context)
: … { … }
void OperatorsRepresentationCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) { … }
std::optional<TraversalKind>
OperatorsRepresentationCheck::getCheckTraversalKind() const { … }
bool OperatorsRepresentationCheck::isLanguageVersionSupported(
const LangOptions &LangOpts) const { … }
void OperatorsRepresentationCheck::registerBinaryOperatorMatcher(
MatchFinder *Finder) { … }
void OperatorsRepresentationCheck::registerUnaryOperatorMatcher(
MatchFinder *Finder) { … }
void OperatorsRepresentationCheck::registerOverloadedOperatorMatcher(
MatchFinder *Finder) { … }
void OperatorsRepresentationCheck::registerMatchers(MatchFinder *Finder) { … }
void OperatorsRepresentationCheck::check(
const MatchFinder::MatchResult &Result) { … }
}