Index: lib/ARCMigrate/TransGCAttrs.cpp =================================================================== --- lib/ARCMigrate/TransGCAttrs.cpp +++ lib/ARCMigrate/TransGCAttrs.cpp @@ -109,7 +109,7 @@ return false; MigrateCtx.AttrSet.insert(RawLoc); - MigrateCtx.GCAttrs.push_back(MigrationContext::GCAttrOccurrence()); + MigrateCtx.GCAttrs.emplace_back(); MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs.back(); Attr.Kind = Kind; Index: lib/ARCMigrate/TransProperties.cpp =================================================================== --- lib/ARCMigrate/TransProperties.cpp +++ lib/ARCMigrate/TransProperties.cpp @@ -84,7 +84,7 @@ if (PrevAtProps->find(RawLoc) != PrevAtProps->end()) continue; PropsTy &props = AtProps[RawLoc]; - props.push_back(Prop); + props.emplace_back(Prop); } } Index: lib/AST/ASTContext.cpp =================================================================== --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -811,7 +811,7 @@ } void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) { - Deallocations.push_back({Callback, Data}); + Deallocations.emplace_back(Callback, Data); } void Index: lib/AST/ASTDiagnostic.cpp =================================================================== --- lib/AST/ASTDiagnostic.cpp +++ lib/AST/ASTDiagnostic.cpp @@ -111,7 +111,7 @@ for (unsigned I = 0, N = TST->getNumArgs(); I != N; ++I) { const TemplateArgument &Arg = TST->getArg(I); if (Arg.getKind() == TemplateArgument::Type) - Args.push_back(Desugar(Context, Arg.getAsType(), DesugarArgument)); + Args.emplace_back(Desugar(Context, Arg.getAsType(), DesugarArgument)); else Args.push_back(Arg); } Index: lib/AST/CommentParser.cpp =================================================================== --- lib/AST/CommentParser.cpp +++ lib/AST/CommentParser.cpp @@ -444,8 +444,8 @@ Token Ident = Tok; consumeToken(); if (Tok.isNot(tok::html_equals)) { - Attrs.push_back(HTMLStartTagComment::Attribute(Ident.getLocation(), - Ident.getHTMLIdent())); + Attrs.emplace_back(Ident.getLocation(), + Ident.getHTMLIdent()); continue; } Token Equals = Tok; @@ -454,20 +454,20 @@ Diag(Tok.getLocation(), diag::warn_doc_html_start_tag_expected_quoted_string) << SourceRange(Equals.getLocation()); - Attrs.push_back(HTMLStartTagComment::Attribute(Ident.getLocation(), - Ident.getHTMLIdent())); + Attrs.emplace_back(Ident.getLocation(), + Ident.getHTMLIdent()); while (Tok.is(tok::html_equals) || Tok.is(tok::html_quoted_string)) consumeToken(); continue; } - Attrs.push_back(HTMLStartTagComment::Attribute( + Attrs.emplace_back( Ident.getLocation(), Ident.getHTMLIdent(), Equals.getLocation(), SourceRange(Tok.getLocation(), Tok.getEndLocation()), - Tok.getHTMLQuotedString())); + Tok.getHTMLQuotedString()); consumeToken(); continue; } Index: lib/AST/DeclObjC.cpp =================================================================== --- lib/AST/DeclObjC.cpp +++ lib/AST/DeclObjC.cpp @@ -1558,8 +1558,8 @@ SmallVector layout; for (auto *IV : ImplDecl->ivars()) { if (IV->getSynthesize() && !IV->isInvalidDecl()) { - layout.push_back(SynthesizeIvarChunk( - IV->getASTContext().getTypeSize(IV->getType()), IV)); + layout.emplace_back( + IV->getASTContext().getTypeSize(IV->getType()), IV); continue; } if (!data().IvarList) Index: lib/AST/ExprConstant.cpp =================================================================== --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -968,7 +968,7 @@ bool IsLifetimeExtended) { APValue &Result = Temporaries[Key]; assert(Result.isUninit() && "temporary created multiple times"); - Info.CleanupStack.push_back(Cleanup(&Result, IsLifetimeExtended)); + Info.CleanupStack.emplace_back(&Result, IsLifetimeExtended); return Result; } Index: lib/AST/VTTBuilder.cpp =================================================================== --- lib/AST/VTTBuilder.cpp +++ lib/AST/VTTBuilder.cpp @@ -46,11 +46,11 @@ } if (!GenerateDefinition) { - VTTComponents.push_back(VTTComponent()); + VTTComponents.emplace_back(); return; } - VTTComponents.push_back(VTTComponent(VTableIndex, Base)); + VTTComponents.emplace_back(VTableIndex, Base); } void VTTBuilder::LayoutSecondaryVTTs(BaseSubobject Base) { @@ -190,7 +190,7 @@ } uint64_t VTableIndex = VTTVTables.size(); - VTTVTables.push_back(VTTVTable(Base, BaseIsVirtual)); + VTTVTables.emplace_back(Base, BaseIsVirtual); // Add the primary vtable pointer. AddVTablePointer(Base, VTableIndex, RD); Index: lib/AST/VTableBuilder.cpp =================================================================== --- lib/AST/VTableBuilder.cpp +++ lib/AST/VTableBuilder.cpp @@ -515,7 +515,7 @@ } // Add the offset. - Offsets.push_back(MethodAndOffsetPairTy(MD, OffsetOffset)); + Offsets.emplace_back(MD, OffsetOffset); return true; } Index: lib/Analysis/BlockFrequencyInfoImpl.cpp =================================================================== --- lib/Analysis/BlockFrequencyInfoImpl.cpp +++ lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -113,7 +113,7 @@ Total = NewTotal; // Save the weight. - Weights.push_back(Weight(Type, Node, Amount)); + Weights.emplace_back(Type, Node, Amount); } static void combineWeight(Weight &W, const Weight &OtherW) { Index: lib/Analysis/CFG.cpp =================================================================== --- lib/Analysis/CFG.cpp +++ lib/Analysis/CFG.cpp @@ -2368,7 +2368,7 @@ if (I == LabelMap.end()) // We will need to backpatch this block later. - BackpatchBlocks.push_back(JumpSource(Block, ScopePos)); + BackpatchBlocks.emplace_back(Block, ScopePos); else { JumpTarget JT = I->second; addAutomaticObjDtors(ScopePos, JT.scopePosition, G); Index: lib/Analysis/EHPersonalities.cpp =================================================================== --- lib/Analysis/EHPersonalities.cpp +++ lib/Analysis/EHPersonalities.cpp @@ -66,7 +66,7 @@ DEBUG_WITH_TYPE("winehprepare-coloring", dbgs() << "\nColoring funclets for " << F.getName() << "\n"); - Worklist.push_back({EntryBlock, EntryBlock}); + Worklist.emplace_back(EntryBlock, EntryBlock); while (!Worklist.empty()) { BasicBlock *Visiting; @@ -103,7 +103,7 @@ } for (BasicBlock *Succ : successors(Visiting)) - Worklist.push_back({Succ, SuccColor}); + Worklist.emplace_back(Succ, SuccColor); } return BlockColors; } Index: lib/Analysis/LazyCallGraph.cpp =================================================================== --- lib/Analysis/LazyCallGraph.cpp +++ lib/Analysis/LazyCallGraph.cpp @@ -545,7 +545,7 @@ RootN->DFSNumber = RootN->LowLink = 1; int NextDFSNumber = 2; - DFSStack.push_back({RootN, RootN->call_begin()}); + DFSStack.emplace_back(RootN, RootN->call_begin()); do { Node *N; call_edge_iterator I; @@ -556,7 +556,7 @@ if (ChildN.DFSNumber == 0) { // We haven't yet visited this child, so descend, pushing the current // node onto the stack. - DFSStack.push_back({N, I}); + DFSStack.emplace_back(N, I); assert(!G->SCCMap.count(&ChildN) && "Found a node with 0 DFS number but already in an SCC!"); @@ -770,7 +770,7 @@ SmallVector, 8> DFSStack; SmallPtrSet Visited; int ConnectedDepth = -1; - DFSStack.push_back({&SourceC, SourceC.parent_begin()}); + DFSStack.emplace_back(&SourceC, SourceC.parent_begin()); do { auto DFSPair = DFSStack.pop_back_val(); RefSCC *C = DFSPair.first; @@ -795,7 +795,7 @@ // We fully explore the depth-first space, adding nodes to the connected // set only as we pop them off, so "recurse" by rotating to the parent. - DFSStack.push_back({C, I}); + DFSStack.emplace_back(C, I); C = &Parent; I = C->parent_begin(); E = C->parent_end(); @@ -1023,7 +1023,7 @@ RootN->DFSNumber = RootN->LowLink = 1; int NextDFSNumber = 2; - DFSStack.push_back({RootN, RootN->begin()}); + DFSStack.emplace_back(RootN, RootN->begin()); do { Node *N; edge_iterator I; @@ -1039,7 +1039,7 @@ // Mark that we should start at this child when next this node is the // top of the stack. We don't start at the next child to ensure this // child's lowlink is reflected. - DFSStack.push_back({N, I}); + DFSStack.emplace_back(N, I); // Continue, resetting to the child node. ChildN.LowLink = ChildN.DFSNumber = NextDFSNumber++; @@ -1305,7 +1305,7 @@ RootN->DFSNumber = RootN->LowLink = 1; int NextDFSNumber = 2; - DFSStack.push_back({RootN, RootN->call_begin()}); + DFSStack.emplace_back(RootN, RootN->call_begin()); do { Node *N; call_edge_iterator I; @@ -1316,7 +1316,7 @@ if (ChildN.DFSNumber == 0) { // We haven't yet visited this child, so descend, pushing the current // node onto the stack. - DFSStack.push_back({N, I}); + DFSStack.emplace_back(N, I); assert(!lookupSCC(ChildN) && "Found a node with 0 DFS number but already in an SCC!"); @@ -1419,7 +1419,7 @@ // Found a new root, begin the DFS here. N->LowLink = N->DFSNumber = 1; NextDFSNumber = 2; - DFSStack.push_back({N, N->begin()}); + DFSStack.emplace_back(N, N->begin()); } for (;;) { @@ -1436,7 +1436,7 @@ if (ChildN.DFSNumber == 0) { // We haven't yet visited this child, so descend, pushing the current // node onto the stack. - DFSStack.push_back({N, N->begin()}); + DFSStack.emplace_back(N, N->begin()); assert(!SCCMap.count(&ChildN) && "Found a node with 0 DFS number but already in an SCC!"); Index: lib/Analysis/LoopAccessAnalysis.cpp =================================================================== --- lib/Analysis/LoopAccessAnalysis.cpp +++ lib/Analysis/LoopAccessAnalysis.cpp @@ -1404,7 +1404,7 @@ // algorithm. if (RecordDependences) { if (Type != Dependence::NoDep) - Dependences.push_back(Dependence(A.second, B.second, Type)); + Dependences.emplace_back(A.second, B.second, Type); if (Dependences.size() >= MaxDependences) { RecordDependences = false; Index: lib/Analysis/MemoryDependenceAnalysis.cpp =================================================================== --- lib/Analysis/MemoryDependenceAnalysis.cpp +++ lib/Analysis/MemoryDependenceAnalysis.cpp @@ -853,7 +853,7 @@ if (ExistingResult) ExistingResult->setResult(Dep); else - Cache.push_back(NonLocalDepEntry(DirtyBB, Dep)); + Cache.emplace_back(DirtyBB, Dep); // If the block has a dependency (i.e. it isn't completely transparent to // the value), remember the association! Index: lib/Basic/Diagnostic.cpp =================================================================== --- lib/Basic/Diagnostic.cpp +++ lib/Basic/Diagnostic.cpp @@ -135,7 +135,7 @@ // Create a DiagState and DiagStatePoint representing diagnostic changes // through command-line. DiagStates.emplace_back(); - DiagStatePoints.push_back(DiagStatePoint(&DiagStates.back(), FullSourceLoc())); + DiagStatePoints.emplace_back(&DiagStates.back(), FullSourceLoc()); } void DiagnosticsEngine::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1, Index: lib/Basic/Module.cpp =================================================================== --- lib/Basic/Module.cpp +++ lib/Basic/Module.cpp @@ -125,7 +125,7 @@ // Build up the set of module names (from innermost to outermost). for (const Module *M = this; M; M = M->Parent) - Names.push_back(M->Name); + Names.emplace_back(M->Name); std::string Result; for (SmallVectorImpl::reverse_iterator I = Names.rbegin(), Index: lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- lib/Bitcode/Reader/BitcodeReader.cpp +++ lib/Bitcode/Reader/BitcodeReader.cpp @@ -2478,7 +2478,7 @@ // Move the Upgrade the list of subprograms. if (Metadata *SPs = getMDOrNullWithoutPlaceholders(Record[11])) - CUSubprograms.push_back({CU, SPs}); + CUSubprograms.emplace_back(CU, SPs); break; } case bitc::METADATA_SUBPROGRAM: { @@ -3900,7 +3900,7 @@ UnnamedAddr = getDecodedUnnamedAddrType(Record[9]); Func->setUnnamedAddr(UnnamedAddr); if (Record.size() > 10 && Record[10] != 0) - FunctionPrologues.push_back(std::make_pair(Func, Record[10]-1)); + FunctionPrologues.emplace_back(std::make_pair(Func, Record[10]-1)); if (Record.size() > 11) Func->setDLLStorageClass(getDecodedDLLStorageClass(Record[11])); @@ -3918,10 +3918,10 @@ } if (Record.size() > 13 && Record[13] != 0) - FunctionPrefixes.push_back(std::make_pair(Func, Record[13]-1)); + FunctionPrefixes.emplace_back(std::make_pair(Func, Record[13]-1)); if (Record.size() > 14 && Record[14] != 0) - FunctionPersonalityFns.push_back(std::make_pair(Func, Record[14] - 1)); + FunctionPersonalityFns.emplace_back(std::make_pair(Func, Record[14] - 1)); ValueList.push_back(Func); @@ -3986,7 +3986,7 @@ if (OpNum != Record.size()) NewGA->setUnnamedAddr(getDecodedUnnamedAddrType(Record[OpNum++])); ValueList.push_back(NewGA); - IndirectSymbolInits.push_back(std::make_pair(NewGA, Val)); + IndirectSymbolInits.emplace_back(std::make_pair(NewGA, Val)); break; } /// MODULE_CODE_PURGEVALS: [numvals] Index: lib/Bitcode/Writer/ValueEnumerator.cpp =================================================================== --- lib/Bitcode/Writer/ValueEnumerator.cpp +++ lib/Bitcode/Writer/ValueEnumerator.cpp @@ -146,7 +146,7 @@ for (const Use &U : V->uses()) // Check if this user will be serialized. if (OM.lookup(U.getUser()).first) - List.push_back(std::make_pair(&U, List.size())); + List.emplace_back(std::make_pair(&U, List.size())); if (List.size() < 2) // We may have lost some users. @@ -603,7 +603,7 @@ if (Op->isDistinct() && !N->isDistinct()) DelayedDistinctNodes.push_back(Op); else - Worklist.push_back(std::make_pair(Op, Op->op_begin())); + Worklist.emplace_back(std::make_pair(Op, Op->op_begin())); continue; } Index: lib/CodeGen/Analysis.cpp =================================================================== --- lib/CodeGen/Analysis.cpp +++ lib/CodeGen/Analysis.cpp @@ -746,8 +746,7 @@ // they could be inside a finally block. const MachineBasicBlock *Successor = MBBI->getOperand(0).getMBB(); const MachineBasicBlock *SuccessorColor = MBBI->getOperand(1).getMBB(); - CatchRetSuccessors.push_back( - {Successor, IsSEH ? EntryBBNumber : SuccessorColor->getNumber()}); + CatchRetSuccessors.emplace_back(Successor, IsSEH ? EntryBBNumber : SuccessorColor->getNumber()); } // We don't have anything to do if there aren't any EH pads. Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -254,7 +254,7 @@ if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) { DD = new DwarfDebug(this, &M); DD->beginModule(); - Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName)); + Handlers.emplace_back(DD, DbgTimerName, DWARFGroupName); } } @@ -282,7 +282,7 @@ break; } if (ES) - Handlers.push_back(HandlerInfo(ES, EHTimerName, DWARFGroupName)); + Handlers.emplace_back(ES, EHTimerName, DWARFGroupName); return false; } @@ -1612,7 +1612,7 @@ break; // Found a null terminator, skip the rest. ConstantInt *Priority = dyn_cast(CS->getOperand(0)); if (!Priority) continue; // Malformed. - Structors.push_back(Structor()); + Structors.emplace_back(); Structor &S = Structors.back(); S.Priority = Priority->getLimitedValue(65535); S.Func = CS->getOperand(1); Index: lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp +++ lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp @@ -47,7 +47,7 @@ << "\t" << Ranges.back().first << "\t" << MI << "\n"); return; } - Ranges.push_back(std::make_pair(&MI, nullptr)); + Ranges.emplace_back(std::make_pair(&MI, nullptr)); } void DbgValueHistoryMap::endInstrRange(InlinedVariable Var, Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -417,8 +417,8 @@ SmallVector List; List.reserve(Ranges.size()); for (const InsnRange &R : Ranges) - List.push_back(RangeSpan(DD->getLabelBeforeInsn(R.first), - DD->getLabelAfterInsn(R.second))); + List.emplace_back(DD->getLabelBeforeInsn(R.first), + DD->getLabelAfterInsn(R.second)); attachRangesOrLowHighPC(Die, std::move(List)); } Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1587,7 +1587,7 @@ }); // Insert a final terminator. - List.push_back(SymbolCU(nullptr, Asm->OutStreamer->endSection(Section))); + List.emplace_back(nullptr, Asm->OutStreamer->endSection(Section)); // Build spans between each label. const MCSymbol *StartSym = List[0].Sym; Index: lib/CodeGen/BranchFolding.cpp =================================================================== --- lib/CodeGen/BranchFolding.cpp +++ lib/CodeGen/BranchFolding.cpp @@ -687,11 +687,11 @@ SameTails.clear(); maxCommonTailLength = CommonTailLen; HighestMPIter = CurMPIter; - SameTails.push_back(SameTailElt(CurMPIter, TrialBBI1)); + SameTails.emplace_back(CurMPIter, TrialBBI1); } if (HighestMPIter == CurMPIter && CommonTailLen == maxCommonTailLength) - SameTails.push_back(SameTailElt(I, TrialBBI2)); + SameTails.emplace_back(I, TrialBBI2); } if (I == B) break; @@ -957,7 +957,7 @@ if (MergePotentials.size() == TailMergeThreshold) break; if (!TriedMerging.count(&MBB) && MBB.succ_empty()) - MergePotentials.push_back(MergePotentialsElt(HashEndOfMBB(MBB), &MBB)); + MergePotentials.emplace_back(HashEndOfMBB(MBB), &MBB); } // If this is a large problem, avoid visiting the same basic blocks @@ -1077,7 +1077,7 @@ NewCond, dl); } - MergePotentials.push_back(MergePotentialsElt(HashEndOfMBB(*PBB), PBB)); + MergePotentials.emplace_back(HashEndOfMBB(*PBB), PBB); } } Index: lib/CodeGen/CGBlocks.cpp =================================================================== --- lib/CodeGen/CGBlocks.cpp +++ lib/CodeGen/CGBlocks.cpp @@ -356,9 +356,9 @@ = CGM.getContext().getTypeInfoInChars(thisType); maxFieldAlign = std::max(maxFieldAlign, tinfo.second); - layout.push_back(BlockLayoutChunk(tinfo.second, tinfo.first, + layout.emplace_back(tinfo.second, tinfo.first, Qualifiers::OCL_None, - nullptr, llvmType)); + nullptr, llvmType); } // Next, all the block captures. @@ -373,9 +373,9 @@ CharUnits align = CGM.getPointerAlign(); maxFieldAlign = std::max(maxFieldAlign, align); - layout.push_back(BlockLayoutChunk(align, CGM.getPointerSize(), + layout.emplace_back(align, CGM.getPointerSize(), Qualifiers::OCL_None, &CI, - CGM.VoidPtrTy)); + CGM.VoidPtrTy); continue; } @@ -439,7 +439,7 @@ llvm::Type *llvmType = CGM.getTypes().ConvertTypeForMem(VT); - layout.push_back(BlockLayoutChunk(align, size, lifetime, &CI, llvmType)); + layout.emplace_back(align, size, lifetime, &CI, llvmType); } // If that was everything, we're done here. Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -1739,7 +1739,7 @@ llvm::DIType *FwdDecl = DBuilder.createReplaceableCompositeType( llvm::dwarf::DW_TAG_structure_type, ID->getName(), Mod ? Mod : TheCU, DefUnit, Line, RuntimeLang); - ObjCInterfaceCache.push_back(ObjCInterfaceCacheEntry(Ty, FwdDecl, Unit)); + ObjCInterfaceCache.emplace_back(Ty, FwdDecl, Unit); return FwdDecl; } Index: lib/CodeGen/CGExprConstant.cpp =================================================================== --- lib/CodeGen/CGExprConstant.cpp +++ lib/CodeGen/CGExprConstant.cpp @@ -455,7 +455,7 @@ assert(!Base->isVirtual() && "should not have virtual bases here"); const CXXRecordDecl *BD = Base->getType()->getAsCXXRecordDecl(); CharUnits BaseOffset = Layout.getBaseClassOffset(BD); - Bases.push_back(BaseInfo(BD, BaseOffset, BaseNo)); + Bases.emplace_back(BD, BaseOffset, BaseNo); } std::stable_sort(Bases.begin(), Bases.end()); Index: lib/CodeGen/CGExprScalar.cpp =================================================================== --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -2752,7 +2752,7 @@ llvm::PHINode *BaseCheck = Builder.CreatePHI(ValidBase->getType(), 2); BaseCheck->addIncoming(Builder.getTrue(), Orig); BaseCheck->addIncoming(ValidBase, CheckShiftBase); - Checks.push_back(std::make_pair(BaseCheck, SanitizerKind::ShiftBase)); + Checks.emplace_back(std::make_pair(BaseCheck, SanitizerKind::ShiftBase)); } assert(!Checks.empty()); Index: lib/CodeGen/CGLoopInfo.cpp =================================================================== --- lib/CodeGen/CGLoopInfo.cpp +++ lib/CodeGen/CGLoopInfo.cpp @@ -121,7 +121,7 @@ } void LoopInfoStack::push(BasicBlock *Header, llvm::DebugLoc Location) { - Active.push_back(LoopInfo(Header, StagedAttrs, Location)); + Active.emplace_back(Header, StagedAttrs, Location); // Clear the attributes so nested loops do not inherit them. StagedAttrs.clear(); } Index: lib/CodeGen/CGObjC.cpp =================================================================== --- lib/CodeGen/CGObjC.cpp +++ lib/CodeGen/CGObjC.cpp @@ -1671,7 +1671,7 @@ EmitAutoVarCleanups(variable); // Perform the loop body, setting up break and continue labels. - BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody)); + BreakContinueStack.emplace_back(LoopEnd, AfterBody); { RunCleanupsScope Scope(*this); EmitStmt(S.getBody()); Index: lib/CodeGen/CGObjCMac.cpp =================================================================== --- lib/CodeGen/CGObjCMac.cpp +++ lib/CodeGen/CGObjCMac.cpp @@ -2102,7 +2102,7 @@ void IvarLayoutBuilder::visitBlock(const CGBlockInfo &blockInfo) { // __isa is the first field in block descriptor and must assume by runtime's // convention that it is GC'able. - IvarsInfo.push_back(IvarInfo(CharUnits::Zero(), 1)); + IvarsInfo.emplace_back(CharUnits::Zero(), 1); const BlockDecl *blockDecl = blockInfo.getBlockDecl(); @@ -2131,7 +2131,7 @@ // __block variables are passed by their descriptor address. if (CI.isByRef()) { - IvarsInfo.push_back(IvarInfo(fieldOffset, /*size in words*/ 1)); + IvarsInfo.emplace_back(fieldOffset, /*size in words*/ 1); continue; } @@ -2146,7 +2146,7 @@ if (GCAttr == Qualifiers::Strong) { assert(CGM.getContext().getTypeSize(type) == CGM.getTarget().getPointerWidth(0)); - IvarsInfo.push_back(IvarInfo(fieldOffset, /*size in words*/ 1)); + IvarsInfo.emplace_back(fieldOffset, /*size in words*/ 1); } } } @@ -2177,21 +2177,21 @@ CharUnits FieldSize) { // __block variables are passed by their descriptor address. if (IsByref) - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_BYREF, FieldOffset, - FieldSize)); + RunSkipBlockVars.emplace_back(BLOCK_LAYOUT_BYREF, FieldOffset, + FieldSize); else if (LifeTime == Qualifiers::OCL_Strong) - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_STRONG, FieldOffset, - FieldSize)); + RunSkipBlockVars.emplace_back(BLOCK_LAYOUT_STRONG, FieldOffset, + FieldSize); else if (LifeTime == Qualifiers::OCL_Weak) - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_WEAK, FieldOffset, - FieldSize)); + RunSkipBlockVars.emplace_back(BLOCK_LAYOUT_WEAK, FieldOffset, + FieldSize); else if (LifeTime == Qualifiers::OCL_ExplicitNone) - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_UNRETAINED, FieldOffset, - FieldSize)); + RunSkipBlockVars.emplace_back(BLOCK_LAYOUT_UNRETAINED, FieldOffset, + FieldSize); else - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_NON_OBJECT_BYTES, + RunSkipBlockVars.emplace_back(BLOCK_LAYOUT_NON_OBJECT_BYTES, FieldOffset, - FieldSize)); + FieldSize); } void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, @@ -2260,10 +2260,9 @@ for (int FirstIndex = RunSkipBlockVars.size() - 1 ;ElIx < ElCount; ElIx++) { CharUnits Size = CGM.getContext().getTypeSizeInChars(RT); for (int i = OldIndex+1; i <= FirstIndex; ++i) - RunSkipBlockVars.push_back( - RUN_SKIP(RunSkipBlockVars[i].opcode, + RunSkipBlockVars.emplace_back(RunSkipBlockVars[i].opcode, RunSkipBlockVars[i].block_var_bytepos + Size*ElIx, - RunSkipBlockVars[i].block_var_size)); + RunSkipBlockVars[i].block_var_size); } continue; } @@ -4805,8 +4804,8 @@ // each for the element size. for (size_t i = 0; i != numEltEntries; ++i) { auto firstEntry = IvarsInfo[oldEnd + i]; - IvarsInfo.push_back(IvarInfo(firstEntry.Offset + eltIndex * eltSize, - firstEntry.SizeInWords)); + IvarsInfo.emplace_back(firstEntry.Offset + eltIndex * eltSize, + firstEntry.SizeInWords); } } } @@ -4822,7 +4821,7 @@ || (!ForStrongLayout && GCAttr == Qualifiers::Weak)) { assert(CGM.getContext().getTypeSizeInChars(fieldType) == CGM.getPointerSize()); - IvarsInfo.push_back(IvarInfo(fieldOffset, numElts)); + IvarsInfo.emplace_back(fieldOffset, numElts); } } Index: lib/CodeGen/CGObjCRuntime.cpp =================================================================== --- lib/CodeGen/CGObjCRuntime.cpp +++ lib/CodeGen/CGObjCRuntime.cpp @@ -193,7 +193,7 @@ const ObjCAtCatchStmt *CatchStmt = S.getCatchStmt(I); const VarDecl *CatchDecl = CatchStmt->getCatchParamDecl(); - Handlers.push_back(CatchHandler()); + Handlers.emplace_back(); CatchHandler &Handler = Handlers.back(); Handler.Variable = CatchDecl; Handler.Body = CatchStmt->getCatchBody(); Index: lib/CodeGen/CGRecordLayoutBuilder.cpp =================================================================== --- lib/CodeGen/CGRecordLayoutBuilder.cpp +++ lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -356,9 +356,9 @@ for (++Field; Field != FieldEnd && Field->isBitField(); ++Field); accumulateBitFields(Start, Field); } else { - Members.push_back(MemberInfo( + Members.emplace_back( bitsToCharUnits(getFieldBitOffset(*Field)), MemberInfo::Field, - getStorageType(*Field), *Field)); + getStorageType(*Field), *Field); ++Field; } } @@ -398,8 +398,8 @@ } // Bitfields get the offset of their storage but come afterward and remain // there after a stable sort. - Members.push_back(MemberInfo(bitsToCharUnits(StartBitOffset), - MemberInfo::Field, nullptr, *Field)); + Members.emplace_back(bitsToCharUnits(StartBitOffset), + MemberInfo::Field, nullptr, *Field); } return; } @@ -432,8 +432,8 @@ // come afterward and remain there after a stable sort. Members.push_back(StorageInfo(bitsToCharUnits(StartBitOffset), Type)); for (; Run != Field; ++Run) - Members.push_back(MemberInfo(bitsToCharUnits(StartBitOffset), - MemberInfo::Field, nullptr, *Run)); + Members.emplace_back(bitsToCharUnits(StartBitOffset), + MemberInfo::Field, nullptr, *Run); Run = FieldEnd; } } @@ -442,8 +442,8 @@ // If we've got a primary virtual base, we need to add it with the bases. if (Layout.isPrimaryBaseVirtual()) { const CXXRecordDecl *BaseDecl = Layout.getPrimaryBase(); - Members.push_back(MemberInfo(CharUnits::Zero(), MemberInfo::Base, - getStorageType(BaseDecl), BaseDecl)); + Members.emplace_back(CharUnits::Zero(), MemberInfo::Base, + getStorageType(BaseDecl), BaseDecl); } // Accumulate the non-virtual bases. for (const auto &Base : RD->bases()) { @@ -455,19 +455,19 @@ const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl(); if (!BaseDecl->isEmpty() && !Context.getASTRecordLayout(BaseDecl).getNonVirtualSize().isZero()) - Members.push_back(MemberInfo(Layout.getBaseClassOffset(BaseDecl), - MemberInfo::Base, getStorageType(BaseDecl), BaseDecl)); + Members.emplace_back(Layout.getBaseClassOffset(BaseDecl), + MemberInfo::Base, getStorageType(BaseDecl), BaseDecl); } } void CGRecordLowering::accumulateVPtrs() { if (Layout.hasOwnVFPtr()) - Members.push_back(MemberInfo(CharUnits::Zero(), MemberInfo::VFPtr, + Members.emplace_back(CharUnits::Zero(), MemberInfo::VFPtr, llvm::FunctionType::get(getIntNType(32), /*isVarArg=*/true)-> - getPointerTo()->getPointerTo())); + getPointerTo()->getPointerTo()); if (Layout.hasOwnVBPtr()) - Members.push_back(MemberInfo(Layout.getVBPtrOffset(), MemberInfo::VBPtr, - llvm::Type::getInt32PtrTy(Types.getLLVMContext()))); + Members.emplace_back(Layout.getVBPtrOffset(), MemberInfo::VBPtr, + llvm::Type::getInt32PtrTy(Types.getLLVMContext())); } void CGRecordLowering::accumulateVBases() { @@ -488,8 +488,8 @@ ScissorOffset = std::min(ScissorOffset, Layout.getVBaseClassOffset(BaseDecl)); } - Members.push_back(MemberInfo(ScissorOffset, MemberInfo::Scissor, nullptr, - RD)); + Members.emplace_back(ScissorOffset, MemberInfo::Scissor, nullptr, + RD); for (const auto &Base : RD->vbases()) { const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl(); if (BaseDecl->isEmpty()) @@ -500,16 +500,16 @@ if (isOverlappingVBaseABI() && Context.isNearlyEmpty(BaseDecl) && !hasOwnStorage(RD, BaseDecl)) { - Members.push_back(MemberInfo(Offset, MemberInfo::VBase, nullptr, - BaseDecl)); + Members.emplace_back(Offset, MemberInfo::VBase, nullptr, + BaseDecl); continue; } // If we've got a vtordisp, add it as a storage type. if (Layout.getVBaseOffsetsMap().find(BaseDecl)->second.hasVtorDisp()) Members.push_back(StorageInfo(Offset - CharUnits::fromQuantity(4), getIntNType(32))); - Members.push_back(MemberInfo(Offset, MemberInfo::VBase, - getStorageType(BaseDecl), BaseDecl)); + Members.emplace_back(Offset, MemberInfo::VBase, + getStorageType(BaseDecl), BaseDecl); } } Index: lib/CodeGen/CGStmt.cpp =================================================================== --- lib/CodeGen/CGStmt.cpp +++ lib/CodeGen/CGStmt.cpp @@ -640,7 +640,7 @@ JumpDest LoopExit = getJumpDestInCurrentScope("while.end"); // Store the blocks to use for break and continue. - BreakContinueStack.push_back(BreakContinue(LoopExit, LoopHeader)); + BreakContinueStack.emplace_back(LoopExit, LoopHeader); // C++ [stmt.while]p2: // When the condition of a while statement is a declaration, the @@ -719,7 +719,7 @@ uint64_t ParentCount = getCurrentProfileCount(); // Store the blocks to use for break and continue. - BreakContinueStack.push_back(BreakContinue(LoopExit, LoopCond)); + BreakContinueStack.emplace_back(LoopExit, LoopCond); // Emit the body of the loop. llvm::BasicBlock *LoopBody = createBasicBlock("do.body"); @@ -800,7 +800,7 @@ Continue = getJumpDestInCurrentScope("for.inc"); // Store the blocks to use for break and continue. - BreakContinueStack.push_back(BreakContinue(LoopExit, Continue)); + BreakContinueStack.emplace_back(LoopExit, Continue); // Create a cleanup scope for the condition variable cleanups. LexicalScope ConditionScope(*this, S.getSourceRange()); @@ -918,7 +918,7 @@ JumpDest Continue = getJumpDestInCurrentScope("for.inc"); // Store the blocks to use for break and continue. - BreakContinueStack.push_back(BreakContinue(LoopExit, Continue)); + BreakContinueStack.emplace_back(LoopExit, Continue); { // Create a separate cleanup scope for the loop variable and body. @@ -1525,7 +1525,7 @@ if (!BreakContinueStack.empty()) OuterContinue = BreakContinueStack.back().ContinueBlock; - BreakContinueStack.push_back(BreakContinue(SwitchExit, OuterContinue)); + BreakContinueStack.emplace_back(SwitchExit, OuterContinue); // Emit switch body. EmitStmt(S.getBody()); Index: lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- lib/CodeGen/CGStmtOpenMP.cpp +++ lib/CodeGen/CGStmtOpenMP.cpp @@ -1263,7 +1263,7 @@ // On a continue in the body, jump to the end. auto Continue = getJumpDestInCurrentScope("omp.body.continue"); - BreakContinueStack.push_back(BreakContinue(LoopExit, Continue)); + BreakContinueStack.emplace_back(LoopExit, Continue); // Emit loop body. EmitStmt(D.getBody()); // The end (updates/cleanups). @@ -1303,7 +1303,7 @@ // Create a block for the increment. auto Continue = getJumpDestInCurrentScope("omp.inner.for.inc"); - BreakContinueStack.push_back(BreakContinue(LoopExit, Continue)); + BreakContinueStack.emplace_back(LoopExit, Continue); BodyGen(*this); @@ -1718,7 +1718,7 @@ // Create a block for the increment. auto Continue = getJumpDestInCurrentScope("omp.dispatch.inc"); - BreakContinueStack.push_back(BreakContinue(LoopExit, Continue)); + BreakContinueStack.emplace_back(LoopExit, Continue); // Generate !llvm.loop.parallel metadata for loads and stores for loops // with dynamic/guided scheduling and without ordered clause. Index: lib/CodeGen/CGVTables.cpp =================================================================== --- lib/CodeGen/CGVTables.cpp +++ lib/CodeGen/CGVTables.cpp @@ -945,7 +945,7 @@ std::vector BitsetEntries; // Create a bit set entry for each address point. for (auto &&AP : VTLayout.getAddressPoints()) - BitsetEntries.push_back(std::make_pair(AP.first.getBase(), AP.second)); + BitsetEntries.emplace_back(std::make_pair(AP.first.getBase(), AP.second)); // Sort the bit set entries for determinism. std::sort(BitsetEntries.begin(), BitsetEntries.end(), Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -714,14 +714,14 @@ void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority, llvm::Constant *AssociatedData) { // FIXME: Type coercion of void()* types. - GlobalCtors.push_back(Structor(Priority, Ctor, AssociatedData)); + GlobalCtors.emplace_back(Priority, Ctor, AssociatedData); } /// AddGlobalDtor - Add a function to the list that will be called /// when the module is unloaded. void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) { // FIXME: Type coercion of void()* types. - GlobalDtors.push_back(Structor(Priority, Dtor, nullptr)); + GlobalDtors.emplace_back(Priority, Dtor, nullptr); } void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) { Index: lib/CodeGen/CodeGenPGO.cpp =================================================================== --- lib/CodeGen/CodeGenPGO.cpp +++ lib/CodeGen/CodeGenPGO.cpp @@ -330,7 +330,7 @@ RecordStmtCount(S); uint64_t ParentCount = CurrentCount; - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); // Visit the body region first so the break/continue adjustments can be // included when visiting the condition. uint64_t BodyCount = setCount(PGO.getRegionCount(S)); @@ -355,7 +355,7 @@ RecordStmtCount(S); uint64_t LoopCount = PGO.getRegionCount(S); - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); // The count doesn't include the fallthrough from the parent scope. Add it. uint64_t BodyCount = setCount(LoopCount + CurrentCount); CountMap[S->getBody()] = BodyCount; @@ -379,7 +379,7 @@ uint64_t ParentCount = CurrentCount; - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); // Visit the body region first. (This is basically the same as a while // loop; see further comments in VisitWhileStmt.) uint64_t BodyCount = setCount(PGO.getRegionCount(S)); @@ -415,7 +415,7 @@ Visit(S->getEndStmt()); uint64_t ParentCount = CurrentCount; - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); // Visit the body region first. (This is basically the same as a while // loop; see further comments in VisitWhileStmt.) uint64_t BodyCount = setCount(PGO.getRegionCount(S)); @@ -443,7 +443,7 @@ RecordStmtCount(S); Visit(S->getElement()); uint64_t ParentCount = CurrentCount; - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); // Counter tracks the body of the loop. uint64_t BodyCount = setCount(PGO.getRegionCount(S)); CountMap[S->getBody()] = BodyCount; @@ -460,7 +460,7 @@ RecordStmtCount(S); Visit(S->getCond()); CurrentCount = 0; - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); Visit(S->getBody()); // If the switch is inside a loop, add the continue counts. BreakContinue BC = BreakContinueStack.pop_back_val(); Index: lib/CodeGen/CodeGenPrepare.cpp =================================================================== --- lib/CodeGen/CodeGenPrepare.cpp +++ lib/CodeGen/CodeGenPrepare.cpp @@ -2412,7 +2412,7 @@ // Record the original uses. for (Use &U : Inst->uses()) { Instruction *UserI = cast(U.getUser()); - OriginalUses.push_back(InstructionAndIdx(UserI, U.getOperandNo())); + OriginalUses.emplace_back(UserI, U.getOperandNo()); } // Now, we can replace the uses. Inst->replaceAllUsesWith(New); Index: lib/CodeGen/CoverageMappingGen.cpp =================================================================== --- lib/CodeGen/CoverageMappingGen.cpp +++ lib/CodeGen/CoverageMappingGen.cpp @@ -670,7 +670,7 @@ Counter BodyCount = getRegionCounter(S); // Handle the body first so that we can get the backedge count. - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); extendRegion(S->getBody()); Counter BackedgeCount = propagateCounts(BodyCount, S->getBody()); BreakContinue BC = BreakContinueStack.pop_back_val(); @@ -693,7 +693,7 @@ Counter ParentCount = getRegion().getCounter(); Counter BodyCount = getRegionCounter(S); - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); extendRegion(S->getBody()); Counter BackedgeCount = propagateCounts(addCounters(ParentCount, BodyCount), S->getBody()); @@ -717,7 +717,7 @@ Counter BodyCount = getRegionCounter(S); // Handle the body first so that we can get the backedge count. - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); extendRegion(S->getBody()); Counter BackedgeCount = propagateCounts(BodyCount, S->getBody()); BreakContinue BC = BreakContinueStack.pop_back_val(); @@ -749,7 +749,7 @@ Counter ParentCount = getRegion().getCounter(); Counter BodyCount = getRegionCounter(S); - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); extendRegion(S->getBody()); Counter BackedgeCount = propagateCounts(BodyCount, S->getBody()); BreakContinue BC = BreakContinueStack.pop_back_val(); @@ -769,7 +769,7 @@ Counter ParentCount = getRegion().getCounter(); Counter BodyCount = getRegionCounter(S); - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); extendRegion(S->getBody()); Counter BackedgeCount = propagateCounts(BodyCount, S->getBody()); BreakContinue BC = BreakContinueStack.pop_back_val(); @@ -786,7 +786,7 @@ extendRegion(S); Visit(S->getCond()); - BreakContinueStack.push_back(BreakContinue()); + BreakContinueStack.emplace_back(); const Stmt *Body = S->getBody(); extendRegion(Body); Index: lib/CodeGen/EarlyIfConversion.cpp =================================================================== --- lib/CodeGen/EarlyIfConversion.cpp +++ lib/CodeGen/EarlyIfConversion.cpp @@ -407,7 +407,7 @@ MachineBasicBlock *FPred = getFPred(); for (MachineBasicBlock::iterator I = Tail->begin(), E = Tail->end(); I != E && I->isPHI(); ++I) { - PHIs.push_back(&*I); + PHIs.emplace_back(&*I); PHIInfo &PI = PHIs.back(); // Find PHI operands corresponding to TPred and FPred. for (unsigned i = 1; i != PI.PHI->getNumOperands(); i += 2) { Index: lib/CodeGen/IfConversion.cpp =================================================================== --- lib/CodeGen/IfConversion.cpp +++ lib/CodeGen/IfConversion.cpp @@ -854,8 +854,8 @@ // Push the False and True blocks to the stack. State.SuccsAnalyzed = true; - BBStack.push_back(BBI.FalseBB); - BBStack.push_back(BBI.TrueBB); + BBStack.emplace_back(BBI.FalseBB); + BBStack.emplace_back(BBI.TrueBB); continue; } Index: lib/CodeGen/LocalStackSlotAllocation.cpp =================================================================== --- lib/CodeGen/LocalStackSlotAllocation.cpp +++ lib/CodeGen/LocalStackSlotAllocation.cpp @@ -315,7 +315,7 @@ if (!TRI->needsFrameBaseReg(MI, LocalOffset)) break; FrameReferenceInsns. - push_back(FrameRef(MI, LocalOffset, Idx)); + emplace_back(MI, LocalOffset, Idx); break; } } Index: lib/CodeGen/MIRParser/MIRParser.cpp =================================================================== --- lib/CodeGen/MIRParser/MIRParser.cpp +++ lib/CodeGen/MIRParser/MIRParser.cpp @@ -558,7 +558,7 @@ if (parseNamedRegisterReference(Reg, SM, MF, RegisterSource.Value, PFS, IRSlots, Error)) return error(Error, RegisterSource.SourceRange); - CSIInfo.push_back(CalleeSavedInfo(Reg, FrameIdx)); + CSIInfo.emplace_back(Reg, FrameIdx); return false; } Index: lib/CodeGen/MachineFunction.cpp =================================================================== --- lib/CodeGen/MachineFunction.cpp +++ lib/CodeGen/MachineFunction.cpp @@ -581,8 +581,8 @@ bool isSS, const AllocaInst *Alloca) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment); - Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, Alloca, - !isSS)); + Objects.emplace_back(Size, Alignment, 0, false, isSS, Alloca, + !isSS); int Index = (int)Objects.size() - NumFixedObjects - 1; assert(Index >= 0 && "Bad frame index!"); ensureMaxAlignment(Alignment); @@ -607,7 +607,7 @@ const AllocaInst *Alloca) { HasVarSizedObjects = true; Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment); - Objects.push_back(StackObject(0, Alignment, 0, false, false, Alloca, true)); + Objects.emplace_back(0, Alignment, 0, false, false, Alloca, true); ensureMaxAlignment(Alignment); return (int)Objects.size()-NumFixedObjects-1; } @@ -962,7 +962,7 @@ return i; } - Constants.push_back(MachineConstantPoolEntry(C, Alignment)); + Constants.emplace_back(C, Alignment); return Constants.size()-1; } @@ -980,7 +980,7 @@ return (unsigned)Idx; } - Constants.push_back(MachineConstantPoolEntry(V, Alignment)); + Constants.emplace_back(V, Alignment); return Constants.size()-1; } Index: lib/CodeGen/MachineScheduler.cpp =================================================================== --- lib/CodeGen/MachineScheduler.cpp +++ lib/CodeGen/MachineScheduler.cpp @@ -947,7 +947,7 @@ DEBUG(dbgs() << TRI->getRegPressureSetName(i) << " Limit " << Limit << " Actual " << RegionPressure[i] << "\n"); - RegionCriticalPSets.push_back(PressureChange(i)); + RegionCriticalPSets.emplace_back(i); } } DEBUG(dbgs() << "Excess PSets: "; @@ -1403,7 +1403,7 @@ unsigned BaseReg; int64_t Offset; if (TII->getMemOpBaseRegImmOfs(SU->getInstr(), BaseReg, Offset, TRI)) - MemOpRecords.push_back(MemOpInfo(SU, BaseReg, Offset)); + MemOpRecords.emplace_back(SU, BaseReg, Offset); } if (MemOpRecords.size() < 2) return; Index: lib/CodeGen/MachineTraceMetrics.cpp =================================================================== --- lib/CodeGen/MachineTraceMetrics.cpp +++ lib/CodeGen/MachineTraceMetrics.cpp @@ -966,7 +966,7 @@ return; TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()]; // Just add the register. The height will be updated later. - TBI.LiveIns.push_back(Reg); + TBI.LiveIns.emplace_back(Reg); } } @@ -1117,7 +1117,7 @@ // Transfer the live regunits to the live-in list. for (SparseSet::const_iterator RI = RegUnits.begin(), RE = RegUnits.end(); RI != RE; ++RI) { - TBI.LiveIns.push_back(LiveInReg(RI->RegUnit, RI->Cycle)); + TBI.LiveIns.emplace_back(RI->RegUnit, RI->Cycle); DEBUG(dbgs() << ' ' << PrintRegUnit(RI->RegUnit, MTM.TRI) << '@' << RI->Cycle); } Index: lib/CodeGen/PeepholeOptimizer.cpp =================================================================== --- lib/CodeGen/PeepholeOptimizer.cpp +++ lib/CodeGen/PeepholeOptimizer.cpp @@ -237,7 +237,7 @@ } void addSource(unsigned SrcReg, unsigned SrcSubReg) { - RegSrcs.push_back(TargetInstrInfo::RegSubRegPair(SrcReg, SrcSubReg)); + RegSrcs.emplace_back(SrcReg, SrcSubReg); } void setSource(int Idx, unsigned SrcReg, unsigned SrcSubReg) { @@ -667,8 +667,8 @@ if (NumSrcs > 1) { PHICount++; for (unsigned i = 0; i < NumSrcs; ++i) - SrcToLook.push_back(TargetInstrInfo::RegSubRegPair( - Res.getSrcReg(i), Res.getSrcSubReg(i))); + SrcToLook.emplace_back( + Res.getSrcReg(i), Res.getSrcSubReg(i)); break; } Index: lib/CodeGen/PrologEpilogInserter.cpp =================================================================== --- lib/CodeGen/PrologEpilogInserter.cpp +++ lib/CodeGen/PrologEpilogInserter.cpp @@ -336,7 +336,7 @@ for (unsigned i = 0; CSRegs[i]; ++i) { unsigned Reg = CSRegs[i]; if (SavedRegs.test(Reg)) - CSI.push_back(CalleeSavedInfo(Reg)); + CSI.emplace_back(Reg); } const TargetFrameLowering *TFI = F.getSubtarget().getFrameLowering(); Index: lib/CodeGen/RegAllocGreedy.cpp =================================================================== --- lib/CodeGen/RegAllocGreedy.cpp +++ lib/CodeGen/RegAllocGreedy.cpp @@ -2329,8 +2329,8 @@ ? OtherReg : VRM->getPhys(OtherReg); // Push the collected information. - Out.push_back(HintInfo(MBFI->getBlockFreq(Instr.getParent()), OtherReg, - OtherPhysReg)); + Out.emplace_back(MBFI->getBlockFreq(Instr.getParent()), OtherReg, + OtherPhysReg); } } Index: lib/CodeGen/RegisterCoalescer.cpp =================================================================== --- lib/CodeGen/RegisterCoalescer.cpp +++ lib/CodeGen/RegisterCoalescer.cpp @@ -2950,8 +2950,8 @@ MBBs.reserve(MF->size()); for (MachineFunction::iterator I = MF->begin(), E = MF->end(); I != E; ++I) { MachineBasicBlock *MBB = &*I; - MBBs.push_back(MBBPriorityInfo(MBB, Loops->getLoopDepth(MBB), - JoinSplitEdges && isSplitEdge(MBB))); + MBBs.emplace_back(MBB, Loops->getLoopDepth(MBB), + JoinSplitEdges && isSplitEdge(MBB)); } array_pod_sort(MBBs.begin(), MBBs.end(), compareMBBPriority); Index: lib/CodeGen/ScheduleDAGInstrs.cpp =================================================================== --- lib/CodeGen/ScheduleDAGInstrs.cpp +++ lib/CodeGen/ScheduleDAGInstrs.cpp @@ -188,7 +188,7 @@ return false; bool MayAlias = PSV->mayAlias(MFI); - Objects.push_back(UnderlyingObjectsVector::value_type(PSV, MayAlias)); + Objects.emplace_back(PSV, MayAlias); } else if (const Value *V = MMO->getValue()) { SmallVector Objs; getUnderlyingObjects(V, Objs, DL); @@ -197,7 +197,7 @@ if (!isIdentifiedObject(V)) return false; - Objects.push_back(UnderlyingObjectsVector::value_type(V, true)); + Objects.emplace_back(V, true); } } else return false; @@ -1495,7 +1495,7 @@ /// Add a connection for cross edges. void visitCrossEdge(const SDep &PredDep, const SUnit *Succ) { - ConnectionPairs.push_back(std::make_pair(PredDep.getSUnit(), Succ)); + ConnectionPairs.emplace_back(std::make_pair(PredDep.getSUnit(), Succ)); } /// Set each node's subtree ID to the representative ID and record connections Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -11754,7 +11754,7 @@ } // We found a potential memory operand to merge. - LoadNodes.push_back(MemOpLink(Ld, LdPtr.Offset, 0)); + LoadNodes.emplace_back(Ld, LdPtr.Offset, 0); } if (LoadNodes.size() < 2) Index: lib/CodeGen/SelectionDAG/FastISel.cpp =================================================================== --- lib/CodeGen/SelectionDAG/FastISel.cpp +++ lib/CodeGen/SelectionDAG/FastISel.cpp @@ -2076,7 +2076,7 @@ FuncInfo.PHINodesToUpdate.resize(FuncInfo.OrigNumPHINodesToUpdate); return false; } - FuncInfo.PHINodesToUpdate.push_back(std::make_pair(MBBI++, Reg)); + FuncInfo.PHINodesToUpdate.emplace_back(std::make_pair(MBBI++, Reg)); DbgLoc = DebugLoc(); } } Index: lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -176,7 +176,7 @@ SmallVector VTs(N->value_begin(), N->value_end()); if (AddGlue) - VTs.push_back(MVT::Glue); + VTs.emplace_back(MVT::Glue); CloneNodeWithValues(N, DAG, VTs, Glue); Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -4090,7 +4090,7 @@ if (LoadSDNode *L = dyn_cast(*U)) if (FrameIndexSDNode *FI = dyn_cast(L->getBasePtr())) if (FI->getIndex() < 0) - ArgChains.push_back(SDValue(L, 1)); + ArgChains.emplace_back(L, 1); // Build a tokenfactor for all the chains. return getNode(ISD::TokenFactor, SDLoc(Chain), MVT::Other, ArgChains); @@ -6758,7 +6758,7 @@ EVTArray() { VTs.reserve(MVT::LAST_VALUETYPE); for (unsigned i = 0; i < MVT::LAST_VALUETYPE; ++i) - VTs.push_back(MVT((MVT::SimpleValueType)i)); + VTs.emplace_back(MVT((MVT::SimpleValueType)i)); } }; } Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1140,7 +1140,7 @@ // Add each leaf value from the operand to the Constants list // to form a flattened list of all the values. for (unsigned i = 0, e = Val->getNumValues(); i != e; ++i) - Constants.push_back(SDValue(Val, i)); + Constants.emplace_back(Val, i); } return DAG.getMergeValues(Constants, getCurSDLoc()); @@ -1154,7 +1154,7 @@ // Add each leaf value from the operand to the Constants list // to form a flattened list of all the values. for (unsigned i = 0, e = Val->getNumValues(); i != e; ++i) - Ops.push_back(SDValue(Val, i)); + Ops.emplace_back(Val, i); } if (isa(CDS->getType())) @@ -1477,8 +1477,8 @@ Flags.setZExt(); for (unsigned i = 0; i < NumParts; ++i) { - Outs.push_back(ISD::OutputArg(Flags, Parts[i].getValueType(), - VT, /*isfixed=*/true, 0, 0)); + Outs.emplace_back(Flags, Parts[i].getValueType(), + VT, /*isfixed=*/true, 0, 0); OutVals.push_back(Parts[i]); } } @@ -1493,10 +1493,10 @@ F->getAttributes().hasAttrSomewhere(Attribute::SwiftError)) { ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy(); Flags.setSwiftError(); - Outs.push_back(ISD::OutputArg(Flags, EVT(TLI.getPointerTy(DL)) /*vt*/, + Outs.emplace_back(Flags, EVT(TLI.getPointerTy(DL)) /*vt*/, EVT(TLI.getPointerTy(DL)) /*argvt*/, true /*isfixed*/, 1 /*origidx*/, - 0 /*partOffs*/)); + 0 /*partOffs*/); // Create SDNode for the swifterror virtual register. OutVals.push_back(DAG.getRegister(FuncInfo.SwiftErrorMap[FuncInfo.MBB][0], EVT(TLI.getPointerTy(DL)))); @@ -2831,8 +2831,8 @@ for (unsigned i = 0; i != NumValues; ++i) { SmallVector Ops(BaseOps.begin(), BaseOps.end()); - Ops.push_back(SDValue(LHSVal.getNode(), LHSVal.getResNo() + i)); - Ops.push_back(SDValue(RHSVal.getNode(), RHSVal.getResNo() + i)); + Ops.emplace_back(LHSVal.getNode(), LHSVal.getResNo() + i); + Ops.emplace_back(RHSVal.getNode(), RHSVal.getResNo() + i); Values[i] = DAG.getNode(OpCode, getCurSDLoc(), LHSVal.getNode()->getValueType(LHSVal.getResNo()+i), Ops); @@ -4067,7 +4067,7 @@ ComputeValueVTs(TLI, DAG.getDataLayout(), I.getType(), ValueVTs); if (HasChain) - ValueVTs.push_back(MVT::Other); + ValueVTs.emplace_back(MVT::Other); SDVTList VTs = DAG.getVTList(ValueVTs); @@ -6746,7 +6746,7 @@ // AsmNodeOperands - The operands for the ISD::INLINEASM node. std::vector AsmNodeOperands; - AsmNodeOperands.push_back(SDValue()); // reserve space for input chain + AsmNodeOperands.emplace_back(); // reserve space for input chain AsmNodeOperands.push_back(DAG.getTargetExternalSymbol( IA->getAsmString().c_str(), TLI.getPointerTy(DAG.getDataLayout()))); @@ -7417,8 +7417,8 @@ assert(ValueVTs.size() == 1 && "Expected only one return value type."); // There is always a chain and a glue type at the end - ValueVTs.push_back(MVT::Other); - ValueVTs.push_back(MVT::Glue); + ValueVTs.emplace_back(MVT::Other); + ValueVTs.emplace_back(MVT::Glue); NodeTys = DAG.getVTList(ValueVTs); } else NodeTys = DAG.getVTList(MVT::Other, MVT::Glue); @@ -8143,7 +8143,7 @@ EVT VT = ValueVTs[vti]; unsigned NumRegisters = TLI.getNumRegisters(*DAG.getContext(), VT); for (unsigned i = 0, e = NumRegisters; i != e; ++i) - FuncInfo.PHINodesToUpdate.push_back(std::make_pair(MBBI++, Reg+i)); + FuncInfo.PHINodesToUpdate.emplace_back(std::make_pair(MBBI++, Reg+i)); Reg += NumRegisters; } } @@ -8514,8 +8514,7 @@ if (CBV[j].BB == Clusters[i].MBB) break; if (j == CBV.size()) - CBV.push_back( - CaseBits(0, Clusters[i].MBB, 0, BranchProbability::getZero())); + CBV.emplace_back(0, Clusters[i].MBB, 0, BranchProbability::getZero()); CaseBits *CB = &CBV[j]; // Update Mask, Bits and ExtraProb. @@ -8539,7 +8538,7 @@ for (auto &CB : CBV) { MachineBasicBlock *BitTestBB = FuncInfo.MF->CreateMachineBasicBlock(SI->getParent()); - BTI.push_back(BitTestCase(CB.Mask, BitTestBB, CB.BB, CB.ExtraProb)); + BTI.emplace_back(CB.Mask, BitTestBB, CB.BB, CB.ExtraProb); } BitTestCases.emplace_back(std::move(LowBound), std::move(CmpRange), SI->getCondition(), -1U, MVT::Other, false, Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -3147,17 +3147,17 @@ int64_t Val = MatcherTable[MatcherIndex++]; if (Val & 128) Val = GetVBR(Val, MatcherTable, MatcherIndex); - RecordedNodes.push_back(std::pair( + RecordedNodes.emplace_back( CurDAG->getTargetConstant(Val, SDLoc(NodeToMatch), - VT), nullptr)); + VT), nullptr); continue; } case OPC_EmitRegister: { MVT::SimpleValueType VT = (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; unsigned RegNo = MatcherTable[MatcherIndex++]; - RecordedNodes.push_back(std::pair( - CurDAG->getRegister(RegNo, VT), nullptr)); + RecordedNodes.emplace_back( + CurDAG->getRegister(RegNo, VT), nullptr); continue; } case OPC_EmitRegister2: { @@ -3168,8 +3168,8 @@ (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; unsigned RegNo = MatcherTable[MatcherIndex++]; RegNo |= MatcherTable[MatcherIndex++] << 8; - RecordedNodes.push_back(std::pair( - CurDAG->getRegister(RegNo, VT), nullptr)); + RecordedNodes.emplace_back( + CurDAG->getRegister(RegNo, VT), nullptr); continue; } @@ -3287,7 +3287,7 @@ unsigned RecNo = MatcherTable[MatcherIndex++]; assert(RecNo < RecordedNodes.size() && "Invalid EmitNodeXForm"); SDValue Res = RunSDNodeXForm(RecordedNodes[RecNo].first, XFormNo); - RecordedNodes.push_back(std::pair(Res, nullptr)); + RecordedNodes.emplace_back(Res, nullptr); continue; } @@ -3313,13 +3313,13 @@ (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; if (VT == MVT::iPTR) VT = TLI->getPointerTy(CurDAG->getDataLayout()).SimpleTy; - VTs.push_back(VT); + VTs.emplace_back(VT); } if (EmitNodeInfo & OPFL_Chain) - VTs.push_back(MVT::Other); + VTs.emplace_back(MVT::Other); if (EmitNodeInfo & OPFL_GlueOutput) - VTs.push_back(MVT::Glue); + VTs.emplace_back(MVT::Glue); // This is hot code, so optimize the two most common cases of 1 and 2 // results. @@ -3379,8 +3379,8 @@ // Add all the non-glue/non-chain results to the RecordedNodes list. for (unsigned i = 0, e = VTs.size(); i != e; ++i) { if (VTs[i] == MVT::Other || VTs[i] == MVT::Glue) break; - RecordedNodes.push_back(std::pair(SDValue(Res, i), - nullptr)); + RecordedNodes.emplace_back(SDValue(Res, i), + nullptr); } } else { Index: lib/CodeGen/SelectionDAG/StatepointLowering.cpp =================================================================== --- lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -691,7 +691,7 @@ SmallVector TEOps; // Add chain - TEOps.push_back(SDValue(StatepointMCNode, 0)); + TEOps.emplace_back(StatepointMCNode, 0); // Add GC transition arguments for (const Value *V : SI.GCTransitionArgs) { @@ -701,7 +701,7 @@ } // Add glue - TEOps.push_back(SDValue(StatepointMCNode, 1)); + TEOps.emplace_back(StatepointMCNode, 1); SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue); Index: lib/CodeGen/SlotIndexes.cpp =================================================================== --- lib/CodeGen/SlotIndexes.cpp +++ lib/CodeGen/SlotIndexes.cpp @@ -96,7 +96,7 @@ MBBRanges[mbb->getNumber()].first = blockStartIndex; MBBRanges[mbb->getNumber()].second = SlotIndex(&indexList.back(), SlotIndex::Slot_Block); - idx2MBBMap.push_back(IdxMBBPair(blockStartIndex, mbb)); + idx2MBBMap.emplace_back(blockStartIndex, mbb); } // Sort the Idx2MBBMap Index: lib/CodeGen/WinEHPrepare.cpp =================================================================== --- lib/CodeGen/WinEHPrepare.cpp +++ lib/CodeGen/WinEHPrepare.cpp @@ -1106,7 +1106,7 @@ // stored to the spill slot by the end of the given Block. SmallVector, 4> Worklist; - Worklist.push_back({OriginalPHI->getParent(), OriginalPHI}); + Worklist.emplace_back(OriginalPHI->getParent(), OriginalPHI); while (!Worklist.empty()) { BasicBlock *EHBlock; Index: lib/DebugInfo/CodeView/MemoryTypeTableBuilder.cpp =================================================================== --- lib/DebugInfo/CodeView/MemoryTypeTableBuilder.cpp +++ lib/DebugInfo/CodeView/MemoryTypeTableBuilder.cpp @@ -40,7 +40,7 @@ // Use only the data supplied by the user as a key to the hash table, so that // future lookups will succeed. HashedRecords.insert(std::make_pair(StringRef(Mem + SizeOfRecLen, Data.size()), TI)); - Records.push_back(StringRef(Mem, TotalSize)); + Records.emplace_back(Mem, TotalSize); return TI; } Index: lib/DebugInfo/CodeView/TypeStreamMerger.cpp =================================================================== --- lib/DebugInfo/CodeView/TypeStreamMerger.cpp +++ lib/DebugInfo/CodeView/TypeStreamMerger.cpp @@ -127,8 +127,7 @@ Error TypeStreamMerger::visitUnknownType(const CVRecord &Rec) { // We failed to translate a type. Translate this index as "not translated". - IndexMap.push_back( - TypeIndex(SimpleTypeKind::NotTranslated, SimpleTypeMode::Direct)); + IndexMap.emplace_back(SimpleTypeKind::NotTranslated, SimpleTypeMode::Direct); return llvm::make_error(cv_error_code::corrupt_record); } Index: lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp +++ lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp @@ -51,7 +51,7 @@ } if (Attr == 0 && Form == 0) break; - AttributeSpecs.push_back(AttributeSpec(Attr, Form)); + AttributeSpecs.emplace_back(Attr, Form); } if (Tag == 0) { Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1313,26 +1313,26 @@ } if (DiagnoseInputExistence(*this, Args, Value, Ty)) - Inputs.push_back(std::make_pair(Ty, A)); + Inputs.emplace_back(std::make_pair(Ty, A)); } else if (A->getOption().matches(options::OPT__SLASH_Tc)) { StringRef Value = A->getValue(); if (DiagnoseInputExistence(*this, Args, Value, types::TY_C)) { Arg *InputArg = MakeInputArg(Args, Opts, A->getValue()); - Inputs.push_back(std::make_pair(types::TY_C, InputArg)); + Inputs.emplace_back(std::make_pair(types::TY_C, InputArg)); } A->claim(); } else if (A->getOption().matches(options::OPT__SLASH_Tp)) { StringRef Value = A->getValue(); if (DiagnoseInputExistence(*this, Args, Value, types::TY_CXX)) { Arg *InputArg = MakeInputArg(Args, Opts, A->getValue()); - Inputs.push_back(std::make_pair(types::TY_CXX, InputArg)); + Inputs.emplace_back(std::make_pair(types::TY_CXX, InputArg)); } A->claim(); } else if (A->getOption().hasFlag(options::LinkerInput)) { // Just treat as object type, we could make a special type for this if // necessary. - Inputs.push_back(std::make_pair(types::TY_Object, A)); + Inputs.emplace_back(std::make_pair(types::TY_Object, A)); } else if (A->getOption().matches(options::OPT_x)) { InputTypeArg = A; @@ -1352,7 +1352,7 @@ // If called as standalone preprocessor, stdin is processed // if no other input is present. Arg *A = MakeInputArg(Args, Opts, "-"); - Inputs.push_back(std::make_pair(types::TY_C, A)); + Inputs.emplace_back(std::make_pair(types::TY_C, A)); } } Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp =================================================================== --- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -260,8 +260,7 @@ return Err; } } - UnregisteredEHFrameSections.push_back( - EHFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID)); + UnregisteredEHFrameSections.emplace_back(HFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID); return Error::success(); } Index: lib/ExecutionEngine/SectionMemoryManager.cpp =================================================================== --- lib/ExecutionEngine/SectionMemoryManager.cpp +++ lib/ExecutionEngine/SectionMemoryManager.cpp @@ -58,7 +58,7 @@ if (FreeMB.PendingPrefixIndex == (unsigned)-1) { // The part of the block we're giving out to the user is now pending - MemGroup.PendingMem.push_back(sys::MemoryBlock((void *)Addr, Size)); + MemGroup.PendingMem.emplace_back((void *)Addr, Size); // Remember this pending block, such that future allocations can just // modify it rather than creating a new one @@ -106,7 +106,7 @@ Addr = (Addr + Alignment - 1) & ~(uintptr_t)(Alignment - 1); // The part of the block we're giving out to the user is now pending - MemGroup.PendingMem.push_back(sys::MemoryBlock((void *)Addr, Size)); + MemGroup.PendingMem.emplace_back((void *)Addr, Size); // The allocateMappedMemory may allocate much more memory than we need. In // this case, we store the unused memory as a free memory block. Index: lib/Format/ContinuationIndenter.cpp =================================================================== --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -81,9 +81,9 @@ State.Column = FirstIndent; State.Line = Line; State.NextToken = Line->First; - State.Stack.push_back(ParenState(FirstIndent, Line->Level, FirstIndent, + State.Stack.emplace_back(FirstIndent, Line->Level, FirstIndent, /*AvoidBinPacking=*/false, - /*NoLineBreak=*/false)); + /*NoLineBreak=*/false); State.LineContainsContinuedForLoopSection = false; State.StartOfStringLiteral = 0; State.StartOfLineLevel = 0; @@ -1003,8 +1003,8 @@ (State.Stack.back().NoLineBreak || (Current.is(TT_TemplateOpener) && State.Stack.back().ContainsUnwrappedBuilder)); - State.Stack.push_back(ParenState(NewIndent, NewIndentLevel, LastSpace, - AvoidBinPacking, NoLineBreak)); + State.Stack.emplace_back(NewIndent, NewIndentLevel, LastSpace, + AvoidBinPacking, NoLineBreak); State.Stack.back().NestedBlockIndent = NestedBlockIndent; State.Stack.back().BreakBeforeParameter = BreakBeforeParameter; State.Stack.back().HasMultipleNestedBlocks = Current.BlockParameterCount > 1; @@ -1038,10 +1038,10 @@ NestedBlockIndent + (State.NextToken->is(TT_ObjCBlockLBrace) ? Style.ObjCBlockIndentWidth : Style.IndentWidth); - State.Stack.push_back(ParenState( + State.Stack.emplace_back( NewIndent, /*NewIndentLevel=*/State.Stack.back().IndentLevel + 1, State.Stack.back().LastSpace, /*AvoidBinPacking=*/true, - /*NoLineBreak=*/false)); + /*NoLineBreak=*/false); State.Stack.back().NestedBlockIndent = NestedBlockIndent; State.Stack.back().BreakBeforeParameter = true; } Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -36,7 +36,7 @@ const AdditionalKeywords &Keywords) : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false), Keywords(Keywords) { - Contexts.push_back(Context(tok::unknown, 1, /*IsExpression=*/false)); + Contexts.emplace_back(tok::unknown, 1, /*IsExpression=*/false); resetTokenMetadata(CurrentToken); } @@ -902,9 +902,9 @@ ScopedContextCreator(AnnotatingParser &P, tok::TokenKind ContextKind, unsigned Increase) : P(P) { - P.Contexts.push_back(Context(ContextKind, + P.Contexts.emplace_back(ContextKind, P.Contexts.back().BindingStrength + Increase, - P.Contexts.back().IsExpression)); + P.Contexts.back().IsExpression); } ~ScopedContextCreator() { P.Contexts.pop_back(); } Index: lib/Frontend/ASTUnit.cpp =================================================================== --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -2299,8 +2299,8 @@ Completion = Builder.TakeString(); } - AllResults.push_back(Result(Completion, Priority, C->Kind, - C->Availability)); + AllResults.emplace_back(Completion, Priority, C->Kind, + C->Availability); } // If we did not add any cached completion results, just forward the Index: lib/Frontend/CompilerInstance.cpp =================================================================== --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -1582,7 +1582,7 @@ BestEditDistance = ED; } - Best.push_back((*J)->Name); + Best.emplace_back((*J)->Name); } } Index: lib/Frontend/PrintPreprocessedOutput.cpp =================================================================== --- lib/Frontend/PrintPreprocessedOutput.cpp +++ lib/Frontend/PrintPreprocessedOutput.cpp @@ -721,7 +721,7 @@ I != E; ++I) { auto *MD = I->second.getLatest(); if (MD && MD->isDefined()) - MacrosByID.push_back(id_macro_pair(I->first, MD->getMacroInfo())); + MacrosByID.emplace_back(I->first, MD->getMacroInfo()); } llvm::array_pod_sort(MacrosByID.begin(), MacrosByID.end(), MacroIDCompare); Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -142,7 +142,7 @@ for (const Use &U : V->uses()) // Check if this user will be serialized. if (OM.lookup(U.getUser()).first) - List.push_back(std::make_pair(&U, List.size())); + List.emplace_back(std::make_pair(&U, List.size())); if (List.size() < 2) // We may have lost some users. Index: lib/Lex/MacroArgs.cpp =================================================================== --- lib/Lex/MacroArgs.cpp +++ lib/Lex/MacroArgs.cpp @@ -169,7 +169,7 @@ // Lex all of the macro-expanded tokens into Result. do { - Result.push_back(Token()); + Result.emplace_back(); Token &Tok = Result.back(); PP.Lex(Tok); } while (Result.back().isNot(tok::eof)); Index: lib/Lex/ModuleMap.cpp =================================================================== --- lib/Lex/ModuleMap.cpp +++ lib/Lex/ModuleMap.cpp @@ -389,7 +389,7 @@ // If inferred submodules export everything they import, add a // wildcard to the set of exports. if (UmbrellaModule->InferExportWildcard && Result->Exports.empty()) - Result->Exports.push_back(Module::ExportDecl(nullptr, true)); + Result->Exports.emplace_back(nullptr, true); } // Infer a submodule with the same name as this header file. @@ -405,7 +405,7 @@ // If inferred submodules export everything they import, add a // wildcard to the set of exports. if (UmbrellaModule->InferExportWildcard && Result->Exports.empty()) - Result->Exports.push_back(Module::ExportDecl(nullptr, true)); + Result->Exports.emplace_back(nullptr, true); } else { // Record each of the directories we stepped through as being part of // the module we found, since the umbrella header covers them all. @@ -699,7 +699,7 @@ setUmbrellaHeader(Result, UmbrellaHeader, ModuleName + ".h"); // export * - Result->Exports.push_back(Module::ExportDecl(nullptr, true)); + Result->Exports.emplace_back(nullptr, true); // module * { export * } Result->InferSubmodules = true; @@ -758,7 +758,7 @@ void ModuleMap::setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, Twine NameAsWritten) { - Headers[UmbrellaHeader].push_back(KnownHeader(Mod, NormalHeader)); + Headers[UmbrellaHeader].emplace_back(Mod, NormalHeader); Mod->Umbrella = UmbrellaHeader; Mod->UmbrellaAsWritten = NameAsWritten.str(); UmbrellaDirs[UmbrellaHeader->getDir()] = Mod; @@ -1703,7 +1703,7 @@ SmallVector Paths; for (; Mod; Mod = Mod->Parent) { if (Mod->IsFramework) - Paths.push_back(Mod->Name); + Paths.emplace_back(Mod->Name); } if (Paths.empty()) Index: lib/Lex/PPCaching.cpp =================================================================== --- lib/Lex/PPCaching.cpp +++ lib/Lex/PPCaching.cpp @@ -87,7 +87,7 @@ assert(CachedLexPos + N > CachedTokens.size() && "Confused caching."); ExitCachingLexMode(); for (unsigned C = CachedLexPos + N - CachedTokens.size(); C > 0; --C) { - CachedTokens.push_back(Token()); + CachedTokens.emplace_back(); Lex(CachedTokens.back()); } EnterCachingLexMode(); Index: lib/Lex/PPConditionalDirectiveRecord.cpp =================================================================== --- lib/Lex/PPConditionalDirectiveRecord.cpp +++ lib/Lex/PPConditionalDirectiveRecord.cpp @@ -18,7 +18,7 @@ PPConditionalDirectiveRecord::PPConditionalDirectiveRecord(SourceManager &SM) : SourceMgr(SM) { - CondDirectiveStack.push_back(SourceLocation()); + CondDirectiveStack.emplace_back(); } bool PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective( Index: lib/Lex/PPDirectives.cpp =================================================================== --- lib/Lex/PPDirectives.cpp +++ lib/Lex/PPDirectives.cpp @@ -772,7 +772,7 @@ // map file. if (!FileEnt) { if (FID == SourceMgr.getMainFileID() && MainFileDir) { - Includers.push_back(std::make_pair(nullptr, MainFileDir)); + Includers.emplace_back(std::make_pair(nullptr, MainFileDir)); BuildSystemModule = getCurrentModule()->IsSystem; } else if ((FileEnt = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()))) Index: lib/Lex/PPLexerChange.cpp =================================================================== --- lib/Lex/PPLexerChange.cpp +++ lib/Lex/PPLexerChange.cpp @@ -622,8 +622,8 @@ void Preprocessor::EnterSubmodule(Module *M, SourceLocation ImportLoc) { if (!getLangOpts().ModulesLocalVisibility) { // Just track that we entered this submodule. - BuildingSubmoduleStack.push_back(BuildingSubmoduleInfo( - M, ImportLoc, CurSubmoduleState, PendingModuleMacroNames.size())); + BuildingSubmoduleStack.emplace_back( + M, ImportLoc, CurSubmoduleState, PendingModuleMacroNames.size()); return; } @@ -664,8 +664,8 @@ } // Track that we entered this module. - BuildingSubmoduleStack.push_back(BuildingSubmoduleInfo( - M, ImportLoc, CurSubmoduleState, PendingModuleMacroNames.size())); + BuildingSubmoduleStack.emplace_back( + M, ImportLoc, CurSubmoduleState, PendingModuleMacroNames.size()); // Switch to this submodule as the current submodule. CurSubmoduleState = &State; Index: lib/Lex/PPMacroExpansion.cpp =================================================================== --- lib/Lex/PPMacroExpansion.cpp +++ lib/Lex/PPMacroExpansion.cpp @@ -475,8 +475,7 @@ // reading the function macro arguments. To ensure, in that case, that // MacroExpands callbacks still happen in source order, queue this // callback to have it happen after the function macro callback. - DelayedMacroExpandsCallbacks.push_back( - MacroExpandsInfo(Identifier, M, ExpansionRange)); + DelayedMacroExpandsCallbacks.emplace_back(Identifier, M, ExpansionRange); } else { Callbacks->MacroExpands(Identifier, M, ExpansionRange, Args); if (!DelayedMacroExpandsCallbacks.empty()) { Index: lib/LibDriver/LibDriver.cpp =================================================================== --- lib/LibDriver/LibDriver.cpp +++ lib/LibDriver/LibDriver.cpp @@ -69,11 +69,11 @@ StringSaver &Saver) { std::vector Ret; // Add current directory as first item of the search path. - Ret.push_back(""); + Ret.emplace_back(""); // Add /libpath flags. for (auto *Arg : Args->filtered(OPT_libpath)) - Ret.push_back(Arg->getValue()); + Ret.emplace_back(Arg->getValue()); // Add $LIB. Optional EnvOpt = sys::Process::GetEnv("LIB"); Index: lib/MC/ConstantPools.cpp =================================================================== --- lib/MC/ConstantPools.cpp +++ lib/MC/ConstantPools.cpp @@ -39,7 +39,7 @@ unsigned Size, SMLoc Loc) { MCSymbol *CPEntryLabel = Context.createTempSymbol(); - Entries.push_back(ConstantPoolEntry(CPEntryLabel, Value, Size, Loc)); + Entries.emplace_back(CPEntryLabel, Value, Size, Loc); return MCSymbolRefExpr::create(CPEntryLabel, Context); } Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -3334,7 +3334,7 @@ return Error(Loc, "expected identifier in directive"); MCSymbol *GapEndSym = getContext().getOrCreateSymbol(GapEndName); - Ranges.push_back({GapStartSym, GapEndSym}); + Ranges.emplace_back(GapStartSym, GapEndSym); } if (getLexer().isNot(AsmToken::Comma)) Index: lib/MC/MCStreamer.cpp =================================================================== --- lib/MC/MCStreamer.cpp +++ lib/MC/MCStreamer.cpp @@ -44,7 +44,7 @@ MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx), CurrentWinFrameInfo(nullptr) { - SectionStack.push_back(std::pair()); + SectionStack.emplace_back(); } MCStreamer::~MCStreamer() { @@ -60,7 +60,7 @@ CurrentWinFrameInfo = nullptr; SymbolOrdering.clear(); SectionStack.clear(); - SectionStack.push_back(std::pair()); + SectionStack.emplace_back(); } raw_ostream &MCStreamer::GetCommentOS() { Index: lib/Object/SymbolSize.cpp =================================================================== --- lib/Object/SymbolSize.cpp +++ lib/Object/SymbolSize.cpp @@ -52,7 +52,7 @@ if (Syms.begin() == Syms.end()) Syms = E->getDynamicSymbolIterators(); for (ELFSymbolRef Sym : Syms) - Ret.push_back({Sym, Sym.getSize()}); + Ret.emplace_back(Sym, Sym.getSize()); return Ret; } Index: lib/Parse/ParseDecl.cpp =================================================================== --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -291,7 +291,7 @@ } if (IsIdentifierArg) - ArgExprs.push_back(ParseIdentifierLoc()); + ArgExprs.emplace_back(ParseIdentifierLoc()); } if (!ArgExprs.empty() ? Tok.is(tok::comma) : Tok.isNot(tok::r_paren)) { @@ -312,7 +312,7 @@ SkipUntil(tok::r_paren, StopAtSemi); return 0; } - ArgExprs.push_back(ArgExpr.get()); + ArgExprs.emplace_back(ArgExpr.get()); // Eat the comma, move to the next argument } while (TryConsumeToken(tok::comma)); } @@ -2523,7 +2523,7 @@ *EndLoc = T.getCloseLocation(); ArgsVector ArgExprs; - ArgExprs.push_back(ArgExpr.get()); + ArgExprs.emplace_back(ArgExpr.get()); Attrs.addNew(KWName, KWLoc, nullptr, KWLoc, ArgExprs.data(), 1, AttributeList::AS_Keyword, EllipsisLoc); } Index: lib/Parse/ParseDeclCXX.cpp =================================================================== --- lib/Parse/ParseDeclCXX.cpp +++ lib/Parse/ParseDeclCXX.cpp @@ -1994,8 +1994,8 @@ // defaults will be NULL. LateMethod->DefaultArgs.reserve(FTI.NumParams); for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx) - LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument( - FTI.Params[ParamIdx].Param, FTI.Params[ParamIdx].DefaultArgTokens)); + LateMethod->DefaultArgs.emplace_back( + FTI.Params[ParamIdx].Param, FTI.Params[ParamIdx].DefaultArgTokens); } } Index: lib/Parse/ParseExpr.cpp =================================================================== --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -1996,7 +1996,7 @@ // Keep track of the various subcomponents we see. SmallVector Comps; - Comps.push_back(Sema::OffsetOfComponent()); + Comps.emplace_back(); Comps.back().isBrackets = false; Comps.back().U.IdentInfo = Tok.getIdentifierInfo(); Comps.back().LocStart = Comps.back().LocEnd = ConsumeToken(); @@ -2005,7 +2005,7 @@ while (1) { if (Tok.is(tok::period)) { // offsetof-member-designator: offsetof-member-designator '.' identifier - Comps.push_back(Sema::OffsetOfComponent()); + Comps.emplace_back(); Comps.back().isBrackets = false; Comps.back().LocStart = ConsumeToken(); @@ -2022,7 +2022,7 @@ return ExprError(); // offsetof-member-designator: offsetof-member-design '[' expression ']' - Comps.push_back(Sema::OffsetOfComponent()); + Comps.emplace_back(); Comps.back().isBrackets = true; BalancedDelimiterTracker ST(*this, tok::l_square); ST.consumeOpen(); Index: lib/Parse/ParseObjc.cpp =================================================================== --- lib/Parse/ParseObjc.cpp +++ lib/Parse/ParseObjc.cpp @@ -1509,10 +1509,10 @@ ParseDeclarator(ParmDecl); IdentifierInfo *ParmII = ParmDecl.getIdentifier(); Decl *Param = Actions.ActOnParamDeclarator(getCurScope(), ParmDecl); - CParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII, + CParamInfo.emplace_back(ParmII, ParmDecl.getIdentifierLoc(), Param, - nullptr)); + nullptr); } // FIXME: Add support for optional parameter list... @@ -1649,8 +1649,8 @@ // FIXME: Also include types here. SmallVector identifierLocPairs; for (unsigned i = 0, n = identifiers.size(); i != n; ++i) { - identifierLocPairs.push_back(IdentifierLocPair(identifiers[i], - identifierLocs[i])); + identifierLocPairs.emplace_back(identifiers[i], + identifierLocs[i]); } QualType BaseT = Actions.GetTypeFromParser(baseType); @@ -2065,8 +2065,8 @@ SkipUntil(tok::semi); return nullptr; } - ProtocolRefs.push_back(IdentifierLocPair(Tok.getIdentifierInfo(), - Tok.getLocation())); + ProtocolRefs.emplace_back(Tok.getIdentifierInfo(), + Tok.getLocation()); ConsumeToken(); // the identifier if (Tok.isNot(tok::comma)) Index: lib/Parse/ParseStmtAsm.cpp =================================================================== --- lib/Parse/ParseStmtAsm.cpp +++ lib/Parse/ParseStmtAsm.cpp @@ -405,7 +405,7 @@ SrcMgr.getDecomposedExpansionLoc(EndLoc); FID = ExpAsmLoc.first; LineNo = SrcMgr.getLineNumber(FID, ExpAsmLoc.second); - LBraceLocs.push_back(SourceLocation()); + LBraceLocs.emplace_back(); } SourceLocation TokLoc = Tok.getLocation(); Index: lib/ProfileData/Coverage/CoverageMappingReader.cpp =================================================================== --- lib/ProfileData/Coverage/CoverageMappingReader.cpp +++ lib/ProfileData/Coverage/CoverageMappingReader.cpp @@ -218,9 +218,9 @@ dbgs() << "\n"; }); - MappingRegions.push_back(CounterMappingRegion( + MappingRegions.emplace_back( C, InferredFileID, ExpandedFileID, LineStart, ColumnStart, - LineStart + NumLines, ColumnEnd, Kind)); + LineStart + NumLines, ColumnEnd, Kind); } return Error::success(); } Index: lib/Sema/AnalysisBasedWarnings.cpp =================================================================== --- lib/Sema/AnalysisBasedWarnings.cpp +++ lib/Sema/AnalysisBasedWarnings.cpp @@ -1260,7 +1260,7 @@ } } - UsesByStmt.push_back(StmtUsesPair(UI->getUseExpr(), I)); + UsesByStmt.emplace_back(UI->getUseExpr(), I); } if (UsesByStmt.empty()) Index: lib/Sema/CodeCompleteConsumer.cpp =================================================================== --- lib/Sema/CodeCompleteConsumer.cpp +++ lib/Sema/CodeCompleteConsumer.cpp @@ -340,7 +340,7 @@ } void CodeCompletionBuilder::AddTypedTextChunk(const char *Text) { - Chunks.push_back(Chunk(CodeCompletionString::CK_TypedText, Text)); + Chunks.emplace_back(CodeCompletionString::CK_TypedText, Text); } void CodeCompletionBuilder::AddTextChunk(const char *Text) { @@ -370,7 +370,7 @@ void CodeCompletionBuilder::AddChunk(CodeCompletionString::ChunkKind CK, const char *Text) { - Chunks.push_back(Chunk(CK, Text)); + Chunks.emplace_back(CK, Text); } void CodeCompletionBuilder::addParentContext(const DeclContext *DC) { Index: lib/Sema/JumpDiagnostics.cpp =================================================================== --- lib/Sema/JumpDiagnostics.cpp +++ lib/Sema/JumpDiagnostics.cpp @@ -95,7 +95,7 @@ JumpScopeChecker::JumpScopeChecker(Stmt *Body, Sema &s) : S(s), Permissive(s.hasAnyUnrecoverableErrorsInThisFunction()) { // Add a scope entry for function scope. - Scopes.push_back(GotoScope(~0U, ~0U, ~0U, SourceLocation())); + Scopes.emplace_back(~0U, ~0U, ~0U, SourceLocation()); // Build information for the top level compound statement, so that we have a // defined scope record for every "goto" and label. @@ -217,8 +217,8 @@ // If this decl causes a new scope, push and switch to it. std::pair Diags = GetDiagForGotoScopeDecl(S, D); if (Diags.first || Diags.second) { - Scopes.push_back(GotoScope(ParentScope, Diags.first, Diags.second, - D->getLocation())); + Scopes.emplace_back(ParentScope, Diags.first, Diags.second, + D->getLocation()); ParentScope = Scopes.size()-1; } @@ -260,8 +260,8 @@ SourceLocation Loc = D->getLocation(); if (Loc.isInvalid()) Loc = BDecl->getLocation(); - Scopes.push_back(GotoScope(ParentScope, - Diags.first, Diags.second, Loc)); + Scopes.emplace_back(ParentScope, + Diags.first, Diags.second, Loc); ParentScope = Scopes.size()-1; } } @@ -321,20 +321,20 @@ case Stmt::CXXTryStmtClass: { CXXTryStmt *TS = cast(S); unsigned newParentScope; - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_cxx_try, diag::note_exits_cxx_try, - TS->getSourceRange().getBegin())); + TS->getSourceRange().getBegin()); if (Stmt *TryBlock = TS->getTryBlock()) BuildScopeInformation(TryBlock, (newParentScope = Scopes.size()-1)); // Jump from the catch into the try is not allowed either. for (unsigned I = 0, E = TS->getNumHandlers(); I != E; ++I) { CXXCatchStmt *CS = TS->getHandler(I); - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_cxx_catch, diag::note_exits_cxx_catch, - CS->getSourceRange().getBegin())); + CS->getSourceRange().getBegin()); BuildScopeInformation(CS->getHandlerBlock(), (newParentScope = Scopes.size()-1)); } @@ -344,26 +344,26 @@ case Stmt::SEHTryStmtClass: { SEHTryStmt *TS = cast(S); unsigned newParentScope; - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_seh_try, diag::note_exits_seh_try, - TS->getSourceRange().getBegin())); + TS->getSourceRange().getBegin()); if (Stmt *TryBlock = TS->getTryBlock()) BuildScopeInformation(TryBlock, (newParentScope = Scopes.size()-1)); // Jump from __except or __finally into the __try are not allowed either. if (SEHExceptStmt *Except = TS->getExceptHandler()) { - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_seh_except, diag::note_exits_seh_except, - Except->getSourceRange().getBegin())); + Except->getSourceRange().getBegin()); BuildScopeInformation(Except->getBlock(), (newParentScope = Scopes.size()-1)); } else if (SEHFinallyStmt *Finally = TS->getFinallyHandler()) { - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_seh_finally, diag::note_exits_seh_finally, - Finally->getSourceRange().getBegin())); + Finally->getSourceRange().getBegin()); BuildScopeInformation(Finally->getBlock(), (newParentScope = Scopes.size()-1)); } @@ -415,20 +415,20 @@ if (ObjCAtTryStmt *AT = dyn_cast(SubStmt)) { unsigned newParentScope; // Recursively walk the AST for the @try part. - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_objc_try, diag::note_exits_objc_try, - AT->getAtTryLoc())); + AT->getAtTryLoc()); if (Stmt *TryPart = AT->getTryBody()) BuildScopeInformation(TryPart, (newParentScope = Scopes.size()-1)); // Jump from the catch to the finally or try is not valid. for (unsigned I = 0, N = AT->getNumCatchStmts(); I != N; ++I) { ObjCAtCatchStmt *AC = AT->getCatchStmt(I); - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_objc_catch, diag::note_exits_objc_catch, - AC->getAtCatchLoc())); + AC->getAtCatchLoc()); // @catches are nested and it isn't BuildScopeInformation(AC->getCatchBody(), (newParentScope = Scopes.size()-1)); @@ -436,10 +436,10 @@ // Jump from the finally to the try or catch is not valid. if (ObjCAtFinallyStmt *AF = AT->getFinallyStmt()) { - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_objc_finally, diag::note_exits_objc_finally, - AF->getAtFinallyLoc())); + AF->getAtFinallyLoc()); BuildScopeInformation(AF, (newParentScope = Scopes.size()-1)); } @@ -457,10 +457,10 @@ // Recursively walk the AST for the @synchronized part, protected by a new // scope. - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_objc_synchronized, diag::note_exits_objc_synchronized, - AS->getAtSynchronizedLoc())); + AS->getAtSynchronizedLoc()); BuildScopeInformation(AS->getSynchBody(), (newParentScope = Scopes.size()-1)); continue; @@ -471,10 +471,10 @@ dyn_cast(SubStmt)) { // Recursively walk the AST for the @autoreleasepool part, protected by a // new scope. - Scopes.push_back(GotoScope(ParentScope, + Scopes.emplace_back(ParentScope, diag::note_protected_by_objc_autoreleasepool, diag::note_exits_objc_autoreleasepool, - AS->getAtLoc())); + AS->getAtLoc()); BuildScopeInformation(AS->getSubStmt(), (newParentScope = Scopes.size() - 1)); continue; @@ -504,9 +504,9 @@ MTE->GetTemporaryExpr()->skipRValueSubobjectAdjustments( CommaLHS, Adjustments); if (ExtendedObject->getType().isDestructedType()) { - Scopes.push_back(GotoScope(ParentScope, 0, + Scopes.emplace_back(ParentScope, 0, diag::note_exits_temporary_dtor, - ExtendedObject->getExprLoc())); + ExtendedObject->getExprLoc()); ParentScope = Scopes.size()-1; } } Index: lib/Sema/ScopeInfo.cpp =================================================================== --- lib/Sema/ScopeInfo.cpp +++ lib/Sema/ScopeInfo.cpp @@ -157,7 +157,7 @@ assert(Msg && Prop); WeakUseVector &Uses = WeakObjectUses[WeakObjectProfileTy(Msg->getInstanceReceiver(), Prop)]; - Uses.push_back(WeakUseTy(Msg, Msg->getNumArgs() == 0)); + Uses.emplace_back(Msg, Msg->getNumArgs() == 0); } void FunctionScopeInfo::markSafeWeakUse(const Expr *E) { Index: lib/Sema/Sema.cpp =================================================================== --- lib/Sema/Sema.cpp +++ lib/Sema/Sema.cpp @@ -1157,7 +1157,7 @@ } void Sema::PushCompoundScope() { - getCurFunction()->CompoundScopes.push_back(CompoundScopeInfo()); + getCurFunction()->CompoundScopes.emplace_back(); } void Sema::PopCompoundScope() { Index: lib/Sema/SemaAttr.cpp =================================================================== --- lib/Sema/SemaAttr.cpp +++ lib/Sema/SemaAttr.cpp @@ -218,7 +218,7 @@ return; } if (Action & PSK_Push) - Stack.push_back(Slot(StackSlotLabel, CurrentValue, CurrentPragmaLocation)); + Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation); else if (Action & PSK_Pop) { if (!StackSlotLabel.empty()) { // If we've got a label, try to find it and jump there. Index: lib/Sema/SemaCast.cpp =================================================================== --- lib/Sema/SemaCast.cpp +++ lib/Sema/SemaCast.cpp @@ -1800,15 +1800,15 @@ } else { // __attribute__((stdcall)) or __attribute__((vectorcall)) OS << "__attribute__((" << DstCCName << "))"; - AttrTokens.push_back(tok::kw___attribute); - AttrTokens.push_back(tok::l_paren); - AttrTokens.push_back(tok::l_paren); + AttrTokens.emplace_back(tok::kw___attribute); + AttrTokens.emplace_back(tok::l_paren); + AttrTokens.emplace_back(tok::l_paren); IdentifierInfo *II = PP.getIdentifierInfo(DstCCName); AttrTokens.push_back(II->isKeyword(Self.getLangOpts()) ? TokenValue(II->getTokenID()) : TokenValue(II)); - AttrTokens.push_back(tok::r_paren); - AttrTokens.push_back(tok::r_paren); + AttrTokens.emplace_back(tok::r_paren); + AttrTokens.emplace_back(tok::r_paren); } StringRef AttrSpelling = PP.getLastMacroWithSpelling(NameLoc, AttrTokens); if (!AttrSpelling.empty()) Index: lib/Sema/SemaDeclCXX.cpp =================================================================== --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -13409,7 +13409,7 @@ } VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired; - NewUses.push_back(VTableUse(VTables[I].Record, VTables[I].Location)); + NewUses.emplace_back(VTables[I].Record, VTables[I].Location); } VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end()); Index: lib/Sema/SemaDeclObjC.cpp =================================================================== --- lib/Sema/SemaDeclObjC.cpp +++ lib/Sema/SemaDeclObjC.cpp @@ -1448,23 +1448,23 @@ NamedDecl *decl = LookupSingleName(S, identifiers[i], identifierLocs[i], LookupOrdinaryName); if (!decl) { - typeDecls.push_back(TypeOrClassDecl()); + typeDecls.emplace_back(); continue; } if (auto typeDecl = dyn_cast(decl)) { - typeDecls.push_back(typeDecl); + typeDecls.emplace_back(typeDecl); ++numTypeDeclsResolved; continue; } if (auto objcClass = dyn_cast(decl)) { - typeDecls.push_back(objcClass); + typeDecls.emplace_back(objcClass); ++numTypeDeclsResolved; continue; } - typeDecls.push_back(TypeOrClassDecl()); + typeDecls.emplace_back(); } AttributeFactory attrFactory; Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -11731,7 +11731,7 @@ << Idx->getSourceRange()); // Record this array index. - Comps.push_back(OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd)); + Comps.emplace_back(OC.LocStart, Exprs.size(), OC.LocEnd); Exprs.push_back(Idx); continue; } @@ -11740,7 +11740,7 @@ if (CurrentType->isDependentType()) { // We have the offset of a field, but we can't look into the dependent // type. Just record the identifier of the field. - Comps.push_back(OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd)); + Comps.emplace_back(OC.LocStart, OC.U.IdentInfo, OC.LocEnd); CurrentType = Context.DependentTy; continue; } @@ -11829,11 +11829,11 @@ if (IndirectMemberDecl) { for (auto *FI : IndirectMemberDecl->chain()) { assert(isa(FI)); - Comps.push_back(OffsetOfNode(OC.LocStart, - cast(FI), OC.LocEnd)); + Comps.emplace_back(OC.LocStart, + cast(FI), OC.LocEnd); } } else - Comps.push_back(OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd)); + Comps.emplace_back(OC.LocStart, MemberDecl, OC.LocEnd); CurrentType = MemberDecl->getType().getNonReferenceType(); } @@ -13066,15 +13066,14 @@ if (isa(Func->getDeclContext()) && cast(Func->getDeclContext())->isLocalClass() && ActiveTemplateInstantiations.size()) - PendingLocalImplicitInstantiations.push_back( - std::make_pair(Func, PointOfInstantiation)); + PendingLocalImplicitInstantiations.emplace_back(std::make_pair(Func, PointOfInstantiation)); else if (Func->isConstexpr()) // Do not defer instantiations of constexpr functions, to avoid the // expression evaluator needing to call back into Sema if it sees a // call to such a function. InstantiateFunctionDefinition(PointOfInstantiation, Func); else { - PendingInstantiations.push_back(std::make_pair(Func, + PendingInstantiations.emplace_back(std::make_pair(Func, PointOfInstantiation)); // Notify the consumer that a function was implicitly instantiated. Consumer.HandleCXXImplicitFunctionInstantiation(Func); @@ -13924,7 +13923,7 @@ SemaRef.InstantiateVariableDefinition(PointOfInstantiation, Var); } else { SemaRef.PendingInstantiations - .push_back(std::make_pair(Var, PointOfInstantiation)); + .emplace_back(std::make_pair(Var, PointOfInstantiation)); } } } Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -4356,10 +4356,9 @@ QualType ArgTy = Args[I]->getType(); if (ArgTy->isObjectType() || ArgTy->isFunctionType()) ArgTy = S.Context.getRValueReferenceType(ArgTy); - OpaqueArgExprs.push_back( - OpaqueValueExpr(Args[I]->getTypeLoc().getLocStart(), + OpaqueArgExprs.emplace_back(Args[I]->getTypeLoc().getLocStart(), ArgTy.getNonLValueExprType(S.Context), - Expr::getValueKindForType(ArgTy))); + Expr::getValueKindForType(ArgTy)); } for (Expr &E : OpaqueArgExprs) ArgExprs.push_back(&E); @@ -5429,7 +5428,7 @@ QualifierUnion.push_back( Composite1.getCVRQualifiers() | Composite2.getCVRQualifiers()); - MemberOfClass.push_back(std::make_pair(nullptr, nullptr)); + MemberOfClass.emplace_back(std::make_pair(nullptr, nullptr)); continue; } Index: lib/Sema/SemaInit.cpp =================================================================== --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -1953,12 +1953,12 @@ for (IndirectFieldDecl::chain_iterator PI = IndirectField->chain_begin(), PE = IndirectField->chain_end(); PI != PE; ++PI) { if (PI + 1 == PE) - Replacements.push_back(Designator((IdentifierInfo *)nullptr, + Replacements.emplace_back((IdentifierInfo *)nullptr, DIE->getDesignator(DesigIdx)->getDotLoc(), - DIE->getDesignator(DesigIdx)->getFieldLoc())); + DIE->getDesignator(DesigIdx)->getFieldLoc()); else - Replacements.push_back(Designator((IdentifierInfo *)nullptr, - SourceLocation(), SourceLocation())); + Replacements.emplace_back((IdentifierInfo *)nullptr, + SourceLocation(), SourceLocation()); assert(isa(*PI)); Replacements.back().setField(cast(*PI)); } @@ -2764,8 +2764,8 @@ const Designator &D = Desig.getDesignator(Idx); switch (D.getKind()) { case Designator::FieldDesignator: - Designators.push_back(ASTDesignator(D.getField(), D.getDotLoc(), - D.getFieldLoc())); + Designators.emplace_back(D.getField(), D.getDotLoc(), + D.getFieldLoc()); break; case Designator::ArrayDesignator: { @@ -2776,9 +2776,9 @@ if (!Index) Invalid = true; else { - Designators.push_back(ASTDesignator(InitExpressions.size(), + Designators.emplace_back(InitExpressions.size(), D.getLBracketLoc(), - D.getRBracketLoc())); + D.getRBracketLoc()); InitExpressions.push_back(Index); } break; @@ -2816,10 +2816,10 @@ << StartIndex->getSourceRange() << EndIndex->getSourceRange(); Invalid = true; } else { - Designators.push_back(ASTDesignator(InitExpressions.size(), + Designators.emplace_back(InitExpressions.size(), D.getLBracketLoc(), D.getEllipsisLoc(), - D.getRBracketLoc())); + D.getRBracketLoc()); InitExpressions.push_back(StartIndex); InitExpressions.push_back(EndIndex); } Index: lib/Sema/SemaLambda.cpp =================================================================== --- lib/Sema/SemaLambda.cpp +++ lib/Sema/SemaLambda.cpp @@ -1533,16 +1533,14 @@ // Handle 'this' capture. if (From.isThisCapture()) { - Captures.push_back( - LambdaCapture(From.getLocation(), IsImplicit, - From.isCopyCapture() ? LCK_StarThis : LCK_This)); + Captures.emplace_back(From.getLocation(), IsImplicit, + From.isCopyCapture() ? LCK_StarThis : LCK_This); CaptureInits.push_back(From.getInitExpr()); ArrayIndexStarts.push_back(ArrayIndexVars.size()); continue; } if (From.isVLATypeCapture()) { - Captures.push_back( - LambdaCapture(From.getLocation(), IsImplicit, LCK_VLAType)); + Captures.emplace_back(From.getLocation(), IsImplicit, LCK_VLAType); CaptureInits.push_back(nullptr); ArrayIndexStarts.push_back(ArrayIndexVars.size()); continue; @@ -1550,8 +1548,8 @@ VarDecl *Var = From.getVariable(); LambdaCaptureKind Kind = From.isCopyCapture() ? LCK_ByCopy : LCK_ByRef; - Captures.push_back(LambdaCapture(From.getLocation(), IsImplicit, Kind, - Var, From.getEllipsisLoc())); + Captures.emplace_back(From.getLocation(), IsImplicit, Kind, + Var, From.getEllipsisLoc()); Expr *Init = From.getInitExpr(); if (!Init) { auto InitResult = performLambdaVarCaptureInitialization( Index: lib/Sema/SemaLookup.cpp =================================================================== --- lib/Sema/SemaLookup.cpp +++ lib/Sema/SemaLookup.cpp @@ -185,7 +185,7 @@ Common = Common->getParent(); Common = Common->getPrimaryContext(); - list.push_back(UnqualUsingEntry(UD->getNominatedNamespace(), Common)); + list.emplace_back(UD->getNominatedNamespace(), Common); } void done() { Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -9690,7 +9690,7 @@ DepCounter.getZExtValue()); continue; } - OpsOffs.push_back({RHS, OOK}); + OpsOffs.emplace_back(RHS, OOK); } else { // OpenMP [2.11.1.1, Restrictions, p.3] // A variable that is part of another variable (such as a field of a @@ -9959,8 +9959,8 @@ AllowWholeSizeArraySection = false; // Record the component. - CurComponents.push_back(OMPClauseMappableExprCommon::MappableComponent( - CurE, CurE->getDecl())); + CurComponents.emplace_back( + CurE, CurE->getDecl()); continue; } @@ -10017,8 +10017,7 @@ AllowWholeSizeArraySection = false; // Record the component. - CurComponents.push_back( - OMPClauseMappableExprCommon::MappableComponent(CurE, FD)); + CurComponents.emplace_back(CurE, FD); continue; } @@ -10039,8 +10038,7 @@ AllowWholeSizeArraySection = false; // Record the component - we don't have any declaration associated. - CurComponents.push_back( - OMPClauseMappableExprCommon::MappableComponent(CurE, nullptr)); + CurComponents.emplace_back(CurE, nullptr); continue; } @@ -10088,8 +10086,7 @@ } // Record the component - we don't have any declaration associated. - CurComponents.push_back( - OMPClauseMappableExprCommon::MappableComponent(CurE, nullptr)); + CurComponents.emplace_back(CurE, nullptr); continue; } Index: lib/Sema/SemaTemplate.cpp =================================================================== --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -2798,7 +2798,7 @@ MakeDeductionFailureInfo(Context, Result, Info)); (void)Result; } else { - Matched.push_back(PartialSpecMatchResult()); + Matched.emplace_back(); Matched.back().Partial = Partial; Matched.back().Args = Info.take(); } Index: lib/Sema/SemaTemplateDeduction.cpp =================================================================== --- lib/Sema/SemaTemplateDeduction.cpp +++ lib/Sema/SemaTemplateDeduction.cpp @@ -3421,8 +3421,8 @@ // Keep track of the argument type and corresponding parameter index, // so we can check for compatibility between the deduced A and A. - OriginalCallArgs.push_back(OriginalCallArg(OrigParamType, ArgIdx-1, - ArgType)); + OriginalCallArgs.emplace_back(OrigParamType, ArgIdx-1, + ArgType); if (TemplateDeductionResult Result = DeduceTemplateArgumentsByTypeMatch(*this, TemplateParams, @@ -3484,8 +3484,8 @@ // Keep track of the argument type and corresponding argument index, // so we can check for compatibility between the deduced A and A. if (hasDeducibleTemplateParameters(*this, FunctionTemplate, ParamType)) - OriginalCallArgs.push_back(OriginalCallArg(OrigParamType, ArgIdx, - ArgType)); + OriginalCallArgs.emplace_back(OrigParamType, ArgIdx, + ArgType); if (TemplateDeductionResult Result = DeduceTemplateArgumentsByTypeMatch(*this, TemplateParams, Index: lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- lib/Sema/SemaTemplateInstantiate.cpp +++ lib/Sema/SemaTemplateInstantiate.cpp @@ -2333,7 +2333,7 @@ MakeDeductionFailureInfo(Context, Result, Info)); (void)Result; } else { - Matched.push_back(PartialSpecMatchResult()); + Matched.emplace_back(); Matched.back().Partial = Partial; Matched.back().Args = Info.take(); } @@ -2492,8 +2492,7 @@ } else if (TSK == TSK_ExplicitInstantiationDefinition) { InstantiateFunctionDefinition(PointOfInstantiation, Function); } else if (TSK == TSK_ImplicitInstantiation) { - PendingLocalImplicitInstantiations.push_back( - std::make_pair(Function, PointOfInstantiation)); + PendingLocalImplicitInstantiations.emplace_back(std::make_pair(Function, PointOfInstantiation)); } } } else if (auto *Var = dyn_cast(D)) { Index: lib/Sema/SemaTemplateInstantiateDecl.cpp =================================================================== --- lib/Sema/SemaTemplateInstantiateDecl.cpp +++ lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1719,8 +1719,7 @@ if (MSInfo->getPointOfInstantiation().isInvalid()) { SourceLocation Loc = R->getLocation(); // FIXME MSInfo->setPointOfInstantiation(Loc); - SemaRef.PendingLocalImplicitInstantiations.push_back( - std::make_pair(Function, Loc)); + SemaRef.PendingLocalImplicitInstantiations.emplace_back(std::make_pair(Function, Loc)); QueuedInstantiation = true; } } @@ -3556,8 +3555,7 @@ // Postpone late parsed template instantiations. if (PatternDecl->isLateTemplateParsed() && !LateTemplateParser) { - PendingInstantiations.push_back( - std::make_pair(Function, PointOfInstantiation)); + PendingInstantiations.emplace_back(std::make_pair(Function, PointOfInstantiation)); return; } @@ -3607,8 +3605,7 @@ } else if (Function->getTemplateSpecializationKind() == TSK_ExplicitInstantiationDefinition) { assert(!Recursive); - PendingInstantiations.push_back( - std::make_pair(Function, PointOfInstantiation)); + PendingInstantiations.emplace_back(std::make_pair(Function, PointOfInstantiation)); } else if (Function->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) { if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) { @@ -4109,8 +4106,7 @@ Var->setInvalidDecl(); } else if (Var->getTemplateSpecializationKind() == TSK_ExplicitInstantiationDefinition) { - PendingInstantiations.push_back( - std::make_pair(Var, PointOfInstantiation)); + PendingInstantiations.emplace_back(std::make_pair(Var, PointOfInstantiation)); } else if (Var->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) { // Warn about missing definition at the end of translation unit. Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -1644,7 +1644,7 @@ ModuleFile *M, uint64_t MacroDirectivesOffset) { assert(NumCurrentElementsDeserializing > 0 &&"Missing deserialization guard"); - PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset)); + PendingMacroIDs[II].emplace_back(M, MacroDirectivesOffset); } void ASTReader::ReadDefinedMacros() { @@ -3149,7 +3149,7 @@ unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]); SourceLocation Loc = ReadSourceLocation(F, Record, I); if (GlobalID) - ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc)); + ImportedModules.emplace_back(GlobalID, Loc); } } break; @@ -5151,9 +5151,8 @@ SourceLocation Loc = ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]); unsigned DiagStateID = F.PragmaDiagMappings[Idx++]; if (DiagStateID != 0) { - Diag.DiagStatePoints.push_back( - DiagnosticsEngine::DiagStatePoint(DiagStates[DiagStateID-1], - FullSourceLoc(Loc, SourceMgr))); + Diag.DiagStatePoints.emplace_back(DiagStates[DiagStateID-1], + FullSourceLoc(Loc, SourceMgr)); continue; } @@ -5162,9 +5161,8 @@ Diag.DiagStates.push_back(*Diag.GetCurDiagState()); DiagnosticsEngine::DiagState *NewState = &Diag.DiagStates.back(); DiagStates.push_back(NewState); - Diag.DiagStatePoints.push_back( - DiagnosticsEngine::DiagStatePoint(NewState, - FullSourceLoc(Loc, SourceMgr))); + Diag.DiagStatePoints.emplace_back(NewState, + FullSourceLoc(Loc, SourceMgr)); while (1) { assert(Idx < F.PragmaDiagMappings.size() && "Invalid data, didn't find '-1' marking end of diag/map pairs"); Index: lib/Serialization/ASTReaderDecl.cpp =================================================================== --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1324,7 +1324,7 @@ bool nested = (flags & 2); Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) : nullptr); - captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr)); + captures.emplace_back(decl, byRef, nested, copyExpr); } BD->setCaptures(Reader.getContext(), captures, capturesCXXThis); } @@ -2274,7 +2274,7 @@ // above; this ensures that the redeclaration chain is built in the correct // order. if (IsFirstLocalDecl) - Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset)); + Reader.PendingDeclChains.emplace_back(std::make_pair(DAsT, RedeclOffset)); return RedeclarableResult(FirstDeclID, MergeWith, IsKeyDecl); } Index: lib/Serialization/ASTReaderStmt.cpp =================================================================== --- lib/Serialization/ASTReaderStmt.cpp +++ lib/Serialization/ASTReaderStmt.cpp @@ -361,7 +361,7 @@ Clobbers.reserve(S->NumClobbers); for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) { ClobbersData.push_back(ReadString(Record, Idx)); - Clobbers.push_back(ClobbersData.back()); + Clobbers.emplace_back(ClobbersData.back()); } // Read the operands. @@ -375,7 +375,7 @@ for (unsigned i = 0; i != NumOperands; ++i) { Exprs.push_back(cast(Reader.ReadSubStmt())); ConstraintsData.push_back(ReadString(Record, Idx)); - Constraints.push_back(ConstraintsData.back()); + Constraints.emplace_back(ConstraintsData.back()); } S->initialize(Reader.getContext(), AsmStr, AsmToks, @@ -788,8 +788,8 @@ = ReadSourceLocation(Record, Idx); SourceLocation FieldLoc = ReadSourceLocation(Record, Idx); - Designators.push_back(Designator(Field->getIdentifier(), DotLoc, - FieldLoc)); + Designators.emplace_back(Field->getIdentifier(), DotLoc, + FieldLoc); Designators.back().setField(Field); break; } @@ -800,7 +800,7 @@ = ReadSourceLocation(Record, Idx); SourceLocation FieldLoc = ReadSourceLocation(Record, Idx); - Designators.push_back(Designator(Name, DotLoc, FieldLoc)); + Designators.emplace_back(Name, DotLoc, FieldLoc); break; } @@ -810,7 +810,7 @@ = ReadSourceLocation(Record, Idx); SourceLocation RBracketLoc = ReadSourceLocation(Record, Idx); - Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); + Designators.emplace_back(Index, LBracketLoc, RBracketLoc); break; } @@ -822,8 +822,8 @@ = ReadSourceLocation(Record, Idx); SourceLocation RBracketLoc = ReadSourceLocation(Record, Idx); - Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, - RBracketLoc)); + Designators.emplace_back(Index, LBracketLoc, EllipsisLoc, + RBracketLoc); break; } } @@ -2285,8 +2285,8 @@ Expr *AssociatedExpr = Reader->Reader.ReadSubExpr(); ValueDecl *AssociatedDecl = Reader->Reader.ReadDeclAs(Reader->F, Record, Idx); - Components.push_back(OMPClauseMappableExprCommon::MappableComponent( - AssociatedExpr, AssociatedDecl)); + Components.emplace_back( + AssociatedExpr, AssociatedDecl); } C->setComponents(Components, ListSizes); } @@ -2379,8 +2379,8 @@ Expr *AssociatedExpr = Reader->Reader.ReadSubExpr(); ValueDecl *AssociatedDecl = Reader->Reader.ReadDeclAs(Reader->F, Record, Idx); - Components.push_back(OMPClauseMappableExprCommon::MappableComponent( - AssociatedExpr, AssociatedDecl)); + Components.emplace_back( + AssociatedExpr, AssociatedDecl); } C->setComponents(Components, ListSizes); } @@ -2423,8 +2423,8 @@ Expr *AssociatedExpr = Reader->Reader.ReadSubExpr(); ValueDecl *AssociatedDecl = Reader->Reader.ReadDeclAs(Reader->F, Record, Idx); - Components.push_back(OMPClauseMappableExprCommon::MappableComponent( - AssociatedExpr, AssociatedDecl)); + Components.emplace_back( + AssociatedExpr, AssociatedDecl); } C->setComponents(Components, ListSizes); } Index: lib/Serialization/ASTWriter.cpp =================================================================== --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -2346,8 +2346,7 @@ (void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) { Record.clear(); - PreprocessedEntityOffsets.push_back( - PPEntityOffset((*E)->getSourceRange(), Stream.GetCurrentBitNo())); + PreprocessedEntityOffsets.emplace_back((*E)->getSourceRange(), Stream.GetCurrentBitNo()); if (auto *MD = dyn_cast(*E)) { // Record this macro definition's ID. @@ -4345,7 +4344,7 @@ if (NamespaceDecl *NS = TU->getAnonymousNamespace()) { ASTWriter::UpdateRecord &Record = DeclUpdates[TU]; if (Record.empty()) - Record.push_back(DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, NS)); + Record.emplace_back(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, NS); } // Add update records for all mangling numbers and static local numbers. @@ -4353,12 +4352,12 @@ // tagging this rare extra data onto the declarations. for (const auto &Number : Context.MangleNumbers) if (!Number.first->isFromASTFile()) - DeclUpdates[Number.first].push_back(DeclUpdate(UPD_MANGLING_NUMBER, - Number.second)); + DeclUpdates[Number.first].emplace_back(UPD_MANGLING_NUMBER, + Number.second); for (const auto &Number : Context.StaticLocalNumbers) if (!Number.first->isFromASTFile()) - DeclUpdates[Number.first].push_back(DeclUpdate(UPD_STATIC_LOCAL_NUMBER, - Number.second)); + DeclUpdates[Number.first].emplace_back(UPD_STATIC_LOCAL_NUMBER, + Number.second); // Make sure visible decls, added to DeclContexts previously loaded from // an AST file, are registered for serialization. @@ -4586,8 +4585,8 @@ llvm::SmallVector Imports; for (const auto *I : Context.local_imports()) { assert(SubmoduleIDs.find(I->getImportedModule()) != SubmoduleIDs.end()); - Imports.push_back(ModuleInfo(SubmoduleIDs[I->getImportedModule()], - I->getImportedModule())); + Imports.emplace_back(SubmoduleIDs[I->getImportedModule()], + I->getImportedModule()); } if (!Imports.empty()) { @@ -5711,7 +5710,7 @@ // A decl coming from PCH was modified. assert(RD->isCompleteDefinition()); assert(!WritingAST && "Already writing the AST!"); - DeclUpdates[RD].push_back(DeclUpdate(UPD_CXX_ADDED_IMPLICIT_MEMBER, D)); + DeclUpdates[RD].emplace_back(UPD_CXX_ADDED_IMPLICIT_MEMBER, D); } void ASTWriter::ResolvedExceptionSpec(const FunctionDecl *FD) { @@ -5724,7 +5723,7 @@ ->getType() ->castAs() ->getExceptionSpecType())) - DeclUpdates[D].push_back(UPD_CXX_RESOLVED_EXCEPTION_SPEC); + DeclUpdates[D].emplace_back(UPD_CXX_RESOLVED_EXCEPTION_SPEC); }); } @@ -5732,8 +5731,7 @@ assert(!WritingAST && "Already writing the AST!"); if (!Chain) return; Chain->forEachImportedKeyDecl(FD, [&](const Decl *D) { - DeclUpdates[D].push_back( - DeclUpdate(UPD_CXX_DEDUCED_RETURN_TYPE, ReturnType)); + DeclUpdates[D].emplace_back(UPD_CXX_DEDUCED_RETURN_TYPE, ReturnType); }); } @@ -5743,7 +5741,7 @@ assert(Delete && "Not given an operator delete"); if (!Chain) return; Chain->forEachImportedKeyDecl(DD, [&](const Decl *D) { - DeclUpdates[D].push_back(DeclUpdate(UPD_CXX_RESOLVED_DTOR_DELETE, Delete)); + DeclUpdates[D].emplace_back(UPD_CXX_RESOLVED_DTOR_DELETE, Delete); }); } @@ -5771,9 +5769,8 @@ // Since the actual instantiation is delayed, this really means that we need // to update the instantiation location. - DeclUpdates[D].push_back( - DeclUpdate(UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER, - D->getMemberSpecializationInfo()->getPointOfInstantiation())); + DeclUpdates[D].emplace_back(UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER, + D->getMemberSpecializationInfo()->getPointOfInstantiation()); } void ASTWriter::DefaultArgumentInstantiated(const ParmVarDecl *D) { @@ -5781,8 +5778,7 @@ if (!D->isFromASTFile()) return; - DeclUpdates[D].push_back( - DeclUpdate(UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT, D)); + DeclUpdates[D].emplace_back(UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT, D); } void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, @@ -5823,14 +5819,13 @@ if (!D->isFromASTFile()) return; - DeclUpdates[D].push_back( - DeclUpdate(UPD_DECL_MARKED_OPENMP_DECLARETARGET, Attr)); + DeclUpdates[D].emplace_back(UPD_DECL_MARKED_OPENMP_DECLARETARGET, Attr); } void ASTWriter::RedefinedHiddenDefinition(const NamedDecl *D, Module *M) { assert(!WritingAST && "Already writing the AST!"); assert(D->isHidden() && "expected a hidden declaration"); - DeclUpdates[D].push_back(DeclUpdate(UPD_DECL_EXPORTED, M)); + DeclUpdates[D].emplace_back(UPD_DECL_EXPORTED, M); } void ASTWriter::AddedAttributeToRecord(const Attr *Attr, @@ -5838,5 +5833,5 @@ assert(!WritingAST && "Already writing the AST!"); if (!Record->isFromASTFile()) return; - DeclUpdates[Record].push_back(DeclUpdate(UPD_ADDED_ATTR_TO_RECORD, Attr)); + DeclUpdates[Record].emplace_back(UPD_ADDED_ATTR_TO_RECORD, Attr); } Index: lib/Serialization/ASTWriterDecl.cpp =================================================================== --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -246,8 +246,8 @@ if (Writer.getFirstLocalDecl(Specialization) != Specialization) return; - Writer.DeclUpdates[Template].push_back(ASTWriter::DeclUpdate( - UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION, Specialization)); + Writer.DeclUpdates[Template].emplace_back( + UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION, Specialization); } }; } @@ -1088,8 +1088,7 @@ Decl *Parent = cast( D->getParent()->getRedeclContext()->getPrimaryContext()); if (Parent->isFromASTFile() || isa(Parent)) { - Writer.DeclUpdates[Parent].push_back( - ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D)); + Writer.DeclUpdates[Parent].emplace_back(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D); } } } @@ -2132,7 +2131,7 @@ SourceLocation Loc = D->getLocation(); unsigned Index = ID - FirstDeclID; if (DeclOffsets.size() == Index) - DeclOffsets.push_back(DeclOffset(Loc, Offset)); + DeclOffsets.emplace_back(Loc, Offset); else if (DeclOffsets.size() < Index) { // FIXME: Can/should this happen? DeclOffsets.resize(Index+1); Index: lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp @@ -60,8 +60,8 @@ void VisitChild(ExprParent Parent, const Stmt *S) { TypeCallPair AllocCall = Visit(S); if (AllocCall.second && AllocCall.second != S) - Calls.push_back(CallRecord(Parent, cast(S), AllocCall.first, - AllocCall.second)); + Calls.emplace_back(Parent, cast(S), AllocCall.first, + AllocCall.second); } void VisitChildren(const Stmt *S) { Index: lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- lib/StaticAnalyzer/Core/BugReporter.cpp +++ lib/StaticAnalyzer/Core/BugReporter.cpp @@ -580,7 +580,7 @@ LCM[&C->path] = CE->getCalleeContext(); PD.getActivePath().push_front(C); PD.pushActivePath(&C->path); - CallStack.push_back(StackDiagPair(C, N)); + CallStack.emplace_back(C, N); break; } @@ -1144,12 +1144,12 @@ rawAddEdge(NewLoc); if (IsConsumedExpr(CLoc)) { - CLocs.push_back(ContextLocation(CLoc, /*IsDead=*/true)); + CLocs.emplace_back(CLoc, /*IsDead=*/true); return; } } - CLocs.push_back(ContextLocation(CLoc, /*IsDead=*/IsPostJump)); + CLocs.emplace_back(CLoc, /*IsDead=*/IsPostJump); return; } @@ -1210,7 +1210,7 @@ return; if (containsLocation(TopContextLoc, L)) { - CLocs.push_back(L); + CLocs.emplace_back(L); return; } @@ -1218,7 +1218,7 @@ popLocation(); } - CLocs.push_back(L); + CLocs.emplace_back(L); } // Cone-of-influence: support the reverse propagation of "interesting" symbols @@ -1424,7 +1424,7 @@ PD.getActivePath().push_front(C); PD.pushActivePath(&C->path); - CallStack.push_back(StackDiagPair(C, N)); + CallStack.emplace_back(C, N); break; } @@ -1734,7 +1734,7 @@ // Make the contents of the call the active path for now. PD.pushActivePath(&C->path); - CallStack.push_back(StackDiagPair(C, N)); + CallStack.emplace_back(C, N); break; } @@ -2858,7 +2858,7 @@ for (unsigned i = 0, count = Nodes.size(); i < count; ++i) { if (const ExplodedNode *NewNode = ForwardMap.lookup(Nodes[i])) { - ReportNodes.push_back(std::make_pair(NewNode, i)); + ReportNodes.emplace_back(std::make_pair(NewNode, i)); RemainingNodes.insert(NewNode); } } @@ -3332,7 +3332,7 @@ llvm::DenseMap Visited; DFSWorkList WL; - WL.push_back(errorNode); + WL.emplace_back(errorNode); Visited[errorNode] = 1; while (!WL.empty()) { @@ -3359,7 +3359,7 @@ unsigned &mark = Visited[Succ]; if (!mark) { mark = 1; - WL.push_back(Succ); + WL.emplace_back(Succ); break; } } Index: lib/StaticAnalyzer/Core/CheckerRegistry.cpp =================================================================== --- lib/StaticAnalyzer/Core/CheckerRegistry.cpp +++ lib/StaticAnalyzer/Core/CheckerRegistry.cpp @@ -83,7 +83,7 @@ void CheckerRegistry::addChecker(InitializationFunction fn, StringRef name, StringRef desc) { - Checkers.push_back(CheckerInfo(fn, name, desc)); + Checkers.emplace_back(fn, name, desc); // Record the presence of the checker in its packages. StringRef packageName, leafName; Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -111,7 +111,7 @@ SmallVector checkerOpts; for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { const std::pair &opt = opts.CheckersControlList[i]; - checkerOpts.push_back(CheckerOptInfo(opt.first.c_str(), opt.second)); + checkerOpts.emplace_back(opt.first.c_str(), opt.second); } ClangCheckerRegistry allCheckers(plugins, &diags); Index: lib/Support/CommandLine.cpp =================================================================== --- lib/Support/CommandLine.cpp +++ lib/Support/CommandLine.cpp @@ -919,14 +919,14 @@ } if (!PositionalOpts.empty()) { - PositionalVals.push_back(std::make_pair(argv[i], i)); + PositionalVals.emplace_back(std::make_pair(argv[i], i)); // All of the positional arguments have been fulfulled, give the rest to // the consume after option... if it's specified... // if (PositionalVals.size() >= NumPositionalRequired && ConsumeAfterOpt) { for (++i; i < argc; ++i) - PositionalVals.push_back(std::make_pair(argv[i], i)); + PositionalVals.emplace_back(std::make_pair(argv[i], i)); break; // Handle outside of the argument processing loop... } Index: lib/Support/SourceMgr.cpp =================================================================== --- lib/Support/SourceMgr.cpp +++ lib/Support/SourceMgr.cpp @@ -183,7 +183,7 @@ // Translate from SMLoc ranges to column ranges. // FIXME: Handle multibyte characters. - ColRanges.push_back(std::make_pair(R.Start.getPointer()-LineStart, + ColRanges.emplace_back(std::make_pair(R.Start.getPointer()-LineStart, R.End.getPointer()-LineStart)); } Index: lib/Support/TargetRegistry.cpp =================================================================== --- lib/Support/TargetRegistry.cpp +++ lib/Support/TargetRegistry.cpp @@ -119,7 +119,7 @@ std::vector > Targets; size_t Width = 0; for (const auto &T : TargetRegistry::targets()) { - Targets.push_back(std::make_pair(T.getName(), &T)); + Targets.emplace_back(std::make_pair(T.getName(), &T)); Width = std::max(Width, Targets.back().first.size()); } array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn); Index: lib/TableGen/TGParser.cpp =================================================================== --- lib/TableGen/TGParser.cpp +++ lib/TableGen/TGParser.cpp @@ -306,7 +306,7 @@ // Process each value. for (unsigned i = 0; i < List->size(); ++i) { Init *ItemVal = List->resolveListElementReference(*CurRec, nullptr, i); - IterVals.push_back(IterRecord(CurLoop.IterVar, ItemVal)); + IterVals.emplace_back(CurLoop.IterVar, ItemVal); if (ProcessForeachDefs(CurRec, Loc, IterVals)) return true; IterVals.pop_back(); @@ -2068,7 +2068,7 @@ Lex.Lex(); // Eat the in // Create a loop object and remember it. - Loops.push_back(ForeachLoop(IterName, ListValue)); + Loops.emplace_back(IterName, ListValue); if (Lex.getCode() != tgtok::l_brace) { // FOREACH Declaration IN Object Index: lib/Target/AArch64/AArch64ISelLowering.cpp =================================================================== --- lib/Target/AArch64/AArch64ISelLowering.cpp +++ lib/Target/AArch64/AArch64ISelLowering.cpp @@ -2935,7 +2935,7 @@ if ((InFirstByte <= FirstByte && FirstByte <= InLastByte) || (FirstByte <= InFirstByte && InFirstByte <= LastByte)) - ArgChains.push_back(SDValue(L, 1)); + ArgChains.emplace_back(L, 1); } // Build a tokenfactor for all the chains. @@ -8934,8 +8934,8 @@ // Update the uses. SmallVector NewResults; - NewResults.push_back(SDValue(LD, 0)); // The result of load - NewResults.push_back(SDValue(UpdN.getNode(), 2)); // Chain + NewResults.emplace_back(LD, 0); // The result of load + NewResults.emplace_back(UpdN.getNode(), 2); // Chain DCI.CombineTo(LD, NewResults); DCI.CombineTo(N, SDValue(UpdN.getNode(), 0)); // Dup/Inserted Result DCI.CombineTo(User, SDValue(UpdN.getNode(), 1)); // Write back register @@ -9358,9 +9358,9 @@ // Update the uses. std::vector NewResults; for (unsigned i = 0; i < NumResultVecs; ++i) { - NewResults.push_back(SDValue(UpdN.getNode(), i)); + NewResults.emplace_back(UpdN.getNode(), i); } - NewResults.push_back(SDValue(UpdN.getNode(), NumResultVecs + 1)); + NewResults.emplace_back(UpdN.getNode(), NumResultVecs + 1); DCI.CombineTo(N, NewResults); DCI.CombineTo(User, SDValue(UpdN.getNode(), NumResultVecs)); Index: lib/Target/AMDGPU/R600EmitClauseMarkers.cpp =================================================================== --- lib/Target/AMDGPU/R600EmitClauseMarkers.cpp +++ lib/Target/AMDGPU/R600EmitClauseMarkers.cpp @@ -135,20 +135,20 @@ const std::pair &BankLine = getAccessedBankLine(Sel); if (CachedConsts.empty()) { CachedConsts.push_back(BankLine); - UsedKCache.push_back(std::pair(0, KCacheIndex)); + UsedKCache.emplace_back(0, KCacheIndex); continue; } if (CachedConsts[0] == BankLine) { - UsedKCache.push_back(std::pair(0, KCacheIndex)); + UsedKCache.emplace_back(0, KCacheIndex); continue; } if (CachedConsts.size() == 1) { CachedConsts.push_back(BankLine); - UsedKCache.push_back(std::pair(1, KCacheIndex)); + UsedKCache.emplace_back(1, KCacheIndex); continue; } if (CachedConsts[1] == BankLine) { - UsedKCache.push_back(std::pair(1, KCacheIndex)); + UsedKCache.emplace_back(1, KCacheIndex); continue; } return false; Index: lib/Target/AMDGPU/R600InstrInfo.cpp =================================================================== --- lib/Target/AMDGPU/R600InstrInfo.cpp +++ lib/Target/AMDGPU/R600InstrInfo.cpp @@ -344,7 +344,7 @@ } assert(Operand.isGlobal()); } - Result.push_back(std::make_pair(&MO, 0)); + Result.emplace_back(std::make_pair(&MO, 0)); } return Result; } Index: lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp =================================================================== --- lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp +++ lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp @@ -151,14 +151,12 @@ DenseMap::const_iterator PosInUntouched = Untouched->RegToChan.find((*It).first); if (PosInUntouched != Untouched->RegToChan.end()) { - Remap.push_back(std::pair - ((*It).second, (*PosInUntouched).second)); + Remap.emplace_back((*It).second, (*PosInUntouched).second); continue; } if (CurrentUndexIdx >= Untouched->UndefReg.size()) return false; - Remap.push_back(std::pair - ((*It).second, Untouched->UndefReg[CurrentUndexIdx++])); + Remap.emplace_back((*It).second, Untouched->UndefReg[CurrentUndexIdx++]); } return true; Index: lib/Target/AMDGPU/SIFoldOperands.cpp =================================================================== --- lib/Target/AMDGPU/SIFoldOperands.cpp +++ lib/Target/AMDGPU/SIFoldOperands.cpp @@ -186,7 +186,7 @@ return false; } - FoldList.push_back(FoldCandidate(MI, OpNo, OpToFold)); + FoldList.emplace_back(MI, OpNo, OpToFold); return true; } Index: lib/Target/AMDGPU/SIISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/SIISelLowering.cpp +++ lib/Target/AMDGPU/SIISelLowering.cpp @@ -3115,9 +3115,9 @@ } SDLoc DL(Node); - Ops.push_back(SDValue(DAG.getMachineNode(AMDGPU::S_MOV_B32, DL, + Ops.emplace_back(DAG.getMachineNode(AMDGPU::S_MOV_B32, DL, Node->getOperand(i).getValueType(), - Node->getOperand(i)), 0)); + Node->getOperand(i)), 0); } DAG.UpdateNodeOperands(Node, Ops); Index: lib/Target/AMDGPU/SIWholeQuadMode.cpp =================================================================== --- lib/Target/AMDGPU/SIWholeQuadMode.cpp +++ lib/Target/AMDGPU/SIWholeQuadMode.cpp @@ -199,14 +199,14 @@ } Instructions[&MI].Needs = Flags; - Worklist.push_back(&MI); + Worklist.emplace_back(&MI); GlobalFlags |= Flags; } if (WQMOutputs && MBB.succ_empty()) { // This is a prolog shader. Make sure we go back to exact mode at the end. Blocks[&MBB].OutNeeds = StateExact; - Worklist.push_back(&MBB); + Worklist.emplace_back(&MBB); GlobalFlags |= StateExact; } } @@ -232,7 +232,7 @@ BI.Needs |= II.Needs; if ((BI.InNeeds | II.Needs) != BI.InNeeds) { BI.InNeeds |= II.Needs; - Worklist.push_back(&MBB); + Worklist.emplace_back(&MBB); } // Propagate backwards within block @@ -242,7 +242,7 @@ InstrInfo &PrevII = Instructions[PrevMI]; if ((PrevII.OutNeeds | InNeeds) != PrevII.OutNeeds) { PrevII.OutNeeds |= InNeeds; - Worklist.push_back(PrevMI); + Worklist.emplace_back(PrevMI); } } } @@ -281,7 +281,7 @@ continue; DefII.Needs = StateWQM; - Worklist.push_back(DefMI); + Worklist.emplace_back(DefMI); } } } @@ -296,7 +296,7 @@ InstrInfo &LastII = Instructions[LastMI]; if ((LastII.OutNeeds | BI.OutNeeds) != LastII.OutNeeds) { LastII.OutNeeds |= BI.OutNeeds; - Worklist.push_back(LastMI); + Worklist.emplace_back(LastMI); } } @@ -308,7 +308,7 @@ PredBI.OutNeeds |= BI.InNeeds; PredBI.InNeeds |= BI.InNeeds; - Worklist.push_back(Pred); + Worklist.emplace_back(Pred); } // All successors must be prepared to accept the same set of WQM/Exact @@ -319,7 +319,7 @@ continue; SuccBI.InNeeds |= BI.OutNeeds; - Worklist.push_back(Succ); + Worklist.emplace_back(Succ); } } Index: lib/Target/ARM/ARMConstantIslandPass.cpp =================================================================== --- lib/Target/ARM/ARMConstantIslandPass.cpp +++ lib/Target/ARM/ARMConstantIslandPass.cpp @@ -814,7 +814,7 @@ // Record this immediate branch. unsigned MaxOffs = ((1 << (Bits-1))-1) * Scale; - ImmBranches.push_back(ImmBranch(I, MaxOffs, isCond, UOpc)); + ImmBranches.emplace_back(I, MaxOffs, isCond, UOpc); } if (Opc == ARM::tPUSH || Opc == ARM::tPOP_RET) @@ -894,7 +894,7 @@ MachineInstr *CPEMI = CPEMIs[CPI]; unsigned MaxOffs = ((1 << Bits)-1) * Scale; - CPUsers.push_back(CPUser(I, CPEMI, MaxOffs, NegOk, IsSoImm)); + CPUsers.emplace_back(I, CPEMI, MaxOffs, NegOk, IsSoImm); // Increment corresponding CPEntry reference count. CPEntry *CPE = findConstPoolEntry(CPI, CPEMI); @@ -1407,8 +1407,8 @@ BuildMI(UserMBB, DebugLoc(), TII->get(UncondBr)).addMBB(NewMBB) .addImm(ARMCC::AL).addReg(0); unsigned MaxDisp = getUnconditionalBrDisp(UncondBr); - ImmBranches.push_back(ImmBranch(&UserMBB->back(), - MaxDisp, false, UncondBr)); + ImmBranches.emplace_back(&UserMBB->back(), + MaxDisp, false, UncondBr); computeBlockSize(UserMBB); adjustBBOffsetsAfter(UserMBB); return; @@ -1586,7 +1586,7 @@ U.HighWaterMark = NewIsland; U.CPEMI = BuildMI(NewIsland, DebugLoc(), CPEMI->getDesc()) .addImm(ID).addOperand(CPEMI->getOperand(1)).addImm(Size); - CPEntries[CPI].push_back(CPEntry(U.CPEMI, ID, 1)); + CPEntries[CPI].emplace_back(U.CPEMI, ID, 1); ++NumCPEs; // Decrement the old entry, and remove it if refcount becomes 0. @@ -1795,7 +1795,7 @@ BuildMI(MBB, DebugLoc(), TII->get(Br.UncondBr)).addMBB(DestBB); BBInfo[MBB->getNumber()].Size += TII->GetInstSizeInBytes(&MBB->back()); unsigned MaxDisp = getUnconditionalBrDisp(Br.UncondBr); - ImmBranches.push_back(ImmBranch(&MBB->back(), MaxDisp, false, Br.UncondBr)); + ImmBranches.emplace_back(&MBB->back(), MaxDisp, false, Br.UncondBr); // Remove the old conditional branch. It may or may not still be in MBB. BBInfo[MI->getParent()->getNumber()].Size -= TII->GetInstSizeInBytes(MI); Index: lib/Target/ARM/ARMISelDAGToDAG.cpp =================================================================== --- lib/Target/ARM/ARMISelDAGToDAG.cpp +++ lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -1863,8 +1863,8 @@ std::vector ResTys; ResTys.push_back(ResTy); if (isUpdating) - ResTys.push_back(MVT::i32); - ResTys.push_back(MVT::Other); + ResTys.emplace_back(MVT::i32); + ResTys.emplace_back(MVT::Other); SDValue Pred = getAL(CurDAG, dl); SDValue Reg0 = CurDAG->getRegister(0, MVT::i32); @@ -1909,7 +1909,7 @@ Chain = SDValue(VLdA, 2); // Load the odd subregs. - Ops.push_back(SDValue(VLdA, 1)); + Ops.emplace_back(VLdA, 1); Ops.push_back(Align); if (isUpdating) { SDValue Inc = N->getOperand(AddrOpIdx + 1); @@ -1918,7 +1918,7 @@ (void)Inc; Ops.push_back(Reg0); } - Ops.push_back(SDValue(VLdA, 0)); + Ops.emplace_back(VLdA, 0); Ops.push_back(Pred); Ops.push_back(Reg0); Ops.push_back(Chain); @@ -1993,8 +1993,8 @@ std::vector ResTys; if (isUpdating) - ResTys.push_back(MVT::i32); - ResTys.push_back(MVT::Other); + ResTys.emplace_back(MVT::i32); + ResTys.emplace_back(MVT::Other); SDValue Pred = getAL(CurDAG, dl); SDValue Reg0 = CurDAG->getRegister(0, MVT::i32); @@ -2079,7 +2079,7 @@ Chain = SDValue(VStA, 1); // Store the odd D registers. - Ops.push_back(SDValue(VStA, 0)); + Ops.emplace_back(VStA, 0); Ops.push_back(Align); if (isUpdating) { SDValue Inc = N->getOperand(AddrOpIdx + 1); @@ -2158,8 +2158,8 @@ MVT::i64, ResTyElts)); } if (isUpdating) - ResTys.push_back(MVT::i32); - ResTys.push_back(MVT::Other); + ResTys.emplace_back(MVT::i32); + ResTys.emplace_back(MVT::Other); SDValue Pred = getAL(CurDAG, dl); SDValue Reg0 = CurDAG->getRegister(0, MVT::i32); @@ -2284,8 +2284,8 @@ std::vector ResTys; ResTys.push_back(EVT::getVectorVT(*CurDAG->getContext(), MVT::i64,ResTyElts)); if (isUpdating) - ResTys.push_back(MVT::i32); - ResTys.push_back(MVT::Other); + ResTys.emplace_back(MVT::i32); + ResTys.emplace_back(MVT::Other); SDNode *VLdDup = CurDAG->getMachineNode(Opc, dl, ResTys, Ops); cast(VLdDup)->setMemRefs(MemOp, MemOp + 1); SuperReg = SDValue(VLdDup, 0); @@ -3381,11 +3381,11 @@ // arm_ldrexd returns a i64 value in {i32, i32} std::vector ResTys; if (isThumb) { - ResTys.push_back(MVT::i32); - ResTys.push_back(MVT::i32); + ResTys.emplace_back(MVT::i32); + ResTys.emplace_back(MVT::i32); } else - ResTys.push_back(MVT::Untyped); - ResTys.push_back(MVT::Other); + ResTys.emplace_back(MVT::Untyped); + ResTys.emplace_back(MVT::Other); // Place arguments in the right order. SDValue Ops[] = {MemAddr, getAL(CurDAG, dl), @@ -3448,7 +3448,7 @@ Ops.push_back(Val1); } else // arm_strexd uses GPRPair. - Ops.push_back(SDValue(createGPRPairNode(MVT::Untyped, Val0, Val1), 0)); + Ops.emplace_back(createGPRPairNode(MVT::Untyped, Val0, Val1), 0); Ops.push_back(MemAddr); Ops.push_back(getAL(CurDAG, dl)); Ops.push_back(CurDAG->getRegister(0, MVT::i32)); Index: lib/Target/ARM/ARMISelLowering.cpp =================================================================== --- lib/Target/ARM/ARMISelLowering.cpp +++ lib/Target/ARM/ARMISelLowering.cpp @@ -9867,7 +9867,7 @@ // Update the uses. SmallVector NewResults; for (unsigned i = 0; i < NumResultVecs; ++i) - NewResults.push_back(SDValue(UpdN.getNode(), i)); + NewResults.emplace_back(UpdN.getNode(), i); // If this is an non-standard-aligned LOAD, the first result is the loaded // value. Bitcast it to the expected result type. @@ -9876,7 +9876,7 @@ LdVal = DAG.getNode(ISD::BITCAST, dl, VecTy, LdVal); } - NewResults.push_back(SDValue(UpdN.getNode(), NumResultVecs+1)); // chain + NewResults.emplace_back(UpdN.getNode(), NumResultVecs+1); // chain DCI.CombineTo(N, NewResults); DCI.CombineTo(User, SDValue(UpdN.getNode(), NumResultVecs)); @@ -9967,8 +9967,8 @@ // Update uses of the chain. std::vector VLDDupResults; for (unsigned n = 0; n < NumVecs; ++n) - VLDDupResults.push_back(SDValue(VLDDup.getNode(), n)); - VLDDupResults.push_back(SDValue(VLDDup.getNode(), NumVecs)); + VLDDupResults.emplace_back(VLDDup.getNode(), n); + VLDDupResults.emplace_back(VLDDup.getNode(), NumVecs); DCI.CombineTo(VLD, VLDDupResults); return true; Index: lib/Target/ARM/ARMLoadStoreOptimizer.cpp =================================================================== --- lib/Target/ARM/ARMLoadStoreOptimizer.cpp +++ lib/Target/ARM/ARMLoadStoreOptimizer.cpp @@ -1721,7 +1721,7 @@ CurrBase = Base; CurrOpc = Opcode; CurrPred = Pred; - MemOps.push_back(MemOpQueueEntry(MBBI, Offset, Position)); + MemOps.emplace_back(MBBI, Offset, Position); continue; } // Note: No need to match PredReg in the next if. @@ -1749,7 +1749,7 @@ if (!Overlap) { // Check offset and sort memory operation into the current chain. if (Offset > MemOps.back().Offset) { - MemOps.push_back(MemOpQueueEntry(MBBI, Offset, Position)); + MemOps.emplace_back(MBBI, Offset, Position); continue; } else { MemOpQueue::iterator MI, ME; Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -3440,7 +3440,7 @@ if (ARMMCRegisterClasses[ARM::QPRRegClassID].contains(Reg)) { Reg = getDRegFromQReg(Reg); EReg = MRI->getEncodingValue(Reg); - Registers.push_back(std::pair(EReg, Reg)); + Registers.emplace_back(EReg, Reg); ++Reg; } const MCRegisterClass *RC; @@ -3455,7 +3455,7 @@ // Store the register. EReg = MRI->getEncodingValue(Reg); - Registers.push_back(std::pair(EReg, Reg)); + Registers.emplace_back(EReg, Reg); // This starts immediately after the first register token in the list, // so we can see either a comma or a minus (range separator) as a legal @@ -3486,7 +3486,7 @@ while (Reg != EndReg) { Reg = getNextRegister(Reg); EReg = MRI->getEncodingValue(Reg); - Registers.push_back(std::pair(EReg, Reg)); + Registers.emplace_back(EReg, Reg); } continue; } @@ -3523,10 +3523,10 @@ Reg != OldReg + 1) return Error(RegLoc, "non-contiguous register range"); EReg = MRI->getEncodingValue(Reg); - Registers.push_back(std::pair(EReg, Reg)); + Registers.emplace_back(EReg, Reg); if (isQReg) { EReg = MRI->getEncodingValue(++Reg); - Registers.push_back(std::pair(EReg, Reg)); + Registers.emplace_back(EReg, Reg); } } Index: lib/Target/Hexagon/HexagonBitSimplify.cpp =================================================================== --- lib/Target/Hexagon/HexagonBitSimplify.cpp +++ lib/Target/Hexagon/HexagonBitSimplify.cpp @@ -2558,7 +2558,7 @@ if (BadUse || !GoodUse) continue; - Phis.push_back(PhiInfo(I, *C.LB)); + Phis.emplace_back(I, *C.LB); } DEBUG({ @@ -2776,7 +2776,7 @@ break; } - Cand.push_back(LoopCand(&B, PB, EB)); + Cand.emplace_back(&B, PB, EB); } bool Changed = false; Index: lib/Target/Hexagon/HexagonFrameLowering.cpp =================================================================== --- lib/Target/Hexagon/HexagonFrameLowering.cpp +++ lib/Target/Hexagon/HexagonFrameLowering.cpp @@ -1323,7 +1323,7 @@ const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(S->Reg); int FI = MFI->CreateFixedSpillStackObject(RC->getSize(), S->Offset); MinOffset = std::min(MinOffset, S->Offset); - CSI.push_back(CalleeSavedInfo(S->Reg, FI)); + CSI.emplace_back(S->Reg, FI); SRegs[S->Reg] = false; } @@ -1339,7 +1339,7 @@ Off &= -Align; int FI = MFI->CreateFixedSpillStackObject(RC->getSize(), Off); MinOffset = std::min(MinOffset, Off); - CSI.push_back(CalleeSavedInfo(R, FI)); + CSI.emplace_back(R, FI); SRegs[R] = false; } Index: lib/Target/Hexagon/HexagonGenMux.cpp =================================================================== --- lib/Target/Hexagon/HexagonGenMux.cpp +++ lib/Target/Hexagon/HexagonGenMux.cpp @@ -286,7 +286,7 @@ // Prefer "down", since this will move the MUX farther away from the // predicate definition. MachineBasicBlock::iterator At = CanDown ? Def2 : Def1; - ML.push_back(MuxInfo(At, DR, PR, SrcT, SrcF, Def1, Def2)); + ML.emplace_back(At, DR, PR, SrcT, SrcF, Def1, Def2); } for (unsigned I = 0, N = ML.size(); I < N; ++I) { Index: lib/Target/Hexagon/HexagonOptAddrMode.cpp =================================================================== --- lib/Target/Hexagon/HexagonOptAddrMode.cpp +++ lib/Target/Hexagon/HexagonOptAddrMode.cpp @@ -276,12 +276,12 @@ auto phiUseSet = I.second; for (auto phiUI : phiUseSet) { NodeAddr phiUA = DFG->addr(phiUI); - UNodeList.push_back(phiUA); + UNodeList.emplace_back(phiUA); } } } } else - UNodeList.push_back(UA); + UNodeList.emplace_back(UA); } } } Index: lib/Target/Hexagon/MCTargetDesc/HexagonMCDuplexInfo.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonMCDuplexInfo.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonMCDuplexInfo.cpp @@ -1046,7 +1046,7 @@ getDuplexCandidateGroup(*MCB.getOperand(j).getInst())); // Save off pairs for duplex checking. - duplexToTry.push_back(DuplexCandidate(j, k, iClass)); + duplexToTry.emplace_back(j, k, iClass); DEBUG(dbgs() << "adding pair: " << j << "," << k << ":" << MCB.getOperand(j).getInst()->getOpcode() << "," << MCB.getOperand(k).getInst()->getOpcode() << "\n"); @@ -1071,7 +1071,7 @@ getDuplexCandidateGroup(*MCB.getOperand(k).getInst())); // Save off pairs for duplex checking. - duplexToTry.push_back(DuplexCandidate(k, j, iClass)); + duplexToTry.emplace_back(k, j, iClass); DEBUG(dbgs() << "adding pair:" << k << "," << j << ":" << MCB.getOperand(j).getInst()->getOpcode() << "," << MCB.getOperand(k).getInst()->getOpcode() << "\n"); Index: lib/Target/Hexagon/RDFDeadCode.cpp =================================================================== --- lib/Target/Hexagon/RDFDeadCode.cpp +++ lib/Target/Hexagon/RDFDeadCode.cpp @@ -177,7 +177,7 @@ auto BA = DFG.addr(I); uint16_t Type = BA.Addr->getType(); if (Type == NodeAttrs::Ref) { - DRNs.push_back(DFG.addr(I)); + DRNs.emplace_back(DFG.addr(I)); continue; } @@ -186,7 +186,7 @@ if (Kind == NodeAttrs::Stmt || Kind == NodeAttrs::Phi) { for (auto N : NodeAddr(BA).Addr->members(DFG)) DRNs.push_back(N); - DINs.push_back(DFG.addr(I)); + DINs.emplace_back(DFG.addr(I)); } else { llvm_unreachable("Unexpected code node"); return false; Index: lib/Target/Hexagon/RDFGraph.cpp =================================================================== --- lib/Target/Hexagon/RDFGraph.cpp +++ lib/Target/Hexagon/RDFGraph.cpp @@ -772,7 +772,7 @@ // Push a delimiter for block node N on the stack. void DataFlowGraph::DefStack::start_block(NodeId N) { assert(N != 0); - Stack.push_back(NodeAddr(nullptr, N)); + Stack.emplace_back(nullptr, N); } // Remove all nodes from the top of the stack, until the delimited for @@ -1059,7 +1059,7 @@ NodeList Refs; NodeId Start = RA.Id; do { - Refs.push_back(RA); + Refs.emplace_back(RA); RA = getNextRelated(IA, RA); } while (RA.Id != 0 && RA.Id != Start); return Refs; @@ -1671,7 +1671,7 @@ while (N) { auto RA = addr(N); // Keep the nodes in the exact sibling order. - Res.push_back(RA); + Res.emplace_back(RA); N = RA.Addr->getSibling(); } return Res; Index: lib/Target/Hexagon/RDFLiveness.cpp =================================================================== --- lib/Target/Hexagon/RDFLiveness.cpp +++ lib/Target/Hexagon/RDFLiveness.cpp @@ -213,7 +213,7 @@ // d2(d1,,u3), ... // ..., u3(d2) This use needs to be live on entry. if (FullChain || IsPhi || !RAI.covers(RRs, QR)) - Ds.push_back(DA); + Ds.emplace_back(DA); } RDefs.insert(RDefs.end(), Ds.begin(), Ds.end()); for (NodeAddr DA : Ds) { Index: lib/Target/Mips/MipsConstantIslandPass.cpp =================================================================== --- lib/Target/Mips/MipsConstantIslandPass.cpp +++ lib/Target/Mips/MipsConstantIslandPass.cpp @@ -741,7 +741,7 @@ } // Record this immediate branch. unsigned MaxOffs = ((1 << (Bits-1))-1) * Scale; - ImmBranches.push_back(ImmBranch(I, MaxOffs, isCond, UOpc)); + ImmBranches.emplace_back(I, MaxOffs, isCond, UOpc); } if (Opc == Mips::CONSTPOOL_ENTRY) @@ -783,8 +783,8 @@ MachineInstr *CPEMI = CPEMIs[CPI]; unsigned MaxOffs = ((1 << Bits)-1) * Scale; unsigned LongFormMaxOffs = ((1 << LongFormBits)-1) * LongFormScale; - CPUsers.push_back(CPUser(I, CPEMI, MaxOffs, NegOk, - LongFormMaxOffs, LongFormOpcode)); + CPUsers.emplace_back(I, CPEMI, MaxOffs, NegOk, + LongFormMaxOffs, LongFormOpcode); // Increment corresponding CPEntry reference count. CPEntry *CPE = findConstPoolEntry(CPI, CPEMI); @@ -1265,8 +1265,8 @@ int UncondBr = Mips::Bimm16; BuildMI(UserMBB, DebugLoc(), TII->get(UncondBr)).addMBB(NewMBB); unsigned MaxDisp = getUnconditionalBrDisp(UncondBr); - ImmBranches.push_back(ImmBranch(&UserMBB->back(), - MaxDisp, false, UncondBr)); + ImmBranches.emplace_back(&UserMBB->back(), + MaxDisp, false, UncondBr); BBInfo[UserMBB->getNumber()].Size += Delta; adjustBBOffsetsAfter(UserMBB); return; @@ -1417,7 +1417,7 @@ U.HighWaterMark = NewIsland; U.CPEMI = BuildMI(NewIsland, DebugLoc(), TII->get(Mips::CONSTPOOL_ENTRY)) .addImm(ID).addConstantPoolIndex(CPI).addImm(Size); - CPEntries[CPI].push_back(CPEntry(U.CPEMI, ID, 1)); + CPEntries[CPI].emplace_back(U.CPEMI, ID, 1); ++NumCPEs; // Mark the basic block as aligned as required by the const-pool entry. @@ -1658,7 +1658,7 @@ BuildMI(MBB, DebugLoc(), TII->get(Br.UncondBr)).addMBB(DestBB); BBInfo[MBB->getNumber()].Size += TII->GetInstSizeInBytes(&MBB->back()); unsigned MaxDisp = getUnconditionalBrDisp(Br.UncondBr); - ImmBranches.push_back(ImmBranch(&MBB->back(), MaxDisp, false, Br.UncondBr)); + ImmBranches.emplace_back(&MBB->back(), MaxDisp, false, Br.UncondBr); // Remove the old conditional branch. It may or may not still be in MBB. BBInfo[MI->getParent()->getNumber()].Size -= TII->GetInstSizeInBytes(MI); Index: lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp =================================================================== --- lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp +++ lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp @@ -1349,7 +1349,7 @@ for (unsigned i = 0; i != NumElts; ++i) { InstVTs.push_back(NodeVT); } - InstVTs.push_back(MVT::Other); + InstVTs.emplace_back(MVT::Other); SDVTList InstVTList = CurDAG->getVTList(InstVTs); if (SelectDirectAddr(Op1, Addr)) { Index: lib/Target/NVPTX/NVPTXISelLowering.cpp =================================================================== --- lib/Target/NVPTX/NVPTXISelLowering.cpp +++ lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -1506,11 +1506,11 @@ // load.b8 i16 // if i1 // trunc i16 to i1 - LoadRetVTs.push_back(MVT::i16); + LoadRetVTs.emplace_back(MVT::i16); } else LoadRetVTs.push_back(EltVT); - LoadRetVTs.push_back(MVT::Other); - LoadRetVTs.push_back(MVT::Glue); + LoadRetVTs.emplace_back(MVT::Other); + LoadRetVTs.emplace_back(MVT::Glue); SDValue LoadRetOps[] = {Chain, DAG.getConstant(1, dl, MVT::i32), DAG.getConstant(0, dl, MVT::i32), InFlag}; SDValue retval = DAG.getMemIntrinsicNode( @@ -1530,14 +1530,14 @@ // load.b8 i16 // if i1 // trunc i16 to i1 - LoadRetVTs.push_back(MVT::i16); - LoadRetVTs.push_back(MVT::i16); + LoadRetVTs.emplace_back(MVT::i16); + LoadRetVTs.emplace_back(MVT::i16); } else { LoadRetVTs.push_back(EltVT); LoadRetVTs.push_back(EltVT); } - LoadRetVTs.push_back(MVT::Other); - LoadRetVTs.push_back(MVT::Glue); + LoadRetVTs.emplace_back(MVT::Other); + LoadRetVTs.emplace_back(MVT::Glue); SDValue LoadRetOps[] = {Chain, DAG.getConstant(1, dl, MVT::i32), DAG.getConstant(0, dl, MVT::i32), InFlag}; SDValue retval = DAG.getMemIntrinsicNode( @@ -1574,13 +1574,13 @@ // if i1 // trunc i16 to i1 for (unsigned j = 0; j < VecSize; ++j) - LoadRetVTs.push_back(MVT::i16); + LoadRetVTs.emplace_back(MVT::i16); } else { for (unsigned j = 0; j < VecSize; ++j) LoadRetVTs.push_back(EltVT); } - LoadRetVTs.push_back(MVT::Other); - LoadRetVTs.push_back(MVT::Glue); + LoadRetVTs.emplace_back(MVT::Other); + LoadRetVTs.emplace_back(MVT::Glue); SDValue LoadRetOps[] = {Chain, DAG.getConstant(1, dl, MVT::i32), DAG.getConstant(Ofst, dl, MVT::i32), InFlag}; SDValue retval = DAG.getMemIntrinsicNode( @@ -1625,7 +1625,7 @@ if (retTy->isIntegerTy() && DL.getTypeAllocSizeInBits(retTy) < 32) { // This is for integer types only, and specifically not for // aggregates. - LoadRetVTs.push_back(MVT::i32); + LoadRetVTs.emplace_back(MVT::i32); TheLoadType = MVT::i32; needTruncate = true; } else if (sz < 16) { @@ -1637,11 +1637,11 @@ // not figure out what this branch is for in D17872, so we left it // alone. The comment above about loading i1/i8 may be wrong, as the // branch above seems to cover integers of size < 32. - LoadRetVTs.push_back(MVT::i16); + LoadRetVTs.emplace_back(MVT::i16); } else - LoadRetVTs.push_back(Ins[i].VT); - LoadRetVTs.push_back(MVT::Other); - LoadRetVTs.push_back(MVT::Glue); + LoadRetVTs.emplace_back(Ins[i].VT); + LoadRetVTs.emplace_back(MVT::Other); + LoadRetVTs.emplace_back(MVT::Glue); SDValue LoadRetOps[] = {Chain, DAG.getConstant(1, dl, MVT::i32), DAG.getConstant(Offsets[i], dl, MVT::i32), Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp =================================================================== --- lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -1059,15 +1059,15 @@ continue; if (LastValue.getNode()) - BitGroups.push_back(BitGroup(LastValue, LastRLAmt, LastGroupStartIdx, - i-1)); + BitGroups.emplace_back(LastValue, LastRLAmt, LastGroupStartIdx, + i-1); LastRLAmt = ThisRLAmt; LastValue = ThisValue; LastGroupStartIdx = i; } if (LastValue.getNode()) - BitGroups.push_back(BitGroup(LastValue, LastRLAmt, LastGroupStartIdx, - Bits.size()-1)); + BitGroups.emplace_back(LastValue, LastRLAmt, LastGroupStartIdx, + Bits.size()-1); if (BitGroups.empty()) return; @@ -4208,7 +4208,7 @@ SDNode *ReplOp = CurDAG->getMachineNode(TargetOpcode::INSERT_SUBREG, SDLoc(V), ISR.getNode()->getVTList(), ReplOpOps); - Ops.push_back(SDValue(ReplOp, 0)); + Ops.emplace_back(ReplOp, 0); } else { Ops.push_back(V); } @@ -4222,7 +4222,7 @@ SDVTList VTs = PN->getVTList(); for (unsigned i = 0, ie = VTs.NumVTs; i != ie; ++i) if (VTs.VTs[i] == MVT::i32) - NewVTs.push_back(MVT::i64); + NewVTs.emplace_back(MVT::i64); else NewVTs.push_back(VTs.VTs[i]); Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -4267,8 +4267,8 @@ bool isELFv2ABI = Subtarget.isELFv2ABI(); EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout()); - NodeTys.push_back(MVT::Other); // Returns a chain - NodeTys.push_back(MVT::Glue); // Returns a flag for retval copy to use. + NodeTys.emplace_back(MVT::Other); // Returns a chain + NodeTys.emplace_back(MVT::Glue); // Returns a flag for retval copy to use. unsigned CallOpc = PPCISD::CALL; @@ -4419,8 +4419,8 @@ InFlag = Chain.getValue(1); NodeTys.clear(); - NodeTys.push_back(MVT::Other); - NodeTys.push_back(MVT::Glue); + NodeTys.emplace_back(MVT::Other); + NodeTys.emplace_back(MVT::Glue); Ops.push_back(Chain); CallOpc = PPCISD::BCTRL; Callee.setNode(nullptr); @@ -5160,7 +5160,7 @@ MachinePointerInfo(), VT, false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); ArgOffset += PtrByteSize; continue; @@ -5222,7 +5222,7 @@ MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); // Done with this argument. ArgOffset += PtrByteSize; @@ -5239,7 +5239,7 @@ MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); ArgOffset += PtrByteSize; } else { ArgOffset += ((Size - j + PtrByteSize-1)/PtrByteSize)*PtrByteSize; @@ -5256,7 +5256,7 @@ case MVT::i64: if (Flags.isNest()) { // The 'nest' parameter, if any, is passed in R11. - RegsToPass.push_back(std::make_pair(PPC::X11, Arg)); + RegsToPass.emplace_back(std::make_pair(PPC::X11, Arg)); hasNest = true; break; } @@ -5265,7 +5265,7 @@ // passed directly. Clang may use those instead of "byval" aggregate // types to avoid forcing arguments to memory unnecessarily. if (GPR_idx != NumGPRs) { - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Arg)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Arg)); } else { if (CallConv == CallingConv::Fast) ComputePtrOff(); @@ -5295,7 +5295,7 @@ // First load the argument into the next available FPR. if (FPR_idx != NumFPRs) - RegsToPass.push_back(std::make_pair(FPR[FPR_idx++], Arg)); + RegsToPass.emplace_back(std::make_pair(FPR[FPR_idx++], Arg)); // Next, load the argument into GPR or stack slot if needed. if (!NeedGPROrStack) @@ -5342,7 +5342,7 @@ ArgVal = SDValue(); if (ArgVal.getNode()) - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], ArgVal)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], ArgVal)); } else { if (CallConv == CallingConv::Fast) ComputePtrOff(); @@ -5416,7 +5416,7 @@ SDValue Load = DAG.getLoad(PtrVT, dl, Store, Ix, MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); } break; } @@ -5463,7 +5463,7 @@ Store, PtrOff, MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(QFPR[QFPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(QFPR[QFPR_idx++], Load)); } ArgOffset += (IsF32 ? 16 : 32); for (unsigned i = 0; i < (IsF32 ? 16U : 32U); i += PtrByteSize) { @@ -5474,14 +5474,14 @@ SDValue Load = DAG.getLoad(PtrVT, dl, Store, Ix, MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); } break; } // Non-varargs QPX params go into registers or on the stack. if (QFPR_idx != NumQFPRs) { - RegsToPass.push_back(std::make_pair(QFPR[QFPR_idx++], Arg)); + RegsToPass.emplace_back(std::make_pair(QFPR[QFPR_idx++], Arg)); } else { if (CallConv == CallingConv::Fast) ComputePtrOff(); @@ -5716,7 +5716,7 @@ MachinePointerInfo(), VT, false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); ArgOffset += PtrByteSize; } else { @@ -5748,7 +5748,7 @@ MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); ArgOffset += PtrByteSize; } else { ArgOffset += ((Size - j + PtrByteSize-1)/PtrByteSize)*PtrByteSize; @@ -5767,7 +5767,7 @@ if (Arg.getValueType() == MVT::i1) Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, PtrVT, Arg); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Arg)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Arg)); } else { LowerMemOpCallTo(DAG, MF, Chain, Arg, PtrOff, SPDiff, ArgOffset, isPPC64, isTailCall, false, MemOpChains, @@ -5778,7 +5778,7 @@ case MVT::f32: case MVT::f64: if (FPR_idx != NumFPRs) { - RegsToPass.push_back(std::make_pair(FPR[FPR_idx++], Arg)); + RegsToPass.emplace_back(std::make_pair(FPR[FPR_idx++], Arg)); if (isVarArg) { SDValue Store = DAG.getStore(Chain, dl, Arg, PtrOff, @@ -5791,7 +5791,7 @@ MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); } if (GPR_idx != NumGPRs && Arg.getValueType() == MVT::f64 && !isPPC64){ SDValue ConstFour = DAG.getConstant(4, dl, PtrOff.getValueType()); @@ -5800,7 +5800,7 @@ MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); } } else { // If we have any FPRs remaining, we may also have GPRs remaining. @@ -5848,7 +5848,7 @@ MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(VR[VR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(VR[VR_idx++], Load)); } ArgOffset += 16; for (unsigned i=0; i<16; i+=PtrByteSize) { @@ -5859,7 +5859,7 @@ SDValue Load = DAG.getLoad(PtrVT, dl, Store, Ix, MachinePointerInfo(), false, false, false, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + RegsToPass.emplace_back(std::make_pair(GPR[GPR_idx++], Load)); } break; } @@ -5868,7 +5868,7 @@ // stack space allocated at the end. if (VR_idx != NumVRs) { // Doesn't have GPR space allocated. - RegsToPass.push_back(std::make_pair(VR[VR_idx++], Arg)); + RegsToPass.emplace_back(std::make_pair(VR[VR_idx++], Arg)); } else if (nAltivecParamsAtEnd==0) { // We are emitting Altivec params in order. LowerMemOpCallTo(DAG, MF, Chain, Arg, PtrOff, SPDiff, ArgOffset, Index: lib/Target/PowerPC/PPCLoopPreIncPrep.cpp =================================================================== --- lib/Target/PowerPC/PPCLoopPreIncPrep.cpp +++ lib/Target/PowerPC/PPCLoopPreIncPrep.cpp @@ -225,7 +225,7 @@ for (auto &B : Buckets) { const SCEV *Diff = SE->getMinusSCEV(LSCEV, B.BaseSCEV); if (const auto *CDiff = dyn_cast(Diff)) { - B.Elements.push_back(BucketElement(CDiff, MemI)); + B.Elements.emplace_back(CDiff, MemI); FoundBucket = true; break; } Index: lib/Target/Sparc/SparcISelLowering.cpp =================================================================== --- lib/Target/Sparc/SparcISelLowering.cpp +++ lib/Target/Sparc/SparcISelLowering.cpp @@ -224,7 +224,7 @@ SDValue Flag; SmallVector RetOps(1, Chain); // Make room for the return address offset. - RetOps.push_back(SDValue()); + RetOps.emplace_back(); // Copy the result values into the output registers. for (unsigned i = 0, realRVLocIdx = 0; Index: lib/Target/X86/AsmParser/X86AsmParser.cpp =================================================================== --- lib/Target/X86/AsmParser/X86AsmParser.cpp +++ lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -147,7 +147,7 @@ InfixOperatorStack.pop_back(); } else { InfixOperatorStack.pop_back(); - PostfixStack.push_back(std::make_pair(StackOp, 0)); + PostfixStack.emplace_back(std::make_pair(StackOp, 0)); } } // Push the new operator. @@ -159,7 +159,7 @@ while (!InfixOperatorStack.empty()) { InfixCalculatorTok StackOp = InfixOperatorStack.pop_back_val(); if (StackOp != IC_LPAREN && StackOp != IC_RPAREN) - PostfixStack.push_back(std::make_pair(StackOp, 0)); + PostfixStack.emplace_back(std::make_pair(StackOp, 0)); } if (PostfixStack.empty()) Index: lib/Target/X86/X86ISelDAGToDAG.cpp =================================================================== --- lib/Target/X86/X86ISelDAGToDAG.cpp +++ lib/Target/X86/X86ISelDAGToDAG.cpp @@ -486,7 +486,7 @@ Load.getOperand(1), Load.getOperand(2)); Ops.clear(); - Ops.push_back(SDValue(Load.getNode(), 1)); + Ops.emplace_back(Load.getNode(), 1); Ops.append(Call->op_begin() + 1, Call->op_end()); CurDAG->UpdateNodeOperands(Call.getNode(), Ops); } Index: lib/Target/X86/X86InstrInfo.cpp =================================================================== --- lib/Target/X86/X86InstrInfo.cpp +++ lib/Target/X86/X86InstrInfo.cpp @@ -6524,7 +6524,7 @@ const TargetRegisterClass *DstRC = nullptr; if (MCID.getNumDefs() > 0) { DstRC = getRegClass(MCID, 0, &RI, MF); - VTs.push_back(*DstRC->vt_begin()); + VTs.emplace_back(*DstRC->vt_begin()); } for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) { EVT VT = N->getValueType(i); @@ -6532,7 +6532,7 @@ VTs.push_back(VT); } if (Load) - BeforeOps.push_back(SDValue(Load, 0)); + BeforeOps.emplace_back(Load, 0); BeforeOps.insert(BeforeOps.end(), AfterOps.begin(), AfterOps.end()); SDNode *NewNode= DAG.getMachineNode(Opc, dl, VTs, BeforeOps); NewNodes.push_back(NewNode); @@ -6540,7 +6540,7 @@ // Emit the store instruction. if (FoldedStore) { AddrOps.pop_back(); - AddrOps.push_back(SDValue(NewNode, 0)); + AddrOps.emplace_back(NewNode, 0); AddrOps.push_back(Chain); std::pair MMOs = Index: lib/Target/XCore/XCoreISelLowering.cpp =================================================================== --- lib/Target/XCore/XCoreISelLowering.cpp +++ lib/Target/XCore/XCoreISelLowering.cpp @@ -1082,7 +1082,7 @@ InVals.push_back(Chain.getValue(0)); } else { assert(VA.isMemLoc()); - ResultMemLocs.push_back(std::make_pair(VA.getLocMemOffset(), + ResultMemLocs.emplace_back(std::make_pair(VA.getLocMemOffset(), InVals.size())); // Reserve space for this result. InVals.push_back(SDValue()); Index: lib/Tooling/Core/Replacement.cpp =================================================================== --- lib/Tooling/Core/Replacement.cpp +++ lib/Tooling/Core/Replacement.cpp @@ -207,7 +207,7 @@ ++ConflictLength; } else { if (ConflictLength > 1) - Conflicts.push_back(Range(ConflictStart, ConflictLength)); + Conflicts.emplace_back(ConflictStart, ConflictLength); ConflictRange = Current; ConflictStart = i; ConflictLength = 1; @@ -215,7 +215,7 @@ } if (ConflictLength > 1) - Conflicts.push_back(Range(ConflictStart, ConflictLength)); + Conflicts.emplace_back(ConflictStart, ConflictLength); } bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite) { @@ -285,7 +285,7 @@ unsigned Offset = R.getOffset() + Shift; unsigned Length = R.getReplacementText().size(); Shift += Length - R.getLength(); - ChangedRanges.push_back(Range(Offset, Length)); + ChangedRanges.emplace_back(Offset, Length); } return ChangedRanges; } Index: lib/Tooling/FileMatchTrie.cpp =================================================================== --- lib/Tooling/FileMatchTrie.cpp +++ lib/Tooling/FileMatchTrie.cpp @@ -139,7 +139,7 @@ if (Path.empty()) return; if (Children.empty()) { - Results.push_back(StringRef(Path)); + Results.emplace_back(Path); return; } for (llvm::StringMap::const_iterator Index: lib/Transforms/IPO/GlobalOpt.cpp =================================================================== --- lib/Transforms/IPO/GlobalOpt.cpp +++ lib/Transforms/IPO/GlobalOpt.cpp @@ -172,7 +172,7 @@ SI->eraseFromParent(); } else if (Instruction *I = dyn_cast(V)) { if (I->hasOneUse()) - Dead.push_back(std::make_pair(I, SI)); + Dead.emplace_back(std::make_pair(I, SI)); } } else if (MemSetInst *MSI = dyn_cast(U)) { if (isa(MSI->getValue())) { @@ -180,7 +180,7 @@ MSI->eraseFromParent(); } else if (Instruction *I = dyn_cast(MSI->getValue())) { if (I->hasOneUse()) - Dead.push_back(std::make_pair(I, MSI)); + Dead.emplace_back(std::make_pair(I, MSI)); } } else if (MemTransferInst *MTI = dyn_cast(U)) { GlobalVariable *MemSrc = dyn_cast(MTI->getSource()); @@ -189,7 +189,7 @@ MTI->eraseFromParent(); } else if (Instruction *I = dyn_cast(MemSrc)) { if (I->hasOneUse()) - Dead.push_back(std::make_pair(I, MTI)); + Dead.emplace_back(std::make_pair(I, MTI)); } } else if (ConstantExpr *CE = dyn_cast(U)) { if (CE->use_empty()) { Index: lib/Transforms/IPO/MergeFunctions.cpp =================================================================== --- lib/Transforms/IPO/MergeFunctions.cpp +++ lib/Transforms/IPO/MergeFunctions.cpp @@ -1547,7 +1547,7 @@ HashedFuncs; for (Function &Func : M) { if (!Func.isDeclaration() && !Func.hasAvailableExternallyLinkage()) { - HashedFuncs.push_back({FunctionComparator::functionHash(Func), &Func}); + HashedFuncs.emplace_back(FunctionComparator::functionHash(Func), &Func); } } Index: lib/Transforms/IPO/SampleProfile.cpp =================================================================== --- lib/Transforms/IPO/SampleProfile.cpp +++ lib/Transforms/IPO/SampleProfile.cpp @@ -602,8 +602,8 @@ DISubprogram *SP = DIL->getScope()->getSubprogram(); if (!SP) return nullptr; - S.push_back(LineLocation(getOffset(DIL->getLine(), SP->getLine()), - DIL->getDiscriminator())); + S.emplace_back(getOffset(DIL->getLine(), SP->getLine()), + DIL->getDiscriminator()); } if (S.size() == 0) return Samples; Index: lib/Transforms/IPO/WholeProgramDevirt.cpp =================================================================== --- lib/Transforms/IPO/WholeProgramDevirt.cpp +++ lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -357,7 +357,7 @@ if (Fn->getName() == "__cxa_pure_virtual") continue; - TargetsForSlot.push_back({Fn, &BS}); + TargetsForSlot.emplace_back(Fn, &BS); } // Give up if we couldn't find any targets. Index: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -74,14 +74,13 @@ if (isa(I) || isa(I)) { // If uses of the bitcast are ok, we are ok. - ValuesToInspect.push_back(std::make_pair(I, IsOffset)); + ValuesToInspect.emplace_back(std::make_pair(I, IsOffset)); continue; } if (GetElementPtrInst *GEP = dyn_cast(I)) { // If the GEP has all zero indices, it doesn't offset the pointer. If it // doesn't, it does. - ValuesToInspect.push_back( - std::make_pair(I, IsOffset || !GEP->hasAllZeroIndices())); + ValuesToInspect.emplace_back(std::make_pair(I, IsOffset || !GEP->hasAllZeroIndices())); continue; } Index: lib/Transforms/InstCombine/InstCombinePHI.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombinePHI.cpp +++ lib/Transforms/InstCombine/InstCombinePHI.cpp @@ -737,7 +737,7 @@ // Truncates are always ok. if (isa(UserI)) { - PHIUsers.push_back(PHIUsageRecord(PHIId, 0, UserI)); + PHIUsers.emplace_back(PHIId, 0, UserI); continue; } @@ -748,7 +748,7 @@ return nullptr; unsigned Shift = cast(UserI->getOperand(1))->getZExtValue(); - PHIUsers.push_back(PHIUsageRecord(PHIId, Shift, UserI->user_back())); + PHIUsers.emplace_back(PHIId, Shift, UserI->user_back()); } } @@ -837,8 +837,8 @@ if (PHIsInspected.count(OldInVal)) { unsigned RefPHIId = std::find(PHIsToSlice.begin(),PHIsToSlice.end(), OldInVal)-PHIsToSlice.begin(); - PHIUsers.push_back(PHIUsageRecord(RefPHIId, Offset, - cast(Res))); + PHIUsers.emplace_back(RefPHIId, Offset, + cast(Res)); ++UserE; } } Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp =================================================================== --- lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -616,7 +616,7 @@ GlobalValue::InternalLinkage, Constant::getNullValue(CounterTy), "__llvm_gcov_ctr"); - CountersBySP.push_back(std::make_pair(Counters, SP)); + CountersBySP.emplace_back(std::make_pair(Counters, SP)); UniqueVector ComplexEdgePreds; UniqueVector ComplexEdgeSuccs; Index: lib/Transforms/Instrumentation/IndirectCallPromotion.cpp =================================================================== --- lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -339,7 +339,7 @@ Twine(" with count of ") + Twine(Count) + ": " + Reason); break; } - Ret.push_back(PromotionCandidate(TargetFunction, Count)); + Ret.emplace_back(TargetFunction, Count); TotalCount -= Count; } return Ret; Index: lib/Transforms/Instrumentation/MemorySanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1197,8 +1197,7 @@ assert((isa(ShadowTy) || isa(ShadowTy)) && "Can only insert checks for integer and vector shadow types"); #endif - InstrumentationList.push_back( - ShadowOriginAndInsertPoint(Shadow, Origin, OrigIns)); + InstrumentationList.emplace_back(Shadow, Origin, OrigIns); } /// \brief Remember the place where a shadow check should be inserted. Index: lib/Transforms/ObjCARC/ObjCARCOpts.cpp =================================================================== --- lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -923,7 +923,7 @@ DEBUG(dbgs() << "Cloning " << *CInst << "\n" "And inserting clone at " << *InsertPos << "\n"); - Worklist.push_back(std::make_pair(Clone, Incoming)); + Worklist.emplace_back(std::make_pair(Clone, Incoming)); } } // Erase the original call. Index: lib/Transforms/Scalar/ConstantHoisting.cpp =================================================================== --- lib/Transforms/Scalar/ConstantHoisting.cpp +++ lib/Transforms/Scalar/ConstantHoisting.cpp @@ -81,7 +81,7 @@ /// \brief Add the user to the use list and update the cost. void addUser(Instruction *Inst, unsigned Idx, unsigned Cost) { CumulativeCost += Cost; - Uses.push_back(ConstantUser(Inst, Idx)); + Uses.emplace_back(Inst, Idx); } }; Index: lib/Transforms/Scalar/JumpThreading.cpp =================================================================== --- lib/Transforms/Scalar/JumpThreading.cpp +++ lib/Transforms/Scalar/JumpThreading.cpp @@ -1059,7 +1059,7 @@ if (AATags) NewVal->setAAMetadata(AATags); - AvailablePreds.push_back(std::make_pair(UnavailablePred, NewVal)); + AvailablePreds.emplace_back(std::make_pair(UnavailablePred, NewVal)); } // Now we know that each predecessor of this block has a value in Index: lib/Transforms/Scalar/LoadCombine.cpp =================================================================== --- lib/Transforms/Scalar/LoadCombine.cpp +++ lib/Transforms/Scalar/LoadCombine.cpp @@ -258,7 +258,7 @@ auto POP = getPointerOffsetPair(*LI); if (!POP.Pointer) continue; - LoadMap[POP.Pointer].push_back(LoadPOPPair(LI, POP, Index++)); + LoadMap[POP.Pointer].emplace_back(LI, POP, Index++); AST.add(LI); } if (combineLoads(LoadMap)) Index: lib/Transforms/Scalar/LoopInstSimplify.cpp =================================================================== --- lib/Transforms/Scalar/LoopInstSimplify.cpp +++ lib/Transforms/Scalar/LoopInstSimplify.cpp @@ -97,7 +97,7 @@ VisitStack.clear(); Visited.clear(); - VisitStack.push_back(WorklistItem(L->getHeader(), false)); + VisitStack.emplace_back(L->getHeader(), false); while (!VisitStack.empty()) { WorklistItem Item = VisitStack.pop_back_val(); @@ -153,7 +153,7 @@ const Loop *SuccLoop = LI->getLoopFor(SuccBB); if (SuccLoop && SuccLoop->getHeader() == SuccBB && L->contains(SuccLoop)) { - VisitStack.push_back(WorklistItem(SuccBB, true)); + VisitStack.emplace_back(SuccBB, true); SmallVector SubLoopExitBlocks; SuccLoop->getExitBlocks(SubLoopExitBlocks); @@ -161,7 +161,7 @@ for (unsigned i = 0; i < SubLoopExitBlocks.size(); ++i) { BasicBlock *ExitBB = SubLoopExitBlocks[i]; if (LI->getLoopFor(ExitBB) == L && Visited.insert(ExitBB).second) - VisitStack.push_back(WorklistItem(ExitBB, false)); + VisitStack.emplace_back(ExitBB, false); } continue; @@ -172,7 +172,7 @@ if (IsExitBlock) continue; - VisitStack.push_back(WorklistItem(SuccBB, false)); + VisitStack.emplace_back(SuccBB, false); } } Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp =================================================================== --- lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -3710,7 +3710,7 @@ LUIdx = UsedByIndices.find_next(LUIdx)) // Make a memo of this use, offset, and register tuple. if (UniqueItems.insert(std::make_pair(LUIdx, Imm)).second) - WorkItems.push_back(WorkItem(LUIdx, Imm, OrigReg)); + WorkItems.emplace_back(LUIdx, Imm, OrigReg); } } } Index: lib/Transforms/Scalar/LoopUnrollPass.cpp =================================================================== --- lib/Transforms/Scalar/LoopUnrollPass.cpp +++ lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -392,7 +392,7 @@ if (Iteration != 0 && !C) C = SimplifiedValues.lookup(V); if (C) - SimplifiedInputValues.push_back({PHI, C}); + SimplifiedInputValues.emplace_back(PHI, C); } // Now clear and re-populate the map for the next iteration. Index: lib/Transforms/Scalar/PlaceSafepoints.cpp =================================================================== --- lib/Transforms/Scalar/PlaceSafepoints.cpp +++ lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -674,7 +674,7 @@ // These are likely runtime calls. Should we assert that via calling // convention or something? - ParsePointsNeeded.push_back(CallSite(CI)); + ParsePointsNeeded.emplace_back(CI); } assert(ParsePointsNeeded.size() <= Calls.size()); } Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -661,7 +661,7 @@ EndOffset = AllocSize; } - AS.Slices.push_back(Slice(BeginOffset, EndOffset, U, IsSplittable)); + AS.Slices.emplace_back(BeginOffset, EndOffset, U, IsSplittable); } void visitBitCastInst(BitCastInst &BC) { @@ -3571,10 +3571,9 @@ SplitLoads.push_back(PLoad); // Now build a new slice for the alloca. - NewSlices.push_back( - Slice(BaseOffset + PartOffset, BaseOffset + PartOffset + PartSize, + NewSlices.emplace_back(BaseOffset + PartOffset, BaseOffset + PartOffset + PartSize, &PLoad->getOperandUse(PLoad->getPointerOperandIndex()), - /*IsSplittable*/ false)); + /*IsSplittable*/ false); DEBUG(dbgs() << " new slice [" << NewSlices.back().beginOffset() << ", " << NewSlices.back().endOffset() << "): " << *PLoad << "\n"); @@ -3709,10 +3708,9 @@ getAdjustedAlignment(SI, PartOffset, DL), /*IsVolatile*/ false); // Now build a new slice for the alloca. - NewSlices.push_back( - Slice(BaseOffset + PartOffset, BaseOffset + PartOffset + PartSize, + NewSlices.emplace_back(BaseOffset + PartOffset, BaseOffset + PartOffset + PartSize, &PStore->getOperandUse(PStore->getPointerOperandIndex()), - /*IsSplittable*/ false)); + /*IsSplittable*/ false); DEBUG(dbgs() << " new slice [" << NewSlices.back().beginOffset() << ", " << NewSlices.back().endOffset() << "): " << *PStore << "\n"); @@ -4000,7 +3998,7 @@ uint64_t AllocaSize = DL.getTypeSizeInBits(NewAI->getAllocatedType()); // Don't include any padding. uint64_t Size = std::min(AllocaSize, P.size() * SizeOfByte); - Pieces.push_back(Piece(NewAI, P.beginOffset() * SizeOfByte, Size)); + Pieces.emplace_back(NewAI, P.beginOffset() * SizeOfByte, Size); } } ++NumPartitions; Index: lib/Transforms/Scalar/Scalarizer.cpp =================================================================== --- lib/Transforms/Scalar/Scalarizer.cpp +++ lib/Transforms/Scalar/Scalarizer.cpp @@ -313,7 +313,7 @@ } } SV = CV; - Gathered.push_back(GatherList::value_type(Op, &SV)); + Gathered.emplace_back(Op, &SV); } // Return true if it is safe to transfer the given metadata tag from Index: lib/Transforms/Utils/LowerSwitch.cpp =================================================================== --- lib/Transforms/Utils/LowerSwitch.cpp +++ lib/Transforms/Utils/LowerSwitch.cpp @@ -363,8 +363,8 @@ // Start with "simple" cases for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i) - Cases.push_back(CaseRange(i.getCaseValue(), i.getCaseValue(), - i.getCaseSuccessor())); + Cases.emplace_back(i.getCaseValue(), i.getCaseValue(), + i.getCaseSuccessor()); std::sort(Cases.begin(), Cases.end(), CaseCmp()); Index: lib/Transforms/Utils/MemorySSA.cpp =================================================================== --- lib/Transforms/Utils/MemorySSA.cpp +++ lib/Transforms/Utils/MemorySSA.cpp @@ -150,7 +150,7 @@ SmallPtrSet &Visited) { SmallVector WorkStack; IncomingVal = renameBlock(Root->getBlock(), IncomingVal); - WorkStack.push_back({Root, Root->begin(), IncomingVal}); + WorkStack.emplace_back(Root, Root->begin(), IncomingVal); Visited.insert(Root->getBlock()); while (!WorkStack.empty()) { @@ -166,7 +166,7 @@ BasicBlock *BB = Child->getBlock(); Visited.insert(BB); IncomingVal = renameBlock(BB, IncomingVal); - WorkStack.push_back({Child, Child->begin(), IncomingVal}); + WorkStack.emplace_back(Child, Child->begin(), IncomingVal); } } } Index: lib/Transforms/Utils/SimplifyCFG.cpp =================================================================== --- lib/Transforms/Utils/SimplifyCFG.cpp +++ lib/Transforms/Utils/SimplifyCFG.cpp @@ -651,16 +651,15 @@ Cases.reserve(SI->getNumCases()); for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i) - Cases.push_back( - ValueEqualityComparisonCase(i.getCaseValue(), i.getCaseSuccessor())); + Cases.emplace_back(i.getCaseValue(), i.getCaseSuccessor()); return SI->getDefaultDest(); } BranchInst *BI = cast(TI); ICmpInst *ICI = cast(BI->getCondition()); BasicBlock *Succ = BI->getSuccessor(ICI->getPredicate() == ICmpInst::ICMP_NE); - Cases.push_back(ValueEqualityComparisonCase( - GetConstantInt(ICI->getOperand(1), DL), Succ)); + Cases.emplace_back( + GetConstantInt(ICI->getOperand(1), DL), Succ); return BI->getSuccessor(ICI->getPredicate() == ICmpInst::ICMP_EQ); } @@ -1064,7 +1063,7 @@ I != E; ++I) { if (PredHasWeights || SuccHasWeights) Weights.push_back(WeightsForHandled[*I]); - PredCases.push_back(ValueEqualityComparisonCase(*I, BBDefault)); + PredCases.emplace_back(*I, BBDefault); NewSuccessors.push_back(BBDefault); } } Index: lib/Transforms/Utils/SplitModule.cpp =================================================================== --- lib/Transforms/Utils/SplitModule.cpp +++ lib/Transforms/Utils/SplitModule.cpp @@ -156,8 +156,7 @@ for (ClusterMapType::iterator I = GVtoClusterMap.begin(), E = GVtoClusterMap.end(); I != E; ++I) if (I->isLeader()) - Sets.push_back( - std::make_pair(std::distance(GVtoClusterMap.member_begin(I), + Sets.emplace_back(std::make_pair(std::distance(GVtoClusterMap.member_begin(I), GVtoClusterMap.member_end()), I)); std::sort(Sets.begin(), Sets.end(), [](const SortType &a, const SortType &b) { Index: lib/Transforms/Utils/ValueMapper.cpp =================================================================== --- lib/Transforms/Utils/ValueMapper.cpp +++ lib/Transforms/Utils/ValueMapper.cpp @@ -124,7 +124,7 @@ unsigned registerAlternateMappingContext(ValueToValueMapTy &VM, ValueMaterializer *Materializer = nullptr) { - MCs.push_back(MappingContext(VM, Materializer)); + MCs.emplace_back(VM, Materializer); return MCs.size() - 1; } Index: lib/Transforms/Vectorize/BBVectorize.cpp =================================================================== --- lib/Transforms/Vectorize/BBVectorize.cpp +++ lib/Transforms/Vectorize/BBVectorize.cpp @@ -1615,7 +1615,7 @@ // the pairs that compose the DAG and the maximum depth of the DAG. SmallVector Q; // General depth-first post-order traversal: - Q.push_back(ValuePairWithDepth(J, getDepthFactor(J.first))); + Q.emplace_back(J, getDepthFactor(J.first)); do { ValuePairWithDepth QTop = Q.back(); @@ -1632,7 +1632,7 @@ DenseMap::iterator C = DAG.find(*k); if (C == DAG.end()) { size_t d = getDepthFactor(k->first); - Q.push_back(ValuePairWithDepth(*k, QTop.second+d)); + Q.emplace_back(*k, QTop.second+d); MoreChildren = true; } else { MaxChildDepth = std::max(MaxChildDepth, C->second); @@ -1663,7 +1663,7 @@ bool UseCycleCheck) { SmallVector Q; // General depth-first post-order traversal: - Q.push_back(ValuePairWithDepth(J, getDepthFactor(J.first))); + Q.emplace_back(J, getDepthFactor(J.first)); do { ValuePairWithDepth QTop = Q.pop_back_val(); PrunedDAG.insert(QTop.first); @@ -1810,14 +1810,14 @@ ++C2; } - BestChildren.push_back(ValuePairWithDepth(C->first, C->second)); + BestChildren.emplace_back(C->first, C->second); } for (SmallVectorImpl::iterator C = BestChildren.begin(), E2 = BestChildren.end(); C != E2; ++C) { size_t DepthF = getDepthFactor(C->first.first); - Q.push_back(ValuePairWithDepth(C->first, QTop.second+DepthF)); + Q.emplace_back(C->first, QTop.second+DepthF); } } while (!Q.empty()); } @@ -3185,13 +3185,13 @@ if (II != LoadMoveSet.end()) for (std::vector::iterator N = II->second.begin(), NE = II->second.end(); N != NE; ++N) - NewSetMembers.push_back(ValuePair(K, *N)); + NewSetMembers.emplace_back(K, *N); DenseMap >::iterator JJ = LoadMoveSet.find(J); if (JJ != LoadMoveSet.end()) for (std::vector::iterator N = JJ->second.begin(), NE = JJ->second.end(); N != NE; ++N) - NewSetMembers.push_back(ValuePair(K, *N)); + NewSetMembers.emplace_back(K, *N); for (std::vector::iterator A = NewSetMembers.begin(), AE = NewSetMembers.end(); A != AE; ++A) { LoadMoveSet[A->first].push_back(A->second); Index: lib/Transforms/Vectorize/SLPVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/SLPVectorizer.cpp +++ lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1000,7 +1000,7 @@ DEBUG(dbgs() << "SLP: Need to extract:" << *U << " from lane " << Lane << " from " << *Scalar << ".\n"); - ExternalUses.push_back(ExternalUser(Scalar, U, Lane)); + ExternalUses.emplace_back(Scalar, U, Lane); } } } @@ -2195,7 +2195,7 @@ } } assert(FoundLane >= 0 && "Could not find the correct lane"); - ExternalUses.push_back(ExternalUser(VL[i], Insrt, FoundLane)); + ExternalUses.emplace_back(VL[i], Insrt, FoundLane); } } } @@ -2452,8 +2452,7 @@ // ExternalUses list to make sure that an extract will be generated in the // future. if (ScalarToTreeEntry.count(LI->getPointerOperand())) - ExternalUses.push_back( - ExternalUser(LI->getPointerOperand(), cast(VecPtr), 0)); + ExternalUses.emplace_back(LI->getPointerOperand(), cast(VecPtr), 0); unsigned Alignment = LI->getAlignment(); LI = Builder.CreateLoad(VecPtr); @@ -2485,8 +2484,7 @@ // ExternalUses list to make sure that an extract will be generated in the // future. if (ScalarToTreeEntry.count(SI->getPointerOperand())) - ExternalUses.push_back( - ExternalUser(SI->getPointerOperand(), cast(VecPtr), 0)); + ExternalUses.emplace_back(SI->getPointerOperand(), cast(VecPtr), 0); if (!Alignment) { Alignment = DL->getABITypeAlignment(SI->getValueOperand()->getType()); @@ -2568,7 +2566,7 @@ // call to ExternalUses list to make sure that an extract will be // generated in the future. if (ScalarArg && ScalarToTreeEntry.count(ScalarArg)) - ExternalUses.push_back(ExternalUser(ScalarArg, cast(V), 0)); + ExternalUses.emplace_back(ScalarArg, cast(V), 0); E->VectorizedValue = V; ++NumVectorInstructions; @@ -4053,7 +4051,7 @@ // Post order traverse the reduction tree starting at B. We only handle true // trees containing only binary operators or selects. SmallVector, 32> Stack; - Stack.push_back(std::make_pair(B, 0)); + Stack.emplace_back(std::make_pair(B, 0)); while (!Stack.empty()) { Instruction *TreeN = Stack.back().first; unsigned EdgeToVist = Stack.back().second++; @@ -4094,7 +4092,7 @@ // We currently only allow BinaryOperator's and SelectInst's as reduction // values in our tree. if (isa(NextV) || isa(NextV)) - Stack.push_back(std::make_pair(cast(NextV), 0)); + Stack.emplace_back(std::make_pair(cast(NextV), 0)); else if (NextV != Phi) return false; } Index: tools/clang-format/ClangFormat.cpp =================================================================== --- tools/clang-format/ClangFormat.cpp +++ tools/clang-format/ClangFormat.cpp @@ -160,7 +160,7 @@ return true; unsigned Offset = Sources.getFileOffset(Start); unsigned Length = Sources.getFileOffset(End) - Offset; - Ranges.push_back(tooling::Range(Offset, Length)); + Ranges.emplace_back(Offset, Length); } return false; } @@ -193,7 +193,7 @@ } unsigned Offset = Sources.getFileOffset(Start); unsigned Length = Sources.getFileOffset(End) - Offset; - Ranges.push_back(tooling::Range(Offset, Length)); + Ranges.emplace_back(Offset, Length); } return false; } @@ -260,7 +260,7 @@ std::string ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), Replaces); for (const auto &R : Replaces) - Ranges.push_back({R.getOffset(), R.getLength()}); + Ranges.emplace_back(R.getOffset(), R.getLength()); bool IncompleteFormat = false; Replacements FormatChanges = reformat(FormatStyle, ChangedCode, Ranges, Index: tools/diagtool/ShowEnabledWarnings.cpp =================================================================== --- tools/diagtool/ShowEnabledWarnings.cpp +++ tools/diagtool/ShowEnabledWarnings.cpp @@ -132,7 +132,7 @@ continue; StringRef WarningOpt = DiagnosticIDs::getWarningOptionForDiag(DiagID); - Active.push_back(PrettyDiag(I->getName(), WarningOpt, DiagLevel)); + Active.emplace_back(I->getName(), WarningOpt, DiagLevel); } // Print them all out. Index: tools/libclang/CIndex.cpp =================================================================== --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -2967,15 +2967,15 @@ Pieces.push_back(QLoc); if (Kind != DeclarationName::CXXOperatorName || IsMemberRefExpr) - Pieces.push_back(NI.getLoc()); + Pieces.emplace_back(NI.getLoc()); if (WantTemplateArgs && TemplateArgsLoc && TemplateArgsLoc->isValid()) Pieces.push_back(*TemplateArgsLoc); if (Kind == DeclarationName::CXXOperatorName) { - Pieces.push_back(SourceLocation::getFromRawEncoding( + Pieces.emplace_back(SourceLocation::getFromRawEncoding( NI.getInfo().CXXOperatorName.BeginOpNameLoc)); - Pieces.push_back(SourceLocation::getFromRawEncoding( + Pieces.emplace_back(SourceLocation::getFromRawEncoding( NI.getInfo().CXXOperatorName.EndOpNameLoc)); } Index: tools/libclang/CXIndexDataConsumer.cpp =================================================================== --- tools/libclang/CXIndexDataConsumer.cpp +++ tools/libclang/CXIndexDataConsumer.cpp @@ -284,13 +284,13 @@ CXIdxLoc Loc = IdxCtx.getIndexLoc(A->getLocation()); switch (C.kind) { default: - Attrs.push_back(AttrInfo(CXIdxAttr_Unexposed, C, Loc, A)); + Attrs.emplace_back(CXIdxAttr_Unexposed, C, Loc, A); break; case CXCursor_IBActionAttr: - Attrs.push_back(AttrInfo(CXIdxAttr_IBAction, C, Loc, A)); + Attrs.emplace_back(CXIdxAttr_IBAction, C, Loc, A); break; case CXCursor_IBOutletAttr: - Attrs.push_back(AttrInfo(CXIdxAttr_IBOutlet, C, Loc, A)); + Attrs.emplace_back(CXIdxAttr_IBOutlet, C, Loc, A); break; case CXCursor_IBOutletCollectionAttr: IBCollAttrs.push_back(IBOutletCollectionInfo(C, Loc, A)); Index: tools/llvm-ar/llvm-ar.cpp =================================================================== --- tools/llvm-ar/llvm-ar.cpp +++ tools/llvm-ar/llvm-ar.cpp @@ -181,7 +181,7 @@ // Copy over remaining items in RestOfArgs to our Members vector static void getMembers() { for (auto &Arg : RestOfArgs) - Members.push_back(Arg); + Members.emplace_back(Arg); } static void runMRIScript(); Index: tools/llvm-config/llvm-config.cpp =================================================================== --- tools/llvm-config/llvm-config.cpp +++ tools/llvm-config/llvm-config.cpp @@ -571,7 +571,7 @@ // If no components were specified, default to "all". if (Components.empty()) - Components.push_back("all"); + Components.emplace_back("all"); // Construct the list of all the required libraries. std::function Index: tools/llvm-diff/DiffLog.cpp =================================================================== --- tools/llvm-diff/DiffLog.cpp +++ tools/llvm-diff/DiffLog.cpp @@ -31,15 +31,15 @@ DiffLogBuilder::~DiffLogBuilder() { consumer.logd(*this); } void DiffLogBuilder::addMatch(Instruction *L, Instruction *R) { - Diff.push_back(DiffRecord(L, R)); + Diff.emplace_back(L, R); } void DiffLogBuilder::addLeft(Instruction *L) { // HACK: VS 2010 has a bug in the stdlib that requires this. - Diff.push_back(DiffRecord(L, DiffRecord::second_type(nullptr))); + Diff.emplace_back(L, DiffRecord::second_type(nullptr)); } void DiffLogBuilder::addRight(Instruction *R) { // HACK: VS 2010 has a bug in the stdlib that requires this. - Diff.push_back(DiffRecord(DiffRecord::first_type(nullptr), R)); + Diff.emplace_back(DiffRecord::first_type(nullptr), R); } unsigned DiffLogBuilder::getNumLines() const { return Diff.size(); } Index: tools/llvm-pdbdump/llvm-pdbdump.cpp =================================================================== --- tools/llvm-pdbdump/llvm-pdbdump.cpp +++ tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -360,7 +360,7 @@ if (YamlObj.StreamMap.hasValue()) { std::vector> StreamMap; for (auto &E : YamlObj.StreamMap.getValue()) { - StreamMap.push_back(E.Blocks); + StreamMap.emplace_back(E.Blocks); } Pdb.setStreamMap(StreamMap); } Index: tools/llvm-readobj/ELFDumper.cpp =================================================================== --- tools/llvm-readobj/ELFDumper.cpp +++ tools/llvm-readobj/ELFDumper.cpp @@ -482,8 +482,8 @@ // The first two version indexes are reserved. // Index 0 is LOCAL, index 1 is GLOBAL. - VersionMap.push_back(VersionMapEntry()); - VersionMap.push_back(VersionMapEntry()); + VersionMap.emplace_back(); + VersionMap.emplace_back(); if (dot_gnu_version_d_sec) LoadVersionDefs(dot_gnu_version_d_sec); Index: tools/obj2yaml/macho2yaml.cpp =================================================================== --- tools/obj2yaml/macho2yaml.cpp +++ tools/obj2yaml/macho2yaml.cpp @@ -232,7 +232,7 @@ case MachO::REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: ULEB = decodeULEB128(OpCode + 1, &Count); - RebaseOp.ExtraData.push_back(ULEB); + RebaseOp.ExtraData.emplace_back(ULEB); OpCode += Count; // Intentionally no break here -- This opcode has two ULEB values case MachO::REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: @@ -241,7 +241,7 @@ case MachO::REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB: ULEB = decodeULEB128(OpCode + 1, &Count); - RebaseOp.ExtraData.push_back(ULEB); + RebaseOp.ExtraData.emplace_back(ULEB); OpCode += Count; break; default: @@ -279,7 +279,7 @@ switch (BindOp.Opcode) { case MachO::BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: ULEB = decodeULEB128(OpCode + 1, &Count); - BindOp.ULEBExtraData.push_back(ULEB); + BindOp.ULEBExtraData.emplace_back(ULEB); OpCode += Count; // Intentionally no break here -- this opcode has two ULEB values @@ -288,7 +288,7 @@ case MachO::BIND_OPCODE_ADD_ADDR_ULEB: case MachO::BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: ULEB = decodeULEB128(OpCode + 1, &Count); - BindOp.ULEBExtraData.push_back(ULEB); + BindOp.ULEBExtraData.emplace_back(ULEB); OpCode += Count; break; Index: tools/yaml2obj/yaml2macho.cpp =================================================================== --- tools/yaml2obj/yaml2macho.cpp +++ tools/yaml2obj/yaml2macho.cpp @@ -347,22 +347,20 @@ switch (LC.Data.load_command_data.cmd) { case MachO::LC_SYMTAB: SymtabCmd = &LC.Data.symtab_command_data; - WriteQueue.push_back( - std::make_pair(SymtabCmd->symoff, &MachOWriter::writeNameList)); - WriteQueue.push_back( - std::make_pair(SymtabCmd->stroff, &MachOWriter::writeStringTable)); + WriteQueue.emplace_back(std::make_pair(SymtabCmd->symoff, &MachOWriter::writeNameList)); + WriteQueue.emplace_back(std::make_pair(SymtabCmd->stroff, &MachOWriter::writeStringTable)); break; case MachO::LC_DYLD_INFO_ONLY: DyldInfoOnlyCmd = &LC.Data.dyld_info_command_data; - WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->rebase_off, + WriteQueue.emplace_back(std::make_pair(DyldInfoOnlyCmd->rebase_off, &MachOWriter::writeRebaseOpcodes)); - WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->bind_off, + WriteQueue.emplace_back(std::make_pair(DyldInfoOnlyCmd->bind_off, &MachOWriter::writeBasicBindOpcodes)); - WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->weak_bind_off, + WriteQueue.emplace_back(std::make_pair(DyldInfoOnlyCmd->weak_bind_off, &MachOWriter::writeWeakBindOpcodes)); - WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->lazy_bind_off, + WriteQueue.emplace_back(std::make_pair(DyldInfoOnlyCmd->lazy_bind_off, &MachOWriter::writeLazyBindOpcodes)); - WriteQueue.push_back(std::make_pair(DyldInfoOnlyCmd->export_off, + WriteQueue.emplace_back(std::make_pair(DyldInfoOnlyCmd->export_off, &MachOWriter::writeExportTrie)); break; } Index: unittests/ADT/DAGDeltaAlgorithmTest.cpp =================================================================== --- unittests/ADT/DAGDeltaAlgorithmTest.cpp +++ unittests/ADT/DAGDeltaAlgorithmTest.cpp @@ -63,7 +63,7 @@ // Dependencies: // 1 - 3 Deps.clear(); - Deps.push_back(std::make_pair(3, 1)); + Deps.emplace_back(std::make_pair(3, 1)); // P = {3,5,7} \in S, // [0, 20), @@ -77,10 +77,10 @@ // \- 2 - 3 // \- 4 Deps.clear(); - Deps.push_back(std::make_pair(1, 0)); - Deps.push_back(std::make_pair(2, 0)); - Deps.push_back(std::make_pair(4, 0)); - Deps.push_back(std::make_pair(3, 2)); + Deps.emplace_back(std::make_pair(1, 0)); + Deps.emplace_back(std::make_pair(2, 0)); + Deps.emplace_back(std::make_pair(4, 0)); + Deps.emplace_back(std::make_pair(3, 2)); // This is a case where we must hold required changes. // Index: unittests/ADT/SmallVectorTest.cpp =================================================================== --- unittests/ADT/SmallVectorTest.cpp +++ unittests/ADT/SmallVectorTest.cpp @@ -762,7 +762,7 @@ TEST(SmallVectorTest, MidInsert) { SmallVector v; - v.push_back(MovedFrom()); + v.emplace_back(); v.insert(v.begin(), MovedFrom()); for (MovedFrom &m : v) EXPECT_TRUE(m.hasValue); Index: unittests/ADT/StringRefTest.cpp =================================================================== --- unittests/ADT/StringRefTest.cpp +++ unittests/ADT/StringRefTest.cpp @@ -151,18 +151,18 @@ SmallVector parts; SmallVector expected; - expected.push_back("ab"); expected.push_back("c"); + expected.emplace_back("ab"); expected.emplace_back("c"); StringRef(",ab,,c,").split(parts, ",", -1, false); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back(""); expected.push_back("ab"); expected.push_back(""); - expected.push_back("c"); expected.push_back(""); + expected.emplace_back(""); expected.emplace_back("ab"); expected.emplace_back(""); + expected.emplace_back("c"); expected.emplace_back(""); StringRef(",ab,,c,").split(parts, ",", -1, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back(""); + expected.emplace_back(""); StringRef("").split(parts, ",", -1, true); EXPECT_TRUE(parts == expected); @@ -175,69 +175,69 @@ EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back(""); expected.push_back(""); + expected.emplace_back(""); expected.emplace_back(""); StringRef(",").split(parts, ",", -1, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); expected.push_back("b"); + expected.emplace_back("a"); expected.emplace_back("b"); StringRef("a,b").split(parts, ",", -1, true); EXPECT_TRUE(parts == expected); // Test MaxSplit expected.clear(); parts.clear(); - expected.push_back("a,,b,c"); + expected.emplace_back("a,,b,c"); StringRef("a,,b,c").split(parts, ",", 0, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a,,b,c"); + expected.emplace_back("a,,b,c"); StringRef("a,,b,c").split(parts, ",", 0, false); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); expected.push_back(",b,c"); + expected.emplace_back("a"); expected.emplace_back(",b,c"); StringRef("a,,b,c").split(parts, ",", 1, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); expected.push_back(",b,c"); + expected.emplace_back("a"); expected.emplace_back(",b,c"); StringRef("a,,b,c").split(parts, ",", 1, false); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); expected.push_back(""); expected.push_back("b,c"); + expected.emplace_back("a"); expected.emplace_back(""); expected.emplace_back("b,c"); StringRef("a,,b,c").split(parts, ",", 2, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); expected.push_back("b,c"); + expected.emplace_back("a"); expected.emplace_back("b,c"); StringRef("a,,b,c").split(parts, ",", 2, false); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); expected.push_back(""); expected.push_back("b"); - expected.push_back("c"); + expected.emplace_back("a"); expected.emplace_back(""); expected.emplace_back("b"); + expected.emplace_back("c"); StringRef("a,,b,c").split(parts, ",", 3, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); expected.push_back("b"); expected.push_back("c"); + expected.emplace_back("a"); expected.emplace_back("b"); expected.emplace_back("c"); StringRef("a,,b,c").split(parts, ",", 3, false); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); expected.push_back("b"); expected.push_back("c"); + expected.emplace_back("a"); expected.emplace_back("b"); expected.emplace_back("c"); StringRef("a,,b,c").split(parts, ',', 3, false); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back(""); + expected.emplace_back(""); StringRef().split(parts, ",", 0, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back(StringRef()); + expected.emplace_back(); StringRef("").split(parts, ",", 0, true); EXPECT_TRUE(parts == expected); @@ -248,20 +248,20 @@ EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); - expected.push_back(""); - expected.push_back("b"); - expected.push_back("c,d"); + expected.emplace_back("a"); + expected.emplace_back(""); + expected.emplace_back("b"); + expected.emplace_back("c,d"); StringRef("a,,b,c,d").split(parts, ",", 3, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back(""); + expected.emplace_back(""); StringRef().split(parts, ',', 0, true); EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back(StringRef()); + expected.emplace_back(); StringRef("").split(parts, ',', 0, true); EXPECT_TRUE(parts == expected); @@ -272,10 +272,10 @@ EXPECT_TRUE(parts == expected); expected.clear(); parts.clear(); - expected.push_back("a"); - expected.push_back(""); - expected.push_back("b"); - expected.push_back("c,d"); + expected.emplace_back("a"); + expected.emplace_back(""); + expected.emplace_back("b"); + expected.emplace_back("c,d"); StringRef("a,,b,c,d").split(parts, ',', 3, true); EXPECT_TRUE(parts == expected); } @@ -567,7 +567,7 @@ std::vector v1; std::vector v2; for (size_t i = 0; i < array_lengthof(join_input); ++i) { - v1.push_back(join_input[i]); + v1.emplace_back(join_input[i]); v2.push_back(join_input[i]); } Index: unittests/Format/CleanupTest.cpp =================================================================== --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -44,9 +44,9 @@ "namespace D { int i; }\n \n" "}"; std::vector Ranges; - Ranges.push_back(tooling::Range(28, 0)); - Ranges.push_back(tooling::Range(91, 6)); - Ranges.push_back(tooling::Range(132, 0)); + Ranges.emplace_back(28, 0); + Ranges.emplace_back(91, 6); + Ranges.emplace_back(132, 0); std::string Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); } @@ -118,22 +118,22 @@ std::string Code = "class A {\nA() : , {} };"; std::string Expected = "class A {\nA() {} };"; std::vector Ranges; - Ranges.push_back(tooling::Range(17, 0)); - Ranges.push_back(tooling::Range(19, 0)); + Ranges.emplace_back(17, 0); + Ranges.emplace_back(19, 0); std::string Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); Code = "class A {\nA() : x(1), {} };"; Expected = "class A {\nA() : x(1) {} };"; Ranges.clear(); - Ranges.push_back(tooling::Range(23, 0)); + Ranges.emplace_back(23, 0); Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); Code = "class A {\nA() :,,,,{} };"; Expected = "class A {\nA() {} };"; Ranges.clear(); - Ranges.push_back(tooling::Range(15, 0)); + Ranges.emplace_back(15, 0); Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); } @@ -142,15 +142,15 @@ std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5}}; }"; std::string Expected = "void f() { std::vector v = {1,2,3,{4,5}}; }"; std::vector Ranges; - Ranges.push_back(tooling::Range(40, 0)); + Ranges.emplace_back(40, 0); std::string Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); Code = "int main() { f(1,,2,3,,4);}"; Expected = "int main() { f(1,2,3,4);}"; Ranges.clear(); - Ranges.push_back(tooling::Range(17, 0)); - Ranges.push_back(tooling::Range(22, 0)); + Ranges.emplace_back(17, 0); + Ranges.emplace_back(22, 0); Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); } @@ -159,8 +159,8 @@ std::string Code = "class A {\nA() : x({1}),, {} };"; std::string Expected = "class A {\nA() : x({1}) {} };"; std::vector Ranges; - Ranges.push_back(tooling::Range(24, 0)); - Ranges.push_back(tooling::Range(26, 0)); + Ranges.emplace_back(24, 0); + Ranges.emplace_back(26, 0); std::string Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); } @@ -190,8 +190,8 @@ std::string Code = "class A {\nA() : x({1}), /* comment */, {} };"; std::string Expected = "class A {\nA() : x({1}) /* comment */ {} };"; std::vector Ranges; - Ranges.push_back(tooling::Range(25, 0)); - Ranges.push_back(tooling::Range(40, 0)); + Ranges.emplace_back(25, 0); + Ranges.emplace_back(40, 0); std::string Result = cleanup(Code, Ranges); EXPECT_EQ(Expected, Result); Index: unittests/IR/ValueMapTest.cpp =================================================================== --- unittests/IR/ValueMapTest.cpp +++ unittests/IR/ValueMapTest.cpp @@ -107,8 +107,8 @@ // Range insert: SmallVector, 2> Elems; - Elems.push_back(std::make_pair(this->AddV.get(), 1)); - Elems.push_back(std::make_pair(this->BitcastV.get(), 2)); + Elems.emplace_back(std::make_pair(this->AddV.get(), 1)); + Elems.emplace_back(std::make_pair(this->BitcastV.get(), 2)); VM.insert(Elems.begin(), Elems.end()); EXPECT_EQ(1, VM.lookup(this->AddV.get())); EXPECT_EQ(2, VM.lookup(this->BitcastV.get())); Index: unittests/ProfileData/InstrProfTest.cpp =================================================================== --- unittests/ProfileData/InstrProfTest.cpp +++ unittests/ProfileData/InstrProfTest.cpp @@ -829,12 +829,12 @@ // Testing symtab creator interface used by indexed profile reader. TEST_P(MaybeSparseInstrProfTest, instr_prof_symtab_test) { std::vector FuncNames; - FuncNames.push_back("func1"); - FuncNames.push_back("func2"); - FuncNames.push_back("func3"); - FuncNames.push_back("bar1"); - FuncNames.push_back("bar2"); - FuncNames.push_back("bar3"); + FuncNames.emplace_back("func1"); + FuncNames.emplace_back("func2"); + FuncNames.emplace_back("func3"); + FuncNames.emplace_back("bar1"); + FuncNames.emplace_back("bar2"); + FuncNames.emplace_back("bar3"); InstrProfSymtab Symtab; Symtab.create(FuncNames); StringRef R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("func1")); Index: unittests/Support/Path.cpp =================================================================== --- unittests/Support/Path.cpp +++ unittests/Support/Path.cpp @@ -57,46 +57,46 @@ TEST(Support, Path) { SmallVector paths; - paths.push_back(""); - paths.push_back("."); - paths.push_back(".."); - paths.push_back("foo"); - paths.push_back("/"); - paths.push_back("/foo"); - paths.push_back("foo/"); - paths.push_back("/foo/"); - paths.push_back("foo/bar"); - paths.push_back("/foo/bar"); - paths.push_back("//net"); - paths.push_back("//net/foo"); - paths.push_back("///foo///"); - paths.push_back("///foo///bar"); - paths.push_back("/."); - paths.push_back("./"); - paths.push_back("/.."); - paths.push_back("../"); - paths.push_back("foo/."); - paths.push_back("foo/.."); - paths.push_back("foo/./"); - paths.push_back("foo/./bar"); - paths.push_back("foo/.."); - paths.push_back("foo/../"); - paths.push_back("foo/../bar"); - paths.push_back("c:"); - paths.push_back("c:/"); - paths.push_back("c:foo"); - paths.push_back("c:/foo"); - paths.push_back("c:foo/"); - paths.push_back("c:/foo/"); - paths.push_back("c:/foo/bar"); - paths.push_back("prn:"); - paths.push_back("c:\\"); - paths.push_back("c:foo"); - paths.push_back("c:\\foo"); - paths.push_back("c:foo\\"); - paths.push_back("c:\\foo\\"); - paths.push_back("c:\\foo/"); - paths.push_back("c:/foo\\bar"); + paths.emplace_back(""); + paths.emplace_back("."); + paths.emplace_back(".."); + paths.emplace_back("foo"); + paths.emplace_back("/"); + paths.emplace_back("/foo"); + paths.emplace_back("foo/"); + paths.emplace_back("/foo/"); + paths.emplace_back("foo/bar"); + paths.emplace_back("/foo/bar"); + paths.emplace_back("//net"); + paths.emplace_back("//net/foo"); + paths.emplace_back("///foo///"); + paths.emplace_back("///foo///bar"); + paths.emplace_back("/."); + paths.emplace_back("./"); + paths.emplace_back("/.."); + paths.emplace_back("../"); + paths.emplace_back("foo/."); + paths.emplace_back("foo/.."); + paths.emplace_back("foo/./"); + paths.emplace_back("foo/./bar"); + paths.emplace_back("foo/.."); + paths.emplace_back("foo/../"); + paths.emplace_back("foo/../bar"); + paths.emplace_back("c:"); + paths.emplace_back("c:/"); + paths.emplace_back("c:foo"); + paths.emplace_back("c:/foo"); + paths.emplace_back("c:foo/"); + paths.emplace_back("c:/foo/"); + paths.emplace_back("c:/foo/bar"); + paths.emplace_back("prn:"); + paths.emplace_back("c:\\"); + paths.emplace_back("c:foo"); + paths.emplace_back("c:\\foo"); + paths.emplace_back("c:foo\\"); + paths.emplace_back("c:\\foo\\"); + paths.emplace_back("c:\\foo/"); + paths.emplace_back("c:/foo\\bar"); SmallVector ComponentStack; for (SmallVector::const_iterator i = paths.begin(), @@ -274,9 +274,9 @@ TEST(Support, AbsolutePathIteratorEnd) { // Trailing slashes are converted to '.' unless they are part of the root path. SmallVector Paths; - Paths.push_back("/foo/"); - Paths.push_back("/foo//"); - Paths.push_back("//net//"); + Paths.emplace_back("/foo/"); + Paths.emplace_back("/foo//"); + Paths.emplace_back("//net//"); #ifdef LLVM_ON_WIN32 Paths.push_back("c:\\\\"); #endif @@ -287,8 +287,8 @@ } SmallVector RootPaths; - RootPaths.push_back("/"); - RootPaths.push_back("//net/"); + RootPaths.emplace_back("/"); + RootPaths.emplace_back("//net/"); #ifdef LLVM_ON_WIN32 RootPaths.push_back("c:\\"); #endif Index: unittests/Support/YAMLIOTest.cpp =================================================================== --- unittests/Support/YAMLIOTest.cpp +++ unittests/Support/YAMLIOTest.cpp @@ -1103,12 +1103,12 @@ { NameAndNumbers map; map.name = "hello"; - map.strings.push_back(llvm::StringRef("one")); - map.strings.push_back(llvm::StringRef("two")); - map.single.push_back(1); - map.numbers.push_back(10); - map.numbers.push_back(-30); - map.numbers.push_back(1024); + map.strings.emplace_back("one"); + map.strings.emplace_back("two"); + map.single.emplace_back(1); + map.numbers.emplace_back(10); + map.numbers.emplace_back(-30); + map.numbers.emplace_back(1024); llvm::raw_string_ostream ostr(intermediate); Output yout(ostr); @@ -1255,9 +1255,9 @@ std::string intermediate; { SecondsSequence seq; - seq.push_back(4000); - seq.push_back(500); - seq.push_back(59); + seq.emplace_back(4000); + seq.emplace_back(500); + seq.emplace_back(59); llvm::raw_string_ostream ostr(intermediate); Output yout(ostr); @@ -1378,11 +1378,11 @@ std::string intermediate; { KindAndFlagsSequence seq; - seq.push_back(KindAndFlags(kindA,a1)); - seq.push_back(KindAndFlags(kindB,b1)); - seq.push_back(KindAndFlags(kindA,a2)); - seq.push_back(KindAndFlags(kindB,b2)); - seq.push_back(KindAndFlags(kindA,a3)); + seq.emplace_back(kindA,a1); + seq.emplace_back(kindB,b1); + seq.emplace_back(kindA,a2); + seq.emplace_back(kindB,b2); + seq.emplace_back(kindA,a3); llvm::raw_string_ostream ostr(intermediate); Output yout(ostr); @@ -1663,9 +1663,9 @@ { FlowFooBarDoc doc; doc.attribute = FlowFooBar(42, 907); - doc.seq.push_back(FlowFooBar(1, 2)); - doc.seq.push_back(FlowFooBar(0, 0)); - doc.seq.push_back(FlowFooBar(-1, 1024)); + doc.seq.emplace_back(1, 2); + doc.seq.emplace_back(0, 0); + doc.seq.emplace_back(-1, 1024); llvm::raw_string_ostream ostr(intermediate); Output yout(ostr); Index: utils/FileCheck/FileCheck.cpp =================================================================== --- utils/FileCheck/FileCheck.cpp +++ utils/FileCheck/FileCheck.cpp @@ -326,7 +326,7 @@ } AddBackrefToRegEx(VarParenNum); } else { - VariableUses.push_back(std::make_pair(Name, RegExStr.size())); + VariableUses.emplace_back(std::make_pair(Name, RegExStr.size())); } continue; } Index: utils/TableGen/AsmMatcherEmitter.cpp =================================================================== --- utils/TableGen/AsmMatcherEmitter.cpp +++ utils/TableGen/AsmMatcherEmitter.cpp @@ -945,7 +945,7 @@ /// Append an AsmOperand for the given substring of AsmString. void MatchableInfo::addAsmOperand(StringRef Token, bool IsIsolatedToken) { - AsmOperands.push_back(AsmOperand(IsIsolatedToken, Token)); + AsmOperands.emplace_back(IsIsolatedToken, Token); } /// tokenizeAsmString - Tokenize a simplified assembly string. @@ -2262,10 +2262,10 @@ for (const auto &A : Infos) { std::vector SuperClasses; if (A.IsOptional) - SuperClasses.push_back("OptionalMatchClass"); + SuperClasses.emplace_back("OptionalMatchClass"); for (const auto &B : Infos) { if (&A != &B && A.isSubsetOf(B)) - SuperClasses.push_back(B.Name); + SuperClasses.emplace_back(B.Name); } if (SuperClasses.empty()) Index: utils/TableGen/CTagsEmitter.cpp =================================================================== --- utils/TableGen/CTagsEmitter.cpp +++ utils/TableGen/CTagsEmitter.cpp @@ -69,9 +69,9 @@ // Collect tags. Tags.reserve(Classes.size() + Defs.size()); for (const auto &C : Classes) - Tags.push_back(Tag(C.first, locate(C.second.get()))); + Tags.emplace_back(C.first, locate(C.second.get())); for (const auto &D : Defs) - Tags.push_back(Tag(D.first, locate(D.second.get()))); + Tags.emplace_back(D.first, locate(D.second.get())); // Emit tags. std::sort(Tags.begin(), Tags.end()); OS << "!_TAG_FILE_FORMAT\t1\t/original ctags format/\n"; Index: utils/TableGen/ClangAttrEmitter.cpp =================================================================== --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -3273,7 +3273,7 @@ "documentation categories"); if (!Undocumented) - SplitDocs[Category].push_back(DocumentationData(Doc, Attr)); + SplitDocs[Category].emplace_back(Doc, Attr); } } Index: utils/TableGen/CodeGenInstruction.cpp =================================================================== --- utils/TableGen/CodeGenInstruction.cpp +++ utils/TableGen/CodeGenInstruction.cpp @@ -649,7 +649,7 @@ ResultOperands.emplace_back(Result->getArgName(AliasOpNo) + "." + MIOI->getArgName(SubOp), SubRec); - ResultInstOperandIndex.push_back(std::make_pair(i, SubOp)); + ResultInstOperandIndex.emplace_back(std::make_pair(i, SubOp)); } ++AliasOpNo; } @@ -667,7 +667,7 @@ if (tryAliasOpMatch(Result, AliasOpNo, SubRec, false, R->getLoc(), T, ResOp)) { ResultOperands.push_back(ResOp); - ResultInstOperandIndex.push_back(std::make_pair(i, SubOp)); + ResultInstOperandIndex.emplace_back(std::make_pair(i, SubOp)); ++AliasOpNo; } else { PrintFatalError(R->getLoc(), "result argument #" + Twine(AliasOpNo) + Index: utils/TableGen/CodeGenRegisters.cpp =================================================================== --- utils/TableGen/CodeGenRegisters.cpp +++ utils/TableGen/CodeGenRegisters.cpp @@ -445,7 +445,7 @@ // Each part of Cand is a sub-register of this. Make the full Cand also // a sub-register with a concatenated sub-register index. CodeGenSubRegIndex *Concat= RegBank.getConcatSubRegIndex(Parts); - NewSubRegs.push_back(std::make_pair(Concat, Cand)); + NewSubRegs.emplace_back(std::make_pair(Concat, Cand)); } } Index: utils/TableGen/CodeGenSchedule.cpp =================================================================== --- utils/TableGen/CodeGenSchedule.cpp +++ utils/TableGen/CodeGenSchedule.cpp @@ -1057,7 +1057,7 @@ // Push each variant. Assign TransVecIdx later. const RecVec VarDefs = SchedRW.TheDef->getValueAsListOfDefs("Variants"); for (RecIter RI = VarDefs.begin(), RE = VarDefs.end(); RI != RE; ++RI) - Variants.push_back(TransVariant(*RI, SchedRW.Index, VarProcIdx, 0)); + Variants.emplace_back(*RI, SchedRW.Index, VarProcIdx, 0); if (VarProcIdx == 0) GenericRW = true; } @@ -1077,11 +1077,10 @@ if (AliasRW.HasVariants) { const RecVec VarDefs = AliasRW.TheDef->getValueAsListOfDefs("Variants"); for (RecIter RI = VarDefs.begin(), RE = VarDefs.end(); RI != RE; ++RI) - Variants.push_back(TransVariant(*RI, AliasRW.Index, AliasProcIdx, 0)); + Variants.emplace_back(*RI, AliasRW.Index, AliasProcIdx, 0); } if (AliasRW.IsSequence) { - Variants.push_back( - TransVariant(AliasRW.TheDef, SchedRW.Index, AliasProcIdx, 0)); + Variants.emplace_back(AliasRW.TheDef, SchedRW.Index, AliasProcIdx, 0); } if (AliasProcIdx == 0) GenericRW = true; @@ -1143,7 +1142,7 @@ IdxVec SelectedRWs; if (VInfo.VarOrSeqDef->isSubClassOf("SchedVar")) { Record *PredDef = VInfo.VarOrSeqDef->getValueAsDef("Predicate"); - Trans.PredTerm.push_back(PredCheck(IsRead, VInfo.RWIdx,PredDef)); + Trans.PredTerm.emplace_back(IsRead, VInfo.RWIdx,PredDef); RecVec SelectedDefs = VInfo.VarOrSeqDef->getValueAsListOfDefs("Selected"); SchedModels.findRWs(SelectedDefs, SelectedRWs, IsRead); } Index: utils/TableGen/FixedLenDecoderEmitter.cpp =================================================================== --- utils/TableGen/FixedLenDecoderEmitter.cpp +++ utils/TableGen/FixedLenDecoderEmitter.cpp @@ -51,7 +51,7 @@ : Decoder(std::move(D)), HasCompleteDecoder(HCD) {} void addField(unsigned Base, unsigned Width, unsigned Offset) { - Fields.push_back(EncodingField(Base, Width, Offset)); + Fields.emplace_back(Base, Width, Offset); } unsigned numFields() const { return Fields.size(); }