[cfe-commits] r133024 - in /cfe/trunk: lib/Analysis/FormatString.cpp lib/Analysis/PrintfFormatString.cpp test/SemaObjC/format-strings-objc.m
Ted Kremenek
kremenek at apple.com
Tue Jun 14 15:56:51 PDT 2011
Author: kremenek
Date: Tue Jun 14 17:56:51 2011
New Revision: 133024
URL: http://llvm.org/viewvc/llvm-project?rev=133024&view=rev
Log:
[format strings] correctly suggest correct type for '%@' specifiers. Fixes <rdar://problem/9607158>.
Modified:
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/test/SemaObjC/format-strings-objc.m
Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=133024&r1=133023&r2=133024&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Tue Jun 14 17:56:51 2011
@@ -300,7 +300,8 @@
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
Modified: cfe/trunk/lib/Analysis/PrintfFormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PrintfFormatString.cpp?rev=133024&r1=133023&r2=133024&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Tue Jun 14 17:56:51 2011
@@ -348,6 +348,8 @@
return Ctx.WCharTy;
case ConversionSpecifier::pArg:
return ArgTypeResult::CPointerTy;
+ case ConversionSpecifier::ObjCObjArg:
+ return ArgTypeResult::ObjCPointerTy;
default:
break;
}
Modified: cfe/trunk/test/SemaObjC/format-strings-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/format-strings-objc.m?rev=133024&r1=133023&r2=133024&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/format-strings-objc.m (original)
+++ cfe/trunk/test/SemaObjC/format-strings-objc.m Tue Jun 14 17:56:51 2011
@@ -38,6 +38,7 @@
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
More information about the cfe-commits
mailing list