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) {
122 const char *OSLogVisibilityFlagsStart =
nullptr,
123 *OSLogVisibilityFlagsEnd =
nullptr;
125 OSLogVisibilityFlagsStart = I++;
127 while (I != E && *I !=
'}') {
136 OSLogVisibilityFlagsEnd = I++;
140 const char *
P = OSLogVisibilityFlagsStart + 1;
141 while (P < OSLogVisibilityFlagsEnd && isspace(*P))
143 const char *WordStart =
P;
144 while (P < OSLogVisibilityFlagsEnd && (isalnum(*P) || *P ==
'_'))
146 const char *WordEnd =
P;
147 StringRef Word(WordStart, WordEnd - WordStart);
148 if (Word ==
"private") {
150 }
else if (Word ==
"public") {
157 for ( ; I != E; ++I) {
159 default: hasMore =
false;
break;
228 const char *ObjCModifierFlagsStart =
nullptr,
229 *ObjCModifierFlagsEnd =
nullptr;
231 ObjCModifierFlagsStart = I;
235 ObjCModifierFlagsEnd = I;
261 const char *conversionPosition = I++;
263 switch (*conversionPosition) {
299 if (isFreeBSDKPrintf)
303 if (isFreeBSDKPrintf)
307 if (isFreeBSDKPrintf)
312 if (isFreeBSDKPrintf)
314 else if (Target.
getTriple().isOSDarwin())
335 ObjCModifierFlagsStart) {
337 ObjCModifierFlagsEnd + 1,
352 unsigned Len = I - Start;
368 bool isFreeBSDKPrintf) {
370 unsigned argIndex = 0;
390 assert(I == E &&
"Format string not exhausted");
399 unsigned argIndex = 0;
428 bool IsObjCLiteral)
const {
435 switch (LM.getKind()) {
450 switch (LM.getKind()) {
483 switch (LM.getKind()) {
522 switch (LM.getKind()) {
608 HasThousandsGrouping =
false;
609 HasPlusPrefix =
false;
610 HasSpacePrefix =
false;
611 HasAlternativeForm =
false;
612 HasLeadingZeroes =
false;
624 HasAlternativeForm = 0;
625 HasLeadingZeroes = 0;
638 QT = ETy->getDecl()->getIntegerType();
647 case BuiltinType::Bool:
648 case BuiltinType::WChar_U:
649 case BuiltinType::WChar_S:
650 case BuiltinType::Char16:
651 case BuiltinType::Char32:
652 case BuiltinType::UInt128:
653 case BuiltinType::Int128:
654 case BuiltinType::Half:
655 case BuiltinType::Float16:
656 case BuiltinType::Float128:
660 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 661 case BuiltinType::Id: 662 #include "clang/Basic/OpenCLImageTypes.def" 663 #define SIGNED_TYPE(Id, SingletonId) 664 #define UNSIGNED_TYPE(Id, SingletonId) 665 #define FLOATING_TYPE(Id, SingletonId) 666 #define BUILTIN_TYPE(Id, SingletonId) \ 667 case BuiltinType::Id: 668 #include "clang/AST/BuiltinTypes.def" 672 case BuiltinType::UInt:
673 case BuiltinType::Int:
674 case BuiltinType::Float:
675 case BuiltinType::Double:
679 case BuiltinType::Char_U:
680 case BuiltinType::UChar:
681 case BuiltinType::Char_S:
682 case BuiltinType::SChar:
686 case BuiltinType::Short:
687 case BuiltinType::UShort:
691 case BuiltinType::Long:
692 case BuiltinType::ULong:
696 case BuiltinType::LongLong:
697 case BuiltinType::ULongLong:
701 case BuiltinType::LongDouble:
707 if (isa<TypedefType>(QT) && (LangOpt.C99 || LangOpt.CPlusPlus11))
708 namedTypeToLengthModifier(QT, LM);
713 switch (CS.getKind()) {
737 if (!isa<TypedefType>(QT) && QT->
isCharType()) {
741 HasAlternativeForm = 0;
742 HasLeadingZeroes = 0;
751 HasAlternativeForm = 0;
755 HasAlternativeForm = 0;
758 llvm_unreachable(
"Unexpected type");
770 if (usesPositionalArg()) {
771 os << getPositionalArgIndex() <<
"$";
775 if (IsLeftJustified) os <<
"-";
776 if (HasPlusPrefix) os <<
"+";
777 if (HasSpacePrefix) os <<
" ";
778 if (HasAlternativeForm) os <<
"#";
779 if (HasLeadingZeroes) os <<
"0";
782 FieldWidth.toString(os);
784 Precision.toString(os);
791 bool PrintfSpecifier::hasValidPlusPrefix()
const {
796 switch (CS.getKind()) {
817 bool PrintfSpecifier::hasValidAlternativeForm()
const {
818 if (!HasAlternativeForm)
822 switch (CS.getKind()) {
844 bool PrintfSpecifier::hasValidLeadingZeros()
const {
845 if (!HasLeadingZeroes)
849 switch (CS.getKind()) {
876 bool PrintfSpecifier::hasValidSpacePrefix()
const {
881 switch (CS.getKind()) {
902 bool PrintfSpecifier::hasValidLeftJustified()
const {
903 if (!IsLeftJustified)
907 switch (CS.getKind()) {
916 bool PrintfSpecifier::hasValidThousandsGroupingPrefix()
const {
917 if (!HasThousandsGrouping)
920 switch (CS.getKind()) {
936 bool PrintfSpecifier::hasValidPrecision()
const {
941 switch (CS.getKind()) {
969 bool PrintfSpecifier::hasValidFieldWidth()
const {
974 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>.