[cfe-commits] r147218 - in /cfe/trunk: include/clang/Frontend/CompilerInvocation.h lib/Frontend/CompilerInvocation.cpp lib/Frontend/CreateInvocationFromCommandLine.cpp tools/arcmt-test/arcmt-test.cpp tools/driver/cc1_main.cpp tools/driver/cc1as_m
Nick Lewycky
nlewycky at google.com
Sat Dec 24 08:07:33 PST 2011
On 22 December 2011 19:05, Dylan Noblesmith <nobled at dreamwidth.org> wrote:
> Author: nobled
> Date: Thu Dec 22 21:05:38 2011
> New Revision: 147218
>
> URL: http://llvm.org/viewvc/llvm-project?rev=147218&view=rev
> Log:
> Let CompilerInvocation initialization indicate failure
>
> This fixes the FIXMEs in ParseAnalyzeArgs. (Also a
> precursor to moving the analyzer into an AST plugin.)
>
> For consistency, do the same with AssemblerInvocation.
>
>
> Modified:
> cfe/trunk/include/clang/Frontend/CompilerInvocation.h
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
> cfe/trunk/tools/arcmt-test/arcmt-test.cpp
> cfe/trunk/tools/driver/cc1_main.cpp
> cfe/trunk/tools/driver/cc1as_main.cpp
>
> Modified: cfe/trunk/tools/driver/cc1as_main.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=147218&r1=147217&r2=147218&view=diff
>
> ==============================================================================
> --- cfe/trunk/tools/driver/cc1as_main.cpp (original)
> +++ cfe/trunk/tools/driver/cc1as_main.cpp Thu Dec 22 21:05:38 2011
> @@ -122,17 +122,19 @@
> NoExecStack = 0;
> }
>
> - static void CreateFromArgs(AssemblerInvocation &Res, const char
> **ArgBegin,
> + static bool CreateFromArgs(AssemblerInvocation &Res, const char
> **ArgBegin,
> const char **ArgEnd, DiagnosticsEngine
> &Diags);
> };
>
> }
>
> -void AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
> +bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
> const char **ArgBegin,
> const char **ArgEnd,
> DiagnosticsEngine &Diags) {
> using namespace clang::driver::cc1asoptions;
> + bool Success = true;
> +
> // Parse the arguments.
> OwningPtr<OptTable> OptTbl(createCC1AsOptTable());
> unsigned MissingArgIndex, MissingArgCount;
> @@ -140,14 +142,18 @@
> OptTbl->ParseArgs(ArgBegin, ArgEnd,MissingArgIndex, MissingArgCount));
>
> // Check for missing argument error.
> - if (MissingArgCount)
> + if (MissingArgCount) {
> Diags.Report(diag::err_drv_missing_argument)
> << Args->getArgString(MissingArgIndex) << MissingArgCount;
> + Success = false;
> + }
>
> // Issue errors on unknown arguments.
> for (arg_iterator it = Args->filtered_begin(cc1asoptions::OPT_UNKNOWN),
> - ie = Args->filtered_end(); it != ie; ++it)
> + ie = Args->filtered_end(); it != ie; ++it) {
> Diags.Report(diag::err_drv_unknown_argument) << (*it)
> ->getAsString(*Args);
> + Success = false;
> + }
>
> // Construct the invocation.
>
> @@ -171,8 +177,10 @@
> const Arg *A = it;
> if (First)
> Opts.InputFile = A->getValue(*Args);
> - else
> + else {
> Diags.Report(diag::err_drv_unknown_argument) <<
> A->getAsString(*Args);
> + Success = false;
> + }
> }
> }
> Opts.LLVMArgs = Args->getAllArgValues(OPT_mllvm);
> @@ -186,10 +194,11 @@
> .Case("null", FT_Null)
> .Case("obj", FT_Obj)
> .Default(~0U);
> - if (OutputType == ~0U)
> + if (OutputType == ~0U) {
> Diags.Report(diag::err_drv_invalid_value)
> << A->getAsString(*Args) << Name;
> - else
> + Success = false;
> + } else
> Opts.OutputType = FileType(OutputType);
> }
> Opts.ShowHelp = Args->hasArg(OPT_help);
> @@ -204,6 +213,8 @@
> // Assemble Options
> Opts.RelaxAll = Args->hasArg(OPT_relax_all);
> Opts.NoExecStack = Args->hasArg(OPT_no_exec_stack);
> +
> + return true;
>
GCC is warnings about Success being a dead variable. Did you want to return
it here, or else should we remove Success from this function?
Nick
> }
>
> static formatted_raw_ostream *GetOutputStream(AssemblerInvocation &Opts,
> @@ -374,7 +385,8 @@
>
> // Parse the arguments.
> AssemblerInvocation Asm;
> - AssemblerInvocation::CreateFromArgs(Asm, ArgBegin, ArgEnd, Diags);
> + if (!AssemblerInvocation::CreateFromArgs(Asm, ArgBegin, ArgEnd, Diags))
> + return 1;
>
> // Honor -help.
> if (Asm.ShowHelp) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111224/a8bc75b6/attachment.html>
More information about the cfe-commits
mailing list