Fix -Wredundant-move warnings, 2nd try

std::move is redundant when it is used to return a local object from a function (eg return std::move(local)): indeed, returning a local object from a function implicitly moves it. Moreover using std::move this way
See https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rf-return-move-local
However, in order to avoid -Wreturn-std-move as well, a Base object is move-constructed
from Derived when required.
This commit is contained in:
howetuft
2019-11-16 10:41:05 +01:00
committed by wmayer
parent 5807ee2022
commit f1e3b7a166
6 changed files with 23 additions and 13 deletions

View File

@@ -236,7 +236,7 @@ TopoDS_Shape FaceMakerCheese::makeFace(const std::vector<TopoDS_Wire>& w)
builder.Add(comp, aFace);
}
return std::move(comp);
return TopoDS_Shape(std::move(comp));
}
else {
return TopoDS_Shape(); // error

View File

@@ -2222,7 +2222,7 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height,
TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edgeOnSurf);
BRepLib::BuildCurves3d(wire);
return std::move(wire);
return TopoDS_Shape(std::move(wire));
}
//***********
@@ -2308,7 +2308,7 @@ TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
TopoDS_Wire wire = mkWire.Wire();
BRepLib::BuildCurves3d(wire);
return std::move(wire);
return TopoDS_Shape(std::move(wire));
}
TopoDS_Shape TopoShape::makeThread(Standard_Real pitch,
@@ -2926,9 +2926,10 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
TopoDS_Compound result;
BRep_Builder builder;
builder.MakeCompound(result);
for(TopoDS_Shape &sh : shapesToReturn)
for(TopoDS_Shape &sh : shapesToReturn) {
builder.Add(result, sh);
return std::move(result);
}
return TopoDS_Shape(std::move(result));
}
else {
return shapesToReturn[0];
@@ -3175,7 +3176,7 @@ TopoDS_Shape TopoShape::removeSplitter() const
builder.Add(comp, xp.Current());
}
return std::move(comp);
return TopoDS_Shape(std::move(comp));
}
return _Shape;

View File

@@ -542,7 +542,7 @@ TopoDS_Shape PartGui::DlgProjectionOnSurface::create_compound(const std::vector<
}
}
}
return std::move(aCompound);
return TopoDS_Shape(std::move(aCompound));
}
void PartGui::DlgProjectionOnSurface::show_projected_shapes(const std::vector<SShapeStore>& iShapeStoreVec)

View File

@@ -1736,7 +1736,7 @@ TopoDS_Shape Area::toShape(CArea &area, short fill, int reorient) {
builder.Add(compound,s);\
}\
if(TopExp_Explorer(compound,TopAbs_EDGE).More())\
return std::move(compound);\
return TopoDS_Shape(std::move(compound));\
return TopoDS_Shape();\
}\
return mySections[_index]->_op(_index, ## __VA_ARGS__);\
@@ -1873,8 +1873,9 @@ TopoDS_Shape Area::makeOffset(int index,PARAM_ARGS(PARAM_FARG,AREA_PARAMS_OFFSET
}
if(thicken)
FC_DURATION_LOG(d,"Thicken");
if(TopExp_Explorer(compound,TopAbs_EDGE).More())
return std::move(compound);
if(TopExp_Explorer(compound,TopAbs_EDGE).More()) {
return TopoDS_Shape(std::move(compound));
}
return TopoDS_Shape();
}
@@ -2261,7 +2262,7 @@ TopoDS_Shape Area::toShape(const CArea &area, bool fill, const gp_Trsf *trsf, in
AREA_WARN("FaceMakerBullseye failed: "<<e.what());
}
}
return std::move(compound);
return TopoDS_Shape(std::move(compound));
}
struct WireInfo {

View File

@@ -66,14 +66,18 @@ void ExternalGeometryExtension::Restore(Base::XMLReader &reader)
std::unique_ptr<Part::GeometryExtension> ExternalGeometryExtension::copy(void) const
{
std::unique_ptr<ExternalGeometryExtension> cpy = std::make_unique<ExternalGeometryExtension>();
auto cpy = std::make_unique<ExternalGeometryExtension>();
cpy->Ref = this->Ref;
cpy->Flags = this->Flags;
cpy->setName(this->getName()); // Base Class
#if defined (__GNUC__) && (__GNUC__ <=4)
return std::move(cpy);
#else
return cpy;
#endif
}
PyObject * ExternalGeometryExtension::getPyObject(void)

View File

@@ -75,13 +75,17 @@ void SketchGeometryExtension::Restore(Base::XMLReader &reader)
std::unique_ptr<Part::GeometryExtension> SketchGeometryExtension::copy(void) const
{
std::unique_ptr<SketchGeometryExtension> cpy = std::make_unique<SketchGeometryExtension>();
auto cpy = std::make_unique<SketchGeometryExtension>();
cpy->Id = this->Id;
cpy->setName(this->getName()); // Base Class
#if defined (__GNUC__) && (__GNUC__ <=4)
return std::move(cpy);
#else
return cpy;
#endif
}
PyObject * SketchGeometryExtension::getPyObject(void)