Skip to content

Commit

Permalink
[OpenACC][NFC] Change Readonly token check to use isSpecialTokenKind
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
erichkeane committed Dec 8, 2023
1 parent c64385c commit 9b154da
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions clang/lib/Parse/ParseOpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ OpenACCAtomicKind getOpenACCAtomicKind(Token Tok) {
}

enum class OpenACCSpecialTokenKind {
ReadOnly,
DevNum,
Queues,
};
Expand All @@ -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:
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 9b154da

Please sign in to comment.