]> granicus.if.org Git - clang/commitdiff
[coroutines] Support "coroutines" feature in module map requires clause
authorEric Fiselier <eric@efcs.ca>
Sat, 27 May 2017 02:46:17 +0000 (02:46 +0000)
committerEric Fiselier <eric@efcs.ca>
Sat, 27 May 2017 02:46:17 +0000 (02:46 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304054 91177308-0d34-0410-b5e6-96231b3b80d8

docs/Modules.rst
lib/Basic/Module.cpp
test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h [new file with mode: 0644]
test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h [new file with mode: 0644]
test/Modules/Inputs/DependsOnModule.framework/module.map
test/Modules/requires-coroutines.mm [new file with mode: 0644]

index 2b1bde2fedc109463a5aa67de3912b771475d82b..b8841c0a5cec6660730fb9db1220333affcd3236 100644 (file)
@@ -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.
 
index a6fd931cb174c2871cbcf30fa56e846dc6c29840..ac3d7c55967997e90fd2826321b52bfbc1972956 100644 (file)
@@ -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/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h b/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h
new file mode 100644 (file)
index 0000000..85281f5
--- /dev/null
@@ -0,0 +1,3 @@
+#ifndef __cpp_coroutines
+#error coroutines must be enabled
+#endif
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h b/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
new file mode 100644 (file)
index 0000000..9312b9a
--- /dev/null
@@ -0,0 +1,3 @@
+#ifdef __cpp_coroutines
+#error coroutines must NOT be enabled
+#endif
index b62308583df43e2218325f4b2632bb6e2d339c73..4d468f2a8c01c19e3a7aa7eafc5994689027b5c4 100644 (file)
@@ -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/test/Modules/requires-coroutines.mm b/test/Modules/requires-coroutines.mm
new file mode 100644 (file)
index 0000000..d3519cd
--- /dev/null
@@ -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