clang  6.0.0svn
Public Member Functions | Static Public Member Functions | List of all members
clang::analyze_printf::PrintfSpecifier Class Reference

#include "clang/Analysis/Analyses/FormatString.h"

Inheritance diagram for clang::analyze_printf::PrintfSpecifier:
Inheritance graph
[legend]
Collaboration diagram for clang::analyze_printf::PrintfSpecifier:
Collaboration graph
[legend]

Public Member Functions

 PrintfSpecifier ()
 
void setConversionSpecifier (const PrintfConversionSpecifier &cs)
 
void setHasThousandsGrouping (const char *position)
 
void setIsLeftJustified (const char *position)
 
void setHasPlusPrefix (const char *position)
 
void setHasSpacePrefix (const char *position)
 
void setHasAlternativeForm (const char *position)
 
void setHasLeadingZeros (const char *position)
 
void setHasObjCTechnicalTerm (const char *position)
 
void setIsPrivate (const char *position)
 
void setIsPublic (const char *position)
 
void setUsesPositionalArg ()
 
const PrintfConversionSpecifiergetConversionSpecifier () const
 
void setPrecision (const OptionalAmount &Amt)
 
const OptionalAmountgetPrecision () const
 
bool consumesDataArgument () const
 
ArgType getArgType (ASTContext &Ctx, bool IsObjCLiteral) const
 Returns the builtin type that a data argument paired with this format specifier should have. More...
 
const OptionalFlaghasThousandsGrouping () const
 
const OptionalFlagisLeftJustified () const
 
const OptionalFlaghasPlusPrefix () const
 
const OptionalFlaghasAlternativeForm () const
 
const OptionalFlaghasLeadingZeros () const
 
const OptionalFlaghasSpacePrefix () const
 
const OptionalFlaghasObjCTechnicalTerm () const
 
const OptionalFlagisPrivate () const
 
const OptionalFlagisPublic () const
 
bool usesPositionalArg () const
 
bool fixType (QualType QT, const LangOptions &LangOpt, ASTContext &Ctx, bool IsObjCLiteral)
 Changes the specifier and length according to a QualType, retaining any flags or options. More...
 
void toString (raw_ostream &os) const
 
bool hasValidPlusPrefix () const
 
bool hasValidAlternativeForm () const
 
bool hasValidLeadingZeros () const
 
bool hasValidSpacePrefix () const
 
bool hasValidLeftJustified () const
 
bool hasValidThousandsGroupingPrefix () const
 
bool hasValidPrecision () const
 
bool hasValidFieldWidth () const
 
- Public Member Functions inherited from clang::analyze_format_string::FormatSpecifier
 FormatSpecifier (bool isPrintf)
 
void setLengthModifier (LengthModifier lm)
 
void setUsesPositionalArg ()
 
void setArgIndex (unsigned i)
 
unsigned getArgIndex () const
 
unsigned getPositionalArgIndex () const
 
const LengthModifiergetLengthModifier () const
 
const OptionalAmountgetFieldWidth () const
 
void setFieldWidth (const OptionalAmount &Amt)
 
bool usesPositionalArg () const
 
bool hasValidLengthModifier (const TargetInfo &Target) const
 
bool hasStandardLengthModifier () const
 
Optional< LengthModifiergetCorrectedLengthModifier () const
 
bool hasStandardConversionSpecifier (const LangOptions &LangOpt) const
 
bool hasStandardLengthConversionCombination () const
 

Static Public Member Functions

static PrintfSpecifier Parse (const char *beg, const char *end)
 
- Static Public Member Functions inherited from clang::analyze_format_string::FormatSpecifier
static bool namedTypeToLengthModifier (QualType QT, LengthModifier &LM)
 For a TypedefType QT, if it is a named integer type such as size_t, assign the appropriate value to LM and return true. More...
 

Additional Inherited Members

- Protected Attributes inherited from clang::analyze_format_string::FormatSpecifier
LengthModifier LM
 
OptionalAmount FieldWidth
 
ConversionSpecifier CS
 
bool UsesPositionalArg
 Positional arguments, an IEEE extension: IEEE Std 1003.1, 2004 Edition http://www.opengroup.org/onlinepubs/009695399/functions/printf.html. More...
 
unsigned argIndex
 

Detailed Description

Definition at line 445 of file FormatString.h.

Constructor & Destructor Documentation

◆ PrintfSpecifier()

clang::analyze_printf::PrintfSpecifier::PrintfSpecifier ( )
inline

Definition at line 457 of file FormatString.h.

Member Function Documentation

◆ consumesDataArgument()

bool clang::analyze_printf::PrintfSpecifier::consumesDataArgument ( ) const
inline

Definition at line 509 of file FormatString.h.

◆ fixType()

bool PrintfSpecifier::fixType ( QualType  QT,
const LangOptions LangOpt,
ASTContext Ctx,
bool  IsObjCLiteral 
)

Changes the specifier and length according to a QualType, retaining any flags or options.

Returns true on success, or false when a conversion was not successful.

Definition at line 591 of file PrintfFormatString.cpp.

