diff --git a/llvm/include/llvm/BinaryFormat/GOFF.h b/llvm/include/llvm/BinaryFormat/GOFF.h --- a/llvm/include/llvm/BinaryFormat/GOFF.h +++ b/llvm/include/llvm/BinaryFormat/GOFF.h @@ -27,7 +27,7 @@ namespace GOFF { -const uint8_t RecordLength = 80; +constexpr uint8_t RecordLength = 80; /// \brief Maximum data length before starting a new card for RLD and TXT data. /// @@ -238,4 +238,4 @@ } // end namespace llvm -#endif // LLVM_BINARYFORMAT_GOFF_H +#endif // LLVM_BINARYFORMAT_GOFF_H diff --git a/llvm/include/llvm/Object/GOFF.h b/llvm/include/llvm/Object/GOFF.h --- a/llvm/include/llvm/Object/GOFF.h +++ b/llvm/include/llvm/Object/GOFF.h @@ -185,9 +185,8 @@ uint8_t Length) { assert(Length <= TXTMaxDataLength && "Data too long for TXT Record"); - for (int I = 0; I < Length; ++I) { + for (int I = 0; I < Length; ++I) set8(24 + I, Data[I]); - } } // Get routines @@ -232,21 +231,13 @@ void setNameSpaceId(GOFF::ESDNameSpaceId Id) { set8(40, Id); } - void setFillBytePresent(bool Present) { - setBits(41, 0, 1, Present); - } + void setFillBytePresent(bool Present) { setBits(41, 0, 1, Present); } - void setNameMangled(bool Mangled) { - setBits(41, 1, 1, Mangled); - } + void setNameMangled(bool Mangled) { setBits(41, 1, 1, Mangled); } - void setRenamable(bool Renamable) { - setBits(41, 2, 1, Renamable); - } + void setRenamable(bool Renamable) { setBits(41, 2, 1, Renamable); } - void setRemovable(bool Removable) { - setBits(41, 3, 1, Removable); - } + void setRemovable(bool Removable) { setBits(41, 3, 1, Removable); } void setReserveQwords(GOFF::ESDReserveQwords Reserve) { setBits(41, 5, 3, Reserve); @@ -316,9 +307,8 @@ void setName(const StringRef::const_iterator &Data, uint8_t Length) { assert(Length <= ESDMaxNameLength && "Data too long for ESD Record"); - for (int I = 0; I < Length; ++I) { + for (int I = 0; I < Length; ++I) set8(72 + I, Data[I]); - } } // ESD Get routines @@ -547,9 +537,8 @@ assert(Length <= ContinuationMaxDataLength && "Data too long for Continuation Record"); - for (int I = 0; I < Length; ++I) { + for (int I = 0; I < Length; ++I) set8(3 + I, Data[I]); - } } }; diff --git a/llvm/include/llvm/Object/GOFFObjectFile.h b/llvm/include/llvm/Object/GOFFObjectFile.h --- a/llvm/include/llvm/Object/GOFFObjectFile.h +++ b/llvm/include/llvm/Object/GOFFObjectFile.h @@ -23,7 +23,7 @@ #include "llvm/Object/ObjectFile.h" #include "llvm/Support/CharSet.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/Endian.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/raw_ostream.h" namespace llvm { @@ -118,7 +118,7 @@ uint64_t OOffset; //// === fields when processing relocations for manufactured function - ///descriptor section + /// descriptor section uint32_t FunctionDescriptorIndex; bool DoingFuncSymb; } RelocationIteratorState_t; diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp --- a/llvm/lib/Object/Binary.cpp +++ b/llvm/lib/Object/Binary.cpp @@ -67,8 +67,8 @@ case file_magic::macho_dsym_companion: case file_magic::macho_kext_bundle: case file_magic::coff_object: - case file_magic::goff_object: case file_magic::coff_import_library: + case file_magic::goff_object: case file_magic::pecoff_executable: case file_magic::bitcode: case file_magic::xcoff_object_32: diff --git a/llvm/lib/Object/GOFFObjectFile.cpp b/llvm/lib/Object/GOFFObjectFile.cpp --- a/llvm/lib/Object/GOFFObjectFile.cpp +++ b/llvm/lib/Object/GOFFObjectFile.cpp @@ -170,7 +170,8 @@ uint16_t Continuations = 0; while (true) { // Is the record continued in the next record - const char *ContinuationByte = Record + (Continuations * GOFF::RecordLength) + 1; + const char *ContinuationByte = + Record + (Continuations * GOFF::RecordLength) + 1; bool IsContinued = *ContinuationByte & 0x01; if (IsContinued) @@ -233,9 +234,8 @@ if (SymbolType == GOFF::ESD_ST_PartReference) { uint32_t Length; ESDRecord::getLength(Record, Length); - if (Length == 0) { + if (Length == 0) return true; - } } return false; } @@ -256,9 +256,8 @@ GOFF::ESDBindingStrength BindingStrength; ESDRecord::getBindingStrength(Record, BindingStrength); - if (BindingStrength == GOFF::ESD_BST_Weak) { + if (BindingStrength == GOFF::ESD_BST_Weak) Flags |= SymbolRef::SF_Weak; - } GOFF::ESDBindingScope BindingScope; ESDRecord::getBindingScope(Record, BindingScope); @@ -358,9 +357,8 @@ const uint8_t *GOFFObjectFile::getSectionPrEsdRecord(DataRefImpl &Sec) const { SectionEntryImpl EsdIds = SectionList[Sec.d.a]; const uint8_t *EsdRecord = NULL; - if (EsdIds.d.b) { + if (EsdIds.d.b) EsdRecord = reinterpret_cast(EsdPtrs[EsdIds.d.b]); - } return EsdRecord; } const uint8_t * @@ -607,9 +605,8 @@ // RelocationRef void GOFFObjectFile::getRelocationData() { - if (RelocationData.size()) { + if (RelocationData.size()) return; - } // Calculate total length of relocation items from all records uint32_t RelocationDataSize = 0; @@ -648,9 +645,8 @@ void GOFFObjectFile::moveRelocationNext(DataRefImpl &Rel) const { RelocationIteratorState_t *RIS = (RelocationIteratorState_t *)Rel.p; - if (!RIS) { + if (!RIS) return; - } #define F_SAME_R_ID 0x80 #define F_SAME_P_ID 0x40 @@ -693,9 +689,8 @@ CurrOffset += 4; } } - if (Flags0 & F_EXT_ATTR_PRESENT) { + if (Flags0 & F_EXT_ATTR_PRESENT) CurrOffset += 8; - } RIS->CurrentRldSize = CurrOffset; @@ -710,9 +705,9 @@ (Rld[4] << 24) + (Rld[5] << 16) + (Rld[1] << 8) + Rld[2]; // Note: we encode indirect, weak, and code address flags in the high // word of RelocationType. -#define RLD_INDIRECT_FLAG 0x400000000 +#define RLD_INDIRECT_FLAG 0x400000000 #define RLD_CODE_ADDR_FLAG 0x200000000 -#define RLD_WEAK_FLAG 0x100000000 +#define RLD_WEAK_FLAG 0x100000000 if (isSymbolIndirect(RIS->RefSymb)) { RIS->RelocationType |= RLD_INDIRECT_FLAG; } else if (getRLDReferenceType(RIS->RelocationType) != @@ -731,9 +726,8 @@ } } uint32_t Flags = cantFail(getSymbolFlags(RIS->RefSymb)); - if (Flags & SymbolRef::SF_Weak) { + if (Flags & SymbolRef::SF_Weak) RIS->RelocationType |= RLD_WEAK_FLAG; - } return; } } @@ -754,20 +748,19 @@ symbol_iterator GOFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const { RelocationIteratorState_t *RIS = (RelocationIteratorState_t *)Rel.p; - if (!RIS) { + if (!RIS) llvm_unreachable("invalid call to getRelocationSymbol"); - } return basic_symbol_iterator(SymbolRef(RIS->RefSymb, this)); } uint64_t GOFFObjectFile::getRelocationType(DataRefImpl Rel) const { RelocationIteratorState_t *RIS = (RelocationIteratorState_t *)Rel.p; uint64_t RelocationType = 0; - if (RIS) { + if (RIS) RelocationType = RIS->RelocationType; - } else { + else llvm_unreachable("invalid call to getRelocationType"); - } + return RelocationType; } diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -18,15 +18,15 @@ #include "llvm-objdump.h" #include "COFFDump.h" #include "ELFDump.h" -#include "MachODump.h" #include "GOFFDump.h" +#include "MachODump.h" #include "WasmDump.h" #include "XCOFFDump.h" #include "llvm/ADT/IndexedMap.h" #include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SetOperations.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" #include "llvm/ADT/Triple.h" diff --git a/llvm/tools/llvm-readobj/GOFFDumper.cpp b/llvm/tools/llvm-readobj/GOFFDumper.cpp --- a/llvm/tools/llvm-readobj/GOFFDumper.cpp +++ b/llvm/tools/llvm-readobj/GOFFDumper.cpp @@ -34,11 +34,10 @@ namespace llvm { std::unique_ptr createGOFFDumper(const object::GOFFObjectFile &Obj, - ScopedPrinter &Writer) { + ScopedPrinter &Writer) { return std::make_unique(&Obj, Writer); } - } // namespace llvm void GOFFDumper::printSymbol(const SymbolRef &Symbol) {