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);
58 FS.setHasObjCTechnicalTerm(FlagBeg);
78 bool isFreeBSDKPrintf) {
84 const char *Start =
nullptr;
85 UpdateOnReturn <const char*> UpdateBeg(Beg, I);
88 for ( ; I !=
E ; ++I) {
113 if (ParseArgPosition(H, FS, Start, I,
E))
125 unsigned char PrivacyFlags = 0;
126 StringRef MatchedStr;
129 StringRef Str(I,
E - I);
130 std::string Match =
"^[[:space:]]*"
131 "(private|public|sensitive|mask\\.[^[:space:],}]*)"
133 llvm::Regex R(Match);
136 if (R.match(Str, &Matches)) {
137 MatchedStr = Matches[1];
138 I += Matches[0].size();
143 if (MatchedStr.starts_with(
"mask")) {
144 StringRef MaskType = MatchedStr.substr(
sizeof(
"mask.") - 1);
145 unsigned Size = MaskType.size();
146 if (Warn && (Size == 0 || Size > 8))
148 FS.setMaskType(MaskType);
149 }
else if (MatchedStr ==
"sensitive")
151 else if (PrivacyFlags !=
153 MatchedStr ==
"private")
155 else if (PrivacyFlags == 0 && MatchedStr ==
"public")
158 size_t CommaOrBracePos =
159 Str.find_if([](
char c) {
return c ==
',' ||
c ==
'}'; });
161 if (CommaOrBracePos == StringRef::npos) {
168 I += CommaOrBracePos + 1;
171 }
while (*(I - 1) ==
',');
174 switch (PrivacyFlags) {
178 FS.setIsPrivate(MatchedStr.data());
181 FS.setIsPublic(MatchedStr.data());
184 FS.setIsSensitive(MatchedStr.data());
187 llvm_unreachable(
"Unexpected privacy flag value");
193 for ( ; I !=
E; ++I) {
195 default: hasMore =
false;
break;
198 FS.setHasThousandsGrouping(I);
200 case '-': FS.setIsLeftJustified(I);
break;
201 case '+': FS.setHasPlusPrefix(I);
break;
202 case ' ': FS.setHasSpacePrefix(I);
break;
203 case '#': FS.setHasAlternativeForm(I);
break;
204 case '0': FS.setHasLeadingZeros(I);
break;
218 if (ParseFieldWidth(H, FS, Start, I,
E,
219 FS.usesPositionalArg() ?
nullptr : &argIndex))
239 FS.usesPositionalArg() ?
nullptr : &argIndex))
250 if (ParseVectorModifier(H, FS, I,
E, LO))
254 if (ParseLengthModifier(FS, I,
E, LO) && I ==
E) {
267 const char *ObjCModifierFlagsStart =
nullptr,
268 *ObjCModifierFlagsEnd =
nullptr;
270 ObjCModifierFlagsStart = I;
274 ObjCModifierFlagsEnd = I;
300 const char *conversionPosition = I++;
302 switch (*conversionPosition) {
331 if (isFreeBSDKPrintf)
349 if (isFreeBSDKPrintf)
351 else if (LO.FixedPoint)
355 if (isFreeBSDKPrintf)
360 if (isFreeBSDKPrintf)
362 else if (
Target.getTriple().isOSDarwin())
366 if (
Target.getTriple().isOSDarwin())
370 if (
Target.getTriple().isOSDarwin())
375 if (
Target.getTriple().isOSMSVCRT())
398 ObjCModifierFlagsStart) {
400 ObjCModifierFlagsEnd + 1,
406 FS.setConversionSpecifier(CS);
408 FS.setArgIndex(argIndex++);
415 unsigned Len = I - Start;
416 if (ParseUTF8InvalidSpecifier(Start,
E, Len)) {
418 FS.setConversionSpecifier(CS);
431 bool isFreeBSDKPrintf) {
433 unsigned argIndex = 0;
453 assert(I ==
E &&
"Format string not exhausted");
462 unsigned argIndex = 0;
489 unsigned ArgIndex = 0;
492 while (
Begin != End) {
508 bool IsObjCLiteral)
const {
509 if (
CS.
getKind() == ConversionSpecifier::cArg)
550 :
ArgType(Ctx.IntTy,
"__int32");
585 :
ArgType(Ctx.UnsignedIntTy,
"unsigned __int32");
613 if (
CS.
getKind() == ConversionSpecifier::nArg) {
642 llvm_unreachable(
"only used for OpenCL which doesn not handle nArg");
650 case ConversionSpecifier::sArg:
660 case ConversionSpecifier::SArg:
668 case ConversionSpecifier::CArg:
675 case ConversionSpecifier::pArg:
676 case ConversionSpecifier::PArg:
678 case ConversionSpecifier::ObjCObjArg:
680 case ConversionSpecifier::kArg:
691 case ConversionSpecifier::KArg:
702 case ConversionSpecifier::rArg:
713 case ConversionSpecifier::RArg:
734 bool IsObjCLiteral)
const {
740 ArgType ScalarTy = getScalarArgType(Ctx, IsObjCLiteral);
750 if (
CS.
getKind() == ConversionSpecifier::nArg)
761 CS.
setKind(ConversionSpecifier::ObjCObjArg);
764 HasThousandsGrouping =
false;
765 HasPlusPrefix =
false;
766 HasSpacePrefix =
false;
767 HasAlternativeForm =
false;
768 HasLeadingZeroes =
false;
780 HasAlternativeForm =
false;
781 HasLeadingZeroes =
false;
794 QT = ETy->getDecl()->getIntegerType();
812 case BuiltinType::Bool:
813 case BuiltinType::WChar_U:
814 case BuiltinType::WChar_S:
815 case BuiltinType::Char8:
816 case BuiltinType::Char16:
817 case BuiltinType::Char32:
818 case BuiltinType::UInt128:
819 case BuiltinType::Int128:
820 case BuiltinType::Half:
821 case BuiltinType::BFloat16:
822 case BuiltinType::Float16:
823 case BuiltinType::Float128:
824 case BuiltinType::Ibm128:
825 case BuiltinType::ShortAccum:
826 case BuiltinType::Accum:
827 case BuiltinType::LongAccum:
828 case BuiltinType::UShortAccum:
829 case BuiltinType::UAccum:
830 case BuiltinType::ULongAccum:
831 case BuiltinType::ShortFract:
832 case BuiltinType::Fract:
833 case BuiltinType::LongFract:
834 case BuiltinType::UShortFract:
835 case BuiltinType::UFract:
836 case BuiltinType::ULongFract:
837 case BuiltinType::SatShortAccum:
838 case BuiltinType::SatAccum:
839 case BuiltinType::SatLongAccum:
840 case BuiltinType::SatUShortAccum:
841 case BuiltinType::SatUAccum:
842 case BuiltinType::SatULongAccum:
843 case BuiltinType::SatShortFract:
844 case BuiltinType::SatFract:
845 case BuiltinType::SatLongFract:
846 case BuiltinType::SatUShortFract:
847 case BuiltinType::SatUFract:
848 case BuiltinType::SatULongFract:
852#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
853 case BuiltinType::Id:
854#include "clang/Basic/OpenCLImageTypes.def"
855#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
856 case BuiltinType::Id:
857#include "clang/Basic/OpenCLExtensionTypes.def"
858#define SVE_TYPE(Name, Id, SingletonId) \
859 case BuiltinType::Id:
860#include "clang/Basic/AArch64SVEACLETypes.def"
861#define PPC_VECTOR_TYPE(Name, Id, Size) \
862 case BuiltinType::Id:
863#include "clang/Basic/PPCTypes.def"
864#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
865#include "clang/Basic/RISCVVTypes.def"
866#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
867#include "clang/Basic/WebAssemblyReferenceTypes.def"
868#define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
869#include "clang/Basic/AMDGPUTypes.def"
870#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
871#include "clang/Basic/HLSLIntangibleTypes.def"
872#define SIGNED_TYPE(Id, SingletonId)
873#define UNSIGNED_TYPE(Id, SingletonId)
874#define FLOATING_TYPE(Id, SingletonId)
875#define BUILTIN_TYPE(Id, SingletonId) \
876 case BuiltinType::Id:
877#include "clang/AST/BuiltinTypes.def"
881 case BuiltinType::UInt:
882 case BuiltinType::Int:
883 case BuiltinType::Float:
887 case BuiltinType::Double:
891 case BuiltinType::Char_U:
892 case BuiltinType::UChar:
893 case BuiltinType::Char_S:
894 case BuiltinType::SChar:
898 case BuiltinType::Short:
899 case BuiltinType::UShort:
903 case BuiltinType::Long:
904 case BuiltinType::ULong:
908 case BuiltinType::LongLong:
909 case BuiltinType::ULongLong:
913 case BuiltinType::LongDouble:
919 if (LangOpt.C99 || LangOpt.CPlusPlus11)
926 case ConversionSpecifier::uArg:
927 case ConversionSpecifier::UArg:
931 case ConversionSpecifier::dArg:
932 case ConversionSpecifier::DArg:
933 case ConversionSpecifier::iArg:
953 HasAlternativeForm =
false;
954 HasLeadingZeroes =
false;
955 HasPlusPrefix =
false;
962 HasAlternativeForm =
false;
965 HasAlternativeForm =
false;
966 HasPlusPrefix =
false;
968 llvm_unreachable(
"Unexpected type");
985 if (IsLeftJustified) os <<
"-";
986 if (HasPlusPrefix) os <<
"+";
987 if (HasSpacePrefix) os <<
" ";
988 if (HasAlternativeForm) os <<
"#";
989 if (HasLeadingZeroes) os <<
"0";
1012 case ConversionSpecifier::dArg:
1013 case ConversionSpecifier::DArg:
1014 case ConversionSpecifier::iArg:
1015 case ConversionSpecifier::fArg:
1016 case ConversionSpecifier::FArg:
1017 case ConversionSpecifier::eArg:
1018 case ConversionSpecifier::EArg:
1019 case ConversionSpecifier::gArg:
1020 case ConversionSpecifier::GArg:
1021 case ConversionSpecifier::aArg:
1022 case ConversionSpecifier::AArg:
1023 case ConversionSpecifier::FreeBSDrArg:
1024 case ConversionSpecifier::FreeBSDyArg:
1025 case ConversionSpecifier::rArg:
1026 case ConversionSpecifier::kArg:
1035 if (!HasAlternativeForm)
1040 case ConversionSpecifier::bArg:
1041 case ConversionSpecifier::BArg:
1042 case ConversionSpecifier::oArg:
1043 case ConversionSpecifier::OArg:
1044 case ConversionSpecifier::xArg:
1045 case ConversionSpecifier::XArg:
1046 case ConversionSpecifier::aArg:
1047 case ConversionSpecifier::AArg:
1048 case ConversionSpecifier::eArg:
1049 case ConversionSpecifier::EArg:
1050 case ConversionSpecifier::fArg:
1051 case ConversionSpecifier::FArg:
1052 case ConversionSpecifier::gArg:
1053 case ConversionSpecifier::GArg:
1054 case ConversionSpecifier::FreeBSDrArg:
1055 case ConversionSpecifier::FreeBSDyArg:
1056 case ConversionSpecifier::rArg:
1057 case ConversionSpecifier::RArg:
1058 case ConversionSpecifier::kArg:
1059 case ConversionSpecifier::KArg:
1068 if (!HasLeadingZeroes)
1073 case ConversionSpecifier::bArg:
1074 case ConversionSpecifier::BArg:
1075 case ConversionSpecifier::dArg:
1076 case ConversionSpecifier::DArg:
1077 case ConversionSpecifier::iArg:
1078 case ConversionSpecifier::oArg:
1079 case ConversionSpecifier::OArg:
1080 case ConversionSpecifier::uArg:
1081 case ConversionSpecifier::UArg:
1082 case ConversionSpecifier::xArg:
1083 case ConversionSpecifier::XArg:
1084 case ConversionSpecifier::aArg:
1085 case ConversionSpecifier::AArg:
1086 case ConversionSpecifier::eArg:
1087 case ConversionSpecifier::EArg:
1088 case ConversionSpecifier::fArg:
1089 case ConversionSpecifier::FArg:
1090 case ConversionSpecifier::gArg:
1091 case ConversionSpecifier::GArg:
1092 case ConversionSpecifier::FreeBSDrArg:
1093 case ConversionSpecifier::FreeBSDyArg:
1094 case ConversionSpecifier::rArg:
1095 case ConversionSpecifier::RArg:
1096 case ConversionSpecifier::kArg:
1097 case ConversionSpecifier::KArg:
1106 if (!HasSpacePrefix)
1111 case ConversionSpecifier::dArg:
1112 case ConversionSpecifier::DArg:
1113 case ConversionSpecifier::iArg:
1114 case ConversionSpecifier::fArg:
1115 case ConversionSpecifier::FArg:
1116 case ConversionSpecifier::eArg:
1117 case ConversionSpecifier::EArg:
1118 case ConversionSpecifier::gArg:
1119 case ConversionSpecifier::GArg:
1120 case ConversionSpecifier::aArg:
1121 case ConversionSpecifier::AArg:
1122 case ConversionSpecifier::FreeBSDrArg:
1123 case ConversionSpecifier::FreeBSDyArg:
1124 case ConversionSpecifier::rArg:
1125 case ConversionSpecifier::kArg:
1134 if (!IsLeftJustified)
1139 case ConversionSpecifier::nArg:
1148 if (!HasThousandsGrouping)
1152 case ConversionSpecifier::dArg:
1153 case ConversionSpecifier::DArg:
1154 case ConversionSpecifier::iArg:
1155 case ConversionSpecifier::uArg:
1156 case ConversionSpecifier::UArg:
1157 case ConversionSpecifier::fArg:
1158 case ConversionSpecifier::FArg:
1159 case ConversionSpecifier::gArg:
1160 case ConversionSpecifier::GArg:
1173 case ConversionSpecifier::bArg:
1174 case ConversionSpecifier::BArg:
1175 case ConversionSpecifier::dArg:
1176 case ConversionSpecifier::DArg:
1177 case ConversionSpecifier::iArg:
1178 case ConversionSpecifier::oArg:
1179 case ConversionSpecifier::OArg:
1180 case ConversionSpecifier::uArg:
1181 case ConversionSpecifier::UArg:
1182 case ConversionSpecifier::xArg:
1183 case ConversionSpecifier::XArg:
1184 case ConversionSpecifier::aArg:
1185 case ConversionSpecifier::AArg:
1186 case ConversionSpecifier::eArg:
1187 case ConversionSpecifier::EArg:
1188 case ConversionSpecifier::fArg:
1189 case ConversionSpecifier::FArg:
1190 case ConversionSpecifier::gArg:
1191 case ConversionSpecifier::GArg:
1192 case ConversionSpecifier::sArg:
1193 case ConversionSpecifier::FreeBSDrArg:
1194 case ConversionSpecifier::FreeBSDyArg:
1195 case ConversionSpecifier::PArg:
1196 case ConversionSpecifier::rArg:
1197 case ConversionSpecifier::RArg:
1198 case ConversionSpecifier::kArg:
1199 case ConversionSpecifier::KArg:
1212 case ConversionSpecifier::nArg:
llvm::MachO::Target Target
__device__ __2f16 float c
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 getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CanQualType UnsignedCharTy
CanQualType UnsignedShortFractTy
CanQualType UnsignedIntTy
CanQualType UnsignedLongLongTy
CanQualType UnsignedShortTy
const TargetInfo & getTargetInfo() const
CanQualType 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.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
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.
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
bool hasValidLeftJustified() const
bool hasValidFieldWidth() const
bool hasValidSpacePrefix() 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.
bool hasValidPrecision() const
bool hasValidLeadingZeros() const
void toString(raw_ostream &os) const
const PrintfConversionSpecifier & getConversionSpecifier() const
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.
bool hasValidPlusPrefix() const
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.