]> granicus.if.org Git - clang/commitdiff
Teach VariadicMethodTypeChecker that CF references are valid arguments to variadic...
authorTed Kremenek <kremenek@apple.com>
Thu, 17 Mar 2011 04:01:35 +0000 (04:01 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 17 Mar 2011 04:01:35 +0000 (04:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127797 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
test/Analysis/variadic-method-types.m

index 792b720b8fb15389e19eec4c46dde177f54ea667..51847094dadb8b16d69ed90bf96c1873ebaef883 100644 (file)
@@ -14,6 +14,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "ClangSACheckers.h"
+#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
@@ -594,6 +595,10 @@ void VariadicMethodTypeChecker::checkPreObjCMessage(ObjCMessage msg,
     // Ignore pointer constants.
     if (isa<loc::ConcreteInt>(msg.getArgSVal(I, state)))
       continue;
+    
+    // Ignore CF references, which can be toll-free bridged.
+    if (cocoa::isCFObjectRef(ArgTy))
+      continue;
 
     // Generate only one error node to use for all bug reports.
     if (!errorNode.hasValue()) {
index 6f67d2f0d5f8f7815f305a922eb434837bbec6e4..7d199134355f64c79ebc174a95d8cb40e9cb04b6 100644 (file)
@@ -11,7 +11,8 @@
 //===----------------------------------------------------------------------===//
 
 #define nil (void*)0
-
+typedef const struct __CFString * CFStringRef;
+extern const CFStringRef kCGImageSourceShouldCache __attribute__((visibility("default")));
 typedef signed char BOOL;
 typedef struct _NSZone NSZone;
 typedef unsigned int NSUInteger;
@@ -70,6 +71,7 @@ void f(id a, id<P> b, C* c, C<P> *d) {
   [[[NSArray alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
   [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
   [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", (void*) 0, nil] autorelease]; // no-warning
+  [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", kCGImageSourceShouldCache, nil] autorelease]; // no-warning
   [[[NSSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
 }