LLVM  9.0.0svn
RemarkStreamer.h
Go to the documentation of this file.
1 //===- llvm/IR/RemarkStreamer.h - Remark Streamer ---------------*- 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 // This file declares the main interface for outputting remarks.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_IR_REMARKSTREAMER_H
14 #define LLVM_IR_REMARKSTREAMER_H
15 
16 #include "llvm/IR/DiagnosticInfo.h"
18 #include "llvm/Support/Error.h"
19 #include "llvm/Support/Regex.h"
22 #include <string>
23 #include <vector>
24 
25 namespace llvm {
26 /// Streamer for remarks.
28  /// The filename that the remark diagnostics are emitted to.
29  const std::string Filename;
30  /// The open raw_ostream that the remark diagnostics are emitted to.
31  raw_ostream &OS;
32  /// The regex used to filter remarks based on the passes that emit them.
33  Optional<Regex> PassFilter;
34 
35  /// The YAML streamer.
36  yaml::Output YAMLOutput;
37 
38  /// The string table containing all the unique strings used in the output.
39  /// The table will be serialized in a section to be consumed after the
40  /// compilation.
41  remarks::StringTable StrTab;
42 
43 public:
44  RemarkStreamer(StringRef Filename, raw_ostream& OS);
45  /// Return the filename that the remark diagnostics are emitted to.
46  StringRef getFilename() const { return Filename; }
47  /// Return stream that the remark diagnostics are emitted to.
48  raw_ostream &getStream() { return OS; }
49  /// Set a pass filter based on a regex \p Filter.
50  /// Returns an error if the regex is invalid.
52  /// Emit a diagnostic through the streamer.
53  void emit(const DiagnosticInfoOptimizationBase &Diag);
54  /// The string table used during emission.
55  remarks::StringTable &getStringTable() { return StrTab; }
56  const remarks::StringTable &getStringTable() const { return StrTab; }
57 };
58 } // end namespace llvm
59 
60 #endif // LLVM_IR_REMARKSTREAMER_H
Error setFilter(StringRef Filter)
Set a pass filter based on a regex Filter.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
StringRef getFilename() const
Return the filename that the remark diagnostics are emitted to.
The string table used for serializing remarks.
raw_ostream & getStream()
Return stream that the remark diagnostics are emitted to.
const remarks::StringTable & getStringTable() const
RemarkStreamer(StringRef Filename, raw_ostream &OS)
Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...
Streamer for remarks.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
remarks::StringTable & getStringTable()
The string table used during emission.
void emit(const DiagnosticInfoOptimizationBase &Diag)
Emit a diagnostic through the streamer.