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

via cfe-commits cfe-commits at lists.llvm.org
Fri May 3 05:10:04 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 10aab63c9cb49d3ddfbe2cf8992de433efeef6f1 0b472f255ca8f9279e58f25e2350cd0eb31baad7 -- clang/test/CXX/cpp/cpp.module/p2.cppm clang/include/clang/Basic/IdentifierTable.h clang/include/clang/Lex/Preprocessor.h clang/include/clang/Parse/Parser.h clang/lib/Basic/IdentifierTable.cpp clang/lib/Lex/PPLexerChange.cpp clang/lib/Lex/Preprocessor.cpp clang/lib/Parse/Parser.cpp clang/test/CXX/module/basic/basic.link/module-declaration.cpp clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.import/p1.cppm clang/test/SemaCXX/modules.cppm
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h
index 5bbb921955..645f7ae913 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -215,9 +215,9 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
         IsFutureCompatKeyword(false), IsPoisoned(false),
         IsCPPOperatorKeyword(false), NeedsHandleIdentifier(false),
         IsFromAST(false), ChangedAfterLoad(false), FEChangedAfterLoad(false),
-        RevertedTokenID(false), OutOfDate(false), IsModulesImport(false), IsModulesDecl(false),
-        IsMangledOpenMPVariantName(false), IsDeprecatedMacro(false),
-        IsRestrictExpansion(false), IsFinal(false) {}
+        RevertedTokenID(false), OutOfDate(false), IsModulesImport(false),
+        IsModulesDecl(false), IsMangledOpenMPVariantName(false),
+        IsDeprecatedMacro(false), IsRestrictExpansion(false), IsFinal(false) {}
 
 public:
   IdentifierInfo(const IdentifierInfo &) = delete;
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index b1571494f1..5982c9a72d 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -863,9 +863,8 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) {
     CurLexerCallback = CLK_LexAfterModuleImport;
   }
 
-  if ((II.isModulesDecl() ||
-       Identifier.is(tok::kw_module)) &&
-      !InMacroArgs && !DisableMacroExpansion &&
+  if ((II.isModulesDecl() || Identifier.is(tok::kw_module)) && !InMacroArgs &&
+      !DisableMacroExpansion &&
       (getLangOpts().Modules || getLangOpts().DebuggerSupport) &&
       CurLexerCallback != CLK_CachingLexer) {
     CurLexerCallback = CLK_LexAfterModuleDecl;
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index f1e35028e1..2c45e037a1 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -2705,14 +2705,15 @@ bool Parser::ParseModuleName(
     if (!IsImport && MI) {
       HasMacroInModuleName = true;
       if (MI->isFunctionLike())
-        SkipUntil(tok::r_paren, tok::period, tok::colon, StopAtSemi | StopBeforeMatch);
+        SkipUntil(tok::r_paren, tok::period, tok::colon,
+                  StopAtSemi | StopBeforeMatch);
       Diag(Identifier, diag::err_module_decl_cannot_be_macros)
-            << Identifier.getLocation()
-            << IsPartition << MI->isFunctionLike()
-            << Identifier.getIdentifierInfo();
+          << Identifier.getLocation() << IsPartition << MI->isFunctionLike()
+          << Identifier.getIdentifierInfo();
     } else if (!HasMacroInModuleName) {
       // Record this part of the module path.
-      Path.push_back(std::make_pair(Identifier.getIdentifierInfo(), Identifier.getLocation()));
+      Path.push_back(std::make_pair(Identifier.getIdentifierInfo(),
+                                    Identifier.getLocation()));
     }
 
     if (!TryConsumeToken(tok::period))

``````````

</details>


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


More information about the cfe-commits mailing list