[clang-tools-extra] r300588 - [clang-tidy] Address a few late comments.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 18 16:46:39 PDT 2017
Thanks! One nit: StringRef doesn't need to be qualified.
On Apr 18, 2017 11:00 PM, "Haojian Wu via cfe-commits" <
cfe-commits at lists.llvm.org> wrote:
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/InefficientVectorOperationChec
k.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 at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170419/ae871f59/attachment.html>
More information about the cfe-commits
mailing list