Commit 55014e9d authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* src/sanity/style.test: Diagnose superfluous constructs such

as `if (x) delete x;'.
* iface/gspn/gspn.cc, iface/gspn/ssp.cc, src/ltlvisit/basicreduce.cc,
src/tgba/tgba.cc, src/tgba/tgbaproduct.cc, src/tgbaalgos/magic.cc,
src/tgbatest/ltl2tgba.cc: Remove such constructs.
parent 4654da9a
2004-10-29 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/sanity/style.test: Diagnose superfluous constructs such
as `if (x) delete x;'.
* iface/gspn/gspn.cc, iface/gspn/ssp.cc, src/ltlvisit/basicreduce.cc,
src/tgba/tgba.cc, src/tgba/tgbaproduct.cc, src/tgbaalgos/magic.cc,
src/tgbatest/ltl2tgba.cc: Remove such constructs.
* src/tgbatest/ltl2tgba.cc: Replace -e, -E, -m, -M, and -n by
-eALGO and -EALGO to ease the addition of new algorithms.
* src/tgbatest/emptchk.test, src/tgbatest/emptchke.test: Adjust.
......
......@@ -175,10 +175,8 @@ namespace spot
tgba_gspn_private_::~tgba_gspn_private_()
{
dict->unregister_all_my_variables(this);
if (last_state_conds_input)
delete last_state_conds_input;
if (all_indexes)
delete[] all_indexes;
delete last_state_conds_input;
delete[] all_indexes;
}
bdd index_to_bdd(AtomicProp index) const
......@@ -213,8 +211,7 @@ namespace spot
}
satisfy_free(cube);
if (last_state_conds_input)
delete last_state_conds_input;
delete last_state_conds_input;
last_state_conds_input = s->clone();
}
return last_state_conds_output;
......
......@@ -162,8 +162,7 @@ namespace spot
tgba_gspn_ssp_private_::~tgba_gspn_ssp_private_()
{
dict->unregister_all_my_variables(this);
if (all_props)
delete[] all_props;
delete[] all_props;
}
};
......
......@@ -509,11 +509,6 @@ namespace spot
destroy(*i);
}
/*
delete tmpFG;
tmpFG = 0;
*/
break;
}
......@@ -525,22 +520,21 @@ namespace spot
tmpOther->push_back(unop::instance(unop::X,
multop::instance(mo->op(),
tmpX)));
else if (tmpX)
else
delete tmpX;
if (tmpU && !tmpU->empty())
tmpOther->push_back(multop::instance(mo->op(), tmpU));
else if (tmpU)
else
delete tmpU;
if (tmpR && !tmpR->empty())
tmpOther->push_back(multop::instance(mo->op(), tmpR));
else if (tmpR)
else
delete tmpR;
if (tmpGF && !tmpGF->empty())
{
formula* ftmp
......@@ -550,7 +544,7 @@ namespace spot
tmpGF)));
tmpOther->push_back(ftmp);
}
else if (tmpGF)
else
delete tmpGF;
......@@ -569,14 +563,13 @@ namespace spot
multop::instance(mo->op(), tmpFG));
tmpOther->push_back(ftmp);
}
else if (tmpFG)
else
delete tmpFG;
result_ = multop::instance(op, tmpOther);
return;
}
protected:
......
......@@ -37,7 +37,7 @@ for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do
sed 's,[ ]*//.*,,' < $file > $tmp
grep '[ ]$' $tmp &&
diag 'Trailing space or tab.'
diag 'Trailing whitespace.'
grep '[ ]if(' $tmp &&
diag 'Missing space after "if"'
......@@ -137,6 +137,14 @@ for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do
grep '[^a-zA-Z0-9_](\*[a-zA-Z0-9_]*)\.' $tmp &&
diag 'Use "x->y", not "(*x).y"'
res=`perl -ne '$/ = undef;
print "$&\n"
while /if \((.*)(\s*==\s*0)?\)\s*delete(\[\])?\s+\1;(?!\s+else)/g' $tmp`
if test -n "$res"; then
echo "$res"
diag 'No "if (x)" required before "delete x;".'
fi
case $file in
*.hh | *.hxx)
if egrep '(cout|cerr|clog)' $tmp >/dev/null; then
......
......@@ -31,10 +31,8 @@ namespace spot
tgba::~tgba()
{
if (last_support_conditions_input_)
delete last_support_conditions_input_;
if (last_support_variables_input_)
delete last_support_variables_input_;
delete last_support_conditions_input_;
delete last_support_variables_input_;
}
bdd
......@@ -43,10 +41,8 @@ namespace spot
if (!last_support_conditions_input_
|| last_support_conditions_input_->compare(state) != 0)
{
last_support_conditions_output_ =
compute_support_conditions(state);
if (last_support_conditions_input_)
delete last_support_conditions_input_;
last_support_conditions_output_ = compute_support_conditions(state);
delete last_support_conditions_input_;
last_support_conditions_input_ = state->clone();
}
return last_support_conditions_output_;
......@@ -58,10 +54,8 @@ namespace spot
if (!last_support_variables_input_
|| last_support_variables_input_->compare(state) != 0)
{
last_support_variables_output_ =
compute_support_variables(state);
if (last_support_variables_input_)
delete last_support_variables_input_;
last_support_variables_output_ = compute_support_variables(state);
delete last_support_variables_input_;
last_support_variables_input_ = state->clone();
}
return last_support_variables_output_;
......
......@@ -81,8 +81,7 @@ namespace spot
tgba_succ_iterator_product::~tgba_succ_iterator_product()
{
delete left_;
if (right_)
delete right_;
delete right_;
}
void
......
......@@ -68,8 +68,7 @@ namespace spot
++s;
delete ptr;
}
if (x)
delete x;
delete x;
// Release all iterators on the stack.
while (!stack.empty())
{
......@@ -165,8 +164,7 @@ namespace spot
{
if (!has(s, true))
{
if (x)
delete x;
delete x;
x = s->clone();
push(s, true);
continue;
......
......@@ -116,8 +116,7 @@ syntax(char* prog)
<< " couvreur99" << std::endl
<< " couvreur99_shy" << std::endl
<< " magic_search" << std::endl
<< " magic_search_repeated" << std::endl
;
<< " magic_search_repeated" << std::endl;
exit(2);
}
......@@ -319,32 +318,34 @@ main(int argc, char** argv)
}
}
if (echeck_algo == "couvreur99")
if (echeck_algo != "")
{
echeck = Couvreur;
}
else if (echeck_algo == "couvreur99_shy")
{
echeck = Couvreur2;
}
else if (echeck_algo == "magic_search")
{
echeck = MagicSearch;
degeneralize_opt = true;
}
else if (echeck_algo == "magic_search_repeated")
{
echeck = MagicSearch;
degeneralize_opt = true;
magic_many = true;
}
else
{
std::cerr << "unknown emptiness-check: " << echeck_algo << std::endl;
syntax(argv[0]);
if (echeck_algo == "couvreur99")
{
echeck = Couvreur;
}
else if (echeck_algo == "couvreur99_shy")
{
echeck = Couvreur2;
}
else if (echeck_algo == "magic_search")
{
echeck = MagicSearch;
degeneralize_opt = true;
}
else if (echeck_algo == "magic_search_repeated")
{
echeck = MagicSearch;
degeneralize_opt = true;
magic_many = true;
}
else
{
std::cerr << "unknown emptiness-check: " << echeck_algo << std::endl;
syntax(argv[0]);
}
}
std::string input;
if (file_opt)
......@@ -591,13 +592,9 @@ main(int argc, char** argv)
if (f)
spot::ltl::destroy(f);
if (expl)
delete expl;
if (degeneralize_opt)
delete degeneralized;
if (aut_red)
delete aut_red;
delete expl;
delete degeneralized;
delete aut_red;
delete to_free;
}
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment