clang 23.0.0git
clang::analyze_printf::ArgType Class Reference

#include "clang/AST/FormatString.h"

Public Types

enum  Kind {
  UnknownTy , InvalidTy , UnsupportedTy , SpecificTy ,
  ObjCPointerTy , CPointerTy , AnyCharTy , CStrTy ,
  WCStrTy , WIntTy
}
enum  MatchKind {
  NoMatch = 0 , Match = 1 , MatchPromotion , NoMatchPromotionTypeConfusion ,
  NoMatchPedantic , NoMatchSignedness , NoMatchTypeConfusion
}
 How well a given conversion specifier matches its argument. More...

Public Member Functions

 ArgType (Kind K=UnknownTy, const char *N=nullptr)
 ArgType (QualType T, const char *N=nullptr)
 ArgType (CanQualType T)
bool isValid () const
bool isUnsupported () const
bool isSizeT () const
bool isPtrdiffT () const
MatchKind matchesType (ASTContext &C, QualType argTy) const
MatchKind matchesArgType (ASTContext &C, const ArgType &other) const
QualType getRepresentativeType (ASTContext &C) const
ArgType makeVectorType (ASTContext &C, unsigned NumElts) const
std::string getRepresentativeTypeName (ASTContext &C) const

Static Public Member Functions

static ArgType Invalid ()
static ArgType Unsupported (const char *N)
static ArgType PtrTo (const ArgType &A)
 Create an ArgType which corresponds to the type pointer to A.
static ArgType makeSizeT (const ArgType &A)
 Create an ArgType which corresponds to the size_t/ssize_t type.
static ArgType makePtrdiffT (const ArgType &A)
 Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t type.
static ArgType makeIntNType (ASTContext &Ctx, const LengthModifier &LengthMod, bool Signed)

Detailed Description

Definition at line 278 of file FormatString.h.

Member Enumeration Documentation

◆ Kind

Enumerator
UnknownTy 
InvalidTy 
UnsupportedTy 
SpecificTy 
ObjCPointerTy 
CPointerTy 
AnyCharTy 
CStrTy 
WCStrTy 
WIntTy 

Definition at line 280 of file FormatString.h.

◆ MatchKind

How well a given conversion specifier matches its argument.

Enumerator
NoMatch 

The conversion specifier and the argument types are incompatible.

For instance, "%d" and float.

Match 

The conversion specifier and the argument type are compatible.

For instance, "%d" and int.

MatchPromotion 

The conversion specifier and the argument type are compatible because of default argument promotions.

For instance, "%hhd" and int.

NoMatchPromotionTypeConfusion 

The conversion specifier and the argument type are compatible but still seems likely to be an error.

For instanace, "%hhd" and short.

NoMatchPedantic 

The conversion specifier and the argument type are disallowed by the C standard, but are in practice harmless.

For instance, "%p" and int*.

NoMatchSignedness 

The conversion specifier and the argument type have different sign.

NoMatchTypeConfusion 

The conversion specifier and the argument type are compatible, but still seems likely to be an error.

For instance, "%hd" and _Bool.

Definition at line 294 of file FormatString.h.

Constructor & Destructor Documentation

◆ ArgType() [1/3]

clang::analyze_format_string::ArgType::ArgType ( Kind K = UnknownTy,
const char * N = nullptr )
inline

Definition at line 337 of file FormatString.h.

◆ ArgType() [2/3]

clang::analyze_format_string::ArgType::ArgType ( QualType T,
const char * N = nullptr )
inline

Definition at line 338 of file FormatString.h.

◆ ArgType() [3/3]

clang::analyze_format_string::ArgType::ArgType ( CanQualType T)
inline

Definition at line 339 of file FormatString.h.

Member Function Documentation

◆ getRepresentativeType()

QualType ArgType::getRepresentativeType ( ASTContext & C) const

Definition at line 852 of file FormatString.cpp.

◆ getRepresentativeTypeName()

std::string ArgType::getRepresentativeTypeName ( ASTContext & C) const

Definition at line 894 of file FormatString.cpp.

◆ Invalid()

ArgType clang::analyze_format_string::ArgType::Invalid ( )
inlinestatic

Definition at line 341 of file FormatString.h.

Referenced by clang::analyze_printf::PrintfSpecifier::getArgType().

◆ isPtrdiffT()

bool clang::analyze_format_string::ArgType::isPtrdiffT ( ) const
inline

Definition at line 352 of file FormatString.h.

◆ isSizeT()

bool clang::analyze_format_string::ArgType::isSizeT ( ) const
inline

Definition at line 350 of file FormatString.h.

◆ isUnsupported()

bool clang::analyze_format_string::ArgType::isUnsupported ( ) const
inline

Definition at line 348 of file FormatString.h.

◆ isValid()

bool clang::analyze_format_string::ArgType::isValid ( ) const
inline

Definition at line 347 of file FormatString.h.

◆ makeIntNType()

ArgType ArgType::makeIntNType ( ASTContext & Ctx,
const LengthModifier & LengthMod,
bool Signed )
static

Definition at line 836 of file FormatString.cpp.

◆ makePtrdiffT()

ArgType clang::analyze_format_string::ArgType::makePtrdiffT ( const ArgType & A)
inlinestatic

Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t type.

Definition at line 371 of file FormatString.h.

◆ makeSizeT()

ArgType clang::analyze_format_string::ArgType::makeSizeT ( const ArgType & A)
inlinestatic

Create an ArgType which corresponds to the size_t/ssize_t type.

Definition at line 363 of file FormatString.h.

◆ makeVectorType()

ArgType ArgType::makeVectorType ( ASTContext & C,
unsigned NumElts ) const

Definition at line 827 of file FormatString.cpp.

◆ matchesArgType()

analyze_format_string::ArgType::MatchKind ArgType::matchesArgType ( ASTContext & C,
const ArgType & other ) const

Definition at line 745 of file FormatString.cpp.

◆ matchesType()

clang::analyze_format_string::ArgType::MatchKind ArgType::matchesType ( ASTContext & C,
QualType argTy ) const

Definition at line 445 of file FormatString.cpp.

◆ PtrTo()

ArgType clang::analyze_format_string::ArgType::PtrTo ( const ArgType & A)
inlinestatic

Create an ArgType which corresponds to the type pointer to A.

Definition at line 355 of file FormatString.h.

◆ Unsupported()

ArgType clang::analyze_format_string::ArgType::Unsupported ( const char * N)
inlinestatic

Definition at line 342 of file FormatString.h.


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