References clang::analyze_format_string::LengthModifier::AsChar, clang::analyze_format_string::LengthModifier::AsLong, clang::analyze_format_string::LengthModifier::AsLongDouble, clang::analyze_format_string::LengthModifier::AsLongLong, clang::analyze_format_string::LengthModifier::AsShort, clang::analyze_format_string::LengthModifier::AsWideChar, clang::analyze_format_string::ConversionSpecifier::cArg, clang::analyze_format_string::ConversionSpecifier::dArg, clang::analyze_format_string::ConversionSpecifier::DArg, clang::analyze_format_string::ConversionSpecifier::fArg, clang::Type::getAs(), clang::BuiltinType::getKind(), clang::Type::getPointeeType(), clang::ASTContext::getTargetInfo(), clang::analyze_format_string::ConversionSpecifier::iArg, clang::Type::isAnyCharacterType(), clang::Type::isCharType(), clang::Type::isObjCRetainableType(), clang::Type::isPointerType(), clang::Type::isRealFloatingType(), clang::Type::isSignedIntegerType(), clang::Type::isUnsignedIntegerType(), clang::analyze_format_string::ArgType::isValid(), clang::Type::isWideCharType(), clang::analyze_format_string::ArgType::matchesType(), clang::analyze_format_string::ConversionSpecifier::nArg, clang::analyze_format_string::LengthModifier::None, clang::analyze_format_string::OptionalAmount::NotSpecified, clang::analyze_format_string::ConversionSpecifier::ObjCObjArg, clang::analyze_format_string::ConversionSpecifier::sArg, clang::analyze_format_string::ConversionSpecifier::uArg, and clang::analyze_format_string::ConversionSpecifier::UArg.

◆ getArgType()

ArgType PrintfSpecifier::getArgType ( ASTContext Ctx,
bool  IsObjCLiteral 
) const

Returns the builtin type that a data argument paired with this format specifier should have.

This method will return null if the format specifier does not have a matching data argument or the matching argument matches more than one type.

Definition at line 427 of file PrintfFormatString.cpp.

References clang::analyze_format_string::ArgType::AnyCharTy, clang::analyze_format_string::LengthModifier::AsAllocate, clang::analyze_format_string::LengthModifier::AsChar, clang::analyze_format_string::LengthModifier::AsInt32, clang::analyze_format_string::LengthModifier::AsInt3264, clang::analyze_format_string::LengthModifier::AsInt64, clang::analyze_format_string::LengthModifier::AsIntMax, clang::analyze_format_string::LengthModifier::AsLong, clang::analyze_format_string::LengthModifier::AsLongDouble, clang::analyze_format_string::LengthModifier::AsLongLong, clang::analyze_format_string::LengthModifier::AsMAllocate, clang::analyze_format_string::LengthModifier::AsPtrDiff, clang::analyze_format_string::LengthModifier::AsQuad, clang::analyze_format_string::LengthModifier::AsShort, clang::analyze_format_string::LengthModifier::AsSizeT, clang::analyze_format_string::LengthModifier::AsWide, clang::analyze_format_string::LengthModifier::AsWideChar, clang::analyze_format_string::ConversionSpecifier::cArg, clang::analyze_format_string::ConversionSpecifier::CArg, clang::analyze_format_string::ConversionSpecifier::consumesDataArgument(), clang::analyze_format_string::ArgType::CPointerTy, clang::analyze_format_string::ArgType::CStrTy, clang::ASTContext::DoubleTy, clang::ASTContext::getIntMaxType(), clang::analyze_format_string::ConversionSpecifier::getKind(), clang::ASTContext::getPointerDiffType(), clang::ASTContext::getPointerType(), clang::ASTContext::getSignedSizeType(), clang::ASTContext::getSizeType(), clang::ASTContext::getTargetInfo(), clang::TargetInfo::getTriple(), clang::ASTContext::getUIntMaxType(), clang::ASTContext::getUnsignedPointerDiffType(), clang::ASTContext::IntTy, clang::analyze_format_string::ArgType::Invalid(), clang::analyze_printf::PrintfConversionSpecifier::isDoubleArg(), clang::analyze_format_string::ConversionSpecifier::isIntArg(), clang::analyze_format_string::ConversionSpecifier::isUIntArg(), clang::ASTContext::LongDoubleTy, clang::ASTContext::LongLongTy, clang::ASTContext::LongTy, clang::analyze_format_string::ConversionSpecifier::nArg, clang::analyze_format_string::LengthModifier::None, clang::analyze_format_string::ConversionSpecifier::ObjCObjArg, clang::analyze_format_string::ArgType::ObjCPointerTy, clang::analyze_format_string::ConversionSpecifier::pArg, clang::analyze_format_string::ConversionSpecifier::PArg, clang::analyze_format_string::ArgType::PtrTo(), clang::analyze_format_string::ConversionSpecifier::sArg, clang::analyze_format_string::ConversionSpecifier::SArg, clang::ASTContext::ShortTy, clang::ASTContext::SignedCharTy, clang::ASTContext::UnsignedCharTy, clang::ASTContext::UnsignedIntTy, clang::ASTContext::UnsignedLongLongTy, clang::ASTContext::UnsignedLongTy, clang::ASTContext::UnsignedShortTy, clang::analyze_format_string::ArgType::WCStrTy, clang::ASTContext::WideCharTy, clang::analyze_format_string::ArgType::WIntTy, and clang::CanQual< T >::withConst().

