[llvm] 6e3d129 - [llvm][NFC] Use move instead of copy
Michael Buch via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 1 09:41:06 PST 2023
Author: Chris Cotter
Date: 2023-02-01T17:40:27Z
New Revision: 6e3d12951dd7d3305f0e33e0aa4038cbd82f245a
URL: https://github.com/llvm/llvm-project/commit/6e3d12951dd7d3305f0e33e0aa4038cbd82f245a
DIFF: https://github.com/llvm/llvm-project/commit/6e3d12951dd7d3305f0e33e0aa4038cbd82f245a.diff
LOG: [llvm][NFC] Use move instead of copy
Summary: For functions that accept an rvalue reference type
parameter, use move to avoid copying the parameter.
These were found when implementing CppCoreGuideline F.18 in
clang-tidy.
Committed on behalf of ccotter (Chris Cotter)
Reviewers: Michael137 thieta
Differential Revision: https://reviews.llvm.org/D142825
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 0a67c4b6beb67..de050cd52572e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -488,10 +488,10 @@ void CodeViewDebug::recordLocalVariable(LocalVariable &&Var,
// This variable was inlined. Associate it with the InlineSite.
const DISubprogram *Inlinee = Var.DIVar->getScope()->getSubprogram();
InlineSite &Site = getInlineSite(InlinedAt, Inlinee);
- Site.InlinedLocals.emplace_back(Var);
+ Site.InlinedLocals.emplace_back(std::move(Var));
} else {
// This variable goes into the corresponding lexical scope.
- ScopeVariables[LS].emplace_back(Var);
+ ScopeVariables[LS].emplace_back(std::move(Var));
}
}
diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index 570dcab34fb96..5d09630c3a32b 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -151,14 +151,14 @@ struct IntFieldInfo {
IntFieldInfo() = default;
IntFieldInfo(const SmallVector<const MCExpr *, 1> &V) { Values = V; }
- IntFieldInfo(SmallVector<const MCExpr *, 1> &&V) { Values = V; }
+ IntFieldInfo(SmallVector<const MCExpr *, 1> &&V) { Values = std::move(V); }
};
struct RealFieldInfo {
SmallVector<APInt, 1> AsIntValues;
RealFieldInfo() = default;
RealFieldInfo(const SmallVector<APInt, 1> &V) { AsIntValues = V; }
- RealFieldInfo(SmallVector<APInt, 1> &&V) { AsIntValues = V; }
+ RealFieldInfo(SmallVector<APInt, 1> &&V) { AsIntValues = std::move(V); }
};
struct StructFieldInfo {
std::vector<StructInitializer> Initializers;
@@ -269,12 +269,12 @@ FieldInitializer::FieldInitializer(FieldType FT) : FT(FT) {
FieldInitializer::FieldInitializer(SmallVector<const MCExpr *, 1> &&Values)
: FT(FT_INTEGRAL) {
- new (&IntInfo) IntFieldInfo(Values);
+ new (&IntInfo) IntFieldInfo(std::move(Values));
}
FieldInitializer::FieldInitializer(SmallVector<APInt, 1> &&AsIntValues)
: FT(FT_REAL) {
- new (&RealInfo) RealFieldInfo(AsIntValues);
+ new (&RealInfo) RealFieldInfo(std::move(AsIntValues));
}
FieldInitializer::FieldInitializer(
More information about the llvm-commits
mailing list