#include "FormatStringConverter.h"
#include "../utils/FixItHintUtils.h"
#include "clang/AST/Expr.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Lex/Lexer.h"
#include "clang/Tooling/FixIt.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
usingnamespaceclang::ast_matchers;
usingnamespaceclang::analyze_printf;
namespace clang::tidy::utils {
ConversionSpecifier;
static bool isRealCharType(const clang::QualType &Ty) { … }
static std::optional<std::string>
getCorrespondingSignedTypeName(const clang::QualType &QT) { … }
static std::optional<std::string>
getCorrespondingUnsignedTypeName(const clang::QualType &QT) { … }
static std::optional<std::string>
castTypeForArgument(ConversionSpecifier::Kind ArgKind,
const clang::QualType &QT) { … }
static bool isMatchingSignedness(ConversionSpecifier::Kind ArgKind,
const clang::QualType &ArgType) { … }
namespace {
AST_MATCHER(clang::QualType, isRealChar) { … }
}
static bool castMismatchedIntegerTypes(const CallExpr *Call, bool StrictMode) { … }
FormatStringConverter::FormatStringConverter(ASTContext *ContextIn,
const CallExpr *Call,
unsigned FormatArgOffset,
const Configuration ConfigIn,
const LangOptions &LO)
: … { … }
void FormatStringConverter::emitAlignment(const PrintfSpecifier &FS,
std::string &FormatSpec) { … }
void FormatStringConverter::emitSign(const PrintfSpecifier &FS,
std::string &FormatSpec) { … }
void FormatStringConverter::emitAlternativeForm(const PrintfSpecifier &FS,
std::string &FormatSpec) { … }
void FormatStringConverter::emitFieldWidth(const PrintfSpecifier &FS,
std::string &FormatSpec) { … }
void FormatStringConverter::emitPrecision(const PrintfSpecifier &FS,
std::string &FormatSpec) { … }
void FormatStringConverter::maybeRotateArguments(const PrintfSpecifier &FS) { … }
void FormatStringConverter::emitStringArgument(unsigned ArgIndex,
const Expr *Arg) { … }
bool FormatStringConverter::emitIntegerArgument(
ConversionSpecifier::Kind ArgKind, const Expr *Arg, unsigned ArgIndex,
std::string &FormatSpec) { … }
bool FormatStringConverter::emitType(const PrintfSpecifier &FS, const Expr *Arg,
std::string &FormatSpec) { … }
bool FormatStringConverter::convertArgument(const PrintfSpecifier &FS,
const Expr *Arg,
std::string &StandardFormatString) { … }
bool FormatStringConverter::HandlePrintfSpecifier(const PrintfSpecifier &FS,
const char *StartSpecifier,
unsigned SpecifierLen,
const TargetInfo &Target) { … }
void FormatStringConverter::finalizeFormatText() { … }
void FormatStringConverter::appendFormatText(const StringRef Text) { … }
static std::string withoutCStrReplacement(const BoundNodes &CStrRemovalMatch,
ASTContext &Context) { … }
void FormatStringConverter::applyFixes(DiagnosticBuilder &Diag,
SourceManager &SM) { … }
}