[PATCH] D91055: [clang-tidy] Introduce misc No Integer To Pointer Cast check

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 9 02:11:41 PST 2020


lebedev.ri added a comment.

In D91055#2382112 <https://reviews.llvm.org/D91055#2382112>, @nlopes wrote:

> Nice!

Why thank you.

> BTW, another popular idiom is to store data in the last few bits of the pointer (e.g., LLVM's own PointerIntPair). I guess that one can also be implement by casting the ptr to char* and doing operations over that.

Yep, there is a number of such patterns.
My basic idea behind this patch is that it is very much non-obvious whether

1. such a cast was actually intended to be there
2. the provenance obscurement is intentional

so let's just diagnose everything, and the user can either silence it, or rewrite it without the cast.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91055/new/

https://reviews.llvm.org/D91055



More information about the cfe-commits mailing list