26 using namespace clang;
38 const char *Start,
const char *&Beg,
const char *E,
53 const char *FlagBeg,
const char *E,
bool Warn) {
54 StringRef Flag(FlagBeg, E - FlagBeg);
77 bool isFreeBSDKPrintf) {
83 const char *Start =
nullptr;
87 for ( ; I != E ; ++I) {
124 unsigned char PrivacyFlags = 0;
125 StringRef MatchedStr;
128 StringRef Str(I, E - I);
129 std::string Match =
"^[[:space:]]*" 130 "(private|public|sensitive|mask\\.[^[:space:],}]*)" 132 llvm::Regex R(Match);
135 if (R.match(Str, &Matches)) {
136 MatchedStr = Matches[1];
137 I += Matches[0].size();
142 if (MatchedStr.startswith(
"mask")) {
143 StringRef MaskType = MatchedStr.substr(
sizeof(
"mask.") - 1);
144 unsigned Size = MaskType.size();
145 if (Warn && (Size == 0 || Size > 8))
148 }
else if (MatchedStr.equals(
"sensitive"))
150 else if (PrivacyFlags !=
152 MatchedStr.equals(
"private"))
154 else if (PrivacyFlags == 0 && MatchedStr.equals(
"public"))
157 size_t CommaOrBracePos =
158 Str.find_if([](
char c) {
return c ==
',' || c ==
'}'; });
160 if (CommaOrBracePos == StringRef::npos) {
167 I += CommaOrBracePos + 1;
170 }
while (*(I - 1) ==
',');
173 switch (PrivacyFlags) {
186 llvm_unreachable(
"Unexpected privacy flag value");
192 for ( ; I != E; ++I) {
194 default: hasMore =
false;
break;
266 const char *ObjCModifierFlagsStart =
nullptr,
267 *ObjCModifierFlagsEnd =
nullptr;
269 ObjCModifierFlagsStart = I;
273 ObjCModifierFlagsEnd = I;
299 const char *conversionPosition = I++;
301 switch (*conversionPosition) {
341 if (isFreeBSDKPrintf)
345 if (isFreeBSDKPrintf)
349 if (isFreeBSDKPrintf)
354 if (isFreeBSDKPrintf)
356 else if (Target.
getTriple().isOSDarwin())
378 ObjCModifierFlagsStart) {
380 ObjCModifierFlagsEnd + 1,
395 unsigned Len = I - Start;
411 bool isFreeBSDKPrintf) {
413 unsigned argIndex = 0;
433 assert(I == E &&
"Format string not exhausted");
442 unsigned argIndex = 0;
469 unsigned ArgIndex = 0;
472 while (Begin != End) {
488 bool IsObjCLiteral)
const {
490 switch (LM.getKind()) {
505 switch (LM.getKind()) {
541 switch (LM.getKind()) {
575 if (CS.isDoubleArg()) {
576 if (!VectorNumElts.isInvalid()) {
577 switch (LM.getKind()) {
594 switch (LM.getKind()) {
622 llvm_unreachable(
"only used for OpenCL which doesn not handle nArg");
626 switch (CS.getKind()) {
667 bool IsObjCLiteral)
const {
673 ArgType ScalarTy = getScalarArgType(Ctx, IsObjCLiteral);
674 if (!ScalarTy.
isValid() || VectorNumElts.isInvalid())
677 return ScalarTy.
makeVectorType(Ctx, VectorNumElts.getConstantAmount());
697 HasThousandsGrouping =
false;
698 HasPlusPrefix =
false;
699 HasSpacePrefix =
false;
700 HasAlternativeForm =
false;
701 HasLeadingZeroes =
false;
713 HasAlternativeForm = 0;
714 HasLeadingZeroes = 0;
727 QT = ETy->getDecl()->getIntegerType();
745 case BuiltinType::Bool:
746 case BuiltinType::WChar_U:
747 case BuiltinType::WChar_S:
748 case BuiltinType::Char8:
749 case BuiltinType::Char16:
750 case BuiltinType::Char32:
751 case BuiltinType::UInt128:
752 case BuiltinType::Int128:
753 case BuiltinType::Half:
754 case BuiltinType::Float16:
755 case BuiltinType::Float128:
756 case BuiltinType::ShortAccum:
757 case BuiltinType::Accum:
758 case BuiltinType::LongAccum:
759 case BuiltinType::UShortAccum:
760 case BuiltinType::UAccum:
761 case BuiltinType::ULongAccum:
762 case BuiltinType::ShortFract:
763 case BuiltinType::Fract:
764 case BuiltinType::LongFract:
765 case BuiltinType::UShortFract:
766 case BuiltinType::UFract:
767 case BuiltinType::ULongFract:
768 case BuiltinType::SatShortAccum:
769 case BuiltinType::SatAccum:
770 case BuiltinType::SatLongAccum:
771 case BuiltinType::SatUShortAccum:
772 case BuiltinType::SatUAccum:
773 case BuiltinType::SatULongAccum:
774 case BuiltinType::SatShortFract:
775 case BuiltinType::SatFract:
776 case BuiltinType::SatLongFract:
777 case BuiltinType::SatUShortFract:
778 case BuiltinType::SatUFract:
779 case BuiltinType::SatULongFract:
783 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 784 case BuiltinType::Id: 785 #include "clang/Basic/OpenCLImageTypes.def" 786 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 787 case BuiltinType::Id: 788 #include "clang/Basic/OpenCLExtensionTypes.def" 789 #define SVE_TYPE(Name, Id, SingletonId) \ 790 case BuiltinType::Id: 791 #include "clang/Basic/AArch64SVEACLETypes.def" 792 #define SIGNED_TYPE(Id, SingletonId) 793 #define UNSIGNED_TYPE(Id, SingletonId) 794 #define FLOATING_TYPE(Id, SingletonId) 795 #define BUILTIN_TYPE(Id, SingletonId) \ 796 case BuiltinType::Id: 797 #include "clang/AST/BuiltinTypes.def" 801 case BuiltinType::UInt:
802 case BuiltinType::Int:
803 case BuiltinType::Float:
804 LM.setKind(VectorNumElts.isInvalid() ?
807 case BuiltinType::Double:
808 LM.setKind(VectorNumElts.isInvalid() ?
811 case BuiltinType::Char_U:
812 case BuiltinType::UChar:
813 case BuiltinType::Char_S:
814 case BuiltinType::SChar:
818 case BuiltinType::Short:
819 case BuiltinType::UShort:
823 case BuiltinType::Long:
824 case BuiltinType::ULong:
828 case BuiltinType::LongLong:
829 case BuiltinType::ULongLong:
833 case BuiltinType::LongDouble:
839 if (isa<TypedefType>(QT) && (LangOpt.C99 || LangOpt.CPlusPlus11))
840 namedTypeToLengthModifier(QT, LM);
845 switch (CS.getKind()) {
869 if (!isa<TypedefType>(QT) && QT->
isCharType()) {
873 HasAlternativeForm = 0;
874 HasLeadingZeroes = 0;
883 HasAlternativeForm = 0;
887 HasAlternativeForm = 0;
890 llvm_unreachable(
"Unexpected type");
902 if (usesPositionalArg()) {
903 os << getPositionalArgIndex() <<
"$";
907 if (IsLeftJustified) os <<
"-";
908 if (HasPlusPrefix) os <<
"+";
909 if (HasSpacePrefix) os <<
" ";
910 if (HasAlternativeForm) os <<
"#";
911 if (HasLeadingZeroes) os <<
"0";
914 FieldWidth.toString(os);
916 Precision.toString(os);
919 if (!VectorNumElts.isInvalid())
920 os <<
'v' << VectorNumElts.getConstantAmount();
928 bool PrintfSpecifier::hasValidPlusPrefix()
const {
933 switch (CS.getKind()) {
954 bool PrintfSpecifier::hasValidAlternativeForm()
const {
955 if (!HasAlternativeForm)
959 switch (CS.getKind()) {
981 bool PrintfSpecifier::hasValidLeadingZeros()
const {
982 if (!HasLeadingZeroes)
986 switch (CS.getKind()) {
1013 bool PrintfSpecifier::hasValidSpacePrefix()
const {
1014 if (!HasSpacePrefix)
1018 switch (CS.getKind()) {
1039 bool PrintfSpecifier::hasValidLeftJustified()
const {
1040 if (!IsLeftJustified)
1044 switch (CS.getKind()) {
1053 bool PrintfSpecifier::hasValidThousandsGroupingPrefix()
const {
1054 if (!HasThousandsGrouping)
1057 switch (CS.getKind()) {
1073 bool PrintfSpecifier::hasValidPrecision()
const {
1078 switch (CS.getKind()) {
1106 bool PrintfSpecifier::hasValidFieldWidth()
const {
1111 switch (CS.getKind()) {
QualType withConst() const
Retrieves a version of this type with const applied.
A (possibly-)qualified type.
void setIsPublic(const char *position)
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool isRealFloatingType() const
Floating point categories.
const TargetInfo & getTargetInfo() const
void setHasLeadingZeros(const char *position)
bool usesPositionalArg() 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 isWideCharType() const
void setPrecision(const OptionalAmount &Amt)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Pieces specific to fprintf format strings.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
void setHasSpacePrefix(const char *position)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
QualType getUnsignedPointerDiffType() const
Return the unique unsigned counterpart of "ptrdiff_t" integer type.
void setConversionSpecifier(const PrintfConversionSpecifier &cs)
void setIsLeftJustified(const char *position)
CanQualType UnsignedCharTy
Exposes information about the current target.
bool isObjCRetainableType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
Represents a GCC generic vector type.
CanQualType getUIntMaxType() const
Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in <stdint.h>.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
void setMaskType(StringRef S)
void setIsPrivate(const char *position)
QualType getElementType() const
CanQualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t. ...
void setHasThousandsGrouping(const char *position)
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
const PrintfConversionSpecifier & getConversionSpecifier() const
CanQualType UnsignedShortTy
Dataflow Directional Tag Classes.
CanQualType UnsignedLongLongTy
void setHasObjCTechnicalTerm(const char *position)
CanQualType UnsignedLongTy
void setHasPlusPrefix(const char *position)
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
This class is used for builtin types like 'int'.
Defines the clang::TargetInfo interface.
unsigned getNumElements() const
bool isPointerType() const
void setHasAlternativeForm(const char *position)
void setIsSensitive(const char *position)
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
CanQualType UnsignedIntTy
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.