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,7 @@ /// 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 +186,7 @@ } 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,9 @@ /// 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 @@ -163,8 +163,8 @@ static std::error_code 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 object_error::unexpected_eof; } return std::error_code(); 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 @@ -147,7 +147,7 @@ "Frame size " + Twine(FrameSize) + ">= 65536.\n" "(" + - Twine(uintptr_t(&FI)) + ")"); + 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 @@ static std::error_code 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 (std::error_code EC = Binary::checkOffset(M, Addr, Size)) return EC; Obj = reinterpret_cast(Addr); @@ -330,7 +330,7 @@ unsigned COFFObjectFile::getSectionID(SectionRef Sec) const { uintptr_t Offset = - uintptr_t(Sec.getRawDataRefImpl().p) - uintptr_t(SectionTable); + reinterpret_cast(Sec.getRawDataRefImpl().p) - reinterpret_cast(SectionTable); assert((Offset % sizeof(coff_section)) == 0); return (Offset / sizeof(coff_section)) + 1; } @@ -371,7 +371,7 @@ // relocations. begin++; } - if (Binary::checkOffset(M, uintptr_t(begin), + if (Binary::checkOffset(M, reinterpret_cast(begin), sizeof(coff_relocation) * NumRelocs)) return nullptr; return begin; @@ -461,7 +461,7 @@ 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 std::error_code(); } } @@ -480,7 +480,7 @@ if (SectionStart <= RVA && OffsetIntoSection < Section->VirtualSize && Size <= Section->VirtualSize - OffsetIntoSection) { uintptr_t Begin = - uintptr_t(base()) + Section->PointerToRawData + OffsetIntoSection; + reinterpret_cast(base()) + Section->PointerToRawData + OffsetIntoSection; Contents = ArrayRef(reinterpret_cast(Begin), Size); return std::error_code(); @@ -1105,7 +1105,7 @@ // 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 (checkOffset(Data, ConStart, SectionSize)) return make_error(); 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 @@ -71,7 +71,7 @@ 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 @@ -24,7 +24,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 (std::error_code EC = Binary::checkOffset(M, Addr, Size)) return errorCodeToError(EC); return reinterpret_cast(Addr); @@ -276,7 +276,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 @@ -482,7 +482,8 @@ // 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); + 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); diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -619,14 +619,14 @@ ArgTLS = nullptr; GetArgTLSTy = FunctionType::get(PointerType::getUnqual(ArgTLSTy), false); GetArgTLS = ConstantExpr::getIntToPtr( - ConstantInt::get(IntptrTy, uintptr_t(GetArgTLSPtr)), + ConstantInt::get(IntptrTy, reinterpret_cast(GetArgTLSPtr)), PointerType::getUnqual(GetArgTLSTy)); } if (GetRetvalTLSPtr) { RetvalTLS = nullptr; GetRetvalTLSTy = FunctionType::get(PointerType::getUnqual(ShadowTy), false); GetRetvalTLS = ConstantExpr::getIntToPtr( - ConstantInt::get(IntptrTy, uintptr_t(GetRetvalTLSPtr)), + ConstantInt::get(IntptrTy, reinterpret_cast(GetRetvalTLSPtr)), PointerType::getUnqual(GetRetvalTLSTy)); } 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 @@ -443,7 +443,7 @@ const ELFFile *Obj = ObjF->getELFFile(); unsigned SecNdx = Sec - &cantFail(Obj->sections()).front(); - 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 SHT_GNU_versym section with index " + Twine(SecNdx) + " is misaligned"); @@ -522,7 +522,7 @@ Twine(SecNdx) + ": 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 SHT_GNU_verdef section with index " + Twine(SecNdx) + ": found a misaligned version definition entry at offset 0x" + @@ -545,7 +545,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 SHT_GNU_verdef section with index " + Twine(SecNdx) + ": found a misaligned auxiliary entry at offset 0x" + @@ -597,7 +597,7 @@ Twine(SecNdx) + ": 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 SHT_GNU_verneed section with index " + Twine(SecNdx) + ": found a misaligned version dependency entry at offset 0x" + @@ -624,7 +624,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 SHT_GNU_verneed section with index " + Twine(SecNdx) + ": found a misaligned auxiliary entry at offset 0x" +