[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 09:14:27 PDT 2024


================
@@ -160,6 +160,8 @@ static char GetFirstChar(const Preprocessor &PP, const Token &Tok) {
 bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok,
                                      const Token &PrevTok,
                                      const Token &Tok) const {
+  if (PrevTok.is(tok::annot_module_name))
+    return false;
----------------
yronglin wrote:

This change was used to solve the issue in preprocessing output:
```C++
import non_exist_modules;
```
clang++ -E -std=c++20 main.cppm

Without this change, we will get:
```C++
import non_exist_modules ;
```
There has a extra whitespace between `non_exist_modules` and ':', because `TokenConcatenation::AvoidConcat` return s true. Also this issue will cause 2 tests broken.
```
Failed Tests (2):
  Clang :: Driver/crash-report-modules.m
  Clang :: Modules/preprocess-named-modules.cppm
```

https://github.com/llvm/llvm-project/pull/90574


More information about the cfe-commits mailing list