Skip to content

Commit 8529a7f

Browse files
committed
P3034R1 Module Declarations Shouldn’t be Macros
Signed-off-by: yronglin <[email protected]>
1 parent 04ddbf6 commit 8529a7f

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

clang/lib/Lex/PPDirectives.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4249,7 +4249,13 @@ void Preprocessor::HandleCXXModuleDirective(Token ModuleTok) {
42494249
DirToks.push_back(Tok);
42504250
break;
42514251
case tok::identifier: {
4252-
if (LexModuleNameContinue(Tok, UseLoc, Path)) {
4252+
// C++ [cpp.module]p3: Any preprocessing tokens after the module
4253+
// preprocessing token in the module directive are processed just as in
4254+
// normal text.
4255+
//
4256+
// P3034R1 Module Declarations Shouldn’t be Macros.
4257+
if (LexModuleNameContinue(Tok, UseLoc, Path,
4258+
/*AllowMacroExpansion=*/false)) {
42534259
if (Tok.isNot(tok::eod))
42544260
CheckEndOfDirective(ModuleTok.getIdentifierInfo()->getName());
42554261
return;

clang/lib/Lex/Preprocessor.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,12 +1168,12 @@ bool Preprocessor::LexModuleNameContinue(Token &Tok, SourceLocation UseLoc,
11681168
///
11691169
/// At the start of phase 4 an import or module token is treated as starting a
11701170
/// directive and are converted to their respective keywords iff:
1171-
/// After skipping horizontal whitespace are
1172-
/// at the start of a logical line, or
1173-
/// preceded by an 'export' at the start of the logical line.
1174-
/// Are followed by an identifier pp token (before macro expansion), or
1175-
/// <, ", or : (but not ::) pp tokens for 'import', or
1176-
/// ; for 'module'
1171+
/// - After skipping horizontal whitespace are
1172+
/// - at the start of a logical line, or
1173+
/// - preceded by an 'export' at the start of the logical line.
1174+
/// - Are followed by an identifier pp token (before macro expansion), or
1175+
/// - <, ", or : (but not ::) pp tokens for 'import', or
1176+
/// - ; for 'module'
11771177
/// Otherwise the token is treated as an identifier.
11781178
bool Preprocessor::HandleModuleContextualKeyword(
11791179
Token &Result, bool TokAtPhysicalStartOfLine) {

0 commit comments

Comments
 (0)