aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-05-28 21:07:22 +0000
committerEric Fiselier <eric@efcs.ca>2017-05-28 21:07:22 +0000
commite38cea026b92285c8d7acaaceed5c1dd2fa21b71 (patch)
tree9043cd3cb8978b7cdeeb125180e85147bf308d38
parent09fcc2ce9b45b5c5437a4b62b9f632939fdfe79e (diff)
downloadllvm-e38cea026b92285c8d7acaaceed5c1dd2fa21b71.zip
llvm-e38cea026b92285c8d7acaaceed5c1dd2fa21b71.tar.gz
llvm-e38cea026b92285c8d7acaaceed5c1dd2fa21b71.tar.bz2
[coroutines] Support "coroutines" feature in module map requires clause
Summary: In order for libc++ to add `<experimental/coroutine>` to its module map, there has to be a feature that can be used to detect if coroutines support is enabled in Clang. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33538 llvm-svn: 304107
-rw-r--r--clang/docs/Modules.rst3
-rw-r--r--clang/lib/Basic/Module.cpp1
-rw-r--r--clang/test/Index/index-module.m1
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h3
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h3
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/module.map9
-rw-r--r--clang/test/Modules/requires-coroutines.mm12
7 files changed, 31 insertions, 1 deletions
diff --git a/clang/docs/Modules.rst b/clang/docs/Modules.rst
index 2b1bde2..b8841c0 100644
--- a/clang/docs/Modules.rst
+++ b/clang/docs/Modules.rst
@@ -413,6 +413,9 @@ altivec
blocks
The "blocks" language feature is available.
+coroutines
+ Support for the coroutines TS is available.
+
cplusplus
C++ support is available.
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index a6fd931..ac3d7c5 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -64,6 +64,7 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
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)
diff --git a/clang/test/Index/index-module.m b/clang/test/Index/index-module.m
index 6f3d848..c6387fe 100644
--- a/clang/test/Index/index-module.m
+++ b/clang/test/Index/index-module.m
@@ -27,6 +27,7 @@ int glob;
// 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
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h
new file mode 100644
index 0000000..85281f5
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h
@@ -0,0 +1,3 @@
+#ifndef __cpp_coroutines
+#error coroutines must be enabled
+#endif
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
new file mode 100644
index 0000000..9312b9a
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
@@ -0,0 +1,3 @@
+#ifdef __cpp_coroutines
+#error coroutines must NOT be enabled
+#endif
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/module.map b/clang/test/Modules/Inputs/DependsOnModule.framework/module.map
index b623085..4d468f2 100644
--- a/clang/test/Modules/Inputs/DependsOnModule.framework/module.map
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -22,7 +22,14 @@ framework module DependsOnModule {
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"
diff --git a/clang/test/Modules/requires-coroutines.mm b/clang/test/Modules/requires-coroutines.mm
new file mode 100644
index 0000000..d3519cd
--- /dev/null
+++ b/clang/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
+@import DependsOnModule.Coroutines;
+@import DependsOnModule.NotCoroutines; // expected-error {{module 'DependsOnModule.NotCoroutines' is incompatible with feature 'coroutines'}}
+#else
+@import DependsOnModule.NotCoroutines;
+@import DependsOnModule.Coroutines; // expected-error {{module 'DependsOnModule.Coroutines' requires feature 'coroutines'}}
+#endif