LLVM  14.0.0git
RemarkStreamer.cpp
Go to the documentation of this file.
1 //===- llvm/Remarks/RemarkStreamer.cpp - 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 contains the implementation of the main remark streamer.
10 //
11 //===----------------------------------------------------------------------===//
12 
15 
16 using namespace llvm;
17 using namespace llvm::remarks;
18 
20  "remarks-section",
21  cl::desc(
22  "Emit a section containing remark diagnostics metadata. By default, "
23  "this is enabled for the following formats: yaml-strtab, bitstream."),
25 
27  std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer,
28  Optional<StringRef> FilenameIn)
29  : PassFilter(), RemarkSerializer(std::move(RemarkSerializer)),
30  Filename(FilenameIn ? Optional<std::string>(FilenameIn->str()) : None) {}
31 
33  Regex R = Regex(Filter);
34  std::string RegexError;
35  if (!R.isValid(RegexError))
36  return createStringError(std::make_error_code(std::errc::invalid_argument),
37  RegexError.data());
38  PassFilter = std::move(R);
39  return Error::success();
40 }
41 
43  if (PassFilter)
44  return PassFilter->match(Str);
45  // No filter means all strings pass.
46  return true;
47 }
48 
51  return true;
52 
54  return false;
55 
57 
58  // We only need a section if we're in separate mode.
60  return false;
61 
62  // Only some formats need a section:
63  // * bitstream
64  // * yaml-strtab
68  return true;
69  default:
70  return false;
71  }
72 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::remarks::Format::Bitstream
@ Bitstream
llvm::cl::BOU_FALSE
@ BOU_FALSE
Definition: CommandLine.h:625
llvm::remarks::SerializerMode::Separate
@ Separate
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::Optional
Definition: APInt.h:33
llvm::remarks::RemarkSerializer::SerializerFormat
Format SerializerFormat
The format of the serializer.
Definition: RemarkSerializer.h:40
llvm::remarks::RemarkStreamer::RemarkStreamer
RemarkStreamer(std::unique_ptr< remarks::RemarkSerializer > RemarkSerializer, Optional< StringRef > Filename=None)
Definition: RemarkStreamer.cpp:26
llvm::remarks::RemarkSerializer::Mode
SerializerMode Mode
The serialization mode.
Definition: RemarkSerializer.h:44
CommandLine.h
llvm::remarks::RemarkStreamer::needsSection
bool needsSection() const
Check if the remarks also need to have associated metadata in a section.
Definition: RemarkStreamer.cpp:49
llvm::None
const NoneType None
Definition: None.h:23
llvm::remarks::RemarkSerializer
This is the base class for a remark serializer.
Definition: RemarkSerializer.h:38
llvm::remarks
Definition: AsmPrinter.h:77
llvm::cl::opt
Definition: CommandLine.h:1434
llvm::ClrHandlerType::Filter
@ Filter
llvm::cl::BOU_UNSET
@ BOU_UNSET
Definition: CommandLine.h:625
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
llvm::remarks::Format::YAMLStrTab
@ YAMLStrTab
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1605
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::remarks::RemarkStreamer::setFilter
Error setFilter(StringRef Filter)
Set a pass filter based on a regex Filter.
Definition: RemarkStreamer.cpp:32
llvm::make_error_code
std::error_code make_error_code(BitcodeError E)
Definition: BitcodeReader.h:270
llvm::remarks::RemarkStreamer::matchesFilter
bool matchesFilter(StringRef Str)
Check wether the string matches the filter.
Definition: RemarkStreamer.cpp:42
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1231
std
Definition: BitVector.h:838
EnableRemarksSection
static cl::opt< cl::boolOrDefault > EnableRemarksSection("remarks-section", cl::desc("Emit a section containing remark diagnostics metadata. By default, " "this is enabled for the following formats: yaml-strtab, bitstream."), cl::init(cl::BOU_UNSET), cl::Hidden)
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
RemarkStreamer.h
llvm::cl::BOU_TRUE
@ BOU_TRUE
Definition: CommandLine.h:625
llvm::cl::desc
Definition: CommandLine.h:414
llvm::Regex
Definition: Regex.h:28
SpecialSubKind::string
@ string