On 22 December 2011 19:05, Dylan Noblesmith <span dir="ltr"><<a href="mailto:nobled@dreamwidth.org">nobled@dreamwidth.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: nobled<br>
Date: Thu Dec 22 21:05:38 2011<br>
New Revision: 147218<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=147218&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=147218&view=rev</a><br>
Log:<br>
Let CompilerInvocation initialization indicate failure<br>
<br>
This fixes the FIXMEs in ParseAnalyzeArgs. (Also a<br>
precursor to moving the analyzer into an AST plugin.)<br>
<br>
For consistency, do the same with AssemblerInvocation.<br>
<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Frontend/CompilerInvocation.h<br>
cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp<br>
cfe/trunk/tools/arcmt-test/arcmt-test.cpp<br>
cfe/trunk/tools/driver/cc1_main.cpp<br>
cfe/trunk/tools/driver/cc1as_main.cpp<br>
</blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Modified: cfe/trunk/tools/driver/cc1as_main.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=147218&r1=147217&r2=147218&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=147218&r1=147217&r2=147218&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)<br>
+++ cfe/trunk/tools/driver/cc1as_main.cpp Thu Dec 22 21:05:38 2011<br>
@@ -122,17 +122,19 @@<br>
NoExecStack = 0;<br>
}<br>
<br>
- static void CreateFromArgs(AssemblerInvocation &Res, const char **ArgBegin,<br>
+ static bool CreateFromArgs(AssemblerInvocation &Res, const char **ArgBegin,<br>
const char **ArgEnd, DiagnosticsEngine &Diags);<br>
};<br>
<br>
}<br>
<br>
-void AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,<br>
+bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,<br>
const char **ArgBegin,<br>
const char **ArgEnd,<br>
DiagnosticsEngine &Diags) {<br>
using namespace clang::driver::cc1asoptions;<br>
+ bool Success = true;<br>
+<br>
// Parse the arguments.<br>
OwningPtr<OptTable> OptTbl(createCC1AsOptTable());<br>
unsigned MissingArgIndex, MissingArgCount;<br>
@@ -140,14 +142,18 @@<br>
OptTbl->ParseArgs(ArgBegin, ArgEnd,MissingArgIndex, MissingArgCount));<br>
<br>
// Check for missing argument error.<br>
- if (MissingArgCount)<br>
+ if (MissingArgCount) {<br>
Diags.Report(diag::err_drv_missing_argument)<br>
<< Args->getArgString(MissingArgIndex) << MissingArgCount;<br>
+ Success = false;<br>
+ }<br>
<br>
// Issue errors on unknown arguments.<br>
for (arg_iterator it = Args->filtered_begin(cc1asoptions::OPT_UNKNOWN),<br>
- ie = Args->filtered_end(); it != ie; ++it)<br>
+ ie = Args->filtered_end(); it != ie; ++it) {<br>
Diags.Report(diag::err_drv_unknown_argument) << (*it) ->getAsString(*Args);<br>
+ Success = false;<br>
+ }<br>
<br>
// Construct the invocation.<br>
<br>
@@ -171,8 +177,10 @@<br>
const Arg *A = it;<br>
if (First)<br>
Opts.InputFile = A->getValue(*Args);<br>
- else<br>
+ else {<br>
Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(*Args);<br>
+ Success = false;<br>
+ }<br>
}<br>
}<br>
Opts.LLVMArgs = Args->getAllArgValues(OPT_mllvm);<br>
@@ -186,10 +194,11 @@<br>
.Case("null", FT_Null)<br>
.Case("obj", FT_Obj)<br>
.Default(~0U);<br>
- if (OutputType == ~0U)<br>
+ if (OutputType == ~0U) {<br>
Diags.Report(diag::err_drv_invalid_value)<br>
<< A->getAsString(*Args) << Name;<br>
- else<br>
+ Success = false;<br>
+ } else<br>
Opts.OutputType = FileType(OutputType);<br>
}<br>
Opts.ShowHelp = Args->hasArg(OPT_help);<br>
@@ -204,6 +213,8 @@<br>
// Assemble Options<br>
Opts.RelaxAll = Args->hasArg(OPT_relax_all);<br>
Opts.NoExecStack = Args->hasArg(OPT_no_exec_stack);<br>
+<br>
+ return true;<br></blockquote><div><br></div><div>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?</div><div><br></div><div>Nick</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
<br>
static formatted_raw_ostream *GetOutputStream(AssemblerInvocation &Opts,<br>
@@ -374,7 +385,8 @@<br>
<br>
// Parse the arguments.<br>
AssemblerInvocation Asm;<br>
- AssemblerInvocation::CreateFromArgs(Asm, ArgBegin, ArgEnd, Diags);<br>
+ if (!AssemblerInvocation::CreateFromArgs(Asm, ArgBegin, ArgEnd, Diags))<br>
+ return 1;<br>
<br>
// Honor -help.<br>
if (Asm.ShowHelp) {<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>