]> granicus.if.org Git - llvm/commitdiff
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337337 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 139882778d743b8e1e35e8cfdefebf63511606a1..7e88f5263a39c46462f00df4e0e9901c093744c6 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 b8f45a431e1fd11377b0360d392fccd1a2d7f242..76748d5fc64115bc57fedb5dbd0d37a4c3a44d51 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 b4c579c20d96f169d19cd523db79f54396318ae7..12e9ca17e1990b1145554819f386526be63df192 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 10b083ecaee7ebb673aed30c48093250ec0e4dfc..e222b65dc78fbbc7609f95ba7ad5f4f258b9bfcd 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