I don't personally think this diagnostic is clear enough. What is a RunAnalysis? Clang is known for its good, readable diagnostics - I'd prefer something more human-readable.<div><br></div><div>error:<command line>: Using functionality that has been compiled out of Clang</div>
<div>note:<command line>: Recompile without -DXXXX to enable this functionality<br><br><div class="gmail_quote">On 19 November 2012 11:53, Roman Divacky <span dir="ltr"><<a href="mailto:rdivacky@freebsd.org" target="_blank">rdivacky@freebsd.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ok, I made it emit an error like this:<br>
<br>
witten ~/llvm$ ./Release+Asserts/bin/clang -cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region tools/clang/test/Analysis/virtualcall.cpp<br>
error: action RunAnalysis not compiled in<br>
<br>
<br>
This happens to uncover a small bug though. We are emitting diagnostics in<br>
ExecuteCompilerInvocation.cpp which then gets warn about with -verify:<br>
<br>
<br>
witten ~/llvm$ ./Release+Asserts/bin/clang -cc1 -fsyntax-only -load /tmp/bah -plugin foobar -verify ~/hello.c<br>
error: 'error' diagnostics seen but not expected:<br>
  (frontend): unable to load plugin '/tmp/bah': '/tmp/bah: cannot open shared object file: No such file or directory'<br>
<br>
but thats a separate issue, just fwiw :)<br>
<br>
<br>
With the patch like that (#ifndef + emitting diagnostic), is it ok?<br>
<span class="HOEnZb"><font color="#888888"><br>
Roman<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Sun, Nov 18, 2012 at 06:50:37PM +0000, James Molloy wrote:<br>
> Agreed. If this is user facing, there should be a proper, explanatory<br>
> diagnostic message. Executing llvm_unreachable is a bug, not a feature!<br>
><br>
> On 18 November 2012 17:11, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>> wrote:<br>
><br>
> > On Sun, Nov 18, 2012 at 7:06 PM, Roman Divacky <<a href="mailto:rdivacky@freebsd.org">rdivacky@freebsd.org</a>><br>
> > wrote:<br>
> > > On Sun, Nov 18, 2012 at 02:45:10PM +0200, Dmitri Gribenko wrote:<br>
> > >> On Sun, Nov 18, 2012 at 2:16 PM, Roman Divacky <<a href="mailto:rdivacky@freebsd.org">rdivacky@freebsd.org</a>><br>
> > wrote:<br>
> > >> > I would like to ask about your opinion on the attached trivial patch,<br>
> > which<br>
> > >> > introduces #ifndef CLANG_IS_COMPILER_ONLY in two places.<br>
> > >><br>
> > >> --- lib/FrontendTool/ExecuteCompilerInvocation.cpp    (revision 168286)<br>
> > >> +++ lib/FrontendTool/ExecuteCompilerInvocation.cpp    (working copy)<br>
> > >> @@ -79,11 +81,13 @@<br>
> > >>      return new PrintPreprocessedAction();<br>
> > >>    }<br>
> > >><br>
> > >> +#ifndef CLANG_IS_COMPILER_ONLY<br>
> > >>    case RewriteMacros:          return new RewriteMacrosAction();<br>
> > >>    case RewriteObjC:            return new RewriteObjCAction();<br>
> > >>    case RewriteTest:            return new RewriteTestAction();<br>
> > >>    case RunAnalysis:            return new ento::AnalysisAction();<br>
> > >>    case MigrateSource:          return new arcmt::MigrateSourceAction();<br>
> > >> +#endif<br>
> > >>    case RunPreprocessorOnly:    return new PreprocessOnlyAction();<br>
> > >>    }<br>
> > >>    llvm_unreachable("Invalid program action!");<br>
> > >><br>
> > >> Won't this cause Clang to crash if the user asks for an action that is<br>
> > >> not compiled-in?<br>
> > ><br>
> > > It will execute llvm_unreachable("Invalid program action!"); which is<br>
> > fine<br>
> > > for me. FreeBSD really needs just the compiler bits.<br>
> > ><br>
> > > Note that I am not advocating making this the default, just having a way<br>
> > > to make this possible without modifying the sources.<br>
> ><br>
> > Well, I am just suggesting that Clang crashing on command line<br>
> > parameter invoking an action that is disabled during compile-time is<br>
> > not the user experience we want to provide for any Clang<br>
> > configuration.  A proper error message would be much better.<br>
> ><br>
> > Dmitri<br>
> ><br>
> > --<br>
> > main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
> > (j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>>*/<br>
> > _______________________________________________<br>
> > cfe-dev mailing list<br>
> > <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
> ><br>
</div></div></blockquote></div><br></div>