[all-commits] [llvm/llvm-project] 980653: [clang-tidy] Give readability-redundant-member-ini...

mitchell-stellar via All-commits all-commits at lists.llvm.org
Tue Nov 19 08:00:58 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 980653621ef563df41f1d09a1ac8c58708f79930
      https://github.com/llvm/llvm-project/commit/980653621ef563df41f1d09a1ac8c58708f79930
  Author: Mitchell Balan <mitchell at stellarscience.com>
  Date:   2019-11-19 (Tue, 19 Nov 2019)

  Changed paths:
    M clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp
    M clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.h
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/docs/clang-tidy/checks/readability-redundant-member-init.rst
    M clang-tools-extra/test/clang-tidy/checkers/readability-redundant-member-init.cpp

  Log Message:
  -----------
  [clang-tidy] Give readability-redundant-member-init an option IgnoreBaseInCopyConstructors to avoid breaking code with gcc -Werror=extra

Summary:
readability-redundant-member-init removes redundant / unnecessary member and base class initialization. Unfortunately for the specific case of a copy constructor's initialization of a base class, gcc at strict warning levels warns if "base class is not initialized in the copy constructor of a derived class".

This patch adds an option `IgnoreBaseInCopyConstructors` defaulting to 0 (thus maintaining current behavior by default) to skip the specific case of removal of redundant base class initialization in the copy constructor. Enabling this option enables the resulting code to continue to compile successfully under `gcc -Werror=extra`. New test cases `WithCopyConstructor1` and `WithCopyConstructor2` in clang-tools-extra/test/clang-tidy/readability-redundant-member-init.cpp show that it removes redundant members even from copy constructors.

Reviewers: malcolm.parsons, alexfh, hokein, aaron.ballman, lebedev.ri

Patch by: poelmanc

Subscribers: mgehre, lebedev.ri, cfe-commits

Tags: #clang, #clang-tools-extra

Differential revision: https://reviews.llvm.org/D69145




More information about the All-commits mailing list