diff options
author | Felix Berger <flx@google.com> | 2016-07-05 14:40:44 +0000 |
---|---|---|
committer | Felix Berger <flx@google.com> | 2016-07-05 14:40:44 +0000 |
commit | a9ec0ac72f6f9dff9afbcb3adc3d29eb085acb58 (patch) | |
tree | 5048a09a85adb67c4c9e18abbb3f4ec2fe5b52c3 /clang-tidy/performance | |
parent | 3979e83d5a51f469186e5e23c31284a070791e23 (diff) |
[clang-tidy] UnnecessaryValueParamCheck - only warn for virtual methods
Summary:
As changing virtual methods could break method overrides disable applying the fix and just warn.
Reviewers: alexfh, sbenza
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D21936
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@274552 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/performance')
-rw-r--r-- | clang-tidy/performance/UnnecessaryValueParamCheck.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tidy/performance/UnnecessaryValueParamCheck.cpp index d3e4c7fb..71dc4551 100644 --- a/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -118,8 +118,10 @@ void UnnecessaryValueParamCheck::check(const MatchFinder::MatchResult &Result) { "invocation but only used as a const reference; " "consider making it a const reference") << paramNameOrIndex(Param->getName(), Index); - // Do not propose fixes in macros since we cannot place them correctly. - if (Param->getLocStart().isMacroID()) + // Do not propose fixes in macros since we cannot place them correctly, or if + // function is virtual as it might break overrides. + const auto *Method = llvm::dyn_cast<CXXMethodDecl>(Function); + if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual())) return; for (const auto *FunctionDecl = Function; FunctionDecl != nullptr; FunctionDecl = FunctionDecl->getPreviousDecl()) { |