<div dir="ltr"><div>The options after the -- get passed to the clang driver.<br></div>Those generally come from the compilcation database when the tool is used.<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 21, 2015 at 6:35 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">Oh, thank you for your fast response. I actually did not came up with the idea<br>
to put my option before the --.<br>
This works, thank you!<br>
<br>
> Manasij Mukherjee <<a href="mailto:manasij7479@gmail.com">manasij7479@gmail.com</a>> hat am 21. Januar 2015 um 12:17<br>
> geschrieben:<br>
<span class="">><br>
> Hi<br>
> Your code seems to work fine, what is your clang version?<br>
> 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>
> That seems to be by design.<br>
><br>
> Examples of invocation:<br>
> $ ./bin/testtool ~/b.cpp -abc=1 -- -std=c++11<br>
> 1<br>
><br>
> $ ./bin/testtool --help<br>
> <snip><br>
> My tool options:<br>
><br>
> -abc -<br>
> <snip><br>
><br>
><br>
><br>
> On Wed, Jan 21, 2015 at 3:41 PM, Christoph Viebig (lists)<br>
</span><div><div class="h5">> <<a href="mailto:lists@christoph-viebig.de">lists@christoph-viebig.de</a> <mailto:<a href="mailto:lists@christoph-viebig.de">lists@christoph-viebig.de</a>> > wrote:<br>
> > > 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<br>
> > 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>
> ><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>
</div></div>> > <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a> <mailto:<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>
<br>
<br>
</blockquote></div><br></div>