]> granicus.if.org Git - clang/commitdiff
Fix crash when using archaic protocol, rdar://10238337
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 5 Oct 2011 21:28:06 +0000 (21:28 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 5 Oct 2011 21:28:06 +0000 (21:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141215 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/SelectorLocationsKind.cpp
test/SemaObjC/protocol-archane.m

index 9a44b387dd8112586bd12fa432bf3b78b8e9e808..671207a7f2d9d46554c0b7f976949dcd895f9df9 100644 (file)
@@ -54,8 +54,11 @@ SourceLocation getArgLoc<Expr>(Expr *Arg) {
 
 template <>
 SourceLocation getArgLoc<ParmVarDecl>(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 <typename T>
index 138c43d1a83a894b748dda8be187c839c50206b1..992d3e4798c1ad9937300e93e7d6551c19abe0eb 100644 (file)
@@ -33,3 +33,10 @@ typedef struct objc_class *Class;
 
 Class <SomeProtocol> UnfortunateGCCExtension;
 
+// rdar://10238337
+@protocol Broken @end
+@interface Crash @end
+@implementation Crash
+- (void)crashWith:(<Broken>)a { // expected-warning {{protocol qualifiers without 'id' is archaic}}
+}
+@end