diff options
author | Dylan Noblesmith <nobled@dreamwidth.org> | 2011-12-23 03:05:38 +0000 |
---|---|---|
committer | Dylan Noblesmith <nobled@dreamwidth.org> | 2011-12-23 03:05:38 +0000 |
commit | 8fdb6dee2da0dee97d64fe12eda46fb318414de9 (patch) | |
tree | 292fb8930530d2d649998f23dc407d4b5ec0b157 /tools/driver/cc1as_main.cpp | |
parent | 9241057266d3460392cbb7fec6ec942d3330ece3 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/driver/cc1as_main.cpp')
-rw-r--r-- | tools/driver/cc1as_main.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index 9959b0d296..4591a36873 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -122,17 +122,19 @@ public: 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 @@ void AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, 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 @@ void AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, 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 @@ void AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, .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 @@ void AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, // Assemble Options Opts.RelaxAll = Args->hasArg(OPT_relax_all); Opts.NoExecStack = Args->hasArg(OPT_no_exec_stack); + + return true; } static formatted_raw_ostream *GetOutputStream(AssemblerInvocation &Opts, @@ -374,7 +385,8 @@ int cc1as_main(const char **ArgBegin, const char **ArgEnd, // 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) { |