forked from OSchip/llvm-project
[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
This commit is contained in:
parent
0ebf904baf
commit
bff6d9bb0f
|
@ -806,6 +806,7 @@ public:
|
|||
return FatalErrorOccurred || UnrecoverableErrorOccurred;
|
||||
}
|
||||
|
||||
unsigned getNumErrors() const { return NumErrors; }
|
||||
unsigned getNumWarnings() const { return NumWarnings; }
|
||||
|
||||
void setNumWarnings(unsigned NumWarnings) {
|
||||
|
|
|
@ -249,7 +249,7 @@ private:
|
|||
DiagnosticsEngine &Diags);
|
||||
|
||||
/// Parse command line options that map to LangOptions.
|
||||
static void ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
|
||||
static bool ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
|
||||
InputKind IK, const llvm::Triple &T,
|
||||
std::vector<std::string> &Includes,
|
||||
DiagnosticsEngine &Diags);
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue