[clang-tidy] performance-unnecessary-copy-initialization: Directly examine the initia...
authorFelix Berger <flx@google.com>
Mon, 24 May 2021 13:45:24 +0000 (09:45 -0400)
committerFelix Berger <flx@google.com>
Fri, 18 Jun 2021 19:25:17 +0000 (15:25 -0400)
commitbdd5da9dec61072f693726d9ed2a94c78e431ba2
tree500035edf1b6f6a94b64f7db40c63a020d462bd5
parentac87133f1de902bcc7ab4330e7ac79b2ba376d34
[clang-tidy] performance-unnecessary-copy-initialization: Directly examine the initializing var's initializer.

This fixes false positive cases where a reference is initialized outside of a
block statement and then its initializing variable is modified. Another case is
when the looped over container is modified.

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

Reviewed-by: ymandel
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp