From 0a3eef53d7eb99bb902c40549d4170a5048c16c0 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 2 Mar 2014 04:08:41 +0000 Subject: [PATCH] [C++11] Switch all uses of the llvm_move macro to use std::move directly, and remove the macro. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202612 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/DenseMap.h | 22 ++++++++++---------- include/llvm/Analysis/PtrUseVisitor.h | 2 +- include/llvm/IR/PassManager.h | 24 +++++++++++----------- include/llvm/Support/Compiler.h | 4 ---- lib/Analysis/PtrUseVisitor.cpp | 2 +- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 6 +++--- lib/DebugInfo/DWARFDebugLoc.cpp | 2 +- lib/IR/PassManager.cpp | 4 ++-- lib/Support/ConstantRange.cpp | 4 ++-- lib/Support/YAMLParser.cpp | 6 +++--- lib/Transforms/Scalar/ConstantHoisting.cpp | 2 +- unittests/ADT/SmallPtrSetTest.cpp | 2 +- unittests/ADT/polymorphic_ptr_test.cpp | 2 +- unittests/Support/Path.cpp | 2 +- utils/yaml-bench/YAMLBench.cpp | 2 +- 15 files changed, 41 insertions(+), 45 deletions(-) diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index abbb453a2e1..07cfe406d6c 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -285,8 +285,8 @@ protected: bool FoundVal = LookupBucketFor(B->first, DestBucket); (void)FoundVal; // silence warning. assert(!FoundVal && "Key already in new map?"); - DestBucket->first = llvm_move(B->first); - new (&DestBucket->second) ValueT(llvm_move(B->second)); + DestBucket->first = std::move(B->first); + new (&DestBucket->second) ValueT(std::move(B->second)); incrementNumEntries(); // Free the value. @@ -753,10 +753,10 @@ public: // Swap separately and handle any assymetry. std::swap(LHSB->first, RHSB->first); if (hasLHSValue) { - new (&RHSB->second) ValueT(llvm_move(LHSB->second)); + new (&RHSB->second) ValueT(std::move(LHSB->second)); LHSB->second.~ValueT(); } else if (hasRHSValue) { - new (&LHSB->second) ValueT(llvm_move(RHSB->second)); + new (&LHSB->second) ValueT(std::move(RHSB->second)); RHSB->second.~ValueT(); } } @@ -772,7 +772,7 @@ public: SmallDenseMap &LargeSide = Small ? RHS : *this; // First stash the large side's rep and move the small side across. - LargeRep TmpRep = llvm_move(*LargeSide.getLargeRep()); + LargeRep TmpRep = std::move(*LargeSide.getLargeRep()); LargeSide.getLargeRep()->~LargeRep(); LargeSide.Small = true; // This is similar to the standard move-from-old-buckets, but the bucket @@ -782,11 +782,11 @@ public: for (unsigned i = 0, e = InlineBuckets; i != e; ++i) { BucketT *NewB = &LargeSide.getInlineBuckets()[i], *OldB = &SmallSide.getInlineBuckets()[i]; - new (&NewB->first) KeyT(llvm_move(OldB->first)); + new (&NewB->first) KeyT(std::move(OldB->first)); OldB->first.~KeyT(); if (!KeyInfoT::isEqual(NewB->first, EmptyKey) && !KeyInfoT::isEqual(NewB->first, TombstoneKey)) { - new (&NewB->second) ValueT(llvm_move(OldB->second)); + new (&NewB->second) ValueT(std::move(OldB->second)); OldB->second.~ValueT(); } } @@ -794,7 +794,7 @@ public: // The hard part of moving the small buckets across is done, just move // the TmpRep into its new home. SmallSide.Small = false; - new (SmallSide.getLargeRep()) LargeRep(llvm_move(TmpRep)); + new (SmallSide.getLargeRep()) LargeRep(std::move(TmpRep)); } SmallDenseMap& operator=(const SmallDenseMap& other) { @@ -852,8 +852,8 @@ public: !KeyInfoT::isEqual(P->first, TombstoneKey)) { assert(size_t(TmpEnd - TmpBegin) < InlineBuckets && "Too many inline buckets!"); - new (&TmpEnd->first) KeyT(llvm_move(P->first)); - new (&TmpEnd->second) ValueT(llvm_move(P->second)); + new (&TmpEnd->first) KeyT(std::move(P->first)); + new (&TmpEnd->second) ValueT(std::move(P->second)); ++TmpEnd; P->second.~ValueT(); } @@ -868,7 +868,7 @@ public: return; } - LargeRep OldRep = llvm_move(*getLargeRep()); + LargeRep OldRep = std::move(*getLargeRep()); getLargeRep()->~LargeRep(); if (AtLeast <= InlineBuckets) { Small = true; diff --git a/include/llvm/Analysis/PtrUseVisitor.h b/include/llvm/Analysis/PtrUseVisitor.h index 1802fe88e35..31b0b5b30a2 100644 --- a/include/llvm/Analysis/PtrUseVisitor.h +++ b/include/llvm/Analysis/PtrUseVisitor.h @@ -219,7 +219,7 @@ public: U = ToVisit.UseAndIsOffsetKnown.getPointer(); IsOffsetKnown = ToVisit.UseAndIsOffsetKnown.getInt(); if (IsOffsetKnown) - Offset = llvm_move(ToVisit.Offset); + Offset = std::move(ToVisit.Offset); Instruction *I = cast(U->getUser()); static_cast(this)->visit(I); diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index b1057b50322..cd3da2d8ab2 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -204,7 +204,7 @@ struct PassModel; template struct PassModel : PassConcept { - PassModel(PassT Pass) : Pass(llvm_move(Pass)) {} + PassModel(PassT Pass) : Pass(std::move(Pass)) {} virtual PassModel *clone() { return new PassModel(Pass); } virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) { return Pass.run(IR, AM); @@ -218,7 +218,7 @@ struct PassModel struct PassModel : PassConcept { - PassModel(PassT Pass) : Pass(llvm_move(Pass)) {} + PassModel(PassT Pass) : Pass(std::move(Pass)) {} virtual PassModel *clone() { return new PassModel(Pass); } virtual PreservedAnalyses run(IRUnitT IR, AnalysisManagerT *AM) { return Pass.run(IR); @@ -280,7 +280,7 @@ struct AnalysisResultModel; template struct AnalysisResultModel : AnalysisResultConcept { - AnalysisResultModel(ResultT Result) : Result(llvm_move(Result)) {} + AnalysisResultModel(ResultT Result) : Result(std::move(Result)) {} virtual AnalysisResultModel *clone() { return new AnalysisResultModel(Result); } @@ -302,7 +302,7 @@ struct AnalysisResultModel struct AnalysisResultModel : AnalysisResultConcept { - AnalysisResultModel(ResultT Result) : Result(llvm_move(Result)) {} + AnalysisResultModel(ResultT Result) : Result(std::move(Result)) {} virtual AnalysisResultModel *clone() { return new AnalysisResultModel(Result); } @@ -347,7 +347,7 @@ template struct AnalysisPassModel : AnalysisPassConcept { - AnalysisPassModel(PassT Pass) : Pass(llvm_move(Pass)) {} + AnalysisPassModel(PassT Pass) : Pass(std::move(Pass)) {} virtual AnalysisPassModel *clone() { return new AnalysisPassModel(Pass); } // FIXME: Replace PassT::Result with type traits when we use C++11. @@ -370,7 +370,7 @@ template struct AnalysisPassModel : AnalysisPassConcept { - AnalysisPassModel(PassT Pass) : Pass(llvm_move(Pass)) {} + AnalysisPassModel(PassT Pass) : Pass(std::move(Pass)) {} virtual AnalysisPassModel *clone() { return new AnalysisPassModel(Pass); } // FIXME: Replace PassT::Result with type traits when we use C++11. @@ -403,7 +403,7 @@ public: PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM = 0); template void addPass(ModulePassT Pass) { - Passes.push_back(new ModulePassModel(llvm_move(Pass))); + Passes.push_back(new ModulePassModel(std::move(Pass))); } static StringRef name() { return "ModulePassManager"; } @@ -428,7 +428,7 @@ public: explicit FunctionPassManager() {} template void addPass(FunctionPassT Pass) { - Passes.push_back(new FunctionPassModel(llvm_move(Pass))); + Passes.push_back(new FunctionPassModel(std::move(Pass))); } PreservedAnalyses run(Function *F, FunctionAnalysisManager *AM = 0); @@ -519,7 +519,7 @@ public: assert(!AnalysisPasses.count(PassT::ID()) && "Registered the same analysis pass twice!"); typedef detail::AnalysisPassModel PassModelT; - AnalysisPasses[PassT::ID()] = new PassModelT(llvm_move(Pass)); + AnalysisPasses[PassT::ID()] = new PassModelT(std::move(Pass)); } /// \brief Invalidate a specific analysis pass for an IR module. @@ -783,7 +783,7 @@ template class ModuleToFunctionPassAdaptor { public: explicit ModuleToFunctionPassAdaptor(FunctionPassT Pass) - : Pass(llvm_move(Pass)) {} + : Pass(std::move(Pass)) {} /// \brief Runs the function pass across every function in the module. PreservedAnalyses run(Module *M, ModuleAnalysisManager *AM) { @@ -804,7 +804,7 @@ public: // Then intersect the preserved set so that invalidation of module // analyses will eventually occur when the module pass completes. - PA.intersect(llvm_move(PassPA)); + PA.intersect(std::move(PassPA)); } // By definition we preserve the proxy. This precludes *any* invalidation @@ -826,7 +826,7 @@ private: template ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT Pass) { - return ModuleToFunctionPassAdaptor(llvm_move(Pass)); + return ModuleToFunctionPassAdaptor(std::move(Pass)); } } diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 153c2fd10f0..c2545542480 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -78,10 +78,6 @@ # define LLVM_HAS_VARIADIC_TEMPLATES 0 #endif -/// llvm_move - Expands to ::std::move. This is a hold-over from when we did -/// not support R-value references. -#define llvm_move(value) (::std::move(value)) - /// Expands to '&' if r-value references are supported. /// /// This can be used to provide l-value/r-value overrides of member functions. diff --git a/lib/Analysis/PtrUseVisitor.cpp b/lib/Analysis/PtrUseVisitor.cpp index 0a342b2167e..54f0e27ce3b 100644 --- a/lib/Analysis/PtrUseVisitor.cpp +++ b/lib/Analysis/PtrUseVisitor.cpp @@ -23,7 +23,7 @@ void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) { UseToVisit::UseAndIsOffsetKnownPair(&UI.getUse(), IsOffsetKnown), Offset }; - Worklist.push_back(llvm_move(NewU)); + Worklist.push_back(std::move(NewU)); } } } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 2eff17176b8..aeb2e526220 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -470,11 +470,11 @@ void DwarfDebug::addScopeRangeList(DwarfCompileUnit *TheCU, DIE *ScopeDIE, RI != RE; ++RI) { RangeSpan Span(getLabelBeforeInsn(RI->first), getLabelAfterInsn(RI->second)); - List.addRange(llvm_move(Span)); + List.addRange(std::move(Span)); } // Add the range list to the set of ranges to be emitted. - TheCU->addRangeList(llvm_move(List)); + TheCU->addRangeList(std::move(List)); } // Construct new DW_TAG_lexical_block for this scope and attach @@ -1800,7 +1800,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { // Add the range of this function to the list of ranges for the CU. RangeSpan Span(FunctionBeginSym, FunctionEndSym); - TheCU->addRange(llvm_move(Span)); + TheCU->addRange(std::move(Span)); // Clear debug info for (ScopeVariablesMap::iterator I = ScopeVariables.begin(), diff --git a/lib/DebugInfo/DWARFDebugLoc.cpp b/lib/DebugInfo/DWARFDebugLoc.cpp index 36d17919dea..8fe7481bbfe 100644 --- a/lib/DebugInfo/DWARFDebugLoc.cpp +++ b/lib/DebugInfo/DWARFDebugLoc.cpp @@ -68,7 +68,7 @@ void DWARFDebugLoc::parse(DataExtractor data, unsigned AddressSize) { Offset += Bytes; E.Loc.reserve(str.size()); std::copy(str.begin(), str.end(), std::back_inserter(E.Loc)); - Loc.Entries.push_back(llvm_move(E)); + Loc.Entries.push_back(std::move(E)); } } if (data.isValidOffset(Offset)) diff --git a/lib/IR/PassManager.cpp b/lib/IR/PassManager.cpp index dbc27cbc504..d6699f44f8a 100644 --- a/lib/IR/PassManager.cpp +++ b/lib/IR/PassManager.cpp @@ -31,7 +31,7 @@ PreservedAnalyses ModulePassManager::run(Module *M, ModuleAnalysisManager *AM) { PreservedAnalyses PassPA = Passes[Idx]->run(M, AM); if (AM) AM->invalidate(M, PassPA); - PA.intersect(llvm_move(PassPA)); + PA.intersect(std::move(PassPA)); } if (DebugPM) @@ -89,7 +89,7 @@ PreservedAnalyses FunctionPassManager::run(Function *F, FunctionAnalysisManager PreservedAnalyses PassPA = Passes[Idx]->run(F, AM); if (AM) AM->invalidate(F, PassPA); - PA.intersect(llvm_move(PassPA)); + PA.intersect(std::move(PassPA)); } if (DebugPM) diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index 265b6e96a74..ced8155af5b 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -39,10 +39,10 @@ ConstantRange::ConstantRange(uint32_t BitWidth, bool Full) { /// Initialize a range to hold the single specified value. /// ConstantRange::ConstantRange(APIntMoveTy V) - : Lower(llvm_move(V)), Upper(Lower + 1) {} + : Lower(std::move(V)), Upper(Lower + 1) {} ConstantRange::ConstantRange(APIntMoveTy L, APIntMoveTy U) - : Lower(llvm_move(L)), Upper(llvm_move(U)) { + : Lower(std::move(L)), Upper(std::move(U)) { assert(Lower.getBitWidth() == Upper.getBitWidth() && "ConstantRange with unequal bit widths"); assert((Lower != Upper || (Lower.isMaxValue() || Lower.isMinValue())) && diff --git a/lib/Support/YAMLParser.cpp b/lib/Support/YAMLParser.cpp index 9495cd42240..c3d1ff1b9ed 100644 --- a/lib/Support/YAMLParser.cpp +++ b/lib/Support/YAMLParser.cpp @@ -1617,11 +1617,11 @@ std::string Node::getVerbatimTag() const { if (Raw.find_last_of('!') == 0) { Ret = Doc->getTagMap().find("!")->second; Ret += Raw.substr(1); - return llvm_move(Ret); + return std::move(Ret); } else if (Raw.startswith("!!")) { Ret = Doc->getTagMap().find("!!")->second; Ret += Raw.substr(2); - return llvm_move(Ret); + return std::move(Ret); } else { StringRef TagHandle = Raw.substr(0, Raw.find_last_of('!') + 1); std::map::const_iterator It = @@ -1635,7 +1635,7 @@ std::string Node::getVerbatimTag() const { setError(Twine("Unknown tag handle ") + TagHandle, T); } Ret += Raw.substr(Raw.find_last_of('!') + 1); - return llvm_move(Ret); + return std::move(Ret); } } diff --git a/lib/Transforms/Scalar/ConstantHoisting.cpp b/lib/Transforms/Scalar/ConstantHoisting.cpp index 6250620c0f1..661d19cdbe4 100644 --- a/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -229,7 +229,7 @@ void ConstantHoisting::FindAndMakeBaseConstant(ConstantMapType::iterator S, ConstantInfo::RebasedConstantInfo RCI; RCI.OriginalConstant = I->first; RCI.Offset = ConstantInt::get(Ty, Diff); - RCI.Uses = llvm_move(I->second.Uses); + RCI.Uses = std::move(I->second.Uses); CI.RebasedConstants.push_back(RCI); } Constants.push_back(CI); diff --git a/unittests/ADT/SmallPtrSetTest.cpp b/unittests/ADT/SmallPtrSetTest.cpp index 675f3373063..fdd1cbb6004 100644 --- a/unittests/ADT/SmallPtrSetTest.cpp +++ b/unittests/ADT/SmallPtrSetTest.cpp @@ -143,7 +143,7 @@ TEST(SmallPtrSetTest, CopyAndMoveTest) { s3.insert(&buf[5]); s3.insert(&buf[6]); s3.insert(&buf[7]); - s1 = llvm_move(s3); + s1 = std::move(s3); EXPECT_EQ(8U, s1.size()); EXPECT_TRUE(s3.empty()); for (int i = 0; i < 8; ++i) diff --git a/unittests/ADT/polymorphic_ptr_test.cpp b/unittests/ADT/polymorphic_ptr_test.cpp index 8198d1f32c0..12e57da7d49 100644 --- a/unittests/ADT/polymorphic_ptr_test.cpp +++ b/unittests/ADT/polymorphic_ptr_test.cpp @@ -57,7 +57,7 @@ TEST(polymorphic_ptr_test, Basic) { EXPECT_EQ(s, p.get()); EXPECT_EQ(42, p->x); - polymorphic_ptr p2((llvm_move(p))); + polymorphic_ptr p2((std::move(p))); EXPECT_FALSE((bool)p); EXPECT_TRUE(!p); EXPECT_TRUE((bool)p2); diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index d07bb5616b5..c4067b9137e 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -588,7 +588,7 @@ TEST_F(FileSystemTest, FileMapping) { EC); ASSERT_NO_ERROR(EC); const char *Data = m.const_data(); - fs::mapped_file_region mfrrv(llvm_move(m)); + fs::mapped_file_region mfrrv(std::move(m)); EXPECT_EQ(mfrrv.const_data(), Data); } } // anonymous namespace diff --git a/utils/yaml-bench/YAMLBench.cpp b/utils/yaml-bench/YAMLBench.cpp index f3356055276..f20a4ccc819 100644 --- a/utils/yaml-bench/YAMLBench.cpp +++ b/utils/yaml-bench/YAMLBench.cpp @@ -69,7 +69,7 @@ static std::string prettyTag(yaml::Node *N) { if (StringRef(Tag).startswith("tag:yaml.org,2002:")) { std::string Ret = "!!"; Ret += StringRef(Tag).substr(18); - return llvm_move(Ret); + return std::move(Ret); } std::string Ret = "!<"; Ret += Tag; -- 2.34.1