[PATCH] D33538: [coroutines] Support "coroutines" feature in module map requires clause
Eric Fiselier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun May 28 14:01:57 PDT 2017
EricWF updated this revision to Diff 100567.
EricWF added a comment.
This patch was initially reverted due to a failing test it caused elsewhere; which has been address in this version.
https://reviews.llvm.org/D33538
Files:
docs/Modules.rst
lib/Basic/Module.cpp
test/Index/index-module.m
test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h
test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
test/Modules/Inputs/DependsOnModule.framework/module.map
test/Modules/requires-coroutines.mm
Index: test/Modules/requires-coroutines.mm
===================================================================
--- /dev/null
+++ test/Modules/requires-coroutines.mm
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify
+// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -fcoroutines-ts -DCOROUTINES
+
+
+#ifdef COROUTINES
+ at import DependsOnModule.Coroutines;
+ at import DependsOnModule.NotCoroutines; // expected-error {{module 'DependsOnModule.NotCoroutines' is incompatible with feature 'coroutines'}}
+#else
+ at import DependsOnModule.NotCoroutines;
+ at import DependsOnModule.Coroutines; // expected-error {{module 'DependsOnModule.Coroutines' requires feature 'coroutines'}}
+#endif
Index: test/Modules/Inputs/DependsOnModule.framework/module.map
===================================================================
--- test/Modules/Inputs/DependsOnModule.framework/module.map
+++ test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -22,7 +22,14 @@
explicit module CustomReq2 {
requires custom_req2
}
-
+ explicit module Coroutines {
+ requires coroutines
+ header "coroutines.h"
+ }
+ explicit module NotCoroutines {
+ requires !coroutines
+ header "not_coroutines.h"
+ }
explicit framework module SubFramework {
umbrella header "SubFramework.h"
Index: test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
@@ -0,0 +1,3 @@
+#ifdef __cpp_coroutines
+#error coroutines must NOT be enabled
+#endif
Index: test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h
@@ -0,0 +1,3 @@
+#ifndef __cpp_coroutines
+#error coroutines must be enabled
+#endif
Index: test/Index/index-module.m
===================================================================
--- test/Index/index-module.m
+++ test/Index/index-module.m
@@ -27,6 +27,7 @@
// CHECK-DMOD-NEXT: [ppIncludedFile]: {{.*}}/Modules/Inputs/Module.framework{{[/\\]}}Headers{{[/\\]}}Module.h | name: "Module/Module.h" | hash loc: {{.*}}/Modules/Inputs/DependsOnModule.framework{{[/\\]}}Headers{{[/\\]}}DependsOnModule.h:1:1 | isImport: 0 | isAngled: 1 | isModule: 1 | module: Module
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_OTHER_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]other\.h]] | {{.*}} | hash loc: <invalid> | {{.*}} | module: DependsOnModule
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_NOT_CXX_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]not_cxx\.h]] | {{.*}} | hash loc: <invalid> | {{.*}} | module: DependsOnModule.NotCXX
+// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_NOT_CORO_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]not_coroutines\.h]] | {{.*}} | hash loc: <invalid> | {{.*}} | module: DependsOnModule.NotCoroutines
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]] | {{.*}} | hash loc: <invalid> | {{.*}} | module: DependsOnModule.SubFramework
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]Other\.h]] | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]] | {{.*}} | hash loc: <invalid> | {{.*}} | module: DependsOnModule.Private.DependsOnModule
Index: lib/Basic/Module.cpp
===================================================================
--- lib/Basic/Module.cpp
+++ lib/Basic/Module.cpp
@@ -64,6 +64,7 @@
bool HasFeature = llvm::StringSwitch<bool>(Feature)
.Case("altivec", LangOpts.AltiVec)
.Case("blocks", LangOpts.Blocks)
+ .Case("coroutines", LangOpts.CoroutinesTS)
.Case("cplusplus", LangOpts.CPlusPlus)
.Case("cplusplus11", LangOpts.CPlusPlus11)
.Case("freestanding", LangOpts.Freestanding)
Index: docs/Modules.rst
===================================================================
--- docs/Modules.rst
+++ docs/Modules.rst
@@ -413,6 +413,9 @@
blocks
The "blocks" language feature is available.
+coroutines
+ Support for the coroutines TS is available.
+
cplusplus
C++ support is available.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33538.100567.patch
Type: text/x-patch
Size: 4915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170528/436a5f15/attachment.bin>
More information about the cfe-commits
mailing list