[all-commits] [llvm/llvm-project] ea3213: [C++][Modules] A module directive may only appear ...

yronglin via All-commits all-commits at lists.llvm.org
Sat Jun 21 03:59:17 PDT 2025


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

  Changed paths:
    M clang/include/clang/Lex/Lexer.h
    M clang/include/clang/Lex/Preprocessor.h
    M clang/include/clang/Lex/Token.h
    M clang/include/clang/Sema/Sema.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/Parse/Parser.cpp
    M clang/lib/Sema/SemaModule.cpp
    M clang/test/CXX/basic/basic.link/p1.cpp
    M clang/test/CXX/basic/basic.link/p2.cpp
    M clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
    M clang/test/CXX/module/basic/basic.def.odr/p6.cppm
    M clang/test/CXX/module/basic/basic.link/module-declaration.cpp
    A clang/test/CXX/module/cpp.pre/module_decl.cpp
    M clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.import/p1.cppm
    M clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.interface/p1.cppm
    M clang/test/CXX/module/dcl.dcl/dcl.module/p1.cpp
    M clang/test/CXX/module/dcl.dcl/dcl.module/p5.cpp
    M clang/test/CXX/module/module.interface/p2.cpp
    M clang/test/CXX/module/module.unit/p8.cpp
    M clang/test/Driver/modules.cpp
    M clang/test/Modules/named-modules-adl-3.cppm
    M clang/test/Modules/reserved-names-1.cppm
    M clang/test/Modules/reserved-names-system-header-1.cpp
    M clang/test/Modules/reserved-names-system-header-2.cpp
    M clang/test/SemaCXX/modules.cppm
    M clang/test/SemaCXX/type-aware-new-delete-transparent-contexts.cpp
    M clang/unittests/Lex/LexerTest.cpp

  Log Message:
  -----------
  [C++][Modules] A module directive may only appear as the first preprocessing tokens in a file (#144233)

This PR is 2nd part of
[P1857R3](https://github.com/llvm/llvm-project/pull/107168)
implementation, and mainly implement the restriction `A module directive
may only appear as the first preprocessing tokens in a file (excluding
the global module fragment.)`:
[cpp.pre](https://eel.is/c++draft/cpp.pre):
```
module-file:
    pp-global-module-fragment[opt] pp-module group[opt] pp-private-module-fragment[opt]
```

We also refine tests use `split-file` instead of conditional macro.

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