[lld] r221974 - Follow-up to r221913. Fix some -Wcast-qual warning reasons.
Simon Atanasyan
simon at atanasyan.com
Thu Nov 13 23:15:44 PST 2014
Author: atanasyan
Date: Fri Nov 14 01:15:43 2014
New Revision: 221974
URL: http://llvm.org/viewvc/llvm-project?rev=221974&view=rev
Log:
Follow-up to r221913. Fix some -Wcast-qual warning reasons.
Modified:
lld/trunk/lib/Core/SymbolTable.cpp
lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h
lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h
lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Fri Nov 14 01:15:43 2014
@@ -187,9 +187,10 @@ bool SymbolTable::addByName(const Atom &
case NCR_Second:
useNew = true;
break;
- case NCR_DupDef:
- switch (mergeSelect(cast<DefinedAtom>(existing)->merge(),
- cast<DefinedAtom>(&newAtom)->merge())) {
+ case NCR_DupDef: {
+ const auto *existingDef = cast<DefinedAtom>(existing);
+ const auto *newDef = cast<DefinedAtom>(&newAtom);
+ switch (mergeSelect(existingDef->merge(), newDef->merge())) {
case MCR_First:
useNew = false;
break;
@@ -197,14 +198,14 @@ bool SymbolTable::addByName(const Atom &
useNew = true;
break;
case MCR_Largest: {
- uint64_t existingSize = sectionSize((DefinedAtom*)existing);
- uint64_t newSize = sectionSize((DefinedAtom*)&newAtom);
+ uint64_t existingSize = sectionSize(existingDef);
+ uint64_t newSize = sectionSize(newDef);
useNew = (newSize >= existingSize);
break;
}
case MCR_SameSize: {
- uint64_t existingSize = sectionSize((DefinedAtom*)existing);
- uint64_t newSize = sectionSize((DefinedAtom*)&newAtom);
+ uint64_t existingSize = sectionSize(existingDef);
+ uint64_t newSize = sectionSize(newDef);
if (existingSize == newSize) {
useNew = true;
break;
@@ -231,6 +232,7 @@ bool SymbolTable::addByName(const Atom &
break;
}
break;
+ }
case NCR_DupUndef: {
const UndefinedAtom* existingUndef = cast<UndefinedAtom>(existing);
const UndefinedAtom* newUndef = cast<UndefinedAtom>(&newAtom);
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Fri Nov 14 01:15:43 2014
@@ -664,8 +664,9 @@ template <class ELFT> std::error_code EL
}
}
- ArrayRef<uint8_t> symbolData(
- (uint8_t *)sectionContents->data() + symbol->st_value, contentSize);
+ ArrayRef<uint8_t> symbolData((const uint8_t *)sectionContents->data() +
+ symbol->st_value,
+ contentSize);
// If the linker finds that a section has global atoms that are in a
// mergeable section, treat them as defined atoms as they shouldn't be
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Fri Nov 14 01:15:43 2014
@@ -216,9 +216,9 @@ private:
case llvm::ELF::R_MIPS_32:
case llvm::ELF::R_MIPS_GPREL32:
case llvm::ELF::R_MIPS_PC32:
- return *(int32_t *)ap;
+ return *(const int32_t *)ap;
case llvm::ELF::R_MIPS_26:
- return *(int32_t *)ap & 0x3ffffff;
+ return *(const int32_t *)ap & 0x3ffffff;
case llvm::ELF::R_MIPS_HI16:
case llvm::ELF::R_MIPS_LO16:
case llvm::ELF::R_MIPS_GOT16:
@@ -226,7 +226,7 @@ private:
case llvm::ELF::R_MIPS_TLS_DTPREL_LO16:
case llvm::ELF::R_MIPS_TLS_TPREL_HI16:
case llvm::ELF::R_MIPS_TLS_TPREL_LO16:
- return *(int16_t *)ap;
+ return *(const int16_t *)ap;
case llvm::ELF::R_MIPS_CALL16:
case llvm::ELF::R_MIPS_TLS_GD:
case llvm::ELF::R_MIPS_TLS_LDM:
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp Fri Nov 14 01:15:43 2014
@@ -521,7 +521,7 @@ std::error_code ArchHandler_arm::getRefe
typedef std::error_code E;
const uint8_t *fixupContent = &inAtom->rawContent()[offsetInAtom];
uint64_t targetAddress;
- uint32_t instruction = *(ulittle32_t *)fixupContent;
+ uint32_t instruction = *(const ulittle32_t *)fixupContent;
int32_t displacement;
switch (relocPattern(reloc)) {
case ARM_THUMB_RELOC_BR22 | rPcRel | rExtern | rLength4:
@@ -781,7 +781,7 @@ ArchHandler_arm::getPairReferenceInfo(co
}
const uint8_t *fixupContent = &inAtom->rawContent()[offsetInAtom];
std::error_code ec;
- uint32_t instruction = *(ulittle32_t *)fixupContent;
+ uint32_t instruction = *(const ulittle32_t *)fixupContent;
uint32_t value;
uint32_t fromAddress;
uint32_t toAddress;
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp Fri Nov 14 01:15:43 2014
@@ -360,7 +360,7 @@ std::error_code ArchHandler_arm64::getRe
return std::error_code();
case ARM64_RELOC_PAGEOFF12 | rExtern | rLength4:
// ex: ldr x0, [x1, _foo at PAGEOFF]
- *kind = offset12KindFromInstruction(*(little32_t *)fixupContent);
+ *kind = offset12KindFromInstruction(*(const little32_t *)fixupContent);
if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
*addend = 0;
@@ -398,7 +398,7 @@ std::error_code ArchHandler_arm64::getRe
*kind = pointer64;
if (auto ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = *(little64_t *)fixupContent;
+ *addend = *(const little64_t *)fixupContent;
return std::error_code();
case ARM64_RELOC_POINTER_TO_GOT | rExtern | rLength8:
// ex: .quad _foo at GOT
@@ -458,7 +458,7 @@ std::error_code ArchHandler_arm64::getPa
*kind = delta64;
if (auto ec = atomFromSymbolIndex(reloc2.symbol, target))
return ec;
- *addend = (int64_t)*(little64_t *)fixupContent + offsetInAtom;
+ *addend = (int64_t)*(const little64_t *)fixupContent + offsetInAtom;
return std::error_code();
case ((ARM64_RELOC_SUBTRACTOR | rExtern | rLength4) << 16 |
ARM64_RELOC_UNSIGNED | rExtern | rLength4):
@@ -466,7 +466,7 @@ std::error_code ArchHandler_arm64::getPa
*kind = delta32;
if (auto ec = atomFromSymbolIndex(reloc2.symbol, target))
return ec;
- *addend = (int32_t)*(little32_t *)fixupContent + offsetInAtom;
+ *addend = (int32_t)*(const little32_t *)fixupContent + offsetInAtom;
return std::error_code();
default:
return make_dynamic_error_code(Twine("unsupported arm64 relocation pair"));
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp Fri Nov 14 01:15:43 2014
@@ -262,18 +262,20 @@ ArchHandler_x86::getReferenceInfo(const
*kind = branch32;
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = fixupAddress + 4 + (int32_t)*(little32_t *)fixupContent;
+ *addend = fixupAddress + 4 + (int32_t)*(const little32_t *)fixupContent;
break;
case GENERIC_RELOC_VANILLA | rPcRel | rLength4:
// ex: call _foo (and _foo defined)
*kind = branch32;
- targetAddress = fixupAddress + 4 + (int32_t)*(little32_t *)fixupContent;
+ targetAddress =
+ fixupAddress + 4 + (int32_t) * (const little32_t *)fixupContent;
return atomFromAddress(reloc.symbol, targetAddress, target, addend);
break;
case GENERIC_RELOC_VANILLA | rScattered | rPcRel | rLength4:
// ex: call _foo+n (and _foo defined)
*kind = branch32;
- targetAddress = fixupAddress + 4 + (int32_t)*(little32_t *)fixupContent;
+ targetAddress =
+ fixupAddress + 4 + (int32_t) * (const little32_t *)fixupContent;
if (E ec = atomFromAddress(0, reloc.value, target, addend))
return ec;
*addend = targetAddress - reloc.value;
@@ -283,18 +285,20 @@ ArchHandler_x86::getReferenceInfo(const
*kind = branch16;
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = fixupAddress + 2 + (int16_t)*(little16_t *)fixupContent;
+ *addend = fixupAddress + 2 + (int16_t)*(const little16_t *)fixupContent;
break;
case GENERIC_RELOC_VANILLA | rPcRel | rLength2:
// ex: callw _foo (and _foo defined)
*kind = branch16;
- targetAddress = fixupAddress + 2 + (int16_t)*(little16_t *)fixupContent;
+ targetAddress =
+ fixupAddress + 2 + (int16_t) * (const little16_t *)fixupContent;
return atomFromAddress(reloc.symbol, targetAddress, target, addend);
break;
case GENERIC_RELOC_VANILLA | rScattered | rPcRel | rLength2:
// ex: callw _foo+n (and _foo defined)
*kind = branch16;
- targetAddress = fixupAddress + 2 + (int16_t)*(little16_t *)fixupContent;
+ targetAddress =
+ fixupAddress + 2 + (int16_t) * (const little16_t *)fixupContent;
if (E ec = atomFromAddress(0, reloc.value, target, addend))
return ec;
*addend = targetAddress - reloc.value;
@@ -308,7 +312,7 @@ ArchHandler_x86::getReferenceInfo(const
: pointer32;
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = *(ulittle32_t *)fixupContent;
+ *addend = *(const ulittle32_t *)fixupContent;
break;
case GENERIC_RELOC_VANILLA | rLength4:
// ex: movl _foo, %eax (and _foo defined)
@@ -317,7 +321,7 @@ ArchHandler_x86::getReferenceInfo(const
*kind =
((perms & DefinedAtom::permR_X) == DefinedAtom::permR_X) ? abs32
: pointer32;
- targetAddress = *(ulittle32_t *)fixupContent;
+ targetAddress = *(const ulittle32_t *)fixupContent;
return atomFromAddress(reloc.symbol, targetAddress, target, addend);
break;
case GENERIC_RELOC_VANILLA | rScattered | rLength4:
@@ -328,7 +332,7 @@ ArchHandler_x86::getReferenceInfo(const
: pointer32;
if (E ec = atomFromAddress(0, reloc.value, target, addend))
return ec;
- *addend = *(ulittle32_t *)fixupContent - reloc.value;
+ *addend = *(const ulittle32_t *)fixupContent - reloc.value;
break;
default:
return make_dynamic_error_code(Twine("unsupported i386 relocation type"));
@@ -364,7 +368,7 @@ ArchHandler_x86::getPairReferenceInfo(co
GENERIC_RELOC_PAIR | rScattered | rLength4):
toAddress = reloc1.value;
fromAddress = reloc2.value;
- value = *(little32_t *)fixupContent;
+ value = *(const little32_t *)fixupContent;
ec = atomFromAddr(0, toAddress, target, &offsetInTo);
if (ec)
return ec;
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp Fri Nov 14 01:15:43 2014
@@ -340,39 +340,39 @@ ArchHandler_x86_64::getReferenceInfo(con
case ripRel32:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = *(little32_t *)fixupContent;
+ *addend = *(const little32_t *)fixupContent;
return std::error_code();
case ripRel32Minus1:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = (int32_t)*(little32_t *)fixupContent + 1;
+ *addend = (int32_t)*(const little32_t *)fixupContent + 1;
return std::error_code();
case ripRel32Minus2:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = (int32_t)*(little32_t *)fixupContent + 2;
+ *addend = (int32_t)*(const little32_t *)fixupContent + 2;
return std::error_code();
case ripRel32Minus4:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = (int32_t)*(little32_t *)fixupContent + 4;
+ *addend = (int32_t)*(const little32_t *)fixupContent + 4;
return std::error_code();
case ripRel32Anon:
- targetAddress = fixupAddress + 4 + *(little32_t *)fixupContent;
+ targetAddress = fixupAddress + 4 + *(const little32_t *)fixupContent;
return atomFromAddress(reloc.symbol, targetAddress, target, addend);
case ripRel32GotLoad:
case ripRel32Got:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = *(little32_t *)fixupContent;
+ *addend = *(const little32_t *)fixupContent;
return std::error_code();
case pointer64:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = *(little64_t *)fixupContent;
+ *addend = *(const little64_t *)fixupContent;
return std::error_code();
case pointer64Anon:
- targetAddress = *(little64_t *)fixupContent;
+ targetAddress = *(const little64_t *)fixupContent;
return atomFromAddress(reloc.symbol, targetAddress, target, addend);
default:
llvm_unreachable("bad reloc kind");
@@ -427,18 +427,18 @@ ArchHandler_x86_64::getPairReferenceInfo
case delta64:
if (E ec = atomFromSymbolIndex(reloc2.symbol, target))
return ec;
- *addend = (int64_t)*(little64_t *)fixupContent + offsetInAtom;
+ *addend = (int64_t)*(const little64_t *)fixupContent + offsetInAtom;
return std::error_code();
case delta32:
if (E ec = atomFromSymbolIndex(reloc2.symbol, target))
return ec;
- *addend = (int32_t)*(little32_t *)fixupContent + offsetInAtom;
+ *addend = (int32_t)*(const little32_t *)fixupContent + offsetInAtom;
return std::error_code();
case delta64Anon:
- targetAddress = offsetInAtom + (int64_t)*(little64_t *)fixupContent;
+ targetAddress = offsetInAtom + (int64_t)*(const little64_t *)fixupContent;
return atomFromAddress(reloc2.symbol, targetAddress, target, addend);
case delta32Anon:
- targetAddress = offsetInAtom + (int32_t)*(little32_t *)fixupContent;
+ targetAddress = offsetInAtom + (int32_t)*(const little32_t *)fixupContent;
return atomFromAddress(reloc2.symbol, targetAddress, target, addend);
default:
llvm_unreachable("bad reloc pair kind");
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp Fri Nov 14 01:15:43 2014
@@ -300,7 +300,7 @@ readBinary(std::unique_ptr<MemoryBuffer>
section.alignment = read32(§->align, isBig);
section.address = read64(§->addr, isBig);
const uint8_t *content =
- (uint8_t *)start + read32(§->offset, isBig);
+ (const uint8_t *)start + read32(§->offset, isBig);
size_t contentSize = read64(§->size, isBig);
// Note: this assign() is copying the content bytes. Ideally,
// we can use a custom allocator for vector to avoid the copy.
@@ -340,11 +340,11 @@ readBinary(std::unique_ptr<MemoryBuffer>
section.type = (SectionType)(read32(§->flags, isBig) &
SECTION_TYPE);
section.attributes =
- read32((uint8_t *)§->flags, isBig) & SECTION_ATTRIBUTES;
+ read32((const uint8_t *)§->flags, isBig) & SECTION_ATTRIBUTES;
section.alignment = read32(§->align, isBig);
section.address = read32(§->addr, isBig);
const uint8_t *content =
- (uint8_t *)start + read32(§->offset, isBig);
+ (const uint8_t *)start + read32(§->offset, isBig);
size_t contentSize = read32(§->size, isBig);
// Note: this assign() is copying the content bytes. Ideally,
// we can use a custom allocator for vector to avoid the copy.
@@ -367,8 +367,8 @@ readBinary(std::unique_ptr<MemoryBuffer>
const char *strings = start + read32(&st->stroff, isBig);
const uint32_t strSize = read32(&st->strsize, isBig);
// Validate string pool and symbol table all in buffer.
- if (read32((uint8_t *)&st->stroff, isBig) +
- read32((uint8_t *)&st->strsize, isBig) >
+ if (read32((const uint8_t *)&st->stroff, isBig) +
+ read32((const uint8_t *)&st->strsize, isBig) >
objSize)
return true;
if (is64) {
@@ -475,7 +475,7 @@ readBinary(std::unique_ptr<MemoryBuffer>
entry.offset = read32(&dataInCode[i].offset, isBig);
entry.length = read16(&dataInCode[i].length, isBig);
entry.kind =
- (DataRegionType)read16((uint8_t *)&dataInCode[i].kind, isBig);
+ (DataRegionType)read16((const uint8_t *)&dataInCode[i].kind, isBig);
f->dataInCode.push_back(entry);
}
}
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h Fri Nov 14 01:15:43 2014
@@ -41,8 +41,8 @@ static inline uint16_t read16(const T *l
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
if (isBig)
- return *(ubig16_t *)loc;
- return *(ulittle16_t *)loc;
+ return *(const ubig16_t *)loc;
+ return *(const ulittle16_t *)loc;
}
template<typename T>
@@ -50,8 +50,8 @@ static inline uint32_t read32(const T *l
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
if (isBig)
- return *(ubig32_t *)loc;
- return *(ulittle32_t *)loc;
+ return *(const ubig32_t *)loc;
+ return *(const ulittle32_t *)loc;
}
template<typename T>
@@ -59,8 +59,8 @@ static inline uint64_t read64(const T *l
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
if (isBig)
- return *(ubig64_t *)loc;
- return *(ulittle64_t *)loc;
+ return *(const ubig64_t *)loc;
+ return *(const ulittle64_t *)loc;
}
inline void write16(uint8_t *loc, uint16_t value, bool isBig) {
Modified: lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/EdataPass.h Fri Nov 14 01:15:43 2014
@@ -55,7 +55,7 @@ public:
ContentPermissions permissions() const override { return permR__; }
template <typename T> T *getContents() const {
- return (T *)rawContent().data();
+ return (T *)const_cast<uint8_t *>(rawContent().data());
}
};
Modified: lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/IdataPass.cpp Fri Nov 14 01:15:43 2014
@@ -314,7 +314,8 @@ std::map<StringRef, std::vector<COFFShar
IdataPass::groupByLoadName(MutableFile &file) {
std::map<StringRef, COFFSharedLibraryAtom *> uniqueAtoms;
for (const SharedLibraryAtom *atom : file.sharedLibrary())
- uniqueAtoms[atom->name()] = (COFFSharedLibraryAtom *)atom;
+ uniqueAtoms[atom->name()] =
+ (COFFSharedLibraryAtom *)const_cast<SharedLibraryAtom *>(atom);
std::map<StringRef, std::vector<COFFSharedLibraryAtom *> > ret;
for (auto i : uniqueAtoms) {
@@ -332,7 +333,7 @@ void IdataPass::replaceSharedLibraryAtom
auto *sharedAtom = dyn_cast<SharedLibraryAtom>(target);
if (!sharedAtom)
continue;
- auto *coffSharedAtom = (COFFSharedLibraryAtom *)sharedAtom;
+ const auto *coffSharedAtom = (const COFFSharedLibraryAtom *)sharedAtom;
const DefinedAtom *entry = coffSharedAtom->getImportTableEntry();
const_cast<Reference *>(ref)->setTarget(entry);
}
Modified: lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LoadConfigPass.h Fri Nov 14 01:15:43 2014
@@ -39,7 +39,7 @@ public:
ContentPermissions permissions() const override { return permR__; }
template <typename T> T *getContents() const {
- return (T *)rawContent().data();
+ return (T *)const_cast<uint8_t *>(rawContent().data());
}
};
Modified: lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp?rev=221974&r1=221973&r2=221974&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp Fri Nov 14 01:15:43 2014
@@ -89,7 +89,7 @@ public:
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "unnamed atom: creating ref-name: '"
<< newName << "' ("
- << (void *)newName.data() << ", "
+ << (const void *)newName.data() << ", "
<< newName.size() << ")\n");
}
}
@@ -118,7 +118,8 @@ public:
_refNames[&atom] = newName;
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "name collsion: creating ref-name: '"
- << newName << "' (" << (void *)newName.data()
+ << newName << "' ("
+ << (const void *)newName.data()
<< ", " << newName.size() << ")\n");
const lld::Atom *prevAtom = pos->second;
AtomToRefName::iterator pos2 = _refNames.find(prevAtom);
@@ -132,7 +133,7 @@ public:
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "name collsion: creating ref-name: '"
<< newName2 << "' ("
- << (void *)newName2.data() << ", "
+ << (const void *)newName2.data() << ", "
<< newName2.size() << ")\n");
}
} else {
@@ -141,8 +142,8 @@ public:
DEBUG_WITH_TYPE("WriterYAML", llvm::dbgs()
<< "atom name seen for first time: '"
<< atom.name() << "' ("
- << (void *)atom.name().data() << ", "
- << atom.name().size() << ")\n");
+ << (const void *)atom.name().data()
+ << ", " << atom.name().size() << ")\n");
}
}
@@ -767,8 +768,8 @@ template <> struct MappingTraits<const l
DEBUG_WITH_TYPE("WriterYAML", llvm::dbgs()
<< "created Reference to name: '"
<< _targetName << "' ("
- << (void *)_targetName.data() << ", "
- << _targetName.size() << ")\n");
+ << (const void *)_targetName.data()
+ << ", " << _targetName.size() << ")\n");
setKindNamespace(_mappedKind.ns);
setKindArch(_mappedKind.arch);
setKindValue(_mappedKind.value);
@@ -844,8 +845,8 @@ template <> struct MappingTraits<const l
_sectionName = f->copyString(_sectionName);
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "created DefinedAtom named: '" << _name
- << "' (" << (void *)_name.data() << ", "
- << _name.size() << ")\n");
+ << "' (" << (const void *)_name.data()
+ << ", " << _name.size() << ")\n");
return this;
}
void bind(const RefNameResolver &);
@@ -996,7 +997,7 @@ template <> struct MappingTraits<const l
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "created UndefinedAtom named: '" << _name
- << "' (" << (void *)_name.data() << ", "
+ << "' (" << (const void *)_name.data() << ", "
<< _name.size() << ")\n");
return this;
}
@@ -1057,7 +1058,8 @@ template <> struct MappingTraits<const l
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "created SharedLibraryAtom named: '"
- << _name << "' (" << (void *)_name.data()
+ << _name << "' ("
+ << (const void *)_name.data()
<< ", " << _name.size() << ")\n");
return this;
}
@@ -1118,8 +1120,8 @@ template <> struct MappingTraits<const l
DEBUG_WITH_TYPE("WriterYAML",
llvm::dbgs() << "created AbsoluteAtom named: '" << _name
- << "' (" << (void *)_name.data() << ", "
- << _name.size() << ")\n");
+ << "' (" << (const void *)_name.data()
+ << ", " << _name.size() << ")\n");
return this;
}
// Extract current File object from YAML I/O parsing context
@@ -1172,7 +1174,7 @@ RefNameResolver::RefNameResolver(const l
typedef MappingTraits<const lld::DefinedAtom *>::NormalizedAtom
NormalizedAtom;
for (const lld::DefinedAtom *a : file->defined()) {
- NormalizedAtom *na = (NormalizedAtom *)a;
+ const auto *na = (const NormalizedAtom *)a;
if (!na->_refName.empty())
add(na->_refName, a);
else if (!na->_name.empty())
@@ -1187,7 +1189,7 @@ RefNameResolver::RefNameResolver(const l
typedef MappingTraits<const lld::AbsoluteAtom *>::NormalizedAtom NormAbsAtom;
for (const lld::AbsoluteAtom *a : file->absolute()) {
- NormAbsAtom *na = (NormAbsAtom *)a;
+ const auto *na = (const NormAbsAtom *)a;
if (na->_refName.empty())
add(na->_name, a);
else
@@ -1203,16 +1205,16 @@ MappingTraits<const lld::File *>::Normal
RefNameResolver nameResolver(this, io);
// Now that all atoms are parsed, references can be bound.
for (const lld::DefinedAtom *a : this->defined()) {
- NormalizedAtom *normAtom = (NormalizedAtom *)a;
+ auto *normAtom = (NormalizedAtom *)const_cast<DefinedAtom *>(a);
normAtom->bind(nameResolver);
}
- _definedAtoms._atoms.erase(std::remove_if(_definedAtoms._atoms.begin(),
- _definedAtoms._atoms.end(),
- [](const DefinedAtom *a) {
- return ((NormalizedAtom *)a)->isGroupChild();
- }),
- _definedAtoms._atoms.end());
+ _definedAtoms._atoms.erase(
+ std::remove_if(_definedAtoms._atoms.begin(), _definedAtoms._atoms.end(),
+ [](const DefinedAtom *a) {
+ return ((const NormalizedAtom *)a)->isGroupChild();
+ }),
+ _definedAtoms._atoms.end());
return this;
}
@@ -1222,7 +1224,7 @@ inline void MappingTraits<const lld::Def
typedef MappingTraits<const lld::Reference *>::NormalizedReference
NormalizedReference;
for (const lld::Reference *ref : _references) {
- NormalizedReference *normRef = (NormalizedReference *)ref;
+ auto *normRef = (NormalizedReference *)const_cast<Reference *>(ref);
normRef->bind(resolver);
}
}
@@ -1235,7 +1237,7 @@ inline void MappingTraits<const lld::Ref
if (_mappedKind.ns == lld::Reference::KindNamespace::all &&
_mappedKind.value == lld::Reference::kindGroupChild) {
- ((NormalizedAtom *)_target)->setGroupChild(true);
+ ((NormalizedAtom *)const_cast<Atom *>(_target))->setGroupChild(true);
}
}
More information about the llvm-commits
mailing list