[clang-tidy] ExprMutationAnalyzer: construct from references. Fixes PR38888
authorRoman Lebedev <lebedev.ri@gmail.com>
Mon, 10 Sep 2018 19:59:18 +0000 (19:59 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Mon, 10 Sep 2018 19:59:18 +0000 (19:59 +0000)
commita3dc9484e3588f55907e87f0d36e605b9989a4d5
tree76d334011928a0fc2e1dab5526926ed7398323ca
parent4d2dff01482ffb7708db699fc4ab294be7eaf715
[clang-tidy] ExprMutationAnalyzer: construct from references. Fixes PR38888

Summary:
I have hit this the rough way, while trying to use this in D51870.

There is no particular point in storing the pointers, and moreover
the pointers are assumed to be non-null, and that assumption is not
enforced. If they are null, it won't be able to do anything good
with them anyway.

Initially i thought about simply adding asserts() that they are
not null, but taking/storing references looks like even cleaner solution?

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=38888 | PR38888 ]]

Reviewers: JonasToth, shuaiwang, alexfh, george.karpenkov

Reviewed By: shuaiwang

Subscribers: xazax.hun, a.sidorin, Szelethus, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 341854
clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.cpp
clang-tools-extra/clang-tidy/utils/ExprMutationAnalyzer.h
clang-tools-extra/unittests/clang-tidy/ExprMutationAnalyzerTest.cpp