summaryrefslogtreecommitdiff
path: root/src/expr
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@cs.nyu.edu>2013-06-27 15:01:21 -0400
committerMorgan Deters <mdeters@cs.nyu.edu>2013-06-27 16:46:22 -0400
commit5d5038723c202b04272f14abc64e7b6a0bbe2979 (patch)
tree714d8586095c986eccc684859fd34c61874f2869 /src/expr
parenta399bd138c387820e0d441372a7dbe7bee1dd0f4 (diff)
Remove macros EXPECT_TRUE / EXPECT_FALSE from cvc4_public.h so that they don't escape to user space
Thanks to Alex Horn for raising the issue on the CVC-BUGS mailing list.
Diffstat (limited to 'src/expr')
-rw-r--r--src/expr/node.h4
-rw-r--r--src/expr/node_builder.h34
-rw-r--r--src/expr/node_value.h10
-rw-r--r--src/expr/type_node.cpp2
-rw-r--r--src/expr/type_node.h2
5 files changed, 26 insertions, 26 deletions
diff --git a/src/expr/node.h b/src/expr/node.h
index 7003aae87..d9e88d8af 100644
--- a/src/expr/node.h
+++ b/src/expr/node.h
@@ -1094,7 +1094,7 @@ NodeTemplate<ref_count>& NodeTemplate<ref_count>::
operator=(const NodeTemplate& e) {
Assert(d_nv != NULL, "Expecting a non-NULL expression value!");
Assert(e.d_nv != NULL, "Expecting a non-NULL expression value on RHS!");
- if(EXPECT_TRUE( d_nv != e.d_nv )) {
+ if(__builtin_expect( ( d_nv != e.d_nv ), true )) {
if(ref_count) {
// shouldn't ever fail
Assert(d_nv->d_rc > 0,
@@ -1118,7 +1118,7 @@ NodeTemplate<ref_count>& NodeTemplate<ref_count>::
operator=(const NodeTemplate<!ref_count>& e) {
Assert(d_nv != NULL, "Expecting a non-NULL expression value!");
Assert(e.d_nv != NULL, "Expecting a non-NULL expression value on RHS!");
- if(EXPECT_TRUE( d_nv != e.d_nv )) {
+ if(__builtin_expect( ( d_nv != e.d_nv ), true )) {
if(ref_count) {
// shouldn't ever fail
Assert(d_nv->d_rc > 0, "Node reference count would be negative");
diff --git a/src/expr/node_builder.h b/src/expr/node_builder.h
index 773828ccb..1f098b4e8 100644
--- a/src/expr/node_builder.h
+++ b/src/expr/node_builder.h
@@ -228,7 +228,7 @@ class NodeBuilder {
* Internally, this state is represented by d_nv pointing to NULL.
*/
inline bool isUsed() const {
- return EXPECT_FALSE( d_nv == NULL );
+ return __builtin_expect( ( d_nv == NULL ), false );
}
/**
@@ -259,7 +259,7 @@ class NodeBuilder {
* heap-allocated by this class).
*/
inline bool nvIsAllocated() const {
- return EXPECT_FALSE( d_nv != &d_inlineNv ) && EXPECT_TRUE( d_nv != NULL );
+ return __builtin_expect( ( d_nv != &d_inlineNv ), false ) && __builtin_expect(( d_nv != NULL ), true );
}
/**
@@ -267,7 +267,7 @@ class NodeBuilder {
* first.
*/
inline bool nvNeedsToBeAllocated() const {
- return EXPECT_FALSE( d_nv->d_nchildren == d_nvMaxChildren );
+ return __builtin_expect( ( d_nv->d_nchildren == d_nvMaxChildren ), false );
}
/**
@@ -279,7 +279,7 @@ class NodeBuilder {
inline void realloc() {
size_t newSize = 2 * size_t(d_nvMaxChildren);
size_t hardLimit = (1lu << __CVC4__EXPR__NODE_VALUE__NBITS__NCHILDREN) - 1;
- realloc(EXPECT_FALSE( newSize > hardLimit ) ? hardLimit : newSize);
+ realloc(__builtin_expect( ( newSize > hardLimit ), false ) ? hardLimit : newSize);
}
/**
@@ -297,7 +297,7 @@ class NodeBuilder {
* double-decremented on destruction/clear. Otherwise, do nothing.
*/
inline void allocateNvIfNecessaryForAppend() {
- if(EXPECT_FALSE( nvNeedsToBeAllocated() )) {
+ if(__builtin_expect( ( nvNeedsToBeAllocated() ), false )) {
realloc();
}
}
@@ -331,8 +331,8 @@ class NodeBuilder {
* @throws bad_alloc if the reallocation fails
*/
void crop() {
- if(EXPECT_FALSE( nvIsAllocated() ) &&
- EXPECT_TRUE( d_nvMaxChildren > d_nv->d_nchildren )) {
+ if(__builtin_expect( ( nvIsAllocated() ), false ) &&
+ __builtin_expect( ( d_nvMaxChildren > d_nv->d_nchildren ), true )) {
// Ensure d_nv is not modified on allocation failure
expr::NodeValue* newBlock = (expr::NodeValue*)
std::realloc(d_nv,
@@ -419,9 +419,9 @@ public:
}
inline ~NodeBuilder() {
- if(EXPECT_FALSE( nvIsAllocated() )) {
+ if(__builtin_expect( ( nvIsAllocated() ), false )) {
dealloc();
- } else if(EXPECT_FALSE( !isUsed() )) {
+ } else if(__builtin_expect( ( !isUsed() ), false )) {
decrRefCounts();
}
}
@@ -578,7 +578,7 @@ public:
// NodeBuilder construction or at the last clear()), but we do
// now. That means we appended a Kind with operator<<(Kind),
// which now (lazily) we'll collapse.
- if(EXPECT_FALSE( d_nv->d_id == 0 && getKind() != kind::UNDEFINED_KIND )) {
+ if(__builtin_expect( ( d_nv->d_id == 0 && getKind() != kind::UNDEFINED_KIND ), false )) {
Node n2 = operator Node();
clear();
append(n2);
@@ -600,7 +600,7 @@ public:
// NodeBuilder construction or at the last clear()), but we do
// now. That means we appended a Kind with operator<<(Kind),
// which now (lazily) we'll collapse.
- if(EXPECT_FALSE( d_nv->d_id == 0 && getKind() != kind::UNDEFINED_KIND )) {
+ if(__builtin_expect( ( d_nv->d_id == 0 && getKind() != kind::UNDEFINED_KIND ), false )) {
Node n2 = operator Node();
clear();
append(n2);
@@ -619,7 +619,7 @@ public:
// NodeBuilder construction or at the last clear()), but we do
// now. That means we appended a Kind with operator<<(Kind),
// which now (lazily) we'll collapse.
- if(EXPECT_FALSE( d_nv->d_id == 0 && getKind() != kind::UNDEFINED_KIND )) {
+ if(__builtin_expect( ( d_nv->d_id == 0 && getKind() != kind::UNDEFINED_KIND ), false )) {
Node n2 = operator Node();
clear();
append(n2);
@@ -756,9 +756,9 @@ template <unsigned nchild_thresh>
void NodeBuilder<nchild_thresh>::clear(Kind k) {
Assert(k != kind::NULL_EXPR, "illegal Node-building clear kind");
- if(EXPECT_FALSE( nvIsAllocated() )) {
+ if(__builtin_expect( ( nvIsAllocated() ), false )) {
dealloc();
- } else if(EXPECT_FALSE( !isUsed() )) {
+ } else if(__builtin_expect( ( !isUsed() ), false )) {
decrRefCounts();
} else {
setUnused();
@@ -783,7 +783,7 @@ void NodeBuilder<nchild_thresh>::realloc(size_t toSize) {
"attempt to realloc() a NodeBuilder to size %u (beyond hard limit of %u)",
toSize, (1lu << __CVC4__EXPR__NODE_VALUE__NBITS__NCHILDREN) - 1 );
- if(EXPECT_FALSE( nvIsAllocated() )) {
+ if(__builtin_expect( ( nvIsAllocated() ), false )) {
// Ensure d_nv is not modified on allocation failure
expr::NodeValue* newBlock = (expr::NodeValue*)
std::realloc(d_nv, sizeof(expr::NodeValue) +
@@ -992,7 +992,7 @@ expr::NodeValue* NodeBuilder<nchild_thresh>::constructNV() {
// NodeManager pool of Nodes. See implementation notes at the top
// of this file.
- if(EXPECT_TRUE( ! nvIsAllocated() )) {
+ if(__builtin_expect( ( ! nvIsAllocated() ), true )) {
/** Case 1. d_nv points to d_inlineNv: it is the backing store
** allocated "inline" in this NodeBuilder. **/
@@ -1177,7 +1177,7 @@ expr::NodeValue* NodeBuilder<nchild_thresh>::constructNV() const {
// NodeManager pool of Nodes. See implementation notes at the top
// of this file.
- if(EXPECT_TRUE( ! nvIsAllocated() )) {
+ if(__builtin_expect( ( ! nvIsAllocated() ), true )) {
/** Case 1. d_nv points to d_inlineNv: it is the backing store
** allocated "inline" in this NodeBuilder. **/
diff --git a/src/expr/node_value.h b/src/expr/node_value.h
index 13fdc6a7f..56ac70c1e 100644
--- a/src/expr/node_value.h
+++ b/src/expr/node_value.h
@@ -299,7 +299,7 @@ private:
RefCountGuard(const NodeValue* nv) :
d_nv(const_cast<NodeValue*>(nv)) {
// inc()
- if(EXPECT_TRUE( d_nv->d_rc < MAX_RC )) {
+ if(__builtin_expect( ( d_nv->d_rc < MAX_RC ), true )) {
++d_nv->d_rc;
}
}
@@ -309,7 +309,7 @@ private:
// E.g., this can happen when debugging code calls the print
// routines below. As RefCountGuards are scoped on the stack,
// this should be fine---but not in multithreaded contexts!
- if(EXPECT_TRUE( d_nv->d_rc < MAX_RC )) {
+ if(__builtin_expect( ( d_nv->d_rc < MAX_RC ), true )) {
--d_nv->d_rc;
}
}
@@ -400,16 +400,16 @@ inline void NodeValue::inc() {
"NodeValue is currently being deleted "
"and increment is being called on it. Don't Do That!");
// FIXME multithreading
- if(EXPECT_TRUE( d_rc < MAX_RC )) {
+ if(__builtin_expect( ( d_rc < MAX_RC ), true )) {
++d_rc;
}
}
inline void NodeValue::dec() {
// FIXME multithreading
- if(EXPECT_TRUE( d_rc < MAX_RC )) {
+ if(__builtin_expect( ( d_rc < MAX_RC ), true )) {
--d_rc;
- if(EXPECT_FALSE( d_rc == 0 )) {
+ if(__builtin_expect( ( d_rc == 0 ), false )) {
Assert(NodeManager::currentNM() != NULL,
"No current NodeManager on destruction of NodeValue: "
"maybe a public CVC4 interface function is missing a NodeManagerScope ?");
diff --git a/src/expr/type_node.cpp b/src/expr/type_node.cpp
index 1d4c330fa..2fc380224 100644
--- a/src/expr/type_node.cpp
+++ b/src/expr/type_node.cpp
@@ -300,7 +300,7 @@ TypeNode TypeNode::leastCommonTypeNode(TypeNode t0, TypeNode t1){
Assert(!t0.isNull());
Assert(!t1.isNull());
- if(EXPECT_TRUE(t0 == t1)) {
+ if(__builtin_expect( (t0 == t1), true )) {
return t0;
} else { // t0 != t1
if(t0.getKind()== kind::TYPE_CONSTANT) {
diff --git a/src/expr/type_node.h b/src/expr/type_node.h
index 35d630a91..061e73fc9 100644
--- a/src/expr/type_node.h
+++ b/src/expr/type_node.h
@@ -770,7 +770,7 @@ inline TypeNode& TypeNode::operator=(const TypeNode& typeNode) {
Assert(d_nv != NULL, "Expecting a non-NULL expression value!");
Assert(typeNode.d_nv != NULL,
"Expecting a non-NULL expression value on RHS!");
- if(EXPECT_TRUE( d_nv != typeNode.d_nv )) {
+ if(__builtin_expect( ( d_nv != typeNode.d_nv ), true )) {
d_nv->dec();
d_nv = typeNode.d_nv;
d_nv->inc();
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback