r276508 - Add -fmodules-ts flag to cc1 for the provisional C++ modules TS, and mark
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 29 02:44:26 PDT 2016
On 23/07/16 04:32, Richard Smith via cfe-commits wrote:
> Author: rsmith
> Date: Fri Jul 22 21:32:21 2016
> New Revision: 276508
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276508&view=rev
> Log:
> Add -fmodules-ts flag to cc1 for the provisional C++ modules TS, and mark
> 'module' and 'import' as keywords when the flag is specified.
>
> Added:
> cfe/trunk/test/Lexer/modules-ts.cpp
> Modified:
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Basic/TokenKinds.def
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/lib/Basic/IdentifierTable.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=276508&r1=276507&r2=276508&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Jul 22 21:32:21 2016
> @@ -142,6 +142,7 @@ BENIGN_LANGOPT(EmitAllDecls , 1, 0,
> LANGOPT(MathErrno , 1, 1, "errno in math functions")
> BENIGN_LANGOPT(HeinousExtensions , 1, 0, "extensions that we really don't like and may be ripped out at any time")
> LANGOPT(Modules , 1, 0, "modules extension to C")
> +LANGOPT(ModulesTS , 1, 0, "C++ Modules TS")
> BENIGN_LANGOPT(CompilingModule, 1, 0, "compiling a module interface")
> COMPATIBLE_LANGOPT(ModulesDeclUse , 1, 0, "require declaration of module uses")
> BENIGN_LANGOPT(ModulesSearchAll , 1, 1, "searching even non-imported modules to find unresolved references")
>
> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=276508&r1=276507&r2=276508&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
> +++ cfe/trunk/include/clang/Basic/TokenKinds.def Fri Jul 22 21:32:21 2016
> @@ -30,6 +30,9 @@
> #ifndef CONCEPTS_KEYWORD
> #define CONCEPTS_KEYWORD(X) KEYWORD(X,KEYCONCEPTS)
> #endif
> +#ifndef MODULES_KEYWORD
> +#define MODULES_KEYWORD(X) KEYWORD(X,KEYMODULES)
> +#endif
> #ifndef TYPE_TRAIT
> #define TYPE_TRAIT(N,I,K) KEYWORD(I,K)
> #endif
> @@ -235,6 +238,8 @@ PUNCTUATOR(caretcaret, "^^")
> // KEYCXX11 - This is a C++ keyword introduced to C++ in C++11
> // KEYCONCEPTS - This is a keyword if the C++ extensions for concepts
> // are enabled.
> +// KEYMODULES - This is a keyword if the C++ extensions for modules
> +// are enabled.
> // KEYGNU - This is a keyword if GNU extensions are enabled
> // KEYMS - This is a keyword if Microsoft extensions are enabled
> // KEYNOMS18 - This is a keyword that must never be enabled under
> @@ -366,6 +371,10 @@ KEYWORD(co_await , KE
> KEYWORD(co_return , KEYCOROUTINES)
> KEYWORD(co_yield , KEYCOROUTINES)
>
> +// C++ modules TS keywords
> +MODULES_KEYWORD(module)
> +MODULES_KEYWORD(import)
> +
> // GNU Extensions (in impl-reserved namespace)
> KEYWORD(_Decimal32 , KEYALL)
> KEYWORD(_Decimal64 , KEYALL)
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=276508&r1=276507&r2=276508&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jul 22 21:32:21 2016
> @@ -388,6 +388,8 @@ def ast_dump_filter : Separate<["-"], "a
> HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration"
> " nodes having a certain substring in a qualified name. Use"
> " -ast-list to list all filterable declaration node names.">;
> +def fmodules_ts : Flag <["-"], "fmodules-ts">, Group<f_Group>,
> + HelpText<"Enable support for the C++ Modules TS">;
> def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">,
> HelpText<"Do not automatically generate or update the global module index">;
> def fno_modules_error_recovery : Flag<["-"], "fno-modules-error-recovery">,
>
> Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=276508&r1=276507&r2=276508&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
> +++ cfe/trunk/lib/Basic/IdentifierTable.cpp Fri Jul 22 21:32:21 2016
> @@ -113,7 +113,8 @@ namespace {
> KEYOBJC2 = 0x20000,
> KEYZVECTOR = 0x40000,
> KEYCOROUTINES = 0x80000,
> - KEYALL = (0xfffff & ~KEYNOMS18 &
> + KEYMODULES = 0x100000,
> + KEYALL = (0x1fffff & ~KEYNOMS18 &
> ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
> };
>
> @@ -147,9 +148,10 @@ static KeywordStatus getKeywordStatus(co
> // We treat bridge casts as objective-C keywords so we can warn on them
> // in non-arc mode.
> 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.ConceptsTS && (Flags & KEYCONCEPTS)) return KS_Enabled;
> if (LangOpts.Coroutines && (Flags & KEYCOROUTINES)) return KS_Enabled;
> + if (LangOpts.ModulesTS && (Flags & KEYMODULES)) return KS_Enabled;
> if (LangOpts.CPlusPlus && (Flags & KEYCXX11)) return KS_Future;
> return KS_Disabled;
> }
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=276508&r1=276507&r2=276508&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Jul 22 21:32:21 2016
> @@ -1873,12 +1873,13 @@ static void ParseLangArgs(LangOptions &O
> && Opts.OpenCLVersion >= 200);
> Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
> Opts.Coroutines = Args.hasArg(OPT_fcoroutines);
> - Opts.Modules = Args.hasArg(OPT_fmodules);
> + Opts.ModulesTS = Args.hasArg(OPT_fmodules_ts);
> + Opts.Modules = Args.hasArg(OPT_fmodules) || Opts.ModulesTS;
> Opts.ModulesStrictDeclUse = Args.hasArg(OPT_fmodules_strict_decluse);
> Opts.ModulesDeclUse =
> Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
> Opts.ModulesLocalVisibility =
> - Args.hasArg(OPT_fmodules_local_submodule_visibility);
> + Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS;
Shall we make the -fmodules-local-submodule-visibility the default
modules behavior? We constantly stumble upon issues which go away if we
use it.
> Opts.ModulesSearchAll = Opts.Modules &&
> !Args.hasArg(OPT_fno_modules_search_all) &&
> Args.hasArg(OPT_fmodules_search_all);
>
> Added: cfe/trunk/test/Lexer/modules-ts.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/modules-ts.cpp?rev=276508&view=auto
> ==============================================================================
> --- cfe/trunk/test/Lexer/modules-ts.cpp (added)
> +++ cfe/trunk/test/Lexer/modules-ts.cpp Fri Jul 22 21:32:21 2016
> @@ -0,0 +1,11 @@
> +// RUN: %clang_cc1 -fsyntax-only %s
> +// RUN: %clang_cc1 -fmodules-ts -DMODULES -fsyntax-only %s
> +
> +#ifdef MODULES
> +#define MODULES_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
> +#else
> +#define MODULES_KEYWORD(NAME) _Static_assert(__is_identifier(NAME), #NAME)
> +#endif
> +
> +MODULES_KEYWORD(import);
> +MODULES_KEYWORD(module);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list