[clang] f4511ae - [clang][cli] Port HeaderSearch simple string options to new option parsing system
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 18 00:30:50 PST 2020
Author: Jan Svoboda
Date: 2020-12-18T09:30:32+01:00
New Revision: f4511aec2bf482f2ae5bbd14138a229b72c41c80
URL: https://github.com/llvm/llvm-project/commit/f4511aec2bf482f2ae5bbd14138a229b72c41c80
DIFF: https://github.com/llvm/llvm-project/commit/f4511aec2bf482f2ae5bbd14138a229b72c41c80.diff
LOG: [clang][cli] Port HeaderSearch simple string options to new option parsing system
Depends on D84669
Reviewed By: Bigcheese
Original patch by Daniel Grumberg.
Differential Revision: https://reviews.llvm.org/D84670
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 9987143009d3..7275e84d7c53 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1797,7 +1797,8 @@ def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group<i_Group>,
HelpText<"Specify the module cache path">;
def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group<i_Group>,
Flags<[NoXarchOption, CC1Option]>, MetaVarName<"<directory>">,
- HelpText<"Specify the module user build path">;
+ HelpText<"Specify the module user build path">,
+ MarshallingInfoString<"HeaderSearchOpts->ModuleUserBuildPath">;
def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, Group<i_Group>,
Flags<[NoXarchOption, CC1Option]>, MetaVarName<"<directory>">,
HelpText<"Specify the prebuilt module path">;
@@ -1806,16 +1807,19 @@ defm prebuilt_implicit_modules : OptInFFlag<"prebuilt-implicit-modules",
[NoXarchOption, CC1Option], "HeaderSearchOpts->EnablePrebuiltImplicitModules">;
def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group<i_Group>,
Flags<[CC1Option]>, MetaVarName<"<seconds>">,
- HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">;
+ HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">,
+ MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneInterval", "7 * 24 * 60 * 60">;
def fmodules_prune_after : Joined<["-"], "fmodules-prune-after=">, Group<i_Group>,
Flags<[CC1Option]>, MetaVarName<"<seconds>">,
- HelpText<"Specify the interval (in seconds) after which a module file will be considered unused">;
+ HelpText<"Specify the interval (in seconds) after which a module file will be considered unused">,
+ MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneAfter", "31 * 24 * 60 * 60">;
def fmodules_search_all : Flag <["-"], "fmodules-search-all">, Group<f_Group>,
Flags<[NoXarchOption, CC1Option]>,
HelpText<"Search even non-imported modules to resolve references">;
def fbuild_session_timestamp : Joined<["-"], "fbuild-session-timestamp=">,
Group<i_Group>, Flags<[CC1Option]>, MetaVarName<"<time since Epoch in seconds>">,
- HelpText<"Time when the current build session started">;
+ HelpText<"Time when the current build session started">,
+ MarshallingInfoStringInt<"HeaderSearchOpts->BuildSessionTimestamp">;
def fbuild_session_file : Joined<["-"], "fbuild-session-file=">,
Group<i_Group>, MetaVarName<"<file>">,
HelpText<"Use the last modification time of <file> as the build session timestamp">;
@@ -2602,7 +2606,8 @@ def iprefix : JoinedOrSeparate<["-"], "iprefix">, Group<clang_i_Group>, Flags<[C
def iquote : JoinedOrSeparate<["-"], "iquote">, Group<clang_i_Group>, Flags<[CC1Option]>,
HelpText<"Add directory to QUOTE include search path">, MetaVarName<"<directory>">;
def isysroot : JoinedOrSeparate<["-"], "isysroot">, Group<clang_i_Group>, Flags<[CC1Option]>,
- HelpText<"Set the system root directory (usually /)">, MetaVarName<"<dir>">;
+ HelpText<"Set the system root directory (usually /)">, MetaVarName<"<dir>">,
+ MarshallingInfoString<"HeaderSearchOpts->Sysroot", [{"/"}]>;
def isystem : JoinedOrSeparate<["-"], "isystem">, Group<clang_i_Group>,
Flags<[CC1Option]>,
HelpText<"Add directory to SYSTEM include search path">, MetaVarName<"<directory>">;
@@ -3330,7 +3335,8 @@ def rewrite_legacy_objc : Flag<["-"], "rewrite-legacy-objc">, Flags<[NoXarchOpti
def rdynamic : Flag<["-"], "rdynamic">, Group<Link_Group>;
def resource_dir : Separate<["-"], "resource-dir">,
Flags<[NoXarchOption, CC1Option, CoreOption, HelpHidden]>,
- HelpText<"The directory which holds the compiler resource files">;
+ HelpText<"The directory which holds the compiler resource files">,
+ MarshallingInfoString<"HeaderSearchOpts->ResourceDir">;
def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[NoXarchOption, CoreOption]>,
Alias<resource_dir>;
def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>;
@@ -4671,7 +4677,8 @@ def fmodules_debuginfo :
MarshallingInfoFlag<"LangOpts->ModulesDebugInfo">;
def fmodule_format_EQ : Joined<["-"], "fmodule-format=">,
HelpText<"Select the container format for clang modules and PCH. "
- "Supported options are 'raw' and 'obj'.">;
+ "Supported options are 'raw' and 'obj'.">,
+ MarshallingInfoString<"HeaderSearchOpts->ModuleFormat", [{"raw"}]>;
def ftest_module_file_extension_EQ :
Joined<["-"], "ftest-module-file-extension=">,
HelpText<"introduce a module file extension for testing purposes. "
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d2b590f08507..f7bb2308953f 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2028,10 +2028,8 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
const std::string &WorkingDir) {
- Opts.Sysroot = std::string(Args.getLastArgValue(OPT_isysroot, "/"));
if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
- Opts.ResourceDir = std::string(Args.getLastArgValue(OPT_resource_dir));
// Canonicalize -fmodules-cache-path before storing it.
SmallString<128> P(Args.getLastArgValue(OPT_fmodules_cache_path));
@@ -2044,8 +2042,6 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
llvm::sys::path::remove_dots(P);
Opts.ModuleCachePath = std::string(P.str());
- Opts.ModuleUserBuildPath =
- std::string(Args.getLastArgValue(OPT_fmodules_user_build_path));
// Only the -fmodule-file=<name>=<file> form.
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
StringRef Val = A->getValue();
@@ -2057,14 +2053,6 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
}
for (const auto *A : Args.filtered(OPT_fprebuilt_module_path))
Opts.AddPrebuiltModulePath(A->getValue());
- Opts.ModuleCachePruneInterval =
- getLastArgIntValue(Args, OPT_fmodules_prune_interval, 7 * 24 * 60 * 60);
- Opts.ModuleCachePruneAfter =
- getLastArgIntValue(Args, OPT_fmodules_prune_after, 31 * 24 * 60 * 60);
- Opts.BuildSessionTimestamp =
- getLastArgUInt64Value(Args, OPT_fbuild_session_timestamp, 0);
- if (const Arg *A = Args.getLastArg(OPT_fmodule_format_EQ))
- Opts.ModuleFormat = A->getValue();
for (const auto *A : Args.filtered(OPT_fmodules_ignore_macro)) {
StringRef MacroDef = A->getValue();
More information about the cfe-commits
mailing list