Merge pull request #718 from p12tic/use-noexcept

Use noexcept instead of dynamic exception specifications
This commit is contained in:
Dom Rodriguez 2020-05-30 21:39:12 +01:00 committed by GitHub
commit 8891364258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 79 additions and 118 deletions

View File

@ -20,7 +20,7 @@
#include "common/common.h"
#include "common/stdstring.h"
#include "common/stdexcept.h"
#include <stdexcept>
//! Generic thread exception
/*!
@ -56,7 +56,7 @@ string for that error code.
class XArchEval {
public:
XArchEval() { }
virtual ~XArchEval() _NOEXCEPT { }
virtual ~XArchEval() noexcept { }
virtual std::string eval() const = 0;
};
@ -66,7 +66,7 @@ class XArch : public std::runtime_error {
public:
XArch(XArchEval* adopted) : std::runtime_error(adopted->eval()) { delete adopted; }
XArch(const std::string& msg) : std::runtime_error(msg) { }
virtual ~XArch() _NOEXCEPT { }
virtual ~XArch() noexcept { }
};
// Macro to declare XArch derived types

View File

@ -24,7 +24,7 @@
class XArchEvalUnix : public XArchEval {
public:
XArchEvalUnix(int error) : m_error(error) { }
virtual ~XArchEvalUnix() _NOEXCEPT { }
virtual ~XArchEvalUnix() noexcept { }
virtual std::string eval() const;

View File

@ -24,7 +24,7 @@
//
std::string
XArchEvalWindows::eval() const throw()
XArchEvalWindows::eval() const noexcept
{
char* cmsg;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
@ -50,7 +50,7 @@ XArchEvalWindows::eval() const throw()
//
std::string
XArchEvalWinsock::eval() const throw()
XArchEvalWinsock::eval() const noexcept
{
// built-in windows function for looking up error message strings
// may not look up network error messages correctly. we'll have

View File

@ -20,7 +20,6 @@
#include "barrier/IPlatformScreen.h"
#include "barrier/DragInformation.h"
#include "common/stdexcept.h"
//! Base screen implementation
/*!

View File

@ -539,7 +539,7 @@ ProtocolUtil::read(barrier::IStream* stream, void* vbuffer, UInt32 count)
//
String
XIOReadMismatch::getWhat() const throw()
XIOReadMismatch::getWhat() const noexcept
{
return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch");
}

View File

@ -92,5 +92,5 @@ match the format.
class XIOReadMismatch : public XIO {
public:
// XBase overrides
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
};

View File

@ -29,9 +29,9 @@
#include "base/Log.h"
#include "base/Stopwatch.h"
#include "base/String.h"
#include "common/stdexcept.h"
#include <fstream>
#include <stdexcept>
using namespace std;

View File

@ -23,8 +23,7 @@
// XBadClient
//
String
XBadClient::getWhat() const throw()
String XBadClient::getWhat() const noexcept
{
return "XBadClient";
}
@ -41,20 +40,17 @@ XIncompatibleClient::XIncompatibleClient(int major, int minor) :
// do nothing
}
int
XIncompatibleClient::getMajor() const throw()
int XIncompatibleClient::getMajor() const noexcept
{
return m_major;
}
int
XIncompatibleClient::getMinor() const throw()
int XIncompatibleClient::getMinor() const noexcept
{
return m_minor;
}
String
XIncompatibleClient::getWhat() const throw()
String XIncompatibleClient::getWhat() const noexcept
{
return format("XIncompatibleClient", "incompatible client %{1}.%{2}",
barrier::string::sprintf("%d", m_major).c_str(),
@ -72,14 +68,12 @@ XDuplicateClient::XDuplicateClient(const String& name) :
// do nothing
}
const String&
XDuplicateClient::getName() const throw()
const String& XDuplicateClient::getName() const noexcept
{
return m_name;
}
String
XDuplicateClient::getWhat() const throw()
String XDuplicateClient::getWhat() const noexcept
{
return format("XDuplicateClient", "duplicate client %{1}", m_name.c_str());
}
@ -95,14 +89,12 @@ XUnknownClient::XUnknownClient(const String& name) :
// do nothing
}
const String&
XUnknownClient::getName() const throw()
const String& XUnknownClient::getName() const noexcept
{
return m_name;
}
String
XUnknownClient::getWhat() const throw()
String XUnknownClient::getWhat() const noexcept
{
return format("XUnknownClient", "unknown client %{1}", m_name.c_str());
}
@ -118,14 +110,12 @@ XExitApp::XExitApp(int code) :
// do nothing
}
int
XExitApp::getCode() const throw()
int XExitApp::getCode() const noexcept
{
return m_code;
}
String
XExitApp::getWhat() const throw()
String XExitApp::getWhat() const noexcept
{
return format(
"XExitApp", "exiting with code %{1}",

View File

@ -47,14 +47,14 @@ public:
//@{
//! Get client's major version number
int getMajor() const throw();
int getMajor() const noexcept;
//! Get client's minor version number
int getMinor() const throw();
int getMinor() const noexcept;
//@}
protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
private:
int m_major;
@ -69,18 +69,18 @@ a client that is already connected.
class XDuplicateClient : public XBarrier {
public:
XDuplicateClient(const std::string& name);
virtual ~XDuplicateClient() _NOEXCEPT { }
virtual ~XDuplicateClient() noexcept { }
//! @name accessors
//@{
//! Get client's name
virtual const std::string& getName() const throw();
virtual const std::string& getName() const noexcept;
//@}
protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
private:
std::string m_name;
@ -94,18 +94,18 @@ unknown to the server.
class XUnknownClient : public XBarrier {
public:
XUnknownClient(const std::string& name);
virtual ~XUnknownClient() _NOEXCEPT { }
virtual ~XUnknownClient() noexcept { }
//! @name accessors
//@{
//! Get the client's name
virtual const std::string& getName() const throw();
virtual const std::string& getName() const noexcept;
//@}
protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
private:
std::string m_name;
@ -120,13 +120,13 @@ exit(int).
class XExitApp : public XBarrier {
public:
XExitApp(int code);
virtual ~XExitApp() _NOEXCEPT { }
virtual ~XExitApp() noexcept { }
//! Get the exit code
int getCode() const throw();
int getCode() const noexcept;
protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
private:
int m_code;

View File

@ -22,7 +22,7 @@
// XScreenOpenFailure
//
std::string XScreenOpenFailure::getWhat() const throw()
std::string XScreenOpenFailure::getWhat() const noexcept
{
return format("XScreenOpenFailure", "unable to open screen");
}
@ -32,7 +32,7 @@ std::string XScreenOpenFailure::getWhat() const throw()
// XScreenXInputFailure
//
std::string XScreenXInputFailure::getWhat() const throw()
std::string XScreenXInputFailure::getWhat() const noexcept
{
return "";
}
@ -48,7 +48,7 @@ XScreenUnavailable::XScreenUnavailable(double timeUntilRetry) :
// do nothing
}
XScreenUnavailable::~XScreenUnavailable() _NOEXCEPT
XScreenUnavailable::~XScreenUnavailable() noexcept
{
// do nothing
}
@ -59,7 +59,7 @@ XScreenUnavailable::getRetryTime() const
return m_timeUntilRetry;
}
std::string XScreenUnavailable::getWhat() const throw()
std::string XScreenUnavailable::getWhat() const noexcept
{
return format("XScreenUnavailable", "unable to open screen");
}

View File

@ -47,7 +47,7 @@ public:
trying to open the screen again.
*/
XScreenUnavailable(double timeUntilRetry);
virtual ~XScreenUnavailable() _NOEXCEPT;
virtual ~XScreenUnavailable() noexcept;
//! @name manipulators
//@{
@ -61,7 +61,7 @@ public:
//@}
protected:
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
private:
double m_timeUntilRetry;

