summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2017-10-04 09:26:28 -0700
committerGitHub <noreply@github.com>2017-10-04 09:26:28 -0700
commitf2bd626d6337ca4df70c0bf541d7d9bec4ef5be5 (patch)
tree26f1e8d8cf034cf18ef9fb9c5fbf7e7e10b6a0b4
parentfa99334bf3c8ef2b833a48cd1141d84723716d80 (diff)
Removing the throw specifier from ArrayStoreAll constructor. (#1182)
Addresses CIDS: 1457252 and 1379620. Miscellaneous cleanup to ArrayStoreAll.
-rw-r--r--src/expr/array_store_all.cpp28
-rw-r--r--src/expr/array_store_all.h64
2 files changed, 47 insertions, 45 deletions
diff --git a/src/expr/array_store_all.cpp b/src/expr/array_store_all.cpp
index 4bad04f79..ff026057c 100644
--- a/src/expr/array_store_all.cpp
+++ b/src/expr/array_store_all.cpp
@@ -28,9 +28,8 @@ using namespace std;
namespace CVC4 {
-ArrayStoreAll::ArrayStoreAll(const ArrayType& type,
- const Expr& expr) throw(IllegalArgumentException)
- : d_type(NULL), d_expr(NULL) {
+ArrayStoreAll::ArrayStoreAll(const ArrayType& type, const Expr& expr)
+ : d_type(), d_expr() {
// this check is stronger than the assertion check in the expr manager that
// ArrayTypes are actually array types
// because this check is done in production builds too
@@ -50,18 +49,15 @@ ArrayStoreAll::ArrayStoreAll(const ArrayType& type,
// Delay allocation until the checks above have been performed. If these fail,
// the memory for d_type and d_expr should not leak. The alternative is catch,
// delete and re-throw.
- d_type = new ArrayType(type);
- d_expr = new Expr(expr);
+ d_type.reset(new ArrayType(type));
+ d_expr.reset(new Expr(expr));
}
ArrayStoreAll::ArrayStoreAll(const ArrayStoreAll& other)
: d_type(new ArrayType(other.getType())),
d_expr(new Expr(other.getExpr())) {}
-ArrayStoreAll::~ArrayStoreAll() throw() {
- delete d_expr;
- delete d_type;
-}
+ArrayStoreAll::~ArrayStoreAll() throw() {}
ArrayStoreAll& ArrayStoreAll::operator=(const ArrayStoreAll& other) {
(*d_type) = other.getType();
@@ -77,6 +73,10 @@ bool ArrayStoreAll::operator==(const ArrayStoreAll& asa) const throw() {
return getType() == asa.getType() && getExpr() == asa.getExpr();
}
+bool ArrayStoreAll::operator!=(const ArrayStoreAll& asa) const throw() {
+ return !(*this == asa);
+}
+
bool ArrayStoreAll::operator<(const ArrayStoreAll& asa) const throw() {
return (getType() < asa.getType()) ||
(getType() == asa.getType() && getExpr() < asa.getExpr());
@@ -87,6 +87,14 @@ bool ArrayStoreAll::operator<=(const ArrayStoreAll& asa) const throw() {
(getType() == asa.getType() && getExpr() <= asa.getExpr());
}
+bool ArrayStoreAll::operator>(const ArrayStoreAll& asa) const throw() {
+ return !(*this <= asa);
+}
+
+bool ArrayStoreAll::operator>=(const ArrayStoreAll& asa) const throw() {
+ return !(*this < asa);
+}
+
std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) {
return out << "__array_store_all__(" << asa.getType() << ", " << asa.getExpr()
<< ')';
@@ -96,4 +104,4 @@ size_t ArrayStoreAllHashFunction::operator()(const ArrayStoreAll& asa) const {
return TypeHashFunction()(asa.getType()) * ExprHashFunction()(asa.getExpr());
}
-} /* CVC4 namespace */
+} // namespace CVC4
diff --git a/src/expr/array_store_all.h b/src/expr/array_store_all.h
index c8474dfa1..308794f48 100644
--- a/src/expr/array_store_all.h
+++ b/src/expr/array_store_all.h
@@ -18,64 +18,58 @@
#include "cvc4_public.h"
-#pragma once
+#ifndef __CVC4__ARRAY_STORE_ALL_H
+#define __CVC4__ARRAY_STORE_ALL_H
#include <iosfwd>
-
-#include "base/exception.h"
+#include <memory>
namespace CVC4 {
- // messy; Expr needs ArrayStoreAll (because it's the payload of a
- // CONSTANT-kinded expression), and ArrayStoreAll needs Expr.
- class Expr;
- class ArrayType;
-}/* CVC4 namespace */
-
+// messy; Expr needs ArrayStoreAll (because it's the payload of a
+// CONSTANT-kinded expression), and ArrayStoreAll needs Expr.
+class Expr;
+class ArrayType;
+} // namespace CVC4
namespace CVC4 {
class CVC4_PUBLIC ArrayStoreAll {
-public:
- ArrayStoreAll(const ArrayStoreAll& other);
+ public:
+ /**
+ * @throws IllegalArgumentException if `type` is not an array or if `expr` is
+ * not a constant of type `type`.
+ */
+ ArrayStoreAll(const ArrayType& type, const Expr& expr);
+ ~ArrayStoreAll() throw();
+ ArrayStoreAll(const ArrayStoreAll& other);
ArrayStoreAll& operator=(const ArrayStoreAll& other);
- ArrayStoreAll(const ArrayType& type, const Expr& expr)
- throw(IllegalArgumentException);
-
- ~ArrayStoreAll() throw();
-
const ArrayType& getType() const throw();
-
const Expr& getExpr() const throw();
bool operator==(const ArrayStoreAll& asa) const throw();
-
- bool operator!=(const ArrayStoreAll& asa) const throw() {
- return !(*this == asa);
- }
-
+ bool operator!=(const ArrayStoreAll& asa) const throw();
bool operator<(const ArrayStoreAll& asa) const throw();
bool operator<=(const ArrayStoreAll& asa) const throw();
- bool operator>(const ArrayStoreAll& asa) const throw() {
- return !(*this <= asa);
- }
- bool operator>=(const ArrayStoreAll& asa) const throw() {
- return !(*this < asa);
- }
+ bool operator>(const ArrayStoreAll& asa) const throw();
+ bool operator>=(const ArrayStoreAll& asa) const throw();
-private:
- ArrayType* d_type;
- Expr* d_expr;
-};/* class ArrayStoreAll */
+ private:
+ std::unique_ptr<ArrayType> d_type;
+ std::unique_ptr<Expr> d_expr;
+}; /* class ArrayStoreAll */
-std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) CVC4_PUBLIC;
+std::ostream& operator<<(std::ostream& out,
+ const ArrayStoreAll& asa) CVC4_PUBLIC;
/**
* Hash function for the ArrayStoreAll constants.
*/
struct CVC4_PUBLIC ArrayStoreAllHashFunction {
size_t operator()(const ArrayStoreAll& asa) const;
-};/* struct ArrayStoreAllHashFunction */
+}; /* struct ArrayStoreAllHashFunction */
+
+} // namespace CVC4
-}/* CVC4 namespace */
+#endif /* __CVC4__ARRAY_STORE_ALL_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback