clang-tools 19.0.0git
Classes | Public Types | Public Member Functions | List of all members
clang::tidy::utils::FormatStringConverter Class Reference

Convert a printf-style format string to a std::formatter-style one, and prepare any casts that are required to wrap the arguments to retain printf compatibility. More...

#include <FormatStringConverter.h>

Inheritance diagram for clang::tidy::utils::FormatStringConverter:
Inheritance graph
[legend]

Classes

struct  Configuration
 

Public Types

using ConversionSpecifier = clang::analyze_format_string::ConversionSpecifier
 
using PrintfSpecifier = analyze_printf::PrintfSpecifier
 

Public Member Functions

 FormatStringConverter (ASTContext *Context, const CallExpr *Call, unsigned FormatArgOffset, Configuration Config, const LangOptions &LO)
 
bool canApply () const
 
const std::string & conversionNotPossibleReason () const
 
void applyFixes (DiagnosticBuilder &Diag, SourceManager &SM)
 Called by the check when it is ready to apply the fixes.
 
bool usePrintNewlineFunction () const
 

Detailed Description

Convert a printf-style format string to a std::formatter-style one, and prepare any casts that are required to wrap the arguments to retain printf compatibility.

This class is expecting to work on the already-cooked format string (i.e. all the escapes have been converted) so we have to convert them back. This means that we might not convert them back using the same form.

Definition at line 30 of file FormatStringConverter.h.

Member Typedef Documentation

◆ ConversionSpecifier

using clang::tidy::utils::FormatStringConverter::ConversionSpecifier = clang::analyze_format_string::ConversionSpecifier

Definition at line 33 of file FormatStringConverter.h.

◆ PrintfSpecifier

using clang::tidy::utils::FormatStringConverter::PrintfSpecifier = analyze_printf::PrintfSpecifier

Definition at line 34 of file FormatStringConverter.h.

Constructor & Destructor Documentation

◆ FormatStringConverter()

clang::tidy::utils::FormatStringConverter::FormatStringConverter ( ASTContext *  Context,
const CallExpr *  Call,
unsigned  FormatArgOffset,
Configuration  Config,
const LangOptions &  LO 
)

Definition at line 198 of file FormatStringConverter.cpp.

Member Function Documentation

◆ applyFixes()

void clang::tidy::utils::FormatStringConverter::applyFixes ( DiagnosticBuilder &  Diag,
SourceManager &  SM 
)

Called by the check when it is ready to apply the fixes.

Definition at line 694 of file FormatStringConverter.cpp.

References Offset, and clang::tidy::utils::withoutCStrReplacement().

Referenced by clang::tidy::modernize::UseStdFormatCheck::check(), and clang::tidy::modernize::UseStdPrintCheck::check().

◆ canApply()

bool clang::tidy::utils::FormatStringConverter::canApply ( ) const
inline

◆ conversionNotPossibleReason()

const std::string & clang::tidy::utils::FormatStringConverter::conversionNotPossibleReason ( ) const
inline

◆ usePrintNewlineFunction()

bool clang::tidy::utils::FormatStringConverter::usePrintNewlineFunction ( ) const
inline

The documentation for this class was generated from the following files: