18#include "llvm/Support/Regex.h"
39 const char *Start,
const char *&Beg,
const char *E,
42 FS.
setPrecision(ParseNonPositionAmount(Beg, E, *argIndex));
54 const char *FlagBeg,
const char *E,
bool Warn) {
55 StringRef Flag(FlagBeg, E - FlagBeg);
75 bool isFreeBSDKPrintf) {
81 const char *Start =
nullptr;
122 unsigned char PrivacyFlags = 0;
123 StringRef MatchedStr;
126 StringRef Str(I, E - I);
127 std::string
Match =
"^[[:space:]]*"
128 "(private|public|sensitive|mask\\.[^[:space:],}]*)"
130 llvm::Regex R(
Match);
133 if (R.match(Str, &Matches)) {
134 MatchedStr = Matches[1];
135 I += Matches[0].size();
140 if (MatchedStr.starts_with(
"mask")) {
141 StringRef MaskType = MatchedStr.substr(
sizeof(
"mask.") - 1);
142 unsigned Size = MaskType.size();
143 if (Warn && (Size == 0 || Size > 8))
146 }
else if (MatchedStr ==
"sensitive")
148 else if (PrivacyFlags !=
150 MatchedStr ==
"private")
152 else if (PrivacyFlags == 0 && MatchedStr ==
"public")
155 size_t CommaOrBracePos =
156 Str.find_if([](
char c) {
return c ==
',' || c ==
'}'; });
158 if (CommaOrBracePos == StringRef::npos) {
165 I += CommaOrBracePos + 1;
168 }
while (*(I - 1) ==
',');
171 switch (PrivacyFlags) {
184 llvm_unreachable(
"Unexpected privacy flag value");
190 for (; I != E; ++I) {
276 const char *ObjCModifierFlagsStart =
nullptr, *ObjCModifierFlagsEnd =
nullptr;
278 ObjCModifierFlagsStart = I;
282 ObjCModifierFlagsEnd = I;
308 const char *conversionPosition = I++;
310 switch (*conversionPosition) {
375 if (isFreeBSDKPrintf)
403 if (isFreeBSDKPrintf)
405 else if (LO.FixedPoint)
409 if (isFreeBSDKPrintf)
414 if (isFreeBSDKPrintf)
416 else if (
Target.getTriple().isOSDarwin())
420 if (
Target.getTriple().isOSDarwin())
424 if (
Target.getTriple().isOSDarwin())
429 if (
Target.getTriple().isOSMSVCRT())
453 ObjCModifierFlagsStart, ObjCModifierFlagsEnd + 1, conversionPosition);
467 unsigned Len = I - Start;
482 unsigned argIndex = 0;
487 H, I, E, argIndex, LO,
Target,
true, isFreeBSDKPrintf);
501 assert(I == E &&
"Format string not exhausted");
506 const char *I,
const char *E,
const LangOptions &LO,
509 unsigned argIndex = 0;
534 const char *Begin,
const char *End,
const LangOptions &LO,
536 unsigned ArgIndex = 0;
539 while (Begin != End) {
555 bool IsObjCLiteral)
const {
600 :
ArgType(Ctx.IntTy,
"__int32");
620 switch (
LM.getKind()) {
647 : ArgType(Ctx.UnsignedIntTy,
"unsigned __int32");
663 if (
CS.isDoubleArg()) {
665 switch (
LM.getKind()) {
676 switch (
LM.getKind()) {
691 switch (
LM.getKind()) {
727 llvm_unreachable(
"only used for OpenCL which doesn not handle nArg");
734 switch (
CS.getKind()) {
766 switch (
LM.getKind()) {
777 switch (
LM.getKind()) {
788 switch (
LM.getKind()) {
799 switch (
LM.getKind()) {
820 if (!
CS.consumesDataArgument())
823 ArgType ScalarTy = getScalarArgType(Ctx, IsObjCLiteral);
847 HasThousandsGrouping =
false;
848 HasPlusPrefix =
false;
849 HasSpacePrefix =
false;
850 HasAlternativeForm =
false;
851 HasLeadingZeroes =
false;
863 HasAlternativeForm =
false;
864 HasLeadingZeroes =
false;
877 QT = ED->getIntegerType();
895 case BuiltinType::Bool:
896 case BuiltinType::WChar_U:
897 case BuiltinType::WChar_S:
898 case BuiltinType::Char8:
899 case BuiltinType::Char16:
900 case BuiltinType::Char32:
901 case BuiltinType::UInt128:
902 case BuiltinType::Int128:
903 case BuiltinType::Half:
904 case BuiltinType::BFloat16:
905 case BuiltinType::Float16:
906 case BuiltinType::Float128:
907 case BuiltinType::Ibm128:
908 case BuiltinType::ShortAccum:
909 case BuiltinType::Accum:
910 case BuiltinType::LongAccum:
911 case BuiltinType::UShortAccum:
912 case BuiltinType::UAccum:
913 case BuiltinType::ULongAccum:
914 case BuiltinType::ShortFract:
915 case BuiltinType::Fract:
916 case BuiltinType::LongFract:
917 case BuiltinType::UShortFract:
918 case BuiltinType::UFract:
919 case BuiltinType::ULongFract:
920 case BuiltinType::SatShortAccum:
921 case BuiltinType::SatAccum:
922 case BuiltinType::SatLongAccum:
923 case BuiltinType::SatUShortAccum:
924 case BuiltinType::SatUAccum:
925 case BuiltinType::SatULongAccum:
926 case BuiltinType::SatShortFract:
927 case BuiltinType::SatFract:
928 case BuiltinType::SatLongFract:
929 case BuiltinType::SatUShortFract:
930 case BuiltinType::SatUFract:
931 case BuiltinType::SatULongFract:
935#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
936 case BuiltinType::Id:
937#include "clang/Basic/OpenCLImageTypes.def"
939#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
940#include "clang/Basic/OpenCLExtensionTypes.def"
942#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
943#include "clang/Basic/AArch64ACLETypes.def"
945#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
946#include "clang/Basic/PPCTypes.def"
948#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
949#include "clang/Basic/RISCVVTypes.def"
951#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
952#include "clang/Basic/WebAssemblyReferenceTypes.def"
954#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
955#include "clang/Basic/AMDGPUTypes.def"
957#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
958#include "clang/Basic/HLSLIntangibleTypes.def"
960#define SIGNED_TYPE(Id, SingletonId)
961#define UNSIGNED_TYPE(Id, SingletonId)
962#define FLOATING_TYPE(Id, SingletonId)
963#define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
964#include "clang/AST/BuiltinTypes.def"
969 case BuiltinType::UInt:
970 case BuiltinType::Int:
971 case BuiltinType::Float:
975 case BuiltinType::Double:
979 case BuiltinType::Char_U:
980 case BuiltinType::UChar:
981 case BuiltinType::Char_S:
982 case BuiltinType::SChar:
986 case BuiltinType::Short:
987 case BuiltinType::UShort:
991 case BuiltinType::Long:
992 case BuiltinType::ULong:
996 case BuiltinType::LongLong:
997 case BuiltinType::ULongLong:
1001 case BuiltinType::LongDouble:
1007 if (LangOpt.C99 || LangOpt.CPlusPlus11)
1013 switch (
CS.getKind()) {
1041 HasAlternativeForm =
false;
1042 HasLeadingZeroes =
false;
1043 HasPlusPrefix =
false;
1050 HasAlternativeForm =
false;
1053 HasAlternativeForm =
false;
1054 HasPlusPrefix =
false;
1056 llvm_unreachable(
"Unexpected type");
1073 if (IsLeftJustified)
1079 if (HasAlternativeForm)
1081 if (HasLeadingZeroes)
1087 Precision.toString(os);
1094 os <<
LM.toString();
1096 os <<
CS.toString();
1104 switch (
CS.getKind()) {
1128 if (!HasAlternativeForm)
1132 switch (
CS.getKind()) {
1161 if (!HasLeadingZeroes)
1165 switch (
CS.getKind()) {
1199 if (!HasSpacePrefix)
1203 switch (
CS.getKind()) {
1227 if (!IsLeftJustified)
1231 switch (
CS.getKind()) {
1241 if (!HasThousandsGrouping)
1244 switch (
CS.getKind()) {
1265 switch (
CS.getKind()) {
1304 switch (
CS.getKind()) {
llvm::MachO::Target Target
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CanQualType UnsignedShortAccumTy
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
CanQualType UnsignedLongFractTy
const LangOptions & getLangOpts() const
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
CanQualType UnsignedFractTy
CanQualType UnsignedLongTy
CanQualType UnsignedLongAccumTy
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
CanQualType UnsignedIntTy
CanQualType UnsignedLongLongTy
CanQualType UnsignedShortTy
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
const TargetInfo & getTargetInfo() const
QualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
CanQualType UnsignedAccumTy
This class is used for builtin types like 'int'.
QualType withConst() const
Retrieves a version of this type with const applied.
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.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isRealFloatingType() const
Floating point categories.
bool isWideCharType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
const T * getAs() const
Member-template getAs<specific type>'.
bool isObjCRetainableType() const
Represents a GCC generic vector type.
unsigned getNumElements() const
QualType getElementType() const
static ArgType makePtrdiffT(const ArgType &A)
Create an ArgType which corresponds to the ptrdiff_t/unsigned ptrdiff_t type.
static ArgType PtrTo(const ArgType &A)
Create an ArgType which corresponds to the type pointer to A.
static ArgType Unsupported(const char *N)
static ArgType makeIntNType(ASTContext &Ctx, const LengthModifier &LengthMod, bool Signed)
static ArgType makeSizeT(const ArgType &A)
Create an ArgType which corresponds to the size_t/ssize_t type.
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)
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.
bool hasValidPrecision() 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)
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)
void setPrecision(const OptionalAmount &Amt)
void setHasObjCTechnicalTerm(const char *position)
bool hasValidPlusPrefix() const
void setConversionSpecifier(const PrintfConversionSpecifier &cs)
bool hasValidAlternativeForm() const
Defines the clang::TargetInfo interface.
Pieces specific to fprintf format strings.
The JSON file list parser is used to communicate input to InstallAPI.
@ Match
This is not an overload because the signature exactly matches an existing declaration.