Skip to content

Commit eb7927e

Browse files
committedOct 22, 2015
[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
1 parent 9c077cf commit eb7927e

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed
 

‎clang/include/clang/Basic/LangOptions.def

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ LANGOPT(Freestanding, 1, 0, "freestanding implementation")
118118
LANGOPT(NoBuiltin , 1, 0, "disable builtin functions")
119119
LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin functions")
120120
LANGOPT(GNUAsm , 1, 1, "GNU-style inline assembly")
121+
LANGOPT(Coroutines , 1, 0, "C++ coroutines TS")
121122

122123
BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
123124
LANGOPT(POSIXThreads , 1, 0, "POSIX thread support")

‎clang/include/clang/Basic/TokenKinds.def

+7
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ PUNCTUATOR(greatergreatergreater, ">>>")
242242
// KEYZVECTOR - This is a keyword for the System z vector extensions,
243243
// which are heavily based on AltiVec
244244
// KEYBORLAND - This is a keyword if Borland extensions are enabled
245+
// KEYCOROUTINES - This is a keyword if support for the C++ coroutines
246+
// TS is enabled
245247
// BOOLSUPPORT - This is a keyword if 'bool' is a built-in type
246248
// HALFSUPPORT - This is a keyword if 'half' is a built-in type
247249
// WCHARSUPPORT - This is a keyword if 'wchar_t' is a built-in type
@@ -356,6 +358,11 @@ CXX11_KEYWORD(thread_local , 0)
356358
CONCEPTS_KEYWORD(concept)
357359
CONCEPTS_KEYWORD(requires)
358360

361+
// C++ coroutines TS keywords
362+
KEYWORD(co_await , KEYCOROUTINES)
363+
KEYWORD(co_return , KEYCOROUTINES)
364+
KEYWORD(co_yield , KEYCOROUTINES)
365+
359366
// GNU Extensions (in impl-reserved namespace)
360367
KEYWORD(_Decimal32 , KEYALL)
361368
KEYWORD(_Decimal64 , KEYALL)

‎clang/include/clang/Driver/CC1Options.td

+4
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,10 @@ def fnative_half_type: Flag<["-"], "fnative-half-type">,
580580
def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">,
581581
HelpText<"Allow function arguments and returns of type half">;
582582

583+
// C++ TSes.
584+
def fcoroutines : Flag<["-"], "fcoroutines">,
585+
HelpText<"Enable support for the C++ Coroutines TS">;
586+
583587
//===----------------------------------------------------------------------===//
584588
// Header Search Options
585589
//===----------------------------------------------------------------------===//

‎clang/lib/Basic/IdentifierTable.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ namespace {
111111
KEYCONCEPTS = 0x10000,
112112
KEYOBJC2 = 0x20000,
113113
KEYZVECTOR = 0x40000,
114-
KEYALL = (0x7ffff & ~KEYNOMS18 &
114+
KEYCOROUTINES = 0x80000,
115+
KEYALL = (0xfffff & ~KEYNOMS18 &
115116
~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
116117
};
117118

@@ -147,6 +148,7 @@ static KeywordStatus getKeywordStatus(const LangOptions &LangOpts,
147148
if (LangOpts.ObjC2 && (Flags & KEYARC)) return KS_Enabled;
148149
if (LangOpts.ConceptsTS && (Flags & KEYCONCEPTS)) return KS_Enabled;
149150
if (LangOpts.ObjC2 && (Flags & KEYOBJC2)) return KS_Enabled;
151+
if (LangOpts.Coroutines && (Flags & KEYCOROUTINES)) return KS_Enabled;
150152
if (LangOpts.CPlusPlus && (Flags & KEYCXX11)) return KS_Future;
151153
return KS_Disabled;
152154
}

‎clang/lib/Frontend/CompilerInvocation.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
15361536
Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
15371537
Opts.Blocks = Args.hasArg(OPT_fblocks);
15381538
Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
1539+
Opts.Coroutines = Args.hasArg(OPT_fcoroutines);
15391540
Opts.Modules = Args.hasArg(OPT_fmodules);
15401541
Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse);
15411542
Opts.ModulesDeclUse =

0 commit comments

Comments
 (0)
Please sign in to comment.