diff options
| author | Ted Kremenek <kremenek@apple.com> | 2011-06-14 22:56:51 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2011-06-14 22:56:51 +0000 |
| commit | 192ed0b7eebcdf7905f595591496c22ced5a7042 (patch) | |
| tree | 0c61604a436cace13755e811e3da9b0992df61b1 /clang | |
| parent | cd7f70e8b5362390d8911fdd41b524ced88ab88c (diff) | |
| download | bcm5719-llvm-192ed0b7eebcdf7905f595591496c22ced5a7042.tar.gz bcm5719-llvm-192ed0b7eebcdf7905f595591496c22ced5a7042.zip | |
[format strings] correctly suggest correct type for '%@' specifiers. Fixes <rdar://problem/9607158>.
llvm-svn: 133024
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Analysis/FormatString.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Analysis/PrintfFormatString.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaObjC/format-strings-objc.m | 1 |
3 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Analysis/FormatString.cpp b/clang/lib/Analysis/FormatString.cpp index c1b5ea8a652..be214e0d86d 100644 --- a/clang/lib/Analysis/FormatString.cpp +++ b/clang/lib/Analysis/FormatString.cpp @@ -300,7 +300,8 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const { argTy->isNullPtrType(); case ObjCPointerTy: - return argTy->getAs<ObjCObjectPointerType>() != NULL; + return argTy->getAs<ObjCObjectPointerType>() != NULL || + argTy->getAs<BlockPointerType>() != NULL; } // FIXME: Should be unreachable, but Clang is currently emitting diff --git a/clang/lib/Analysis/PrintfFormatString.cpp b/clang/lib/Analysis/PrintfFormatString.cpp index 00b0b279e4a..270308a08f2 100644 --- a/clang/lib/Analysis/PrintfFormatString.cpp +++ b/clang/lib/Analysis/PrintfFormatString.cpp @@ -348,6 +348,8 @@ ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx) const { return Ctx.WCharTy; case ConversionSpecifier::pArg: return ArgTypeResult::CPointerTy; + case ConversionSpecifier::ObjCObjArg: + return ArgTypeResult::ObjCPointerTy; default: break; } diff --git a/clang/test/SemaObjC/format-strings-objc.m b/clang/test/SemaObjC/format-strings-objc.m index d89f50afa96..dd49cf7a936 100644 --- a/clang/test/SemaObjC/format-strings-objc.m +++ b/clang/test/SemaObjC/format-strings-objc.m @@ -38,6 +38,7 @@ int printf(const char * restrict, ...) ; void check_nslog(unsigned k) { NSLog(@"%d%%", k); // no-warning NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{invalid conversion specifier 'b'}} + NSLog(@"%@", "a"); // expected-warning {{conversion specifies type 'id' but the argument has type 'char *'}} } // Check type validation |

