diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-05-29 19:42:19 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-05-29 19:42:19 +0000 |
| commit | 3204b152b53e539304f9da2aff100876aeefa856 (patch) | |
| tree | 413a942366f5a46724c5658daf847ee3493e9f5e /clang/lib/ASTMatchers | |
| parent | 36cbc0901f7a8ac02511143f1b5e4b6478221239 (diff) | |
| download | bcm5719-llvm-3204b152b53e539304f9da2aff100876aeefa856.tar.gz bcm5719-llvm-3204b152b53e539304f9da2aff100876aeefa856.zip | |
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
Diffstat (limited to 'clang/lib/ASTMatchers')
| -rw-r--r-- | clang/lib/ASTMatchers/ASTMatchFinder.cpp | 12 | ||||
| -rw-r--r-- | clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp index c5f3063fb4f..e3b666ef42a 100644 --- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -912,37 +912,37 @@ MatchFinder::~MatchFinder() {} void MatchFinder::addMatcher(const DeclarationMatcher &NodeMatch, MatchCallback *Action) { - Matchers.DeclOrStmt.push_back(std::make_pair(NodeMatch, Action)); + Matchers.DeclOrStmt.emplace_back(NodeMatch, Action); Matchers.AllCallbacks.push_back(Action); } void MatchFinder::addMatcher(const TypeMatcher &NodeMatch, MatchCallback *Action) { - Matchers.Type.push_back(std::make_pair(NodeMatch, Action)); + Matchers.Type.emplace_back(NodeMatch, Action); Matchers.AllCallbacks.push_back(Action); } void MatchFinder::addMatcher(const StatementMatcher &NodeMatch, MatchCallback *Action) { - Matchers.DeclOrStmt.push_back(std::make_pair(NodeMatch, Action)); + Matchers.DeclOrStmt.emplace_back(NodeMatch, Action); Matchers.AllCallbacks.push_back(Action); } void MatchFinder::addMatcher(const NestedNameSpecifierMatcher &NodeMatch, MatchCallback *Action) { - Matchers.NestedNameSpecifier.push_back(std::make_pair(NodeMatch, Action)); + Matchers.NestedNameSpecifier.emplace_back(NodeMatch, Action); Matchers.AllCallbacks.push_back(Action); } void MatchFinder::addMatcher(const NestedNameSpecifierLocMatcher &NodeMatch, MatchCallback *Action) { - Matchers.NestedNameSpecifierLoc.push_back(std::make_pair(NodeMatch, Action)); + Matchers.NestedNameSpecifierLoc.emplace_back(NodeMatch, Action); Matchers.AllCallbacks.push_back(Action); } void MatchFinder::addMatcher(const TypeLocMatcher &NodeMatch, MatchCallback *Action) { - Matchers.TypeLoc.push_back(std::make_pair(NodeMatch, Action)); + Matchers.TypeLoc.emplace_back(NodeMatch, Action); Matchers.AllCallbacks.push_back(Action); } diff --git a/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp b/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp index f6d34494dec..72f127185ef 100644 --- a/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp @@ -14,7 +14,7 @@ namespace ast_matchers { namespace dynamic { Diagnostics::ArgStream Diagnostics::pushContextFrame(ContextType Type, SourceRange Range) { - ContextStack.push_back(ContextFrame()); + ContextStack.emplace_back(); ContextFrame& data = ContextStack.back(); data.Type = Type; data.Range = Range; @@ -65,10 +65,10 @@ Diagnostics::ArgStream &Diagnostics::ArgStream::operator<<(const Twine &Arg) { Diagnostics::ArgStream Diagnostics::addError(const SourceRange &Range, ErrorType Error) { - Errors.push_back(ErrorContent()); + Errors.emplace_back(); ErrorContent &Last = Errors.back(); Last.ContextStack = ContextStack; - Last.Messages.push_back(ErrorContent::Message()); + Last.Messages.emplace_back(); Last.Messages.back().Range = Range; Last.Messages.back().Type = Error; return ArgStream(&Last.Messages.back().Args); |

