diff options
author | yronglin <yronglin777@gmail.com> | 2025-06-21 18:58:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-21 18:58:56 +0800 |
commit | ea321392ebc487c1000e43576f44af99edf28a5f (patch) | |
tree | e259fa69b0eec9757771f96085e12337c94b9b65 /clang/lib/Lex/Preprocessor.cpp | |
parent | 1b5d6ec6855369d109fcb740ecd3812231b7a279 (diff) | |
download | llvm-ea321392ebc487c1000e43576f44af99edf28a5f.zip llvm-ea321392ebc487c1000e43576f44af99edf28a5f.tar.gz llvm-ea321392ebc487c1000e43576f44af99edf28a5f.tar.bz2 |
[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@gmail.com>
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 21fc7a2..18b2f5f 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -247,6 +247,8 @@ void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const { llvm::errs() << " [LeadingSpace]"; if (Tok.isExpandDisabled()) llvm::errs() << " [ExpandDisabled]"; + if (Tok.isFirstPPToken()) + llvm::errs() << " [First pp-token]"; if (Tok.needsCleaning()) { const char *Start = SourceMgr.getCharacterData(Tok.getLocation()); llvm::errs() << " [UnClean='" << StringRef(Start, Tok.getLength()) |