[cfe-commits] r127797 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp test/Analysis/variadic-method-types.m

Ted Kremenek kremenek at apple.com
Wed Mar 16 21:01:35 PDT 2011


Author: kremenek
Date: Wed Mar 16 23:01:35 2011
New Revision: 127797

URL: http://llvm.org/viewvc/llvm-project?rev=127797&view=rev
Log:
Teach VariadicMethodTypeChecker that CF references are valid arguments to variadic Objective-C methods.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
    cfe/trunk/test/Analysis/variadic-method-types.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp?rev=127797&r1=127796&r2=127797&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp Wed Mar 16 23:01:35 2011
@@ -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 @@
     // 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()) {

Modified: cfe/trunk/test/Analysis/variadic-method-types.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/variadic-method-types.m?rev=127797&r1=127796&r2=127797&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/variadic-method-types.m (original)
+++ cfe/trunk/test/Analysis/variadic-method-types.m Wed Mar 16 23:01:35 2011
@@ -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 @@
   [[[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 *'}}
 }
 





More information about the cfe-commits mailing list