[all-commits] [llvm/llvm-project] 8dcdfc: Fix cppcoreguidelines-init-variables by removing t...

Liu Ke via All-commits all-commits at lists.llvm.org
Wed Aug 11 21:49:59 PDT 2021


  Branch: refs/heads/release/13.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 8dcdfc0de84f60b5b4af97ac5b357881af55bc6e
      https://github.com/llvm/llvm-project/commit/8dcdfc0de84f60b5b4af97ac5b357881af55bc6e
  Author: Liuke Gehry <liuke.gehry at bytedance.com>
  Date:   2021-08-11 (Wed, 11 Aug 2021)

  Changed paths:
    M clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
    M clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp

  Log Message:
  -----------
  Fix cppcoreguidelines-init-variables by removing the enum FixIt, and add support for initialization check of scoped enum

In C++, the enumeration is never Integer, and the enumeration condition judgment is added to avoid compiling errors when it is initialized to an integer.
Add support for initialization check of scope enum.

As the following case show, clang-tidy will give a wrong automatic fix:

    enum Color {Red, Green, Blue};
    enum class Gender {Male, Female};
    void func() {
      Color color; // Color color = 0; <--- fix bug
      Gender gender; // <--- no warning
    }

Reviewd By: aaron.ballman, whisperity

Differential Revision: http://reviews.llvm.org/D106431

(cherry picked from commit 4a097efe7784767b7d12ffcb8f2b22b9f4d045e2)




More information about the All-commits mailing list