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);
78 bool isFreeBSDKPrintf) {
84 const char *Start =
nullptr;
85 UpdateOnReturn <const char*> UpdateBeg(Beg, I);
88 for ( ; I != E ; ++I) {
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))
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) {
187 llvm_unreachable(
"Unexpected privacy flag value");
193 for ( ; I != E; ++I) {
195 default: hasMore =
false;
break;
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,
415 unsigned Len = I - Start;
431 bool isFreeBSDKPrintf) {
433 unsigned argIndex = 0;
453 assert(I == E &&
"Format string not exhausted");
462 unsigned argIndex = 0;
487 const char *Begin,
const char *End,
const LangOptions &LO,
489 unsigned ArgIndex = 0;
492 while (Begin != End) {
508 bool IsObjCLiteral)
const {
551 :
ArgType(Ctx.IntTy,
"__int32");
562 switch (
LM.getKind()) {
586 : ArgType(Ctx.UnsignedIntTy,
"unsigned __int32");
596 if (
CS.isDoubleArg()) {
598 switch (
LM.getKind()) {
615 switch (
LM.getKind()) {
645 llvm_unreachable(
"only used for OpenCL which doesn not handle nArg");
652 switch (
CS.getKind()) {
684 switch (
LM.getKind()) {
695 switch (
LM.getKind()) {
706 switch (
LM.getKind()) {
717 switch (
LM.getKind()) {
737 bool IsObjCLiteral)
const {
740 if (!
CS.consumesDataArgument())
743 ArgType ScalarTy = getScalarArgType(Ctx, IsObjCLiteral);
767 HasThousandsGrouping =
false;
768 HasPlusPrefix =
false;
769 HasSpacePrefix =
false;
770 HasAlternativeForm =
false;
771 HasLeadingZeroes =
false;
783 HasAlternativeForm =
false;
784 HasLeadingZeroes =
false;
797 QT = ED->getIntegerType();
815 case BuiltinType::Bool:
816 case BuiltinType::WChar_U:
817 case BuiltinType::WChar_S:
818 case BuiltinType::Char8:
819 case BuiltinType::Char16:
820 case BuiltinType::Char32:
821 case BuiltinType::UInt128:
822 case BuiltinType::Int128:
823 case BuiltinType::Half:
824 case BuiltinType::BFloat16:
825 case BuiltinType::Float16:
826 case BuiltinType::Float128:
827 case BuiltinType::Ibm128:
828 case BuiltinType::ShortAccum:
829 case BuiltinType::Accum:
830 case BuiltinType::LongAccum:
831 case BuiltinType::UShortAccum:
832 case BuiltinType::UAccum:
833 case BuiltinType::ULongAccum:
834 case BuiltinType::ShortFract:
835 case BuiltinType::Fract:
836 case BuiltinType::LongFract:
837 case BuiltinType::UShortFract:
838 case BuiltinType::UFract:
839 case BuiltinType::ULongFract:
840 case BuiltinType::SatShortAccum:
841 case BuiltinType::SatAccum:
842 case BuiltinType::SatLongAccum:
843 case BuiltinType::SatUShortAccum:
844 case BuiltinType::SatUAccum:
845 case BuiltinType::SatULongAccum:
846 case BuiltinType::SatShortFract:
847 case BuiltinType::SatFract:
848 case BuiltinType::SatLongFract:
849 case BuiltinType::SatUShortFract:
850 case BuiltinType::SatUFract:
851 case BuiltinType::SatULongFract:
855#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
856 case BuiltinType::Id:
857#include "clang/Basic/OpenCLImageTypes.def"
858#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
859 case BuiltinType::Id:
860#include "clang/Basic/OpenCLExtensionTypes.def"
861#define SVE_TYPE(Name, Id, SingletonId) \
862 case BuiltinType::Id:
863#include "clang/Basic/AArch64ACLETypes.def"
864#define PPC_VECTOR_TYPE(Name, Id, Size) \
865 case BuiltinType::Id:
866#include "clang/Basic/PPCTypes.def"
867#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
868#include "clang/Basic/RISCVVTypes.def"
869#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
870#include "clang/Basic/WebAssemblyReferenceTypes.def"
871#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
872#include "clang/Basic/AMDGPUTypes.def"
873#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
874#include "clang/Basic/HLSLIntangibleTypes.def"
875#define SIGNED_TYPE(Id, SingletonId)
876#define UNSIGNED_TYPE(Id, SingletonId)
877#define FLOATING_TYPE(Id, SingletonId)
878#define BUILTIN_TYPE(Id, SingletonId) \
879 case BuiltinType::Id:
880#include "clang/AST/BuiltinTypes.def"
884 case BuiltinType::UInt:
885 case BuiltinType::Int:
886 case BuiltinType::Float:
890 case BuiltinType::Double:
894 case BuiltinType::Char_U:
895 case BuiltinType::UChar:
896 case BuiltinType::Char_S:
897 case BuiltinType::SChar:
901 case BuiltinType::Short:
902 case BuiltinType::UShort:
906 case BuiltinType::Long:
907 case BuiltinType::ULong:
911 case BuiltinType::LongLong:
912 case BuiltinType::ULongLong:
916 case BuiltinType::LongDouble:
922 if (LangOpt.C99 || LangOpt.CPlusPlus11)
928 switch (
CS.getKind()) {
956 HasAlternativeForm =
false;
957 HasLeadingZeroes =
false;
958 HasPlusPrefix =
false;
965 HasAlternativeForm =
false;
968 HasAlternativeForm =
false;
969 HasPlusPrefix =
false;
971 llvm_unreachable(
"Unexpected type");
988 if (IsLeftJustified) os <<
"-";
989 if (HasPlusPrefix) os <<
"+";
990 if (HasSpacePrefix) os <<
" ";
991 if (HasAlternativeForm) os <<
"#";
992 if (HasLeadingZeroes) os <<
"0";
997 Precision.toString(os);
1004 os <<
LM.toString();
1006 os <<
CS.toString();
1014 switch (
CS.getKind()) {
1038 if (!HasAlternativeForm)
1042 switch (
CS.getKind()) {
1071 if (!HasLeadingZeroes)
1075 switch (
CS.getKind()) {
1109 if (!HasSpacePrefix)
1113 switch (
CS.getKind()) {
1137 if (!IsLeftJustified)
1141 switch (
CS.getKind()) {
1151 if (!HasThousandsGrouping)
1154 switch (
CS.getKind()) {
1175 switch (
CS.getKind()) {
1214 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.