[PATCH] D106431: [clang-tidy] Fix cppcoreguidelines-init-variables with enum judgement

Qing Shan Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 21 05:03:22 PDT 2021


steven.zhang added a comment.

In D106431#2892866 <https://reviews.llvm.org/D106431#2892866>, @MTC wrote:

> In D106431#2892859 <https://reviews.llvm.org/D106431#2892859>, @whisperity wrote:
>
>> Is this the right decision to make, conceptually? It will leave the variable uninitialised still, and reading such an uninit variable is still an issue, even if it is an enum.
>
> Yeah, that's right. However, it's much more difficult to give enum an initial value than an integer.
>
>> Could we consider the alternative of warning the user about the uninitialized variable, just not offering an automatic (and potentially bad / incorrect) fix?
>
> Make sense, we (ByteDance) are also hesitating whether we should provide automatic repair for uninitialized variables, because automatic fix may change the program semantics.

This is the same as what we did for integer in essential. We are changing an uninitialized value to the default one, which makes sense as uninitialized means it could be anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106431



More information about the cfe-commits mailing list