#include "UseConstraintsCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"
#include "../utils/LexerUtils.h"
#include <optional>
#include <utility>
usingnamespaceclang::ast_matchers;
namespace clang::tidy::modernize {
struct EnableIfData { … };
namespace {
AST_MATCHER(FunctionDecl, hasOtherDeclarations) { … }
}
void UseConstraintsCheck::registerMatchers(MatchFinder *Finder) { … }
static std::optional<TemplateSpecializationTypeLoc>
matchEnableIfSpecializationImplTypename(TypeLoc TheType) { … }
static std::optional<TemplateSpecializationTypeLoc>
matchEnableIfSpecializationImplTrait(TypeLoc TheType) { … }
static std::optional<TemplateSpecializationTypeLoc>
matchEnableIfSpecializationImpl(TypeLoc TheType) { … }
static std::optional<EnableIfData>
matchEnableIfSpecialization(TypeLoc TheType) { … }
static std::pair<std::optional<EnableIfData>, const Decl *>
matchTrailingTemplateParam(const FunctionTemplateDecl *FunctionTemplate) { … }
template <typename T>
static SourceLocation getRAngleFileLoc(const SourceManager &SM,
const T &Element) { … }
static SourceRange
getConditionRange(ASTContext &Context,
const TemplateSpecializationTypeLoc &EnableIf) { … }
static SourceRange getTypeRange(ASTContext &Context,
const TemplateSpecializationTypeLoc &EnableIf) { … }
static std::optional<StringRef>
getTypeText(ASTContext &Context,
const TemplateSpecializationTypeLoc &EnableIf) { … }
static std::optional<SourceLocation>
findInsertionForConstraint(const FunctionDecl *Function, ASTContext &Context) { … }
bool isPrimaryExpression(const Expr *Expression) { … }
static std::optional<std::string> getConditionText(const Expr *ConditionExpr,
SourceRange ConditionRange,
ASTContext &Context) { … }
static std::vector<FixItHint> handleReturnType(const FunctionDecl *Function,
const TypeLoc &ReturnType,
const EnableIfData &EnableIf,
ASTContext &Context) { … }
static std::vector<FixItHint>
handleTrailingTemplateType(const FunctionTemplateDecl *FunctionTemplate,
const FunctionDecl *Function,
const Decl *LastTemplateParam,
const EnableIfData &EnableIf, ASTContext &Context) { … }
void UseConstraintsCheck::check(const MatchFinder::MatchResult &Result) { … }
}