[all-commits] [llvm/llvm-project] 4a097e: [clang-tidy] Fix cppcoreguidelines-init-variables ...

Liu Ke via All-commits all-commits at lists.llvm.org
Fri Jul 30 09:25:27 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a097efe7784767b7d12ffcb8f2b22b9f4d045e2
      https://github.com/llvm/llvm-project/commit/4a097efe7784767b7d12ffcb8f2b22b9f4d045e2
  Author: Liuke Gehry <liuke.gehry at bytedance.com>
  Date:   2021-07-30 (Fri, 30 Jul 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:
  -----------
  [clang-tidy] 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




More information about the All-commits mailing list