/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/tools/clang-refactor/ToolRefactoringResultConsumer.h
Line | Count | Source |
1 | | //===--- ToolRefactoringResultConsumer.h - ----------------------*- C++ -*-===// |
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 | | #ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H |
10 | | #define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H |
11 | | |
12 | | #include "clang/AST/ASTContext.h" |
13 | | #include "clang/Tooling/Refactoring/RefactoringResultConsumer.h" |
14 | | |
15 | | namespace clang { |
16 | | namespace refactor { |
17 | | |
18 | | /// An interface that subclasses the \c RefactoringResultConsumer interface |
19 | | /// that stores the reference to the TU-specific diagnostics engine. |
20 | | class ClangRefactorToolConsumerInterface |
21 | | : public tooling::RefactoringResultConsumer { |
22 | | public: |
23 | | /// Called when a TU is entered. |
24 | 18 | void beginTU(ASTContext &Context) { |
25 | 18 | assert(!Diags && "Diags has been set"); |
26 | 18 | Diags = &Context.getDiagnostics(); |
27 | 18 | } |
28 | | |
29 | | /// Called when the tool is done with a TU. |
30 | 18 | void endTU() { |
31 | 18 | assert(Diags && "Diags unset"); |
32 | 18 | Diags = nullptr; |
33 | 18 | } |
34 | | |
35 | 24 | DiagnosticsEngine &getDiags() const { |
36 | 24 | assert(Diags && "no diags"); |
37 | 24 | return *Diags; |
38 | 24 | } |
39 | | |
40 | | private: |
41 | | DiagnosticsEngine *Diags = nullptr; |
42 | | }; |
43 | | |
44 | | } // end namespace refactor |
45 | | } // end namespace clang |
46 | | |
47 | | #endif // LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H |