Skip to content

add noexcept to frequently used constructors #2502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/big-int/bigint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ BigInt::BigInt (BigInt const &y)
memcpy (digit, y.digit, length * sizeof (onedig_t));
}

BigInt::BigInt (BigInt &&y)
: BigInt()
BigInt::BigInt(BigInt &&y) noexcept : BigInt()
{
swap(y);
}
Expand Down
2 changes: 1 addition & 1 deletion src/big-int/bigint.hh
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public:
BigInt (llong_t) _fast;
BigInt (ullong_t) _fast;
BigInt (BigInt const &) _fast;
BigInt (BigInt &&) _fast;
BigInt (BigInt &&) noexcept _fast;
BigInt (char const *, onedig_t = 10) _fast;

BigInt &operator= (BigInt const &) _fast;
Expand Down
7 changes: 4 additions & 3 deletions src/util/dstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ class dstringt final
{
public:
// this is safe for static objects
#ifdef __GNUC__
#ifdef __GNUC__
constexpr
#endif
dstringt():no(0)
#endif
dstringt() noexcept
: no(0)
{
}

Expand Down
4 changes: 3 additions & 1 deletion src/util/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ class exprt:public irept
typedef std::vector<exprt> operandst;

// constructors
exprt() { }
exprt() noexcept
{
}
explicit exprt(const irep_idt &_id):irept(_id) { }
exprt(const irep_idt &_id, const typet &_type):irept(_id)
{
Expand Down
12 changes: 6 additions & 6 deletions src/util/irep.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,22 @@ class irept
bool is_nil() const { return id()==ID_nil; }
bool is_not_nil() const { return id()!=ID_nil; }

explicit irept(const irep_idt &_id)
explicit irept(const irep_idt &_id) noexcept
#ifdef SHARING
:data(&empty_d)
: data(&empty_d)
#endif
{
id(_id);
}

#ifdef SHARING
// constructor for blank irep
irept():data(&empty_d)
irept() noexcept : data(&empty_d)
{
}

// copy constructor
irept(const irept &irep):data(irep.data)
irept(const irept &irep) noexcept : data(irep.data)
{
if(data!=&empty_d)
{
Expand All @@ -201,7 +201,7 @@ class irept
// Copy from rvalue reference.
// Note that this does avoid a branch compared to the
// standard copy constructor above.
irept(irept &&irep):data(irep.data)
irept(irept &&irep) noexcept : data(irep.data)
{
#ifdef IREP_DEBUG
std::cout << "COPY MOVE\n";
Expand Down Expand Up @@ -231,7 +231,7 @@ class irept
#ifdef USE_MOVE
// Note that the move assignment operator does avoid
// three branches compared to standard operator above.
irept &operator=(irept &&irep)
irept &operator=(irept &&irep) noexcept
{
#ifdef IREP_DEBUG
std::cout << "ASSIGN MOVE\n";
Expand Down