Author: arphaman Date: Wed May 17 06:08:36 2017 New Revision: 303246 URL: http://llvm.org/viewvc/llvm-project?rev=303246&view=rev Log: [Lexer] Ensure that the token is not an annotation token when retrieving the identifer info for an Objective-C keyword
This commit fixes an assertion that's triggered in getIdentifier when the token is an annotation token. rdar://32225463 Added: cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h cfe/trunk/test/Modules/objc-at-keyword.m Modified: cfe/trunk/lib/Lex/Lexer.cpp cfe/trunk/test/Modules/Inputs/module.map Modified: cfe/trunk/lib/Lex/Lexer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=303246&r1=303245&r2=303246&view=diff ============================================================================== --- cfe/trunk/lib/Lex/Lexer.cpp (original) +++ cfe/trunk/lib/Lex/Lexer.cpp Wed May 17 06:08:36 2017 @@ -43,6 +43,8 @@ using namespace clang; /// isObjCAtKeyword - Return true if we have an ObjC keyword identifier. bool Token::isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const { + if (isAnnotation()) + return false; if (IdentifierInfo *II = getIdentifierInfo()) return II->getObjCKeywordID() == objcKey; return false; @@ -50,6 +52,8 @@ bool Token::isObjCAtKeyword(tok::ObjCKey /// getObjCKeywordID - Return the ObjC keyword kind. tok::ObjCKeywordKind Token::getObjCKeywordID() const { + if (isAnnotation()) + return tok::objc_not_keyword; IdentifierInfo *specId = getIdentifierInfo(); return specId ? specId->getObjCKeywordID() : tok::objc_not_keyword; } Modified: cfe/trunk/test/Modules/Inputs/module.map URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=303246&r1=303245&r2=303246&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/module.map (original) +++ cfe/trunk/test/Modules/Inputs/module.map Wed May 17 06:08:36 2017 @@ -441,3 +441,7 @@ module DebugNestedB { header "DebugNestedB.h" export * } + +module objcAtKeywordMissingEnd { + header "objcAtKeywordMissingEnd.h" +} Added: cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h?rev=303246&view=auto ============================================================================== --- cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h (added) +++ cfe/trunk/test/Modules/Inputs/objcAtKeywordMissingEnd.h Wed May 17 06:08:36 2017 @@ -0,0 +1,3 @@ +@interface MissingEnd // expected-note {{class started here}} + +@ // expected-error {{expected an Objective-C directive after '@'}} expected-error {{missing '@end'}} Added: cfe/trunk/test/Modules/objc-at-keyword.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-at-keyword.m?rev=303246&view=auto ============================================================================== --- cfe/trunk/test/Modules/objc-at-keyword.m (added) +++ cfe/trunk/test/Modules/objc-at-keyword.m Wed May 17 06:08:36 2017 @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify -x objective-c -fmodule-name=objcAtKeywordMissingEnd -emit-module %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=Empty -emit-module %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify -I %S/Inputs %s + +@interface X // expected-note {{class started here}} +#pragma clang module import Empty // expected-error {{missing '@end'}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits