1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[llvm-objcopy][MachO] Fix namespace style issues

This commit is contained in:
Fangrui Song 2021-06-23 00:31:52 -07:00
parent 1bc7c6b964
commit 66df23eddc
5 changed files with 24 additions and 46 deletions

View File

@ -11,9 +11,8 @@
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
namespace llvm {
namespace objcopy {
namespace macho {
using namespace llvm;
using namespace llvm::objcopy::macho;
StringTableBuilder::Kind
MachOLayoutBuilder::getStringTableBuilderKind(const Object &O, bool Is64Bit) {
@ -395,7 +394,3 @@ Error MachOLayoutBuilder::layout() {
Offset = layoutRelocations(Offset);
return layoutTail(Offset);
}
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm

View File

@ -21,11 +21,11 @@
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/SmallVectorMemoryBuffer.h"
namespace llvm {
namespace objcopy {
namespace macho {
using namespace llvm;
using namespace llvm::objcopy;
using namespace llvm::objcopy::macho;
using namespace llvm::object;
using namespace object;
using SectionPred = std::function<bool(const std::unique_ptr<Section> &Sec)>;
using LoadCommandPred = std::function<bool(const LoadCommand &LC)>;
@ -373,8 +373,10 @@ static Error handleArgs(const CommonConfig &Config, Object &Obj) {
return Error::success();
}
Error executeObjcopyOnBinary(const CommonConfig &Config, const MachOConfig &,
object::MachOObjectFile &In, raw_ostream &Out) {
Error objcopy::macho::executeObjcopyOnBinary(const CommonConfig &Config,
const MachOConfig &,
object::MachOObjectFile &In,
raw_ostream &Out) {
MachOReader Reader(In);
Expected<std::unique_ptr<Object>> O = Reader.create();
if (!O)
@ -402,9 +404,9 @@ Error executeObjcopyOnBinary(const CommonConfig &Config, const MachOConfig &,
return Writer.write();
}
Error executeObjcopyOnMachOUniversalBinary(const MultiFormatConfig &Config,
const MachOUniversalBinary &In,
raw_ostream &Out) {
Error objcopy::macho::executeObjcopyOnMachOUniversalBinary(
const MultiFormatConfig &Config, const MachOUniversalBinary &In,
raw_ostream &Out) {
SmallVector<OwningBinary<Binary>, 2> Binaries;
SmallVector<Slice, 2> Slices;
for (const auto &O : In.objects()) {
@ -477,7 +479,3 @@ Error executeObjcopyOnMachOUniversalBinary(const MultiFormatConfig &Config,
return Error::success();
}
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm

View File

@ -13,9 +13,9 @@
#include "llvm/Support/Errc.h"
#include <memory>
namespace llvm {
namespace objcopy {
namespace macho {
using namespace llvm;
using namespace llvm::objcopy;
using namespace llvm::objcopy::macho;
void MachOReader::readHeader(Object &O) const {
O.Header.Magic = MachOObj.getHeader().magic;
@ -28,7 +28,7 @@ void MachOReader::readHeader(Object &O) const {
}
template <typename SectionType>
Section constructSectionCommon(SectionType Sec, uint32_t Index) {
static Section constructSectionCommon(SectionType Sec, uint32_t Index) {
StringRef SegName(Sec.segname, strnlen(Sec.segname, sizeof(Sec.segname)));
StringRef SectName(Sec.sectname, strnlen(Sec.sectname, sizeof(Sec.sectname)));
Section S(SegName, SectName);
@ -60,10 +60,9 @@ template <> Section constructSection(MachO::section_64 Sec, uint32_t Index) {
}
template <typename SectionType, typename SegmentType>
Expected<std::vector<std::unique_ptr<Section>>>
extractSections(const object::MachOObjectFile::LoadCommandInfo &LoadCmd,
const object::MachOObjectFile &MachOObj,
uint32_t &NextSectionIndex) {
Expected<std::vector<std::unique_ptr<Section>>> static extractSections(
const object::MachOObjectFile::LoadCommandInfo &LoadCmd,
const object::MachOObjectFile &MachOObj, uint32_t &NextSectionIndex) {
auto End = LoadCmd.Ptr + LoadCmd.C.cmdsize;
const SectionType *Curr =
reinterpret_cast<const SectionType *>(LoadCmd.Ptr + sizeof(SegmentType));
@ -335,7 +334,3 @@ Expected<std::unique_ptr<Object>> MachOReader::create() const {
readSwiftVersion(*Obj);
return std::move(Obj);
}
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm

View File

@ -16,9 +16,8 @@
#include "llvm/Support/ErrorHandling.h"
#include <memory>
namespace llvm {
namespace objcopy {
namespace macho {
using namespace llvm;
using namespace llvm::objcopy::macho;
size_t MachOWriter::headerSize() const {
return Is64Bit ? sizeof(MachO::mach_header_64) : sizeof(MachO::mach_header);
@ -529,7 +528,3 @@ Error MachOWriter::write() {
Out.write(Buf->getBufferStart(), Buf->getBufferSize());
return Error::success();
}
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm

View File

@ -10,9 +10,8 @@
#include "llvm/ADT/SmallPtrSet.h"
#include <unordered_set>
namespace llvm {
namespace objcopy {
namespace macho {
using namespace llvm;
using namespace llvm::objcopy::macho;
const SymbolEntry *SymbolTable::getSymbolByIndex(uint32_t Index) const {
assert(Index < Symbols.size() && "invalid symbol index");
@ -190,7 +189,3 @@ Optional<uint64_t> LoadCommand::getSegmentVMAddr() const {
return None;
}
}
} // end namespace macho
} // end namespace objcopy
} // end namespace llvm