Skip to content

Instantly share code, notes, and snippets.

@chichunchen
Last active April 20, 2019 03:09
Show Gist options
  • Select an option

  • Save chichunchen/32838bcf7a53b69c5ff8a03a06b54ae4 to your computer and use it in GitHub Desktop.

Select an option

Save chichunchen/32838bcf7a53b69c5ff8a03a06b54ae4 to your computer and use it in GitHub Desktop.
namespace {
llvm::cl::OptionCategory UseOverrideCategory("Use override options");
llvm::cl::extrahelp UseOverrideCategoryHelp(R"(
This tool ensures that you use the 'override' keyword appropriately.
For example, given this snippet of code:
struct Base {
virtual void method(int);
};
struct Derived : public Base {
void method(int);
};
Running this tool over the code will produce a warning message stating that the
declaration 'method()' should be followed by the keyword 'override'.
)");
}
auto main(int argc, const char* argv[]) -> int {
using namespace clang::tooling;
CommonOptionsParser OptionsParser(argc, argv, UseOverrideCategory);
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
auto action = newFrontendActionFactory<UseOverride::Action>();
return Tool.run(action.get());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment