Commit 40a52033 authored by Kenton Varda's avatar Kenton Varda

Mark every destructor "noexcept(false)" unless it is very clearly noexcept. The…

Mark every destructor "noexcept(false)" unless it is very clearly noexcept.  The change in C++11 making destructors default-noexcept was a mistake.
parent af6bb032
......@@ -32,7 +32,7 @@
namespace capnp {
namespace _ { // private
Arena::~Arena() {}
Arena::~Arena() noexcept(false) {}
void ReadLimiter::unread(WordCount64 amount) {
// Be careful not to overflow here. Since ReadLimiter has no thread-safety, it's possible that
......@@ -51,7 +51,7 @@ ReaderArena::ReaderArena(MessageReader* message)
readLimiter(message->getOptions().traversalLimitInWords * WORDS),
segment0(this, SegmentId(0), message->getSegment(0), &readLimiter) {}
ReaderArena::~ReaderArena() {}
ReaderArena::~ReaderArena() noexcept(false) {}
SegmentReader* ReaderArena::tryGetSegment(SegmentId id) {
if (id == SegmentId(0)) {
......@@ -103,7 +103,7 @@ void ReaderArena::reportReadLimitReached() {
BuilderArena::BuilderArena(MessageBuilder* message)
: message(message), segment0(nullptr, SegmentId(0), nullptr, nullptr) {}
BuilderArena::~BuilderArena() {}
BuilderArena::~BuilderArena() noexcept(false) {}
SegmentBuilder* BuilderArena::getSegment(SegmentId id) {
// This method is allowed to fail if the segment ID is not valid.
......
......@@ -134,7 +134,7 @@ private:
class Arena {
public:
virtual ~Arena();
virtual ~Arena() noexcept(false);
virtual SegmentReader* tryGetSegment(SegmentId id) = 0;
// Gets the segment with the given ID, or return nullptr if no such segment exists.
......@@ -150,7 +150,7 @@ public:
class ReaderArena final: public Arena {
public:
ReaderArena(MessageReader* message);
~ReaderArena();
~ReaderArena() noexcept(false);
KJ_DISALLOW_COPY(ReaderArena);
// implements Arena ------------------------------------------------
......@@ -171,7 +171,7 @@ private:
class BuilderArena final: public Arena {
public:
BuilderArena(MessageBuilder* message);
~BuilderArena();
~BuilderArena() noexcept(false);
KJ_DISALLOW_COPY(BuilderArena);
SegmentBuilder* getSegment(SegmentId id);
......
......@@ -183,7 +183,7 @@ struct UseScratch {
KJ_REQUIRE(scratchCounter < 6, "Too many scratch spaces needed at once.");
words = scratchSpace + scratchCounter++ * SCRATCH_SIZE;
}
~ScratchSpace() {
~ScratchSpace() noexcept {
--scratchCounter;
}
};
......
......@@ -100,8 +100,6 @@ int32_t evaluateExpression(Expression::Reader exp) {
class ExpressionTestCase {
public:
~ExpressionTestCase() {}
typedef Expression Request;
typedef EvaluationResult Response;
typedef int32_t Expectation;
......
......@@ -90,7 +90,7 @@ public:
sem_init(&semaphore, 0, 0);
}
~ProducerConsumerQueue() {
~ProducerConsumerQueue() noexcept(false) {
while (front != nullptr) {
Node* oldFront = front;
front = front->next;
......
......@@ -62,7 +62,7 @@ _::StructReader MessageReader::getRootInternal() {
// -------------------------------------------------------------------
MessageBuilder::MessageBuilder(): allocatedArena(false) {}
MessageBuilder::~MessageBuilder() {
MessageBuilder::~MessageBuilder() noexcept(false) {
if (allocatedArena) {
arena()->~BuilderArena();
}
......@@ -121,7 +121,7 @@ SegmentArrayMessageReader::SegmentArrayMessageReader(
kj::ArrayPtr<const kj::ArrayPtr<const word>> segments, ReaderOptions options)
: MessageReader(options), segments(segments) {}
SegmentArrayMessageReader::~SegmentArrayMessageReader() {}
SegmentArrayMessageReader::~SegmentArrayMessageReader() noexcept(false) {}
kj::ArrayPtr<const word> SegmentArrayMessageReader::getSegment(uint id) {
if (id < segments.size()) {
......@@ -153,7 +153,7 @@ MallocMessageBuilder::MallocMessageBuilder(
"First segment must be zeroed.");
}
MallocMessageBuilder::~MallocMessageBuilder() {
MallocMessageBuilder::~MallocMessageBuilder() noexcept(false) {
if (returnedFirstSegment) {
if (ownFirstSegment) {
free(firstSegment);
......@@ -220,7 +220,7 @@ kj::ArrayPtr<word> MallocMessageBuilder::allocateSegment(uint minimumSize) {
// -------------------------------------------------------------------
FlatMessageBuilder::FlatMessageBuilder(kj::ArrayPtr<word> array): array(array), allocated(false) {}
FlatMessageBuilder::~FlatMessageBuilder() {}
FlatMessageBuilder::~FlatMessageBuilder() noexcept(false) {}
void FlatMessageBuilder::requireFilled() {
KJ_REQUIRE(getSegmentsForOutput()[0].end() == array.end(),
......
......@@ -122,7 +122,7 @@ private:
class MessageBuilder {
public:
MessageBuilder();
virtual ~MessageBuilder();
virtual ~MessageBuilder() noexcept(false);
virtual kj::ArrayPtr<word> allocateSegment(uint minimumSize) = 0;
// Allocates an array of at least the given number of words, throwing an exception or crashing if
......@@ -225,7 +225,7 @@ public:
// segments. All arrays passed in must remain valid until the MessageReader is destroyed.
KJ_DISALLOW_COPY(SegmentArrayMessageReader);
~SegmentArrayMessageReader();
~SegmentArrayMessageReader() noexcept(false);
virtual kj::ArrayPtr<const word> getSegment(uint id) override;
......@@ -282,7 +282,7 @@ public:
// over any space that was used so that it can be reused.
KJ_DISALLOW_COPY(MallocMessageBuilder);
virtual ~MallocMessageBuilder();
virtual ~MallocMessageBuilder() noexcept(false);
virtual kj::ArrayPtr<word> allocateSegment(uint minimumSize) override;
......@@ -306,7 +306,7 @@ class FlatMessageBuilder: public MessageBuilder {
public:
explicit FlatMessageBuilder(kj::ArrayPtr<word> array);
KJ_DISALLOW_COPY(FlatMessageBuilder);
virtual ~FlatMessageBuilder();
virtual ~FlatMessageBuilder() noexcept(false);
void requireFilled();
// Throws an exception if the flat array is not exactly full.
......
......@@ -1111,7 +1111,7 @@ kj::Array<Schema> SchemaLoader::Impl::getAllLoaded() const {
// =======================================================================================
SchemaLoader::SchemaLoader(): impl(kj::heap<Impl>()) {}
SchemaLoader::~SchemaLoader() {}
SchemaLoader::~SchemaLoader() noexcept(false) {}
Schema SchemaLoader::get(uint64_t id) const {
_::RawSchema* raw = impl->tryGet(id);
......
......@@ -32,7 +32,7 @@ namespace capnp {
class SchemaLoader {
public:
SchemaLoader();
~SchemaLoader();
~SchemaLoader() noexcept(false);
KJ_DISALLOW_COPY(SchemaLoader);
Schema get(uint64_t id) const;
......
......@@ -31,7 +31,7 @@ namespace capnp {
namespace _ { // private
PackedInputStream::PackedInputStream(kj::BufferedInputStream& inner): inner(inner) {}
PackedInputStream::~PackedInputStream() {}
PackedInputStream::~PackedInputStream() noexcept(false) {}
size_t PackedInputStream::read(void* dst, size_t minBytes, size_t maxBytes) {
if (maxBytes == 0) {
......@@ -302,7 +302,7 @@ void PackedInputStream::skip(size_t bytes) {
PackedOutputStream::PackedOutputStream(kj::BufferedOutputStream& inner)
: inner(inner) {}
PackedOutputStream::~PackedOutputStream() {}
PackedOutputStream::~PackedOutputStream() noexcept(false) {}
void PackedOutputStream::write(const void* src, size_t size) {
kj::ArrayPtr<byte> buffer = inner.getWriteBuffer();
......@@ -438,7 +438,7 @@ PackedMessageReader::PackedMessageReader(
: PackedInputStream(inputStream),
InputStreamMessageReader(static_cast<PackedInputStream&>(*this), options, scratchSpace) {}
PackedMessageReader::~PackedMessageReader() {}
PackedMessageReader::~PackedMessageReader() noexcept(false) {}
PackedFdMessageReader::PackedFdMessageReader(
int fd, ReaderOptions options, kj::ArrayPtr<word> scratchSpace)
......@@ -454,7 +454,7 @@ PackedFdMessageReader::PackedFdMessageReader(
PackedMessageReader(static_cast<BufferedInputStreamWrapper&>(*this),
options, scratchSpace) {}
PackedFdMessageReader::~PackedFdMessageReader() {}
PackedFdMessageReader::~PackedFdMessageReader() noexcept(false) {}
void writePackedMessage(kj::BufferedOutputStream& output,
kj::ArrayPtr<const kj::ArrayPtr<const word>> segments) {
......
......@@ -37,7 +37,7 @@ class PackedInputStream: public kj::InputStream {
public:
explicit PackedInputStream(kj::BufferedInputStream& inner);
KJ_DISALLOW_COPY(PackedInputStream);
~PackedInputStream();
~PackedInputStream() noexcept(false);
// implements InputStream ------------------------------------------
size_t read(void* buffer, size_t minBytes, size_t maxBytes) override;
......@@ -51,7 +51,7 @@ class PackedOutputStream: public kj::OutputStream {
public:
explicit PackedOutputStream(kj::BufferedOutputStream& inner);
KJ_DISALLOW_COPY(PackedOutputStream);
~PackedOutputStream();
~PackedOutputStream() noexcept(false);
// implements OutputStream -----------------------------------------
void write(const void* buffer, size_t bytes) override;
......@@ -67,7 +67,7 @@ public:
PackedMessageReader(kj::BufferedInputStream& inputStream, ReaderOptions options = ReaderOptions(),
kj::ArrayPtr<word> scratchSpace = nullptr);
KJ_DISALLOW_COPY(PackedMessageReader);
~PackedMessageReader();
~PackedMessageReader() noexcept(false);
};
class PackedFdMessageReader: private kj::FdInputStream, private kj::BufferedInputStreamWrapper,
......@@ -85,7 +85,7 @@ public:
KJ_DISALLOW_COPY(PackedFdMessageReader);
~PackedFdMessageReader();
~PackedFdMessageReader() noexcept(false);
};
void writePackedMessage(kj::BufferedOutputStream& output, MessageBuilder& builder);
......
......@@ -34,7 +34,7 @@ class SnappyInputStream::InputStreamSnappySource: public snappy::Source {
public:
inline InputStreamSnappySource(BufferedInputStream& inputStream)
: inputStream(inputStream) {}
inline ~InputStreamSnappySource() {};
inline ~InputStreamSnappySource() noexcept {};
// implements snappy::Source ---------------------------------------
......@@ -66,7 +66,7 @@ SnappyInputStream::SnappyInputStream(BufferedInputStream& inner, kj::ArrayPtr<by
this->buffer = buffer;
}
SnappyInputStream::~SnappyInputStream() {}
SnappyInputStream::~SnappyInputStream() noexcept(false) {}
kj::ArrayPtr<const byte> SnappyInputStream::getReadBuffer() {
if (bufferAvailable.size() == 0) {
......@@ -193,7 +193,7 @@ SnappyPackedMessageReader::SnappyPackedMessageReader(
: SnappyInputStream(inputStream, buffer),
PackedMessageReader(static_cast<SnappyInputStream&>(*this), options, scratchSpace) {}
SnappyPackedMessageReader::~SnappyPackedMessageReader() {}
SnappyPackedMessageReader::~SnappyPackedMessageReader() noexcept(false) {}
void writeSnappyPackedMessage(kj::OutputStream& output,
kj::ArrayPtr<const kj::ArrayPtr<const word>> segments,
......
......@@ -36,7 +36,7 @@ class SnappyInputStream: public kj::BufferedInputStream {
public:
explicit SnappyInputStream(BufferedInputStream& inner, kj::ArrayPtr<byte> buffer = nullptr);
KJ_DISALLOW_COPY(SnappyInputStream);
~SnappyInputStream();
~SnappyInputStream() noexcept(false);
// implements BufferedInputStream ----------------------------------
kj::ArrayPtr<const byte> getReadBuffer() override;
......@@ -88,7 +88,7 @@ public:
SnappyPackedMessageReader(
BufferedInputStream& inputStream, ReaderOptions options = ReaderOptions(),
kj::ArrayPtr<word> scratchSpace = nullptr, kj::ArrayPtr<byte> buffer = nullptr);
~SnappyPackedMessageReader();
~SnappyPackedMessageReader() noexcept(false);
};
void writeSnappyPackedMessage(kj::OutputStream& output, MessageBuilder& builder,
......
......@@ -25,7 +25,7 @@
namespace kj {
ArrayDisposer::~ArrayDisposer() {}
ArrayDisposer::~ArrayDisposer() noexcept(false) {}
namespace _ { // private
......@@ -42,7 +42,7 @@ struct HeapArrayDisposer::ExceptionGuard {
elementSize(elementSize), elementCount(elementCount),
destroyElement(destroyElement) {}
~ExceptionGuard() {
~ExceptionGuard() noexcept(false) {
if (pos != nullptr) {
destroyAll();
operator delete(pos);
......
......@@ -37,7 +37,7 @@ class ArrayDisposer {
// Much like Disposer from memory.h.
protected:
virtual ~ArrayDisposer();
virtual ~ArrayDisposer() noexcept(false);
virtual void disposeImpl(void* firstElement, size_t elementSize, size_t elementCount,
size_t capacity, void (*destroyElement)(void*)) const = 0;
......@@ -231,7 +231,7 @@ public:
other.endPtr = nullptr;
}
KJ_DISALLOW_COPY(ArrayBuilder);
inline ~ArrayBuilder() { dispose(); }
inline ~ArrayBuilder() noexcept(false) { dispose(); }
inline operator ArrayPtr<T>() {
return arrayPtr(ptr, pos);
......@@ -506,7 +506,7 @@ struct CopyConstructArray_<T, Iterator, false> {
T* start;
T* pos;
inline explicit ExceptionGuard(T* pos): start(pos), pos(pos) {}
~ExceptionGuard() {
~ExceptionGuard() noexcept(false) {
while (pos > start) {
dtor(*--pos);
}
......
......@@ -340,7 +340,7 @@ public:
ctor(value, other.value);
}
}
inline ~NullableValue() {
inline ~NullableValue() noexcept(noexcept(instance<T&>().~T())) {
if (isSet) {
dtor(value);
}
......
......@@ -228,7 +228,7 @@ int Debug::getOsErrorNumber() {
}
Debug::Context::Context(): logged(false) {}
Debug::Context::~Context() {}
Debug::Context::~Context() noexcept(false) {}
Debug::Context::Value Debug::Context::ensureInitialized() {
KJ_IF_MAYBE(v, value) {
......
......@@ -220,7 +220,7 @@ public:
public:
Context();
KJ_DISALLOW_COPY(Context);
virtual ~Context();
virtual ~Context() noexcept(false);
struct Value {
const char* file;
......
......@@ -253,7 +253,7 @@ ExceptionCallback::ExceptionCallback(): next(getExceptionCallback()) {
ExceptionCallback::ExceptionCallback(ExceptionCallback& next): next(next) {}
ExceptionCallback::~ExceptionCallback() {
ExceptionCallback::~ExceptionCallback() noexcept(false) {
if (&next != this) {
threadLocalCallback = &next;
}
......@@ -375,7 +375,7 @@ class RecoverableExceptionCatcher: public ExceptionCallback {
// -fno-exceptions.
public:
virtual ~RecoverableExceptionCatcher() {}
virtual ~RecoverableExceptionCatcher() noexcept(false) {}
void onRecoverableException(Exception&& exception) override {
if (caught == nullptr) {
......
......@@ -141,7 +141,7 @@ class ExceptionCallback {
public:
ExceptionCallback();
KJ_DISALLOW_COPY(ExceptionCallback);
virtual ~ExceptionCallback();
virtual ~ExceptionCallback() noexcept(false);
virtual void onRecoverableException(Exception&& exception);
// Called when an exception has been raised, but the calling code has the ability to continue by
......
......@@ -172,7 +172,7 @@ void BufferedOutputStreamWrapper::write(const void* src, size_t size) {
// =======================================================================================
ArrayInputStream::ArrayInputStream(ArrayPtr<const byte> array): array(array) {}
ArrayInputStream::~ArrayInputStream() {}
ArrayInputStream::~ArrayInputStream() noexcept(false) {}
ArrayPtr<const byte> ArrayInputStream::getReadBuffer() {
return array;
......@@ -201,7 +201,7 @@ void ArrayInputStream::skip(size_t bytes) {
// -------------------------------------------------------------------
ArrayOutputStream::ArrayOutputStream(ArrayPtr<byte> array): array(array), fillPos(array.begin()) {}
ArrayOutputStream::~ArrayOutputStream() {}
ArrayOutputStream::~ArrayOutputStream() noexcept(false) {}
ArrayPtr<byte> ArrayOutputStream::getWriteBuffer() {
return arrayPtr(fillPos, array.end());
......
......@@ -179,7 +179,7 @@ class ArrayInputStream: public BufferedInputStream {
public:
explicit ArrayInputStream(ArrayPtr<const byte> array);
KJ_DISALLOW_COPY(ArrayInputStream);
~ArrayInputStream();
~ArrayInputStream() noexcept(false);
// implements BufferedInputStream ----------------------------------
ArrayPtr<const byte> getReadBuffer() override;
......@@ -194,7 +194,7 @@ class ArrayOutputStream: public BufferedOutputStream {
public:
explicit ArrayOutputStream(ArrayPtr<byte> array);
KJ_DISALLOW_COPY(ArrayOutputStream);
~ArrayOutputStream();
~ArrayOutputStream() noexcept(false);
ArrayPtr<byte> getArray() {
// Get the portion of the array which has been filled in.
......
......@@ -25,6 +25,6 @@
namespace kj {
Disposer::~Disposer() {}
Disposer::~Disposer() noexcept(false) {}
} // namespace kj
......@@ -40,7 +40,7 @@ class Disposer {
// custom memory allocators.
protected:
virtual ~Disposer();
virtual ~Disposer() noexcept(false);
virtual void disposeImpl(void* pointer) const = 0;
// Disposes of the object, given a pointer to the beginning of the object. If the object is
......@@ -99,7 +99,7 @@ public:
}
inline Own(T* ptr, const Disposer& disposer) noexcept: disposer(&disposer), ptr(ptr) {}
~Own() noexcept { dispose(); }
~Own() noexcept(false) { dispose(); }
inline Own& operator=(Own&& other) {
dispose();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment