[all-commits] [llvm/llvm-project] 46ae26: [clang-tidy] implement new check 'misc-const-corre...

Jonas Toth via All-commits all-commits at lists.llvm.org
Sun Jul 24 10:39:13 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 46ae26e7eb7095faeda6d6c15470c256f9294c48
      https://github.com/llvm/llvm-project/commit/46ae26e7eb7095faeda6d6c15470c256f9294c48
  Author: Jonas Toth <development at jonas-toth.eu>
  Date:   2022-07-24 (Sun, 24 Jul 2022)

  Changed paths:
    M clang-tools-extra/clang-tidy/misc/CMakeLists.txt
    A clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
    A clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
    M clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/docs/clang-tidy/checks/list.rst
    A clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
    A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-cxx17.cpp
    A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp
    A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-templates.cpp
    A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-pointer-as-values.cpp
    A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-transform-values.cpp
    A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-unaligned.cpp
    A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
    A clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-wrong-config.cpp
    M clang/lib/Analysis/ExprMutationAnalyzer.cpp
    M clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp

  Log Message:
  -----------
  [clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

This patch connects the check for const-correctness with the new general
utility to add `const` to variables.
The code-transformation is only done, if the detected variable for const-ness
is not part of a group-declaration.

The check allows to control multiple facets of adding `const`, e.g. if pointers themself should be
marked as `const` if they are not changed.

Reviewed By: njames93

Differential Revision: https://reviews.llvm.org/D54943




More information about the All-commits mailing list