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

Ted Kremenek kremenek at apple.com
Tue Apr 12 14:47:06 PDT 2011


Author: kremenek
Date: Tue Apr 12 16:47:05 2011
New Revision: 129395

URL: http://llvm.org/viewvc/llvm-project?rev=129395&view=rev
Log:
Teach VariadicMethodTypeChecker to not crash when processing methods declared in protocols.

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=129395&r1=129394&r2=129395&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp Tue Apr 12 16:47:05 2011
@@ -503,7 +503,8 @@
 bool
 VariadicMethodTypeChecker::isVariadicMessage(const ObjCMessage &msg) const {
   const ObjCMethodDecl *MD = msg.getMethodDecl();
-  if (!MD || !MD->isVariadic())
+  
+  if (!MD || !MD->isVariadic() || isa<ObjCProtocolDecl>(MD->getDeclContext()))
     return false;
   
   Selector S = msg.getSelector();

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=129395&r1=129394&r2=129395&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/variadic-method-types.m (original)
+++ cfe/trunk/test/Analysis/variadic-method-types.m Tue Apr 12 16:47:05 2011
@@ -81,3 +81,12 @@
   [[[NSSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
 }
 
+// This previously crashed the variadic argument checker.
+ at protocol RDar9273215
+- (void)rdar9273215:(id)x, ...;
+ at end
+
+void test_rdar9273215(id<RDar9273215> y) {
+  return [y rdar9273215:y, y];
+}
+





More information about the cfe-commits mailing list