diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp index 4a8f292..a59ab33 100644 --- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp @@ -208,7 +208,7 @@ void InefficientVectorOperationCheck::check( if (!TargetVarDecl) TargetVarDecl = ProtoVarDecl; - llvm::SmallPtrSet<const DeclRefExpr *, 16> AllVarRefs = + const llvm::SmallPtrSet<const DeclRefExpr *, 16> AllVarRefs = utils::decl_ref_expr::allDeclRefExprs(*TargetVarDecl, *LoopParent, *Context); for (const auto *Ref : AllVarRefs) { @@ -231,12 +231,12 @@ void InefficientVectorOperationCheck::check( } else { llvm::StringRef FieldName = ProtoAddFieldCall->getMethodDecl()->getName(); FieldName.consume_front("add_"); - std::string MutableFieldName = ("mutable_" + FieldName).str(); + const std::string MutableFieldName = ("mutable_" + FieldName).str(); PartialReserveStmt = "." + MutableFieldName + "()->Reserve"; // e.g., ".mutable_xxx()->Reserve" } - llvm::StringRef VarName = Lexer::getSourceText( + const llvm::StringRef VarName = Lexer::getSourceText( CharSourceRange::getTokenRange( AppendCall->getImplicitObjectArgument()->getSourceRange()), SM, Context->getLangOpts()); @@ -246,14 +246,14 @@ void InefficientVectorOperationCheck::check( if (RangeLoop) { // Get the range-expression in a for-range statement represented as // `for (range-declarator: range-expression)`. - StringRef RangeInitExpName = + const StringRef RangeInitExpName = Lexer::getSourceText(CharSourceRange::getTokenRange( RangeLoop->getRangeInit()->getSourceRange()), SM, Context->getLangOpts()); ReserveSize = (RangeInitExpName + ".size()").str(); } else if (ForLoop) { // Handle counter-based loop cases. - StringRef LoopEndSource = Lexer::getSourceText( + const StringRef LoopEndSource = Lexer::getSourceText( CharSourceRange::getTokenRange(LoopEndExpr->getSourceRange()), SM, Context->getLangOpts()); ReserveSize = std::string(LoopEndSource); @@ -264,7 +264,7 @@ void InefficientVectorOperationCheck::check( "container capacity before the loop") << AppendCall->getMethodDecl()->getDeclName(); if (!ReserveSize.empty()) { - std::string ReserveStmt = + const std::string ReserveStmt = (VarName + PartialReserveStmt + "(" + ReserveSize + ");\n").str(); Diag << FixItHint::CreateInsertion(LoopStmt->getBeginLoc(), ReserveStmt); } |