◆ getConversionSpecifier()

const PrintfConversionSpecifier& clang::analyze_printf::PrintfSpecifier::getConversionSpecifier ( ) const
inline

Definition at line 496 of file FormatString.h.

◆ getPrecision()

const OptionalAmount& clang::analyze_printf::PrintfSpecifier::getPrecision ( ) const
inline

Definition at line 505 of file FormatString.h.

◆ hasAlternativeForm()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::hasAlternativeForm ( ) const
inline

Definition at line 525 of file FormatString.h.

◆ hasLeadingZeros()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::hasLeadingZeros ( ) const
inline

Definition at line 526 of file FormatString.h.

◆ hasObjCTechnicalTerm()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::hasObjCTechnicalTerm ( ) const
inline

Definition at line 528 of file FormatString.h.

◆ hasPlusPrefix()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::hasPlusPrefix ( ) const
inline

Definition at line 524 of file FormatString.h.

◆ hasSpacePrefix()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::hasSpacePrefix ( ) const
inline

Definition at line 527 of file FormatString.h.

◆ hasThousandsGrouping()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::hasThousandsGrouping ( ) const
inline

Definition at line 520 of file FormatString.h.

◆ hasValidAlternativeForm()

bool PrintfSpecifier::hasValidAlternativeForm ( ) const

◆ hasValidFieldWidth()

bool PrintfSpecifier::hasValidFieldWidth ( ) const

◆ hasValidLeadingZeros()

bool PrintfSpecifier::hasValidLeadingZeros ( ) const

◆ hasValidLeftJustified()

bool PrintfSpecifier::hasValidLeftJustified ( ) const

◆ hasValidPlusPrefix()

bool PrintfSpecifier::hasValidPlusPrefix ( ) const

◆ hasValidPrecision()

bool PrintfSpecifier::hasValidPrecision ( ) const

◆ hasValidSpacePrefix()

bool PrintfSpecifier::hasValidSpacePrefix ( ) const

◆ hasValidThousandsGroupingPrefix()

bool PrintfSpecifier::hasValidThousandsGroupingPrefix ( ) const

◆ isLeftJustified()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::isLeftJustified ( ) const
inline

Definition at line 523 of file FormatString.h.

◆ isPrivate()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::isPrivate ( ) const
inline

Definition at line 529 of file FormatString.h.

◆ isPublic()

const OptionalFlag& clang::analyze_printf::PrintfSpecifier::isPublic ( ) const
inline

Definition at line 530 of file FormatString.h.

◆ Parse()

static PrintfSpecifier clang::analyze_printf::PrintfSpecifier::Parse ( const char *  beg,
const char *  end 
)
static

◆ setConversionSpecifier()

void clang::analyze_printf::PrintfSpecifier::setConversionSpecifier ( const PrintfConversionSpecifier cs)
inline

Definition at line 466 of file FormatString.h.

◆ setHasAlternativeForm()

void clang::analyze_printf::PrintfSpecifier::setHasAlternativeForm ( const char *  position)
inline

◆ setHasLeadingZeros()

void clang::analyze_printf::PrintfSpecifier::setHasLeadingZeros ( const char *  position)
inline

◆ setHasObjCTechnicalTerm()

void clang::analyze_printf::PrintfSpecifier::setHasObjCTechnicalTerm ( const char *  position)
inline

◆ setHasPlusPrefix()

void clang::analyze_printf::PrintfSpecifier::setHasPlusPrefix ( const char *  position)
inline

◆ setHasSpacePrefix()

void clang::analyze_printf::PrintfSpecifier::setHasSpacePrefix ( const char *  position)
inline

◆ setHasThousandsGrouping()

void clang::analyze_printf::PrintfSpecifier::setHasThousandsGrouping ( const char *  position)
inline

◆ setIsLeftJustified()

void clang::analyze_printf::PrintfSpecifier::setIsLeftJustified ( const char *  position)
inline

◆ setIsPrivate()

void clang::analyze_printf::PrintfSpecifier::setIsPrivate ( const char *  position)
inline

◆ setIsPublic()

void clang::analyze_printf::PrintfSpecifier::setIsPublic ( const char *  position)
inline

◆ setPrecision()

void clang::analyze_printf::PrintfSpecifier::setPrecision ( const OptionalAmount Amt)
inline

◆ setUsesPositionalArg()

void clang::analyze_printf::PrintfSpecifier::setUsesPositionalArg ( )
inline

Definition at line 492 of file FormatString.h.

◆ toString()

void PrintfSpecifier::toString ( raw_ostream &  os) const

Definition at line 764 of file PrintfFormatString.cpp.

◆ usesPositionalArg()

bool clang::analyze_printf::PrintfSpecifier::usesPositionalArg ( ) const
inline

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