[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 11:04:25 PDT 2017


lebedev.ri added a comment.

In https://reviews.llvm.org/D33826#868185, @aaron.ballman wrote:

> Ah, I think I'm catching on to the point you're raising (thank you for
>  the patience). If the return type is void *, we don't have enough
>  information to sensibly diagnose (not without data flow analysis to
>  determine where the original value came from, anyway), and if the
>  return type is not void *, we should be checking the alignment anyway.
>
> That suggests we don't need the exception in this check at all, unless
>  we find extant implementations that return something other than void


Yes!

And, more than that, in some rare cases, when casting the pointer that
was *just* returned by `malloc`, i believe we *can* do this check too.
(i.e. in `malloc` case,  the target type should *not* have bigger alignment
requirements than the  `_Alignof (max_align_t)`.)

Now i have fully explained my concerns :)


Repository:
  rL LLVM

https://reviews.llvm.org/D33826





More information about the cfe-commits mailing list