Author: erichkeane
Date: 2023-12-08T06:14:21-08:00
New Revision: 9b154dad5b465bfc45b962488682ed4f95e049a3

URL: 
https://github.com/llvm/llvm-project/commit/9b154dad5b465bfc45b962488682ed4f95e049a3
DIFF: 
https://github.com/llvm/llvm-project/commit/9b154dad5b465bfc45b962488682ed4f95e049a3.diff

LOG: [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.

Added: 
    

Modified: 
    clang/lib/Parse/ParseOpenACC.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Parse/ParseOpenACC.cpp 
b/clang/lib/Parse/ParseOpenACC.cpp
index 40b53dd180c79..83a91d44f73fa 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();


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to