54 changes: 27 additions & 27 deletions llvm/tools/llvm-objcopy/CopyConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -572,7 +572,7 @@ parseObjcopyOptions(ArrayRef<const char *> 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<SectionRename> SR =
Expand Down Expand Up @@ -623,15 +623,15 @@ parseObjcopyOptions(ArrayRef<const char *> 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('='))
Expand Down Expand Up @@ -671,67 +671,67 @@ parseObjcopyOptions(ArrayRef<const char *> 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());

Expand Down Expand Up @@ -788,7 +788,7 @@ parseObjcopyOptions(ArrayRef<const char *> 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.
Expand Down Expand Up @@ -839,7 +839,7 @@ parseInstallNameToolOptions(ArrayRef<const char *> 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
Expand Down Expand Up @@ -915,22 +915,22 @@ parseStripOptions(ArrayRef<const char *> 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 &&
Expand Down Expand Up @@ -965,7 +965,7 @@ parseStripOptions(ArrayRef<const char *> 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;
Expand All @@ -978,7 +978,7 @@ parseStripOptions(ArrayRef<const char *> ArgsArr,
return createStringError(errc::invalid_argument,
"--preserve-dates requires a file");

return DC;
return std::move(DC);
}

} // namespace objcopy
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-objcopy/ELF/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Expected<IHexRecord> 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<uint8_t>(Line.substr(1, 2));
Expand All @@ -293,7 +293,7 @@ Expected<IHexRecord> 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;
}

Expand Down Expand Up @@ -1665,7 +1665,7 @@ Expected<std::vector<IHexRecord>> IHexReader::parse() const {
if (!HasSections)
return parseError(-1U, "no sections");

return Records;
return std::move(Records);
}

std::unique_ptr<Object> IHexReader::create(bool /*EnsureSymtab*/) const {
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-objcopy/wasm/Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Expected<std::unique_ptr<Object>> Reader::create() const {
Obj->Sections.push_back(
{static_cast<uint8_t>(WS.Type), WS.Name, WS.Content});
}
return Obj;
return std::move(Obj);
}

} // end namespace wasm
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static Expected<ModuleDebugStreamRef> getModuleDebugStream(PDBFile &File,
return make_error<RawError>(raw_error_code::corrupt_file,
"Invalid module stream");

return ModS;
return std::move(ModS);
}

template <typename CallbackT>
Expand Down
10 changes: 5 additions & 5 deletions llvm/tools/llvm-pdbutil/InputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ getModuleDebugStream(PDBFile &File, StringRef &ModuleName, uint32_t Index) {
return make_error<RawError>(raw_error_code::corrupt_file,
"Invalid module stream");

return ModS;
return std::move(ModS);
}

static inline bool isCodeViewDebugSubsection(object::SectionRef Section,
Expand Down Expand Up @@ -269,18 +269,18 @@ Expected<InputFile> InputFile::open(StringRef Path, bool AllowUnknownFile) {

IF.CoffObject = std::move(*BinaryOrErr);
IF.PdbOrObj = llvm::cast<COFFObjectFile>(IF.CoffObject.getBinary());
return IF;
return std::move(IF);
}

if (Magic == file_magic::pdb) {
std::unique_ptr<IPDBSession> Session;
if (auto Err = loadDataForPDB(PDB_ReaderType::Native, Path, Session))
return Err;
return std::move(Err);

IF.PdbSession.reset(static_cast<NativeSession *>(Session.release()));
IF.PdbOrObj = &IF.PdbSession->getPDBFile();

return IF;
return std::move(IF);
}

if (!AllowUnknownFile)
Expand All @@ -295,7 +295,7 @@ Expected<InputFile> 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() {
Expand Down
18 changes: 9 additions & 9 deletions llvm/tools/llvm-rc/ResourceScriptParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> and assign it to Var or
// forward the error out of the function.
Expand Down Expand Up @@ -295,7 +295,7 @@ Expected<SmallVector<RCInt, 8>> RCParser::readIntsWithCommas(size_t MinCount,
auto FailureHandler =
[&](llvm::Error Err) -> Expected<SmallVector<RCInt, 8>> {
if (Result.size() < MinCount)
return Err;
return std::move(Err);
consumeError(std::move(Err));
return Result;
};
Expand All @@ -315,7 +315,7 @@ Expected<SmallVector<RCInt, 8>> RCParser::readIntsWithCommas(size_t MinCount,
return FailureHandler(IntResult.takeError());
}

return Result;
return std::move(Result);
}

Expected<uint32_t> RCParser::parseFlags(ArrayRef<StringRef> FlagDesc,
Expand Down Expand Up @@ -386,7 +386,7 @@ RCParser::parseOptionalStatements(OptStmtType StmtsType) {
Result.addStmt(std::move(*SingleParse));
}

return Result;
return std::move(Result);
}

Expected<std::unique_ptr<OptionalStmt>>
Expand Down Expand Up @@ -442,7 +442,7 @@ RCParser::ParseType RCParser::parseAcceleratorsResource() {
Accels->addAccelerator(*EventResult, *IDResult, *FlagsResult);
}

return Accels;
return std::move(Accels);
}

RCParser::ParseType RCParser::parseCursorResource() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -679,7 +679,7 @@ Expected<MenuDefinitionList> RCParser::parseMenuItemsList() {
std::make_unique<MenuItem>(*CaptionResult, MenuResult, *FlagsResult));
}

return List;
return std::move(List);
}

RCParser::ParseType RCParser::parseStringTableResource() {
Expand All @@ -702,7 +702,7 @@ RCParser::ParseType RCParser::parseStringTableResource() {
Table->addString(*IDResult, *StrResult);
}

return Table;
return std::move(Table);
}

Expected<std::unique_ptr<VersionInfoBlock>>
Expand All @@ -718,7 +718,7 @@ RCParser::parseVersionInfoBlockContents(StringRef BlockName) {

consume(); // Consume BlockEnd.

return Contents;
return std::move(Contents);
}

Expected<std::unique_ptr<VersionInfoStmt>> RCParser::parseVersionInfoStmt() {
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-rc/ResourceScriptToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Expected<std::vector<RCToken>> 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)
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-readobj/ELFDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ ELFDumper<ELFT>::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");
Expand Down
46 changes: 23 additions & 23 deletions llvm/tools/obj2yaml/elf2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ template <class ELFT> Expected<ELFYAML::Object *> ELFDumper<ELFT>::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) {
Expand Down Expand Up @@ -563,7 +563,7 @@ Expected<ELFYAML::StackSizesSection *>
ELFDumper<ELFT>::dumpStackSizesSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::StackSizesSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand Down Expand Up @@ -596,7 +596,7 @@ Expected<ELFYAML::AddrsigSection *>
ELFDumper<ELFT>::dumpAddrsigSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::AddrsigSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand Down Expand Up @@ -637,7 +637,7 @@ Expected<ELFYAML::LinkerOptionsSection *>
ELFDumper<ELFT>::dumpLinkerOptionsSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::LinkerOptionsSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand Down Expand Up @@ -668,7 +668,7 @@ Expected<ELFYAML::DependentLibrariesSection *>
ELFDumper<ELFT>::dumpDependentLibrariesSection(const Elf_Shdr *Shdr) {
auto DL = std::make_unique<ELFYAML::DependentLibrariesSection>();
if (Error E = dumpCommonSection(Shdr, *DL))
return E;
return std::move(E);

Expected<ArrayRef<uint8_t>> ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand All @@ -695,7 +695,7 @@ Expected<ELFYAML::CallGraphProfileSection *>
ELFDumper<ELFT>::dumpCallGraphProfileSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::CallGraphProfileSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

Expected<ArrayRef<uint8_t>> ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand Down Expand Up @@ -751,7 +751,7 @@ Expected<ELFYAML::DynamicSection *>
ELFDumper<ELFT>::dumpDynamicSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::DynamicSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto DynTagsOrErr = Obj.template getSectionContentsAsArray<Elf_Dyn>(Shdr);
if (!DynTagsOrErr)
Expand All @@ -768,7 +768,7 @@ Expected<ELFYAML::RelocationSection *>
ELFDumper<ELFT>::dumpRelocSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::RelocationSection>();
if (auto E = dumpCommonRelocationSection(Shdr, *S))
return E;
return std::move(E);

auto SymTabOrErr = Obj.getSection(Shdr->sh_link);
if (!SymTabOrErr)
Expand All @@ -782,7 +782,7 @@ ELFDumper<ELFT>::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 {
Expand All @@ -792,7 +792,7 @@ ELFDumper<ELFT>::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);
}
Expand All @@ -806,7 +806,7 @@ Expected<ELFYAML::RelrSection *>
ELFDumper<ELFT>::dumpRelrSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::RelrSection>();
if (auto E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

if (Expected<ArrayRef<Elf_Relr>> Relrs = Obj.relrs(Shdr)) {
S->Entries.emplace();
Expand All @@ -830,7 +830,7 @@ Expected<ELFYAML::RawContentSection *>
ELFDumper<ELFT>::dumpContentSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::RawContentSection>();
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) {
Expand All @@ -854,7 +854,7 @@ Expected<ELFYAML::SymtabShndxSection *>
ELFDumper<ELFT>::dumpSymtabShndxSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::SymtabShndxSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto EntriesOrErr = Obj.template getSectionContentsAsArray<Elf_Word>(Shdr);
if (!EntriesOrErr)
Expand All @@ -869,7 +869,7 @@ Expected<ELFYAML::NoBitsSection *>
ELFDumper<ELFT>::dumpNoBitsSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::NoBitsSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);
S->Size = Shdr->sh_size;

return S.release();
Expand All @@ -880,7 +880,7 @@ Expected<ELFYAML::NoteSection *>
ELFDumper<ELFT>::dumpNoteSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::NoteSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand Down Expand Up @@ -916,7 +916,7 @@ Expected<ELFYAML::HashSection *>
ELFDumper<ELFT>::dumpHashSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::HashSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand Down Expand Up @@ -957,7 +957,7 @@ Expected<ELFYAML::GnuHashSection *>
ELFDumper<ELFT>::dumpGnuHashSection(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::GnuHashSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand Down Expand Up @@ -1011,7 +1011,7 @@ ELFDumper<ELFT>::dumpVerdefSection(const Elf_Shdr *Shdr) {

auto S = std::make_unique<ELFYAML::VerdefSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

S->Info = Shdr->sh_info;

Expand Down Expand Up @@ -1062,7 +1062,7 @@ ELFDumper<ELFT>::dumpSymverSection(const Elf_Shdr *Shdr) {

auto S = std::make_unique<ELFYAML::SymverSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto VersionsOrErr = Obj.template getSectionContentsAsArray<Elf_Half>(Shdr);
if (!VersionsOrErr)
Expand All @@ -1081,7 +1081,7 @@ ELFDumper<ELFT>::dumpVerneedSection(const Elf_Shdr *Shdr) {

auto S = std::make_unique<ELFYAML::VerneedSection>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

S->Info = Shdr->sh_info;

Expand Down Expand Up @@ -1154,7 +1154,7 @@ template <class ELFT>
Expected<ELFYAML::Group *> ELFDumper<ELFT>::dumpGroup(const Elf_Shdr *Shdr) {
auto S = std::make_unique<ELFYAML::Group>();
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<StringRef> SymbolName = getSymbolName(Shdr->sh_link, Shdr->sh_info);
Expand Down Expand Up @@ -1190,7 +1190,7 @@ ELFDumper<ELFT>::dumpMipsABIFlags(const Elf_Shdr *Shdr) {
"Section type is not SHT_MIPS_ABIFLAGS");
auto S = std::make_unique<ELFYAML::MipsABIFlags>();
if (Error E = dumpCommonSection(Shdr, *S))
return E;
return std::move(E);

auto ContentOrErr = Obj.getSectionContents(Shdr);
if (!ContentOrErr)
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/obj2yaml/macho2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ Expected<std::unique_ptr<MachOYAML::Object>> MachODumper::dump() {

std::unique_ptr<DWARFContext> 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<MachOYAML::Object> &Y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MockObjectLayer {
if (auto Sym = KV.second(Name, ExportedSymbolsOnly))
return Sym;
else if (auto Err = Sym.takeError())
return Err;
return std::move(Err);
}
return JITSymbol(nullptr);
}
Expand Down
40 changes: 20 additions & 20 deletions llvm/utils/TableGen/GlobalISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3817,7 +3817,7 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
if (auto Error =
importChildMatcher(Rule, InsnMatcher, SrcChild, OperandIsAPointer,
OperandIsImmArg, OpIdx++, TempOpIdx))
return Error;
return std::move(Error);
}
}

Expand Down Expand Up @@ -4083,7 +4083,7 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderer(
auto InsertPtOrError = createAndImportSubInstructionRenderer(
++InsertPt, Rule, DstChild, TempRegID);
if (auto Error = InsertPtOrError.takeError())
return Error;
return std::move(Error);
return InsertPtOrError.get();
}

Expand Down Expand Up @@ -4162,7 +4162,7 @@ Expected<BuildMIAction &> 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<BuildMIAction *>(InsertPt->get());
Expand All @@ -4182,7 +4182,7 @@ Expected<BuildMIAction &> GlobalISelEmitter::createAndImportInstructionRenderer(

if (auto Error = importExplicitUseRenderers(InsertPt, M, DstMIBuilder, Dst)
.takeError())
return Error;
return std::move(Error);

return DstMIBuilder;
}
Expand All @@ -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<BuildMIAction *>(InsertPtOrError.get()->get());
Expand All @@ -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
Expand Down Expand Up @@ -4347,7 +4347,7 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
auto InsertPtOrError = createAndImportSubInstructionRenderer(
++InsertPt, M, ValChild, TempRegID);
if (auto Error = InsertPtOrError.takeError())
return Error;
return std::move(Error);

DstMIBuilder.addRenderer<TempRegRenderer>(TempRegID, false, SubIdx);
return InsertPt;
Expand Down Expand Up @@ -4397,7 +4397,7 @@ Expected<action_iterator> 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<SubRegIndexRenderer>(SubIdx);
}
Expand Down Expand Up @@ -4458,15 +4458,15 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
DagInit *DefaultOps = DstIOperand.Rec->getValueAsDag("DefaultOps");
if (auto Error = importDefaultOperandRenderers(
InsertPt, M, DstMIBuilder, DefaultOps))
return Error;
return std::move(Error);
++NumDefaultOps;
continue;
}

auto InsertPtOrError = importExplicitUseRenderer(InsertPt, M, DstMIBuilder,
Dst->getChild(Child));
if (auto Error = InsertPtOrError.takeError())
return Error;
return std::move(Error);
InsertPt = InsertPtOrError.get();
++Child;
}
Expand Down Expand Up @@ -4667,7 +4667,7 @@ Expected<RuleMatcher> 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();
Expand Down Expand Up @@ -4707,7 +4707,7 @@ Expected<RuleMatcher> 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()) {
Expand Down Expand Up @@ -4735,7 +4735,7 @@ Expected<RuleMatcher> 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");
Expand Down Expand Up @@ -4823,13 +4823,13 @@ Expected<RuleMatcher> 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);

Expand All @@ -4850,7 +4850,7 @@ Expected<RuleMatcher> 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") {
Expand Down Expand Up @@ -4886,7 +4886,7 @@ Expected<RuleMatcher> 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") {
Expand All @@ -4907,7 +4907,7 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
M.addAction<ConstrainOperandToRegClassAction>(0, 1, **SuperClass);
M.addAction<ConstrainOperandToRegClassAction>(0, 2, **SubClass);
++NumPatternImported;
return M;
return std::move(M);
}

if (DstIName == "SUBREG_TO_REG") {
Expand All @@ -4931,14 +4931,14 @@ Expected<RuleMatcher> GlobalISelEmitter::runOnPattern(const PatternToMatch &P) {
M.addAction<ConstrainOperandToRegClassAction>(0, 0, **SuperClass);
M.addAction<ConstrainOperandToRegClassAction>(0, 2, **SubClass);
++NumPatternImported;
return M;
return std::move(M);
}

M.addAction<ConstrainOperandsToDefinitionAction>(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.
Expand Down