Quuxplusone updated this revision to Diff 313433. Quuxplusone edited the summary of this revision. Quuxplusone added a comment. Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Rebase in preparation for finally pushing this thing if the buildbots seem happy. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76572/new/ https://reviews.llvm.org/D76572 Files: clang/lib/CodeGen/CGCall.h llvm/include/llvm/IR/SymbolTableListTraits.h llvm/include/llvm/Object/Binary.h llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp llvm/lib/Object/COFFObjectFile.cpp llvm/lib/Object/ELFObjectFile.cpp llvm/lib/Object/XCOFFObjectFile.cpp llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -505,7 +505,9 @@ ELFDumper<ELFT>::getVersionTable(const Elf_Shdr &Sec, ArrayRef<Elf_Sym> *SymTab, StringRef *StrTab) const { assert((!SymTab && !StrTab) || (SymTab && StrTab)); - if (uintptr_t(Obj.base() + Sec.sh_offset) % sizeof(uint16_t) != 0) + if (reinterpret_cast<uintptr_t>(Obj.base() + Sec.sh_offset) % + sizeof(uint16_t) != + 0) return createError("the " + describe(Sec) + " is misaligned"); Expected<ArrayRef<Elf_Versym>> VersionsOrErr = @@ -576,7 +578,7 @@ return createError("invalid " + describe(Sec) + ": version definition " + Twine(I) + " goes past the end of the section"); - if (uintptr_t(VerdefBuf) % sizeof(uint32_t) != 0) + if (reinterpret_cast<uintptr_t>(VerdefBuf) % sizeof(uint32_t) != 0) return createError( "invalid " + describe(Sec) + ": found a misaligned version definition entry at offset 0x" + @@ -598,7 +600,7 @@ const uint8_t *VerdauxBuf = VerdefBuf + D->vd_aux; for (unsigned J = 0; J < D->vd_cnt; ++J) { - if (uintptr_t(VerdauxBuf) % sizeof(uint32_t) != 0) + if (reinterpret_cast<uintptr_t>(VerdauxBuf) % sizeof(uint32_t) != 0) return createError("invalid " + describe(Sec) + ": found a misaligned auxiliary entry at offset 0x" + Twine::utohexstr(VerdauxBuf - Start)); @@ -644,7 +646,7 @@ return createError("invalid " + describe(Sec) + ": version dependency " + Twine(I) + " goes past the end of the section"); - if (uintptr_t(VerneedBuf) % sizeof(uint32_t) != 0) + if (reinterpret_cast<uintptr_t>(VerneedBuf) % sizeof(uint32_t) != 0) return createError( "invalid " + describe(Sec) + ": found a misaligned version dependency entry at offset 0x" + @@ -670,7 +672,7 @@ const uint8_t *VernauxBuf = VerneedBuf + Verneed->vn_aux; for (unsigned J = 0; J < Verneed->vn_cnt; ++J) { - if (uintptr_t(VernauxBuf) % sizeof(uint32_t) != 0) + if (reinterpret_cast<uintptr_t>(VernauxBuf) % sizeof(uint32_t) != 0) return createError("invalid " + describe(Sec) + ": found a misaligned auxiliary entry at offset 0x" + Twine::utohexstr(VernauxBuf - Start)); Index: llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp =================================================================== --- llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp +++ llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp @@ -472,10 +472,11 @@ // determining equality. The only purpose of the ordering is to eliminate // duplication due to the commutativity of equality/non-equality. static NodePair node_pair(GepNode *N1, GepNode *N2) { - uintptr_t P1 = uintptr_t(N1), P2 = uintptr_t(N2); - if (P1 <= P2) - return std::make_pair(N1, N2); - return std::make_pair(N2, N1); + uintptr_t P1 = reinterpret_cast<uintptr_t>(N1); + uintptr_t P2 = reinterpret_cast<uintptr_t>(N2); + if (P1 <= P2) + return std::make_pair(N1, N2); + return std::make_pair(N2, N1); } static unsigned node_hash(GepNode *N) { Index: llvm/lib/Object/XCOFFObjectFile.cpp =================================================================== --- llvm/lib/Object/XCOFFObjectFile.cpp +++ llvm/lib/Object/XCOFFObjectFile.cpp @@ -31,7 +31,7 @@ template <typename T> static Expected<const T *> getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size = sizeof(T)) { - uintptr_t Addr = uintptr_t(Ptr); + uintptr_t Addr = reinterpret_cast<uintptr_t>(Ptr); if (Error E = Binary::checkOffset(M, Addr, Size)) return std::move(E); return reinterpret_cast<const T *>(Addr); @@ -283,7 +283,7 @@ const uint8_t * ContentStart = base() + OffsetToRaw; uint64_t SectionSize = getSectionSize(Sec); - if (checkOffset(Data, uintptr_t(ContentStart), SectionSize)) + if (checkOffset(Data, reinterpret_cast<uintptr_t>(ContentStart), SectionSize)) return make_error<BinaryError>(); return makeArrayRef(ContentStart,SectionSize); Index: llvm/lib/Object/ELFObjectFile.cpp =================================================================== --- llvm/lib/Object/ELFObjectFile.cpp +++ llvm/lib/Object/ELFObjectFile.cpp @@ -73,7 +73,8 @@ std::pair<unsigned char, unsigned char> Ident = getElfArchType(Obj.getBuffer()); std::size_t MaxAlignment = - 1ULL << countTrailingZeros(uintptr_t(Obj.getBufferStart())); + 1ULL << countTrailingZeros( + reinterpret_cast<uintptr_t>(Obj.getBufferStart())); if (MaxAlignment < 2) return createError("Insufficient alignment"); Index: llvm/lib/Object/COFFObjectFile.cpp =================================================================== --- llvm/lib/Object/COFFObjectFile.cpp +++ llvm/lib/Object/COFFObjectFile.cpp @@ -57,7 +57,7 @@ template <typename T> static Error getObject(const T *&Obj, MemoryBufferRef M, const void *Ptr, const uint64_t Size = sizeof(T)) { - uintptr_t Addr = uintptr_t(Ptr); + uintptr_t Addr = reinterpret_cast<uintptr_t>(Ptr); if (Error E = Binary::checkOffset(M, Addr, Size)) return E; Obj = reinterpret_cast<const T *>(Addr); @@ -331,8 +331,8 @@ } unsigned COFFObjectFile::getSectionID(SectionRef Sec) const { - uintptr_t Offset = - uintptr_t(Sec.getRawDataRefImpl().p) - uintptr_t(SectionTable); + uintptr_t Offset = reinterpret_cast<uintptr_t>(Sec.getRawDataRefImpl().p) - + reinterpret_cast<uintptr_t>(SectionTable); assert((Offset % sizeof(coff_section)) == 0); return (Offset / sizeof(coff_section)) + 1; } @@ -376,7 +376,7 @@ // relocations. begin++; } - if (auto E = Binary::checkOffset(M, uintptr_t(begin), + if (auto E = Binary::checkOffset(M, reinterpret_cast<uintptr_t>(begin), sizeof(coff_relocation) * NumRelocs)) { consumeError(std::move(E)); return nullptr; @@ -467,7 +467,8 @@ uint32_t SectionEnd = Section->VirtualAddress + Section->VirtualSize; if (SectionStart <= Addr && Addr < SectionEnd) { uint32_t Offset = Addr - SectionStart; - Res = uintptr_t(base()) + Section->PointerToRawData + Offset; + Res = reinterpret_cast<uintptr_t>(base()) + Section->PointerToRawData + + Offset; return Error::success(); } } @@ -484,8 +485,8 @@ uint32_t OffsetIntoSection = RVA - SectionStart; if (SectionStart <= RVA && OffsetIntoSection < Section->VirtualSize && Size <= Section->VirtualSize - OffsetIntoSection) { - uintptr_t Begin = - uintptr_t(base()) + Section->PointerToRawData + OffsetIntoSection; + uintptr_t Begin = reinterpret_cast<uintptr_t>(base()) + + Section->PointerToRawData + OffsetIntoSection; Contents = ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(Begin), Size); return Error::success(); @@ -1127,7 +1128,8 @@ // The only thing that we need to verify is that the contents is contained // within the file bounds. We don't need to make sure it doesn't cover other // data, as there's nothing that says that is not allowed. - uintptr_t ConStart = uintptr_t(base()) + Sec->PointerToRawData; + uintptr_t ConStart = + reinterpret_cast<uintptr_t>(base()) + Sec->PointerToRawData; uint32_t SectionSize = getSectionSize(Sec); if (Error E = checkOffset(Data, ConStart, SectionSize)) return E; Index: llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp +++ llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp @@ -145,9 +145,10 @@ report_fatal_error("Function '" + FI.getFunction().getName() + "' is too large for the ocaml GC! " "Frame size " + - Twine(FrameSize) + ">= 65536.\n" - "(" + - Twine(uintptr_t(&FI)) + ")"); + Twine(FrameSize) + + ">= 65536.\n" + "(" + + Twine(reinterpret_cast<uintptr_t>(&FI)) + ")"); } AP.OutStreamer->AddComment("live roots for " + Index: llvm/include/llvm/Object/Binary.h =================================================================== --- llvm/include/llvm/Object/Binary.h +++ llvm/include/llvm/Object/Binary.h @@ -165,8 +165,8 @@ static Error checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size) { if (Addr + Size < Addr || Addr + Size < Size || - Addr + Size > uintptr_t(M.getBufferEnd()) || - Addr < uintptr_t(M.getBufferStart())) { + Addr + Size > reinterpret_cast<uintptr_t>(M.getBufferEnd()) || + Addr < reinterpret_cast<uintptr_t>(M.getBufferStart())) { return errorCodeToError(object_error::unexpected_eof); } return Error::success(); Index: llvm/include/llvm/IR/SymbolTableListTraits.h =================================================================== --- llvm/include/llvm/IR/SymbolTableListTraits.h +++ llvm/include/llvm/IR/SymbolTableListTraits.h @@ -76,9 +76,11 @@ /// getListOwner - Return the object that owns this list. If this is a list /// of instructions, it returns the BasicBlock that owns them. ItemParentClass *getListOwner() { - size_t Offset(size_t(&((ItemParentClass*)nullptr->*ItemParentClass:: - getSublistAccess(static_cast<ValueSubClass*>(nullptr))))); - ListTy *Anchor(static_cast<ListTy *>(this)); + size_t Offset = reinterpret_cast<size_t>( + &((ItemParentClass *)nullptr->*ItemParentClass::getSublistAccess( + static_cast<ValueSubClass *>( + nullptr)))); + ListTy *Anchor = static_cast<ListTy *>(this); return reinterpret_cast<ItemParentClass*>(reinterpret_cast<char*>(Anchor)- Offset); } Index: clang/lib/CodeGen/CGCall.h =================================================================== --- clang/lib/CodeGen/CGCall.h +++ clang/lib/CodeGen/CGCall.h @@ -110,7 +110,8 @@ /// Construct a callee. Call this constructor directly when this /// isn't a direct call. CGCallee(const CGCalleeInfo &abstractInfo, llvm::Value *functionPtr) - : KindOrFunctionPointer(SpecialKind(uintptr_t(functionPtr))) { + : KindOrFunctionPointer( + SpecialKind(reinterpret_cast<uintptr_t>(functionPtr))) { AbstractInfo = abstractInfo; assert(functionPtr && "configuring callee without function pointer"); assert(functionPtr->getType()->isPointerTy()); @@ -186,7 +187,8 @@ } void setFunctionPointer(llvm::Value *functionPtr) { assert(isOrdinary()); - KindOrFunctionPointer = SpecialKind(uintptr_t(functionPtr)); + KindOrFunctionPointer = + SpecialKind(reinterpret_cast<uintptr_t>(functionPtr)); } bool isVirtual() const {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits