[PATCH] D84202: [clang][noderef] Enable -Wnoderef warning for CXX C-style casts

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 28 12:29:03 PDT 2020


aaron.ballman added a comment.

In D84202#2179718 <https://reviews.llvm.org/D84202#2179718>, @leonardchan wrote:

> In D84202#2179618 <https://reviews.llvm.org/D84202#2179618>, @aaron.ballman wrote:
>
>>> users can still disable the warning on line granularity with pragmas.
>>
>> This makes me a bit uncomfortable because those pragmas extremely ugly (and not easily portable). Also, this will break code for users who were previously doing something that was explicitly allowed (but not explicitly documented, at least). How often do users need to (legitimately, rather than accidentally) use the C-style cast like this?
>
> For fuchsia's case at least, we want to make it more difficult for users of this to explicitly remove the attribute (so adding dirty pragmas might help be a deterrent), and the only ideal case this would be stripped is in tests. For now, we do purposely have C-style casts scattered about since we're incrementally turning on this warning for various drivers, but we're getting closer to remove all these casts in non-testing driver code.

Good to know. And yeah, the pragma may be a good deterrent, but I was trying to understand whether the casts are *necessary* in some circumstances (e.g., are we forcing users to write these pragmas for correct code?). It sounds like the answer is that the casts aren't necessary?

> I can't speak for other projects use cases though. Would it help to send out an RFC to see if any other users have strong opinions?

It could help, but I'm not ready to insist yet. I'm mostly worried that this attribute has been available for 2+ years and I have no idea how widely used it is and what the usage patterns are. If you have evidence to suggest that this shouldn't be disruptive and that altering code to fit the new restriction is easy, that would help me feel more comfortable too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84202



More information about the cfe-commits mailing list