summaryrefslogtreecommitdiff
path: root/src/proof
diff options
context:
space:
mode:
authorAndres Noetzli <noetzli@stanford.edu>2019-07-22 18:39:12 -0400
committerAina Niemetz <aina.niemetz@gmail.com>2019-07-22 15:39:12 -0700
commit5d203980cb011ce0a9aa5007d4792c1f80dd1e4b (patch)
tree2730abeaf4430217720d17aa3c5068901815291a /src/proof
parented8f4388c859595178e303f65393105e99d4eb59 (diff)
Avoid move constructor of std::fstream for GCC < 5 (#3098)
GCC < 5 does not support the move constructor of `std::fstream` (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54316 for details). This commit wraps the `std::fstream` in an `std::unique_ptr` to work around that issue.
Diffstat (limited to 'src/proof')
-rw-r--r--src/proof/clausal_bitvector_proof.cpp28
-rw-r--r--src/proof/er/er_proof.cpp19
-rw-r--r--src/proof/lrat/lrat_proof.cpp16
3 files changed, 32 insertions, 31 deletions
diff --git a/src/proof/clausal_bitvector_proof.cpp b/src/proof/clausal_bitvector_proof.cpp
index 9d6d0d193..4e700a832 100644
--- a/src/proof/clausal_bitvector_proof.cpp
+++ b/src/proof/clausal_bitvector_proof.cpp
@@ -144,25 +144,26 @@ void ClausalBitVectorProof::optimizeDratProof()
std::string optFormulaFilename("cvc4-optimized-formula-XXXXXX");
{
- std::fstream formStream = openTmpFile(&formulaFilename);
- const int64_t startPos = static_cast<int64_t>(formStream.tellp());
- printDimacs(formStream, d_clauses, d_originalClauseIndices);
+ std::unique_ptr<std::fstream> formStream = openTmpFile(&formulaFilename);
+ const int64_t startPos = static_cast<int64_t>(formStream->tellp());
+ printDimacs(*formStream, d_clauses, d_originalClauseIndices);
d_dratOptimizationStatistics.d_initialFormulaSize.setData(
- static_cast<int64_t>(formStream.tellp()) - startPos);
- formStream.close();
+ static_cast<int64_t>(formStream->tellp()) - startPos);
+ formStream->close();
}
{
- std::fstream dratStream = openTmpFile(&dratFilename);
- const int64_t startPos = static_cast<int64_t>(dratStream.tellp());
- dratStream << d_binaryDratProof.str();
+ std::unique_ptr<std::fstream> dratStream = openTmpFile(&dratFilename);
+ const int64_t startPos = static_cast<int64_t>(dratStream->tellp());
+ (*dratStream) << d_binaryDratProof.str();
d_dratOptimizationStatistics.d_initialDratSize.setData(
- static_cast<int64_t>(dratStream.tellp()) - startPos);
- dratStream.close();
+ static_cast<int64_t>(dratStream->tellp()) - startPos);
+ dratStream->close();
}
- std::fstream optDratStream = openTmpFile(&optDratFilename);
- std::fstream optFormulaStream = openTmpFile(&optFormulaFilename);
+ std::unique_ptr<std::fstream> optDratStream = openTmpFile(&optDratFilename);
+ std::unique_ptr<std::fstream> optFormulaStream =
+ openTmpFile(&optFormulaFilename);
#if CVC4_USE_DRAT2ER
{
@@ -204,7 +205,6 @@ void ClausalBitVectorProof::optimizeDratProof()
std::vector<prop::SatClause> core = parseDimacs(optFormulaStream);
d_dratOptimizationStatistics.d_optimizedFormulaSize.setData(
static_cast<int64_t>(optFormulaStream.tellg()) - startPos);
- optFormulaStream.close();
CodeTimer clauseMatchingTimer{
d_dratOptimizationStatistics.d_clauseMatchingTime};
@@ -241,7 +241,7 @@ void ClausalBitVectorProof::optimizeDratProof()
d_coreClauseIndices = d_originalClauseIndices;
}
- optFormulaStream.close();
+ optFormulaStream->close();
Assert(d_coreClauseIndices.size() > 0);
remove(formulaFilename.c_str());
diff --git a/src/proof/er/er_proof.cpp b/src/proof/er/er_proof.cpp
index ab07875b2..9f22e236b 100644
--- a/src/proof/er/er_proof.cpp
+++ b/src/proof/er/er_proof.cpp
@@ -91,16 +91,17 @@ ErProof ErProof::fromBinaryDratProof(
std::string tracecheckFilename("cvc4-tracecheck-er-XXXXXX");
// Write the formula
- std::fstream formStream = openTmpFile(&formulaFilename);
- printDimacs(formStream, clauses, usedIds);
- formStream.close();
+ std::unique_ptr<std::fstream> formStream = openTmpFile(&formulaFilename);
+ printDimacs(*formStream, clauses, usedIds);
+ formStream->close();
// Write the (binary) DRAT proof
- std::fstream dratStream = openTmpFile(&dratFilename);
- dratStream << dratBinary;
- dratStream.close();
+ std::unique_ptr<std::fstream> dratStream = openTmpFile(&dratFilename);
+ (*dratStream) << dratBinary;
+ dratStream->close();
- std::fstream tracecheckStream = openTmpFile(&tracecheckFilename);
+ std::unique_ptr<std::fstream> tracecheckStream =
+ openTmpFile(&tracecheckFilename);
// Invoke drat2er
{
@@ -120,9 +121,9 @@ ErProof ErProof::fromBinaryDratProof(
}
// Parse the resulting TRACECHECK proof into an ER proof.
- TraceCheckProof pf = TraceCheckProof::fromText(tracecheckStream);
+ TraceCheckProof pf = TraceCheckProof::fromText(*tracecheckStream);
ErProof proof(clauses, usedIds, std::move(pf));
- tracecheckStream.close();
+ tracecheckStream->close();
remove(formulaFilename.c_str());
remove(dratFilename.c_str());
diff --git a/src/proof/lrat/lrat_proof.cpp b/src/proof/lrat/lrat_proof.cpp
index 79a92fe73..1685ad1c3 100644
--- a/src/proof/lrat/lrat_proof.cpp
+++ b/src/proof/lrat/lrat_proof.cpp
@@ -135,15 +135,15 @@ LratProof LratProof::fromDratProof(
std::string dratFilename("cvc4-drat-XXXXXX");
std::string lratFilename("cvc4-lrat-XXXXXX");
- std::fstream formStream = openTmpFile(&formulaFilename);
- printDimacs(formStream, clauses, usedIds);
- formStream.close();
+ std::unique_ptr<std::fstream> formStream = openTmpFile(&formulaFilename);
+ printDimacs(*formStream, clauses, usedIds);
+ formStream->close();
- std::fstream dratStream = openTmpFile(&dratFilename);
- dratStream << dratBinary;
- dratStream.close();
+ std::unique_ptr<std::fstream> dratStream = openTmpFile(&dratFilename);
+ (*dratStream) << dratBinary;
+ dratStream->close();
- std::fstream lratStream = openTmpFile(&lratFilename);
+ std::unique_ptr<std::fstream> lratStream = openTmpFile(&lratFilename);
{
CodeTimer blockTimer{toolTimer};
@@ -157,7 +157,7 @@ LratProof LratProof::fromDratProof(
#endif
}
- LratProof lrat(lratStream);
+ LratProof lrat(*lratStream);
remove(formulaFilename.c_str());
remove(dratFilename.c_str());
remove(lratFilename.c_str());
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback