diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -374,6 +374,9 @@ std::string MTMigrateDir; std::string ARCMTMigrateReportOut; + /// The specifier or deduced input kind. + InputKind DashX; + /// The input files and their types. SmallVector Inputs; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2152,9 +2152,10 @@ return false; } -static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, - DiagnosticsEngine &Diags, - bool &IsHeaderFile) { +static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, + DiagnosticsEngine &Diags, bool &IsHeaderFile) { + unsigned NumErrorsBefore = Diags.getNumErrors(); + Opts.ProgramAction = frontend::ParseSyntaxOnly; if (const Arg *A = Args.getLastArg(OPT_Action_Group)) { switch (A->getOption().getID()) { @@ -2423,7 +2424,9 @@ Opts.Inputs.emplace_back(std::move(Inputs[i]), IK, IsSystem); } - return DashX; + Opts.DashX = DashX; + + return Diags.getNumErrors() == NumErrorsBefore; } std::string CompilerInvocation::GetResourcesPath(const char *Argv0, @@ -3957,9 +3960,10 @@ } Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags, /*DefaultDiagColor=*/false); + Success &= ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags, + LangOpts.IsHeaderFile); // FIXME: We shouldn't have to pass the DashX option around here - InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags, - LangOpts.IsHeaderFile); + InputKind DashX = Res.getFrontendOpts().DashX; ParseTargetArgs(Res.getTargetOpts(), Args, Diags); llvm::Triple T(Res.getTargetOpts().Triple); ParseHeaderSearchArgs(Res, Res.getHeaderSearchOpts(), Args, Diags,