Obj-C: Fix assert-on-invalid (PR27822)

Clang would assert when isObjCInstancetype() was called on a
tok::annot_cxxscope token.

llvm-svn: 271688
This commit is contained in:
Hans Wennborg 2016-06-03 16:59:13 +00:00
parent 4c423773d8
commit 7c09cc67aa
2 changed files with 9 additions and 0 deletions

View File

@ -647,6 +647,8 @@ private:
/// Should only be used in Objective-C language modes. /// Should only be used in Objective-C language modes.
bool isObjCInstancetype() { bool isObjCInstancetype() {
assert(getLangOpts().ObjC1); assert(getLangOpts().ObjC1);
if (Tok.isAnnotation())
return false;
if (!Ident_instancetype) if (!Ident_instancetype)
Ident_instancetype = PP.getIdentifierInfo("instancetype"); Ident_instancetype = PP.getIdentifierInfo("instancetype");
return Tok.getIdentifierInfo() == Ident_instancetype; return Tok.getIdentifierInfo() == Ident_instancetype;

View File

@ -214,3 +214,10 @@ void test_instancetype_inherited() {
return 0; return 0;
} }
@end @end
// PR27822
@class NSString;
namespace pr27822 { }
@interface AXPlatformNodeCocoa
+ (NSString*)nativeRoleFromAXRole:(pr27822::UndeclaredIdentifier)role; // expected-error {{expected a type}}
@end