Skip to content

Commit cc4323c

Browse files
authored
Change remaining hash_set -> unordered_set (cvc5#208)
The nightly competition build has been failing due to a remaining use of hash_set in approx_simplex.cpp. This commit changes the remaining uses of hash_set to unordered_set. The remaining uses of hash_set were in LFSC. Switching to C++11 for LFSC required changing the configure.ac for LFSC to require C++11 support to make sure that it can be compiled independently from the rest of CVC4 (some of our Travis tests do that as well). To have the macros for these additional checks available, the commit adds a symlink to the files in config that contain the macros). I did not find a way to add macros from a parent's folder that did not break `make distcheck
1 parent 08a2bc7 commit cc4323c

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

proofs/lfsc_checker/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ Makefile.in
1212
/aclocal.m4
1313
*~
1414
\#*\#
15-
/config/
1615
*.swp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../config/ax_cxx_compile_stdcxx.m4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../config/ax_cxx_compile_stdcxx_11.m4

proofs/lfsc_checker/configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ AC_DISABLE_STATIC
2727
AC_PROG_CXX
2828
AC_PROG_CC
2929

30+
# C++11 support in the compiler is now mandatory. Check for support and add
31+
# switches if necessary.
32+
AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
33+
3034
# Checks for libraries.
3135
# FIXME: Replace `main' with a function in `-lgmp':
3236
AC_CHECK_LIB([gmp], [__gmpz_init])

proofs/lfsc_checker/expr.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
#define sc2__expr_h
33

44
#include <stdint.h>
5-
#include <ext/hash_set>
65
#include <iostream>
76
#include <map>
87
#include <string>
8+
#include <unordered_set>
99
#include <vector>
10+
1011
#include "chunking_memory_management.h"
1112
#include "gmp.h"
1213

@@ -57,21 +58,17 @@ enum { NOT_CEXPR = 0, // for INT_EXPR, HOLE_EXPR, SYM_EXPR, SYMS_EXPR
5758
class Expr;
5859
class SymExpr;
5960

60-
namespace __gnu_cxx {
61-
template <>
62-
struct hash<Expr *> {
61+
struct hashExprPtr {
6362
size_t operator()(const Expr *x) const {
6463
return reinterpret_cast<uintptr_t>(x);
6564
}
6665
};
67-
}
6866

6967
struct eqExprPtr {
7068
bool operator()(const Expr *e1, const Expr *e2) const { return e1 == e2; }
7169
};
7270

73-
typedef __gnu_cxx::hash_set<Expr *, __gnu_cxx::hash<Expr *>, eqExprPtr>
74-
expr_ptr_set_t;
71+
typedef std::unordered_set<Expr *, hashExprPtr, eqExprPtr> expr_ptr_set_t;
7572

7673
class Expr {
7774
protected:

src/theory/arith/approx_simplex.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
**/
1717
#include "theory/arith/approx_simplex.h"
1818

19+
#include <math.h>
1920
#include <cfloat>
2021
#include <cmath>
21-
#include <map>
22-
#include <math.h>
22+
#include <unordered_set>
2323

2424
#include "base/output.h"
2525
#include "cvc4autoconfig.h"
@@ -2043,7 +2043,7 @@ bool ApproxGLPK::checkCutOnPad(int nid, const CutInfo& cut) const{
20432043

20442044
const DenseMap<Rational>& constructedLhs = d_pad.d_cut.lhs;
20452045
const Rational& constructedRhs = d_pad.d_cut.rhs;
2046-
hash_set<ArithVar> visited;
2046+
std::unordered_set<ArithVar> visited;
20472047

20482048
if(constructedLhs.empty()){
20492049
Debug("approx::checkCutOnPad") << "its empty?" <<endl;

0 commit comments

Comments
 (0)