Skip to content

Commit f4511ae

Browse files
committed
[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
1 parent 2d9ae1d commit f4511ae

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,8 @@ def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group<i_Group>,
17971797
HelpText<"Specify the module cache path">;
17981798
def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group<i_Group>,
17991799
Flags<[NoXarchOption, CC1Option]>, MetaVarName<"<directory>">,
1800-
HelpText<"Specify the module user build path">;
1800+
HelpText<"Specify the module user build path">,
1801+
MarshallingInfoString<"HeaderSearchOpts->ModuleUserBuildPath">;
18011802
def fprebuilt_module_path : Joined<["-"], "fprebuilt-module-path=">, Group<i_Group>,
18021803
Flags<[NoXarchOption, CC1Option]>, MetaVarName<"<directory>">,
18031804
HelpText<"Specify the prebuilt module path">;
@@ -1806,16 +1807,19 @@ defm prebuilt_implicit_modules : OptInFFlag<"prebuilt-implicit-modules",
18061807
[NoXarchOption, CC1Option], "HeaderSearchOpts->EnablePrebuiltImplicitModules">;
18071808
def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group<i_Group>,
18081809
Flags<[CC1Option]>, MetaVarName<"<seconds>">,
1809-
HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">;
1810+
HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">,
1811+
MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneInterval", "7 * 24 * 60 * 60">;
18101812
def fmodules_prune_after : Joined<["-"], "fmodules-prune-after=">, Group<i_Group>,
18111813
Flags<[CC1Option]>, MetaVarName<"<seconds>">,
1812-
HelpText<"Specify the interval (in seconds) after which a module file will be considered unused">;
1814+
HelpText<"Specify the interval (in seconds) after which a module file will be considered unused">,
1815+
MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneAfter", "31 * 24 * 60 * 60">;
18131816
def fmodules_search_all : Flag <["-"], "fmodules-search-all">, Group<f_Group>,
18141817
Flags<[NoXarchOption, CC1Option]>,
18151818
HelpText<"Search even non-imported modules to resolve references">;
18161819
def fbuild_session_timestamp : Joined<["-"], "fbuild-session-timestamp=">,
18171820
Group<i_Group>, Flags<[CC1Option]>, MetaVarName<"<time since Epoch in seconds>">,
1818-
HelpText<"Time when the current build session started">;
1821+
HelpText<"Time when the current build session started">,
1822+
MarshallingInfoStringInt<"HeaderSearchOpts->BuildSessionTimestamp">;
18191823
def fbuild_session_file : Joined<["-"], "fbuild-session-file=">,
18201824
Group<i_Group>, MetaVarName<"<file>">,
18211825
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
26022606
def iquote : JoinedOrSeparate<["-"], "iquote">, Group<clang_i_Group>, Flags<[CC1Option]>,
26032607
HelpText<"Add directory to QUOTE include search path">, MetaVarName<"<directory>">;
26042608
def isysroot : JoinedOrSeparate<["-"], "isysroot">, Group<clang_i_Group>, Flags<[CC1Option]>,
2605-
HelpText<"Set the system root directory (usually /)">, MetaVarName<"<dir>">;
2609+
HelpText<"Set the system root directory (usually /)">, MetaVarName<"<dir>">,
2610+
MarshallingInfoString<"HeaderSearchOpts->Sysroot", [{"/"}]>;
26062611
def isystem : JoinedOrSeparate<["-"], "isystem">, Group<clang_i_Group>,
26072612
Flags<[CC1Option]>,
26082613
HelpText<"Add directory to SYSTEM include search path">, MetaVarName<"<directory>">;
@@ -3330,7 +3335,8 @@ def rewrite_legacy_objc : Flag<["-"], "rewrite-legacy-objc">, Flags<[NoXarchOpti
33303335
def rdynamic : Flag<["-"], "rdynamic">, Group<Link_Group>;
33313336
def resource_dir : Separate<["-"], "resource-dir">,
33323337
Flags<[NoXarchOption, CC1Option, CoreOption, HelpHidden]>,
3333-
HelpText<"The directory which holds the compiler resource files">;
3338+
HelpText<"The directory which holds the compiler resource files">,
3339+
MarshallingInfoString<"HeaderSearchOpts->ResourceDir">;
33343340
def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[NoXarchOption, CoreOption]>,
33353341
Alias<resource_dir>;
33363342
def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>;
@@ -4671,7 +4677,8 @@ def fmodules_debuginfo :
46714677
MarshallingInfoFlag<"LangOpts->ModulesDebugInfo">;
46724678
def fmodule_format_EQ : Joined<["-"], "fmodule-format=">,
46734679
HelpText<"Select the container format for clang modules and PCH. "
4674-
"Supported options are 'raw' and 'obj'.">;
4680+
"Supported options are 'raw' and 'obj'.">,
4681+
MarshallingInfoString<"HeaderSearchOpts->ModuleFormat", [{"raw"}]>;
46754682
def ftest_module_file_extension_EQ :
46764683
Joined<["-"], "ftest-module-file-extension=">,
46774684
HelpText<"introduce a module file extension for testing purposes. "

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,10 +2028,8 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
20282028

20292029
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
20302030
const std::string &WorkingDir) {
2031-
Opts.Sysroot = std::string(Args.getLastArgValue(OPT_isysroot, "/"));
20322031
if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
20332032
Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
2034-
Opts.ResourceDir = std::string(Args.getLastArgValue(OPT_resource_dir));
20352033

20362034
// Canonicalize -fmodules-cache-path before storing it.
20372035
SmallString<128> P(Args.getLastArgValue(OPT_fmodules_cache_path));
@@ -2044,8 +2042,6 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
20442042
llvm::sys::path::remove_dots(P);
20452043
Opts.ModuleCachePath = std::string(P.str());
20462044

2047-
Opts.ModuleUserBuildPath =
2048-
std::string(Args.getLastArgValue(OPT_fmodules_user_build_path));
20492045
// Only the -fmodule-file=<name>=<file> form.
20502046
for (const auto *A : Args.filtered(OPT_fmodule_file)) {
20512047
StringRef Val = A->getValue();
@@ -2057,14 +2053,6 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
20572053
}
20582054
for (const auto *A : Args.filtered(OPT_fprebuilt_module_path))
20592055
Opts.AddPrebuiltModulePath(A->getValue());
2060-
Opts.ModuleCachePruneInterval =
2061-
getLastArgIntValue(Args, OPT_fmodules_prune_interval, 7 * 24 * 60 * 60);
2062-
Opts.ModuleCachePruneAfter =
2063-
getLastArgIntValue(Args, OPT_fmodules_prune_after, 31 * 24 * 60 * 60);
2064-
Opts.BuildSessionTimestamp =
2065-
getLastArgUInt64Value(Args, OPT_fbuild_session_timestamp, 0);
2066-
if (const Arg *A = Args.getLastArg(OPT_fmodule_format_EQ))
2067-
Opts.ModuleFormat = A->getValue();
20682056

20692057
for (const auto *A : Args.filtered(OPT_fmodules_ignore_macro)) {
20702058
StringRef MacroDef = A->getValue();

0 commit comments

Comments
 (0)