From: Daniel Dunbar Date: Tue, 28 Jun 2011 23:33:55 +0000 (+0000) Subject: Revert r133024, "[format strings] correctly suggest correct type for '%@' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6a4d18f52a775ec9012f5eaec9e5190b0499823;p=clang Revert r133024, "[format strings] correctly suggest correct type for '%@' specifiers. Fixes ." because it causes false positives on some code that uses CF toll free bridging. - I'll let Doug or Ted figure out the right fix here, possibly just to accept any pointer type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134041 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp index be214e0d86..c1b5ea8a65 100644 --- a/lib/Analysis/FormatString.cpp +++ b/lib/Analysis/FormatString.cpp @@ -300,8 +300,7 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const { argTy->isNullPtrType(); case ObjCPointerTy: - return argTy->getAs() != NULL || - argTy->getAs() != NULL; + return argTy->getAs() != NULL; } // FIXME: Should be unreachable, but Clang is currently emitting diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp index 270308a08f..00b0b279e4 100644 --- a/lib/Analysis/PrintfFormatString.cpp +++ b/lib/Analysis/PrintfFormatString.cpp @@ -348,8 +348,6 @@ 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/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m index dd49cf7a93..d89f50afa9 100644 --- a/test/SemaObjC/format-strings-objc.m +++ b/test/SemaObjC/format-strings-objc.m @@ -38,7 +38,6 @@ 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