================
@@ -2302,10 +2295,41 @@ class Preprocessor {
     }
   }
 
-  /// Determine whether the next preprocessor token to be
-  /// lexed is a '('.  If so, consume the token and return true, if not, this
+  /// Check whether the next pp-token is one of the specificed token kind. this
   /// method should have no observable side-effect on the lexed tokens.
-  bool isNextPPTokenLParen();
+  template <tok::TokenKind K, tok::TokenKind... Ks> bool isNextPPTokenOneOf() {
----------------
yronglin wrote:

Yes, more details in https://github.com/llvm/llvm-project/pull/143898, we need 
an mechanism that look ahead next pp-token, and check whether the next pp-token 
kind is one of `tok::A, tok::B`...:
Eg.
```cpp
  auto NextTok = peekNextPPToken().value_or(Token{});
  if (Result.getIdentifierInfo()->isModulesImport() &&
      isNextPPTokenOneOf<tok::raw_identifier, tok::less, tok::string_literal,
                      tok::colon>()) {
     // Handle C++ import directive.
  }
  if (Result.getIdentifierInfo()->isModulesDeclaration() &&
      isNextPPTokenOneOf<tok::raw_identifier, tok::colon, tok::semi>()) {
     // Handle C++ module directive.
  }

  // Ok, it's an identifier.
  return false;
```

https://github.com/llvm/llvm-project/pull/145244
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to