18#ifndef LLVM_CLANG_AST_FORMATSTRING_H
19#define LLVM_CLANG_AST_FORMATSTRING_H
22#include "llvm/ADT/StringRef.h"
38 : representation(Representation), flag(
false) {}
39 bool isSet()
const {
return flag; }
40 void set() { flag =
true; }
45 this->position = position;
51 const char *
toString()
const {
return representation; }
54 explicit operator bool()
const {
return flag; }
61 const char *representation;
98 : Position(pos), kind(k), BitWidth(bitWidth), ModifierLength(
length) {}
112 assert(ModifierLength != 0 &&
113 "C23 wN/wfN length modifiers must have a nonzero length");
114 return ModifierLength;
131 const char *Position;
133 unsigned BitWidth = 0;
134 unsigned ModifierLength = 0;
320 const char *Name =
nullptr;
324 enum class TypeKind {
333 TypeKind TK = TypeKind::DontCare;
334 unsigned BitWidth = 0;
350 bool isSizeT()
const {
return TK == TypeKind::SizeT; }
356 assert(A.K >=
InvalidTy &&
"ArgType cannot be pointer to invalid/unknown");
365 Res.TK = TypeKind::SizeT;
373 Res.TK = TypeKind::PtrdiffT;
395 const char *amountStart,
unsigned amountLength,
397 : start(amountStart), length(amountLength), hs(howSpecified), amt(amount),
402 UsesPositionalArg(
false), UsesDotPrefix(
false) {}
406 UsesPositionalArg(
false), UsesDotPrefix(
false) {}
427 return start - UsesDotPrefix;
432 return length + UsesDotPrefix;
436 return StringRef(start - UsesDotPrefix, length + UsesDotPrefix);
441 void toString(raw_ostream &os)
const;
457 bool UsesPositionalArg : 1;
568 IsLeftJustified(
"-"), HasPlusPrefix(
"+"), HasSpacePrefix(
" "),
569 HasAlternativeForm(
"#"), HasLeadingZeroes(
"0"),
570 HasObjCTechnicalTerm(
"tt"), IsPrivate(
"private"), IsPublic(
"public"),
571 IsSensitive(
"sensitive") {}
576 HasThousandsGrouping.setPosition(position);
579 IsLeftJustified.setPosition(position);
582 HasPlusPrefix.setPosition(position);
585 HasSpacePrefix.setPosition(position);
588 HasAlternativeForm.setPosition(position);
591 HasLeadingZeroes.setPosition(position);
594 HasObjCTechnicalTerm.setPosition(position);
596 void setIsPrivate(
const char *position) { IsPrivate.setPosition(position); }
597 void setIsPublic(
const char *position) { IsPublic.setPosition(position); }
599 IsSensitive.setPosition(position);
628 return HasThousandsGrouping;
636 return HasObjCTechnicalTerm;
652 void toString(raw_ostream &os)
const;
698 SuppressAssignment.setPosition(position);
702 return SuppressAssignment;
712 return CS.consumesDataArgument() && !SuppressAssignment;
720 void toString(raw_ostream &os)
const;
728namespace analyze_format_string {
747 unsigned specifierLen) {}
750 unsigned flagsLen) {}
757 const char *flagsEnd,
758 const char *conversionPosition) {}
763 unsigned specifierLen) {
768 const char *startSpecifier,
769 unsigned specifierLen,
781 const char *startSpecifier,
782 unsigned specifierLen) {
787 const char *startSpecifier,
788 unsigned specifierLen) {
797 bool isFreeBSDKPrintf);
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
ArgType(Kind K=UnknownTy, const char *N=nullptr)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
Exposes information about the current target.
PrintfConversionSpecifier(const char *pos, Kind k)
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
PrintfConversionSpecifier()
const OptionalFlag & isPrivate() const
void setHasAlternativeForm(const char *position)
bool hasValidLeftJustified() const
void setIsSensitive(const char *position)
bool hasValidFieldWidth() const
void setMaskType(StringRef S)
void setHasSpacePrefix(const char *position)
bool hasValidSpacePrefix() const
void setHasThousandsGrouping(const char *position)
const OptionalAmount & getPrecision() const
const OptionalFlag & hasSpacePrefix() const
bool usesPositionalArg() const
void setIsLeftJustified(const char *position)
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.
StringRef getMaskType() const
const OptionalFlag & isSensitive() const
const OptionalFlag & isLeftJustified() const
bool hasValidPrecision() const
const OptionalFlag & hasLeadingZeros() const
const OptionalFlag & hasAlternativeForm() const
bool hasValidLeadingZeros() const
void setHasPlusPrefix(const char *position)
void setIsPrivate(const char *position)
void toString(raw_ostream &os) const
const PrintfConversionSpecifier & getConversionSpecifier() const
void setHasLeadingZeros(const char *position)
const OptionalFlag & hasPlusPrefix() const
const OptionalFlag & hasThousandsGrouping() const
void setUsesPositionalArg()
bool hasValidThousandsGroupingPrefix() const
ArgType getArgType(ASTContext &Ctx, bool IsObjCLiteral) const
Returns the builtin type that a data argument paired with this format specifier should have.
void setIsPublic(const char *position)
const OptionalFlag & hasObjCTechnicalTerm() const
void setPrecision(const OptionalAmount &Amt)
void setHasObjCTechnicalTerm(const char *position)
const OptionalFlag & isPublic() const
bool consumesDataArgument() const
bool hasValidPlusPrefix() const
void setConversionSpecifier(const PrintfConversionSpecifier &cs)
bool hasValidAlternativeForm() const
ScanfConversionSpecifier(const char *pos, Kind k)
ScanfConversionSpecifier()
static bool classof(const analyze_format_string::ConversionSpecifier *CS)
bool fixType(QualType QT, QualType RawQT, const LangOptions &LangOpt, ASTContext &Ctx)
const OptionalFlag & getSuppressAssignment() const
void toString(raw_ostream &os) const
bool consumesDataArgument() const
void setConversionSpecifier(const ScanfConversionSpecifier &cs)
const ScanfConversionSpecifier & getConversionSpecifier() const
void setSuppressAssignment(const char *position)
ArgType getArgType(ASTContext &Ctx) const
Pieces specific to fprintf format strings.
Pieces specific to fscanf format strings.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
const FunctionProtoType * T
U cast(CodeGen::Address addr)
float __ovld __cnfn length(float)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)