summaryrefslogtreecommitdiff
path: root/utils/FileCheck
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-05-29 19:43:39 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-05-29 19:43:39 +0000
commit9589ff8949271fe1f1e832040decbcd881b7ccf6 (patch)
tree99c97bbad680133fc876b737b4507e2f9a178fb6 /utils/FileCheck
parent071c3df3781138b275677b5e1f7dfe07760c6ca2 (diff)
Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types
If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238602 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/FileCheck')
-rw-r--r--utils/FileCheck/FileCheck.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp
index 8fe2f88a3e7..9b9ffb04906 100644
--- a/utils/FileCheck/FileCheck.cpp
+++ b/utils/FileCheck/FileCheck.cpp
@@ -946,10 +946,7 @@ static bool ReadCheckFile(SourceMgr &SM,
}
// Okay, add the string we captured to the output vector and move on.
- CheckStrings.push_back(CheckString(P,
- UsedPrefix,
- PatternLoc,
- CheckTy));
+ CheckStrings.emplace_back(P, UsedPrefix, PatternLoc, CheckTy);
std::swap(DagNotMatches, CheckStrings.back().DagNotStrings);
DagNotMatches = ImplicitNegativeChecks;
}
@@ -957,10 +954,9 @@ static bool ReadCheckFile(SourceMgr &SM,
// Add an EOF pattern for any trailing CHECK-DAG/-NOTs, and use the first
// prefix as a filler for the error message.
if (!DagNotMatches.empty()) {
- CheckStrings.push_back(CheckString(Pattern(Check::CheckEOF),
- *CheckPrefixes.begin(),
- SMLoc::getFromPointer(Buffer.data()),
- Check::CheckEOF));
+ CheckStrings.emplace_back(Pattern(Check::CheckEOF), *CheckPrefixes.begin(),
+ SMLoc::getFromPointer(Buffer.data()),
+ Check::CheckEOF);
std::swap(DagNotMatches, CheckStrings.back().DagNotStrings);
}