]> granicus.if.org Git - clang/commitdiff
Sema: Replace some push_backs of expensive to move objects with emplace_back.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 17 Feb 2015 21:55:18 +0000 (21:55 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 17 Feb 2015 21:55:18 +0000 (21:55 +0000)
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229557 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/TemplateDeduction.h
lib/Sema/Sema.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaOverload.cpp

index d1aa081eee6133d9e437afb4a7e0f5deb42eb119..229eb71cabc15e5483c1630dadeda8743b2b1cae 100644 (file)
@@ -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();
   }
 
index f23d89e3b79c025674b11a658f835ac9f40d7906..21e86a11f5dd85be40df1586fc2cb065db1a1971 100644 (file)
@@ -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));
 
index a9ea72577ab53cd524ff5c33e464046f367a59da..4b807c1058135e97593d23c6498541c8878cd1f9 100644 (file)
@@ -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);
index 134c88fd9de0457fa55637faf2f5d1c62ded660c..53ebdd793b70a009150271d808ec645b6c9d1090 100644 (file)
@@ -8118,7 +8118,7 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   bool HasArithmeticOrEnumeralCandidateType = false;
   SmallVector<BuiltinCandidateTypeSet, 2> 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,