<div dir="ltr">I'm writing a program that uses ClangTool to parrse C++ code; per the tutorials, the main module looks as below.<br><br>It works for a single file, but more complex inputs require the usual commandline options to set include path, Microsoft compatibility mode et cetera, and by default you only get a few options like -help and -version.<br><br>How do you get the usual set of commandline options that clang has?<br><br>// Apply a custom category to all command-line options so that they are the<br>// only ones displayed.<br>static cl::OptionCategory MyToolCategory("my-tool options");<br><br>// CommonOptionsParser declares HelpMessage with a description of the common<br>// command-line options related to the compilation database and input files.<br>// It's nice to have this help message in all tools.<br>static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);<br><br>int main(int argc, const char **argv) {<br>  std::set_new_handler([]() {<br>    errs() << "new: " << strerror(errno) << '\n';<br>    exit(1);<br>  });<br><br>  sys::PrintStackTraceOnErrorSignal();<br>  PrettyStackTraceProgram X(argc, argv);<br><br>#ifdef _WIN32<br>  // Stack overflow<br>  AddVectoredExceptionHandler(0, handler);<br>#endif<br><br>  CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);<br>  ClangTool Tool(OptionsParser.getCompilations(),<br>                 OptionsParser.getSourcePathList());<br>  return Tool.run(newFrontendActionFactory<MainAction>().get());<br>}<br><br></div>