[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / unittests / Driver / SimpleDiagnosticConsumer.h
blobf11cccd64e379daf4d3b2abc20e3043ac3621b71
1 //===- unittests/Driver/SimpleDiagnosticConsumer.h ------------------------===//
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 // Simple diagnostic consumer to grab up diagnostics for testing.
11 //===----------------------------------------------------------------------===//
13 #ifndef CLANG_UNITTESTS_SIMPLEDIAGNOSTICCONSUMER_H
14 #define CLANG_UNITTESTS_SIMPLEDIAGNOSTICCONSUMER_H
16 #include "clang/Basic/Diagnostic.h"
17 #include "llvm/ADT/SmallString.h"
19 struct SimpleDiagnosticConsumer : public clang::DiagnosticConsumer {
20 void HandleDiagnostic(clang::DiagnosticsEngine::Level DiagLevel,
21 const clang::Diagnostic &Info) override {
22 if (DiagLevel == clang::DiagnosticsEngine::Level::Error) {
23 Errors.emplace_back();
24 Info.FormatDiagnostic(Errors.back());
25 } else {
26 Msgs.emplace_back();
27 Info.FormatDiagnostic(Msgs.back());
30 void clear() override {
31 Msgs.clear();
32 Errors.clear();
33 DiagnosticConsumer::clear();
35 std::vector<llvm::SmallString<32>> Msgs;
36 std::vector<llvm::SmallString<32>> Errors;
39 #endif // CLANG_UNITTESTS_SIMPLEDIAGNOSTICCONSUMER_H