From 9281efe614741f3742ebf8196a703f6c923c6ff0 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 12 Apr 2011 21:47:05 +0000 Subject: [PATCH] Teach VariadicMethodTypeChecker to not crash when processing methods declared in protocols. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129395 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Checkers/BasicObjCFoundationChecks.cpp | 3 ++- test/Analysis/variadic-method-types.m | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp index 60c437c1e6..2790a19c61 100644 --- a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -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(MD->getDeclContext())) return false; Selector S = msg.getSelector(); diff --git a/test/Analysis/variadic-method-types.m b/test/Analysis/variadic-method-types.m index 607154d32e..76a05ed9c0 100644 --- a/test/Analysis/variadic-method-types.m +++ b/test/Analysis/variadic-method-types.m @@ -81,3 +81,12 @@ void f(id a, id

b, C* c, C

*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 y) { + return [y rdar9273215:y, y]; +} + -- 2.40.0