[all-commits] [llvm/llvm-project] 671ad5: [clang-tidy] performance-unnecessary-copy-initiali...

Felix Berger via All-commits all-commits at lists.llvm.org
Thu Dec 10 13:58:54 PST 2020


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 671ad580610ad91139358b7786e02ff70433a90e
      https://github.com/llvm/llvm-project/commit/671ad580610ad91139358b7786e02ff70433a90e
  Author: Felix Berger <flx at google.com>
  Date:   2020-12-10 (Thu, 10 Dec 2020)

  Changed paths:
    M clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
    M clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
    M clang-tools-extra/clang-tidy/utils/Matchers.h
    M clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

  Log Message:
  -----------
  [clang-tidy] performance-unnecessary-copy-initialization: Prevent false positives when dependent variable is modified.

Extend the check to not only look at the variable the unnecessarily copied
variable is initialized from, but also ensure that any variable the old variable
references is not modified.

Extend DeclRefExprUtils to also count references and pointers to const assigned
from the DeclRef we check for const usages.

Reviewed-by: aaron.ballman

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




More information about the All-commits mailing list