aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2021-01-27 14:34:09 +0100
committerJan Svoboda <jan_svoboda@apple.com>2021-01-27 14:45:55 +0100
commit05127fba4b66c91489e9f380f691a0bb42cd2782 (patch)
treec023dea6407c7e97a36b840ed707002050b76bda /clang/lib/Frontend/CompilerInvocation.cpp
parent9ad94c126aacd7f5c54632430870fa5308830e45 (diff)
downloadllvm-05127fba4b66c91489e9f380f691a0bb42cd2782.zip
llvm-05127fba4b66c91489e9f380f691a0bb42cd2782.tar.gz
llvm-05127fba4b66c91489e9f380f691a0bb42cd2782.tar.bz2
[clang][cli] Parse HeaderSearch options separately
This patch moves parsing of header search options from `parseSimpleArgs` back to `ParseHeaderSearchArgs` where they originally were. The round-trip algorithm in D94472 requires this separation to be able to run parsing and generating **only** for the options that need to be tested via round-tripping. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D94802
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d61c3bd..f3e9f05 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1827,7 +1827,23 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
}
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
+ DiagnosticsEngine &Diags,
const std::string &WorkingDir) {
+ HeaderSearchOptions *HeaderSearchOpts = &Opts;
+ bool Success = true;
+
+#define HEADER_SEARCH_OPTION_WITH_MARSHALLING( \
+ PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
+ HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \
+ DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
+ MERGER, EXTRACTOR, TABLE_INDEX) \
+ PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, ID, FLAGS, PARAM, \
+ SHOULD_PARSE, KEYPATH, DEFAULT_VALUE, \
+ IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, \
+ MERGER, TABLE_INDEX)
+#include "clang/Driver/Options.inc"
+#undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
+
if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
@@ -2774,7 +2790,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
LangOpts.IsHeaderFile);
ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
llvm::Triple T(Res.getTargetOpts().Triple);
- ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args,
+ ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags,
Res.getFileSystemOpts().WorkingDir);
if (DashX.getFormat() == InputKind::Precompiled ||
DashX.getLanguage() == Language::LLVM_IR) {
@@ -2995,6 +3011,7 @@ void CompilerInvocation::generateCC1CommandLine(
EXTRACTOR, TABLE_INDEX)
#define DIAG_OPTION_WITH_MARSHALLING OPTION_WITH_MARSHALLING
+#define HEADER_SEARCH_OPTION_WITH_MARSHALLING OPTION_WITH_MARSHALLING
#define LANG_OPTION_WITH_MARSHALLING OPTION_WITH_MARSHALLING
#define CODEGEN_OPTION_WITH_MARSHALLING OPTION_WITH_MARSHALLING
@@ -3002,6 +3019,7 @@ void CompilerInvocation::generateCC1CommandLine(
#undef CODEGEN_OPTION_WITH_MARSHALLING
#undef LANG_OPTION_WITH_MARSHALLING
+#undef HEADER_SEARCH_OPTION_WITH_MARSHALLING
#undef DIAG_OPTION_WITH_MARSHALLING
#undef OPTION_WITH_MARSHALLING
#undef GENERATE_OPTION_WITH_MARSHALLING