From 0816222e8faf21503030047d3fc0d63d05e1806a Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 10 Feb 2020 07:06:45 -0800 Subject: [PATCH] Revert "Remove redundant "std::move"s in return statements" The build failed with error: call to deleted constructor of 'llvm::Error' errors. This reverts commit 1c2241a7936bf85aa68aef94bd40c3ba77d8ddf2. --- include/llvm/Bitstream/BitstreamReader.h | 6 +-- include/llvm/DebugInfo/CodeView/CVRecord.h | 4 +- .../DebugInfo/CodeView/SymbolDeserializer.h | 2 +- .../DebugInfo/CodeView/TypeDeserializer.h | 2 +- include/llvm/DebugInfo/DWARF/DWARFListTable.h | 2 +- .../Orc/CompileOnDemandLayer.h | 10 ++-- .../ExecutionEngine/Orc/IndirectionUtils.h | 10 ++-- include/llvm/ExecutionEngine/Orc/LLJIT.h | 6 +-- .../ExecutionEngine/Orc/LazyEmittingLayer.h | 4 +- .../llvm/ExecutionEngine/Orc/LazyReexports.h | 4 +- include/llvm/ExecutionEngine/Orc/Legacy.h | 2 +- .../Orc/OrcRemoteTargetClient.h | 12 ++--- .../Orc/OrcRemoteTargetServer.h | 4 +- .../llvm/ExecutionEngine/Orc/RPC/RPCUtils.h | 6 +-- .../Orc/RTDyldObjectLinkingLayer.h | 4 +- include/llvm/Object/ELF.h | 2 +- include/llvm/Object/ELFObjectFile.h | 2 +- .../Coverage/CoverageMappingReader.h | 4 +- include/llvm/Support/Error.h | 2 +- include/llvm/Support/TaskQueue.h | 2 +- lib/Bitcode/Reader/BitcodeAnalyzer.cpp | 24 ++++----- lib/Bitcode/Reader/BitcodeReader.cpp | 54 +++++++++---------- lib/Bitcode/Reader/MetadataLoader.cpp | 14 ++--- lib/Bitstream/Reader/BitstreamReader.cpp | 14 ++--- .../CodeView/DebugStringTableSubsection.cpp | 2 +- lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 4 +- lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 2 +- lib/DebugInfo/DWARF/DWARFUnit.cpp | 4 +- lib/DebugInfo/DWARF/DWARFVerifier.cpp | 4 +- lib/DebugInfo/GSYM/FunctionInfo.cpp | 8 +-- lib/DebugInfo/GSYM/GsymReader.cpp | 4 +- lib/DebugInfo/GSYM/Header.cpp | 2 +- lib/DebugInfo/GSYM/LineTable.cpp | 4 +- lib/DebugInfo/MSF/MSFBuilder.cpp | 18 +++---- lib/DebugInfo/PDB/Native/DbiModuleList.cpp | 2 +- .../PDB/Native/ModuleDebugStream.cpp | 2 +- .../PDB/Native/NativeEnumInjectedSources.cpp | 2 +- lib/DebugInfo/PDB/Native/PDBFile.cpp | 20 +++---- lib/DebugInfo/PDB/Native/TpiHashing.cpp | 6 +-- .../Symbolize/SymbolizableObjectFile.cpp | 2 +- .../JITLink/EHFrameSupport.cpp | 12 ++--- .../JITLink/MachOLinkGraphBuilder.cpp | 10 ++-- .../Orc/CompileOnDemandLayer.cpp | 4 +- lib/ExecutionEngine/Orc/CompileUtils.cpp | 4 +- lib/ExecutionEngine/Orc/Core.cpp | 16 +++--- lib/ExecutionEngine/Orc/DebugUtils.cpp | 2 +- lib/ExecutionEngine/Orc/ExecutionUtils.cpp | 4 +- lib/ExecutionEngine/Orc/OrcCBindingsStack.h | 10 ++-- lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp | 4 +- .../RuntimeDyld/RuntimeDyld.cpp | 8 +-- .../RuntimeDyld/RuntimeDyldELF.cpp | 16 +++--- lib/IR/LLVMRemarkStreamer.cpp | 2 +- lib/LTO/LTO.cpp | 10 ++-- lib/LTO/LTOModule.cpp | 2 +- lib/MCA/InstrBuilder.cpp | 8 +-- lib/MCA/Pipeline.cpp | 2 +- lib/Object/Archive.cpp | 8 +-- lib/Object/ArchiveWriter.cpp | 8 +-- lib/Object/COFFModuleDefinition.cpp | 2 +- lib/Object/COFFObjectFile.cpp | 8 +-- lib/Object/Decompressor.cpp | 2 +- lib/Object/ELFObjectFile.cpp | 2 +- lib/Object/IRObjectFile.cpp | 2 +- lib/Object/IRSymtab.cpp | 6 +-- lib/Object/MachOObjectFile.cpp | 4 +- lib/Object/MachOUniversal.cpp | 4 +- lib/Object/ObjectFile.cpp | 2 +- lib/Object/SymbolicFile.cpp | 4 +- lib/Object/TapiUniversal.cpp | 4 +- lib/Object/WasmObjectFile.cpp | 4 +- lib/Object/WindowsResource.cpp | 6 +-- lib/Object/XCOFFObjectFile.cpp | 20 +++---- lib/ObjectYAML/CodeViewYAMLDebugSections.cpp | 10 ++-- lib/ObjectYAML/CodeViewYAMLSymbols.cpp | 2 +- lib/ObjectYAML/CodeViewYAMLTypes.cpp | 2 +- lib/ObjectYAML/DWARFEmitter.cpp | 2 +- lib/ProfileData/Coverage/CoverageMapping.cpp | 10 ++-- .../Coverage/CoverageMappingReader.cpp | 42 +++++++-------- lib/ProfileData/GCOV.cpp | 2 +- lib/ProfileData/InstrProf.cpp | 4 +- lib/ProfileData/InstrProfReader.cpp | 16 +++--- lib/ProfileData/SampleProfReader.cpp | 4 +- lib/ProfileData/SampleProfWriter.cpp | 2 +- lib/Remarks/BitstreamRemarkParser.cpp | 14 ++--- lib/Remarks/YAMLRemarkParser.cpp | 6 +-- lib/Support/APFloat.cpp | 2 +- lib/Support/FileCheck.cpp | 6 +-- lib/Support/JSON.cpp | 2 +- lib/Support/MemoryBuffer.cpp | 8 +-- lib/Support/Path.cpp | 2 +- lib/Support/YAMLTraits.cpp | 4 +- lib/TableGen/JSONBackend.cpp | 14 ++--- lib/TextAPI/ELF/TBEHandler.cpp | 2 +- lib/TextAPI/MachO/TextStub.cpp | 2 +- lib/Transforms/IPO/FunctionImport.cpp | 10 ++-- lib/XRay/FDRRecordProducer.cpp | 10 ++-- lib/XRay/FileHeaderReader.cpp | 2 +- lib/XRay/InstrumentationMap.cpp | 10 ++-- lib/XRay/Profile.cpp | 8 +-- lib/XRay/Trace.cpp | 8 +-- tools/bugpoint/ExecutionDriver.cpp | 8 +-- tools/bugpoint/ListReducer.h | 6 +-- tools/bugpoint/Miscompilation.cpp | 44 +++++++-------- tools/bugpoint/ToolRunner.cpp | 2 +- tools/dsymutil/BinaryHolder.cpp | 4 +- tools/dsymutil/DebugMap.cpp | 2 +- tools/dsymutil/MachODebugMapParser.cpp | 2 +- tools/dsymutil/dsymutil.cpp | 6 +-- tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 4 +- tools/llvm-cfi-verify/lib/FileAnalysis.cpp | 8 +-- tools/llvm-cov/SourceCoverageView.cpp | 2 +- tools/llvm-cov/SourceCoverageViewHTML.cpp | 2 +- tools/llvm-dwp/llvm-dwp.cpp | 2 +- tools/llvm-elfabi/ELFObjHandler.cpp | 4 +- tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 4 +- tools/llvm-exegesis/lib/Clustering.cpp | 2 +- .../lib/LatencyBenchmarkRunner.cpp | 2 +- .../lib/SerialSnippetGenerator.cpp | 2 +- tools/llvm-exegesis/lib/SnippetGenerator.cpp | 6 +-- .../llvm-exegesis/lib/UopsBenchmarkRunner.cpp | 2 +- tools/llvm-exegesis/lib/X86/Target.cpp | 4 +- tools/llvm-ifs/llvm-ifs.cpp | 2 +- tools/llvm-jitlink/llvm-jitlink.cpp | 4 +- tools/llvm-mca/llvm-mca.cpp | 2 +- tools/llvm-objcopy/COFF/Reader.cpp | 10 ++-- tools/llvm-objcopy/CopyConfig.cpp | 54 +++++++++---------- tools/llvm-objcopy/ELF/Object.cpp | 6 +-- tools/llvm-objcopy/wasm/Reader.cpp | 2 +- tools/llvm-pdbutil/DumpOutputStyle.cpp | 2 +- tools/llvm-pdbutil/InputFile.cpp | 10 ++-- tools/llvm-rc/ResourceScriptParser.cpp | 18 +++---- tools/llvm-rc/ResourceScriptToken.cpp | 2 +- tools/llvm-readobj/ELFDumper.cpp | 2 +- tools/obj2yaml/elf2yaml.cpp | 46 ++++++++-------- tools/obj2yaml/macho2yaml.cpp | 4 +- .../Orc/RemoteObjectLayerTest.cpp | 2 +- utils/TableGen/GlobalISelEmitter.cpp | 40 +++++++------- 137 files changed, 506 insertions(+), 506 deletions(-) diff --git a/include/llvm/Bitstream/BitstreamReader.h b/include/llvm/Bitstream/BitstreamReader.h index fa0855fa154..c476f60420f 100644 --- a/include/llvm/Bitstream/BitstreamReader.h +++ b/include/llvm/Bitstream/BitstreamReader.h @@ -209,7 +209,7 @@ public: unsigned BitsLeft = NumBits - BitsInCurWord; if (Error fillResult = fillCurWord()) - return fillResult; + return std::move(fillResult); // If we run out of data, abort. if (BitsLeft > BitsInCurWord) @@ -425,7 +425,7 @@ public: // We read and accumulate abbrev's, the client can't do anything with // them anyway. if (Error Err = ReadAbbrevRecord()) - return Err; + return std::move(Err); continue; } @@ -448,7 +448,7 @@ public: // If we found a sub-block, just skip over it and check the next entry. if (Error Err = SkipBlock()) - return Err; + return std::move(Err); } } diff --git a/include/llvm/DebugInfo/CodeView/CVRecord.h b/include/llvm/DebugInfo/CodeView/CVRecord.h index 5567214c5b7..784c47e3bf5 100644 --- a/include/llvm/DebugInfo/CodeView/CVRecord.h +++ b/include/llvm/DebugInfo/CodeView/CVRecord.h @@ -100,14 +100,14 @@ inline Expected> readCVRecordFromStream(BinaryStreamRef Stream, Reader.setOffset(Offset); if (auto EC = Reader.readObject(Prefix)) - return EC; + return std::move(EC); if (Prefix->RecordLen < 2) return make_error(cv_error_code::corrupt_record); Reader.setOffset(Offset); ArrayRef RawData; if (auto EC = Reader.readBytes(RawData, Prefix->RecordLen + sizeof(uint16_t))) - return EC; + return std::move(EC); return codeview::CVRecord(RawData); } diff --git a/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h b/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h index 80a092e69ff..108abb29149 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h +++ b/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h @@ -48,7 +48,7 @@ public: template static Expected deserializeAs(CVSymbol Symbol) { T Record(static_cast(Symbol.kind())); if (auto EC = deserializeAs(Symbol, Record)) - return EC; + return std::move(EC); return Record; } diff --git a/include/llvm/DebugInfo/CodeView/TypeDeserializer.h b/include/llvm/DebugInfo/CodeView/TypeDeserializer.h index 6aca4911f46..2b17f5ccb13 100644 --- a/include/llvm/DebugInfo/CodeView/TypeDeserializer.h +++ b/include/llvm/DebugInfo/CodeView/TypeDeserializer.h @@ -60,7 +60,7 @@ public: T Record(K); CVType CVT(Data); if (auto EC = deserializeAs(CVT, Record)) - return EC; + return std::move(EC); return Record; } diff --git a/include/llvm/DebugInfo/DWARF/DWARFListTable.h b/include/llvm/DebugInfo/DWARF/DWARFListTable.h index 8c568f455ea..496fdb2477f 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFListTable.h +++ b/include/llvm/DebugInfo/DWARF/DWARFListTable.h @@ -280,7 +280,7 @@ DWARFListTableBase::findList(DWARFDataExtractor Data, if (Error E = List.extract(Data, getHeaderOffset(), End, &Offset, Header.getSectionName(), Header.getListTypeString())) - return E; + return std::move(E); ListMap[StartingOffset] = List; return List; } diff --git a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h index ca1f3dd81ea..65295f97e2c 100644 --- a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h +++ b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h @@ -233,7 +233,7 @@ private: if (auto Sym = BaseLayer.findSymbolIn(BLK, Name, ExportedSymbolsOnly)) return Sym; else if (auto Err = Sym.takeError()) - return Err; + return std::move(Err); return nullptr; } @@ -342,7 +342,7 @@ public: findSymbolIn(KV.first, std::string(Name), ExportedSymbolsOnly)) return Sym; else if (auto Err = Sym.takeError()) - return Err; + return std::move(Err); } return BaseLayer.findSymbol(std::string(Name), ExportedSymbolsOnly); } @@ -518,7 +518,7 @@ private: if (auto Sym = LD.findSymbol(BaseLayer, std::string(Name), false)) return Sym; else if (auto Err = Sym.takeError()) - return Err; + return std::move(Err); return nullptr; }; @@ -611,7 +611,7 @@ private: } else return FnBodyAddrOrErr.takeError(); } else if (auto Err = FnBodySym.takeError()) - return Err; + return std::move(Err); else llvm_unreachable("Function not emitted for partition"); } @@ -729,7 +729,7 @@ private: SetSymbolResolver(K, std::move(Resolver)); if (auto Err = BaseLayer.addModule(std::move(K), std::move(M))) - return Err; + return std::move(Err); return K; } diff --git a/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h b/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h index eecb31a5c24..a9ab3a630a6 100644 --- a/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h +++ b/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h @@ -80,8 +80,8 @@ public: new LocalTrampolinePool(std::move(GetTrampolineLanding), Err)); if (Err) - return Err; - return LTP; + return std::move(Err); + return std::move(LTP); } /// Get a free trampoline. Returns an error if one can not be provided (e.g. @@ -90,7 +90,7 @@ public: std::lock_guard Lock(LTPMutex); if (AvailableTrampolines.empty()) { if (auto Err = grow()) - return Err; + return std::move(Err); } assert(!AvailableTrampolines.empty() && "Failed to grow trampoline pool"); auto TrampolineAddr = AvailableTrampolines.back(); @@ -229,8 +229,8 @@ public: auto CCMgr = std::unique_ptr( new LocalJITCompileCallbackManager(ES, ErrorHandlerAddress, Err)); if (Err) - return Err; - return CCMgr; + return std::move(Err); + return std::move(CCMgr); } private: diff --git a/include/llvm/ExecutionEngine/Orc/LLJIT.h b/include/llvm/ExecutionEngine/Orc/LLJIT.h index 93f122696a1..3374a29f04d 100644 --- a/include/llvm/ExecutionEngine/Orc/LLJIT.h +++ b/include/llvm/ExecutionEngine/Orc/LLJIT.h @@ -262,13 +262,13 @@ public: /// Create an instance of the JIT. Expected> create() { if (auto Err = impl().prepareForConstruction()) - return Err; + return std::move(Err); Error Err = Error::success(); std::unique_ptr J(new JITType(impl(), Err)); if (Err) - return Err; - return J; + return std::move(Err); + return std::move(J); } protected: diff --git a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h index 326c5982a12..84f5e0350c2 100644 --- a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h @@ -57,13 +57,13 @@ private: else if (this->EmitState == NotEmitted) { this->EmitState = Emitting; if (auto Err = this->emitToBaseLayer(B)) - return Err; + return std::move(Err); this->EmitState = Emitted; } if (auto Sym = B.findSymbolIn(K, Name, ExportedSymbolsOnly)) return Sym.getAddress(); else if (auto Err = Sym.takeError()) - return Err; + return std::move(Err); else llvm_unreachable("Successful symbol lookup should return " "definition address here"); diff --git a/include/llvm/ExecutionEngine/Orc/LazyReexports.h b/include/llvm/ExecutionEngine/Orc/LazyReexports.h index 38eb06360e6..fd34556ff95 100644 --- a/include/llvm/ExecutionEngine/Orc/LazyReexports.h +++ b/include/llvm/ExecutionEngine/Orc/LazyReexports.h @@ -101,9 +101,9 @@ public: new LocalLazyCallThroughManager(ES, ErrorHandlerAddr)); if (auto Err = LLCTM->init()) - return Err; + return std::move(Err); - return LLCTM; + return std::move(LLCTM); } }; diff --git a/include/llvm/ExecutionEngine/Orc/Legacy.h b/include/llvm/ExecutionEngine/Orc/Legacy.h index 29d257ff1bd..148e260c956 100644 --- a/include/llvm/ExecutionEngine/Orc/Legacy.h +++ b/include/llvm/ExecutionEngine/Orc/Legacy.h @@ -123,7 +123,7 @@ getResponsibilitySetWithLegacyFn(const SymbolNameSet &Symbols, if (!Sym.getFlags().isStrong()) Result.insert(S); } else if (auto Err = Sym.takeError()) - return Err; + return std::move(Err); } return Result; diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h index 1c5394677e8..86e8d5df3ad 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h +++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h @@ -457,7 +457,7 @@ public: std::lock_guard Lock(RTPMutex); if (AvailableTrampolines.empty()) { if (auto Err = grow()) - return Err; + return std::move(Err); } assert(!AvailableTrampolines.empty() && "Failed to grow trampoline pool"); auto TrampolineAddr = AvailableTrampolines.back(); @@ -506,8 +506,8 @@ public: auto Client = std::unique_ptr( new OrcRemoteTargetClient(Channel, ES, Err)); if (Err) - return Err; - return Client; + return std::move(Err); + return std::move(Client); } /// Call the int(void) function at the given address in the target and return @@ -541,7 +541,7 @@ public: createRemoteMemoryManager() { auto Id = AllocatorIds.getNext(); if (auto Err = callB(Id)) - return Err; + return std::move(Err); return std::unique_ptr( new RemoteRTDyldMemoryManager(*this, Id)); } @@ -552,7 +552,7 @@ public: createIndirectStubsManager() { auto Id = IndirectStubOwnerIds.getNext(); if (auto Err = callB(Id)) - return Err; + return std::move(Err); return std::make_unique(*this, Id); } @@ -562,7 +562,7 @@ public: // Emit the resolver block on the JIT server. if (auto Err = callB()) - return Err; + return std::move(Err); // Create the callback manager. CallbackManager.emplace(*this, ES, ErrorHandlerAddress); diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h index 7faf08054ae..4c8e2ea1a7b 100644 --- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h +++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h @@ -265,7 +265,7 @@ private: typename TargetT::IndirectStubsInfo IS; if (auto Err = TargetT::emitIndirectStubsBlock(IS, NumStubsRequired, nullptr)) - return Err; + return std::move(Err); JITTargetAddress StubsBase = static_cast( reinterpret_cast(IS.getStub(0))); @@ -382,7 +382,7 @@ private: auto &Allocator = I->second; void *LocalAllocAddr = nullptr; if (auto Err = Allocator.allocate(LocalAllocAddr, Size, Align)) - return Err; + return std::move(Err); LLVM_DEBUG(dbgs() << " Allocator " << Id << " reserved " << LocalAllocAddr << " (" << Size << " bytes, alignment " << Align diff --git a/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h b/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h index 6cf5612af8d..ed09363dcec 100644 --- a/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h +++ b/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h @@ -1528,20 +1528,20 @@ public: Args...)) { detail::ResultTraits::consumeAbandoned( std::move(Result)); - return Err; + return std::move(Err); } if (auto Err = this->C.send()) { detail::ResultTraits::consumeAbandoned( std::move(Result)); - return Err; + return std::move(Err); } while (!ReceivedResponse) { if (auto Err = this->handleOne()) { detail::ResultTraits::consumeAbandoned( std::move(Result)); - return Err; + return std::move(Err); } } diff --git a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h index 74342931dd9..435c882d506 100644 --- a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h @@ -276,7 +276,7 @@ private: // and its execution, so we need to double check. if (!this->Finalized) if (auto Err = this->finalize()) - return Err; + return std::move(Err); return this->getSymbol(Name, false).getAddress(); }; } @@ -430,7 +430,7 @@ public: if (auto Sym = KV.second->getSymbol(Name, ExportedSymbolsOnly)) return Sym; else if (auto Err = Sym.takeError()) - return Err; + return std::move(Err); return nullptr; } diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 28dd77ebd7f..42c5b67ac3f 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -601,7 +601,7 @@ ELFFile::getStringTable(const Elf_Shdr *Section, ": expected SHT_STRTAB, but got " + object::getELFSectionTypeName( getHeader()->e_machine, Section->sh_type))) - return E; + return std::move(E); auto V = getSectionContentsAsArray(Section); if (!V) diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index ca99dcf6188..8a68e49477f 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -948,7 +948,7 @@ Expected> ELFObjectFile::create(MemoryBufferRef Object) { auto EFOrErr = ELFFile::create(Object.getBuffer()); if (Error E = EFOrErr.takeError()) - return E; + return std::move(E); auto EF = std::move(*EFOrErr); auto SectionsOrErr = EF.sections(); diff --git a/include/llvm/ProfileData/Coverage/CoverageMappingReader.h b/include/llvm/ProfileData/Coverage/CoverageMappingReader.h index b7584ea1570..57a2aaefd66 100644 --- a/include/llvm/ProfileData/Coverage/CoverageMappingReader.h +++ b/include/llvm/ProfileData/Coverage/CoverageMappingReader.h @@ -77,7 +77,7 @@ public: if (ReadErr != coveragemap_error::success) { auto E = make_error(ReadErr); ReadErr = coveragemap_error::success; - return E; + return std::move(E); } return Record; } @@ -85,7 +85,7 @@ public: if (ReadErr != coveragemap_error::success) { auto E = make_error(ReadErr); ReadErr = coveragemap_error::success; - return E; + return std::move(E); } return &Record; } diff --git a/include/llvm/Support/Error.h b/include/llvm/Support/Error.h index 61bf9efa90f..44676338808 100644 --- a/include/llvm/Support/Error.h +++ b/include/llvm/Support/Error.h @@ -963,7 +963,7 @@ Expected handleExpected(Expected ValOrErr, RecoveryFtor &&RecoveryPath, if (auto Err = handleErrors(ValOrErr.takeError(), std::forward(Handlers)...)) - return Err; + return std::move(Err); return RecoveryPath(); } diff --git a/include/llvm/Support/TaskQueue.h b/include/llvm/Support/TaskQueue.h index 740400aa44f..df2ffdee2cc 100644 --- a/include/llvm/Support/TaskQueue.h +++ b/include/llvm/Support/TaskQueue.h @@ -98,7 +98,7 @@ public: IsTaskInFlight = true; } } - return F; + return std::move(F); } private: diff --git a/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/lib/Bitcode/Reader/BitcodeAnalyzer.cpp index 0bf62f2c64a..e70caa83c8c 100644 --- a/lib/Bitcode/Reader/BitcodeAnalyzer.cpp +++ b/lib/Bitcode/Reader/BitcodeAnalyzer.cpp @@ -415,41 +415,41 @@ static Expected ReadSignature(BitstreamCursor &Stream) { char Signature[6]; if (Error Err = tryRead(Signature[0], 8)) - return Err; + return std::move(Err); if (Error Err = tryRead(Signature[1], 8)) - return Err; + return std::move(Err); // Autodetect the file contents, if it is one we know. if (Signature[0] == 'C' && Signature[1] == 'P') { if (Error Err = tryRead(Signature[2], 8)) - return Err; + return std::move(Err); if (Error Err = tryRead(Signature[3], 8)) - return Err; + return std::move(Err); if (Signature[2] == 'C' && Signature[3] == 'H') return ClangSerializedASTBitstream; } else if (Signature[0] == 'D' && Signature[1] == 'I') { if (Error Err = tryRead(Signature[2], 8)) - return Err; + return std::move(Err); if (Error Err = tryRead(Signature[3], 8)) - return Err; + return std::move(Err); if (Signature[2] == 'A' && Signature[3] == 'G') return ClangSerializedDiagnosticsBitstream; } else if (Signature[0] == 'R' && Signature[1] == 'M') { if (Error Err = tryRead(Signature[2], 8)) - return Err; + return std::move(Err); if (Error Err = tryRead(Signature[3], 8)) - return Err; + return std::move(Err); if (Signature[2] == 'R' && Signature[3] == 'K') return LLVMBitstreamRemarks; } else { if (Error Err = tryRead(Signature[2], 4)) - return Err; + return std::move(Err); if (Error Err = tryRead(Signature[3], 4)) - return Err; + return std::move(Err); if (Error Err = tryRead(Signature[4], 4)) - return Err; + return std::move(Err); if (Error Err = tryRead(Signature[5], 4)) - return Err; + return std::move(Err); if (Signature[0] == 'B' && Signature[1] == 'C' && Signature[2] == 0x0 && Signature[3] == 0xC && Signature[4] == 0xE && Signature[5] == 0xD) return LLVMIRBitstream; diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 83e72f7a80c..b5476065c36 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -141,9 +141,9 @@ static Expected initStream(MemoryBufferRef Buffer) { BitstreamCursor Stream(ArrayRef(BufPtr, BufEnd)); if (Error Err = hasInvalidBitcodeHeader(Stream)) - return Err; + return std::move(Err); - return Stream; + return std::move(Stream); } /// Convert a string from a record into an std::string, return true on failure. @@ -172,7 +172,7 @@ static void stripTBAA(Module *M) { /// "epoch" encoded in the bitcode, and return the producer name if any. static Expected readIdentificationBlock(BitstreamCursor &Stream) { if (Error Err = Stream.EnterSubBlock(bitc::IDENTIFICATION_BLOCK_ID)) - return Err; + return std::move(Err); // Read all the records. SmallVector Record; @@ -244,7 +244,7 @@ static Expected readIdentificationCode(BitstreamCursor &Stream) { // Ignore other sub-blocks. if (Error Err = Stream.SkipBlock()) - return Err; + return std::move(Err); continue; case BitstreamEntry::Record: if (Expected Skipped = Stream.skipRecord(Entry.ID)) @@ -257,7 +257,7 @@ static Expected readIdentificationCode(BitstreamCursor &Stream) { static Expected hasObjCCategoryInModule(BitstreamCursor &Stream) { if (Error Err = Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID)) - return Err; + return std::move(Err); SmallVector Record; // Read all the records for this module. @@ -324,7 +324,7 @@ static Expected hasObjCCategory(BitstreamCursor &Stream) { // Ignore other sub-blocks. if (Error Err = Stream.SkipBlock()) - return Err; + return std::move(Err); continue; case BitstreamEntry::Record: @@ -338,7 +338,7 @@ static Expected hasObjCCategory(BitstreamCursor &Stream) { static Expected readModuleTriple(BitstreamCursor &Stream) { if (Error Err = Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID)) - return Err; + return std::move(Err); SmallVector Record; @@ -402,7 +402,7 @@ static Expected readTriple(BitstreamCursor &Stream) { // Ignore other sub-blocks. if (Error Err = Stream.SkipBlock()) - return Err; + return std::move(Err); continue; case BitstreamEntry::Record: @@ -2044,7 +2044,7 @@ static Expected jumpToValueSymbolTable(uint64_t Offset, // of the VST read. uint64_t CurrentBit = Stream.GetCurrentBitNo(); if (Error JumpFailed = Stream.JumpToBit(Offset * 32)) - return JumpFailed; + return std::move(JumpFailed); Expected MaybeEntry = Stream.advance(); if (!MaybeEntry) return MaybeEntry.takeError(); @@ -6293,7 +6293,7 @@ const std::error_category &llvm::BitcodeErrorCategory() { static Expected readBlobInRecord(BitstreamCursor &Stream, unsigned Block, unsigned RecordID) { if (Error Err = Stream.EnterSubBlock(Block)) - return Err; + return std::move(Err); StringRef Strtab; while (true) { @@ -6311,7 +6311,7 @@ static Expected readBlobInRecord(BitstreamCursor &Stream, case BitstreamEntry::SubBlock: if (Error Err = Stream.SkipBlock()) - return Err; + return std::move(Err); break; case BitstreamEntry::Record: @@ -6372,7 +6372,7 @@ llvm::getBitcodeFileContents(MemoryBufferRef Buffer) { if (Entry.ID == bitc::IDENTIFICATION_BLOCK_ID) { IdentificationBit = Stream.GetCurrentBitNo() - BCBegin * 8; if (Error Err = Stream.SkipBlock()) - return Err; + return std::move(Err); { Expected MaybeEntry = Stream.advance(); @@ -6389,7 +6389,7 @@ llvm::getBitcodeFileContents(MemoryBufferRef Buffer) { if (Entry.ID == bitc::MODULE_BLOCK_ID) { uint64_t ModuleBit = Stream.GetCurrentBitNo() - BCBegin * 8; if (Error Err = Stream.SkipBlock()) - return Err; + return std::move(Err); F.Mods.push_back({Stream.getBitcodeBytes().slice( BCBegin, Stream.getCurrentByteNo() - BCBegin), @@ -6438,7 +6438,7 @@ llvm::getBitcodeFileContents(MemoryBufferRef Buffer) { } if (Error Err = Stream.SkipBlock()) - return Err; + return std::move(Err); continue; } case BitstreamEntry::Record: @@ -6466,7 +6466,7 @@ BitcodeModule::getModuleImpl(LLVMContext &Context, bool MaterializeAll, std::string ProducerIdentification; if (IdentificationBit != -1ull) { if (Error JumpFailed = Stream.JumpToBit(IdentificationBit)) - return JumpFailed; + return std::move(JumpFailed); Expected ProducerIdentificationOrErr = readIdentificationBlock(Stream); if (!ProducerIdentificationOrErr) @@ -6476,7 +6476,7 @@ BitcodeModule::getModuleImpl(LLVMContext &Context, bool MaterializeAll, } if (Error JumpFailed = Stream.JumpToBit(ModuleBit)) - return JumpFailed; + return std::move(JumpFailed); auto *R = new BitcodeReader(std::move(Stream), Strtab, ProducerIdentification, Context); @@ -6487,18 +6487,18 @@ BitcodeModule::getModuleImpl(LLVMContext &Context, bool MaterializeAll, // Delay parsing Metadata if ShouldLazyLoadMetadata is true. if (Error Err = R->parseBitcodeInto(M.get(), ShouldLazyLoadMetadata, IsImporting)) - return Err; + return std::move(Err); if (MaterializeAll) { // Read in the entire module, and destroy the BitcodeReader. if (Error Err = M->materializeAll()) - return Err; + return std::move(Err); } else { // Resolve forward references from blockaddresses. if (Error Err = R->materializeForwardReferencedFunctions()) - return Err; + return std::move(Err); } - return M; + return std::move(M); } Expected> @@ -6526,22 +6526,22 @@ Error BitcodeModule::readSummary(ModuleSummaryIndex &CombinedIndex, Expected> BitcodeModule::getSummary() { BitstreamCursor Stream(Buffer); if (Error JumpFailed = Stream.JumpToBit(ModuleBit)) - return JumpFailed; + return std::move(JumpFailed); auto Index = std::make_unique(/*HaveGVs=*/false); ModuleSummaryIndexBitcodeReader R(std::move(Stream), Strtab, *Index, ModuleIdentifier, 0); if (Error Err = R.parseModule()) - return Err; + return std::move(Err); - return Index; + return std::move(Index); } static Expected getEnableSplitLTOUnitFlag(BitstreamCursor &Stream, unsigned ID) { if (Error Err = Stream.EnterSubBlock(ID)) - return Err; + return std::move(Err); SmallVector Record; while (true) { @@ -6587,10 +6587,10 @@ static Expected getEnableSplitLTOUnitFlag(BitstreamCursor &Stream, Expected BitcodeModule::getLTOInfo() { BitstreamCursor Stream(Buffer); if (Error JumpFailed = Stream.JumpToBit(ModuleBit)) - return JumpFailed; + return std::move(JumpFailed); if (Error Err = Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID)) - return Err; + return std::move(Err); while (true) { Expected MaybeEntry = Stream.advance(); @@ -6626,7 +6626,7 @@ Expected BitcodeModule::getLTOInfo() { // Ignore other sub-blocks. if (Error Err = Stream.SkipBlock()) - return Err; + return std::move(Err); continue; case BitstreamEntry::Record: diff --git a/lib/Bitcode/Reader/MetadataLoader.cpp b/lib/Bitcode/Reader/MetadataLoader.cpp index 06b8415dc9d..3cff468dca8 100644 --- a/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/lib/Bitcode/Reader/MetadataLoader.cpp @@ -711,7 +711,7 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() { case bitc::METADATA_STRINGS: { // Rewind and parse the strings. if (Error Err = IndexCursor.JumpToBit(CurrentPos)) - return Err; + return std::move(Err); StringRef Blob; Record.clear(); if (Expected MaybeRecord = @@ -725,14 +725,14 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() { MDStringRef.push_back(Str); }; if (auto Err = parseMetadataStrings(Record, Blob, IndexNextMDString)) - return Err; + return std::move(Err); break; } case bitc::METADATA_INDEX_OFFSET: { // This is the offset to the index, when we see this we skip all the // records and load only an index to these. if (Error Err = IndexCursor.JumpToBit(CurrentPos)) - return Err; + return std::move(Err); Record.clear(); if (Expected MaybeRecord = IndexCursor.readRecord(Entry.ID, Record)) @@ -744,7 +744,7 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() { auto Offset = Record[0] + (Record[1] << 32); auto BeginPos = IndexCursor.GetCurrentBitNo(); if (Error Err = IndexCursor.JumpToBit(BeginPos + Offset)) - return Err; + return std::move(Err); Expected MaybeEntry = IndexCursor.advanceSkippingSubblocks( BitstreamCursor::AF_DontPopBlockAtEnd); @@ -778,7 +778,7 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() { case bitc::METADATA_NAME: { // Named metadata need to be materialized now and aren't deferred. if (Error Err = IndexCursor.JumpToBit(CurrentPos)) - return Err; + return std::move(Err); Record.clear(); unsigned Code; @@ -823,7 +823,7 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() { // FIXME: we need to do this early because we don't materialize global // value explicitly. if (Error Err = IndexCursor.JumpToBit(CurrentPos)) - return Err; + return std::move(Err); Record.clear(); if (Expected MaybeRecord = IndexCursor.readRecord(Entry.ID, Record)) @@ -838,7 +838,7 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() { if (auto *GO = dyn_cast(ValueList[ValueID])) if (Error Err = parseGlobalObjectAttachment( *GO, ArrayRef(Record).slice(1))) - return Err; + return std::move(Err); break; } case bitc::METADATA_KIND: diff --git a/lib/Bitstream/Reader/BitstreamReader.cpp b/lib/Bitstream/Reader/BitstreamReader.cpp index c6aeaefdcd3..92d7c91a1d3 100644 --- a/lib/Bitstream/Reader/BitstreamReader.cpp +++ b/lib/Bitstream/Reader/BitstreamReader.cpp @@ -158,7 +158,7 @@ Expected BitstreamCursor::skipRecord(unsigned AbbrevID) { assert((unsigned)EltEnc.getEncodingData() <= MaxChunkSize); if (Error Err = JumpToBit(GetCurrentBitNo() + NumElts * EltEnc.getEncodingData())) - return Err; + return std::move(Err); break; case BitCodeAbbrevOp::VBR: assert((unsigned)EltEnc.getEncodingData() <= MaxChunkSize); @@ -171,7 +171,7 @@ Expected BitstreamCursor::skipRecord(unsigned AbbrevID) { break; case BitCodeAbbrevOp::Char6: if (Error Err = JumpToBit(GetCurrentBitNo() + NumElts * 6)) - return Err; + return std::move(Err); break; } continue; @@ -197,7 +197,7 @@ Expected BitstreamCursor::skipRecord(unsigned AbbrevID) { // Skip over the blob. if (Error Err = JumpToBit(NewEnd)) - return Err; + return std::move(Err); } return Code; } @@ -326,7 +326,7 @@ Expected BitstreamCursor::readRecord(unsigned AbbrevID, // over tail padding first, in case jumping to NewEnd invalidates the Blob // pointer. if (Error Err = JumpToBit(NewEnd)) - return Err; + return std::move(Err); const char *Ptr = (const char *)getPointerToBit(CurBitPos, NumElts); // If we can return a reference to the data, do so to avoid copying it. @@ -401,7 +401,7 @@ Error BitstreamCursor::ReadAbbrevRecord() { Expected> BitstreamCursor::ReadBlockInfoBlock(bool ReadBlockInfoNames) { if (llvm::Error Err = EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) - return Err; + return std::move(Err); BitstreamBlockInfo NewBlockInfo; @@ -421,7 +421,7 @@ BitstreamCursor::ReadBlockInfoBlock(bool ReadBlockInfoNames) { case llvm::BitstreamEntry::Error: return None; case llvm::BitstreamEntry::EndBlock: - return NewBlockInfo; + return std::move(NewBlockInfo); case llvm::BitstreamEntry::Record: // The interesting case. break; @@ -431,7 +431,7 @@ BitstreamCursor::ReadBlockInfoBlock(bool ReadBlockInfoNames) { if (Entry.ID == bitc::DEFINE_ABBREV) { if (!CurBlockInfo) return None; if (Error Err = ReadAbbrevRecord()) - return Err; + return std::move(Err); // ReadAbbrevRecord installs the abbrev in CurAbbrevs. Move it to the // appropriate BlockInfo. diff --git a/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp b/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp index 4ad0bb566bc..63342749918 100644 --- a/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp +++ b/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp @@ -37,7 +37,7 @@ DebugStringTableSubsectionRef::getString(uint32_t Offset) const { Reader.setOffset(Offset); StringRef Result; if (auto EC = Reader.readCString(Result)) - return EC; + return std::move(EC); return Result; } diff --git a/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp index df19b364f32..bfcd0960fae 100644 --- a/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ b/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -481,7 +481,7 @@ DWARFDebugNames::NameIndex::extractAttributeEncodings(uint64_t *Offset) { if (!AttrEncOr) return AttrEncOr.takeError(); if (isSentinel(*AttrEncOr)) - return Result; + return std::move(Result); Result.emplace_back(*AttrEncOr); } @@ -649,7 +649,7 @@ DWARFDebugNames::NameIndex::getEntry(uint64_t *Offset) const { return createStringError(errc::io_error, "Error extracting index attribute values."); } - return E; + return std::move(E); } DWARFDebugNames::NameTableEntry diff --git a/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index bed6686680f..4d1cf71ef9a 100644 --- a/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -522,7 +522,7 @@ Expected DWARFDebugLine::getOrParseLineTable( if (Pos.second) { if (Error Err = LT->parse(DebugLineData, &Offset, Ctx, U, RecoverableErrorCallback)) - return Err; + return std::move(Err); return LT; } return LT; diff --git a/lib/DebugInfo/DWARF/DWARFUnit.cpp b/lib/DebugInfo/DWARF/DWARFUnit.cpp index bde45cbcf10..7bb01946616 100644 --- a/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -349,7 +349,7 @@ parseListTableHeader(DWARFDataExtractor &DA, uint64_t Offset, } ListTableType Table; if (Error E = Table.extractHeaderAndOffsets(DA, &Offset)) - return E; + return std::move(E); return Table; } @@ -621,7 +621,7 @@ DWARFUnit::findRnglistFromOffset(uint64_t Offset) { if (getVersion() <= 4) { DWARFDebugRangeList RangeList; if (Error E = extractRangeList(Offset, RangeList)) - return E; + return std::move(E); return RangeList.getAbsoluteRanges(getBaseAddress()); } if (RngListTable) { diff --git a/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/lib/DebugInfo/DWARF/DWARFVerifier.cpp index eaebc3d62a4..68bacbfda46 100644 --- a/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -34,11 +34,11 @@ DWARFVerifier::DieRangeInfo::insert(const DWARFAddressRange &R) { if (Pos != End) { if (Pos->intersects(R)) - return Pos; + return std::move(Pos); if (Pos != Begin) { auto Iter = Pos - 1; if (Iter->intersects(R)) - return Iter; + return std::move(Iter); } } diff --git a/lib/DebugInfo/GSYM/FunctionInfo.cpp b/lib/DebugInfo/GSYM/FunctionInfo.cpp index 373161d3bd0..6731a8b2744 100644 --- a/lib/DebugInfo/GSYM/FunctionInfo.cpp +++ b/lib/DebugInfo/GSYM/FunctionInfo.cpp @@ -90,7 +90,7 @@ llvm::Expected FunctionInfo::decode(DataExtractor &Data, } Offset += InfoLength; } - return FI; + return std::move(FI); } llvm::Expected FunctionInfo::encode(FileWriter &O) const { @@ -114,7 +114,7 @@ llvm::Expected FunctionInfo::encode(FileWriter &O) const { const auto StartOffset = O.tell(); llvm::Error err = OptLineTable->encode(O, Range.Start); if (err) - return err; + return std::move(err); const auto Length = O.tell() - StartOffset; if (Length > UINT32_MAX) return createStringError(std::errc::invalid_argument, @@ -132,7 +132,7 @@ llvm::Expected FunctionInfo::encode(FileWriter &O) const { const auto StartOffset = O.tell(); llvm::Error err = Inline->encode(O, Range.Start); if (err) - return err; + return std::move(err); const auto Length = O.tell() - StartOffset; if (Length > UINT32_MAX) return createStringError(std::errc::invalid_argument, @@ -244,6 +244,6 @@ llvm::Expected FunctionInfo::lookup(DataExtractor &Data, llvm::Error Err = InlineInfo::lookup(GR, *InlineInfoData, FuncAddr, Addr, LR.Locations); if (Err) - return Err; + return std::move(Err); return LR; } diff --git a/lib/DebugInfo/GSYM/GsymReader.cpp b/lib/DebugInfo/GSYM/GsymReader.cpp index c05d6bce4f6..b4f3f2052ae 100644 --- a/lib/DebugInfo/GSYM/GsymReader.cpp +++ b/lib/DebugInfo/GSYM/GsymReader.cpp @@ -54,8 +54,8 @@ GsymReader::create(std::unique_ptr &MemBuffer) { GsymReader GR(std::move(MemBuffer)); llvm::Error Err = GR.parse(); if (Err) - return Err; - return GR; + return std::move(Err); + return std::move(GR); } llvm::Error diff --git a/lib/DebugInfo/GSYM/Header.cpp b/lib/DebugInfo/GSYM/Header.cpp index 85d8fbe9cf6..0b3fb9c4989 100644 --- a/lib/DebugInfo/GSYM/Header.cpp +++ b/lib/DebugInfo/GSYM/Header.cpp @@ -78,7 +78,7 @@ llvm::Expected
Header::decode(DataExtractor &Data) { H.StrtabSize = Data.getU32(&Offset); Data.getU8(&Offset, H.UUID, GSYM_MAX_UUID_SIZE); if (llvm::Error Err = H.checkForError()) - return Err; + return std::move(Err); return H; } diff --git a/lib/DebugInfo/GSYM/LineTable.cpp b/lib/DebugInfo/GSYM/LineTable.cpp index 4e1d75b26b8..a49a3ba9bf2 100644 --- a/lib/DebugInfo/GSYM/LineTable.cpp +++ b/lib/DebugInfo/GSYM/LineTable.cpp @@ -256,7 +256,7 @@ llvm::Expected LineTable::decode(DataExtractor &Data, return true; // Keep parsing by returning true. }); if (Err) - return Err; + return std::move(Err); return LT; } // Parse the line table on the fly and find the row we are looking for. @@ -278,7 +278,7 @@ Expected LineTable::lookup(DataExtractor &Data, uint64_t BaseAddr, ui return true; // Keep parsing till we find the right row. }); if (Err) - return Err; + return std::move(Err); if (Result.isValid()) return Result; return createStringError(std::errc::invalid_argument, diff --git a/lib/DebugInfo/MSF/MSFBuilder.cpp b/lib/DebugInfo/MSF/MSFBuilder.cpp index d27cecc78c0..c6fe764ab7e 100644 --- a/lib/DebugInfo/MSF/MSFBuilder.cpp +++ b/lib/DebugInfo/MSF/MSFBuilder.cpp @@ -183,7 +183,7 @@ Expected MSFBuilder::addStream(uint32_t Size) { std::vector NewBlocks; NewBlocks.resize(ReqBlocks); if (auto EC = allocateBlocks(ReqBlocks, NewBlocks)) - return EC; + return std::move(EC); StreamData.push_back(std::make_pair(Size, NewBlocks)); return StreamData.size() - 1; } @@ -267,7 +267,7 @@ Expected MSFBuilder::generateLayout() { uint32_t NumExtraBlocks = NumDirectoryBlocks - DirectoryBlocks.size(); ExtraBlocks.resize(NumExtraBlocks); if (auto EC = allocateBlocks(NumExtraBlocks, ExtraBlocks)) - return EC; + return std::move(EC); DirectoryBlocks.insert(DirectoryBlocks.end(), ExtraBlocks.begin(), ExtraBlocks.end()); } else if (NumDirectoryBlocks < DirectoryBlocks.size()) { @@ -346,14 +346,14 @@ Expected MSFBuilder::commit(StringRef Path, uint64_t FileSize = Layout.SB->BlockSize * Layout.SB->NumBlocks; auto OutFileOrError = FileOutputBuffer::create(Path, FileSize); if (auto EC = OutFileOrError.takeError()) - return EC; + return std::move(EC); FileBufferByteStream Buffer(std::move(*OutFileOrError), llvm::support::little); BinaryStreamWriter Writer(Buffer); if (auto EC = Writer.writeObject(*Layout.SB)) - return EC; + return std::move(EC); commitFpm(Buffer, Layout, Allocator); @@ -361,21 +361,21 @@ Expected MSFBuilder::commit(StringRef Path, msf::blockToOffset(Layout.SB->BlockMapAddr, Layout.SB->BlockSize); Writer.setOffset(BlockMapOffset); if (auto EC = Writer.writeArray(Layout.DirectoryBlocks)) - return EC; + return std::move(EC); auto DirStream = WritableMappedBlockStream::createDirectoryStream( Layout, Buffer, Allocator); BinaryStreamWriter DW(*DirStream); if (auto EC = DW.writeInteger(Layout.StreamSizes.size())) - return EC; + return std::move(EC); if (auto EC = DW.writeArray(Layout.StreamSizes)) - return EC; + return std::move(EC); for (const auto &Blocks : Layout.StreamMap) { if (auto EC = DW.writeArray(Blocks)) - return EC; + return std::move(EC); } - return Buffer; + return std::move(Buffer); } diff --git a/lib/DebugInfo/PDB/Native/DbiModuleList.cpp b/lib/DebugInfo/PDB/Native/DbiModuleList.cpp index 991616f0316..5cf014e881c 100644 --- a/lib/DebugInfo/PDB/Native/DbiModuleList.cpp +++ b/lib/DebugInfo/PDB/Native/DbiModuleList.cpp @@ -274,6 +274,6 @@ Expected DbiModuleList::getFileName(uint32_t Index) const { Names.setOffset(FileOffset); StringRef Name; if (auto EC = Names.readCString(Name)) - return EC; + return std::move(EC); return Name; } diff --git a/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp b/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp index 0c990c82607..1445f0bd9e1 100644 --- a/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp +++ b/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp @@ -137,7 +137,7 @@ ModuleDebugStreamRef::findChecksumsSubsection() const { continue; if (auto EC = Result.initialize(SS.getRecordData())) - return EC; + return std::move(EC); return Result; } return Result; diff --git a/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp b/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp index ffaa79d1a27..7a258acbd7c 100644 --- a/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp +++ b/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp @@ -24,7 +24,7 @@ Expected readStreamData(BinaryStream &Stream, uint32_t Limit) { while (Offset < DataLength) { ArrayRef Data; if (auto E = Stream.readLongestContiguousChunk(Offset, Data)) - return E; + return std::move(E); Data = Data.take_front(DataLength - Offset); Offset += Data.size(); Result += toStringRef(Data); diff --git a/lib/DebugInfo/PDB/Native/PDBFile.cpp b/lib/DebugInfo/PDB/Native/PDBFile.cpp index e5c293c8b3e..cde64523685 100644 --- a/lib/DebugInfo/PDB/Native/PDBFile.cpp +++ b/lib/DebugInfo/PDB/Native/PDBFile.cpp @@ -108,7 +108,7 @@ Expected> PDBFile::getBlockData(uint32_t BlockIndex, ArrayRef Result; if (auto EC = Buffer->readBytes(StreamBlockOffset, NumBytes, Result)) - return EC; + return std::move(EC); return Result; } @@ -267,7 +267,7 @@ Expected PDBFile::getPDBGlobalsStream() { return GlobalS.takeError(); auto TempGlobals = std::make_unique(std::move(*GlobalS)); if (auto EC = TempGlobals->reload()) - return EC; + return std::move(EC); Globals = std::move(TempGlobals); } return *Globals; @@ -280,7 +280,7 @@ Expected PDBFile::getPDBInfoStream() { return InfoS.takeError(); auto TempInfo = std::make_unique(std::move(*InfoS)); if (auto EC = TempInfo->reload()) - return EC; + return std::move(EC); Info = std::move(TempInfo); } return *Info; @@ -293,7 +293,7 @@ Expected PDBFile::getPDBDbiStream() { return DbiS.takeError(); auto TempDbi = std::make_unique(std::move(*DbiS)); if (auto EC = TempDbi->reload(this)) - return EC; + return std::move(EC); Dbi = std::move(TempDbi); } return *Dbi; @@ -306,7 +306,7 @@ Expected PDBFile::getPDBTpiStream() { return TpiS.takeError(); auto TempTpi = std::make_unique(*this, std::move(*TpiS)); if (auto EC = TempTpi->reload()) - return EC; + return std::move(EC); Tpi = std::move(TempTpi); } return *Tpi; @@ -322,7 +322,7 @@ Expected PDBFile::getPDBIpiStream() { return IpiS.takeError(); auto TempIpi = std::make_unique(*this, std::move(*IpiS)); if (auto EC = TempIpi->reload()) - return EC; + return std::move(EC); Ipi = std::move(TempIpi); } return *Ipi; @@ -340,7 +340,7 @@ Expected PDBFile::getPDBPublicsStream() { return PublicS.takeError(); auto TempPublics = std::make_unique(std::move(*PublicS)); if (auto EC = TempPublics->reload()) - return EC; + return std::move(EC); Publics = std::move(TempPublics); } return *Publics; @@ -359,7 +359,7 @@ Expected PDBFile::getPDBSymbolStream() { auto TempSymbols = std::make_unique(std::move(*SymbolS)); if (auto EC = TempSymbols->reload()) - return EC; + return std::move(EC); Symbols = std::move(TempSymbols); } return *Symbols; @@ -374,7 +374,7 @@ Expected PDBFile::getStringTable() { auto N = std::make_unique(); BinaryStreamReader Reader(**NS); if (auto EC = N->reload(Reader)) - return EC; + return std::move(EC); assert(Reader.bytesRemaining() == 0); StringTableStream = std::move(*NS); Strings = std::move(N); @@ -394,7 +394,7 @@ Expected PDBFile::getInjectedSourceStream() { auto IJ = std::make_unique(std::move(*IJS)); if (auto EC = IJ->reload(*Strings)) - return EC; + return std::move(EC); InjectedSources = std::move(IJ); } return *InjectedSources; diff --git a/lib/DebugInfo/PDB/Native/TpiHashing.cpp b/lib/DebugInfo/PDB/Native/TpiHashing.cpp index 40ea032aab6..b71b2b15814 100644 --- a/lib/DebugInfo/PDB/Native/TpiHashing.cpp +++ b/lib/DebugInfo/PDB/Native/TpiHashing.cpp @@ -44,7 +44,7 @@ static Expected getHashForUdt(const CVType &Rec) { T Deserialized; if (auto E = TypeDeserializer::deserializeAs(const_cast(Rec), Deserialized)) - return E; + return std::move(E); return getHashForUdt(Deserialized, Rec.data()); } @@ -53,7 +53,7 @@ static Expected getTagRecordHashForUdt(const CVType &Rec) { T Deserialized; if (auto E = TypeDeserializer::deserializeAs(const_cast(Rec), Deserialized)) - return E; + return std::move(E); ClassOptions Opts = Deserialized.getOptions(); @@ -79,7 +79,7 @@ static Expected getSourceLineHash(const CVType &Rec) { T Deserialized; if (auto E = TypeDeserializer::deserializeAs(const_cast(Rec), Deserialized)) - return E; + return std::move(E); char Buf[4]; support::endian::write32le(Buf, Deserialized.getUDT().getIndex()); return hashStringV1(StringRef(Buf, 4)); diff --git a/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp index c6fdeadc2f9..b4d49d9ff95 100644 --- a/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp +++ b/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp @@ -101,7 +101,7 @@ SymbolizableObjectFile::create(const object::ObjectFile *Obj, Uniquify(Fs); Uniquify(Os); - return res; + return std::move(res); } SymbolizableObjectFile::SymbolizableObjectFile(const ObjectFile *Obj, diff --git a/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp b/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp index 3f435f63c16..f1114e92c36 100644 --- a/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp +++ b/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp @@ -547,7 +547,7 @@ EHFrameEdgeFixer::parseAugmentationString(BinaryStreamReader &RecordReader) { uint8_t *NextField = &AugInfo.Fields[0]; if (auto Err = RecordReader.readInteger(NextChar)) - return Err; + return std::move(Err); while (NextChar != 0) { switch (NextChar) { @@ -556,7 +556,7 @@ EHFrameEdgeFixer::parseAugmentationString(BinaryStreamReader &RecordReader) { break; case 'e': if (auto Err = RecordReader.readInteger(NextChar)) - return Err; + return std::move(Err); if (NextChar != 'h') return make_error("Unrecognized substring e" + Twine(NextChar) + @@ -575,10 +575,10 @@ EHFrameEdgeFixer::parseAugmentationString(BinaryStreamReader &RecordReader) { } if (auto Err = RecordReader.readInteger(NextChar)) - return Err; + return std::move(Err); } - return AugInfo; + return std::move(AugInfo); } Expected @@ -589,11 +589,11 @@ EHFrameEdgeFixer::readAbsolutePointer(LinkGraph &G, JITTargetAddress Addr; if (G.getPointerSize() == 8) { if (auto Err = RecordReader.readInteger(Addr)) - return Err; + return std::move(Err); } else if (G.getPointerSize() == 4) { uint32_t Addr32; if (auto Err = RecordReader.readInteger(Addr32)) - return Err; + return std::move(Err); Addr = Addr32; } else llvm_unreachable("Pointer size is not 32-bit or 64-bit"); diff --git a/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp index eeb0a4e473b..89eef5783df 100644 --- a/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp +++ b/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp @@ -28,19 +28,19 @@ Expected> MachOLinkGraphBuilder::buildGraph() { return make_error("Object is not a relocatable MachO"); if (auto Err = createNormalizedSections()) - return Err; + return std::move(Err); if (auto Err = createNormalizedSymbols()) - return Err; + return std::move(Err); if (auto Err = graphifyRegularSymbols()) - return Err; + return std::move(Err); if (auto Err = graphifySectionsWithCustomParsers()) - return Err; + return std::move(Err); if (auto Err = addRelocations()) - return Err; + return std::move(Err); return std::move(G); } diff --git a/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp index b465b11b092..29d18b6e4d7 100644 --- a/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp +++ b/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp @@ -102,7 +102,7 @@ private: Optional CompileOnDemandLayer::compileRequested(GlobalValueSet Requested) { - return Requested; + return std::move(Requested); } Optional @@ -294,7 +294,7 @@ void CompileOnDemandLayer::emitPartition( SymbolFlags[Mangle(GV->getName())] = JITSymbolFlags::fromGlobalValue(*GV); if (auto Err = R.defineMaterializing(SymbolFlags)) - return Err; + return std::move(Err); } expandPartition(*GVsToExtract); diff --git a/lib/ExecutionEngine/Orc/CompileUtils.cpp b/lib/ExecutionEngine/Orc/CompileUtils.cpp index ef3f2253bc3..160e5ba5031 100644 --- a/lib/ExecutionEngine/Orc/CompileUtils.cpp +++ b/lib/ExecutionEngine/Orc/CompileUtils.cpp @@ -37,7 +37,7 @@ irManglingOptionsFromTargetOptions(const TargetOptions &Opts) { Expected SimpleCompiler::operator()(Module &M) { CompileResult CachedObject = tryToLoadFromObjectCache(M); if (CachedObject) - return CachedObject; + return std::move(CachedObject); SmallVector ObjBufferSV; @@ -61,7 +61,7 @@ Expected SimpleCompiler::operator()(Module &M) { return Obj.takeError(); notifyObjectCompiled(M, *ObjBuffer); - return ObjBuffer; + return std::move(ObjBuffer); } SimpleCompiler::CompileResult diff --git a/lib/ExecutionEngine/Orc/Core.cpp b/lib/ExecutionEngine/Orc/Core.cpp index 5341c0c3f2b..f2b161cc9fc 100644 --- a/lib/ExecutionEngine/Orc/Core.cpp +++ b/lib/ExecutionEngine/Orc/Core.cpp @@ -1455,7 +1455,7 @@ JITDylib::lookupFlags(LookupKind K, JITDylibLookupFlags JDLookupFlags, // Run this generator. if (auto Err = DG->tryToGenerate(K, *this, JDLookupFlags, LookupSet)) - return Err; + return std::move(Err); // Re-try the search. lookupFlagsImpl(Result, K, JDLookupFlags, LookupSet); @@ -1613,7 +1613,7 @@ JITDylib::legacyLookup(std::shared_ptr Q, }); if (Err) - return Err; + return std::move(Err); assert((MUs.empty() || !QueryComplete) && "If action flags are set, there should be no work to do (so no MUs)"); @@ -1970,12 +1970,12 @@ Expected ExecutionSession::legacyLookup( auto ResultFuture = PromisedResult.get_future(); auto Result = ResultFuture.get(); if (ResolutionError) - return ResolutionError; - return Result; + return std::move(ResolutionError); + return std::move(Result); #else if (ResolutionError) - return ResolutionError; + return std::move(ResolutionError); return Result; #endif @@ -2125,13 +2125,13 @@ ExecutionSession::lookup(const JITDylibSearchOrder &SearchOrder, auto Result = ResultFuture.get(); if (ResolutionError) - return ResolutionError; + return std::move(ResolutionError); - return Result; + return std::move(Result); #else if (ResolutionError) - return ResolutionError; + return std::move(ResolutionError); return Result; #endif diff --git a/lib/ExecutionEngine/Orc/DebugUtils.cpp b/lib/ExecutionEngine/Orc/DebugUtils.cpp index 85b185481ae..c9e87ff737f 100644 --- a/lib/ExecutionEngine/Orc/DebugUtils.cpp +++ b/lib/ExecutionEngine/Orc/DebugUtils.cpp @@ -53,7 +53,7 @@ DumpObjects::operator()(std::unique_ptr Obj) { return errorCodeToError(EC); DumpStream.write(Obj->getBufferStart(), Obj->getBufferSize()); - return Obj; + return std::move(Obj); } StringRef DumpObjects::getBufferIdentifier(MemoryBuffer &B) { diff --git a/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/lib/ExecutionEngine/Orc/ExecutionUtils.cpp index de0c29ff62f..3d97fe9eeab 100644 --- a/lib/ExecutionEngine/Orc/ExecutionUtils.cpp +++ b/lib/ExecutionEngine/Orc/ExecutionUtils.cpp @@ -267,9 +267,9 @@ StaticLibraryDefinitionGenerator::Create( new StaticLibraryDefinitionGenerator(L, std::move(ArchiveBuffer), Err)); if (Err) - return Err; + return std::move(Err); - return ADG; + return std::move(ADG); } Error StaticLibraryDefinitionGenerator::tryToGenerate( diff --git a/lib/ExecutionEngine/Orc/OrcCBindingsStack.h b/lib/ExecutionEngine/Orc/OrcCBindingsStack.h index 73640d30822..87bb4398765 100644 --- a/lib/ExecutionEngine/Orc/OrcCBindingsStack.h +++ b/lib/ExecutionEngine/Orc/OrcCBindingsStack.h @@ -305,7 +305,7 @@ public: Resolvers[K] = std::make_shared(*this, ExternalResolver, ExternalResolverCtx); if (auto Err = Layer.addModule(K, std::move(M))) - return Err; + return std::move(Err); KeyLayers[K] = detail::createGenericLayer(Layer); @@ -314,7 +314,7 @@ public: orc::LegacyCtorDtorRunner CtorRunner( AcknowledgeORCv1Deprecation, std::move(CtorNames), K); if (auto Err = CtorRunner.runViaLayer(*this)) - return Err; + return std::move(Err); IRStaticDestructorRunners.emplace_back(AcknowledgeORCv1Deprecation, std::move(DtorNames), K); @@ -365,7 +365,7 @@ public: *this, ExternalResolver, ExternalResolverCtx); if (auto Err = ObjectLayer.addObject(K, std::move(ObjBuffer))) - return Err; + return std::move(Err); KeyLayers[K] = detail::createGenericLayer(ObjectLayer); @@ -399,7 +399,7 @@ public: return AddrOrErr.takeError(); } else if (auto Err = Sym.takeError()) { // Lookup failure - report error. - return Err; + return std::move(Err); } // No symbol not found. Return 0. @@ -417,7 +417,7 @@ public: return AddrOrErr.takeError(); } else if (auto Err = Sym.takeError()) { // Lookup failure - report error. - return Err; + return std::move(Err); } // Symbol not found. Return 0. diff --git a/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp b/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp index 15b7f764204..4e2d0f422f3 100644 --- a/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp @@ -119,7 +119,7 @@ LegacyJITSymbolResolver::getResponsibilitySet(const LookupSet &Symbols) { if (!Sym.getFlags().isStrong()) Result.insert(Symbol); } else if (auto Err = Sym.takeError()) - return Err; + return std::move(Err); else { // If there is no existing definition then the caller is responsible for // it. @@ -127,5 +127,5 @@ LegacyJITSymbolResolver::getResponsibilitySet(const LookupSet &Symbols) { } } - return Result; + return std::move(Result); } diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 404c4380ae6..2df71a5e5e7 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -194,7 +194,7 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) { CodeSize, CodeAlign, RODataSize, RODataAlign, RWDataSize, RWDataAlign)) - return Err; + return std::move(Err); MemMgr.reserveAllocationSpace(CodeSize, CodeAlign, RODataSize, RODataAlign, RWDataSize, RWDataAlign); } @@ -319,7 +319,7 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) { // Get symbol offset. uint64_t SectOffset; if (auto Err = getOffset(*I, *SI, SectOffset)) - return Err; + return std::move(Err); bool IsCode = SI->isText(); unsigned SectionID; @@ -341,7 +341,7 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) { // Allocate common symbols if (auto Err = emitCommonSymbols(Obj, CommonSymbolsToAllocate, CommonSize, CommonAlign)) - return Err; + return std::move(Err); // Parse and process relocations LLVM_DEBUG(dbgs() << "Parse relocations:\n"); @@ -432,7 +432,7 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) { // Give the subclasses a chance to tie-up any loose ends. if (auto Err = finalizeLoad(Obj, LocalSections)) - return Err; + return std::move(Err); // for (auto E : LocalSections) // llvm::dbgs() << "Added: " << E.first.getRawDataRefImpl() << " -> " << E.second << "\n"; diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index f5dbf3b5caa..440ab4174a5 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -102,10 +102,10 @@ Expected>> DyldELFObject::create(MemoryBufferRef Wrapper) { auto Obj = ELFObjectFile::create(Wrapper); if (auto E = Obj.takeError()) - return E; + return std::move(E); std::unique_ptr> Ret( new DyldELFObject(std::move(*Obj))); - return Ret; + return std::move(Ret); } template @@ -153,7 +153,7 @@ createRTDyldELFObject(MemoryBufferRef Buffer, const ObjectFile &SourceObject, Expected>> ObjOrErr = DyldELFObject::create(Buffer); if (Error E = ObjOrErr.takeError()) - return E; + return std::move(E); std::unique_ptr> Obj = std::move(*ObjOrErr); @@ -180,7 +180,7 @@ createRTDyldELFObject(MemoryBufferRef Buffer, const ObjectFile &SourceObject, ++SI; } - return Obj; + return std::move(Obj); } static OwningBinary @@ -1460,7 +1460,7 @@ RuntimeDyldELF::processRelocationRef( // so the final symbol value is calculated based on the relocation // values in the .opd section. if (auto Err = findOPDEntrySection(Obj, ObjSectionToID, Value)) - return Err; + return std::move(Err); } else { // In the ELFv2 ABI, a function symbol may provide a local entry // point, which must be used for direct calls. @@ -1574,7 +1574,7 @@ RuntimeDyldELF::processRelocationRef( RelocationValueRef TOCValue; if (auto Err = findPPC64TOCSection(Obj, ObjSectionToID, TOCValue)) - return Err; + return std::move(Err); if (Value.SymbolName || Value.SectionID != TOCValue.SectionID) llvm_unreachable("Unsupported TOC relocation."); Value.Addend -= TOCValue.Addend; @@ -1587,10 +1587,10 @@ RuntimeDyldELF::processRelocationRef( if (RelType == ELF::R_PPC64_TOC) { RelType = ELF::R_PPC64_ADDR64; if (auto Err = findPPC64TOCSection(Obj, ObjSectionToID, Value)) - return Err; + return std::move(Err); } else if (TargetName == ".TOC.") { if (auto Err = findPPC64TOCSection(Obj, ObjSectionToID, Value)) - return Err; + return std::move(Err); Value.Addend += Addend; } diff --git a/lib/IR/LLVMRemarkStreamer.cpp b/lib/IR/LLVMRemarkStreamer.cpp index c137208c442..326523eaa10 100644 --- a/lib/IR/LLVMRemarkStreamer.cpp +++ b/lib/IR/LLVMRemarkStreamer.cpp @@ -133,7 +133,7 @@ Expected> llvm::setupLLVMOptimizationRemarks( if (Error E = Context.getMainRemarkStreamer()->setFilter(RemarksPasses)) return make_error(std::move(E)); - return RemarksFile; + return std::move(RemarksFile); } Error llvm::setupLLVMOptimizationRemarks(LLVMContext &Context, raw_ostream &OS, diff --git a/lib/LTO/LTO.cpp b/lib/LTO/LTO.cpp index 1c52bea8709..1d23c6bab36 100644 --- a/lib/LTO/LTO.cpp +++ b/lib/LTO/LTO.cpp @@ -456,7 +456,7 @@ Expected> InputFile::create(MemoryBufferRef Object) { File->Mods = FOrErr->Mods; File->Strtab = std::move(FOrErr->Strtab); - return File; + return std::move(File); } StringRef InputFile::getName() const { @@ -676,7 +676,7 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef Syms, Mod.M = std::move(*MOrErr); if (Error Err = M.materializeMetadata()) - return Err; + return std::move(Err); UpgradeDebugInfo(M); ModuleSymbolTable SymTab; @@ -776,7 +776,7 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef Syms, for (GlobalValue &GV : M.global_values()) handleNonPrevailingComdat(GV, NonPrevailingComdats); assert(MsymI == MsymE); - return Mod; + return std::move(Mod); } Error LTO::linkRegularLTO(RegularLTOState::AddedModule Mod, @@ -1429,7 +1429,7 @@ Expected> lto::setupLLVMOptimizationRemarks( auto ResultOrErr = llvm::setupLLVMOptimizationRemarks( Context, Filename, RemarksPasses, RemarksFormat, RemarksWithHotness); if (Error E = ResultOrErr.takeError()) - return E; + return std::move(E); if (*ResultOrErr) (*ResultOrErr)->keep(); @@ -1451,5 +1451,5 @@ lto::setupStatsFile(StringRef StatsFilename) { return errorCodeToError(EC); StatsFile->keep(); - return StatsFile; + return std::move(StatsFile); } diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp index 0210953f211..587b332e706 100644 --- a/lib/LTO/LTOModule.cpp +++ b/lib/LTO/LTOModule.cpp @@ -232,7 +232,7 @@ LTOModule::makeLTOModule(MemoryBufferRef Buffer, const TargetOptions &options, Ret->parseSymbols(); Ret->parseMetadata(); - return Ret; + return std::move(Ret); } /// Create a MemoryBuffer from a memory range with an optional name. diff --git a/lib/MCA/InstrBuilder.cpp b/lib/MCA/InstrBuilder.cpp index 90ac0bdc0e0..b2503f348d6 100644 --- a/lib/MCA/InstrBuilder.cpp +++ b/lib/MCA/InstrBuilder.cpp @@ -564,7 +564,7 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI) { computeMaxLatency(*ID, MCDesc, SCDesc, STI); if (Error Err = verifyOperands(MCDesc, MCI)) - return Err; + return std::move(Err); populateWrites(*ID, MCI, SchedClassID); populateReads(*ID, MCI, SchedClassID); @@ -574,7 +574,7 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI) { // Sanity check on the instruction descriptor. if (Error Err = verifyInstrDesc(*ID, MCI)) - return Err; + return std::move(Err); // Now add the new descriptor. bool IsVariadic = MCDesc.isVariadic(); @@ -666,7 +666,7 @@ InstrBuilder::createInstruction(const MCInst &MCI) { // Early exit if there are no writes. if (D.Writes.empty()) - return NewIS; + return std::move(NewIS); // Track register writes that implicitly clear the upper portion of the // underlying super-registers using an APInt. @@ -695,7 +695,7 @@ InstrBuilder::createInstruction(const MCInst &MCI) { ++WriteIndex; } - return NewIS; + return std::move(NewIS); } } // namespace mca } // namespace llvm diff --git a/lib/MCA/Pipeline.cpp b/lib/MCA/Pipeline.cpp index 76258fcb178..22b9d0799f7 100644 --- a/lib/MCA/Pipeline.cpp +++ b/lib/MCA/Pipeline.cpp @@ -40,7 +40,7 @@ Expected Pipeline::run() { do { notifyCycleBegin(); if (Error Err = runCycle()) - return Err; + return std::move(Err); notifyCycleEnd(); ++Cycles; } while (hasWorkToProcess()); diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index 4f7cea8f9e1..17d5eec9156 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -481,7 +481,7 @@ Expected Archive::Child::getNext() const { Error Err = Error::success(); Child Ret(Parent, NextLoc, &Err); if (Err) - return Err; + return std::move(Err); return Ret; } @@ -531,8 +531,8 @@ Expected> Archive::create(MemoryBufferRef Source) { Error Err = Error::success(); std::unique_ptr Ret(new Archive(Source, Err)); if (Err) - return Err; - return Ret; + return std::move(Err); + return std::move(Ret); } void Archive::setFirstRegular(const Child &C) { @@ -852,7 +852,7 @@ Expected Archive::Symbol::getMember() const { Error Err = Error::success(); Child C(Parent, Loc, &Err); if (Err) - return Err; + return std::move(Err); return C; } diff --git a/lib/Object/ArchiveWriter.cpp b/lib/Object/ArchiveWriter.cpp index 7af798eceed..13dafb58f47 100644 --- a/lib/Object/ArchiveWriter.cpp +++ b/lib/Object/ArchiveWriter.cpp @@ -70,7 +70,7 @@ NewArchiveMember::getOldMember(const object::Archive::Child &OldMember, return AccessModeOrErr.takeError(); M.Perms = AccessModeOrErr.get(); } - return M; + return std::move(M); } Expected NewArchiveMember::getFile(StringRef FileName, @@ -109,7 +109,7 @@ Expected NewArchiveMember::getFile(StringRef FileName, M.GID = Status.getGroup(); M.Perms = Status.permissions(); } - return M; + return std::move(M); } template @@ -379,7 +379,7 @@ getSymbols(MemoryBufferRef Buf, raw_ostream &SymNames, bool &HasObject) { continue; Ret.push_back(SymNames.tell()); if (Error E = S.printName(SymNames)) - return E; + return std::move(E); SymNames << '\0'; } return Ret; @@ -492,7 +492,7 @@ computeMemberData(raw_ostream &StringTable, raw_ostream &SymNames, Expected> Symbols = getSymbols(Buf, SymNames, HasObject); if (auto E = Symbols.takeError()) - return E; + return std::move(E); Pos += Header.size() + Data.size() + Padding.size(); Ret.push_back({std::move(*Symbols), std::move(Header), Data, Padding}); diff --git a/lib/Object/COFFModuleDefinition.cpp b/lib/Object/COFFModuleDefinition.cpp index d72a1cf1aaf..8f29f7a658f 100644 --- a/lib/Object/COFFModuleDefinition.cpp +++ b/lib/Object/COFFModuleDefinition.cpp @@ -151,7 +151,7 @@ public: Expected parse() { do { if (Error Err = parseOne()) - return Err; + return std::move(Err); } while (Tok.K != Eof); return Info; } diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp index bab9a7cc825..2c0f6dc2b1e 100644 --- a/lib/Object/COFFObjectFile.cpp +++ b/lib/Object/COFFObjectFile.cpp @@ -297,7 +297,7 @@ COFFObjectFile::getSectionContents(DataRefImpl Ref) const { const coff_section *Sec = toSec(Ref); ArrayRef Res; if (Error E = getSectionContents(Sec, Res)) - return E; + return std::move(E); return Res; } @@ -1625,7 +1625,7 @@ ObjectFile::createCOFFObjectFile(MemoryBufferRef Object) { std::unique_ptr Ret(new COFFObjectFile(Object, EC)); if (EC) return errorCodeToError(EC); - return Ret; + return std::move(Ret); } bool BaseRelocRef::operator==(const BaseRelocRef &Other) const { @@ -1666,7 +1666,7 @@ std::error_code BaseRelocRef::getRVA(uint32_t &Result) const { do { \ Error E = (Expr); \ if (E) \ - return E; \ + return std::move(E); \ } while (0) Expected> @@ -1832,7 +1832,7 @@ ResourceSectionRef::getContents(const coff_resource_data_entry &Entry) { uint64_t Offset = Entry.DataRVA + Sym->getValue(); ArrayRef Contents; if (Error E = Obj->getSectionContents(Section, Contents)) - return E; + return std::move(E); if (Offset + Entry.DataSize > Contents.size()) return createStringError(object_error::parse_failed, "data outside of section"); diff --git a/lib/Object/Decompressor.cpp b/lib/Object/Decompressor.cpp index 6682e4979ed..11efd857d1a 100644 --- a/lib/Object/Decompressor.cpp +++ b/lib/Object/Decompressor.cpp @@ -26,7 +26,7 @@ Expected Decompressor::create(StringRef Name, StringRef Data, Error Err = isGnuStyle(Name) ? D.consumeCompressedGnuHeader() : D.consumeCompressedZLibHeader(Is64Bit, IsLE); if (Err) - return Err; + return std::move(Err); return D; } diff --git a/lib/Object/ELFObjectFile.cpp b/lib/Object/ELFObjectFile.cpp index 671f7b7e6d9..bf6ffd6c37b 100644 --- a/lib/Object/ELFObjectFile.cpp +++ b/lib/Object/ELFObjectFile.cpp @@ -62,7 +62,7 @@ static Expected>> createPtr(MemoryBufferRef Object) { auto Ret = ELFObjectFile::create(Object); if (Error E = Ret.takeError()) - return E; + return std::move(E); return std::make_unique>(std::move(*Ret)); } diff --git a/lib/Object/IRObjectFile.cpp b/lib/Object/IRObjectFile.cpp index 79e8f4d681d..636f1521262 100644 --- a/lib/Object/IRObjectFile.cpp +++ b/lib/Object/IRObjectFile.cpp @@ -151,5 +151,5 @@ Expected object::readIRSymtab(MemoryBufferRef MBRef) { F.Symtab = std::move(FCOrErr->Symtab); F.Strtab = std::move(FCOrErr->Strtab); F.TheReader = std::move(FCOrErr->TheReader); - return F; + return std::move(F); } diff --git a/lib/Object/IRSymtab.cpp b/lib/Object/IRSymtab.cpp index 3fde16c1154..a92cb02ed29 100644 --- a/lib/Object/IRSymtab.cpp +++ b/lib/Object/IRSymtab.cpp @@ -363,7 +363,7 @@ static Expected upgrade(ArrayRef BMs) { StringTableBuilder StrtabBuilder(StringTableBuilder::RAW); BumpPtrAllocator Alloc; if (Error E = build(Mods, FC.Symtab, StrtabBuilder, Alloc)) - return E; + return std::move(E); StrtabBuilder.finalizeInOrder(); FC.Strtab.resize(StrtabBuilder.getSize()); @@ -371,7 +371,7 @@ static Expected upgrade(ArrayRef BMs) { FC.TheReader = {{FC.Symtab.data(), FC.Symtab.size()}, {FC.Strtab.data(), FC.Strtab.size()}}; - return FC; + return std::move(FC); } Expected irsymtab::readBitcode(const BitcodeFileContents &BFC) { @@ -405,5 +405,5 @@ Expected irsymtab::readBitcode(const BitcodeFileContents &BFC) { if (FC.TheReader.getNumModules() != BFC.Mods.size()) return upgrade(std::move(BFC.Mods)); - return FC; + return std::move(FC); } diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index 02e8682149b..8540b7ab03c 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -1251,8 +1251,8 @@ MachOObjectFile::create(MemoryBufferRef Object, bool IsLittleEndian, Is64Bits, Err, UniversalCputype, UniversalIndex)); if (Err) - return Err; - return Obj; + return std::move(Err); + return std::move(Obj); } MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian, diff --git a/lib/Object/MachOUniversal.cpp b/lib/Object/MachOUniversal.cpp index ba4b631a3ab..a178ecde949 100644 --- a/lib/Object/MachOUniversal.cpp +++ b/lib/Object/MachOUniversal.cpp @@ -105,8 +105,8 @@ MachOUniversalBinary::create(MemoryBufferRef Source) { std::unique_ptr Ret( new MachOUniversalBinary(Source, Err)); if (Err) - return Err; - return Ret; + return std::move(Err); + return std::move(Ret); } MachOUniversalBinary::MachOUniversalBinary(MemoryBufferRef Source, Error &Err) diff --git a/lib/Object/ObjectFile.cpp b/lib/Object/ObjectFile.cpp index 766c59a3881..098b3d8f8dd 100644 --- a/lib/Object/ObjectFile.cpp +++ b/lib/Object/ObjectFile.cpp @@ -182,7 +182,7 @@ ObjectFile::createObjectFile(StringRef ObjectPath) { Expected> ObjOrErr = createObjectFile(Buffer->getMemBufferRef()); if (Error Err = ObjOrErr.takeError()) - return Err; + return std::move(Err); std::unique_ptr Obj = std::move(ObjOrErr.get()); return OwningBinary(std::move(Obj), std::move(Buffer)); diff --git a/lib/Object/SymbolicFile.cpp b/lib/Object/SymbolicFile.cpp index 921cb2170d8..3db4ad9ed14 100644 --- a/lib/Object/SymbolicFile.cpp +++ b/lib/Object/SymbolicFile.cpp @@ -82,13 +82,13 @@ SymbolicFile::createSymbolicFile(MemoryBufferRef Object, file_magic Type, Expected> Obj = ObjectFile::createObjectFile(Object, Type); if (!Obj || !Context) - return Obj; + return std::move(Obj); Expected BCData = IRObjectFile::findBitcodeInObject(*Obj->get()); if (!BCData) { consumeError(BCData.takeError()); - return Obj; + return std::move(Obj); } return IRObjectFile::create( diff --git a/lib/Object/TapiUniversal.cpp b/lib/Object/TapiUniversal.cpp index c297e319fcc..b3273e345a6 100644 --- a/lib/Object/TapiUniversal.cpp +++ b/lib/Object/TapiUniversal.cpp @@ -49,6 +49,6 @@ TapiUniversal::create(MemoryBufferRef Source) { Error Err = Error::success(); std::unique_ptr Ret(new TapiUniversal(Source, Err)); if (Err) - return Err; - return Ret; + return std::move(Err); + return std::move(Ret); } diff --git a/lib/Object/WasmObjectFile.cpp b/lib/Object/WasmObjectFile.cpp index 348cb56df95..2e42324629f 100644 --- a/lib/Object/WasmObjectFile.cpp +++ b/lib/Object/WasmObjectFile.cpp @@ -58,9 +58,9 @@ ObjectFile::createWasmObjectFile(MemoryBufferRef Buffer) { Error Err = Error::success(); auto ObjectFile = std::make_unique(Buffer, Err); if (Err) - return Err; + return std::move(Err); - return ObjectFile; + return std::move(ObjectFile); } #define VARINT7_MAX ((1 << 7) - 1) diff --git a/lib/Object/WindowsResource.cpp b/lib/Object/WindowsResource.cpp index dc1d86ae76a..0cf9da43ae2 100644 --- a/lib/Object/WindowsResource.cpp +++ b/lib/Object/WindowsResource.cpp @@ -63,7 +63,7 @@ WindowsResource::createWindowsResource(MemoryBufferRef Source) { Source.getBufferIdentifier() + ": too small to be a resource file", object_error::invalid_file_type); std::unique_ptr Ret(new WindowsResource(Source)); - return Ret; + return std::move(Ret); } Expected WindowsResource::getHeadEntry() { @@ -81,7 +81,7 @@ Expected ResourceEntryRef::create(BinaryStreamRef BSR, const WindowsResource *Owner) { auto Ref = ResourceEntryRef(BSR, Owner); if (auto E = Ref.loadNext()) - return E; + return std::move(E); return Ref; } @@ -1005,7 +1005,7 @@ writeWindowsResourceCOFF(COFF::MachineTypes MachineType, Error E = Error::success(); WindowsResourceCOFFWriter Writer(MachineType, Parser, E); if (E) - return E; + return std::move(E); return Writer.write(TimeDateStamp); } diff --git a/lib/Object/XCOFFObjectFile.cpp b/lib/Object/XCOFFObjectFile.cpp index feb8a19836c..51fc6610164 100644 --- a/lib/Object/XCOFFObjectFile.cpp +++ b/lib/Object/XCOFFObjectFile.cpp @@ -604,7 +604,7 @@ XCOFFObjectFile::relocations(const XCOFFSectionHeader32 &Sec) const { Sec.FileOffsetToRelocationInfo); auto NumRelocEntriesOrErr = getLogicalNumberOfRelocationEntries(Sec); if (Error E = NumRelocEntriesOrErr.takeError()) - return E; + return std::move(E); uint32_t NumRelocEntries = NumRelocEntriesOrErr.get(); @@ -613,7 +613,7 @@ XCOFFObjectFile::relocations(const XCOFFSectionHeader32 &Sec) const { getObject(Data, reinterpret_cast(RelocAddr), NumRelocEntries * sizeof(XCOFFRelocation32)); if (Error E = RelocationOrErr.takeError()) - return E; + return std::move(E); const XCOFFRelocation32 *StartReloc = RelocationOrErr.get(); @@ -639,7 +639,7 @@ XCOFFObjectFile::parseStringTable(const XCOFFObjectFile *Obj, uint64_t Offset) { auto StringTableOrErr = getObject(Obj->Data, Obj->base() + Offset, Size); if (Error E = StringTableOrErr.takeError()) - return E; + return std::move(E); const char *StringTablePtr = StringTableOrErr.get(); if (StringTablePtr[Size - 1] != '\0') @@ -662,7 +662,7 @@ XCOFFObjectFile::create(unsigned Type, MemoryBufferRef MBR) { auto FileHeaderOrErr = getObject(Data, Base + CurOffset, Obj->getFileHeaderSize()); if (Error E = FileHeaderOrErr.takeError()) - return E; + return std::move(E); Obj->FileHeader = FileHeaderOrErr.get(); CurOffset += Obj->getFileHeaderSize(); @@ -676,17 +676,17 @@ XCOFFObjectFile::create(unsigned Type, MemoryBufferRef MBR) { Obj->getNumberOfSections() * Obj->getSectionHeaderSize()); if (Error E = SecHeadersOrErr.takeError()) - return E; + return std::move(E); Obj->SectionHeaderTable = SecHeadersOrErr.get(); } // 64-bit object supports only file header and section headers for now. if (Obj->is64Bit()) - return Obj; + return std::move(Obj); // If there is no symbol table we are done parsing the memory buffer. if (Obj->getLogicalNumberOfSymbolTableEntries32() == 0) - return Obj; + return std::move(Obj); // Parse symbol table. CurOffset = Obj->fileHeader32()->SymbolTableOffset; @@ -695,7 +695,7 @@ XCOFFObjectFile::create(unsigned Type, MemoryBufferRef MBR) { auto SymTableOrErr = getObject(Data, Base + CurOffset, SymbolTableSize); if (Error E = SymTableOrErr.takeError()) - return E; + return std::move(E); Obj->SymbolTblPtr = SymTableOrErr.get(); CurOffset += SymbolTableSize; @@ -703,10 +703,10 @@ XCOFFObjectFile::create(unsigned Type, MemoryBufferRef MBR) { Expected StringTableOrErr = parseStringTable(Obj.get(), CurOffset); if (Error E = StringTableOrErr.takeError()) - return E; + return std::move(E); Obj->StringTable = StringTableOrErr.get(); - return Obj; + return std::move(Obj); } Expected> diff --git a/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp b/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp index 65843418cda..02f053bb0e0 100644 --- a/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp +++ b/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp @@ -694,11 +694,11 @@ YAMLStringTableSubsection::fromCodeViewSubsection( StringRef S; // First item is a single null string, skip it. if (auto EC = Reader.readCString(S)) - return EC; + return std::move(EC); assert(S.empty()); while (Reader.bytesRemaining() > 0) { if (auto EC = Reader.readCString(S)) - return EC; + return std::move(EC); Result->Strings.push_back(S); } return Result; @@ -749,7 +749,7 @@ llvm::CodeViewYAML::toCodeViewSubsectionList( const codeview::StringsAndChecksums &SC) { std::vector> Result; if (Subsections.empty()) - return Result; + return std::move(Result); for (const auto &SS : Subsections) { std::shared_ptr CVS; @@ -757,7 +757,7 @@ llvm::CodeViewYAML::toCodeViewSubsectionList( assert(CVS != nullptr); Result.push_back(std::move(CVS)); } - return Result; + return std::move(Result); } namespace { @@ -892,7 +892,7 @@ YAMLDebugSubsection::fromCodeViewSubection(const StringsAndChecksumsRef &SC, const DebugSubsectionRecord &SS) { SubsectionConversionVisitor V; if (auto EC = visitDebugSubsection(SS, V, SC)) - return EC; + return std::move(EC); return V.Subsection; } diff --git a/lib/ObjectYAML/CodeViewYAMLSymbols.cpp b/lib/ObjectYAML/CodeViewYAMLSymbols.cpp index 094e298c76a..95409fdc330 100644 --- a/lib/ObjectYAML/CodeViewYAMLSymbols.cpp +++ b/lib/ObjectYAML/CodeViewYAMLSymbols.cpp @@ -585,7 +585,7 @@ fromCodeViewSymbolImpl(CVSymbol Symbol) { auto Impl = std::make_shared(Symbol.kind()); if (auto EC = Impl->fromCodeViewSymbol(Symbol)) - return EC; + return std::move(EC); Result.Symbol = Impl; return Result; } diff --git a/lib/ObjectYAML/CodeViewYAMLTypes.cpp b/lib/ObjectYAML/CodeViewYAMLTypes.cpp index a830e829951..a5e3ce1e71e 100644 --- a/lib/ObjectYAML/CodeViewYAMLTypes.cpp +++ b/lib/ObjectYAML/CodeViewYAMLTypes.cpp @@ -671,7 +671,7 @@ static inline Expected fromCodeViewRecordImpl(CVType Type) { auto Impl = std::make_shared>(Type.kind()); if (auto EC = Impl->fromCodeViewRecord(Type)) - return EC; + return std::move(EC); Result.Leaf = Impl; return Result; } diff --git a/lib/ObjectYAML/DWARFEmitter.cpp b/lib/ObjectYAML/DWARFEmitter.cpp index db99ad9bf79..b410fed16f0 100644 --- a/lib/ObjectYAML/DWARFEmitter.cpp +++ b/lib/ObjectYAML/DWARFEmitter.cpp @@ -377,5 +377,5 @@ DWARFYAML::EmitDebugSections(StringRef YAMLString, bool ApplyFixups, DebugSections); EmitDebugSectionImpl(DI, &DWARFYAML::EmitDebugAranges, "debug_aranges", DebugSections); - return DebugSections; + return std::move(DebugSections); } diff --git a/lib/ProfileData/Coverage/CoverageMapping.cpp b/lib/ProfileData/Coverage/CoverageMapping.cpp index 6509afa82a5..9d39b7c63f8 100644 --- a/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -284,14 +284,14 @@ Expected> CoverageMapping::load( for (const auto &CoverageReader : CoverageReaders) { for (auto RecordOrErr : *CoverageReader) { if (Error E = RecordOrErr.takeError()) - return E; + return std::move(E); const auto &Record = *RecordOrErr; if (Error E = Coverage->loadFunctionRecord(Record, ProfileReader)) - return E; + return std::move(E); } } - return Coverage; + return std::move(Coverage); } // If E is a no_data_found error, returns success. Otherwise returns E. @@ -309,7 +309,7 @@ CoverageMapping::load(ArrayRef ObjectFilenames, StringRef ProfileFilename, ArrayRef Arches) { auto ProfileReaderOrErr = IndexedInstrProfReader::create(ProfileFilename); if (Error E = ProfileReaderOrErr.takeError()) - return E; + return std::move(E); auto ProfileReader = std::move(ProfileReaderOrErr.get()); SmallVector, 4> Readers; @@ -326,7 +326,7 @@ CoverageMapping::load(ArrayRef ObjectFilenames, if (Error E = CoverageReadersOrErr.takeError()) { E = handleMaybeNoDataFoundError(std::move(E)); if (E) - return E; + return std::move(E); // E == success (originally a no_data_found error). continue; } diff --git a/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/lib/ProfileData/Coverage/CoverageMappingReader.cpp index b2132009bb3..679ff3525ee 100644 --- a/lib/ProfileData/Coverage/CoverageMappingReader.cpp +++ b/lib/ProfileData/Coverage/CoverageMappingReader.cpp @@ -321,28 +321,28 @@ Expected RawCoverageMappingDummyChecker::isDummy() { // A dummy coverage mapping data consists of just one region with zero count. uint64_t NumFileMappings; if (Error Err = readSize(NumFileMappings)) - return Err; + return std::move(Err); if (NumFileMappings != 1) return false; // We don't expect any specific value for the filename index, just skip it. uint64_t FilenameIndex; if (Error Err = readIntMax(FilenameIndex, std::numeric_limits::max())) - return Err; + return std::move(Err); uint64_t NumExpressions; if (Error Err = readSize(NumExpressions)) - return Err; + return std::move(Err); if (NumExpressions != 0) return false; uint64_t NumRegions; if (Error Err = readSize(NumRegions)) - return Err; + return std::move(Err); if (NumRegions != 1) return false; uint64_t EncodedCounterAndRegion; if (Error Err = readIntMax(EncodedCounterAndRegion, std::numeric_limits::max())) - return Err; + return std::move(Err); unsigned Tag = EncodedCounterAndRegion & Counter::EncodingTagMask; return Tag == Counter::Zero; } @@ -494,7 +494,7 @@ public: size_t FilenamesBegin = Filenames.size(); RawCoverageFilenamesReader Reader(StringRef(Buf, FilenamesSize), Filenames); if (auto Err = Reader.read()) - return Err; + return std::move(Err); Buf += FilenamesSize; // We'll read the coverage mapping records in the loop below. @@ -521,7 +521,7 @@ public: if (Error Err = insertFunctionRecordIfNeeded(CFR, Mapping, FilenamesBegin)) - return Err; + return std::move(Err); CFR++; } return Buf; @@ -545,7 +545,7 @@ Expected> CovMapFuncRecordReader::get( case CovMapVersion::Version3: // Decompress the name data. if (Error E = P.create(P.getNameData())) - return E; + return std::move(E); if (Version == CovMapVersion::Version2) return std::make_unique>(P, R, F); @@ -597,26 +597,26 @@ BinaryCoverageReader::createCoverageReaderFromBuffer( readCoverageMappingData( Reader->ProfileNames, Coverage, Reader->MappingRecords, Reader->Filenames)) - return E; + return std::move(E); } else if (BytesInAddress == 4 && Endian == support::endianness::big) { if (Error E = readCoverageMappingData( Reader->ProfileNames, Coverage, Reader->MappingRecords, Reader->Filenames)) - return E; + return std::move(E); } else if (BytesInAddress == 8 && Endian == support::endianness::little) { if (Error E = readCoverageMappingData( Reader->ProfileNames, Coverage, Reader->MappingRecords, Reader->Filenames)) - return E; + return std::move(E); } else if (BytesInAddress == 8 && Endian == support::endianness::big) { if (Error E = readCoverageMappingData( Reader->ProfileNames, Coverage, Reader->MappingRecords, Reader->Filenames)) - return E; + return std::move(E); } else return make_error(coveragemap_error::malformed); - return Reader; + return std::move(Reader); } static Expected> @@ -643,7 +643,7 @@ loadTestingFormat(StringRef Data) { return make_error(coveragemap_error::malformed); InstrProfSymtab ProfileNames; if (Error E = ProfileNames.create(Data.substr(0, ProfileNamesSize), Address)) - return E; + return std::move(E); StringRef CoverageMapping = Data.substr(ProfileNamesSize); // Skip the padding bytes because coverage map data has an alignment of 8. if (CoverageMapping.empty()) @@ -708,12 +708,12 @@ loadBinaryFormat(std::unique_ptr Bin, StringRef Arch) { lookupSection(*OF, getInstrProfSectionName(IPSK_name, ObjFormat, /*AddSegmentInfo=*/false)); if (auto E = NamesSection.takeError()) - return E; + return std::move(E); auto CoverageSection = lookupSection(*OF, getInstrProfSectionName(IPSK_covmap, ObjFormat, /*AddSegmentInfo=*/false)); if (auto E = CoverageSection.takeError()) - return E; + return std::move(E); // Get the contents of the given sections. auto CoverageMappingOrErr = CoverageSection->getContents(); @@ -722,7 +722,7 @@ loadBinaryFormat(std::unique_ptr Bin, StringRef Arch) { InstrProfSymtab ProfileNames; if (Error E = ProfileNames.create(*NamesSection)) - return E; + return std::move(E); return BinaryCoverageReader::createCoverageReaderFromBuffer( CoverageMappingOrErr.get(), std::move(ProfileNames), BytesInAddress, @@ -741,7 +741,7 @@ BinaryCoverageReader::create( if (!ReaderOrErr) return ReaderOrErr.takeError(); Readers.push_back(std::move(ReaderOrErr.get())); - return Readers; + return std::move(Readers); } auto BinOrErr = createBinary(ObjectBuffer); @@ -786,7 +786,7 @@ BinaryCoverageReader::create( Readers.push_back(std::move(Reader)); } if (Err) - return Err; + return std::move(Err); // Thin archives reference object files outside of the archive file, i.e. // files which reside in memory not owned by the caller. Transfer ownership @@ -795,14 +795,14 @@ BinaryCoverageReader::create( for (auto &Buffer : Ar->takeThinBuffers()) ObjectFileBuffers.push_back(std::move(Buffer)); - return Readers; + return std::move(Readers); } auto ReaderOrErr = loadBinaryFormat(std::move(Bin), Arch); if (!ReaderOrErr) return ReaderOrErr.takeError(); Readers.push_back(std::move(ReaderOrErr.get())); - return Readers; + return std::move(Readers); } Error BinaryCoverageReader::readNextRecord(CoverageMappingRecord &Record) { diff --git a/lib/ProfileData/GCOV.cpp b/lib/ProfileData/GCOV.cpp index 6331be3b237..0c4006d867a 100644 --- a/lib/ProfileData/GCOV.cpp +++ b/lib/ProfileData/GCOV.cpp @@ -711,7 +711,7 @@ FileInfo::openCoveragePath(StringRef CoveragePath) { errs() << EC.message() << "\n"; return std::make_unique(); } - return OS; + return std::move(OS); } /// print - Print source files with collected line count information. diff --git a/lib/ProfileData/InstrProf.cpp b/lib/ProfileData/InstrProf.cpp index 30d2a0e781d..1859127b4a2 100644 --- a/lib/ProfileData/InstrProf.cpp +++ b/lib/ProfileData/InstrProf.cpp @@ -891,9 +891,9 @@ ValueProfData::getValueProfData(const unsigned char *D, Error E = VPD->checkIntegrity(); if (E) - return E; + return std::move(E); - return VPD; + return std::move(VPD); } void ValueProfData::swapBytesToHost(support::endianness Endianness) { diff --git a/lib/ProfileData/InstrProfReader.cpp b/lib/ProfileData/InstrProfReader.cpp index d7f987e7f9e..b904f983dce 100644 --- a/lib/ProfileData/InstrProfReader.cpp +++ b/lib/ProfileData/InstrProfReader.cpp @@ -55,7 +55,7 @@ InstrProfReader::create(const Twine &Path) { // Set up the buffer to read. auto BufferOrError = setupMemoryBuffer(Path); if (Error E = BufferOrError.takeError()) - return E; + return std::move(E); return InstrProfReader::create(std::move(BufferOrError.get())); } @@ -83,9 +83,9 @@ InstrProfReader::create(std::unique_ptr Buffer) { // Initialize the reader and return the result. if (Error E = initializeReader(*Result)) - return E; + return std::move(E); - return Result; + return std::move(Result); } Expected> @@ -93,7 +93,7 @@ IndexedInstrProfReader::create(const Twine &Path, const Twine &RemappingPath) { // Set up the buffer to read. auto BufferOrError = setupMemoryBuffer(Path); if (Error E = BufferOrError.takeError()) - return E; + return std::move(E); // Set up the remapping buffer if requested. std::unique_ptr RemappingBuffer; @@ -101,7 +101,7 @@ IndexedInstrProfReader::create(const Twine &Path, const Twine &RemappingPath) { if (!RemappingPathStr.empty()) { auto RemappingBufferOrError = setupMemoryBuffer(RemappingPathStr); if (Error E = RemappingBufferOrError.takeError()) - return E; + return std::move(E); RemappingBuffer = std::move(RemappingBufferOrError.get()); } @@ -124,9 +124,9 @@ IndexedInstrProfReader::create(std::unique_ptr Buffer, // Initialize the reader and return the result. if (Error E = initializeReader(*Result)) - return E; + return std::move(E); - return Result; + return std::move(Result); } void InstrProfIterator::Increment() { @@ -874,7 +874,7 @@ IndexedInstrProfReader::getInstrProfRecord(StringRef FuncName, ArrayRef Data; Error Err = Remapper->getRecords(FuncName, Data); if (Err) - return Err; + return std::move(Err); // Found it. Look for counters with the right hash. for (unsigned I = 0, E = Data.size(); I < E; ++I) { // Check for a match and fill the vector if there is one. diff --git a/lib/ProfileData/SampleProfReader.cpp b/lib/ProfileData/SampleProfReader.cpp index 5a673931b3f..6f74cec07b9 100644 --- a/lib/ProfileData/SampleProfReader.cpp +++ b/lib/ProfileData/SampleProfReader.cpp @@ -1250,7 +1250,7 @@ setupMemoryBuffer(const Twine &Filename) { if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits::max()) return sampleprof_error::too_large; - return Buffer; + return std::move(Buffer); } /// Create a sample profile reader based on the format of the input file. @@ -1362,7 +1362,7 @@ SampleProfileReader::create(std::unique_ptr &B, LLVMContext &C, return EC; } - return Reader; + return std::move(Reader); } // For text and GCC file formats, we compute the summary after reading the diff --git a/lib/ProfileData/SampleProfWriter.cpp b/lib/ProfileData/SampleProfWriter.cpp index dbb0f309cad..8d09af31f94 100644 --- a/lib/ProfileData/SampleProfWriter.cpp +++ b/lib/ProfileData/SampleProfWriter.cpp @@ -607,7 +607,7 @@ SampleProfileWriter::create(std::unique_ptr &OS, return EC; Writer->Format = Format; - return Writer; + return std::move(Writer); } void SampleProfileWriter::computeSummary( diff --git a/lib/Remarks/BitstreamRemarkParser.cpp b/lib/Remarks/BitstreamRemarkParser.cpp index c1fedfbf09a..25fbea7d31c 100644 --- a/lib/Remarks/BitstreamRemarkParser.cpp +++ b/lib/Remarks/BitstreamRemarkParser.cpp @@ -266,7 +266,7 @@ static Expected isBlock(BitstreamCursor &Stream, unsigned BlockID) { break; } if (Error E = Stream.JumpToBit(PreviousBitNo)) - return E; + return std::move(E); return Result; } @@ -316,7 +316,7 @@ remarks::createBitstreamParserFromMeta( if (Error E = validateMagicNumber( StringRef(MagicNumber->data(), MagicNumber->size()))) - return E; + return std::move(E); auto Parser = StrTab ? std::make_unique(Buf, std::move(*StrTab)) @@ -325,7 +325,7 @@ remarks::createBitstreamParserFromMeta( if (ExternalFilePrependPath) Parser->ExternalFilePrependPath = std::string(*ExternalFilePrependPath); - return Parser; + return std::move(Parser); } Expected> BitstreamRemarkParser::next() { @@ -334,7 +334,7 @@ Expected> BitstreamRemarkParser::next() { if (!ReadyToParseRemarks) { if (Error E = parseMeta()) - return E; + return std::move(E); ReadyToParseRemarks = true; } @@ -491,7 +491,7 @@ Error BitstreamRemarkParser::processSeparateRemarksMetaMeta( Expected> BitstreamRemarkParser::parseRemark() { BitstreamRemarkParserHelper RemarkHelper(ParserHelper.Stream); if (Error E = RemarkHelper.parse()) - return E; + return std::move(E); return processRemark(RemarkHelper); } @@ -562,7 +562,7 @@ BitstreamRemarkParser::processRemark(BitstreamRemarkParserHelper &Helper) { R.Hotness = *Helper.Hotness; if (!Helper.Args) - return Result; + return std::move(Result); for (const BitstreamRemarkParserHelper::Argument &Arg : *Helper.Args) { if (!Arg.KeyIdx) @@ -600,5 +600,5 @@ BitstreamRemarkParser::processRemark(BitstreamRemarkParserHelper &Helper) { } } - return Result; + return std::move(Result); } diff --git a/lib/Remarks/YAMLRemarkParser.cpp b/lib/Remarks/YAMLRemarkParser.cpp index a48b2b85d69..dd834d85676 100644 --- a/lib/Remarks/YAMLRemarkParser.cpp +++ b/lib/Remarks/YAMLRemarkParser.cpp @@ -164,7 +164,7 @@ remarks::createYAMLParserFromMeta(StringRef Buf, : std::make_unique(Buf); if (SeparateBuf) Result->SeparateBuf = std::move(SeparateBuf); - return Result; + return std::move(Result); } YAMLRemarkParser::YAMLRemarkParser(StringRef Buf) @@ -190,7 +190,7 @@ Error YAMLRemarkParser::error() { Expected> YAMLRemarkParser::parseRemark(yaml::Document &RemarkEntry) { if (Error E = error()) - return E; + return std::move(E); yaml::Node *YAMLRoot = RemarkEntry.getRoot(); if (!YAMLRoot) { @@ -267,7 +267,7 @@ YAMLRemarkParser::parseRemark(yaml::Document &RemarkEntry) { return error("Type, Pass, Name or Function missing.", *RemarkEntry.getRoot()); - return Result; + return std::move(Result); } Expected YAMLRemarkParser::parseType(yaml::MappingNode &Node) { diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index 6b72593dae4..03f0bb1f705 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -2518,7 +2518,7 @@ IEEEFloat::convertFromDecimalString(StringRef str, roundingMode rounding_mode) { /* Scan the text. */ StringRef::iterator p = str.begin(); if (Error Err = interpretDecimal(p, str.end(), &D)) - return Err; + return std::move(Err); /* Handle the quick cases. First the case of no significant digits, i.e. zero, and then exponents that are obviously too large or too diff --git a/lib/Support/FileCheck.cpp b/lib/Support/FileCheck.cpp index 5c5a510afe5..23e1ece2113 100644 --- a/lib/Support/FileCheck.cpp +++ b/lib/Support/FileCheck.cpp @@ -86,7 +86,7 @@ Expected BinaryOperation::eval() const { Err = joinErrors(std::move(Err), LeftOp.takeError()); if (!RightOp) Err = joinErrors(std::move(Err), RightOp.takeError()); - return Err; + return std::move(Err); } return EvalBinop(*LeftOp, *RightOp); @@ -284,7 +284,7 @@ Pattern::parseBinop(StringRef &Expr, std::unique_ptr LeftOp, FileCheckPatternContext *Context, const SourceMgr &SM) { Expr = Expr.ltrim(SpaceChars); if (Expr.empty()) - return LeftOp; + return std::move(LeftOp); // Check if this is a supported operation and select a function to perform // it. @@ -425,7 +425,7 @@ Expected> Pattern::parseNumericSubstitutionBlock( DefinedNumericVariable = *ParseResult; } - return ExpressionPointer; + return std::move(ExpressionPointer); } bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix, diff --git a/lib/Support/JSON.cpp b/lib/Support/JSON.cpp index d44eafaca72..16b1d11efd0 100644 --- a/lib/Support/JSON.cpp +++ b/lib/Support/JSON.cpp @@ -513,7 +513,7 @@ Expected parse(StringRef JSON) { if (P.checkUTF8()) if (P.parseValue(E)) if (P.assertEnd()) - return E; + return std::move(E); return P.takeError(); } char ParseError::ID = 0; diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index a7c7c357fe2..e4027ca7bbf 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -128,7 +128,7 @@ getMemBufferCopyImpl(StringRef InputData, const Twine &BufferName) { if (!Buf) return make_error_code(errc::not_enough_memory); memcpy(Buf->getBufferStart(), InputData.data(), InputData.size()); - return Buf; + return std::move(Buf); } std::unique_ptr @@ -398,7 +398,7 @@ getReadWriteFile(const Twine &Filename, uint64_t FileSize, uint64_t MapSize, Offset, EC)); if (EC) return EC; - return Result; + return std::move(Result); } ErrorOr> @@ -450,7 +450,7 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, new (NamedBufferAlloc(Filename)) MemoryBufferMMapFile( RequiresNullTerminator, FD, MapSize, Offset, EC)); if (!EC) - return Result; + return std::move(Result); } auto Buf = WritableMemoryBuffer::getNewUninitMemBuffer(MapSize, Filename); @@ -475,7 +475,7 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, Offset += *ReadBytes; } - return Buf; + return std::move(Buf); } ErrorOr> diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 85698f1289b..fa3bf47569e 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -1264,7 +1264,7 @@ Expected TempFile::create(const Twine &Model, unsigned Mode) { return errorCodeToError(EC); } #endif - return Ret; + return std::move(Ret); } } diff --git a/lib/Support/YAMLTraits.cpp b/lib/Support/YAMLTraits.cpp index de7da63609e..5f0cedc7182 100644 --- a/lib/Support/YAMLTraits.cpp +++ b/lib/Support/YAMLTraits.cpp @@ -388,7 +388,7 @@ std::unique_ptr Input::createHNodes(Node *N) { break; SQHNode->Entries.push_back(std::move(Entry)); } - return SQHNode; + return std::move(SQHNode); } else if (MappingNode *Map = dyn_cast(N)) { auto mapHNode = std::make_unique(N); for (KeyValueNode &KVN : *Map) { @@ -413,7 +413,7 @@ std::unique_ptr Input::createHNodes(Node *N) { break; mapHNode->Mapping[KeyStr] = std::move(ValueHNode); } - return mapHNode; + return std::move(mapHNode); } else if (isa(N)) { return std::make_unique(N); } else { diff --git a/lib/TableGen/JSONBackend.cpp b/lib/TableGen/JSONBackend.cpp index b2e6be6a04f..196644cda66 100644 --- a/lib/TableGen/JSONBackend.cpp +++ b/lib/TableGen/JSONBackend.cpp @@ -54,7 +54,7 @@ json::Value JSONEmitter::translateInit(const Init &I) { json::Array array; for (unsigned i = 0, limit = Bits->getNumBits(); i < limit; i++) array.push_back(translateInit(*Bits->getBit(i))); - return array; + return std::move(array); } else if (auto *Int = dyn_cast(&I)) { return Int->getValue(); } else if (auto *Str = dyn_cast(&I)) { @@ -65,7 +65,7 @@ json::Value JSONEmitter::translateInit(const Init &I) { json::Array array; for (auto val : *List) array.push_back(translateInit(*val)); - return array; + return std::move(array); } // Init subclasses that we return as JSON objects containing a @@ -79,17 +79,17 @@ json::Value JSONEmitter::translateInit(const Init &I) { if (auto *Def = dyn_cast(&I)) { obj["kind"] = "def"; obj["def"] = Def->getDef()->getName(); - return obj; + return std::move(obj); } else if (auto *Var = dyn_cast(&I)) { obj["kind"] = "var"; obj["var"] = Var->getName(); - return obj; + return std::move(obj); } else if (auto *VarBit = dyn_cast(&I)) { if (auto *Var = dyn_cast(VarBit->getBitVar())) { obj["kind"] = "varbit"; obj["var"] = Var->getName(); obj["index"] = VarBit->getBitNum(); - return obj; + return std::move(obj); } } else if (auto *Dag = dyn_cast(&I)) { obj["kind"] = "dag"; @@ -107,7 +107,7 @@ json::Value JSONEmitter::translateInit(const Init &I) { args.push_back(std::move(arg)); } obj["args"] = std::move(args); - return obj; + return std::move(obj); } // Final fallback: anything that gets past here is simply given a @@ -116,7 +116,7 @@ json::Value JSONEmitter::translateInit(const Init &I) { assert(!I.isConcrete()); obj["kind"] = "complex"; - return obj; + return std::move(obj); } void JSONEmitter::run(raw_ostream &OS) { diff --git a/lib/TextAPI/ELF/TBEHandler.cpp b/lib/TextAPI/ELF/TBEHandler.cpp index f1357e1112a..cb597d8896e 100644 --- a/lib/TextAPI/ELF/TBEHandler.cpp +++ b/lib/TextAPI/ELF/TBEHandler.cpp @@ -149,7 +149,7 @@ Expected> elfabi::readTBEFromBuffer(StringRef Buf) { if (std::error_code Err = YamlIn.error()) return createStringError(Err, "YAML failed reading as TBE"); - return Stub; + return std::move(Stub); } Error elfabi::writeTBEToOutputStream(raw_ostream &OS, const ELFStub &Stub) { diff --git a/lib/TextAPI/MachO/TextStub.cpp b/lib/TextAPI/MachO/TextStub.cpp index 2a99d35a5ab..cdfe7f47ee6 100644 --- a/lib/TextAPI/MachO/TextStub.cpp +++ b/lib/TextAPI/MachO/TextStub.cpp @@ -1122,7 +1122,7 @@ TextAPIReader::get(MemoryBufferRef InputBuffer) { if (YAMLIn.error()) return make_error(Ctx.ErrorMessage, YAMLIn.error()); - return File; + return std::move(File); } Error TextAPIWriter::writeToStream(raw_ostream &OS, const InterfaceFile &File) { diff --git a/lib/Transforms/IPO/FunctionImport.cpp b/lib/Transforms/IPO/FunctionImport.cpp index a349020b323..55b5c0377f2 100644 --- a/lib/Transforms/IPO/FunctionImport.cpp +++ b/lib/Transforms/IPO/FunctionImport.cpp @@ -1154,7 +1154,7 @@ Expected FunctionImporter::importFunctions( // If modules were created with lazy metadata loading, materialize it // now, before linking it (otherwise this will be a noop). if (Error Err = SrcModule->materializeMetadata()) - return Err; + return std::move(Err); auto &ImportGUIDs = FunctionsToImportPerModule->second; // Find the globals to import @@ -1169,7 +1169,7 @@ Expected FunctionImporter::importFunctions( << SrcModule->getSourceFileName() << "\n"); if (Import) { if (Error Err = F.materialize()) - return Err; + return std::move(Err); if (EnableImportMetadata) { // Add 'thinlto_src_module' metadata for statistics and debugging. F.setMetadata( @@ -1191,7 +1191,7 @@ Expected FunctionImporter::importFunctions( << SrcModule->getSourceFileName() << "\n"); if (Import) { if (Error Err = GV.materialize()) - return Err; + return std::move(Err); ImportedGVCount += GlobalsToImport.insert(&GV); } } @@ -1205,11 +1205,11 @@ Expected FunctionImporter::importFunctions( << SrcModule->getSourceFileName() << "\n"); if (Import) { if (Error Err = GA.materialize()) - return Err; + return std::move(Err); // Import alias as a copy of its aliasee. GlobalObject *Base = GA.getBaseObject(); if (Error Err = Base->materialize()) - return Err; + return std::move(Err); auto *Fn = replaceAliasWithAliasee(SrcModule.get(), &GA); LLVM_DEBUG(dbgs() << "Is importing aliasee fn " << Base->getGUID() << " " << Base->getName() << " from " diff --git a/lib/XRay/FDRRecordProducer.cpp b/lib/XRay/FDRRecordProducer.cpp index 0a5ece55bee..479b710444b 100644 --- a/lib/XRay/FDRRecordProducer.cpp +++ b/lib/XRay/FDRRecordProducer.cpp @@ -101,8 +101,8 @@ FileBasedRecordProducer::findNextBufferExtent() { R = std::move(MetadataRecordOrErr.get()); RecordInitializer RI(E, OffsetPtr); if (auto Err = R->apply(RI)) - return Err; - return R; + return std::move(Err); + return std::move(R); } } } @@ -132,7 +132,7 @@ Expected> FileBasedRecordProducer::produce() { assert(isa(R.get())); auto BE = cast(R.get()); CurrentBufferBytes = BE->size(); - return R; + return std::move(R); } // @@ -172,7 +172,7 @@ Expected> FileBasedRecordProducer::produce() { RecordInitializer RI(E, OffsetPtr); if (auto Err = R->apply(RI)) - return Err; + return std::move(Err); // If we encountered a BufferExtents record, we should record the remaining // bytes for the current buffer, to determine when we should start ignoring @@ -191,7 +191,7 @@ Expected> FileBasedRecordProducer::produce() { CurrentBufferBytes -= OffsetPtr - PreReadOffset; } assert(R != nullptr); - return R; + return std::move(R); } } // namespace xray diff --git a/lib/XRay/FileHeaderReader.cpp b/lib/XRay/FileHeaderReader.cpp index e0cb40df206..6b6daf9deba 100644 --- a/lib/XRay/FileHeaderReader.cpp +++ b/lib/XRay/FileHeaderReader.cpp @@ -66,7 +66,7 @@ Expected readBinaryFormatHeader(DataExtractor &HeaderExtractor, // Manually advance the offset pointer 16 bytes, after getting a raw memcpy // from the underlying data. OffsetPtr += 16; - return FileHeader; + return std::move(FileHeader); } } // namespace xray diff --git a/lib/XRay/InstrumentationMap.cpp b/lib/XRay/InstrumentationMap.cpp index 79c343fe8db..1e9b69a5f9d 100644 --- a/lib/XRay/InstrumentationMap.cpp +++ b/lib/XRay/InstrumentationMap.cpp @@ -232,26 +232,26 @@ llvm::xray::loadInstrumentationMap(StringRef Filename) { if (!FdOrErr) { // Report the ELF load error if YAML failed. consumeError(FdOrErr.takeError()); - return E; + return std::move(E); } uint64_t FileSize; if (sys::fs::file_size(Filename, FileSize)) - return E; + return std::move(E); // If the file is empty, we return the original error. if (FileSize == 0) - return E; + return std::move(E); // From this point on the errors will be only for the YAML parts, so we // consume the errors at this point. consumeError(std::move(E)); if (auto E = loadYAML(*FdOrErr, FileSize, Filename, Map.Sleds, Map.FunctionAddresses, Map.FunctionIds)) - return E; + return std::move(E); } else if (auto E = loadObj(Filename, *ObjectFileOrError, Map.Sleds, Map.FunctionAddresses, Map.FunctionIds)) { - return E; + return std::move(E); } return Map; } diff --git a/lib/XRay/Profile.cpp b/lib/XRay/Profile.cpp index 8aa8eaf9b74..c1a43632b60 100644 --- a/lib/XRay/Profile.cpp +++ b/lib/XRay/Profile.cpp @@ -90,7 +90,7 @@ static Expected> readPath(DataExtractor &Extractor, CurrentOffset = Offset; Path.push_back(FuncId); } while (FuncId != 0); - return Path; + return std::move(Path); } static Expected readData(DataExtractor &Extractor, @@ -137,7 +137,7 @@ Expected> Profile::expandPath(PathID P) const { std::vector Path; for (auto Node = It->second; Node; Node = Node->Caller) Path.push_back(Node->Func); - return Path; + return std::move(Path); } Profile::PathID Profile::internPath(ArrayRef P) { @@ -308,7 +308,7 @@ Expected loadProfile(StringRef Filename) { if (auto E = P.addBlock(Profile::Block{Profile::ThreadID{Header.Thread}, {{P.internPath(Path), std::move(Data)}}})) - return E; + return std::move(E); } return P; @@ -393,7 +393,7 @@ Expected profileFromTrace(const Trace &T) { std::vector>( PathsData.begin(), PathsData.end()), })) - return E; + return std::move(E); } return P; diff --git a/lib/XRay/Trace.cpp b/lib/XRay/Trace.cpp index 48c6fc9039a..4f107e1059c 100644 --- a/lib/XRay/Trace.cpp +++ b/lib/XRay/Trace.cpp @@ -443,7 +443,7 @@ Expected llvm::xray::loadTrace(const DataExtractor &DE, bool Sort) { if (Version == 1 || Version == 2 || Version == 3) { if (auto E = loadNaiveFormatLog(DE.getData(), DE.isLittleEndian(), T.FileHeader, T.Records)) - return E; + return std::move(E); } else { return make_error( Twine("Unsupported version for Basic/Naive Mode logging: ") + @@ -455,7 +455,7 @@ Expected llvm::xray::loadTrace(const DataExtractor &DE, bool Sort) { if (Version >= 1 && Version <= 5) { if (auto E = loadFDRLog(DE.getData(), DE.isLittleEndian(), T.FileHeader, T.Records)) - return E; + return std::move(E); } else { return make_error( Twine("Unsupported version for FDR Mode logging: ") + Twine(Version), @@ -464,7 +464,7 @@ Expected llvm::xray::loadTrace(const DataExtractor &DE, bool Sort) { break; default: if (auto E = loadYAMLLog(DE.getData(), T.FileHeader, T.Records)) - return E; + return std::move(E); } if (Sort) @@ -472,5 +472,5 @@ Expected llvm::xray::loadTrace(const DataExtractor &DE, bool Sort) { return L.TSC < R.TSC; }); - return T; + return std::move(T); } diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 0aa58372dc2..4c83a959897 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -347,7 +347,7 @@ Expected BugDriver::executeProgram(const Module &Program, OutputFile, AdditionalLinkerArgs, SharedObjs, Timeout, MemoryLimit); if (Error E = RetVal.takeError()) - return E; + return std::move(E); if (*RetVal == -1) { errs() << ""; @@ -393,12 +393,12 @@ BugDriver::compileSharedObject(const std::string &BitcodeFile) { Expected FT = SafeInterpreter->OutputCode(BitcodeFile, OutputFile); if (Error E = FT.takeError()) - return E; + return std::move(E); std::string SharedObjectFile; if (Error E = cc->MakeSharedObject(OutputFile, *FT, SharedObjectFile, AdditionalLinkerArgs)) - return E; + return std::move(E); // Remove the intermediate C file sys::fs::remove(OutputFile); @@ -444,7 +444,7 @@ Expected BugDriver::diffProgram(const Module &Program, Expected Output = executeProgram(Program, "", BitcodeFile, SharedObject, nullptr); if (Error E = Output.takeError()) - return E; + return std::move(E); std::string Error; bool FilesDifferent = false; diff --git a/tools/bugpoint/ListReducer.h b/tools/bugpoint/ListReducer.h index e9445498b6b..04f2207a31e 100644 --- a/tools/bugpoint/ListReducer.h +++ b/tools/bugpoint/ListReducer.h @@ -49,7 +49,7 @@ template struct ListReducer { std::mt19937 randomness(0x6e5ea738); // Seed the random number generator Expected Result = doTest(TheList, empty); if (Error E = Result.takeError()) - return E; + return std::move(E); switch (*Result) { case KeepPrefix: if (TheList.size() == 1) // we are done, it's the base case and it fails @@ -122,7 +122,7 @@ template struct ListReducer { Expected Result = doTest(Prefix, Suffix); if (Error E = Result.takeError()) - return E; + return std::move(E); switch (*Result) { case KeepSuffix: // The property still holds. We can just drop the prefix elements, and @@ -185,7 +185,7 @@ template struct ListReducer { Expected Result = doTest(EmptyList, TestList); if (Error E = Result.takeError()) - return E; + return std::move(E); if (*Result == KeepSuffix) { // We can trim down the list! TheList.swap(TestList); diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index cd5eb19d3af..e69fe9ff6c1 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -82,7 +82,7 @@ ReduceMiscompilingPasses::doTest(std::vector &Prefix, Expected Diff = BD.diffProgram(BD.getProgram(), BitcodeResult, "", true /*delete bitcode*/); if (Error E = Diff.takeError()) - return E; + return std::move(E); if (*Diff) { outs() << " nope.\n"; if (Suffix.empty()) { @@ -123,7 +123,7 @@ ReduceMiscompilingPasses::doTest(std::vector &Prefix, // If the prefix maintains the predicate by itself, only keep the prefix! Diff = BD.diffProgram(BD.getProgram(), BitcodeResult, "", false); if (Error E = Diff.takeError()) - return E; + return std::move(E); if (*Diff) { outs() << " nope.\n"; sys::fs::remove(BitcodeResult); @@ -169,7 +169,7 @@ ReduceMiscompilingPasses::doTest(std::vector &Prefix, Diff = BD.diffProgram(BD.getProgram(), BitcodeResult, "", true /*delete bitcode*/); if (Error E = Diff.takeError()) - return E; + return std::move(E); if (*Diff) { outs() << " nope.\n"; return KeepSuffix; @@ -200,14 +200,14 @@ public: if (!Suffix.empty()) { Expected Ret = TestFuncs(Suffix); if (Error E = Ret.takeError()) - return E; + return std::move(E); if (*Ret) return KeepSuffix; } if (!Prefix.empty()) { Expected Ret = TestFuncs(Prefix); if (Error E = Ret.takeError()) - return E; + return std::move(E); if (*Ret) return KeepPrefix; } @@ -237,9 +237,9 @@ static Expected> testMergedProgram(const BugDriver &BD, // Execute the program. Expected Diff = BD.diffProgram(*Merged, "", "", false); if (Error E = Diff.takeError()) - return E; + return std::move(E); Broken = *Diff; - return Merged; + return std::move(Merged); } /// split functions in a Module into two groups: those that are under @@ -335,7 +335,7 @@ ExtractLoops(BugDriver &BD, Expected> New = testMergedProgram( BD, *ToOptimizeLoopExtracted, *ToNotOptimize, Failure); if (Error E = New.takeError()) - return E; + return std::move(E); if (!*New) return false; @@ -377,7 +377,7 @@ ExtractLoops(BugDriver &BD, Expected Result = TestFn(BD, std::move(ToOptimizeLoopExtracted), std::move(ToNotOptimize)); if (Error E = Result.takeError()) - return E; + return std::move(E); ToOptimizeLoopExtracted = std::move(TOLEBackup); ToNotOptimize = std::move(TNOBackup); @@ -462,14 +462,14 @@ public: if (!Suffix.empty()) { Expected Ret = TestFuncs(Suffix); if (Error E = Ret.takeError()) - return E; + return std::move(E); if (*Ret) return KeepSuffix; } if (!Prefix.empty()) { Expected Ret = TestFuncs(Prefix); if (Error E = Ret.takeError()) - return E; + return std::move(E); if (*Ret) return KeepPrefix; } @@ -556,7 +556,7 @@ ExtractBlocks(BugDriver &BD, Expected Ret = ReduceMiscompiledBlocks(BD, TestFn, MiscompiledFunctions) .TestFuncs(std::vector()); if (Error E = Ret.takeError()) - return E; + return std::move(E); if (*Ret) { Blocks.clear(); } else { @@ -564,7 +564,7 @@ ExtractBlocks(BugDriver &BD, ReduceMiscompiledBlocks(BD, TestFn, MiscompiledFunctions) .reduceList(Blocks); if (Error E = Ret.takeError()) - return E; + return std::move(E); if (Blocks.size() == OldSize) return false; } @@ -632,7 +632,7 @@ static Expected> DebugAMiscompilation( .reduceList(MiscompiledFunctions); if (Error E = Ret.takeError()) { errs() << "\n***Cannot reduce functions: "; - return E; + return std::move(E); } } outs() << "\n*** The following function" @@ -647,7 +647,7 @@ static Expected> DebugAMiscompilation( if (!BugpointIsInterrupted && !DisableLoopExtraction) { Expected Ret = ExtractLoops(BD, TestFn, MiscompiledFunctions); if (Error E = Ret.takeError()) - return E; + return std::move(E); if (*Ret) { // Okay, we extracted some loops and the problem still appears. See if // we can eliminate some of the created functions from being candidates. @@ -658,7 +658,7 @@ static Expected> DebugAMiscompilation( Ret = ReduceMiscompilingFunctions(BD, TestFn) .reduceList(MiscompiledFunctions); if (Error E = Ret.takeError()) - return E; + return std::move(E); outs() << "\n*** The following function" << (MiscompiledFunctions.size() == 1 ? " is" : "s are") @@ -671,7 +671,7 @@ static Expected> DebugAMiscompilation( if (!BugpointIsInterrupted && !DisableBlockExtraction) { Expected Ret = ExtractBlocks(BD, TestFn, MiscompiledFunctions); if (Error E = Ret.takeError()) - return E; + return std::move(E); if (*Ret) { // Okay, we extracted some blocks and the problem still appears. See if // we can eliminate some of the created functions from being candidates. @@ -681,7 +681,7 @@ static Expected> DebugAMiscompilation( Ret = ReduceMiscompilingFunctions(BD, TestFn) .reduceList(MiscompiledFunctions); if (Error E = Ret.takeError()) - return E; + return std::move(E); outs() << "\n*** The following function" << (MiscompiledFunctions.size() == 1 ? " is" : "s are") @@ -711,7 +711,7 @@ static Expected TestOptimizer(BugDriver &BD, std::unique_ptr Test, BD.EmitProgressBitcode(*Test, "pass-error", false); BD.setNewProgram(std::move(Test)); if (Error E = BD.debugOptimizerCrash()) - return E; + return std::move(E); return false; } outs() << "done.\n"; @@ -720,7 +720,7 @@ static Expected TestOptimizer(BugDriver &BD, std::unique_ptr Test, bool Broken; auto Result = testMergedProgram(BD, *Optimized, *Safe, Broken); if (Error E = Result.takeError()) - return E; + return std::move(E); if (auto New = std::move(*Result)) { outs() << (Broken ? " nope.\n" : " yup.\n"); // Delete the original and set the new program. @@ -987,7 +987,7 @@ static Expected TestCodeGenerator(BugDriver &BD, Expected SharedObject = BD.compileSharedObject(std::string(SafeModuleBC.str())); if (Error E = SharedObject.takeError()) - return E; + return std::move(E); FileRemover SharedObjectRemover(*SharedObject, !SaveTemps); @@ -996,7 +996,7 @@ static Expected TestCodeGenerator(BugDriver &BD, Expected Result = BD.diffProgram( BD.getProgram(), std::string(TestModuleBC.str()), *SharedObject, false); if (Error E = Result.takeError()) - return E; + return std::move(E); if (*Result) errs() << ": still failing!\n"; diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 2fc2d9bdf9b..d880aca044d 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -492,7 +492,7 @@ Expected LLC::ExecuteProgram(const std::string &Bitcode, OutputCode(Bitcode, OutputAsmFile, Timeout, MemoryLimit); FileRemover OutFileRemover(OutputAsmFile, !SaveTemps); if (Error E = FileKind.takeError()) - return E; + return std::move(E); std::vector CCArgs(ArgsForCC); CCArgs.insert(CCArgs.end(), SharedLibs.begin(), SharedLibs.end()); diff --git a/tools/dsymutil/BinaryHolder.cpp b/tools/dsymutil/BinaryHolder.cpp index ba3ecbeb295..31d32d8d8e8 100644 --- a/tools/dsymutil/BinaryHolder.cpp +++ b/tools/dsymutil/BinaryHolder.cpp @@ -197,7 +197,7 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename, } } if (Err) - return Err; + return std::move(Err); } if (OE.Objects.empty()) @@ -243,7 +243,7 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) { auto Err = OE.load(Filename, Verbose); if (Err) { ObjectCache.erase(Filename); - return Err; + return std::move(Err); } } diff --git a/tools/dsymutil/DebugMap.cpp b/tools/dsymutil/DebugMap.cpp index f6c3400b49b..41067106e02 100644 --- a/tools/dsymutil/DebugMap.cpp +++ b/tools/dsymutil/DebugMap.cpp @@ -142,7 +142,7 @@ DebugMap::parseYAMLDebugMap(StringRef InputFile, StringRef PrependPath, return EC; std::vector> Result; Result.push_back(std::move(Res)); - return Result; + return std::move(Result); } } // end namespace dsymutil diff --git a/tools/dsymutil/MachODebugMapParser.cpp b/tools/dsymutil/MachODebugMapParser.cpp index 087f514bfcd..83703fb13f0 100644 --- a/tools/dsymutil/MachODebugMapParser.cpp +++ b/tools/dsymutil/MachODebugMapParser.cpp @@ -391,7 +391,7 @@ ErrorOr>> MachODebugMapParser::parse() { if (shouldLinkArch(Archs, Object->getArchTriple().getArchName())) Results.push_back(parseOneBinary(*Object, BinaryPath)); - return Results; + return std::move(Results); } /// Interpret the STAB entries to fill the DebugMap. diff --git a/tools/dsymutil/dsymutil.cpp b/tools/dsymutil/dsymutil.cpp index fa5ac47ef40..6b2608160ae 100644 --- a/tools/dsymutil/dsymutil.cpp +++ b/tools/dsymutil/dsymutil.cpp @@ -279,7 +279,7 @@ static Expected getOptions(opt::InputArgList &Args) { } if (Error E = verifyOptions(Options)) - return E; + return std::move(E); return Options; } @@ -433,9 +433,9 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) { Path = DwarfFile + ".dSYM"; if (!Options.LinkOpts.NoOutput) { if (auto E = createBundleDir(Path)) - return E; + return std::move(E); if (auto E = createPlistFile(DwarfFile, Path, Options.Toolchain)) - return E; + return std::move(E); } sys::path::append(Path, "Contents", "Resources"); diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 3307facf7fa..639a6d1ec02 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -73,14 +73,14 @@ static Expected> openBitcodeFile(StringRef Path) { Expected> MemBufOrErr = errorOrToExpected(MemoryBuffer::getFileOrSTDIN(Path)); if (Error E = MemBufOrErr.takeError()) - return E; + return std::move(E); std::unique_ptr MemBuf = std::move(*MemBufOrErr); if (MemBuf->getBufferSize() & 3) return reportError( "Bitcode stream should be a multiple of 4 bytes in length"); - return MemBuf; + return std::move(MemBuf); } int main(int argc, char **argv) { diff --git a/tools/llvm-cfi-verify/lib/FileAnalysis.cpp b/tools/llvm-cfi-verify/lib/FileAnalysis.cpp index 8b0d257232f..d2b4db3b575 100644 --- a/tools/llvm-cfi-verify/lib/FileAnalysis.cpp +++ b/tools/llvm-cfi-verify/lib/FileAnalysis.cpp @@ -100,15 +100,15 @@ Expected FileAnalysis::Create(StringRef Filename) { // Init the rest of the object. if (auto InitResponse = Analysis.initialiseDisassemblyMembers()) - return InitResponse; + return std::move(InitResponse); if (auto SectionParseResponse = Analysis.parseCodeSections()) - return SectionParseResponse; + return std::move(SectionParseResponse); if (auto SymbolTableParseResponse = Analysis.parseSymbolTable()) - return SymbolTableParseResponse; + return std::move(SymbolTableParseResponse); - return Analysis; + return std::move(Analysis); } FileAnalysis::FileAnalysis(object::OwningBinary Binary) diff --git a/tools/llvm-cov/SourceCoverageView.cpp b/tools/llvm-cov/SourceCoverageView.cpp index c1c3fec709e..cd7395a1a87 100644 --- a/tools/llvm-cov/SourceCoverageView.cpp +++ b/tools/llvm-cov/SourceCoverageView.cpp @@ -69,7 +69,7 @@ CoveragePrinter::createOutputStream(StringRef Path, StringRef Extension, auto OS = CoveragePrinter::OwnedStream(RawStream); if (E) return errorCodeToError(E); - return OS; + return std::move(OS); } std::unique_ptr diff --git a/tools/llvm-cov/SourceCoverageViewHTML.cpp b/tools/llvm-cov/SourceCoverageViewHTML.cpp index 70f8f945476..1363e0a52c1 100644 --- a/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -295,7 +295,7 @@ CoveragePrinterHTML::createViewFile(StringRef Path, bool InToplevel) { emitPrelude(*OS.get(), Opts, getPathToStyle(ViewPath)); } - return OS; + return std::move(OS); } void CoveragePrinterHTML::closeViewFile(OwnedStream OS) { diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp index bd629905fc9..23513ef8fb4 100644 --- a/tools/llvm-dwp/llvm-dwp.cpp +++ b/tools/llvm-dwp/llvm-dwp.cpp @@ -499,7 +499,7 @@ getDWOFilenames(StringRef ExecFilename) { DWOPaths.push_back(std::move(DWOName)); } } - return DWOPaths; + return std::move(DWOPaths); } static Error write(MCStreamer &Out, ArrayRef Inputs) { diff --git a/tools/llvm-elfabi/ELFObjHandler.cpp b/tools/llvm-elfabi/ELFObjHandler.cpp index 420239a1631..124fffbb9cf 100644 --- a/tools/llvm-elfabi/ELFObjHandler.cpp +++ b/tools/llvm-elfabi/ELFObjHandler.cpp @@ -309,7 +309,7 @@ buildStub(const ELFObjectFile &ElfObj) { // Collect relevant .dynamic entries. DynamicEntries DynEnt; if (Error Err = populateDynamic(DynEnt, *DynTable)) - return Err; + return std::move(Err); // Get pointer to in-memory location of .dynstr section. Expected DynStrPtr = @@ -364,7 +364,7 @@ buildStub(const ELFObjectFile &ElfObj) { "when reading dynamic symbols"); } - return DestStub; + return std::move(DestStub); } Expected> readELFFile(MemoryBufferRef Buf) { diff --git a/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/tools/llvm-exegesis/lib/BenchmarkRunner.cpp index e93ab457c25..6981aaa46cd 100644 --- a/tools/llvm-exegesis/lib/BenchmarkRunner.cpp +++ b/tools/llvm-exegesis/lib/BenchmarkRunner.cpp @@ -139,7 +139,7 @@ Expected BenchmarkRunner::runConfiguration( auto Measurements = runMeasurements(Executor); if (Error E = Measurements.takeError()) { if (!E.isA()) - return E; + return std::move(E); InstrBenchmark.Error = toString(std::move(E)); return InstrBenchmark; } @@ -163,7 +163,7 @@ BenchmarkRunner::writeObjectFile(const BenchmarkCode &BC, SmallString<256> ResultPath; if (Error E = errorCodeToError( sys::fs::createTemporaryFile("snippet", "o", ResultFD, ResultPath))) - return E; + return std::move(E); raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/); assembleToStream(State.getExegesisTarget(), State.createTargetMachine(), BC.LiveIns, BC.Key.RegisterInitialValues, FillFunction, OFS); diff --git a/tools/llvm-exegesis/lib/Clustering.cpp b/tools/llvm-exegesis/lib/Clustering.cpp index e73d6ec8ec9..33a8e018f51 100644 --- a/tools/llvm-exegesis/lib/Clustering.cpp +++ b/tools/llvm-exegesis/lib/Clustering.cpp @@ -320,7 +320,7 @@ Expected InstructionBenchmarkClustering::create( InstructionBenchmarkClustering Clustering( Points, AnalysisClusteringEpsilon * AnalysisClusteringEpsilon); if (auto Error = Clustering.validateAndSetup()) { - return Error; + return std::move(Error); } if (Clustering.ErrorCluster_.PointIndices.size() == Points.size()) { return Clustering; // Nothing to cluster. diff --git a/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp b/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp index 3134d03685e..83a3f0183e3 100644 --- a/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp +++ b/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp @@ -49,7 +49,7 @@ Expected> LatencyBenchmarkRunner::runMeasurements( default: break; } - return Result; + return std::move(Result); } } // namespace exegesis diff --git a/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp b/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp index 9c7f7da1072..fea6dc95ce8 100644 --- a/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp +++ b/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp @@ -172,7 +172,7 @@ SerialSnippetGenerator::generateCodeTemplates( if (Results.empty()) return make_error( "No strategy found to make the execution serial"); - return Results; + return std::move(Results); } } // namespace exegesis diff --git a/tools/llvm-exegesis/lib/SnippetGenerator.cpp b/tools/llvm-exegesis/lib/SnippetGenerator.cpp index e7f95d07bf2..21932f416aa 100644 --- a/tools/llvm-exegesis/lib/SnippetGenerator.cpp +++ b/tools/llvm-exegesis/lib/SnippetGenerator.cpp @@ -73,7 +73,7 @@ Expected> SnippetGenerator::generateConfigurations( BC.Info = CT.Info; for (InstructionTemplate &IT : CT.Instructions) { if (auto error = randomizeUnsetVariables(State, ForbiddenRegs, IT)) - return error; + return std::move(error); BC.Key.Instructions.push_back(IT.build()); } if (CT.ScratchSpacePointerInReg) @@ -152,7 +152,7 @@ generateSelfAliasingCodeTemplates(const Instruction &Instr) { setRandomAliasing(SelfAliasing, IT, IT); } CT.Instructions.push_back(std::move(IT)); - return Result; + return std::move(Result); } Expected> @@ -163,7 +163,7 @@ generateUnconstrainedCodeTemplates(const Instruction &Instr, StringRef Msg) { CT.Info = std::string(formatv("{0}, repeating an unconstrained assignment", Msg)); CT.Instructions.emplace_back(&Instr); - return Result; + return std::move(Result); } std::mt19937 &randomGenerator() { diff --git a/tools/llvm-exegesis/lib/UopsBenchmarkRunner.cpp b/tools/llvm-exegesis/lib/UopsBenchmarkRunner.cpp index af5b977b470..b99b1c5e711 100644 --- a/tools/llvm-exegesis/lib/UopsBenchmarkRunner.cpp +++ b/tools/llvm-exegesis/lib/UopsBenchmarkRunner.cpp @@ -39,7 +39,7 @@ UopsBenchmarkRunner::runMeasurements(const FunctionExecutor &Executor) const { Result.push_back( BenchmarkMeasure::Create("NumMicroOps", *ExpectedCounterValue)); } - return Result; + return std::move(Result); } } // namespace exegesis diff --git a/tools/llvm-exegesis/lib/X86/Target.cpp b/tools/llvm-exegesis/lib/X86/Target.cpp index 876847b8c08..72553af823f 100644 --- a/tools/llvm-exegesis/lib/X86/Target.cpp +++ b/tools/llvm-exegesis/lib/X86/Target.cpp @@ -241,13 +241,13 @@ static Expected> generateLEATemplatesCommon( .str(); Result.push_back(std::move(CT)); if (Result.size() >= Opts.MaxConfigsPerOpcode) - return Result; + return std::move(Result); } } } } - return Result; + return std::move(Result); } namespace { diff --git a/tools/llvm-ifs/llvm-ifs.cpp b/tools/llvm-ifs/llvm-ifs.cpp index f653c3a94f5..3b0d2ee725f 100644 --- a/tools/llvm-ifs/llvm-ifs.cpp +++ b/tools/llvm-ifs/llvm-ifs.cpp @@ -215,7 +215,7 @@ static Expected> readInputFile(StringRef FilePath) { if (std::error_code Err = YamlIn.error()) return createStringError(Err, "Failed reading Interface Stub File."); - return Stub; + return std::move(Stub); } int writeTbdStub(const llvm::Triple &T, const std::set &Symbols, diff --git a/tools/llvm-jitlink/llvm-jitlink.cpp b/tools/llvm-jitlink/llvm-jitlink.cpp index df04a2e950a..26bcf46d60a 100644 --- a/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/tools/llvm-jitlink/llvm-jitlink.cpp @@ -238,8 +238,8 @@ public: std::unique_ptr Allocator( new JITLinkSlabAllocator(SlabSize, Err)); if (Err) - return Err; - return Allocator; + return std::move(Err); + return std::move(Allocator); } Expected> diff --git a/tools/llvm-mca/llvm-mca.cpp b/tools/llvm-mca/llvm-mca.cpp index a4b2514bbf9..06c1ce957f7 100644 --- a/tools/llvm-mca/llvm-mca.cpp +++ b/tools/llvm-mca/llvm-mca.cpp @@ -240,7 +240,7 @@ ErrorOr> getOutputStream() { auto Out = std::make_unique(OutputFilename, EC, sys::fs::OF_Text); if (!EC) - return Out; + return std::move(Out); return EC; } } // end of anonymous namespace diff --git a/tools/llvm-objcopy/COFF/Reader.cpp b/tools/llvm-objcopy/COFF/Reader.cpp index ad612af21fd..7be9cce2be3 100644 --- a/tools/llvm-objcopy/COFF/Reader.cpp +++ b/tools/llvm-objcopy/COFF/Reader.cpp @@ -207,15 +207,15 @@ Expected> COFFReader::create() const { } if (Error E = readExecutableHeaders(*Obj)) - return E; + return std::move(E); if (Error E = readSections(*Obj)) - return E; + return std::move(E); if (Error E = readSymbols(*Obj, IsBigObj)) - return E; + return std::move(E); if (Error E = setSymbolTargets(*Obj)) - return E; + return std::move(E); - return Obj; + return std::move(Obj); } } // end namespace coff diff --git a/tools/llvm-objcopy/CopyConfig.cpp b/tools/llvm-objcopy/CopyConfig.cpp index 42bddf7a97f..69d6180d86e 100644 --- a/tools/llvm-objcopy/CopyConfig.cpp +++ b/tools/llvm-objcopy/CopyConfig.cpp @@ -342,7 +342,7 @@ NameOrPattern::create(StringRef Pattern, MatchStyle MS, // a literal if the error reporting is non-fatal. if (!GlobOrErr) { if (Error E = ErrorCallback(GlobOrErr.takeError())) - return E; + return std::move(E); return create(Pattern, MatchStyle::Literal, ErrorCallback); } @@ -572,7 +572,7 @@ parseObjcopyOptions(ArrayRef ArgsArr, for (auto Arg : InputArgs.filtered(OBJCOPY_redefine_symbols)) if (Error E = addSymbolsToRenameFromFile(Config.SymbolsToRename, DC.Alloc, Arg->getValue())) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_rename_section)) { Expected SR = @@ -623,15 +623,15 @@ parseObjcopyOptions(ArrayRef ArgsArr, for (auto Arg : InputArgs.filtered(OBJCOPY_remove_section)) if (Error E = Config.ToRemove.addMatcher(NameOrPattern::create( Arg->getValue(), SectionMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_keep_section)) if (Error E = Config.KeepSection.addMatcher(NameOrPattern::create( Arg->getValue(), SectionMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_only_section)) if (Error E = Config.OnlySection.addMatcher(NameOrPattern::create( Arg->getValue(), SectionMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_add_section)) { StringRef ArgValue(Arg->getValue()); if (!ArgValue.contains('=')) @@ -671,67 +671,67 @@ parseObjcopyOptions(ArrayRef ArgsArr, for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbol)) if (Error E = Config.SymbolsToLocalize.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbols)) if (Error E = addSymbolsFromFile(Config.SymbolsToLocalize, DC.Alloc, Arg->getValue(), SymbolMatchStyle, ErrorCallback)) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_keep_global_symbol)) if (Error E = Config.SymbolsToKeepGlobal.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_keep_global_symbols)) if (Error E = addSymbolsFromFile(Config.SymbolsToKeepGlobal, DC.Alloc, Arg->getValue(), SymbolMatchStyle, ErrorCallback)) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_globalize_symbol)) if (Error E = Config.SymbolsToGlobalize.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_globalize_symbols)) if (Error E = addSymbolsFromFile(Config.SymbolsToGlobalize, DC.Alloc, Arg->getValue(), SymbolMatchStyle, ErrorCallback)) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_weaken_symbol)) if (Error E = Config.SymbolsToWeaken.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_weaken_symbols)) if (Error E = addSymbolsFromFile(Config.SymbolsToWeaken, DC.Alloc, Arg->getValue(), SymbolMatchStyle, ErrorCallback)) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_strip_symbol)) if (Error E = Config.SymbolsToRemove.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_strip_symbols)) if (Error E = addSymbolsFromFile(Config.SymbolsToRemove, DC.Alloc, Arg->getValue(), SymbolMatchStyle, ErrorCallback)) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_strip_unneeded_symbol)) if (Error E = Config.UnneededSymbolsToRemove.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_strip_unneeded_symbols)) if (Error E = addSymbolsFromFile(Config.UnneededSymbolsToRemove, DC.Alloc, Arg->getValue(), SymbolMatchStyle, ErrorCallback)) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbol)) if (Error E = Config.SymbolsToKeep.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbols)) if (Error E = addSymbolsFromFile(Config.SymbolsToKeep, DC.Alloc, Arg->getValue(), SymbolMatchStyle, ErrorCallback)) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(OBJCOPY_add_symbol)) Config.SymbolsToAdd.push_back(Arg->getValue()); @@ -788,7 +788,7 @@ parseObjcopyOptions(ArrayRef ArgsArr, "--extract-main-partition"); DC.CopyConfigs.push_back(std::move(Config)); - return DC; + return std::move(DC); } // ParseInstallNameToolOptions returns the config and sets the input arguments. @@ -839,7 +839,7 @@ parseInstallNameToolOptions(ArrayRef ArgsArr) { Config.OutputFilename = Positional[0]; DC.CopyConfigs.push_back(std::move(Config)); - return DC; + return std::move(DC); } // ParseStripOptions returns the config and sets the input arguments. If a @@ -915,22 +915,22 @@ parseStripOptions(ArrayRef ArgsArr, for (auto Arg : InputArgs.filtered(STRIP_keep_section)) if (Error E = Config.KeepSection.addMatcher(NameOrPattern::create( Arg->getValue(), SectionMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(STRIP_remove_section)) if (Error E = Config.ToRemove.addMatcher(NameOrPattern::create( Arg->getValue(), SectionMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(STRIP_strip_symbol)) if (Error E = Config.SymbolsToRemove.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); for (auto Arg : InputArgs.filtered(STRIP_keep_symbol)) if (Error E = Config.SymbolsToKeep.addMatcher(NameOrPattern::create( Arg->getValue(), SymbolMatchStyle, ErrorCallback))) - return E; + return std::move(E); if (!InputArgs.hasArg(STRIP_no_strip_all) && !Config.StripDebug && !Config.StripUnneeded && Config.DiscardMode == DiscardType::None && @@ -965,7 +965,7 @@ parseStripOptions(ArrayRef ArgsArr, if (Error E = ErrorCallback(createStringError( errc::invalid_argument, "'%s' was already specified", Filename.str().c_str()))) - return E; + return std::move(E); } Config.InputFilename = Filename; Config.OutputFilename = Filename; @@ -978,7 +978,7 @@ parseStripOptions(ArrayRef ArgsArr, return createStringError(errc::invalid_argument, "--preserve-dates requires a file"); - return DC; + return std::move(DC); } } // namespace objcopy diff --git a/tools/llvm-objcopy/ELF/Object.cpp b/tools/llvm-objcopy/ELF/Object.cpp index 691034f8136..14ac7bba24f 100644 --- a/tools/llvm-objcopy/ELF/Object.cpp +++ b/tools/llvm-objcopy/ELF/Object.cpp @@ -277,7 +277,7 @@ Expected IHexRecord::parse(StringRef Line) { "line is too short: %zu chars.", Line.size()); if (Error E = checkChars(Line)) - return E; + return std::move(E); IHexRecord Rec; size_t DataLen = checkedGetHex(Line.substr(1, 2)); @@ -293,7 +293,7 @@ Expected IHexRecord::parse(StringRef Line) { if (getChecksum(Line.drop_front(1)) != 0) return createStringError(errc::invalid_argument, "incorrect checksum."); if (Error E = checkRecord(Rec)) - return E; + return std::move(E); return Rec; } @@ -1665,7 +1665,7 @@ Expected> IHexReader::parse() const { if (!HasSections) return parseError(-1U, "no sections"); - return Records; + return std::move(Records); } std::unique_ptr IHexReader::create(bool /*EnsureSymtab*/) const { diff --git a/tools/llvm-objcopy/wasm/Reader.cpp b/tools/llvm-objcopy/wasm/Reader.cpp index 20443cc2253..13fa84ad802 100644 --- a/tools/llvm-objcopy/wasm/Reader.cpp +++ b/tools/llvm-objcopy/wasm/Reader.cpp @@ -25,7 +25,7 @@ Expected> Reader::create() const { Obj->Sections.push_back( {static_cast(WS.Type), WS.Name, WS.Content}); } - return Obj; + return std::move(Obj); } } // end namespace wasm diff --git a/tools/llvm-pdbutil/DumpOutputStyle.cpp b/tools/llvm-pdbutil/DumpOutputStyle.cpp index 63dc4610c7f..32448cec88f 100644 --- a/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -429,7 +429,7 @@ static Expected getModuleDebugStream(PDBFile &File, return make_error(raw_error_code::corrupt_file, "Invalid module stream"); - return ModS; + return std::move(ModS); } template diff --git a/tools/llvm-pdbutil/InputFile.cpp b/tools/llvm-pdbutil/InputFile.cpp index 7a5dfd32d58..b316882de64 100644 --- a/tools/llvm-pdbutil/InputFile.cpp +++ b/tools/llvm-pdbutil/InputFile.cpp @@ -60,7 +60,7 @@ getModuleDebugStream(PDBFile &File, StringRef &ModuleName, uint32_t Index) { return make_error(raw_error_code::corrupt_file, "Invalid module stream"); - return ModS; + return std::move(ModS); } static inline bool isCodeViewDebugSubsection(object::SectionRef Section, @@ -269,18 +269,18 @@ Expected InputFile::open(StringRef Path, bool AllowUnknownFile) { IF.CoffObject = std::move(*BinaryOrErr); IF.PdbOrObj = llvm::cast(IF.CoffObject.getBinary()); - return IF; + return std::move(IF); } if (Magic == file_magic::pdb) { std::unique_ptr Session; if (auto Err = loadDataForPDB(PDB_ReaderType::Native, Path, Session)) - return Err; + return std::move(Err); IF.PdbSession.reset(static_cast(Session.release())); IF.PdbOrObj = &IF.PdbSession->getPDBFile(); - return IF; + return std::move(IF); } if (!AllowUnknownFile) @@ -295,7 +295,7 @@ Expected InputFile::open(StringRef Path, bool AllowUnknownFile) { IF.UnknownFile = std::move(*Result); IF.PdbOrObj = IF.UnknownFile.get(); - return IF; + return std::move(IF); } PDBFile &InputFile::pdb() { diff --git a/tools/llvm-rc/ResourceScriptParser.cpp b/tools/llvm-rc/ResourceScriptParser.cpp index 62adb512566..36b305645fb 100644 --- a/tools/llvm-rc/ResourceScriptParser.cpp +++ b/tools/llvm-rc/ResourceScriptParser.cpp @@ -19,7 +19,7 @@ // Take an expression returning llvm::Error and forward the error if it exists. #define RETURN_IF_ERROR(Expr) \ if (auto Err = (Expr)) \ - return Err; + return std::move(Err); // Take an expression returning llvm::Expected and assign it to Var or // forward the error out of the function. @@ -295,7 +295,7 @@ Expected> RCParser::readIntsWithCommas(size_t MinCount, auto FailureHandler = [&](llvm::Error Err) -> Expected> { if (Result.size() < MinCount) - return Err; + return std::move(Err); consumeError(std::move(Err)); return Result; }; @@ -315,7 +315,7 @@ Expected> RCParser::readIntsWithCommas(size_t MinCount, return FailureHandler(IntResult.takeError()); } - return Result; + return std::move(Result); } Expected RCParser::parseFlags(ArrayRef FlagDesc, @@ -386,7 +386,7 @@ RCParser::parseOptionalStatements(OptStmtType StmtsType) { Result.addStmt(std::move(*SingleParse)); } - return Result; + return std::move(Result); } Expected> @@ -442,7 +442,7 @@ RCParser::ParseType RCParser::parseAcceleratorsResource() { Accels->addAccelerator(*EventResult, *IDResult, *FlagsResult); } - return Accels; + return std::move(Accels); } RCParser::ParseType RCParser::parseCursorResource() { @@ -484,7 +484,7 @@ RCParser::ParseType RCParser::parseDialogResource(bool IsExtended) { Dialog->addControl(std::move(*ControlDefResult)); } - return Dialog; + return std::move(Dialog); } RCParser::ParseType RCParser::parseUserDefinedResource(IntOrString Type) { @@ -679,7 +679,7 @@ Expected RCParser::parseMenuItemsList() { std::make_unique(*CaptionResult, MenuResult, *FlagsResult)); } - return List; + return std::move(List); } RCParser::ParseType RCParser::parseStringTableResource() { @@ -702,7 +702,7 @@ RCParser::ParseType RCParser::parseStringTableResource() { Table->addString(*IDResult, *StrResult); } - return Table; + return std::move(Table); } Expected> @@ -718,7 +718,7 @@ RCParser::parseVersionInfoBlockContents(StringRef BlockName) { consume(); // Consume BlockEnd. - return Contents; + return std::move(Contents); } Expected> RCParser::parseVersionInfoStmt() { diff --git a/tools/llvm-rc/ResourceScriptToken.cpp b/tools/llvm-rc/ResourceScriptToken.cpp index 3c88d904a99..17537478876 100644 --- a/tools/llvm-rc/ResourceScriptToken.cpp +++ b/tools/llvm-rc/ResourceScriptToken.cpp @@ -170,7 +170,7 @@ Expected> Tokenizer::run() { const size_t TokenStart = Pos; if (Error TokenError = consumeToken(TokenKind)) - return TokenError; + return std::move(TokenError); // Comments are just deleted, don't bother saving them. if (TokenKind == Kind::LineComment || TokenKind == Kind::StartComment) diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index eda064a1162..4dd4e4129c2 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -1087,7 +1087,7 @@ ELFDumper::getSymbolVersionByIndex(uint32_t SymbolVersionIndex, // Lookup this symbol in the version table. if (Error E = LoadVersionMap()) - return E; + return std::move(E); if (VersionIndex >= VersionMap.size() || !VersionMap[VersionIndex]) return createError("SHT_GNU_versym section refers to a version index " + Twine(VersionIndex) + " which is missing"); diff --git a/tools/obj2yaml/elf2yaml.cpp b/tools/obj2yaml/elf2yaml.cpp index b6a8395f237..d399b95c1cf 100644 --- a/tools/obj2yaml/elf2yaml.cpp +++ b/tools/obj2yaml/elf2yaml.cpp @@ -218,13 +218,13 @@ template Expected ELFDumper::dump() { if (SymTab) { Y->Symbols.emplace(); if (Error E = dumpSymbols(SymTab, *Y->Symbols)) - return E; + return std::move(E); } if (DynSymTab) { Y->DynamicSymbols.emplace(); if (Error E = dumpSymbols(DynSymTab, *Y->DynamicSymbols)) - return E; + return std::move(E); } for (const Elf_Shdr &Sec : Sections) { @@ -563,7 +563,7 @@ Expected ELFDumper::dumpStackSizesSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) @@ -596,7 +596,7 @@ Expected ELFDumper::dumpAddrsigSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) @@ -637,7 +637,7 @@ Expected ELFDumper::dumpLinkerOptionsSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) @@ -668,7 +668,7 @@ Expected ELFDumper::dumpDependentLibrariesSection(const Elf_Shdr *Shdr) { auto DL = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *DL)) - return E; + return std::move(E); Expected> ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) @@ -695,7 +695,7 @@ Expected ELFDumper::dumpCallGraphProfileSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); Expected> ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) @@ -751,7 +751,7 @@ Expected ELFDumper::dumpDynamicSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto DynTagsOrErr = Obj.template getSectionContentsAsArray(Shdr); if (!DynTagsOrErr) @@ -768,7 +768,7 @@ Expected ELFDumper::dumpRelocSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (auto E = dumpCommonRelocationSection(Shdr, *S)) - return E; + return std::move(E); auto SymTabOrErr = Obj.getSection(Shdr->sh_link); if (!SymTabOrErr) @@ -782,7 +782,7 @@ ELFDumper::dumpRelocSection(const Elf_Shdr *Shdr) { for (const Elf_Rel &Rel : *Rels) { ELFYAML::Relocation R; if (Error E = dumpRelocation(&Rel, SymTab, R)) - return E; + return std::move(E); S->Relocations.push_back(R); } } else { @@ -792,7 +792,7 @@ ELFDumper::dumpRelocSection(const Elf_Shdr *Shdr) { for (const Elf_Rela &Rel : *Rels) { ELFYAML::Relocation R; if (Error E = dumpRelocation(&Rel, SymTab, R)) - return E; + return std::move(E); R.Addend = Rel.r_addend; S->Relocations.push_back(R); } @@ -806,7 +806,7 @@ Expected ELFDumper::dumpRelrSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (auto E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); if (Expected> Relrs = Obj.relrs(Shdr)) { S->Entries.emplace(); @@ -830,7 +830,7 @@ Expected ELFDumper::dumpContentSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); unsigned SecIndex = Shdr - &Sections[0]; if (SecIndex != 0 || Shdr->sh_type != ELF::SHT_NULL) { @@ -854,7 +854,7 @@ Expected ELFDumper::dumpSymtabShndxSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto EntriesOrErr = Obj.template getSectionContentsAsArray(Shdr); if (!EntriesOrErr) @@ -869,7 +869,7 @@ Expected ELFDumper::dumpNoBitsSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); S->Size = Shdr->sh_size; return S.release(); @@ -880,7 +880,7 @@ Expected ELFDumper::dumpNoteSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) @@ -916,7 +916,7 @@ Expected ELFDumper::dumpHashSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) @@ -957,7 +957,7 @@ Expected ELFDumper::dumpGnuHashSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) @@ -1011,7 +1011,7 @@ ELFDumper::dumpVerdefSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); S->Info = Shdr->sh_info; @@ -1062,7 +1062,7 @@ ELFDumper::dumpSymverSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto VersionsOrErr = Obj.template getSectionContentsAsArray(Shdr); if (!VersionsOrErr) @@ -1081,7 +1081,7 @@ ELFDumper::dumpVerneedSection(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); S->Info = Shdr->sh_info; @@ -1154,7 +1154,7 @@ template Expected ELFDumper::dumpGroup(const Elf_Shdr *Shdr) { auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); // Get symbol with index sh_info. This symbol's name is the signature of the group. Expected SymbolName = getSymbolName(Shdr->sh_link, Shdr->sh_info); @@ -1190,7 +1190,7 @@ ELFDumper::dumpMipsABIFlags(const Elf_Shdr *Shdr) { "Section type is not SHT_MIPS_ABIFLAGS"); auto S = std::make_unique(); if (Error E = dumpCommonSection(Shdr, *S)) - return E; + return std::move(E); auto ContentOrErr = Obj.getSectionContents(Shdr); if (!ContentOrErr) diff --git a/tools/obj2yaml/macho2yaml.cpp b/tools/obj2yaml/macho2yaml.cpp index aff2d9442c3..0ee8814d35a 100644 --- a/tools/obj2yaml/macho2yaml.cpp +++ b/tools/obj2yaml/macho2yaml.cpp @@ -198,8 +198,8 @@ Expected> MachODumper::dump() { std::unique_ptr DICtx = DWARFContext::create(Obj); if (auto Err = dwarf2yaml(*DICtx, Y->DWARF)) - return Err; - return Y; + return std::move(Err); + return std::move(Y); } void MachODumper::dumpHeader(std::unique_ptr &Y) { diff --git a/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp b/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp index a9f2d3fff03..31a4247e27d 100644 --- a/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp +++ b/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp @@ -56,7 +56,7 @@ public: if (auto Sym = KV.second(Name, ExportedSymbolsOnly)) return Sym; else if (auto Err = Sym.takeError()) - return Err; + return std::move(Err); } return JITSymbol(nullptr); } diff --git a/utils/TableGen/GlobalISelEmitter.cpp b/utils/TableGen/GlobalISelEmitter.cpp index 726e4ab73f0..9a2f1a1b5ea 100644 --- a/utils/TableGen/GlobalISelEmitter.cpp +++ b/utils/TableGen/GlobalISelEmitter.cpp @@ -3817,7 +3817,7 @@ Expected GlobalISelEmitter::createAndImportSelDAGMatcher( if (auto Error = importChildMatcher(Rule, InsnMatcher, SrcChild, OperandIsAPointer, OperandIsImmArg, OpIdx++, TempOpIdx)) - return Error; + return std::move(Error); } } @@ -4083,7 +4083,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderer( auto InsertPtOrError = createAndImportSubInstructionRenderer( ++InsertPt, Rule, DstChild, TempRegID); if (auto Error = InsertPtOrError.takeError()) - return Error; + return std::move(Error); return InsertPtOrError.get(); } @@ -4162,7 +4162,7 @@ Expected GlobalISelEmitter::createAndImportInstructionRenderer( const TreePatternNode *Dst) { auto InsertPtOrError = createInstructionRenderer(M.actions_end(), M, Dst); if (auto Error = InsertPtOrError.takeError()) - return Error; + return std::move(Error); action_iterator InsertPt = InsertPtOrError.get(); BuildMIAction &DstMIBuilder = *static_cast(InsertPt->get()); @@ -4182,7 +4182,7 @@ Expected GlobalISelEmitter::createAndImportInstructionRenderer( if (auto Error = importExplicitUseRenderers(InsertPt, M, DstMIBuilder, Dst) .takeError()) - return Error; + return std::move(Error); return DstMIBuilder; } @@ -4196,7 +4196,7 @@ GlobalISelEmitter::createAndImportSubInstructionRenderer( // TODO: Assert there's exactly one result. if (auto Error = InsertPtOrError.takeError()) - return Error; + return std::move(Error); BuildMIAction &DstMIBuilder = *static_cast(InsertPtOrError.get()->get()); @@ -4207,7 +4207,7 @@ GlobalISelEmitter::createAndImportSubInstructionRenderer( InsertPtOrError = importExplicitUseRenderers(InsertPtOrError.get(), M, DstMIBuilder, Dst); if (auto Error = InsertPtOrError.takeError()) - return Error; + return std::move(Error); // We need to make sure that when we import an INSERT_SUBREG as a // subinstruction that it ends up being constrained to the correct super @@ -4347,7 +4347,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderers( auto InsertPtOrError = createAndImportSubInstructionRenderer( ++InsertPt, M, ValChild, TempRegID); if (auto Error = InsertPtOrError.takeError()) - return Error; + return std::move(Error); DstMIBuilder.addRenderer(TempRegID, false, SubIdx); return InsertPt; @@ -4397,7 +4397,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderers( auto InsertPtOrError = importExplicitUseRenderer(InsertPt, M, DstMIBuilder, ValChild); if (auto Error = InsertPtOrError.takeError()) - return Error; + return std::move(Error); InsertPt = InsertPtOrError.get(); DstMIBuilder.addRenderer(SubIdx); } @@ -4458,7 +4458,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderers( DagInit *DefaultOps = DstIOperand.Rec->getValueAsDag("DefaultOps"); if (auto Error = importDefaultOperandRenderers( InsertPt, M, DstMIBuilder, DefaultOps)) - return Error; + return std::move(Error); ++NumDefaultOps; continue; } @@ -4466,7 +4466,7 @@ Expected GlobalISelEmitter::importExplicitUseRenderers( auto InsertPtOrError = importExplicitUseRenderer(InsertPt, M, DstMIBuilder, Dst->getChild(Child)); if (auto Error = InsertPtOrError.takeError()) - return Error; + return std::move(Error); InsertPt = InsertPtOrError.get(); ++Child; } @@ -4667,7 +4667,7 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { llvm::to_string(*P.getDstPattern())); if (auto Error = importRulePredicates(M, P.getPredicates())) - return Error; + return std::move(Error); // Next, analyze the pattern operators. TreePatternNode *Src = P.getSrcPattern(); @@ -4707,7 +4707,7 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { auto InsnMatcherOrError = createAndImportSelDAGMatcher(M, InsnMatcherTemp, Src, TempOpIdx); if (auto Error = InsnMatcherOrError.takeError()) - return Error; + return std::move(Error); InstructionMatcher &InsnMatcher = InsnMatcherOrError.get(); if (Dst->isLeaf()) { @@ -4735,7 +4735,7 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { // We're done with this pattern! It's eligible for GISel emission; return // it. ++NumPatternImported; - return M; + return std::move(M); } return failedImport("Dst pattern root isn't a known leaf"); @@ -4823,13 +4823,13 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { auto DstMIBuilderOrError = createAndImportInstructionRenderer(M, InsnMatcher, Src, Dst); if (auto Error = DstMIBuilderOrError.takeError()) - return Error; + return std::move(Error); BuildMIAction &DstMIBuilder = DstMIBuilderOrError.get(); // Render the implicit defs. // These are only added to the root of the result. if (auto Error = importImplicitDefRenderers(DstMIBuilder, P.getDstRegs())) - return Error; + return std::move(Error); DstMIBuilder.chooseInsnToMutate(M); @@ -4850,7 +4850,7 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { // We're done with this pattern! It's eligible for GISel emission; return // it. ++NumPatternImported; - return M; + return std::move(M); } if (DstIName == "EXTRACT_SUBREG") { @@ -4886,7 +4886,7 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { // We're done with this pattern! It's eligible for GISel emission; return // it. ++NumPatternImported; - return M; + return std::move(M); } if (DstIName == "INSERT_SUBREG") { @@ -4907,7 +4907,7 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { M.addAction(0, 1, **SuperClass); M.addAction(0, 2, **SubClass); ++NumPatternImported; - return M; + return std::move(M); } if (DstIName == "SUBREG_TO_REG") { @@ -4931,14 +4931,14 @@ Expected GlobalISelEmitter::runOnPattern(const PatternToMatch &P) { M.addAction(0, 0, **SuperClass); M.addAction(0, 2, **SubClass); ++NumPatternImported; - return M; + return std::move(M); } M.addAction(0); // We're done with this pattern! It's eligible for GISel emission; return it. ++NumPatternImported; - return M; + return std::move(M); } // Emit imm predicate table and an enum to reference them with.