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");
611 switch (
LM.getKind()) {
638 : ArgType(Ctx.UnsignedIntTy,
"unsigned __int32");
648 if (
CS.isDoubleArg()) {
650 switch (
LM.getKind()) {
667 switch (
LM.getKind()) {
697 llvm_unreachable(
"only used for OpenCL which doesn not handle nArg");
704 switch (
CS.getKind()) {
736 switch (
LM.getKind()) {
747 switch (
LM.getKind()) {
758 switch (
LM.getKind()) {
769 switch (
LM.getKind()) {
790 if (!
CS.consumesDataArgument())
793 ArgType ScalarTy = getScalarArgType(Ctx, IsObjCLiteral);
817 HasThousandsGrouping =
false;
818 HasPlusPrefix =
false;
819 HasSpacePrefix =
false;
820 HasAlternativeForm =
false;
821 HasLeadingZeroes =
false;
833 HasAlternativeForm =
false;
834 HasLeadingZeroes =
false;
847 QT = ED->getIntegerType();
865 case BuiltinType::Bool:
866 case BuiltinType::WChar_U:
867 case BuiltinType::WChar_S:
868 case BuiltinType::Char8:
869 case BuiltinType::Char16:
870 case BuiltinType::Char32:
871 case BuiltinType::UInt128:
872 case BuiltinType::Int128:
873 case BuiltinType::Half:
874 case BuiltinType::BFloat16:
875 case BuiltinType::Float16:
876 case BuiltinType::Float128:
877 case BuiltinType::Ibm128:
878 case BuiltinType::ShortAccum:
879 case BuiltinType::Accum:
880 case BuiltinType::LongAccum:
881 case BuiltinType::UShortAccum:
882 case BuiltinType::UAccum:
883 case BuiltinType::ULongAccum:
884 case BuiltinType::ShortFract:
885 case BuiltinType::Fract:
886 case BuiltinType::LongFract:
887 case BuiltinType::UShortFract:
888 case BuiltinType::UFract:
889 case BuiltinType::ULongFract:
890 case BuiltinType::SatShortAccum:
891 case BuiltinType::SatAccum:
892 case BuiltinType::SatLongAccum:
893 case BuiltinType::SatUShortAccum:
894 case BuiltinType::SatUAccum:
895 case BuiltinType::SatULongAccum:
896 case BuiltinType::SatShortFract:
897 case BuiltinType::SatFract:
898 case BuiltinType::SatLongFract:
899 case BuiltinType::SatUShortFract:
900 case BuiltinType::SatUFract:
901 case BuiltinType::SatULongFract:
905#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
906 case BuiltinType::Id:
907#include "clang/Basic/OpenCLImageTypes.def"
909#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
910#include "clang/Basic/OpenCLExtensionTypes.def"
912#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
913#include "clang/Basic/AArch64ACLETypes.def"
915#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
916#include "clang/Basic/PPCTypes.def"
918#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
919#include "clang/Basic/RISCVVTypes.def"
921#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
922#include "clang/Basic/WebAssemblyReferenceTypes.def"
924#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
925#include "clang/Basic/AMDGPUTypes.def"
927#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
928#include "clang/Basic/HLSLIntangibleTypes.def"
930#define SIGNED_TYPE(Id, SingletonId)
931#define UNSIGNED_TYPE(Id, SingletonId)
932#define FLOATING_TYPE(Id, SingletonId)
933#define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
934#include "clang/AST/BuiltinTypes.def"
939 case BuiltinType::UInt:
940 case BuiltinType::Int:
941 case BuiltinType::Float:
945 case BuiltinType::Double:
949 case BuiltinType::Char_U:
950 case BuiltinType::UChar:
951 case BuiltinType::Char_S:
952 case BuiltinType::SChar:
956 case BuiltinType::Short:
957 case BuiltinType::UShort:
961 case BuiltinType::Long:
962 case BuiltinType::ULong:
966 case BuiltinType::LongLong:
967 case BuiltinType::ULongLong:
971 case BuiltinType::LongDouble:
977 if (LangOpt.C99 || LangOpt.CPlusPlus11)
983 switch (
CS.getKind()) {
1011 HasAlternativeForm =
false;
1012 HasLeadingZeroes =
false;
1013 HasPlusPrefix =
false;
1020 HasAlternativeForm =
false;
1023 HasAlternativeForm =
false;
1024 HasPlusPrefix =
false;
1026 llvm_unreachable(
"Unexpected type");
1043 if (IsLeftJustified)
1049 if (HasAlternativeForm)
1051 if (HasLeadingZeroes)
1057 Precision.toString(os);
1064 os <<
LM.toString();
1066 os <<
CS.toString();
1074 switch (
CS.getKind()) {
1098 if (!HasAlternativeForm)
1102 switch (
CS.getKind()) {
1131 if (!HasLeadingZeroes)
1135 switch (
CS.getKind()) {
1169 if (!HasSpacePrefix)
1173 switch (
CS.getKind()) {
1197 if (!IsLeftJustified)
1201 switch (
CS.getKind()) {
1211 if (!HasThousandsGrouping)
1214 switch (
CS.getKind()) {
1235 switch (
CS.getKind()) {
1274 switch (
CS.getKind()) {
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 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 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.