diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-10-13 17:01:33 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-10-13 17:01:33 +0000 |
commit | af78e384376e526cfd369c67894e2538672914e7 (patch) | |
tree | bffeb84286ad83c735bd377c25d6220e2eea74c1 /contrib/llvm | |
parent | 501752af9c2900d1e6903aa8598db800e97cdfc7 (diff) | |
download | FreeBSD-src-af78e384376e526cfd369c67894e2538672914e7.zip FreeBSD-src-af78e384376e526cfd369c67894e2538672914e7.tar.gz |
Actually, check for any kind of "C string type".
Approved by: rpaulo (mentor)
Diffstat (limited to 'contrib/llvm')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp index 3429d86..8ce95ae 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp @@ -1519,14 +1519,10 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier // Now type check the data expression that matches the // format specifier. const Expr *Ex = getDataArg(argIndex); - QualType Pointee = S.Context.UnsignedCharTy; - Pointee.addConst(); - QualType constType = (CS.getKind() == ConversionSpecifier::bArg) ? S.Context.IntTy : S.Context.getPointerType(Pointee); - QualType type = (CS.getKind() == ConversionSpecifier::bArg) ? S.Context.IntTy : S.Context.getPointerType(S.Context.UnsignedCharTy); - const analyze_printf::ArgTypeResult &ConstATR = constType; - const analyze_printf::ArgTypeResult &ATR = type; - if (ATR.isValid() && !ATR.matchesType(S.Context, Ex->getType()) && - !ConstATR.matchesType(S.Context, Ex->getType())) + const analyze_printf::ArgTypeResult &ATR = + (CS.getKind() == ConversionSpecifier::bArg) ? + ArgTypeResult(S.Context.IntTy) : ArgTypeResult::CStrTy; + if (ATR.isValid() && !ATR.matchesType(S.Context, Ex->getType())) S.Diag(getLocationOfByte(CS.getStart()), diag::warn_printf_conversion_argument_type_mismatch) << ATR.getRepresentativeType(S.Context) << Ex->getType() |