[PATCH] [coroutines] Rename driver flag -fcoroutines to -fcoroutines-ts
Gor Nishanov via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 29 17:45:35 PDT 2016
Let's see if renaming the attachment to *.txt helps.
On Thu, Sep 29, 2016 at 5:42 PM, Gor Nishanov <gornishanov at gmail.com> wrote:
> Currently the -fcoroutines flag is a CC1 only flag. It really should be
> both a Driver and CC1 flag. This patch fixes the option and adds tests for
> the new options.
>
> Also adds a __has_feature for coroutines.
> Patch is mostly by Eric Fiselier
> .
> Meticulous and painstaking extraction from the larger coroutine branch by
> Gor Nishanov
>
> P.S.
>
> Switching to lowercase [coroutines] tag in the title, as most of the
> coroutine commits in cfe were done with lowercase tag.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160929/c5e44b13/attachment.html>
-------------- next part --------------
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 66e1ad6..73ab5e6 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -638,10 +638,6 @@ def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
def finclude_default_header : Flag<["-"], "finclude-default-header">,
HelpText<"Include the default header file for OpenCL">;
-// C++ TSes.
-def fcoroutines : Flag<["-"], "fcoroutines">,
- HelpText<"Enable support for the C++ Coroutines TS">;
-
//===----------------------------------------------------------------------===//
// Header Search Options
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 6090304..dba95c7 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -481,6 +481,13 @@ def fno_autolink : Flag <["-"], "fno-autolink">, Group<f_Group>,
Flags<[DriverOption, CC1Option]>,
HelpText<"Disable generation of linker directives for automatic library linking">;
+// C++ Coroutines TS
+def fcoroutines : Flag <["-"], "fcoroutines-ts">, Group<f_Group>,
+ Flags<[DriverOption, CC1Option]>,
+ HelpText<"Enable support for the C++ Coroutines TS">;
+def fno_coroutines : Flag <["-"], "fno-coroutines-ts">, Group<f_Group>,
+ Flags<[DriverOption]>;
+
def fembed_bitcode_EQ : Joined<["-"], "fembed-bitcode=">,
Group<f_Group>, Flags<[DriverOption, CC1Option]>, MetaVarName<"<option>">,
HelpText<"Embed LLVM bitcode (option: off, all, bitcode, marker)">;
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index d806efd..18891cf 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -5423,6 +5423,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-fblocks-runtime-optional");
}
+ if (Args.hasFlag(options::OPT_fcoroutines, options::OPT_fno_coroutines, false)
+ && types::isCXX(InputType)) {
+ CmdArgs.push_back("-fcoroutines-ts");
+ }
+
// -fmodules enables the use of precompiled modules (off by default).
// Users can pass -fno-cxx-modules to turn off modules support for
// C++/Objective-C++ programs.
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 940192b..838f769 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -1213,6 +1213,7 @@ static bool HasFeature(const Preprocessor &PP, StringRef Feature) {
// Type traits
// N.B. Additional type traits should not be added to the following list.
// Instead, they should be detected by has_extension.
+ .Case("coroutines", LangOpts.Coroutines)
.Case("has_nothrow_assign", LangOpts.CPlusPlus)
.Case("has_nothrow_copy", LangOpts.CPlusPlus)
.Case("has_nothrow_constructor", LangOpts.CPlusPlus)
diff --git a/test/CodeGenCoroutines/microsoft-abi-operator-coawait.cpp b/test/CodeGenCoroutines/microsoft-abi-operator-coawait.cpp
index e87fed0..1921c06 100644
--- a/test/CodeGenCoroutines/microsoft-abi-operator-coawait.cpp
+++ b/test/CodeGenCoroutines/microsoft-abi-operator-coawait.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines -emit-llvm %s -o - -std=c++14 -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines-ts -emit-llvm %s -o - -std=c++14 -disable-llvm-passes | FileCheck %s
struct no_suspend {
bool await_ready() { return true; }
template <typename F> void await_suspend(F) {}
diff --git a/test/Driver/coroutines.m b/test/Driver/coroutines.m
new file mode 100644
index 0000000..d610234
--- /dev/null
+++ b/test/Driver/coroutines.m
@@ -0,0 +1,6 @@
+// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// RUN: %clang -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// RUN: %clang -fno-coroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// RUN: %clang -fno-coroutines-ts -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// CHECK-NO-CORO-NOT: -fcoroutines-ts
+
diff --git a/test/Driver/coroutines.mm b/test/Driver/coroutines.mm
new file mode 100644
index 0000000..99e0ff5
--- /dev/null
+++ b/test/Driver/coroutines.mm
@@ -0,0 +1,9 @@
+// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// RUN: %clang -fcoroutines-ts -fno-coroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// RUN: %clang -fno-coroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// CHECK-NO-CORO-NOT: -fcoroutines-ts
+
+// RUN: %clang -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-CORO %s
+// RUN: %clang -fno-coroutines-ts -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-CORO %s
+// CHECK-HAS-CORO: -fcoroutines-ts
+
diff --git a/test/Lexer/coroutines.cpp b/test/Lexer/coroutines.cpp
index 86d5f96..186c84b 100644
--- a/test/Lexer/coroutines.cpp
+++ b/test/Lexer/coroutines.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only %s
-// RUN: %clang_cc1 -fcoroutines -DCORO -fsyntax-only %s
+// RUN: %clang_cc1 -fcoroutines-ts -DCORO -fsyntax-only %s
#ifdef CORO
#define CORO_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
diff --git a/test/Lexer/cxx-features.cpp b/test/Lexer/cxx-features.cpp
index 5a4c45d..2f751ac 100644
--- a/test/Lexer/cxx-features.cpp
+++ b/test/Lexer/cxx-features.cpp
@@ -5,7 +5,7 @@
// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -verify %s
// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
// RUN: %clang_cc1 -fno-rtti -verify %s -DNO_EXCEPTIONS -DNO_RTTI
-// RUN: %clang_cc1 -fcoroutines -DNO_EXCEPTIONS -DCOROUTINES -verify %s
+// RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify %s
// expected-no-diagnostics
diff --git a/test/Lexer/has_feature_coroutines.m b/test/Lexer/has_feature_coroutines.m
new file mode 100644
index 0000000..b219c5f
--- /dev/null
+++ b/test/Lexer/has_feature_coroutines.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E -fcoroutines-ts %s -o - | FileCheck --check-prefix=CHECK-HAS-COROUTINES %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-COROUTINES %s
+// RUN: %clang_cc1 -E -x c -fcoroutines-ts %s -o - | FileCheck --check-prefix=CHECK-HAS-COROUTINES %s
+
+#if __has_feature(coroutines)
+int has_coroutines();
+#else
+int no_coroutines();
+#endif
+
+// CHECK-HAS-COROUTINES: has_coroutines
+// CHECK-NO-COROUTINES: no_coroutines
+
diff --git a/test/Parser/cxx1z-coroutines.cpp b/test/Parser/cxx1z-coroutines.cpp
index 3e69840..68ef91c 100644
--- a/test/Parser/cxx1z-coroutines.cpp
+++ b/test/Parser/cxx1z-coroutines.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fcoroutines %s -verify
+// RUN: %clang_cc1 -std=c++11 -fcoroutines-ts %s -verify
template<typename T, typename U>
U f(T t) {
diff --git a/test/SemaCXX/coroutines.cpp b/test/SemaCXX/coroutines.cpp
index e82cb62..214af83 100644
--- a/test/SemaCXX/coroutines.cpp
+++ b/test/SemaCXX/coroutines.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -fcoroutines -verify %s
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s
struct awaitable {
bool await_ready();
More information about the cfe-commits
mailing list