]> granicus.if.org Git - clang/commitdiff
Teach VariadicMethodTypeChecker to not crash when processing methods declared in...
authorTed Kremenek <kremenek@apple.com>
Tue, 12 Apr 2011 21:47:05 +0000 (21:47 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 12 Apr 2011 21:47:05 +0000 (21:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129395 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 60c437c1e6f2b2a38047711c6dfd0f58ade69e9d..2790a19c61cd7d6835227376b805559bcc847e6f 100644 (file)
@@ -503,7 +503,8 @@ public:
 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();
index 607154d32eb6c8eb80cbbfdfd09a41c526bfd76f..76a05ed9c0568fa4885596cc3bbb28c26df3aeba 100644 (file)
@@ -81,3 +81,12 @@ void f(id a, id<P> b, C* c, C<P> *d, FooType fooType, BarType barType) {
   [[[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.
+@protocol RDar9273215
+- (void)rdar9273215:(id)x, ...;
+@end
+
+void test_rdar9273215(id<RDar9273215> y) {
+  return [y rdar9273215:y, y];
+}
+