diff options
author | Haojian Wu <hokein@google.com> | 2017-04-18 20:47:34 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2017-04-18 20:47:34 +0000 |
commit | 7cdb374d6060d4f5584d5a5c4764b9e8ad74bc16 (patch) | |
tree | 784fa757142ea82e177a775b055eafbf1fda9e72 /clang-tidy/performance | |
parent | 400a84d86d1b22ed5410320341766b906409b54f (diff) |
[clang-tidy] Address a few late comments.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@300588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/performance')
-rw-r--r-- | clang-tidy/performance/InefficientVectorOperationCheck.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/clang-tidy/performance/InefficientVectorOperationCheck.cpp b/clang-tidy/performance/InefficientVectorOperationCheck.cpp index be9b1e31..a2207d39 100644 --- a/clang-tidy/performance/InefficientVectorOperationCheck.cpp +++ b/clang-tidy/performance/InefficientVectorOperationCheck.cpp @@ -99,7 +99,8 @@ void InefficientVectorOperationCheck::registerMatchers(MatchFinder *Finder) { void InefficientVectorOperationCheck::check( const MatchFinder::MatchResult &Result) { - if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred()) + auto* Context = Result.Context; + if (Context->getDiagnostics().hasUncompilableErrorOccurred()) return; const SourceManager &SM = *Result.SourceManager; @@ -113,7 +114,7 @@ void InefficientVectorOperationCheck::check( llvm::SmallPtrSet<const DeclRefExpr *, 16> AllVectorVarRefs = utils::decl_ref_expr::allDeclRefExprs(*VectorVarDecl, *LoopParent, - *Result.Context); + *Context); for (const auto *Ref : AllVectorVarRefs) { // Skip cases where there are usages (defined as DeclRefExpr that refers to // "v") of vector variable `v` before the for loop. We consider these usages @@ -128,19 +129,19 @@ void InefficientVectorOperationCheck::check( } } - llvm::StringRef LoopEndSource = clang::Lexer::getSourceText( + llvm::StringRef LoopEndSource = Lexer::getSourceText( CharSourceRange::getTokenRange(LoopEndExpr->getSourceRange()), SM, - clang::LangOptions()); - llvm::StringRef VectorVarName = clang::Lexer::getSourceText( + Context->getLangOpts()); + llvm::StringRef VectorVarName = Lexer::getSourceText( CharSourceRange::getTokenRange( PushBackCall->getImplicitObjectArgument()->getSourceRange()), - SM, clang::LangOptions()); + SM, Context->getLangOpts()); std::string ReserveStmt = (VectorVarName + ".reserve(" + LoopEndSource + ");\n").str(); diag(PushBackCall->getLocStart(), "'push_back' is called inside a loop; " - "consider pre-allocating the vector capacity before the loop.") + "consider pre-allocating the vector capacity before the loop") << FixItHint::CreateInsertion(ForLoop->getLocStart(), ReserveStmt); } |