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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 23 00:31:58 PDT 2021


Author: Fangrui Song
Date: 2021-06-23T00:31:52-07:00
New Revision: 011b502ce850f423991c97356f566548372c50ca

URL: https://github.com/llvm/llvm-project/commit/011b502ce850f423991c97356f566548372c50ca
DIFF: https://github.com/llvm/llvm-project/commit/011b502ce850f423991c97356f566548372c50ca.diff

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

Added: 
    

Modified: 
    llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
    llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
    llvm/tools/llvm-objcopy/MachO/MachOReader.cpp
    llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp
    llvm/tools/llvm-objcopy/MachO/Object.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp b/llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
index c72600a9f01e..8dc425941840 100644
--- a/llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
@@ -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

diff  --git a/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp b/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
index 64326d9fe8d5..823306916bbe 100644
--- a/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
@@ -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

diff  --git a/llvm/tools/llvm-objcopy/MachO/MachOReader.cpp b/llvm/tools/llvm-objcopy/MachO/MachOReader.cpp
index 548a85bd497e..050dd976f3f3 100644
--- a/llvm/tools/llvm-objcopy/MachO/MachOReader.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/MachOReader.cpp
@@ -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

diff  --git a/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp b/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp
index 012d9dfcc4f2..483703de352f 100644
--- a/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp
@@ -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

diff  --git a/llvm/tools/llvm-objcopy/MachO/Object.cpp b/llvm/tools/llvm-objcopy/MachO/Object.cpp
index cdb97531fb66..c82dae6d98ad 100644
--- a/llvm/tools/llvm-objcopy/MachO/Object.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/Object.cpp
@@ -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


        


More information about the llvm-commits mailing list