/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/tools/diagtool/DiagTool.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- DiagTool.h - Classes for defining diagtool tools -------------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // |
9 | | // This file implements the boilerplate for defining diagtool tools. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_CLANG_TOOLS_DIAGTOOL_DIAGTOOL_H |
14 | | #define LLVM_CLANG_TOOLS_DIAGTOOL_DIAGTOOL_H |
15 | | |
16 | | #include "llvm/ADT/StringRef.h" |
17 | | #include "llvm/Support/ManagedStatic.h" |
18 | | #include "llvm/Support/raw_ostream.h" |
19 | | #include <string> |
20 | | |
21 | | |
22 | | namespace diagtool { |
23 | | |
24 | | class DiagTool { |
25 | | const std::string cmd; |
26 | | const std::string description; |
27 | | public: |
28 | | DiagTool(llvm::StringRef toolCmd, llvm::StringRef toolDesc); |
29 | | virtual ~DiagTool(); |
30 | | |
31 | 92 | llvm::StringRef getName() const { return cmd; } |
32 | 0 | llvm::StringRef getDescription() const { return description; } |
33 | | |
34 | | virtual int run(unsigned argc, char *argv[], llvm::raw_ostream &out) = 0; |
35 | | }; |
36 | | |
37 | | class DiagTools { |
38 | | void *tools; |
39 | | public: |
40 | | DiagTools(); |
41 | | ~DiagTools(); |
42 | | |
43 | | DiagTool *getTool(llvm::StringRef toolCmd); |
44 | | void registerTool(DiagTool *tool); |
45 | | void printCommands(llvm::raw_ostream &out); |
46 | | }; |
47 | | |
48 | | extern llvm::ManagedStatic<DiagTools> diagTools; |
49 | | |
50 | | template <typename DIAGTOOL> |
51 | | class RegisterDiagTool { |
52 | | public: |
53 | 92 | RegisterDiagTool() { diagTools->registerTool(new DIAGTOOL()); } FindDiagnosticID.cpp:diagtool::RegisterDiagTool<(anonymous namespace)::FindDiagnosticID>::RegisterDiagTool() Line | Count | Source | 53 | 23 | RegisterDiagTool() { diagTools->registerTool(new DIAGTOOL()); } |
ListWarnings.cpp:diagtool::RegisterDiagTool<(anonymous namespace)::ListWarnings>::RegisterDiagTool() Line | Count | Source | 53 | 23 | RegisterDiagTool() { diagTools->registerTool(new DIAGTOOL()); } |
ShowEnabledWarnings.cpp:diagtool::RegisterDiagTool<(anonymous namespace)::ShowEnabledWarnings>::RegisterDiagTool() Line | Count | Source | 53 | 23 | RegisterDiagTool() { diagTools->registerTool(new DIAGTOOL()); } |
TreeView.cpp:diagtool::RegisterDiagTool<(anonymous namespace)::TreeView>::RegisterDiagTool() Line | Count | Source | 53 | 23 | RegisterDiagTool() { diagTools->registerTool(new DIAGTOOL()); } |
|
54 | | }; |
55 | | |
56 | | } // end diagtool namespace |
57 | | |
58 | | #define DEF_DIAGTOOL(NAME, DESC, CLSNAME)\ |
59 | | namespace {\ |
60 | | class CLSNAME : public diagtool::DiagTool {\ |
61 | | public:\ |
62 | 92 | CLSNAME() : DiagTool(NAME, DESC) {}\ FindDiagnosticID.cpp:(anonymous namespace)::FindDiagnosticID::FindDiagnosticID() Line | Count | Source | 62 | 23 | CLSNAME() : DiagTool(NAME, DESC) {}\ |
ListWarnings.cpp:(anonymous namespace)::ListWarnings::ListWarnings() Line | Count | Source | 62 | 23 | CLSNAME() : DiagTool(NAME, DESC) {}\ |
ShowEnabledWarnings.cpp:(anonymous namespace)::ShowEnabledWarnings::ShowEnabledWarnings() Line | Count | Source | 62 | 23 | CLSNAME() : DiagTool(NAME, DESC) {}\ |
TreeView.cpp:(anonymous namespace)::TreeView::TreeView() Line | Count | Source | 62 | 23 | CLSNAME() : DiagTool(NAME, DESC) {}\ |
|
63 | 0 | virtual ~CLSNAME() {}\ Unexecuted instantiation: FindDiagnosticID.cpp:(anonymous namespace)::FindDiagnosticID::~FindDiagnosticID() Unexecuted instantiation: ListWarnings.cpp:(anonymous namespace)::ListWarnings::~ListWarnings() Unexecuted instantiation: ShowEnabledWarnings.cpp:(anonymous namespace)::ShowEnabledWarnings::~ShowEnabledWarnings() Unexecuted instantiation: TreeView.cpp:(anonymous namespace)::TreeView::~TreeView() |
64 | | int run(unsigned argc, char *argv[], llvm::raw_ostream &out) override;\ |
65 | | };\ |
66 | | diagtool::RegisterDiagTool<CLSNAME> Register##CLSNAME;\ |
67 | | } |
68 | | |
69 | | #endif |