diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-04-12 21:47:05 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-04-12 21:47:05 +0000 |
commit | 9281efe614741f3742ebf8196a703f6c923c6ff0 (patch) | |
tree | 1d6bb61c63f3ad81c5e8abd257b4b8ce45a5639e | |
parent | 1212f807af8aa93689845d18eb5a260718c77e57 (diff) |
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
-rw-r--r-- | lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp | 3 | ||||
-rw-r--r-- | test/Analysis/variadic-method-types.m | 9 |
2 files changed, 11 insertions, 1 deletions
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<ObjCProtocolDecl>(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<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]; +} + |