aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerichkeane <ekeane@nvidia.com>2023-12-08 06:06:28 -0800
committererichkeane <ekeane@nvidia.com>2023-12-08 06:14:21 -0800
commit9b154dad5b465bfc45b962488682ed4f95e049a3 (patch)
treebaf3e743cead3fb17bf7f9e7a10525af5d6ba9ef
parentc64385cc8c9d05ee70a6d7c03a8c5f312f63060f (diff)
downloadllvm-9b154dad5b465bfc45b962488682ed4f95e049a3.zip
llvm-9b154dad5b465bfc45b962488682ed4f95e049a3.tar.gz
llvm-9b154dad5b465bfc45b962488682ed4f95e049a3.tar.bz2
[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.
-rw-r--r--clang/lib/Parse/ParseOpenACC.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp
index 40b53dd..83a91d44f 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();