[all-commits] [llvm/llvm-project] e8976e: [clang][Preprocessor] Add peekNextPPToken, makes l...

yronglin via All-commits all-commits at lists.llvm.org
Tue Jun 24 03:55:43 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e8976e92f655f8c358081ffae01e10ea159cd37d
      https://github.com/llvm/llvm-project/commit/e8976e92f655f8c358081ffae01e10ea159cd37d
  Author: yronglin <yronglin777 at gmail.com>
  Date:   2025-06-24 (Tue, 24 Jun 2025)

  Changed paths:
    M clang/include/clang/Lex/Lexer.h
    M clang/include/clang/Lex/Preprocessor.h
    M clang/include/clang/Lex/TokenLexer.h
    M clang/lib/Lex/Lexer.cpp
    M clang/lib/Lex/PPDirectives.cpp
    M clang/lib/Lex/PPMacroExpansion.cpp
    M clang/lib/Lex/Preprocessor.cpp
    M clang/lib/Lex/TokenLexer.cpp

  Log Message:
  -----------
  [clang][Preprocessor] Add peekNextPPToken, makes look ahead next token without side-effects (#143898)

This PR introduce a new function `peekNextPPToken`. It's an extension of
`isNextPPTokenLParen` and can makes look ahead one token in preprocessor
without side-effects.

It's also the 1st part of
https://github.com/llvm/llvm-project/pull/107168 and it was used to look
ahead next token then determine whether current lexing pp directive is
one of pp-import or pp-module directive.

At the start of phase 4 an import or module token is treated as starting
a directive and are converted to their respective keywords iff:

 - After skipping horizontal whitespace are
    - at the start of a logical line, or
    - preceded by an export at the start of the logical line.
- Are followed by an identifier pp token (before macro expansion), or
    - <, ", or : (but not ::) pp tokens for import, or
    - ; for module
Otherwise the token is treated as an identifier.

---------

Signed-off-by: yronglin <yronglin777 at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list