diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2016-12-23 16:38:21 +0000 |
---|---|---|
committer | Dan Liew <delcypher@gmail.com> | 2017-02-13 22:07:13 +0000 |
commit | 950c823ddec56d59edb88e6ef81ba541aa5a34df (patch) | |
tree | 2ad5c5bb1c8ad4add59e19bf63e96e9c234e8424 | |
parent | 88e8a93bcf2cfd4bd2f7832205fa2998d3569358 (diff) | |
download | klee-950c823ddec56d59edb88e6ef81ba541aa5a34df.tar.gz |
Silenced two "control may reach end of non-void function [-Wreturn-type]" compiler warnings, one by adding an assert, and the other by refactoring the choose() function.
-rw-r--r-- | include/klee/Internal/ADT/DiscretePDF.inc | 42 | ||||
-rw-r--r-- | lib/Core/ExecutorUtil.cpp | 7 |
2 files changed, 27 insertions, 22 deletions
diff --git a/include/klee/Internal/ADT/DiscretePDF.inc b/include/klee/Internal/ADT/DiscretePDF.inc index 5aee2de5..eb7bd860 100644 --- a/include/klee/Internal/ADT/DiscretePDF.inc +++ b/include/klee/Internal/ADT/DiscretePDF.inc @@ -162,32 +162,32 @@ void DiscretePDF<T>::update(T item, weight_type weight) { template <class T> T DiscretePDF<T>::choose(double p) { - if (p<0.0 || p>=1.0) { + if ((p < 0.0) || (p >= 1.0)) assert(0 && "choose: argument(p) outside valid range"); - } else if (!m_root) { + + if (!m_root) assert(0 && "choose: choose() called on empty tree"); - } else { - weight_type w = (weight_type) (m_root->sumWeights * p); - Node *n = m_root; - - while (1) { - if (n->left) { - if (w<n->left->sumWeights) { - n = n->left; - continue; - } else { - w -= n->left->sumWeights; - } - } - if (w<n->weight || !n->right) { - break; // !n->right condition shouldn't be necessary, just sanity check + + weight_type w = (weight_type) (m_root->sumWeights * p); + Node *n = m_root; + + while (1) { + if (n->left) { + if (w<n->left->sumWeights) { + n = n->left; + continue; + } else { + w -= n->left->sumWeights; } - w -= n->weight; - n = n->right; } - - return n->key; + if (w<n->weight || !n->right) { + break; // !n->right condition shouldn't be necessary, just sanity check + } + w -= n->weight; + n = n->right; } + + return n->key; } template <class T> diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp index 56f18e6b..b91b5dee 100644 --- a/lib/Core/ExecutorUtil.cpp +++ b/lib/Core/ExecutorUtil.cpp @@ -153,6 +153,11 @@ namespace klee { case Instruction::FCmp: assert(0 && "floating point ConstantExprs unsupported"); } +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1) + llvm_unreachable("Unsupported expression in evalConstantExpr"); +#else + assert(0 && "Unsupported expression in evalConstantExpr"); +#endif + return op1; } - } |