[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / tools / clang-refactor / ToolRefactoringResultConsumer.h
blobb69f9d673fb6b69c38640718895146e550d1b7b2
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
10 #define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H
12 #include "clang/AST/ASTContext.h"
13 #include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
15 namespace clang {
16 namespace refactor {
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 void beginTU(ASTContext &Context) {
25 assert(!Diags && "Diags has been set");
26 Diags = &Context.getDiagnostics();
29 /// Called when the tool is done with a TU.
30 void endTU() {
31 assert(Diags && "Diags unset");
32 Diags = nullptr;
35 DiagnosticsEngine &getDiags() const {
36 assert(Diags && "no diags");
37 return *Diags;
40 private:
41 DiagnosticsEngine *Diags = nullptr;
44 } // end namespace refactor
45 } // end namespace clang
47 #endif // LLVM_CLANG_TOOLS_CLANG_REFACTOR_TOOL_REFACTORING_RESULT_CONSUMER_H