[llvm] r366939 - [Remarks][NFC] Rename remarks::Serializer to remarks::RemarkSerializer
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 12:47:57 PDT 2019
Author: thegameg
Date: Wed Jul 24 12:47:57 2019
New Revision: 366939
URL: http://llvm.org/viewvc/llvm-project?rev=366939&view=rev
Log:
[Remarks][NFC] Rename remarks::Serializer to remarks::RemarkSerializer
Modified:
llvm/trunk/include/llvm/IR/RemarkStreamer.h
llvm/trunk/include/llvm/Remarks/RemarkSerializer.h
llvm/trunk/include/llvm/Remarks/YAMLRemarkSerializer.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/IR/RemarkStreamer.cpp
llvm/trunk/lib/Remarks/RemarkSerializer.cpp
llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp
llvm/trunk/unittests/Remarks/YAMLRemarksSerializerTest.cpp
Modified: llvm/trunk/include/llvm/IR/RemarkStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/RemarkStreamer.h?rev=366939&r1=366938&r2=366939&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/RemarkStreamer.h (original)
+++ llvm/trunk/include/llvm/IR/RemarkStreamer.h Wed Jul 24 12:47:57 2019
@@ -30,7 +30,7 @@ class RemarkStreamer {
/// The regex used to filter remarks based on the passes that emit them.
Optional<Regex> PassFilter;
/// The object used to serialize the remarks to a specific format.
- std::unique_ptr<remarks::Serializer> Serializer;
+ std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer;
/// Convert diagnostics into remark objects.
/// The lifetime of the members of the result is bound to the lifetime of
@@ -39,13 +39,13 @@ class RemarkStreamer {
public:
RemarkStreamer(StringRef Filename,
- std::unique_ptr<remarks::Serializer> Serializer);
+ std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer);
/// Return the filename that the remark diagnostics are emitted to.
StringRef getFilename() const { return Filename; }
/// Return stream that the remark diagnostics are emitted to.
- raw_ostream &getStream() { return Serializer->OS; }
+ raw_ostream &getStream() { return RemarkSerializer->OS; }
/// Return the serializer used for this stream.
- remarks::Serializer &getSerializer() { return *Serializer; }
+ remarks::RemarkSerializer &getSerializer() { return *RemarkSerializer; }
/// Set a pass filter based on a regex \p Filter.
/// Returns an error if the regex is invalid.
Error setFilter(StringRef Filter);
Modified: llvm/trunk/include/llvm/Remarks/RemarkSerializer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Remarks/RemarkSerializer.h?rev=366939&r1=366938&r2=366939&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Remarks/RemarkSerializer.h (original)
+++ llvm/trunk/include/llvm/Remarks/RemarkSerializer.h Wed Jul 24 12:47:57 2019
@@ -22,26 +22,26 @@ namespace remarks {
/// This is the base class for a remark serializer.
/// It includes support for using a string table while emitting.
-struct Serializer {
+struct RemarkSerializer {
/// The open raw_ostream that the remark diagnostics are emitted to.
raw_ostream &OS;
/// The string table containing all the unique strings used in the output.
/// The table can be serialized to be consumed after the compilation.
Optional<StringTable> StrTab;
- Serializer(raw_ostream &OS) : OS(OS), StrTab() {}
+ RemarkSerializer(raw_ostream &OS) : OS(OS), StrTab() {}
/// This is just an interface.
- virtual ~Serializer() = default;
+ virtual ~RemarkSerializer() = default;
virtual void emit(const Remark &Remark) = 0;
};
/// Create a remark serializer.
-Expected<std::unique_ptr<Serializer>>
+Expected<std::unique_ptr<RemarkSerializer>>
createRemarkSerializer(Format RemarksFormat, raw_ostream &OS);
/// Create a remark serializer that uses a pre-filled string table.
-Expected<std::unique_ptr<Serializer>>
+Expected<std::unique_ptr<RemarkSerializer>>
createRemarkSerializer(Format RemarksFormat, raw_ostream &OS,
remarks::StringTable StrTab);
Modified: llvm/trunk/include/llvm/Remarks/YAMLRemarkSerializer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Remarks/YAMLRemarkSerializer.h?rev=366939&r1=366938&r2=366939&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Remarks/YAMLRemarkSerializer.h (original)
+++ llvm/trunk/include/llvm/Remarks/YAMLRemarkSerializer.h Wed Jul 24 12:47:57 2019
@@ -30,11 +30,11 @@ namespace remarks {
/// - <KEY>: <VALUE>
/// DebugLoc: { File: <FILE>, Line: <LINE>, Column: <COL> }
/// ...
-struct YAMLSerializer : public Serializer {
+struct YAMLRemarkSerializer : public RemarkSerializer {
/// The YAML streamer.
yaml::Output YAMLOutput;
- YAMLSerializer(raw_ostream &OS);
+ YAMLRemarkSerializer(raw_ostream &OS);
/// Emit a remark to the stream.
void emit(const Remark &Remark) override;
@@ -43,13 +43,13 @@ struct YAMLSerializer : public Serialize
/// Serialize the remarks to YAML using a string table. An remark entry looks
/// like the regular YAML remark but instead of string entries it's using
/// numbers that map to an index in the string table.
-struct YAMLStrTabSerializer : public YAMLSerializer {
- YAMLStrTabSerializer(raw_ostream &OS) : YAMLSerializer(OS) {
+struct YAMLStrTabRemarkSerializer : public YAMLRemarkSerializer {
+ YAMLStrTabRemarkSerializer(raw_ostream &OS) : YAMLRemarkSerializer(OS) {
// Having a string table set up enables the serializer to use it.
StrTab.emplace();
}
- YAMLStrTabSerializer(raw_ostream &OS, StringTable StrTabIn)
- : YAMLSerializer(OS) {
+ YAMLStrTabRemarkSerializer(raw_ostream &OS, StringTable StrTabIn)
+ : YAMLRemarkSerializer(OS) {
StrTab = std::move(StrTabIn);
}
};
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=366939&r1=366938&r2=366939&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Jul 24 12:47:57 2019
@@ -1349,7 +1349,7 @@ void AsmPrinter::emitRemarksSection(Modu
RemarkStreamer *RS = M.getContext().getRemarkStreamer();
if (!RS)
return;
- const remarks::Serializer &Serializer = RS->getSerializer();
+ const remarks::RemarkSerializer &RemarkSerializer = RS->getSerializer();
// Switch to the right section: .remarks/__remarks.
MCSection *RemarksSection =
@@ -1372,7 +1372,7 @@ void AsmPrinter::emitRemarksSection(Modu
// just use the serialize function with a raw_ostream because of the way
// MCStreamers work.
uint64_t StrTabSize =
- Serializer.StrTab ? Serializer.StrTab->SerializedSize : 0;
+ RemarkSerializer.StrTab ? RemarkSerializer.StrTab->SerializedSize : 0;
// Emit the total size of the string table (the size itself excluded):
// little-endian uint64_t.
// The total size is located after the version number.
@@ -1382,7 +1382,7 @@ void AsmPrinter::emitRemarksSection(Modu
OutStreamer->EmitBinaryData(
StringRef(StrTabSizeBuf.data(), StrTabSizeBuf.size()));
- if (const Optional<remarks::StringTable> &StrTab = Serializer.StrTab) {
+ if (const Optional<remarks::StringTable> &StrTab = RemarkSerializer.StrTab) {
std::vector<StringRef> StrTabStrings = StrTab->serialize();
// Emit a list of null-terminated strings.
// Note: the order is important here: the ID used in the remarks corresponds
Modified: llvm/trunk/lib/IR/RemarkStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/RemarkStreamer.cpp?rev=366939&r1=366938&r2=366939&view=diff
==============================================================================
--- llvm/trunk/lib/IR/RemarkStreamer.cpp (original)
+++ llvm/trunk/lib/IR/RemarkStreamer.cpp Wed Jul 24 12:47:57 2019
@@ -20,9 +20,11 @@
using namespace llvm;
-RemarkStreamer::RemarkStreamer(StringRef Filename,
- std::unique_ptr<remarks::Serializer> Serializer)
- : Filename(Filename), PassFilter(), Serializer(std::move(Serializer)) {
+RemarkStreamer::RemarkStreamer(
+ StringRef Filename,
+ std::unique_ptr<remarks::RemarkSerializer> RemarkSerializer)
+ : Filename(Filename), PassFilter(),
+ RemarkSerializer(std::move(RemarkSerializer)) {
assert(!Filename.empty() && "This needs to be a real filename.");
}
@@ -100,7 +102,7 @@ void RemarkStreamer::emit(const Diagnost
// First, convert the diagnostic to a remark.
remarks::Remark R = toRemark(Diag);
// Then, emit the remark through the serializer.
- Serializer->emit(R);
+ RemarkSerializer->emit(R);
}
char RemarkSetupFileError::ID = 0;
@@ -133,13 +135,13 @@ llvm::setupOptimizationRemarks(LLVMConte
if (Error E = Format.takeError())
return make_error<RemarkSetupFormatError>(std::move(E));
- Expected<std::unique_ptr<remarks::Serializer>> Serializer =
+ Expected<std::unique_ptr<remarks::RemarkSerializer>> RemarkSerializer =
remarks::createRemarkSerializer(*Format, RemarksFile->os());
- if (Error E = Serializer.takeError())
+ if (Error E = RemarkSerializer.takeError())
return make_error<RemarkSetupFormatError>(std::move(E));
Context.setRemarkStreamer(llvm::make_unique<RemarkStreamer>(
- RemarksFilename, std::move(*Serializer)));
+ RemarksFilename, std::move(*RemarkSerializer)));
if (!RemarksPasses.empty())
if (Error E = Context.getRemarkStreamer()->setFilter(RemarksPasses))
Modified: llvm/trunk/lib/Remarks/RemarkSerializer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Remarks/RemarkSerializer.cpp?rev=366939&r1=366938&r2=366939&view=diff
==============================================================================
--- llvm/trunk/lib/Remarks/RemarkSerializer.cpp (original)
+++ llvm/trunk/lib/Remarks/RemarkSerializer.cpp Wed Jul 24 12:47:57 2019
@@ -16,21 +16,21 @@
using namespace llvm;
using namespace llvm::remarks;
-Expected<std::unique_ptr<Serializer>>
+Expected<std::unique_ptr<RemarkSerializer>>
remarks::createRemarkSerializer(Format RemarksFormat, raw_ostream &OS) {
switch (RemarksFormat) {
case Format::Unknown:
return createStringError(std::errc::invalid_argument,
"Unknown remark serializer format.");
case Format::YAML:
- return llvm::make_unique<YAMLSerializer>(OS);
+ return llvm::make_unique<YAMLRemarkSerializer>(OS);
case Format::YAMLStrTab:
- return llvm::make_unique<YAMLStrTabSerializer>(OS);
+ return llvm::make_unique<YAMLStrTabRemarkSerializer>(OS);
}
llvm_unreachable("Unknown remarks::Format enum");
}
-Expected<std::unique_ptr<Serializer>>
+Expected<std::unique_ptr<RemarkSerializer>>
remarks::createRemarkSerializer(Format RemarksFormat, raw_ostream &OS,
remarks::StringTable StrTab) {
switch (RemarksFormat) {
@@ -42,7 +42,7 @@ remarks::createRemarkSerializer(Format R
"Unable to use a string table with the yaml "
"format. Use 'yaml-strtab' instead.");
case Format::YAMLStrTab:
- return llvm::make_unique<YAMLStrTabSerializer>(OS, std::move(StrTab));
+ return llvm::make_unique<YAMLStrTabRemarkSerializer>(OS, std::move(StrTab));
}
llvm_unreachable("Unknown remarks::Format enum");
}
Modified: llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp?rev=366939&r1=366938&r2=366939&view=diff
==============================================================================
--- llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp (original)
+++ llvm/trunk/lib/Remarks/YAMLRemarkSerializer.cpp Wed Jul 24 12:47:57 2019
@@ -57,7 +57,7 @@ template <> struct MappingTraits<remarks
llvm_unreachable("Unknown remark type");
if (Optional<StringTable> &StrTab =
- reinterpret_cast<YAMLSerializer *>(io.getContext())->StrTab) {
+ reinterpret_cast<YAMLRemarkSerializer *>(io.getContext())->StrTab) {
unsigned PassID = StrTab->add(Remark->PassName).first;
unsigned NameID = StrTab->add(Remark->RemarkName).first;
unsigned FunctionID = StrTab->add(Remark->FunctionName).first;
@@ -79,7 +79,7 @@ template <> struct MappingTraits<RemarkL
unsigned Col = RL.SourceColumn;
if (Optional<StringTable> &StrTab =
- reinterpret_cast<YAMLSerializer *>(io.getContext())->StrTab) {
+ reinterpret_cast<YAMLRemarkSerializer *>(io.getContext())->StrTab) {
unsigned FileID = StrTab->add(File).first;
io.mapRequired("File", FileID);
} else {
@@ -131,7 +131,7 @@ template <> struct MappingTraits<Argumen
assert(io.outputting() && "input not yet implemented");
if (Optional<StringTable> &StrTab =
- reinterpret_cast<YAMLSerializer *>(io.getContext())->StrTab) {
+ reinterpret_cast<YAMLRemarkSerializer *>(io.getContext())->StrTab) {
auto ValueID = StrTab->add(A.Val).first;
io.mapRequired(A.Key.data(), ValueID);
} else if (StringRef(A.Val).count('\n') > 1) {
@@ -149,10 +149,10 @@ template <> struct MappingTraits<Argumen
LLVM_YAML_IS_SEQUENCE_VECTOR(Argument)
-YAMLSerializer::YAMLSerializer(raw_ostream &OS)
- : Serializer(OS), YAMLOutput(OS, reinterpret_cast<void *>(this)) {}
+YAMLRemarkSerializer::YAMLRemarkSerializer(raw_ostream &OS)
+ : RemarkSerializer(OS), YAMLOutput(OS, reinterpret_cast<void *>(this)) {}
-void YAMLSerializer::emit(const Remark &Remark) {
+void YAMLRemarkSerializer::emit(const Remark &Remark) {
// Again, YAMLTraits expect a non-const object for inputting, but we're not
// using that here.
auto R = const_cast<remarks::Remark *>(&Remark);
Modified: llvm/trunk/unittests/Remarks/YAMLRemarksSerializerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Remarks/YAMLRemarksSerializerTest.cpp?rev=366939&r1=366938&r2=366939&view=diff
==============================================================================
--- llvm/trunk/unittests/Remarks/YAMLRemarksSerializerTest.cpp (original)
+++ llvm/trunk/unittests/Remarks/YAMLRemarksSerializerTest.cpp Wed Jul 24 12:47:57 2019
@@ -19,7 +19,7 @@ static void check(const remarks::Remark
std::string Buf;
raw_string_ostream OS(Buf);
bool UseStrTab = ExpectedStrTab.hasValue();
- Expected<std::unique_ptr<remarks::Serializer>> MaybeS = [&] {
+ Expected<std::unique_ptr<remarks::RemarkSerializer>> MaybeS = [&] {
if (UseStrTab) {
if (StrTab)
return createRemarkSerializer(remarks::Format::YAMLStrTab, OS,
@@ -30,7 +30,7 @@ static void check(const remarks::Remark
return createRemarkSerializer(remarks::Format::YAML, OS);
}();
EXPECT_FALSE(errorToBool(MaybeS.takeError()));
- std::unique_ptr<remarks::Serializer> S = std::move(*MaybeS);
+ std::unique_ptr<remarks::RemarkSerializer> S = std::move(*MaybeS);
S->emit(R);
EXPECT_EQ(OS.str(), ExpectedR);
More information about the llvm-commits
mailing list