From: Argyrios Kyrtzidis Date: Wed, 5 Oct 2011 21:28:06 +0000 (+0000) Subject: Fix crash when using archaic protocol, rdar://10238337 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d94094cdbfd531ec96b719e0c8339aff7463ff9;p=clang Fix crash when using archaic protocol, rdar://10238337 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141215 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/SelectorLocationsKind.cpp b/lib/AST/SelectorLocationsKind.cpp index 9a44b387dd..671207a7f2 100644 --- a/lib/AST/SelectorLocationsKind.cpp +++ b/lib/AST/SelectorLocationsKind.cpp @@ -54,8 +54,11 @@ SourceLocation getArgLoc(Expr *Arg) { template <> SourceLocation getArgLoc(ParmVarDecl *Arg) { + SourceLocation Loc = Arg->getLocStart(); + if (Loc.isInvalid()) + return Loc; // -1 to point to left paren of the method parameter's type. - return Arg->getLocStart().getLocWithOffset(-1); + return Loc.getLocWithOffset(-1); } template diff --git a/test/SemaObjC/protocol-archane.m b/test/SemaObjC/protocol-archane.m index 138c43d1a8..992d3e4798 100644 --- a/test/SemaObjC/protocol-archane.m +++ b/test/SemaObjC/protocol-archane.m @@ -33,3 +33,10 @@ typedef struct objc_class *Class; Class UnfortunateGCCExtension; +// rdar://10238337 +@protocol Broken @end +@interface Crash @end +@implementation Crash +- (void)crashWith:()a { // expected-warning {{protocol qualifiers without 'id' is archaic}} +} +@end