diff options
Diffstat (limited to 'docs/LibASTMatchersTutorial.rst')
-rw-r--r-- | docs/LibASTMatchersTutorial.rst | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/docs/LibASTMatchersTutorial.rst b/docs/LibASTMatchersTutorial.rst index 5bd62a133649..1e88ec203c9f 100644 --- a/docs/LibASTMatchersTutorial.rst +++ b/docs/LibASTMatchersTutorial.rst @@ -137,6 +137,10 @@ documentation <LibTooling.html>`_. using namespace clang::tooling; using namespace llvm; + // Apply a custom category to all command-line options so that they are the + // only ones displayed. + static llvm::cl::OptionCategory MyToolCategory("my-tool options"); + // CommonOptionsParser declares HelpMessage with a description of the common // command-line options related to the compilation database and input files. // It's nice to have this help message in all tools. @@ -146,10 +150,10 @@ documentation <LibTooling.html>`_. static cl::extrahelp MoreHelp("\nMore help text..."); int main(int argc, const char **argv) { - CommonOptionsParser OptionsParser(argc, argv); + CommonOptionsParser OptionsParser(argc, argv, MyToolCategory); ClangTool Tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList()); - return Tool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>()); + return Tool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>().get()); } And that's it! You can compile our new tool by running ninja from the @@ -287,7 +291,7 @@ And change ``main()`` to: .. code-block:: c++ int main(int argc, const char **argv) { - CommonOptionsParser OptionsParser(argc, argv); + CommonOptionsParser OptionsParser(argc, argv, MyToolCategory); ClangTool Tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList()); @@ -295,7 +299,7 @@ And change ``main()`` to: MatchFinder Finder; Finder.addMatcher(LoopMatcher, &Printer); - return Tool.run(newFrontendActionFactory(&Finder)); + return Tool.run(newFrontendActionFactory(&Finder).get()); } Now, you should be able to recompile and run the code to discover for |