[NFC][llvm-objcopy] Cleanup namespace usage in llvm-objcopy.
authorPuyan Lotfi <puyan@puyan.org>
Wed, 18 Jul 2018 00:10:51 +0000 (00:10 +0000)
committerPuyan Lotfi <puyan@puyan.org>
Wed, 18 Jul 2018 00:10:51 +0000 (00:10 +0000)
Nest any classes not used outside of a file into anon. Nest any classes used
across files in llvm-objcopy into namespace llvm::objcopy.

Differential Revision: https://reviews.llvm.org/D49449

llvm-svn: 337337

llvm/tools/llvm-objcopy/Object.cpp
llvm/tools/llvm-objcopy/Object.h
llvm/tools/llvm-objcopy/llvm-objcopy.cpp
llvm/tools/llvm-objcopy/llvm-objcopy.h

index 1398827..7e88f52 100644 (file)
@@ -27,6 +27,7 @@
 #include <vector>
 
 using namespace llvm;
+using namespace llvm::objcopy;
 using namespace object;
 using namespace ELF;
 
@@ -1387,6 +1388,7 @@ void BinaryWriter::finalize() {
 }
 
 namespace llvm {
+namespace objcopy {
 
 template class ELFBuilder<ELF64LE>;
 template class ELFBuilder<ELF64BE>;
@@ -1397,4 +1399,5 @@ template class ELFWriter<ELF64LE>;
 template class ELFWriter<ELF64BE>;
 template class ELFWriter<ELF32LE>;
 template class ELFWriter<ELF32BE>;
+} // end namespace objcopy
 } // end namespace llvm
index b8f45a4..76748d5 100644 (file)
@@ -26,6 +26,7 @@
 #include <vector>
 
 namespace llvm {
+namespace objcopy {
 
 class Buffer;
 class SectionBase;
@@ -714,6 +715,7 @@ public:
     return *Segments.back();
   }
 };
+} // end namespace objcopy
 } // end namespace llvm
 
 #endif // LLVM_TOOLS_OBJCOPY_OBJECT_H
index b4c579c..12e9ca1 100644 (file)
@@ -43,6 +43,7 @@
 #include <utility>
 
 using namespace llvm;
+using namespace llvm::objcopy;
 using namespace object;
 using namespace ELF;
 
@@ -114,35 +115,6 @@ public:
   StripOptTable() : OptTable(StripInfoTable, true) {}
 };
 
-} // namespace
-
-// The name this program was invoked as.
-static StringRef ToolName;
-
-namespace llvm {
-
-LLVM_ATTRIBUTE_NORETURN void error(Twine Message) {
-  errs() << ToolName << ": " << Message << ".\n";
-  errs().flush();
-  exit(1);
-}
-
-LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, std::error_code EC) {
-  assert(EC);
-  errs() << ToolName << ": '" << File << "': " << EC.message() << ".\n";
-  exit(1);
-}
-
-LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) {
-  assert(E);
-  std::string Buf;
-  raw_string_ostream OS(Buf);
-  logAllUnhandledErrors(std::move(E), OS, "");
-  OS.flush();
-  errs() << ToolName << ": '" << File << "': " << Buf;
-  exit(1);
-}
-
 struct CopyConfig {
   StringRef OutputFilename;
   StringRef InputFilename;
@@ -179,6 +151,37 @@ struct CopyConfig {
 
 using SectionPred = std::function<bool(const SectionBase &Sec)>;
 
+} // namespace
+
+namespace llvm {
+namespace objcopy {
+
+// The name this program was invoked as.
+StringRef ToolName;
+
+LLVM_ATTRIBUTE_NORETURN void error(Twine Message) {
+  errs() << ToolName << ": " << Message << ".\n";
+  errs().flush();
+  exit(1);
+}
+
+LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, std::error_code EC) {
+  assert(EC);
+  errs() << ToolName << ": '" << File << "': " << EC.message() << ".\n";
+  exit(1);
+}
+
+LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) {
+  assert(E);
+  std::string Buf;
+  raw_string_ostream OS(Buf);
+  logAllUnhandledErrors(std::move(E), OS, "");
+  OS.flush();
+  errs() << ToolName << ": '" << File << "': " << Buf;
+  exit(1);
+}
+
+} // end namespace objcopy
 } // end namespace llvm
 
 static bool IsDWOSection(const SectionBase &Sec) {
index 10b083e..e222b65 100644 (file)
@@ -17,6 +17,7 @@
 #include <string>
 
 namespace llvm {
+namespace objcopy {
 
 LLVM_ATTRIBUTE_NORETURN extern void error(Twine Message);
 LLVM_ATTRIBUTE_NORETURN extern void reportError(StringRef File, Error E);
@@ -35,6 +36,7 @@ template <class T> T unwrapOrError(Expected<T> EO) {
   error(Buf);
 }
 
+} // end namespace objcopy
 } // end namespace llvm
 
 #endif // LLVM_TOOLS_OBJCOPY_OBJCOPY_H