[PATCH] D149850: [Clang][Modules] Support `requires cplusplus20` in a modulemap

Egor Zhdan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 4 07:16:07 PDT 2023


egorzhdan created this revision.
Herald added a project: All.
egorzhdan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change adds the support for `requires cplusplus20` directive for a module declared in a Clang modulemap, similarly to existing directives `requires cplusplus17`, `requires cplusplus14`, etc.

rdar://108891417


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149850

Files:
  clang/docs/Modules.rst
  clang/lib/Basic/Module.cpp
  clang/test/Modules/Inputs/DependsOnModule.framework/module.map
  clang/test/Modules/requires.m


Index: clang/test/Modules/requires.m
===================================================================
--- clang/test/Modules/requires.m
+++ clang/test/Modules/requires.m
@@ -22,11 +22,13 @@
 @import DependsOnModule.CXX14; // expected-note {{module imported here}}
 // expected-error at DependsOnModule.framework/module.map:46 {{module 'DependsOnModule.CXX17' requires feature 'cplusplus17'}}
 @import DependsOnModule.CXX17; // expected-note {{module imported here}}
+// expected-error at DependsOnModule.framework/module.map:49 {{module 'DependsOnModule.CXX20' requires feature 'cplusplus20'}}
+ at import DependsOnModule.CXX20; // expected-note {{module imported here}}
 #else
-// expected-error at DependsOnModule.framework/module.map:49 {{module 'DependsOnModule.C99' requires feature 'c99'}}
+// expected-error at DependsOnModule.framework/module.map:52 {{module 'DependsOnModule.C99' requires feature 'c99'}}
 @import DependsOnModule.C99; // expected-note {{module imported here}}
-// expected-error at DependsOnModule.framework/module.map:52 {{module 'DependsOnModule.C11' requires feature 'c11'}}
+// expected-error at DependsOnModule.framework/module.map:55 {{module 'DependsOnModule.C11' requires feature 'c11'}}
 @import DependsOnModule.C11; // expected-note {{module imported here}}
-// expected-error at DependsOnModule.framework/module.map:55 {{module 'DependsOnModule.C17' requires feature 'c17'}}
+// expected-error at DependsOnModule.framework/module.map:58 {{module 'DependsOnModule.C17' requires feature 'c17'}}
 @import DependsOnModule.C17; // expected-note {{module imported here}}
 #endif
Index: clang/test/Modules/Inputs/DependsOnModule.framework/module.map
===================================================================
--- clang/test/Modules/Inputs/DependsOnModule.framework/module.map
+++ clang/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -46,6 +46,9 @@
   explicit module CXX17 {
     requires cplusplus17
   }
+  explicit module CXX20 {
+    requires cplusplus20
+  }
   explicit module C99 {
     requires c99
   }
Index: clang/lib/Basic/Module.cpp
===================================================================
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -107,6 +107,7 @@
                         .Case("cplusplus11", LangOpts.CPlusPlus11)
                         .Case("cplusplus14", LangOpts.CPlusPlus14)
                         .Case("cplusplus17", LangOpts.CPlusPlus17)
+                        .Case("cplusplus20", LangOpts.CPlusPlus20)
                         .Case("c99", LangOpts.C99)
                         .Case("c11", LangOpts.C11)
                         .Case("c17", LangOpts.C17)
Index: clang/docs/Modules.rst
===================================================================
--- clang/docs/Modules.rst
+++ clang/docs/Modules.rst
@@ -573,6 +573,9 @@
 cplusplus17
   C++17 support is available.
 
+cplusplus20
+  C++20 support is available.
+
 c99
   C99 support is available.
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149850.519481.patch
Type: text/x-patch
Size: 2952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230504/16f6bf32/attachment.bin>


More information about the cfe-commits mailing list