Author: hokein Date: Tue Apr 18 15:47:34 2017 New Revision: 300588 URL: http://llvm.org/viewvc/llvm-project?rev=300588&view=rev Log: [clang-tidy] Address a few late comments.
Modified: clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp?rev=300588&r1=300587&r2=300588&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp Tue Apr 18 15:47:34 2017 @@ -99,7 +99,8 @@ void InefficientVectorOperationCheck::re 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::ch 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::ch } } - 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); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits