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.
llvm-svn: 238601
This commit is contained in:
@@ -921,13 +921,13 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
|
||||
void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {
|
||||
assert(!GV->isDeclaration() &&
|
||||
"Only globals with definition can force usage.");
|
||||
LLVMUsed.push_back(GV);
|
||||
LLVMUsed.emplace_back(GV);
|
||||
}
|
||||
|
||||
void CodeGenModule::addCompilerUsedGlobal(llvm::GlobalValue *GV) {
|
||||
assert(!GV->isDeclaration() &&
|
||||
"Only globals with definition can force usage.");
|
||||
LLVMCompilerUsed.push_back(GV);
|
||||
LLVMCompilerUsed.emplace_back(GV);
|
||||
}
|
||||
|
||||
static void emitUsed(CodeGenModule &CGM, StringRef Name,
|
||||
|
||||
Reference in New Issue
Block a user