diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp index c5bbcdb23c5..c840bd61891 100644 --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -162,15 +162,18 @@ void UnnecessaryValueParamCheck::check(const MatchFinder::MatchResult &Result) { // 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); + if (!CurrentParam.getType().getCanonicalType().isConstQualified()) { + if (llvm::Optional<FixItHint> Fix = utils::fixit::addQualifierToVarDecl( + CurrentParam, *Result.Context, DeclSpec::TQ::TQ_const)) + Diag << *Fix; + } } } void UnnecessaryValueParamCheck::registerPPCallbacks( const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) { Inserter = std::make_unique<utils::IncludeInserter>(SM, getLangOpts(), - IncludeStyle); + IncludeStyle); PP->addPPCallbacks(Inserter->CreatePPCallbacks()); } |