diff options
author | Felix Berger <flx@google.com> | 2016-11-04 20:51:31 +0000 |
---|---|---|
committer | Felix Berger <flx@google.com> | 2016-11-04 20:51:31 +0000 |
commit | c73878412b8e354281c148caf02cc3ce254b5886 (patch) | |
tree | 2567b83b0ffe849b40ec16669d71d0cbf749477c /clang-tidy/performance | |
parent | 9db711c3358335e494f3bc0b4e66a03e46f0d805 (diff) |
[ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified
Reviewers: alexfh, sbenza, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26207
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@286010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/performance')
-rw-r--r-- | clang-tidy/performance/UnnecessaryValueParamCheck.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tidy/performance/UnnecessaryValueParamCheck.cpp index f00133c4..1d229cf1 100644 --- a/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -128,7 +128,10 @@ void UnnecessaryValueParamCheck::check(const MatchFinder::MatchResult &Result) { const auto &CurrentParam = *FunctionDecl->getParamDecl(Index); Diag << utils::fixit::changeVarDeclToReference(CurrentParam, *Result.Context); - if (!IsConstQualified) + // The parameter of each declaration needs to be checked individually as to + // whether it is const or not as constness can differ between definition and + // declaration. + if (!CurrentParam.getType().getCanonicalType().isConstQualified()) Diag << utils::fixit::changeVarDeclToConst(CurrentParam); } } |