27 using namespace clang;
39 const char *Start,
const char *&Beg,
const char *E,
54 const char *FlagBeg,
const char *E,
bool Warn) {
55 StringRef Flag(FlagBeg, E - FlagBeg);
78 bool isFreeBSDKPrintf) {
84 const char *Start =
nullptr;
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.startswith(
"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.equals(
"sensitive"))
151 else if (PrivacyFlags !=
153 MatchedStr.equals(
"private"))
155 else if (PrivacyFlags == 0 && MatchedStr.equals(
"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) {
338 if (isFreeBSDKPrintf)
342 if (isFreeBSDKPrintf)
346 if (isFreeBSDKPrintf)
351 if (isFreeBSDKPrintf)
353 else if (Target.
getTriple().isOSDarwin())
375 ObjCModifierFlagsStart) {
377 ObjCModifierFlagsEnd + 1,
392 unsigned Len = I - Start;
408 bool isFreeBSDKPrintf) {
410 unsigned argIndex = 0;
430 assert(I == E &&
"Format string not exhausted");
439 unsigned argIndex = 0;
468 bool IsObjCLiteral)
const {
470 switch (LM.getKind()) {
485 switch (LM.getKind()) {
519 switch (LM.getKind()) {
552 if (CS.isDoubleArg()) {
559 switch (LM.getKind()) {
589 switch (CS.getKind()) {
630 bool IsObjCLiteral)
const {
636 ArgType ScalarTy = getScalarArgType(Ctx, IsObjCLiteral);
637 if (!ScalarTy.
isValid() || VectorNumElts.isInvalid())
640 return ScalarTy.
makeVectorType(Ctx, VectorNumElts.getConstantAmount());
660 HasThousandsGrouping =
false;
661 HasPlusPrefix =
false;
662 HasSpacePrefix =
false;
663 HasAlternativeForm =
false;
664 HasLeadingZeroes =
false;
676 HasAlternativeForm = 0;
677 HasLeadingZeroes = 0;
690 QT = ETy->getDecl()->getIntegerType();
708 case BuiltinType::Bool:
709 case BuiltinType::WChar_U:
710 case BuiltinType::WChar_S:
711 case BuiltinType::Char8:
712 case BuiltinType::Char16:
713 case BuiltinType::Char32:
714 case BuiltinType::UInt128:
715 case BuiltinType::Int128:
716 case BuiltinType::Half:
717 case BuiltinType::Float16:
718 case BuiltinType::Float128:
719 case BuiltinType::ShortAccum:
720 case BuiltinType::Accum:
721 case BuiltinType::LongAccum:
722 case BuiltinType::UShortAccum:
723 case BuiltinType::UAccum:
724 case BuiltinType::ULongAccum:
725 case BuiltinType::ShortFract:
726 case BuiltinType::Fract:
727 case BuiltinType::LongFract:
728 case BuiltinType::UShortFract:
729 case BuiltinType::UFract:
730 case BuiltinType::ULongFract:
731 case BuiltinType::SatShortAccum:
732 case BuiltinType::SatAccum:
733 case BuiltinType::SatLongAccum:
734 case BuiltinType::SatUShortAccum:
735 case BuiltinType::SatUAccum:
736 case BuiltinType::SatULongAccum:
737 case BuiltinType::SatShortFract:
738 case BuiltinType::SatFract:
739 case BuiltinType::SatLongFract:
740 case BuiltinType::SatUShortFract:
741 case BuiltinType::SatUFract:
742 case BuiltinType::SatULongFract:
746 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 747 case BuiltinType::Id: 748 #include "clang/Basic/OpenCLImageTypes.def" 749 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 750 case BuiltinType::Id: 751 #include "clang/Basic/OpenCLExtensionTypes.def" 752 #define SIGNED_TYPE(Id, SingletonId) 753 #define UNSIGNED_TYPE(Id, SingletonId) 754 #define FLOATING_TYPE(Id, SingletonId) 755 #define BUILTIN_TYPE(Id, SingletonId) \ 756 case BuiltinType::Id: 757 #include "clang/AST/BuiltinTypes.def" 761 case BuiltinType::UInt:
762 case BuiltinType::Int:
763 case BuiltinType::Float:
764 case BuiltinType::Double:
768 case BuiltinType::Char_U:
769 case BuiltinType::UChar:
770 case BuiltinType::Char_S:
771 case BuiltinType::SChar:
775 case BuiltinType::Short:
776 case BuiltinType::UShort:
780 case BuiltinType::Long:
781 case BuiltinType::ULong:
785 case BuiltinType::LongLong:
786 case BuiltinType::ULongLong:
790 case BuiltinType::LongDouble:
796 if (isa<TypedefType>(QT) && (LangOpt.C99 || LangOpt.CPlusPlus11))
797 namedTypeToLengthModifier(QT, LM);
802 switch (CS.getKind()) {
826 if (!isa<TypedefType>(QT) && QT->
isCharType()) {
830 HasAlternativeForm = 0;
831 HasLeadingZeroes = 0;
840 HasAlternativeForm = 0;
844 HasAlternativeForm = 0;
847 llvm_unreachable(
"Unexpected type");
859 if (usesPositionalArg()) {
860 os << getPositionalArgIndex() <<
"$";
864 if (IsLeftJustified) os <<
"-";
865 if (HasPlusPrefix) os <<
"+";
866 if (HasSpacePrefix) os <<
" ";
867 if (HasAlternativeForm) os <<
"#";
868 if (HasLeadingZeroes) os <<
"0";
871 FieldWidth.toString(os);
873 Precision.toString(os);
876 if (!VectorNumElts.isInvalid())
877 os <<
'v' << VectorNumElts.getConstantAmount();
885 bool PrintfSpecifier::hasValidPlusPrefix()
const {
890 switch (CS.getKind()) {
911 bool PrintfSpecifier::hasValidAlternativeForm()
const {
912 if (!HasAlternativeForm)
916 switch (CS.getKind()) {
938 bool PrintfSpecifier::hasValidLeadingZeros()
const {
939 if (!HasLeadingZeroes)
943 switch (CS.getKind()) {
970 bool PrintfSpecifier::hasValidSpacePrefix()
const {
975 switch (CS.getKind()) {
996 bool PrintfSpecifier::hasValidLeftJustified()
const {
997 if (!IsLeftJustified)
1001 switch (CS.getKind()) {
1010 bool PrintfSpecifier::hasValidThousandsGroupingPrefix()
const {
1011 if (!HasThousandsGrouping)
1014 switch (CS.getKind()) {
1030 bool PrintfSpecifier::hasValidPrecision()
const {
1035 switch (CS.getKind()) {
1063 bool PrintfSpecifier::hasValidFieldWidth()
const {
1068 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>.