]> granicus.if.org Git - clang/commitdiff
VariadicMethodTypeChecker: don't warn for null pointer constants passed to variadic...
authorTed Kremenek <kremenek@apple.com>
Wed, 16 Mar 2011 00:22:51 +0000 (00:22 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 16 Mar 2011 00:22:51 +0000 (00:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127719 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 8677f08ab9bce27059b1bbec242f8840b87c2a17..792b720b8fb15389e19eec4c46dde177f54ea667 100644 (file)
@@ -584,12 +584,17 @@ void VariadicMethodTypeChecker::checkPreObjCMessage(ObjCMessage msg,
 
   // Verify that all arguments have Objective-C types.
   llvm::Optional<ExplodedNode*> errorNode;
+  const GRState *state = C.getState();
   
   for (unsigned I = variadicArgsBegin; I != variadicArgsEnd; ++I) {
     QualType ArgTy = msg.getArgType(I);
     if (ArgTy->isObjCObjectPointerType())
       continue;
 
+    // Ignore pointer constants.
+    if (isa<loc::ConcreteInt>(msg.getArgSVal(I, state)))
+      continue;
+
     // Generate only one error node to use for all bug reports.
     if (!errorNode.hasValue()) {
       errorNode = C.generateNode();
index bd1b227f9f8b3c4f229c230c72f1b884c69a2bd3..6f67d2f0d5f8f7815f305a922eb434837bbec6e4 100644 (file)
@@ -69,6 +69,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
   [[[NSSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
 }