diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-09-02 15:31:08 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-09-13 16:22:13 +0200 |
commit | cc9c5da74bebd877538a581bcb7af0f01dbbfeb3 (patch) | |
tree | dafb9b30d359cd178606779879dba635ba5a2ab4 /src | |
parent | b2cf7f8cf46183d0c4afb78c31d9f3279f1f85bc (diff) |
Add '-supported-checks-json' command line option
Summary:
...to dump the contents of checks.json.
This is useful for IDEs as they can find out now whether a particular
check is supported.
BUG: 409986
Differential Revision: https://phabricator.kde.org/D23680
Diffstat (limited to 'src')
-rw-r--r-- | src/ClazyStandaloneMain.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ClazyStandaloneMain.cpp b/src/ClazyStandaloneMain.cpp index b9af72d7..39af763b 100644 --- a/src/ClazyStandaloneMain.cpp +++ b/src/ClazyStandaloneMain.cpp @@ -24,12 +24,15 @@ #include "Clazy.h" #include "ClazyContext.h" +#include "checks.json.h" + #include <clang/Tooling/CommonOptionsParser.h> #include <clang/Tooling/Tooling.h> #include <llvm/Support/CommandLine.h> #include <llvm/ADT/ArrayRef.h> #include <llvm/ADT/StringRef.h> +#include <iostream> #include <string> namespace clang { @@ -72,6 +75,9 @@ static cl::opt<std::string> s_ignoreDirs("ignore-dirs", cl::desc(R"(Regular expr directories for which diagnostics should never be emitted. Useful for ignoring 3rdparty code.)"), cl::init(""), cl::cat(s_clazyCategory)); +static cl::opt<bool> s_supportedChecks("supported-checks-json", cl::desc("Dump meta information about supported checks in JSON format."), + cl::init(false), cl::cat(s_clazyCategory)); + static cl::extrahelp s_commonHelp(CommonOptionsParser::HelpMessage); class ClazyToolActionFactory @@ -116,7 +122,13 @@ public: int main(int argc, const char **argv) { - CommonOptionsParser optionsParser(argc, argv, s_clazyCategory); + CommonOptionsParser optionsParser(argc, argv, s_clazyCategory, cl::ZeroOrMore); + + if (s_supportedChecks.getValue()) { + std::cout << SUPPORTED_CHECKS_JSON_STR; + return 0; + } + ClangTool tool(optionsParser.getCompilations(), optionsParser.getSourcePathList()); return tool.run(new ClazyToolActionFactory(optionsParser.getSourcePathList())); |