Commit 2beacc39 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

common: introduce SPOT_UNREACHABLE and SPOT_UNIMPLEMENTED.

* src/misc/common.hh (SPOT_UNIMPLEMENTED, SPOT_UNREACHABLE,
SPOT_UNREACHABLE_BUILTIN): New macros.
* src/bin/dstar2tgba.cc, src/bin/ltlcross.cc,
src/dstarparse/dstar2tgba.cc, src/eltlparse/eltlparse.yy,
src/ltlast/binop.cc, src/ltlast/bunop.cc, src/ltlast/constant.cc,
src/ltlast/formula_tree.cc, src/ltlast/multop.cc, src/ltlast/nfa.cc,
src/ltlast/unop.cc, src/ltlvisit/dotty.cc, src/ltlvisit/lbt.cc,
src/ltlvisit/lunabbrev.cc, src/ltlvisit/mark.cc,
src/ltlvisit/randomltl.cc, src/ltlvisit/simpfg.cc,
src/ltlvisit/simplify.cc, src/ltlvisit/snf.cc, src/ltlvisit/tostring.cc,
src/misc/intvcomp.cc, src/misc/minato.cc, src/tgba/bdddict.cc,
src/tgba/formula2bdd.cc, src/tgba/tgbasafracomplement.cc,
src/tgbaalgos/eltl2tgba_lacim.cc, src/tgbaalgos/ltl2taa.cc,
src/tgbaalgos/ltl2tgba_fm.cc, src/tgbaalgos/ltl2tgba_lacim.cc,
src/tgbaalgos/simulation.cc, src/tgbatest/ltl2tgba.cc:  Use them.
* src/sanity/style.test: Catch assert(0) and assert(!"text");
parent c93b41a2
......@@ -285,8 +285,7 @@ namespace
int
process_formula(const spot::ltl::formula*, const char*, int)
{
assert(!"should not happen");
return 0;
SPOT_UNREACHABLE();
}
......
......@@ -715,7 +715,7 @@ namespace
else if (*pos == 'D')
format = Dstar;
else
assert(!"BUG");
SPOT_UNREACHABLE();
if (val_)
{
......@@ -823,7 +823,7 @@ namespace
return string_ltl_wring;
if (!string_ltl_lbt.val().empty())
return string_ltl_lbt;
assert(!"None of the translators need the input formula?");
SPOT_UNREACHABLE();
return string_ltl_spot;
}
......@@ -997,7 +997,7 @@ namespace
break;
}
case printable_result_filename::None:
assert(!"unreachable code");
SPOT_UNREACHABLE();
}
}
......
// Copyright (C) 2013 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
// -*- coding: utf-8 -*-
// Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
......@@ -30,7 +31,6 @@ namespace spot
case spot::Streett:
return nsa_to_tgba(daut);
}
assert(!"unreachable code");
return 0;
SPOT_UNREACHABLE();
}
}
......@@ -138,10 +138,7 @@ namespace spot
res->rhs = realias(a->rhs, v);
return node_ptr(res);
}
/* Unreachable code. */
assert(0);
return node_ptr(static_cast<node_unop*>(0));
SPOT_UNREACHABLE();
}
}
}
......
......@@ -300,9 +300,7 @@ namespace spot
case UConcat:
return "UConcat";
}
// Unreachable code.
assert(0);
return 0;
SPOT_UNREACHABLE();
}
binop::map binop::instances;
......
......@@ -107,9 +107,7 @@ namespace spot
case Star:
return "Star";
}
// Unreachable code.
assert(0);
return 0;
SPOT_UNREACHABLE();
}
std::string
......
......@@ -100,9 +100,7 @@ namespace spot
case EmptyWord:
return "constant(e)";
}
// Unreachable code.
assert(0);
return "BUG";
SPOT_UNREACHABLE();
}
void
......@@ -123,9 +121,7 @@ namespace spot
case EmptyWord:
return "[*0]";
}
// Unreachable code.
assert(0);
return 0;
SPOT_UNREACHABLE();
}
}
}
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2012, 2013 Laboratoire de Recherche et
// Copyright (C) 2009, 2012, 2013, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -53,10 +53,7 @@ namespace spot
return multop::instance(n->op,
instanciate(n->lhs, v),
instanciate(n->rhs, v));
/* Unreachable code. */
assert(0);
return 0;
SPOT_UNREACHABLE();
}
size_t
......@@ -78,10 +75,7 @@ namespace spot
return std::max(arity(n->lhs), arity(n->rhs));
if (node_multop* n = dynamic_cast<node_multop*>(np.get()))
return std::max(arity(n->lhs), arity(n->rhs));
/* Unreachable code. */
assert(0);
return 0;
SPOT_UNREACHABLE();
}
}
}
......
......@@ -185,9 +185,7 @@ namespace spot
case Fusion:
return "Fusion";
}
// Unreachable code.
assert(0);
return 0;
SPOT_UNREACHABLE();
}
namespace
......
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2013 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
// Copyright (C) 2008, 2013, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
......@@ -106,8 +106,7 @@ namespace spot
const nfa::state*
nfa::get_init_state()
{
if (!init_)
assert(0);
assert(init_);
return init_;
}
......
......@@ -189,9 +189,7 @@ namespace spot
case NegClosureMarked:
return "NegClosureMarked";
}
// Unreachable code.
assert(0);
return 0;
SPOT_UNREACHABLE();
}
unop::map unop::instances;
......
......@@ -95,7 +95,7 @@ namespace spot
void
visit(const automatop*)
{
assert(0);
SPOT_UNIMPLEMENTED();
}
void
......
......@@ -94,7 +94,7 @@ namespace spot
os_ << 't';
break;
case constant::EmptyWord:
assert(!"unsupported constant");
SPOT_UNIMPLEMENTED();
break;
}
}
......@@ -129,7 +129,7 @@ namespace spot
case binop::UConcat:
case binop::EConcat:
case binop::EConcatMarked:
assert(!"unsupported operator");
SPOT_UNIMPLEMENTED();
break;
}
bo->first()->accept(*this);
......@@ -139,7 +139,7 @@ namespace spot
void
visit(const bunop*)
{
assert(!"unsupported operator");
SPOT_UNIMPLEMENTED();
}
void
......@@ -164,7 +164,7 @@ namespace spot
case unop::Closure:
case unop::NegClosure:
case unop::NegClosureMarked:
assert(!"unsupported operator");
SPOT_UNIMPLEMENTED();
break;
}
uo->child()->accept(*this);
......@@ -173,7 +173,7 @@ namespace spot
void
visit(const automatop*)
{
assert(!"unsupported operator");
SPOT_UNIMPLEMENTED();
}
void
......@@ -193,7 +193,7 @@ namespace spot
case multop::AndNLM:
case multop::Concat:
case multop::Fusion:
assert(!"unsupported operator");
SPOT_UNIMPLEMENTED();
break;
}
......
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2010, 2012 Laboratoire de Recherche et
// Copyright (C) 2009, 2010, 2012, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
......@@ -93,8 +93,7 @@ namespace spot
result_ = binop::instance(op, f1, f2);
return;
}
/* Unreachable code. */
assert(0);
SPOT_UNREACHABLE();
}
const formula*
......
// Copyright (C) 2010, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// -*- coding: utf-8 -*-
// Copyright (C) 2010, 2012, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
......@@ -94,7 +95,7 @@ namespace spot
case multop::AndRat:
case multop::Concat:
case multop::Fusion:
assert(!"unexpected operator");
SPOT_UNIMPLEMENTED();
case multop::Or:
for (unsigned i = 0; i < mos; ++i)
res->push_back(recurse(mo->nth(i)));
......@@ -252,8 +253,7 @@ namespace spot
uo->child()->clone());
return;
}
/* Unreachable code. */
assert(0);
SPOT_UNREACHABLE();
}
void
......@@ -280,7 +280,7 @@ namespace spot
case binop::Xor:
case binop::Implies:
case binop::Equiv:
assert(!"mark not defined on logic abbreviations");
SPOT_UNIMPLEMENTED();
case binop::U:
case binop::W:
case binop::M:
......@@ -297,8 +297,7 @@ namespace spot
return;
}
}
/* Unreachable code. */
assert(0);
SPOT_UNREACHABLE();
}
const formula*
......
......@@ -189,7 +189,7 @@ namespace spot
else if (proba_[i].min_n > 2)
total_2_and_more_ += proba_[i].proba;
else
assert(!"unexpected max_n");
SPOT_UNREACHABLE(); // unexpected max_n
}
assert(total_2_and_more_ >= total_2_);
}
......
// -*- coding: utf-8 -*-
// Copyright (C) 2010, 2012 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
// Copyright (C) 2010, 2012, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
......@@ -84,8 +84,7 @@ namespace spot
result_ = binop::instance(binop::M, f1, f2);
return;
}
/* Unreachable code. */
assert(0);
SPOT_UNREACHABLE();
}
const formula*
......
......@@ -185,7 +185,7 @@ namespace spot
else if (f == constant::false_instance())
result = bddfalse;
else
assert(!"Unsupported operator");
SPOT_UNIMPLEMENTED();
break;
case formula::AtomicProp:
result = bdd_ithvar(dict->register_proposition(f, this));
......@@ -213,7 +213,7 @@ namespace spot
op = bddop_biimp;
break;
default:
assert(!"Unsupported operator");
SPOT_UNIMPLEMENTED();
}
result = bdd_apply(as_bdd(bo->first()), as_bdd(bo->second()), op);
break;
......@@ -244,14 +244,14 @@ namespace spot
case multop::OrRat:
case multop::Concat:
case multop::Fusion:
assert(!"Unsupported operator");
SPOT_UNIMPLEMENTED();
break;
}
break;
}
case formula::BUnOp:
case formula::AutomatOp:
assert(!"Unsupported operator");
SPOT_UNIMPLEMENTED();
break;
}
......@@ -490,9 +490,7 @@ namespace spot
{
case unop::Not:
// "Not"s should be caught by nenoform_recursively().
assert(!"Not should not occur");
//result_ = recurse_(f, negated_ ^ true);
return;
SPOT_UNREACHABLE();
case unop::X:
/* !Xa == X!a */
result_ = unop::instance(unop::X, recurse(f));
......@@ -525,8 +523,7 @@ namespace spot
result_ = unop::instance(unop::Not, result_);
return;
}
/* Unreachable code. */
assert(0);
SPOT_UNREACHABLE();
}
void
......@@ -630,8 +627,7 @@ namespace spot
recurse_(f1, false), recurse(f2));
return;
}
// Unreachable code.
assert(0);
SPOT_UNREACHABLE();
}
void
......@@ -2182,7 +2178,7 @@ namespace spot
case binop::Xor:
case binop::Equiv:
case binop::Implies:
assert(!"operator not supported for implication rules");
SPOT_UNIMPLEMENTED();
return;
case binop::UConcat:
case binop::EConcat:
......
......@@ -49,7 +49,7 @@ namespace spot
void
visit(const atomic_prop*)
{
assert(!"unexpected operator");
SPOT_UNIMPLEMENTED();
}
void
......@@ -76,19 +76,19 @@ namespace spot
void
visit(const unop*)
{
assert(!"unexpected operator");
SPOT_UNIMPLEMENTED();
}
void
visit(const binop*)
{
assert(!"unexpected operator");
SPOT_UNIMPLEMENTED();
}
void
visit(const automatop*)
{
assert(!"unexpected operator");
SPOT_UNIMPLEMENTED();
}
void
......@@ -100,7 +100,7 @@ namespace spot
case multop::And:
case multop::Or:
case multop::Fusion:
assert(!"unexpected operator");
SPOT_UNIMPLEMENTED();
break;
case multop::Concat:
case multop::AndNLM:
......
......@@ -847,7 +847,7 @@ namespace spot
break;
case multop::Concat:
// Handled by resugar_concat.
assert(0);
SPOT_UNREACHABLE();
break;
case multop::Fusion:
k = KFusion;
......
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