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;
471 bool IsObjCLiteral)
const {
473 switch (LM.getKind()) {
488 switch (LM.getKind()) {
524 switch (LM.getKind()) {
558 if (CS.isDoubleArg()) {
559 if (!VectorNumElts.isInvalid()) {
560 switch (LM.getKind()) {
577 switch (LM.getKind()) {
605 llvm_unreachable(
"only used for OpenCL which doesn not handle nArg");
609 switch (CS.getKind()) {
650 bool IsObjCLiteral)
const {
656 ArgType ScalarTy = getScalarArgType(Ctx, IsObjCLiteral);
657 if (!ScalarTy.
isValid() || VectorNumElts.isInvalid())
660 return ScalarTy.
makeVectorType(Ctx, VectorNumElts.getConstantAmount());
680 HasThousandsGrouping =
false;
681 HasPlusPrefix =
false;
682 HasSpacePrefix =
false;
683 HasAlternativeForm =
false;
684 HasLeadingZeroes =
false;
696 HasAlternativeForm = 0;
697 HasLeadingZeroes = 0;
710 QT = ETy->getDecl()->getIntegerType();
728 case BuiltinType::Bool:
729 case BuiltinType::WChar_U:
730 case BuiltinType::WChar_S:
731 case BuiltinType::Char8:
732 case BuiltinType::Char16:
733 case BuiltinType::Char32:
734 case BuiltinType::UInt128:
735 case BuiltinType::Int128:
736 case BuiltinType::Half:
737 case BuiltinType::Float16:
738 case BuiltinType::Float128:
739 case BuiltinType::ShortAccum:
740 case BuiltinType::Accum:
741 case BuiltinType::LongAccum:
742 case BuiltinType::UShortAccum:
743 case BuiltinType::UAccum:
744 case BuiltinType::ULongAccum:
745 case BuiltinType::ShortFract:
746 case BuiltinType::Fract:
747 case BuiltinType::LongFract:
748 case BuiltinType::UShortFract:
749 case BuiltinType::UFract:
750 case BuiltinType::ULongFract:
751 case BuiltinType::SatShortAccum:
752 case BuiltinType::SatAccum:
753 case BuiltinType::SatLongAccum:
754 case BuiltinType::SatUShortAccum:
755 case BuiltinType::SatUAccum:
756 case BuiltinType::SatULongAccum:
757 case BuiltinType::SatShortFract:
758 case BuiltinType::SatFract:
759 case BuiltinType::SatLongFract:
760 case BuiltinType::SatUShortFract:
761 case BuiltinType::SatUFract:
762 case BuiltinType::SatULongFract:
766 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 767 case BuiltinType::Id: 768 #include "clang/Basic/OpenCLImageTypes.def" 769 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 770 case BuiltinType::Id: 771 #include "clang/Basic/OpenCLExtensionTypes.def" 772 #define SIGNED_TYPE(Id, SingletonId) 773 #define UNSIGNED_TYPE(Id, SingletonId) 774 #define FLOATING_TYPE(Id, SingletonId) 775 #define BUILTIN_TYPE(Id, SingletonId) \ 776 case BuiltinType::Id: 777 #include "clang/AST/BuiltinTypes.def" 781 case BuiltinType::UInt:
782 case BuiltinType::Int:
783 case BuiltinType::Float:
784 LM.setKind(VectorNumElts.isInvalid() ?
787 case BuiltinType::Double:
788 LM.setKind(VectorNumElts.isInvalid() ?
791 case BuiltinType::Char_U:
792 case BuiltinType::UChar:
793 case BuiltinType::Char_S:
794 case BuiltinType::SChar:
798 case BuiltinType::Short:
799 case BuiltinType::UShort:
803 case BuiltinType::Long:
804 case BuiltinType::ULong:
808 case BuiltinType::LongLong:
809 case BuiltinType::ULongLong:
813 case BuiltinType::LongDouble:
819 if (isa<TypedefType>(QT) && (LangOpt.C99 || LangOpt.CPlusPlus11))
820 namedTypeToLengthModifier(QT, LM);
825 switch (CS.getKind()) {
849 if (!isa<TypedefType>(QT) && QT->
isCharType()) {
853 HasAlternativeForm = 0;
854 HasLeadingZeroes = 0;
863 HasAlternativeForm = 0;
867 HasAlternativeForm = 0;
870 llvm_unreachable(
"Unexpected type");
882 if (usesPositionalArg()) {
883 os << getPositionalArgIndex() <<
"$";
887 if (IsLeftJustified) os <<
"-";
888 if (HasPlusPrefix) os <<
"+";
889 if (HasSpacePrefix) os <<
" ";
890 if (HasAlternativeForm) os <<
"#";
891 if (HasLeadingZeroes) os <<
"0";
894 FieldWidth.toString(os);
896 Precision.toString(os);
899 if (!VectorNumElts.isInvalid())
900 os <<
'v' << VectorNumElts.getConstantAmount();
908 bool PrintfSpecifier::hasValidPlusPrefix()
const {
913 switch (CS.getKind()) {
934 bool PrintfSpecifier::hasValidAlternativeForm()
const {
935 if (!HasAlternativeForm)
939 switch (CS.getKind()) {
961 bool PrintfSpecifier::hasValidLeadingZeros()
const {
962 if (!HasLeadingZeroes)
966 switch (CS.getKind()) {
993 bool PrintfSpecifier::hasValidSpacePrefix()
const {
998 switch (CS.getKind()) {
1019 bool PrintfSpecifier::hasValidLeftJustified()
const {
1020 if (!IsLeftJustified)
1024 switch (CS.getKind()) {
1033 bool PrintfSpecifier::hasValidThousandsGroupingPrefix()
const {
1034 if (!HasThousandsGrouping)
1037 switch (CS.getKind()) {
1053 bool PrintfSpecifier::hasValidPrecision()
const {
1058 switch (CS.getKind()) {
1086 bool PrintfSpecifier::hasValidFieldWidth()
const {
1091 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>.