summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ObjectYAML/COFFEmitter.cpp12
-rw-r--r--llvm/lib/ObjectYAML/ELFEmitter.cpp10
-rw-r--r--llvm/lib/ObjectYAML/MachOEmitter.cpp6
-rw-r--r--llvm/lib/ObjectYAML/MinidumpEmitter.cpp4
-rw-r--r--llvm/lib/ObjectYAML/WasmEmitter.cpp13
-rw-r--r--llvm/lib/ObjectYAML/yaml2obj.cpp15
6 files changed, 29 insertions, 31 deletions
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index d94cdbf5605..daa4f6d83db 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -592,27 +592,27 @@ static bool writeCOFF(COFFParser &CP, raw_ostream &OS) {
namespace llvm {
namespace yaml {
-int yaml2coff(llvm::COFFYAML::Object &Doc, raw_ostream &Out) {
+bool yaml2coff(llvm::COFFYAML::Object &Doc, raw_ostream &Out) {
COFFParser CP(Doc);
if (!CP.parse()) {
errs() << "yaml2obj: Failed to parse YAML file!\n";
- return 1;
+ return false;
}
if (!layoutOptionalHeader(CP)) {
errs() << "yaml2obj: Failed to layout optional header for COFF file!\n";
- return 1;
+ return false;
}
if (!layoutCOFF(CP)) {
errs() << "yaml2obj: Failed to layout COFF file!\n";
- return 1;
+ return false;
}
if (!writeCOFF(CP, Out)) {
errs() << "yaml2obj: Failed to write COFF file!\n";
- return 1;
+ return false;
}
- return 0;
+ return true;
}
} // namespace yaml
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index 72063a5dafd..6c64754f49b 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -168,7 +168,7 @@ template <class ELFT> class ELFState {
ContiguousBlobAccumulator &CBA);
ELFState(ELFYAML::Object &D);
public:
- static int writeELF(raw_ostream &OS, ELFYAML::Object &Doc);
+ static bool writeELF(raw_ostream &OS, ELFYAML::Object &Doc);
};
} // end anonymous namespace
@@ -983,7 +983,7 @@ template <class ELFT> void ELFState<ELFT>::finalizeStrings() {
}
template <class ELFT>
-int ELFState<ELFT>::writeELF(raw_ostream &OS, ELFYAML::Object &Doc) {
+bool ELFState<ELFT>::writeELF(raw_ostream &OS, ELFYAML::Object &Doc) {
ELFState<ELFT> State(Doc);
// Finalize .strtab and .dynstr sections. We do that early because want to
@@ -1010,19 +1010,19 @@ int ELFState<ELFT>::writeELF(raw_ostream &OS, ELFYAML::Object &Doc) {
State.setProgramHeaderLayout(PHeaders, SHeaders);
if (State.HasError)
- return 1;
+ return false;
State.writeELFHeader(CBA, OS);
writeArrayData(OS, makeArrayRef(PHeaders));
CBA.writeBlobToStream(OS);
writeArrayData(OS, makeArrayRef(SHeaders));
- return 0;
+ return true;
}
namespace llvm {
namespace yaml {
-int yaml2elf(llvm::ELFYAML::Object &Doc, raw_ostream &Out) {
+bool yaml2elf(llvm::ELFYAML::Object &Doc, raw_ostream &Out) {
bool IsLE = Doc.Header.Data == ELFYAML::ELF_ELFDATA(ELF::ELFDATA2LSB);
bool Is64Bit = Doc.Header.Class == ELFYAML::ELF_ELFCLASS(ELF::ELFCLASS64);
if (Is64Bit) {
diff --git a/llvm/lib/ObjectYAML/MachOEmitter.cpp b/llvm/lib/ObjectYAML/MachOEmitter.cpp
index 47d7667787b..621b9b2617d 100644
--- a/llvm/lib/ObjectYAML/MachOEmitter.cpp
+++ b/llvm/lib/ObjectYAML/MachOEmitter.cpp
@@ -596,13 +596,13 @@ void UniversalWriter::ZeroToOffset(raw_ostream &OS, size_t Offset) {
namespace llvm {
namespace yaml {
-int yaml2macho(YamlObjectFile &Doc, raw_ostream &Out) {
+bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out) {
UniversalWriter Writer(Doc);
if (auto Err = Writer.writeMachO(Out)) {
errs() << toString(std::move(Err));
- return 1;
+ return false;
}
- return 0;
+ return true;
}
} // namespace yaml
diff --git a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
index e02a01fe54d..cc28f96a44a 100644
--- a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
+++ b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
@@ -198,7 +198,7 @@ static Directory layout(BlobAllocator &File, Stream &S) {
namespace llvm {
namespace yaml {
-int yaml2minidump(MinidumpYAML::Object &Obj, raw_ostream &Out) {
+bool yaml2minidump(MinidumpYAML::Object &Obj, raw_ostream &Out) {
BlobAllocator File;
File.allocateObject(Obj.Header);
@@ -211,7 +211,7 @@ int yaml2minidump(MinidumpYAML::Object &Obj, raw_ostream &Out) {
StreamDirectory[Stream.index()] = layout(File, *Stream.value());
File.writeTo(Out);
- return 0;
+ return true;
}
} // namespace yaml
diff --git a/llvm/lib/ObjectYAML/WasmEmitter.cpp b/llvm/lib/ObjectYAML/WasmEmitter.cpp
index 5769d7b8959..28d469ccb97 100644
--- a/llvm/lib/ObjectYAML/WasmEmitter.cpp
+++ b/llvm/lib/ObjectYAML/WasmEmitter.cpp
@@ -26,7 +26,7 @@ namespace {
class WasmWriter {
public:
WasmWriter(WasmYAML::Object &Obj) : Obj(Obj) {}
- int writeWasm(raw_ostream &OS);
+ bool writeWasm(raw_ostream &OS);
private:
int writeRelocSection(raw_ostream &OS, WasmYAML::Section &Sec,
@@ -563,7 +563,7 @@ int WasmWriter::writeRelocSection(raw_ostream &OS, WasmYAML::Section &Sec,
return 0;
}
-int WasmWriter::writeWasm(raw_ostream &OS) {
+bool WasmWriter::writeWasm(raw_ostream &OS) {
// Write headers
OS.write(wasm::WasmMagic, sizeof(wasm::WasmMagic));
writeUint32(OS, Obj.Header.Version);
@@ -576,7 +576,7 @@ int WasmWriter::writeWasm(raw_ostream &OS) {
SecName = S->Name;
if (!Checker.isValidSectionOrder(Sec->Type, SecName)) {
errs() << "Out of order section type: " << Sec->Type << "\n";
- return 1;
+ return false;
}
encodeULEB128(Sec->Type, OS);
std::string OutString;
@@ -625,7 +625,7 @@ int WasmWriter::writeWasm(raw_ostream &OS) {
return Err;
} else {
errs() << "Unknown section type: " << Sec->Type << "\n";
- return 1;
+ return false;
}
StringStream.flush();
@@ -652,15 +652,14 @@ int WasmWriter::writeWasm(raw_ostream &OS) {
OS << OutString;
}
- return 0;
+ return true;
}
namespace llvm {
namespace yaml {
-int yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out) {
+bool yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out) {
WasmWriter Writer(Doc);
-
return Writer.writeWasm(Out);
}
diff --git a/llvm/lib/ObjectYAML/yaml2obj.cpp b/llvm/lib/ObjectYAML/yaml2obj.cpp
index f9bcba68c84..8ca490bf9ca 100644
--- a/llvm/lib/ObjectYAML/yaml2obj.cpp
+++ b/llvm/lib/ObjectYAML/yaml2obj.cpp
@@ -17,9 +17,8 @@ namespace llvm {
namespace yaml {
Error convertYAML(yaml::Input &YIn, raw_ostream &Out, unsigned DocNum) {
- // TODO: make yaml2* functions return Error instead of int.
- auto IntToErr = [](int Ret) -> Error {
- if (Ret)
+ auto BoolToErr = [](bool Ret) -> Error {
+ if (!Ret)
return createStringError(errc::invalid_argument, "yaml2obj failed");
return Error::success();
};
@@ -32,15 +31,15 @@ Error convertYAML(yaml::Input &YIn, raw_ostream &Out, unsigned DocNum) {
if (std::error_code EC = YIn.error())
return createStringError(EC, "Failed to parse YAML input!");
if (Doc.Elf)
- return IntToErr(yaml2elf(*Doc.Elf, Out));
+ return BoolToErr(yaml2elf(*Doc.Elf, Out));
if (Doc.Coff)
- return IntToErr(yaml2coff(*Doc.Coff, Out));
+ return BoolToErr(yaml2coff(*Doc.Coff, Out));
if (Doc.MachO || Doc.FatMachO)
- return IntToErr(yaml2macho(Doc, Out));
+ return BoolToErr(yaml2macho(Doc, Out));
if (Doc.Minidump)
- return IntToErr(yaml2minidump(*Doc.Minidump, Out));
+ return BoolToErr(yaml2minidump(*Doc.Minidump, Out));
if (Doc.Wasm)
- return IntToErr(yaml2wasm(*Doc.Wasm, Out));
+ return BoolToErr(yaml2wasm(*Doc.Wasm, Out));
return createStringError(errc::invalid_argument,
"Unknown document type!");
}
OpenPOWER on IntegriCloud