From: Benjamin Kramer Date: Tue, 17 Feb 2015 21:55:18 +0000 (+0000) Subject: Sema: Replace some push_backs of expensive to move objects with emplace_back. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79ec230107400a8e57bed3bbba75761d10795149;p=clang Sema: Replace some push_backs of expensive to move objects with emplace_back. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229557 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/TemplateDeduction.h b/include/clang/Sema/TemplateDeduction.h index d1aa081eee..229eb71cab 100644 --- a/include/clang/Sema/TemplateDeduction.h +++ b/include/clang/Sema/TemplateDeduction.h @@ -91,9 +91,7 @@ public: if (HasSFINAEDiagnostic) return; SuppressedDiagnostics.clear(); - SuppressedDiagnostics.push_back( - std::make_pair(Loc, PartialDiagnostic::NullDiagnostic())); - SuppressedDiagnostics.back().second.swap(PD); + SuppressedDiagnostics.emplace_back(Loc, std::move(PD)); HasSFINAEDiagnostic = true; } @@ -102,9 +100,7 @@ public: PartialDiagnostic PD) { if (HasSFINAEDiagnostic) return; - SuppressedDiagnostics.push_back( - std::make_pair(Loc, PartialDiagnostic::NullDiagnostic())); - SuppressedDiagnostics.back().second.swap(PD); + SuppressedDiagnostics.emplace_back(Loc, std::move(PD)); } /// \brief Iterator over the set of suppressed diagnostics. @@ -277,7 +273,7 @@ public: /// \brief Add a new candidate with NumConversions conversion sequence slots /// to the overload set. TemplateSpecCandidate &addCandidate() { - Candidates.push_back(TemplateSpecCandidate()); + Candidates.emplace_back(); return Candidates.back(); } diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index f23d89e3b7..21e86a11f5 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -122,9 +122,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, PP.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument, &Context); - ExprEvalContexts.push_back( - ExpressionEvaluationContextRecord(PotentiallyEvaluated, 0, - false, nullptr, false)); + ExprEvalContexts.emplace_back(PotentiallyEvaluated, 0, false, nullptr, false); FunctionScopes.push_back(new FunctionScopeInfo(Diags)); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index a9ea72577a..4b807c1058 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -11606,12 +11606,9 @@ void Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl, bool IsDecltype) { - ExprEvalContexts.push_back( - ExpressionEvaluationContextRecord(NewContext, - ExprCleanupObjects.size(), - ExprNeedsCleanups, - LambdaContextDecl, - IsDecltype)); + ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), + ExprNeedsCleanups, LambdaContextDecl, + IsDecltype); ExprNeedsCleanups = false; if (!MaybeODRUseExprs.empty()) std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs); diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 134c88fd9d..53ebdd793b 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -8118,7 +8118,7 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, bool HasArithmeticOrEnumeralCandidateType = false; SmallVector CandidateTypes; for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) { - CandidateTypes.push_back(BuiltinCandidateTypeSet(*this)); + CandidateTypes.emplace_back(*this); CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(), OpLoc, true,