Author: kremenek
Date: Tue Mar 15 19:22:51 2011
New Revision: 127719
URL: http://llvm.org/viewvc/llvm-project?rev=127719&view=rev
Log:
VariadicMethodTypeChecker: don't warn for null pointer constants passed 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=127719&r1=127718&r2=127719&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp Tue Mar
15 19:22:51 2011
@@ -584,12 +584,17 @@
// 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();
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=127719&r1=127718&r2=127719&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/variadic-method-types.m (original)
+++ cfe/trunk/test/Analysis/variadic-method-types.m Tue Mar 15 19:22:51 2011
@@ -69,6 +69,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
[[[NSSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; //
expected-warning {{Argument to method 'initWithObjects:' should be an
Objective-C pointer type, not 'char *'}}
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits