Skip to content

Commit f996995

Browse files
author
Daniel Kroening
committed
add noexcept to frequently used constructors
1 parent 0f7a99d commit f996995

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

src/big-int/bigint.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,7 @@ BigInt::BigInt (BigInt const &y)
464464
memcpy (digit, y.digit, length * sizeof (onedig_t));
465465
}
466466

467-
BigInt::BigInt (BigInt &&y)
468-
: BigInt()
467+
BigInt::BigInt(BigInt &&y) noexcept : BigInt()
469468
{
470469
swap(y);
471470
}

src/big-int/bigint.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public:
168168
BigInt (llong_t) _fast;
169169
BigInt (ullong_t) _fast;
170170
BigInt (BigInt const &) _fast;
171-
BigInt (BigInt &&) _fast;
171+
BigInt (BigInt &&) noexcept _fast;
172172
BigInt (char const *, onedig_t = 10) _fast;
173173

174174
BigInt &operator= (BigInt const &) _fast;

src/util/dstring.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ class dstringt final
3636
{
3737
public:
3838
// this is safe for static objects
39-
#ifdef __GNUC__
39+
#ifdef __GNUC__
4040
constexpr
41-
#endif
42-
dstringt():no(0)
41+
#endif
42+
dstringt() noexcept
43+
: no(0)
4344
{
4445
}
4546

src/util/expr.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ class exprt:public irept
5757
typedef std::vector<exprt> operandst;
5858

5959
// constructors
60-
exprt() { }
60+
exprt() noexcept
61+
{
62+
}
6163
explicit exprt(const irep_idt &_id):irept(_id) { }
6264
exprt(const irep_idt &_id, const typet &_type):irept(_id)
6365
{

src/util/irep.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,22 @@ class irept
169169
bool is_nil() const { return id()==ID_nil; }
170170
bool is_not_nil() const { return id()!=ID_nil; }
171171

172-
explicit irept(const irep_idt &_id)
172+
explicit irept(const irep_idt &_id) noexcept
173173
#ifdef SHARING
174-
:data(&empty_d)
174+
: data(&empty_d)
175175
#endif
176176
{
177177
id(_id);
178178
}
179179

180180
#ifdef SHARING
181181
// constructor for blank irep
182-
irept():data(&empty_d)
182+
irept() noexcept : data(&empty_d)
183183
{
184184
}
185185

186186
// copy constructor
187-
irept(const irept &irep):data(irep.data)
187+
irept(const irept &irep) noexcept : data(irep.data)
188188
{
189189
if(data!=&empty_d)
190190
{
@@ -201,7 +201,7 @@ class irept
201201
// Copy from rvalue reference.
202202
// Note that this does avoid a branch compared to the
203203
// standard copy constructor above.
204-
irept(irept &&irep):data(irep.data)
204+
irept(irept &&irep) noexcept : data(irep.data)
205205
{
206206
#ifdef IREP_DEBUG
207207
std::cout << "COPY MOVE\n";
@@ -231,7 +231,7 @@ class irept
231231
#ifdef USE_MOVE
232232
// Note that the move assignment operator does avoid
233233
// three branches compared to standard operator above.
234-
irept &operator=(irept &&irep)
234+
irept &operator=(irept &&irep) noexcept
235235
{
236236
#ifdef IREP_DEBUG
237237
std::cout << "ASSIGN MOVE\n";

0 commit comments

Comments
 (0)