[all-commits] [llvm/llvm-project] 3ed940: [clang-tidy] Add check hicpp-ignored-remove-result...

Björn Svensson via All-commits all-commits at lists.llvm.org
Thu Dec 7 11:56:00 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3ed940ac3dac03d044a8d1e51005cec84dd128f9
      https://github.com/llvm/llvm-project/commit/3ed940ac3dac03d044a8d1e51005cec84dd128f9
  Author: Björn Svensson <bjorn.a.svensson at est.tech>
  Date:   2023-12-07 (Thu, 07 Dec 2023)

  Changed paths:
    M clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
    M clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
    M clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
    M clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
    A clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.cpp
    A clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.h
    M clang-tools-extra/docs/ReleaseNotes.rst
    A clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst
    M clang-tools-extra/docs/clang-tidy/checks/list.rst
    A clang-tools-extra/test/clang-tidy/checkers/hicpp/ignored-remove-result.cpp

  Log Message:
  -----------
  [clang-tidy] Add check hicpp-ignored-remove-result (#73119)

This check implements the [rule
17.5.1](https://www.perforce.com/resources/qac/high-integrity-cpp-coding-standard/standard-library)
of the HICPP standard which states:

- Do not ignore the result of std::remove, std::remove_if or std::unique

The mutating algorithms std::remove, std::remove_if and both overloads
of std::unique operate by swapping or moving elements of the range they
are operating over. On completion, they return an iterator to the last
valid element. In the majority of cases the correct behavior is to use
this result as the first operand in a call to std::erase.

This check is based on `bugprone-unused-return-value` but with a fixed
set of functions.

Suppressing issues by casting to `void` is enabled by default, but can
be disabled by setting `AllowCastToVoid` option to `false`.




More information about the All-commits mailing list