26 using namespace clang;
29 FormatStringHandler::~FormatStringHandler() {}
41 unsigned accumulator = 0;
42 bool hasDigits =
false;
44 for ( ; I != E; ++I) {
46 if (c >=
'0' && c <=
'9') {
48 accumulator = (accumulator * 10) + (c -
'0');
53 return OptionalAmount(OptionalAmount::Constant, accumulator, Beg, I - Beg,
68 return OptionalAmount(OptionalAmount::Arg, argIndex++, Beg, 0,
false);
81 const char *I = Beg + 1;
106 const char *Tmp = Beg;
125 const char *&Beg,
const char *E,
126 unsigned *argIndex) {
159 if (Amt.
getHowSpecified() == OptionalAmount::Constant && *(I++) ==
'$') {
187 const char *lmPosition = I;
193 lmKind = (I != E && *I ==
'h') ? (++I, LengthModifier::AsChar)
194 : LengthModifier::AsShort;
198 lmKind = (I != E && *I ==
'l') ? (++I, LengthModifier::AsLongLong)
199 : LengthModifier::AsLong;
201 case 'j': lmKind = LengthModifier::AsIntMax; ++I;
break;
202 case 'z': lmKind = LengthModifier::AsSizeT; ++I;
break;
203 case 't': lmKind = LengthModifier::AsPtrDiff; ++I;
break;
204 case 'L': lmKind = LengthModifier::AsLongDouble; ++I;
break;
205 case 'q': lmKind = LengthModifier::AsQuad; ++I;
break;
207 if (IsScanf && !LO.C99 && !LO.CPlusPlus11) {
212 if (I != E && (*I ==
's' || *I ==
'S' || *I ==
'[')) {
213 lmKind = LengthModifier::AsAllocate;
221 lmKind = LengthModifier::AsMAllocate;
229 if (I + 1 != E && I + 2 != E) {
230 if (I[1] ==
'6' && I[2] ==
'4') {
232 lmKind = LengthModifier::AsInt64;
238 if (I[1] ==
'3' && I[2] ==
'2') {
240 lmKind = LengthModifier::AsInt32;
245 lmKind = LengthModifier::AsInt3264;
248 lmKind = LengthModifier::AsWide; ++I;
break;
276 llvm_unreachable(
"ArgType must be valid");
283 argTy = ETy->getDecl()->getIntegerType();
286 switch (BT->getKind()) {
289 case BuiltinType::Char_S:
290 case BuiltinType::SChar:
291 case BuiltinType::UChar:
292 case BuiltinType::Char_U:
300 argTy = ETy->getDecl()->getIntegerType();
307 switch (BT->getKind()) {
310 case BuiltinType::Char_S:
311 case BuiltinType::SChar:
312 case BuiltinType::Char_U:
313 case BuiltinType::UChar:
316 case BuiltinType::Short:
318 case BuiltinType::UShort:
319 return T == C.
ShortTy ? Match : NoMatch;
320 case BuiltinType::Int:
322 case BuiltinType::UInt:
323 return T == C.
IntTy ? Match : NoMatch;
324 case BuiltinType::Long:
326 case BuiltinType::ULong:
327 return T == C.
LongTy ? Match : NoMatch;
328 case BuiltinType::LongLong:
330 case BuiltinType::ULongLong:
342 switch (BT->getKind()) {
343 case BuiltinType::Void:
344 case BuiltinType::Char_U:
345 case BuiltinType::UChar:
346 case BuiltinType::Char_S:
347 case BuiltinType::SChar:
380 return WInt == PromoArg ? Match : NoMatch;
388 return NoMatchPedantic;
393 case ObjCPointerTy: {
412 llvm_unreachable(
"Invalid ArgType Kind!");
419 llvm_unreachable(
"No representative type for Invalid ArgType");
421 llvm_unreachable(
"No representative type for Unknown ArgType");
451 std::string ArgType::getRepresentativeTypeName(
ASTContext &
C)
const {
452 std::string
S = getRepresentativeType(C).getAsString();
460 Alias += (Alias[Alias.size()-1] ==
'*') ?
"*" :
" *";
468 return std::string(
"'") + Alias +
"' (aka '" + S +
"')";
469 return std::string(
"'") + S +
"'";
531 case dArg:
return "d";
532 case DArg:
return "D";
533 case iArg:
return "i";
534 case oArg:
return "o";
535 case OArg:
return "O";
536 case uArg:
return "u";
537 case UArg:
return "U";
538 case xArg:
return "x";
539 case XArg:
return "X";
540 case fArg:
return "f";
541 case FArg:
return "F";
542 case eArg:
return "e";
543 case EArg:
return "E";
544 case gArg:
return "g";
545 case GArg:
return "G";
546 case aArg:
return "a";
547 case AArg:
return "A";
548 case cArg:
return "c";
549 case sArg:
return "s";
550 case pArg:
return "p";
551 case nArg:
return "n";
557 case CArg:
return "C";
558 case SArg:
return "S";
573 case ZArg:
return "Z";
722 return !Target.
getTriple().isOSDarwin() &&
775 llvm_unreachable(
"Invalid LengthModifier Kind!");
799 llvm_unreachable(
"Invalid LengthModifier Kind!");
829 return LangOpt.ObjC1 || LangOpt.ObjC2;
842 llvm_unreachable(
"Invalid ConversionSpecifier Kind!");
877 assert(isa<TypedefType>(QT) &&
"Expected a TypedefType");
882 if (Identifier->
getName() ==
"size_t") {
885 }
else if (Identifier->
getName() ==
"ssize_t") {
889 }
else if (Identifier->
getName() ==
"intmax_t") {
892 }
else if (Identifier->
getName() ==
"uintmax_t") {
895 }
else if (Identifier->
getName() ==
"ptrdiff_t") {
901 if (!isa<TypedefType>(T))
904 Typedef = cast<TypedefType>(T)->getDecl();
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
bool isNullPtrType() const
IdentifierInfo * getIdentifier() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
QualType getUnderlyingType() const
bool isVoidPointerType() const
bool isBlockPointerType() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
CanQualType UnsignedCharTy
QualType getPointeeType() const
Exposes information about the current target.
Defines the clang::LangOptions interface.
StringRef getName() const
Return the actual identifier string.
QualType getWIntType() const
In C99, this returns a type compatible with the type defined in <stddef.h> as defined by the target...
QualType getWideCharType() const
Return the type of wide characters. In C++, this returns the unique wchar_t type. In C99...
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
QualType getPointeeType() const
CanQualType UnsignedShortTy
Base class for declarations which introduce a typedef-name.
CanQualType ObjCBuiltinIdTy
static __inline__ uint32_t volatile uint32_t * p
CanQualType UnsignedLongLongTy
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getCorrespondingUnsignedType(QualType T) const
const RecordType * getAsStructureType() const
CanQualType UnsignedLongTy
bool isObjCObjectPointerType() const
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Defines the clang::TargetInfo interface.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
CanQualType UnsignedIntTy
bool isPointerType() const