diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2021-02-08 09:44:11 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2021-02-08 09:56:33 +0100 |
commit | bff6d9bb0f6d382d1d1826e997a6104bbe5ade73 (patch) | |
tree | 93826038e20f3ba22e5bf67508410ffeb822ebfa /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 0ebf904bafce983fd2018f2b5b8288dd5ded0cdb (diff) | |
download | llvm-bff6d9bb0f6d382d1d1826e997a6104bbe5ade73.zip llvm-bff6d9bb0f6d382d1d1826e997a6104bbe5ade73.tar.gz llvm-bff6d9bb0f6d382d1d1826e997a6104bbe5ade73.tar.bz2 |
[clang][cli] Report result of ParseLangArgs
This patch correctly reports success/failure of `ParseLangArgs`. Besides being consistent with other `Parse` functions, this is required to make round-tripping of `LangOptions` work.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D95792
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 8743da2..3f8748f 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2642,10 +2642,12 @@ static void GenerateLangArgs(const LangOptions &Opts, GenerateArg(Args, OPT_fdeclare_opencl_builtins, SA); } -void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, +bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, const llvm::Triple &T, std::vector<std::string> &Includes, DiagnosticsEngine &Diags) { + unsigned NumErrorsBefore = Diags.getNumErrors(); + // FIXME: Cleanup per-file based stuff. LangStandard::Kind LangStd = LangStandard::lang_unspecified; if (const Arg *A = Args.getLastArg(OPT_std_EQ)) { @@ -3076,6 +3078,8 @@ void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, } } } + + return Success && Diags.getNumErrors() == NumErrorsBefore; } static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { @@ -3416,8 +3420,8 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, } else { // Other LangOpts are only initialized when the input is not AST or LLVM IR. // FIXME: Should we really be calling this for an Language::Asm input? - ParseLangArgs(LangOpts, Args, DashX, T, Res.getPreprocessorOpts().Includes, - Diags); + Success &= ParseLangArgs(LangOpts, Args, DashX, T, + Res.getPreprocessorOpts().Includes, Diags); if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC) LangOpts.ObjCExceptions = 1; if (T.isOSDarwin() && DashX.isPreprocessed()) { |