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 =
"^[\t\n\v\f\r ]*(private|public)[\t\n\v\f\r ]*(,|})";
131 llvm::Regex R(Match);
134 if (R.match(Str, &Matches)) {
135 MatchedStr = Matches[1];
136 I += Matches[0].size();
141 if (MatchedStr.equals(
"private"))
143 else if (PrivacyFlags == 0 && MatchedStr.equals(
"public"))
146 size_t CommaOrBracePos =
147 Str.find_if([](
char c) {
return c ==
',' || c ==
'}'; });
149 if (CommaOrBracePos == StringRef::npos) {
156 I += CommaOrBracePos + 1;
159 }
while (*(I - 1) ==
',');
162 switch (PrivacyFlags) {
172 llvm_unreachable(
"Unexpected privacy flag value");
178 for ( ; I != E; ++I) {
180 default: hasMore =
false;
break;
249 const char *ObjCModifierFlagsStart =
nullptr,
250 *ObjCModifierFlagsEnd =
nullptr;
252 ObjCModifierFlagsStart = I;
256 ObjCModifierFlagsEnd = I;
282 const char *conversionPosition = I++;
284 switch (*conversionPosition) {
320 if (isFreeBSDKPrintf)
324 if (isFreeBSDKPrintf)
328 if (isFreeBSDKPrintf)
333 if (isFreeBSDKPrintf)
335 else if (Target.
getTriple().isOSDarwin())
356 ObjCModifierFlagsStart) {
358 ObjCModifierFlagsEnd + 1,
373 unsigned Len = I - Start;
389 bool isFreeBSDKPrintf) {
391 unsigned argIndex = 0;
411 assert(I == E &&
"Format string not exhausted");
420 unsigned argIndex = 0;
449 bool IsObjCLiteral)
const {
456 switch (LM.getKind()) {
471 switch (LM.getKind()) {
505 switch (LM.getKind()) {
545 switch (LM.getKind()) {
631 HasThousandsGrouping =
false;
632 HasPlusPrefix =
false;
633 HasSpacePrefix =
false;
634 HasAlternativeForm =
false;
635 HasLeadingZeroes =
false;
647 HasAlternativeForm = 0;
648 HasLeadingZeroes = 0;
661 QT = ETy->getDecl()->getIntegerType();
670 case BuiltinType::Bool:
671 case BuiltinType::WChar_U:
672 case BuiltinType::WChar_S:
673 case BuiltinType::Char8:
674 case BuiltinType::Char16:
675 case BuiltinType::Char32:
676 case BuiltinType::UInt128:
677 case BuiltinType::Int128:
678 case BuiltinType::Half:
679 case BuiltinType::Float16:
680 case BuiltinType::Float128:
681 case BuiltinType::ShortAccum:
682 case BuiltinType::Accum:
683 case BuiltinType::LongAccum:
684 case BuiltinType::UShortAccum:
685 case BuiltinType::UAccum:
686 case BuiltinType::ULongAccum:
687 case BuiltinType::ShortFract:
688 case BuiltinType::Fract:
689 case BuiltinType::LongFract:
690 case BuiltinType::UShortFract:
691 case BuiltinType::UFract:
692 case BuiltinType::ULongFract:
693 case BuiltinType::SatShortAccum:
694 case BuiltinType::SatAccum:
695 case BuiltinType::SatLongAccum:
696 case BuiltinType::SatUShortAccum:
697 case BuiltinType::SatUAccum:
698 case BuiltinType::SatULongAccum:
699 case BuiltinType::SatShortFract:
700 case BuiltinType::SatFract:
701 case BuiltinType::SatLongFract:
702 case BuiltinType::SatUShortFract:
703 case BuiltinType::SatUFract:
704 case BuiltinType::SatULongFract:
708 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 709 case BuiltinType::Id: 710 #include "clang/Basic/OpenCLImageTypes.def" 711 #define SIGNED_TYPE(Id, SingletonId) 712 #define UNSIGNED_TYPE(Id, SingletonId) 713 #define FLOATING_TYPE(Id, SingletonId) 714 #define BUILTIN_TYPE(Id, SingletonId) \ 715 case BuiltinType::Id: 716 #include "clang/AST/BuiltinTypes.def" 720 case BuiltinType::UInt:
721 case BuiltinType::Int:
722 case BuiltinType::Float:
723 case BuiltinType::Double:
727 case BuiltinType::Char_U:
728 case BuiltinType::UChar:
729 case BuiltinType::Char_S:
730 case BuiltinType::SChar:
734 case BuiltinType::Short:
735 case BuiltinType::UShort:
739 case BuiltinType::Long:
740 case BuiltinType::ULong:
744 case BuiltinType::LongLong:
745 case BuiltinType::ULongLong:
749 case BuiltinType::LongDouble:
755 if (isa<TypedefType>(QT) && (LangOpt.C99 || LangOpt.CPlusPlus11))
756 namedTypeToLengthModifier(QT, LM);
761 switch (CS.getKind()) {
785 if (!isa<TypedefType>(QT) && QT->
isCharType()) {
789 HasAlternativeForm = 0;
790 HasLeadingZeroes = 0;
799 HasAlternativeForm = 0;
803 HasAlternativeForm = 0;
806 llvm_unreachable(
"Unexpected type");
818 if (usesPositionalArg()) {
819 os << getPositionalArgIndex() <<
"$";
823 if (IsLeftJustified) os <<
"-";
824 if (HasPlusPrefix) os <<
"+";
825 if (HasSpacePrefix) os <<
" ";
826 if (HasAlternativeForm) os <<
"#";
827 if (HasLeadingZeroes) os <<
"0";
830 FieldWidth.toString(os);
832 Precision.toString(os);
839 bool PrintfSpecifier::hasValidPlusPrefix()
const {
844 switch (CS.getKind()) {
865 bool PrintfSpecifier::hasValidAlternativeForm()
const {
866 if (!HasAlternativeForm)
870 switch (CS.getKind()) {
892 bool PrintfSpecifier::hasValidLeadingZeros()
const {
893 if (!HasLeadingZeroes)
897 switch (CS.getKind()) {
924 bool PrintfSpecifier::hasValidSpacePrefix()
const {
929 switch (CS.getKind()) {
950 bool PrintfSpecifier::hasValidLeftJustified()
const {
951 if (!IsLeftJustified)
955 switch (CS.getKind()) {
964 bool PrintfSpecifier::hasValidThousandsGroupingPrefix()
const {
965 if (!HasThousandsGrouping)
968 switch (CS.getKind()) {
984 bool PrintfSpecifier::hasValidPrecision()
const {
989 switch (CS.getKind()) {
1017 bool PrintfSpecifier::hasValidFieldWidth()
const {
1022 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.
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.
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 setIsPrivate(const char *position)
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
std::string toString(const til::SExpr *E)
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.
bool isPointerType() const
void setHasAlternativeForm(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>.