[PATCH] D76572: Replace `T(x)` with `reinterpret_cast<T>(x)` everywhere it means reinterpret_cast. No functional change

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 22 13:23:10 PDT 2020


Quuxplusone created this revision.
Quuxplusone added reviewers: rsmith, espindola, DiggerLin, ahatanak, reames.
Herald added subscribers: cfe-commits, rupprecht, dexonsmith, MaskRay, hiraditya.
Herald added a reviewer: jhenderson.
Herald added a project: clang.

I wrote a Clang warning [not pictured] to diagnose any use of `T(x)` which was not equivalent to `static_cast<T>(x)`. Then I built Clang with that warning turned on. Here are all of the instances of "unsafe" `T(x)` that it identified in the codebase. Every single one is a cast from some pointer type to `uintptr_t`.

N.B.: The code in `llvm/IR/SymbolTableListTraits.h` looks absolutely crazy, and this will be the first time it's been touched in over a decade.

If this refactor is acceptable, I'll need someone to land it for me, as I don't have permissions.


Repository:
  rG LLVM Github Monorepo

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/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76572.251913.patch
Type: text/x-patch
Size: 11673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200322/59b16f0e/attachment.bin>


More information about the cfe-commits mailing list