[llvm] r337337 - [NFC][llvm-objcopy] Cleanup namespace usage in llvm-objcopy.
Puyan Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 17 17:10:51 PDT 2018
Author: zer0
Date: Tue Jul 17 17:10:51 2018
New Revision: 337337
URL: http://llvm.org/viewvc/llvm-project?rev=337337&view=rev
Log:
[NFC][llvm-objcopy] Cleanup namespace usage in llvm-objcopy.
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
Modified:
llvm/trunk/tools/llvm-objcopy/Object.cpp
llvm/trunk/tools/llvm-objcopy/Object.h
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.h
Modified: llvm/trunk/tools/llvm-objcopy/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/Object.cpp?rev=337337&r1=337336&r2=337337&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/Object.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/Object.cpp Tue Jul 17 17:10:51 2018
@@ -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
Modified: llvm/trunk/tools/llvm-objcopy/Object.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/Object.h?rev=337337&r1=337336&r2=337337&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/Object.h (original)
+++ llvm/trunk/tools/llvm-objcopy/Object.h Tue Jul 17 17:10:51 2018
@@ -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
Modified: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp?rev=337337&r1=337336&r2=337337&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Tue Jul 17 17:10:51 2018
@@ -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) {
Modified: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/llvm-objcopy.h?rev=337337&r1=337336&r2=337337&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.h (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.h Tue Jul 17 17:10:51 2018
@@ -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(Expec
error(Buf);
}
+} // end namespace objcopy
} // end namespace llvm
#endif // LLVM_TOOLS_OBJCOPY_OBJCOPY_H
More information about the llvm-commits
mailing list