<div dir="ltr"><div><div><div><div>Hi<br></div>Your code seems to work fine, what is your clang version?<br></div>Can you elaborate the problem ?<br><br>> Also the category needs to be applied<br>
on the new option, otherwise it's not shown in the help.<br><br></div><div>
That seems to be by design.<br></div><div><br>Examples of invocation:<br>$ ./bin/testtool ~/b.cpp -abc=1 -- -std=c++11<br>1<br></div><br>$ ./bin/testtool --help <br></div><snip><br><div>My tool options:<br><br>  -abc                       - <br></div><div><snip><br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 21, 2015 at 3:41 PM, Christoph Viebig (lists) <span dir="ltr"><<a href="mailto:lists@christoph-viebig.de" target="_blank">lists@christoph-viebig.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello list,<br>
<br>
I am currently working on a libTooling project and need to read custom<br>
command line options for this.<br>
<br>
Unfortunately I was not able to get the following sample code from<br>
CommonOptionsParser [1] to run. Can you please give me an advice what<br>
might be the problem here?<br>
<br>
To make the sample code compiling I had to add the import of Tooling.h<br>
and modify the Tool.run() call to retrieve the Front-end action via<br>
.get() from the factory first. Also the category needs to be applied<br>
on the new option, otherwise it's not shown in the help.<br>
<br>
#include "clang/Frontend/FrontendActions.h"<br>
#include "clang/Tooling/CommonOptionsParser.h"<br>
#include "clang/Tooling/Tooling.h"<br>
#include "llvm/Support/CommandLine.h"<br>
<br>
using namespace clang::tooling;<br>
using namespace llvm;<br>
<br>
static cl::OptionCategory MyToolCategory("My tool options");<br>
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);<br>
static cl::extrahelp MoreHelp("\nMore help text...");<br>
static cl::opt<bool> YourOwnOption("abc", cl::cat(MyToolCategory));<br>
<br>
int main(int argc, const char **argv) {<br>
  CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);<br>
  ClangTool Tool(OptionsParser.getCompilations(),<br>
  OptionsParser.getSourcePathList());<br>
  llvm::outs() << YourOwnOption.getValue();<br>
  return Tool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>().get());<br>
}<br>
<br>
Thank you very much in advance!<br>
<br>
Best regards<br>
Christoph<br>
<br>
[1]<br>
<a href="http://clang.llvm.org/doxygen/classclang_1_1tooling_1_1CommonOptionsParser.html" target="_blank">http://clang.llvm.org/doxygen/classclang_1_1tooling_1_1CommonOptionsParser.html</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>
</blockquote></div><br></div>