diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h --- a/clang/lib/CodeGen/CGCall.h +++ b/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(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(functionPtr)); } bool isVirtual() const { diff --git a/llvm/include/llvm/IR/SymbolTableListTraits.h b/llvm/include/llvm/IR/SymbolTableListTraits.h --- a/llvm/include/llvm/IR/SymbolTableListTraits.h +++ b/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(nullptr))))); - ListTy *Anchor(static_cast(this)); + size_t Offset = reinterpret_cast( + &((ItemParentClass *)nullptr->*ItemParentClass::getSublistAccess( + static_cast( + nullptr)))); + ListTy *Anchor = static_cast(this); return reinterpret_cast(reinterpret_cast(Anchor)- Offset); } diff --git a/llvm/include/llvm/Object/Binary.h b/llvm/include/llvm/Object/Binary.h --- a/llvm/include/llvm/Object/Binary.h +++ b/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(M.getBufferEnd()) || + Addr < reinterpret_cast(M.getBufferStart())) { return errorCodeToError(object_error::unexpected_eof); } return Error::success(); diff --git a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp +++ b/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(&FI)) + ")"); } AP.OutStreamer->AddComment("live roots for " + diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -57,7 +57,7 @@ template 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(Ptr); if (Error E = Binary::checkOffset(M, Addr, Size)) return E; Obj = reinterpret_cast(Addr); @@ -103,10 +103,11 @@ const coff_symbol_type *Addr = reinterpret_cast(Ref.p); - assert(!checkOffset(Data, uintptr_t(Addr), sizeof(*Addr))); + assert(!checkOffset(Data, reinterpret_cast(Addr), sizeof(*Addr))); #ifndef NDEBUG // Verify that the symbol points to a valid entry in the symbol table. - uintptr_t Offset = uintptr_t(Addr) - uintptr_t(base()); + uintptr_t Offset = + reinterpret_cast(Addr) - reinterpret_cast(base()); assert((Offset - getPointerToSymbolTable()) % sizeof(coff_symbol_type) == 0 && "Symbol did not point to the beginning of a symbol"); @@ -123,7 +124,8 @@ if (Addr < SectionTable || Addr >= (SectionTable + getNumberOfSections())) report_fatal_error("Section was outside of section table."); - uintptr_t Offset = uintptr_t(Addr) - uintptr_t(SectionTable); + uintptr_t Offset = reinterpret_cast(Addr) - + reinterpret_cast(SectionTable); assert(Offset % sizeof(coff_section) == 0 && "Section did not point to the beginning of a section"); #endif @@ -332,7 +334,7 @@ unsigned COFFObjectFile::getSectionID(SectionRef Sec) const { uintptr_t Offset = - uintptr_t(Sec.getRawDataRefImpl().p) - uintptr_t(SectionTable); + Sec.getRawDataRefImpl().p - reinterpret_cast(SectionTable); assert((Offset % sizeof(coff_section)) == 0); return (Offset / sizeof(coff_section)) + 1; } @@ -376,7 +378,7 @@ // relocations. begin++; } - if (auto E = Binary::checkOffset(M, uintptr_t(begin), + if (auto E = Binary::checkOffset(M, reinterpret_cast(begin), sizeof(coff_relocation) * NumRelocs)) { consumeError(std::move(E)); return nullptr; @@ -467,7 +469,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(base()) + Section->PointerToRawData + + Offset; return Error::success(); } } @@ -484,8 +487,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(base()) + + Section->PointerToRawData + OffsetIntoSection; Contents = ArrayRef(reinterpret_cast(Begin), Size); return Error::success(); @@ -1127,7 +1130,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(base()) + Sec->PointerToRawData; uint32_t SectionSize = getSectionSize(Sec); if (Error E = checkOffset(Data, ConStart, SectionSize)) return E; diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -73,7 +73,8 @@ std::pair Ident = getElfArchType(Obj.getBuffer()); std::size_t MaxAlignment = - 1ULL << countTrailingZeros(uintptr_t(Obj.getBufferStart())); + 1ULL << countTrailingZeros( + reinterpret_cast(Obj.getBufferStart())); if (MaxAlignment < 2) return createError("Insufficient alignment"); diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp --- a/llvm/lib/Object/XCOFFObjectFile.cpp +++ b/llvm/lib/Object/XCOFFObjectFile.cpp @@ -31,7 +31,7 @@ template static Expected getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size = sizeof(T)) { - uintptr_t Addr = uintptr_t(Ptr); + uintptr_t Addr = reinterpret_cast(Ptr); if (Error E = Binary::checkOffset(M, Addr, Size)) return std::move(E); return reinterpret_cast(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(ContentStart), SectionSize)) return make_error(); return makeArrayRef(ContentStart,SectionSize); diff --git a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp --- a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp +++ b/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(N1); + uintptr_t P2 = reinterpret_cast(N2); + if (P1 <= P2) + return std::make_pair(N1, N2); + return std::make_pair(N2, N1); } static unsigned node_hash(GepNode *N) { diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -505,7 +505,9 @@ ELFDumper::getVersionTable(const Elf_Shdr &Sec, ArrayRef *SymTab, StringRef *StrTab) const { assert((!SymTab && !StrTab) || (SymTab && StrTab)); - if (uintptr_t(Obj.base() + Sec.sh_offset) % sizeof(uint16_t) != 0) + if (reinterpret_cast(Obj.base() + Sec.sh_offset) % + sizeof(uint16_t) != + 0) return createError("the " + describe(Sec) + " is misaligned"); Expected> 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(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(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(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(VernauxBuf) % sizeof(uint32_t) != 0) return createError("invalid " + describe(Sec) + ": found a misaligned auxiliary entry at offset 0x" + Twine::utohexstr(VernauxBuf - Start));