diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-10-22 03:52:15 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-10-22 03:52:15 +0000 |
commit | eb7927ee8f2838e153c3002e94a6af9d18b76d92 (patch) | |
tree | 10d6ff417aaa6cdd0223aa49a76b526d17c270dd | |
parent | 9c077cf33d5a42ee0763d18228d59561f82c8917 (diff) | |
download | bcm5719-llvm-eb7927ee8f2838e153c3002e94a6af9d18b76d92.tar.gz bcm5719-llvm-eb7927ee8f2838e153c3002e94a6af9d18b76d92.zip |
[coroutines] Add lexer support for co_await, co_yield, and co_return keywords.
Add -fcoroutines flag (just for -cc1 for now) to enable the feature. Early
indications are that this will be part of -std=c++1z.
llvm-svn: 250980
-rw-r--r-- | clang/include/clang/Basic/LangOptions.def | 1 | ||||
-rw-r--r-- | clang/include/clang/Basic/TokenKinds.def | 7 | ||||
-rw-r--r-- | clang/include/clang/Driver/CC1Options.td | 4 | ||||
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 1 |
5 files changed, 16 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 3c380f30019..538ae480cf4 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -118,6 +118,7 @@ LANGOPT(Freestanding, 1, 0, "freestanding implementation") LANGOPT(NoBuiltin , 1, 0, "disable builtin functions") LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin functions") LANGOPT(GNUAsm , 1, 1, "GNU-style inline assembly") +LANGOPT(Coroutines , 1, 0, "C++ coroutines TS") BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers") LANGOPT(POSIXThreads , 1, 0, "POSIX thread support") diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index 963e036b6d3..1e0ec117d07 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -242,6 +242,8 @@ PUNCTUATOR(greatergreatergreater, ">>>") // KEYZVECTOR - This is a keyword for the System z vector extensions, // which are heavily based on AltiVec // KEYBORLAND - This is a keyword if Borland extensions are enabled +// KEYCOROUTINES - This is a keyword if support for the C++ coroutines +// TS is enabled // BOOLSUPPORT - This is a keyword if 'bool' is a built-in type // HALFSUPPORT - This is a keyword if 'half' is a built-in type // WCHARSUPPORT - This is a keyword if 'wchar_t' is a built-in type @@ -356,6 +358,11 @@ CXX11_KEYWORD(thread_local , 0) CONCEPTS_KEYWORD(concept) CONCEPTS_KEYWORD(requires) +// C++ coroutines TS keywords +KEYWORD(co_await , KEYCOROUTINES) +KEYWORD(co_return , KEYCOROUTINES) +KEYWORD(co_yield , KEYCOROUTINES) + // GNU Extensions (in impl-reserved namespace) KEYWORD(_Decimal32 , KEYALL) KEYWORD(_Decimal64 , KEYALL) diff --git a/clang/include/clang/Driver/CC1Options.td b/clang/include/clang/Driver/CC1Options.td index 4f2dcdf7f22..dcd724d2451 100644 --- a/clang/include/clang/Driver/CC1Options.td +++ b/clang/include/clang/Driver/CC1Options.td @@ -580,6 +580,10 @@ def fnative_half_type: Flag<["-"], "fnative-half-type">, def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">, HelpText<"Allow function arguments and returns of type half">; +// C++ TSes. +def fcoroutines : Flag<["-"], "fcoroutines">, + HelpText<"Enable support for the C++ Coroutines TS">; + //===----------------------------------------------------------------------===// // Header Search Options //===----------------------------------------------------------------------===// diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 199815aa891..67de1cb6fda 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -111,7 +111,8 @@ namespace { KEYCONCEPTS = 0x10000, KEYOBJC2 = 0x20000, KEYZVECTOR = 0x40000, - KEYALL = (0x7ffff & ~KEYNOMS18 & + KEYCOROUTINES = 0x80000, + KEYALL = (0xfffff & ~KEYNOMS18 & ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude. }; @@ -147,6 +148,7 @@ static KeywordStatus getKeywordStatus(const LangOptions &LangOpts, if (LangOpts.ObjC2 && (Flags & KEYARC)) return KS_Enabled; if (LangOpts.ConceptsTS && (Flags & KEYCONCEPTS)) return KS_Enabled; if (LangOpts.ObjC2 && (Flags & KEYOBJC2)) return KS_Enabled; + if (LangOpts.Coroutines && (Flags & KEYCOROUTINES)) return KS_Enabled; if (LangOpts.CPlusPlus && (Flags & KEYCXX11)) return KS_Future; return KS_Disabled; } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 7cece2b3dd9..71ee7e47149 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1536,6 +1536,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data); Opts.Blocks = Args.hasArg(OPT_fblocks); Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional); + Opts.Coroutines = Args.hasArg(OPT_fcoroutines); Opts.Modules = Args.hasArg(OPT_fmodules); Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse); Opts.ModulesDeclUse = |