llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.37k stars 12.15k forks source link

clang-tidy 14 flags a constructor with an initializer list as replaceable with `= default` #56447

Open gnawme opened 2 years ago

gnawme commented 2 years ago

When running run-clang-tidy-14 on the Point Cloud Library, clang-tidy flags this constructor with the message:

/__w/pcl/pcl/common/include/pcl/common/time.h:62:7: error: use '= default' to define a trivial default constructor [modernize-use-equals-default,-warnings-as-errors]
      StopWatch () : start_time_ (std::chrono::steady_clock::now())

Setup from Github Action clang-tidy.yml:

          cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_COMPILER=/usr/bin/clang-14 -DCMAKE_C_COMPILER=/usr/bin/clang-14 . \
            -DBUILD_apps=ON \
            -DBUILD_apps_3d_rec_framework=ON \
            -DBUILD_apps_in_hand_scanner=ON \
            -DBUILD_apps_point_cloud_editor=ON \
            -DBUILD_benchmarks=ON \
            -DBUILD_examples=ON \
            -DBUILD_simulation=ON \
            -DBUILD_global_tests=ON
          run-clang-tidy -header-filter='.*'
llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-tidy

gnawme commented 2 years ago

clang-tidy also flags this destructor with the message:

/__w/pcl/pcl/visualization/include/pcl/visualization/common/actor_map.h:72:17: error: use '= default' to define a trivial destructor [modernize-use-equals-default,-warnings-as-errors]
        virtual ~CloudActor ()

even though the destructor has a body.

gnawme commented 2 years ago

On further reflection, clang-tidy is likely not suggesting that I do this:

StopWatch () : start_time_ (std::chrono::steady_clock::now()) = default;

but that this is equivalent (including initializing start_time_ to ::now()):

StopWatch () = default;

which is likely not the case.

SimplyDanny commented 9 months ago

Linting the file with clang-tidy (trunk), the constructor isn't marked. Can you confirm the issue is fixed, @gnawme?