[lld] r234861 - ELF: Make common strings file-scoped constants.
Rui Ueyama
ruiu at google.com
Mon Apr 13 23:08:07 PDT 2015
Author: ruiu
Date: Tue Apr 14 01:08:07 2015
New Revision: 234861
URL: http://llvm.org/viewvc/llvm-project?rev=234861&view=rev
Log:
ELF: Make common strings file-scoped constants.
Modified:
lld/trunk/lib/ReaderWriter/ELF/FileCommon.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/FileCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/FileCommon.cpp?rev=234861&r1=234860&r2=234861&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/FileCommon.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/FileCommon.cpp Tue Apr 14 01:08:07 2015
@@ -15,14 +15,20 @@ using namespace llvm::ELF;
namespace lld {
namespace elf {
+static const char *elf32_expected = "ELF32 expected, but got ELF64";
+static const char *elf64_expected = "ELF64 expected, but got ELF32";
+static const char *le_expected =
+ "Little endian files are expected, but got a big endian file.";
+static const char *be_expected =
+ "Big endian files are expected, but got a little endian file.";
+
template <>
std::error_code checkCompatibility<ELF32LE>(unsigned char size,
unsigned char endian) {
if (size == ELFCLASS64)
- return make_dynamic_error_code("ELF32 expected, but got ELF64");
+ return make_dynamic_error_code(elf32_expected);
if (endian == ELFDATA2MSB)
- return make_dynamic_error_code(
- "Little endian files are expected, but got a big endian file.");
+ return make_dynamic_error_code(le_expected);
return std::error_code();
}
@@ -30,10 +36,9 @@ template <>
std::error_code checkCompatibility<ELF32BE>(unsigned char size,
unsigned char endian) {
if (size == ELFCLASS64)
- return make_dynamic_error_code("ELF32 expected, but got ELF64");
+ return make_dynamic_error_code(elf32_expected);
if (endian == ELFDATA2LSB)
- return make_dynamic_error_code(
- "Big endian files are expected, but got a little endian file.");
+ return make_dynamic_error_code(be_expected);
return std::error_code();
}
@@ -41,10 +46,9 @@ template <>
std::error_code checkCompatibility<ELF64LE>(unsigned char size,
unsigned char endian) {
if (size == ELFCLASS32)
- return make_dynamic_error_code("ELF64 expected, but got ELF32");
+ return make_dynamic_error_code(elf64_expected);
if (endian == ELFDATA2MSB)
- return make_dynamic_error_code(
- "Little endian files are expected, but got a big endian file.");
+ return make_dynamic_error_code(le_expected);
return std::error_code();
}
@@ -52,10 +56,9 @@ template <>
std::error_code checkCompatibility<ELF64BE>(unsigned char size,
unsigned char endian) {
if (size == ELFCLASS32)
- return make_dynamic_error_code("ELF64 expected, but got ELF32");
+ return make_dynamic_error_code(elf64_expected);
if (endian == ELFDATA2LSB)
- return make_dynamic_error_code(
- "Big endian files are expected, but got a little endian file.");
+ return make_dynamic_error_code(be_expected);
return std::error_code();
}
More information about the llvm-commits
mailing list