diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-05-17 11:08:36 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-05-17 11:08:36 +0000 |
commit | bd77dc6b8f04ac9afcb5487e91d7a5034521e2cc (patch) | |
tree | 97e01e405fdc14513ba1a9f57a5d70ff4de022c8 /lib/Lex | |
parent | bb0d458629af8f3d52e8fa61ed730a9081a120c3 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303246 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/Lexer.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 3d6fe91115..92942fd09a 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -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::ObjCKeywordKind objcKey) const { /// 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; } |