From 9b154dad5b465bfc45b962488682ed4f95e049a3 Mon Sep 17 00:00:00 2001 From: erichkeane Date: Fri, 8 Dec 2023 06:06:28 -0800 Subject: [PATCH] [OpenACC][NFC] Change Readonly token check to use isSpecialTokenKind As brought up in a previous review, instead of checking a token's spelling in text everywhere, we added a 'special token kind'. This adds the only other use of a special kind to use the checking function instead. --- clang/lib/Parse/ParseOpenACC.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp index 40b53dd180c7..83a91d44f73f 100644 --- a/clang/lib/Parse/ParseOpenACC.cpp +++ b/clang/lib/Parse/ParseOpenACC.cpp @@ -84,6 +84,7 @@ OpenACCAtomicKind getOpenACCAtomicKind(Token Tok) { } enum class OpenACCSpecialTokenKind { + ReadOnly, DevNum, Queues, }; @@ -93,6 +94,8 @@ bool isOpenACCSpecialToken(OpenACCSpecialTokenKind Kind, Token Tok) { return false; switch (Kind) { + case OpenACCSpecialTokenKind::ReadOnly: + return Tok.getIdentifierInfo()->isStr("readonly"); case OpenACCSpecialTokenKind::DevNum: return Tok.getIdentifierInfo()->isStr("devnum"); case OpenACCSpecialTokenKind::Queues: @@ -422,8 +425,7 @@ void Parser::ParseOpenACCCacheVarList() { // specifications. First, see if we have `readonly:`, else we back-out and // treat it like the beginning of a reference to a potentially-existing // `readonly` variable. - if (getCurToken().is(tok::identifier) && - getCurToken().getIdentifierInfo()->isStr("readonly") && + if (isOpenACCSpecialToken(OpenACCSpecialTokenKind::ReadOnly, Tok) && NextToken().is(tok::colon)) { // Consume both tokens. ConsumeToken();