Skip to content

Commit

Permalink
Merge pull request #71 from Thomasb81/compilation_clean_up
Browse files Browse the repository at this point in the history
Compilation clean up warning gnu++11
  • Loading branch information
skieffer authored Feb 12, 2024
2 parents d00ce59 + 2a423a5 commit 1b6afc5
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 28 deletions.
8 changes: 4 additions & 4 deletions cola/libcola/cc_nonoverlapconstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ void NonOverlapConstraints::computeOverlapForShapePairInfo(ShapePairInfo& info,
{
COLA_ASSERT(shape1.halfDim[0] == 0);
COLA_ASSERT(shape1.halfDim[1] == 0);
COLA_ASSERT(info.varIndex1 + 1 < vs[0].size());
COLA_ASSERT(info.varIndex1 + 1U < vs[0].size());
right1 = vs[0][info.varIndex1 + 1]->finalPosition;
COLA_ASSERT(info.varIndex1 + 1 < vs[1].size());
COLA_ASSERT(info.varIndex1 + 1U < vs[1].size());
top1 = vs[1][info.varIndex1 + 1]->finalPosition;
left1 -= shape1.rectPadding.min(XDIM);
bottom1 -= shape1.rectPadding.min(YDIM);
Expand All @@ -218,9 +218,9 @@ void NonOverlapConstraints::computeOverlapForShapePairInfo(ShapePairInfo& info,
{
COLA_ASSERT(shape2.halfDim[0] == 0);
COLA_ASSERT(shape2.halfDim[1] == 0);
COLA_ASSERT(info.varIndex2 + 1 < vs[0].size());
COLA_ASSERT(info.varIndex2 + 1U < vs[0].size());
right2 = vs[0][info.varIndex2 + 1]->finalPosition;
COLA_ASSERT(info.varIndex2 + 1 < vs[1].size());
COLA_ASSERT(info.varIndex2 + 1U < vs[1].size());
top2 = vs[1][info.varIndex2 + 1]->finalPosition;
left2 -= shape2.rectPadding.min(XDIM);
bottom2 -= shape2.rectPadding.min(YDIM);
Expand Down
4 changes: 2 additions & 2 deletions cola/libdialect/chains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ BendSequences Chain::computePossibleBendSequences(void) const {
try {
CardinalDir dIn = m_graph->getSepMatrix().getCardinalDir(A->id(), b->id());
inDirs.push_back(dIn);
} catch (std::runtime_error) {
} catch (std::runtime_error const&) {
// In this case the left anchor edge is not yet aligned, so we get to consider
// both possible non-aggressive alignments of it.
inDirs = possibleCardinalDirections(A, b);
Expand All @@ -438,7 +438,7 @@ BendSequences Chain::computePossibleBendSequences(void) const {
try {
CardinalDir dOut = m_graph->getSepMatrix().getCardinalDir(y->id(), Z->id());
outDirs.push_back(dOut);
} catch (std::runtime_error) {
} catch (std::runtime_error const&) {
outDirs = possibleCardinalDirections(y, Z);
}
// Now we can look up the possible bend sequences.
Expand Down
8 changes: 6 additions & 2 deletions cola/libdialect/constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ SepDir dialect::negateSepDir(SepDir sd) {
return SepDir::RIGHT;
case SepDir::UP:
return SepDir::DOWN;
default :
COLA_ASSERT(false);
}
}

Expand Down Expand Up @@ -112,6 +114,8 @@ SepDir dialect::cardinalDirToSepDir(CardinalDir dir) {
return SepDir::WEST;
case CardinalDir::NORTH:
return SepDir::NORTH;
default:
COLA_ASSERT(false);
}
}

Expand Down Expand Up @@ -317,8 +321,8 @@ string SepPair::writeTglf(std::map<id_type, unsigned> id2ext, const SepMatrix &m
ygtStr = ygt == GapType::BDRY ? "B" : "C";
// Prepare indices.
unsigned src, tgt;
try { src = id2ext.at(this->src); } catch (std::out_of_range) { src = this->src; }
try { tgt = id2ext.at(this->tgt); } catch (std::out_of_range) { tgt = this->tgt; }
try { src = id2ext.at(this->src); } catch (std::out_of_range const&) { src = this->src; }
try { tgt = id2ext.at(this->tgt); } catch (std::out_of_range const&) { tgt = this->tgt; }
std::ostringstream ss;
// Vertically aligned
if (xgt == GapType::CENTRE && xst == SepType::EQ && xgap == 0) {
Expand Down
7 changes: 5 additions & 2 deletions cola/libdialect/graphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ LineSegment_SP BoundingBox::buildSideSegment(CardinalDir side) const {
return std::make_shared<LineSegment>(Point(x, Y), Point(X, Y));
case CardinalDir::NORTH:
return std::make_shared<LineSegment>(Point(x, y), Point(X, y));
default:
COLA_ASSERT(false);

}
}

Expand Down Expand Up @@ -826,7 +829,7 @@ bool Graph::hasSameLayoutAs(const Graph &other, double tol, id_map *idMap) const
++it; ++jt;
}
}
} catch (std::out_of_range) {
} catch (std::out_of_range const&) {
// We invoke the .at() method of various maps, above.
// If any of these fails, the two Graphs do not have the same layout.
return false;
Expand Down Expand Up @@ -1055,7 +1058,7 @@ bool Graph::applyProjSeq(const ColaOptions &opts, ProjSeq &ps, int accept) {
double iel = opts.idealEdgeLength;
if (iel == 0) iel = getIEL();
// Do stress computations iff iel >= 0.
double lastStress;
double lastStress = 0.0;
if (iel >= 0) lastStress = computeStress();
// We will check whether all projections work.
bool allOK = true;
Expand Down
15 changes: 9 additions & 6 deletions cola/libdialect/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ Graph_SP dialect::buildGraphFromTglf(istream &in) {
COLA_ASSERT(iss >> i1 >> i2 >> gtc >> dir >> rel1 >> rel2 >> gap);
id_type j1 = nodesByExternalId[i1]->id(),
j2 = nodesByExternalId[i2]->id();
GapType gt;
SepDir sd;
SepType st;
GapType gt{};
SepDir sd{};
SepType st{};
switch(gtc) {
case 'B': gt=GapType::BDRY; break;
case 'C': gt=GapType::CENTRE; break;
COLA_ASSERT(false);
default:
COLA_ASSERT(false);
}
switch(dir) {
case 'E': sd=SepDir::EAST; break;
Expand All @@ -127,12 +128,14 @@ Graph_SP dialect::buildGraphFromTglf(istream &in) {
case 'U': sd=SepDir::UP; break;
case 'X': sd=SepDir::RIGHT; break;
case 'Y': sd=SepDir::DOWN; break;
COLA_ASSERT(false);
default:
COLA_ASSERT(false);
}
switch(rel1) {
case '=': st=SepType::EQ; break;
case '>': st=SepType::INEQ; break;
COLA_ASSERT(false);
default:
COLA_ASSERT(false);
}
graph->getSepMatrix().addSep(j1, j2, gt, sd, st, gap);
break;
Expand Down
6 changes: 6 additions & 0 deletions cola/libdialect/ortho.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ Point Compass::vectorSigns(CompassDir d) {
case CompassDir::NW: return Point(-1, -1);
case CompassDir::NORTH: return Point( 0, -1);
case CompassDir::NE: return Point( 1, -1);
default:
COLA_ASSERT(false);
}
}

Expand Down Expand Up @@ -249,6 +251,8 @@ std::string Compass::dirToString(CompassDir d) {
case CompassDir::SW: return "SW";
case CompassDir::NW: return "NW";
case CompassDir::NE: return "NE";
default :
COLA_ASSERT(false);
}
}

Expand All @@ -258,6 +262,8 @@ std::string Compass::cardToString(CardinalDir d) {
case CardinalDir::SOUTH: return "SOUTH";
case CardinalDir::WEST: return "WEST";
case CardinalDir::NORTH: return "NORTH";
default:
COLA_ASSERT(false);
}
}

Expand Down
4 changes: 2 additions & 2 deletions cola/libdialect/quadaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ string Assignment::toString() const {
return s;
}

Quad::Quad(unsigned num) : num(num) {
Quad::Quad(unsigned int num) : num(num) {
// The only valid num's for quadrants are 0, 1, 2, 3.
COLA_ASSERT(0 <= num && num <= 3);
COLA_ASSERT(num <= 3);
}

void Quad::sortAndComputeCosts() {
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/quadaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct Quad {
//! @brief Standard constructor.
//!
//! @param[in] num The number of this quadrant in {0, 1, 2, 3}
Quad(unsigned num);
Quad(unsigned int num);

//! @brief Add a neighbour.
void addNbr(const Nbr_SP &nbr) { nbrs.push_back(nbr); }
Expand Down
6 changes: 4 additions & 2 deletions cola/libdialect/routing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ void RoutingAdapter::recordRoutes(bool refine) {
// in the window are within epsilon of one another (in both dimensions),
// we will skip both.
vector<Point> refined_pts;
size_t N = pts.size() - 2; // the number of interior points
size_t M = pts.size();
// We expect that there are at least two route points.
COLA_ASSERT(N >= 0);
COLA_ASSERT( M >= 2);
// the number of interior points:
size_t N = M - 2;
size_t i = 0;
// We always keep the first route point.
refined_pts.push_back(pts[0]);
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct Matrix2d {
std::string toString() const {
std::string s = "";
s += "\n ";
char buffer [10];
char buffer [21];
for (int j=0; j<cols; j++) {
sprintf(buffer," %2d",j);
s += std::string(buffer);
Expand Down
1 change: 1 addition & 0 deletions cola/libvpsc/rectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ inline bool checkIntersection(
ri.intersects=side=true;
sideX=intersection.x_;
sideY=intersection.y_;
return true;
case LineSegment::PARALLEL:
case LineSegment::NOT_INTERSECTING:
return true;
Expand Down
9 changes: 3 additions & 6 deletions cola/libvpsc/rectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,10 @@ class Rectangle {
*/
Rectangle(double x, double X, double y, double Y,
bool allowOverlap = false);
Rectangle(Rectangle const &Other)
: minX(Other.minX)
, maxX(Other.maxX)
, minY(Other.minY)
, maxY(Other.maxY)
, overlap(Other.overlap) { }
Rectangle(const Rectangle &Other) = default;
Rectangle();
~Rectangle() {}

bool isValid(void) const;
Rectangle unionWith(const Rectangle& rhs) const;
/*
Expand Down

0 comments on commit 1b6afc5

Please sign in to comment.