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") {}
578 HasThousandsGrouping.setPosition(position);
581 IsLeftJustified.setPosition(position);
584 HasPlusPrefix.setPosition(position);
587 HasSpacePrefix.setPosition(position);
590 HasAlternativeForm.setPosition(position);
593 HasLeadingZeroes.setPosition(position);
596 HasObjCTechnicalTerm.setPosition(position);
598 void setIsPrivate(
const char *position) { IsPrivate.setPosition(position); }
599 void setIsPublic(
const char *position) { IsPublic.setPosition(position); }
601 IsSensitive.setPosition(position);
630 return HasThousandsGrouping;
638 return HasObjCTechnicalTerm;
654 void toString(raw_ostream &os)
const;
700 SuppressAssignment.setPosition(position);
704 return SuppressAssignment;
714 return CS.consumesDataArgument() && !SuppressAssignment;
722 void toString(raw_ostream &os)
const;
751 unsigned specifierLen) {}
754 unsigned flagsLen) {}
761 const char *flagsEnd,
762 const char *conversionPosition) {}
767 unsigned specifierLen) {
772 const char *startSpecifier,
773 unsigned specifierLen,
785 const char *startSpecifier,
786 unsigned specifierLen) {
791 const char *startSpecifier,
792 unsigned specifierLen) {
801 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
static PrintfSpecifier Parse(const char *beg, const char *end)
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)
static ScanfSpecifier Parse(const char *beg, const char *end)
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.
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
U cast(CodeGen::Address addr)
float __ovld __cnfn length(float)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)