Skip to content

Commit

Permalink
[llvm][NFC] Use move instead of copy
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ccotter authored and CarlosAlbertoEnciso committed Feb 2, 2023
1 parent 51fbe75 commit c5f126c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/MC/MCParser/MasmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c5f126c

Please sign in to comment.