llvm-project/clang/lib/ASTMatchers
Benjamin Kramer 3204b152b5 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
2015-05-29 19:42:19 +00:00
..
Dynamic Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types 2015-05-29 19:42:19 +00:00
ASTMatchFinder.cpp Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types 2015-05-29 19:42:19 +00:00
ASTMatchersInternal.cpp Make the function pointer a template argument instead of a runtime value. 2014-12-01 14:46:14 +00:00
CMakeLists.txt ASTMatchers: Add an explicit dependency on libclangBasic. 2015-03-12 16:25:19 +00:00
Makefile First revision of the dynamic ASTMatcher library. 2013-05-14 09:13:00 +00:00