diff options
Diffstat (limited to 'lib/Analysis/FormatString.cpp')
-rw-r--r-- | lib/Analysis/FormatString.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp index ad0dce4..43ecc66 100644 --- a/lib/Analysis/FormatString.cpp +++ b/lib/Analysis/FormatString.cpp @@ -223,6 +223,27 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, break; } return false; + // printf: AsInt64, AsInt32, AsInt3264 + // scanf: AsInt64 + case 'I': + if (I + 1 != E && I + 2 != E) { + if (I[1] == '6' && I[2] == '4') { + I += 3; + lmKind = LengthModifier::AsInt64; + break; + } + if (IsScanf) + return false; + + if (I[1] == '3' && I[2] == '2') { + I += 3; + lmKind = LengthModifier::AsInt32; + break; + } + } + ++I; + lmKind = LengthModifier::AsInt3264; + break; } LengthModifier lm(lmPosition, lmKind); FS.setLengthModifier(lm); @@ -334,7 +355,7 @@ bool ArgType::matchesType(ASTContext &C, QualType argTy) const { return false; QualType pointeeTy = C.getCanonicalType(PT->getPointeeType()).getUnqualifiedType(); - return pointeeTy == C.getWCharType(); + return pointeeTy == C.getWideCharType(); } case WIntTy: { @@ -398,7 +419,7 @@ QualType ArgType::getRepresentativeType(ASTContext &C) const { Res = C.getPointerType(C.CharTy); break; case WCStrTy: - Res = C.getPointerType(C.getWCharType()); + Res = C.getPointerType(C.getWideCharType()); break; case ObjCPointerTy: Res = C.ObjCBuiltinIdTy; @@ -471,6 +492,12 @@ analyze_format_string::LengthModifier::toString() const { return "z"; case AsPtrDiff: return "t"; + case AsInt32: + return "I32"; + case AsInt3264: + return "I"; + case AsInt64: + return "I64"; case AsLongDouble: return "L"; case AsAllocate: @@ -514,7 +541,7 @@ const char *ConversionSpecifier::toString() const { case ScanListArg: return "["; case InvalidSpecifier: return NULL; - // MacOS X unicode extensions. + // POSIX unicode extensions. case CArg: return "C"; case SArg: return "S"; @@ -678,6 +705,20 @@ bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target) const { default: return false; } + case LengthModifier::AsInt32: + case LengthModifier::AsInt3264: + case LengthModifier::AsInt64: + switch (CS.getKind()) { + case ConversionSpecifier::dArg: + case ConversionSpecifier::iArg: + case ConversionSpecifier::oArg: + case ConversionSpecifier::uArg: + case ConversionSpecifier::xArg: + case ConversionSpecifier::XArg: + return Target.getTriple().isOSMSVCRT(); + default: + return false; + } } llvm_unreachable("Invalid LengthModifier Kind!"); } @@ -697,6 +738,9 @@ bool FormatSpecifier::hasStandardLengthModifier() const { case LengthModifier::AsAllocate: case LengthModifier::AsMAllocate: case LengthModifier::AsQuad: + case LengthModifier::AsInt32: + case LengthModifier::AsInt3264: + case LengthModifier::AsInt64: return false; } llvm_unreachable("Invalid LengthModifier Kind!"); |