View File

@ -38,13 +38,13 @@ XBase::XBase(const std::string& msg) :
// do nothing
}
XBase::~XBase() _NOEXCEPT
XBase::~XBase() noexcept
{
// do nothing
}
const char*
XBase::what() const _NOEXCEPT
XBase::what() const noexcept
{
const char* what = std::runtime_error::what();
if (strlen(what) == 0) {
@ -54,8 +54,7 @@ XBase::what() const _NOEXCEPT
return what;
}
std::string
XBase::format(const char* /*id*/, const char* fmt, ...) const throw()
std::string XBase::format(const char* /*id*/, const char* fmt, ...) const noexcept
{
// FIXME -- lookup message string using id as an index. set
// fmt to that string if it exists.

View File

@ -18,7 +18,7 @@
#pragma once
#include "common/stdexcept.h"
#include <stdexcept>
#include <string>
//! Exception base class
@ -31,14 +31,14 @@ public:
XBase();
//! Use \c msg as the result of what()
XBase(const std::string& msg);
virtual ~XBase() _NOEXCEPT;
virtual ~XBase() noexcept;
//! Reason for exception
virtual const char* what() const _NOEXCEPT;
virtual const char* what() const noexcept;
protected:
//! Get a human readable string describing the exception
virtual std::string getWhat() const throw() { return ""; }
virtual std::string getWhat() const noexcept { return ""; }
//! Format a string
/*!
@ -46,7 +46,7 @@ protected:
no format can be found, then replaces positional parameters in
the format string and returns the result.
*/
virtual std::string format(const char* id, const char* defaultFormat, ...) const throw();
virtual std::string format(const char* id, const char* defaultFormat, ...) const noexcept;
private:
mutable std::string m_what;
};
@ -62,7 +62,7 @@ class name_ : public super_ { \
public: \
name_() : super_() { } \
name_(const std::string& msg) : super_(msg) { } \
virtual ~name_() _NOEXCEPT { } \
virtual ~name_() noexcept { } \
}
/*!
@ -76,10 +76,10 @@ class name_ : public super_ { \
public: \
name_() : super_() { } \
name_(const std::string& msg) : super_(msg) { } \
virtual ~name_() _NOEXCEPT { } \
virtual ~name_() noexcept { } \
\
protected: \
virtual std::string getWhat() const throw(); \
virtual std::string getWhat() const noexcept; \
}
/*!
@ -98,9 +98,9 @@ private: \
public: \
name_() : super_(), m_state(kDone) { } \
name_(const std::string& msg) : super_(msg), m_state(kFirst) { } \
virtual ~name_() _NOEXCEPT { } \
virtual ~name_() noexcept { } \
\
virtual const char* what() const _NOEXCEPT \
virtual const char* what() const noexcept \
{ \
if (m_state == kFirst) { \
m_state = kFormat; \
@ -116,7 +116,7 @@ public: \
} \
\
protected: \
virtual std::string getWhat() const throw(); \
virtual std::string getWhat() const noexcept; \
\
private: \
mutable EState m_state; \

View File

@ -38,11 +38,11 @@
#include "base/IEventQueue.h"
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
#include "common/stdexcept.h"
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stdexcept>
#include <fstream>
//

View File

@ -1,23 +0,0 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
// apple declares _NOEXCEPT
#ifndef _NOEXCEPT
# define _NOEXCEPT throw()
#endif

View File

@ -22,7 +22,7 @@
// XIOClosed
//
std::string XIOClosed::getWhat() const throw()
std::string XIOClosed::getWhat() const noexcept
{
return format("XIOClosed", "already closed");
}
@ -32,7 +32,7 @@ std::string XIOClosed::getWhat() const throw()
// XIOEndOfStream
//
std::string XIOEndOfStream::getWhat() const throw()
std::string XIOEndOfStream::getWhat() const noexcept
{
return format("XIOEndOfStream", "reached end of stream");
}
@ -42,7 +42,7 @@ std::string XIOEndOfStream::getWhat() const throw()
// XIOWouldBlock
//
std::string XIOWouldBlock::getWhat() const throw()
std::string XIOWouldBlock::getWhat() const noexcept
{
return format("XIOWouldBlock", "stream operation would block");
}

View File

@ -22,7 +22,7 @@
// XMTThreadUnavailable
//
std::string XMTThreadUnavailable::getWhat() const throw()
std::string XMTThreadUnavailable::getWhat() const noexcept
{
return format("XMTThreadUnavailable", "cannot create thread");
}

View File

@ -23,7 +23,7 @@
// XSocketAddress
//
XSocketAddress::XSocketAddress(EError error, const std::string& hostname, int port) _NOEXCEPT :
XSocketAddress::XSocketAddress(EError error, const std::string& hostname, int port) noexcept :
m_error(error),
m_hostname(hostname),
m_port(port)
@ -31,25 +31,22 @@ XSocketAddress::XSocketAddress(EError error, const std::string& hostname, int po
// do nothing
}
XSocketAddress::EError
XSocketAddress::getError() const throw()
XSocketAddress::EError XSocketAddress::getError() const noexcept
{
return m_error;
}
std::string
XSocketAddress::getHostname() const throw()
std::string XSocketAddress::getHostname() const noexcept
{
return m_hostname;
}
int
XSocketAddress::getPort() const throw()
int XSocketAddress::getPort() const noexcept
{
return m_port;
}
std::string XSocketAddress::getWhat() const throw()
std::string XSocketAddress::getWhat() const noexcept
{
static const char* s_errorID[] = {
"XSocketAddressUnknown",
@ -75,7 +72,7 @@ std::string XSocketAddress::getWhat() const throw()
// XSocketIOClose
//
std::string XSocketIOClose::getWhat() const throw()
std::string XSocketIOClose::getWhat() const noexcept
{
return format("XSocketIOClose", "close: %{1}", what());
}
@ -85,7 +82,7 @@ std::string XSocketIOClose::getWhat() const throw()
// XSocketBind
//
std::string XSocketBind::getWhat() const throw()
std::string XSocketBind::getWhat() const noexcept
{
return format("XSocketBind", "cannot bind address: %{1}", what());
}
@ -95,7 +92,7 @@ std::string XSocketBind::getWhat() const throw()
// XSocketConnect
//
std::string XSocketConnect::getWhat() const throw()
std::string XSocketConnect::getWhat() const noexcept
{
return format("XSocketConnect", "cannot connect socket: %{1}", what());
}
@ -105,7 +102,7 @@ std::string XSocketConnect::getWhat() const throw()
// XSocketCreate
//
std::string XSocketCreate::getWhat() const throw()
std::string XSocketCreate::getWhat() const noexcept
{
return format("XSocketCreate", "cannot create socket: %{1}", what());
}

View File

@ -40,24 +40,24 @@ public:
kBadPort //!< The port is invalid
};
XSocketAddress(EError, const std::string& hostname, int port) _NOEXCEPT;
virtual ~XSocketAddress() _NOEXCEPT { }
XSocketAddress(EError, const std::string& hostname, int port) noexcept;
virtual ~XSocketAddress() noexcept { }
//! @name accessors
//@{
//! Get the error code
EError getError() const throw();
EError getError() const noexcept;
//! Get the hostname
std::string getHostname() const throw();
std::string getHostname() const noexcept;
//! Get the port
int getPort() const throw();
int getPort() const noexcept;
//@}
protected:
// XBase overrides
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
private:
EError m_error;

View File

@ -88,5 +88,5 @@ public:
XMSWindowsWatchdogError(const std::string& msg) : XBarrier(msg) { }
// XBase overrides
virtual std::string getWhat() const throw() { return what(); }
virtual std::string getWhat() const noexcept { return what(); }
};

View File

@ -2271,12 +2271,12 @@ XConfigRead::XConfigRead(const ConfigReadContext& context, const char* errorFmt,
// do nothing
}
XConfigRead::~XConfigRead() _NOEXCEPT
XConfigRead::~XConfigRead() noexcept
{
// do nothing
}
std::string XConfigRead::getWhat() const throw()
std::string XConfigRead::getWhat() const noexcept
{
return format("XConfigRead", "read error: %{1}", m_error.c_str());
}

View File

@ -521,11 +521,11 @@ class XConfigRead : public XBase {
public:
XConfigRead(const ConfigReadContext& context, const std::string&);
XConfigRead(const ConfigReadContext& contex, const char* errorFmt, const std::string& arg);
virtual ~XConfigRead() _NOEXCEPT;
virtual ~XConfigRead() noexcept;
protected:
// XBase overrides
virtual std::string getWhat() const throw();
virtual std::string getWhat() const noexcept;
private:
std::string m_error;

View File

@ -43,14 +43,13 @@
#include "base/IEventQueue.h"
#include "base/Log.h"
#include "base/TMethodEventJob.h"
#include "common/stdexcept.h"
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <ctime>
#include <stdexcept>
//
// Server
//

View File

@ -20,7 +20,7 @@
#include "base/Log.h"
#include "base/TMethodEventJob.h"
#include "base/SimpleEventQueueBuffer.h"
#include "common/stdexcept.h"
#include <stdexcept>
void
TestEventQueue::raiseQuitEvent()

View File

@ -38,7 +38,7 @@
#include "base/TMethodEventJob.h"
#include "base/TMethodJob.h"
#include "base/Log.h"
#include "common/stdexcept.h"
#include <stdexcept>
#include "test/global/gtest.h"
#include <sstream>