eliminate -Wweak-vtables warnings

master
Daniel Kolesa 2018-01-05 22:31:04 +01:00
parent 770ed476ca
commit 51d7a62bee
16 changed files with 126 additions and 15 deletions

View File

@ -28,6 +28,9 @@ namespace fs = ostd::filesystem;
#include "src/io.cc"
#include "src/process.cc"
#include "src/filesystem.cc"
#include "src/channel.cc"
#include "src/string.cc"
#include "src/argparse.cc"
#define OSTD_GEN_UNICODE_INCLUDE
#include "gen_unicode.cc"
@ -60,15 +63,15 @@ static fs::path OSTD_SHARED_LIB = "libostd.so";
static fs::path OSTD_STATIC_LIB = "libostd.a";
static std::string DEFAULT_CXXFLAGS = "-std=c++1z -I. -O2 -Wall -Wextra "
"-Wshadow -Wold-style-cast";
"-Wshadow -Wold-style-cast -fPIC";
static std::string DEFAULT_LDFLAGS = "-pthread";
static std::string DEFAULT_ASFLAGS = "";
static std::string DEFAULT_ASFLAGS = "-fPIC";
static std::string DEBUG_CXXFLAGS = "-g";
static std::string SHARED_CXXFLAGS = "-fPIC";
static std::string SHARED_CXXFLAGS = "";
static std::string SHARED_LDFLAGS = "-shared";
static std::string SHARED_ASFLAGS = "-fPIC";
static std::string SHARED_ASFLAGS = "";
/* DO NOT CHANGE PAST THIS POINT */

View File

@ -44,6 +44,9 @@ namespace ostd {
struct arg_error: std::runtime_error {
using std::runtime_error::runtime_error;
/* empty, for vtable placement */
virtual ~arg_error();
template<typename ...A>
arg_error(string_range fmt, A const &...args):
arg_error(format(appender<std::string>(), fmt, args...).get())
@ -101,7 +104,7 @@ struct arg_description {
friend struct arg_group;
/** @brief The base class contains no data. */
virtual ~arg_description() {}
virtual ~arg_description();
/** @brief Gets an ostd::arg_type for the class. */
virtual arg_type type() const noexcept = 0;
@ -136,6 +139,9 @@ protected:
* It's not instantiated directly.
*/
struct arg_argument: arg_description {
/* empty, for vtable placement */
virtual ~arg_argument();
/** @brief Sets the help for the argument.
*
* The help string is stored internally. Returns itself.
@ -226,6 +232,9 @@ struct arg_optional: arg_argument {
friend struct arg_group;
friend struct arg_mutually_exclusive_group;
/* empty, for vtable placement */
virtual ~arg_optional();
/** @brief Gets the argument class type (ostd::arg_type).
*
* The value is always `OPTIONAL`.
@ -519,6 +528,9 @@ struct arg_positional: arg_argument {
friend struct basic_arg_parser;
friend struct arg_description_container;
/* empty, for vtable placement */
virtual ~arg_positional();
/** @brief Gets the argument class type (ostd::arg_type).
*
* The value is always `POSITIONAL`.
@ -662,6 +674,9 @@ private:
struct arg_mutually_exclusive_group: arg_description {
friend struct arg_description_container;
/* empty, for vtable placement */
virtual ~arg_mutually_exclusive_group();
/** @brief Gets the argument class type (ostd::arg_type).
*
* The value is always `MUTUALLY_EXCLUSIVE_GROUP`.
@ -866,6 +881,9 @@ struct arg_group: arg_description, arg_description_container {
template<typename HelpFormatter>
friend struct basic_arg_parser;
/* empty, for vtable placement */
virtual ~arg_group();
/** @brief Gets the argument class type (ostd::arg_type).
*
* The value is always `GROUP`.

View File

@ -35,6 +35,8 @@ namespace ostd {
/** @brief Thrown when manipulating a channel that has been closed. */
struct channel_error: std::logic_error {
using std::logic_error::logic_error;
/* empty, for vtable placement */
virtual ~channel_error();
};
/** @brief A thread-safe message queue.

View File

@ -236,7 +236,7 @@ protected:
public:
/** @brief Does nothing, this base class is empty. */
virtual ~scheduler() {}
virtual ~scheduler();
scheduler(scheduler const &) = delete;
scheduler(scheduler &&) = delete;
@ -553,6 +553,9 @@ namespace detail {
csched_task &operator=(csched_task const &) = delete;
csched_task &operator=(csched_task &&) = delete;
/* empty, for vtable placement */
virtual ~csched_task();
template<typename F, typename SA>
csched_task(F &&f, SA &&sa): p_func(std::forward<F>(f)) {
if (!p_func) {

View File

@ -56,6 +56,8 @@ namespace ostd {
*/
struct coroutine_error: std::runtime_error {
using std::runtime_error::runtime_error;
/* empty, for vtable placement */
virtual ~coroutine_error();
};
/** @brief An encapsulated context any coroutine-type inherits from.
@ -91,10 +93,7 @@ protected:
* stack is freed (if present) using the same stack allocator it was
* allocated with.
*/
virtual ~coroutine_context() {
unwind();
free_stack();
}
virtual ~coroutine_context();
coroutine_context(coroutine_context const &) = delete;

View File

@ -57,6 +57,8 @@ enum format_flags {
/** @brief Thrown when format string does not properly match the arguments. */
struct format_error: std::runtime_error {
using std::runtime_error::runtime_error;
/* empty, for vtable placement */
virtual ~format_error();
};
struct format_spec;

View File

@ -25,7 +25,7 @@ namespace ostd {
namespace detail {
struct cond_iface {
cond_iface() {}
virtual ~cond_iface() {}
virtual ~cond_iface();
virtual void notify_one() = 0;
virtual void notify_all() = 0;
virtual void wait(std::unique_lock<std::mutex> &) = 0;

View File

@ -34,6 +34,8 @@ namespace ostd {
/** @brief Thrown on errors in ostd::split_args(). */
struct word_error: std::runtime_error {
using std::runtime_error::runtime_error;
/* empty, for vtable placement */
virtual ~word_error();
};
namespace detail {
@ -81,6 +83,8 @@ Sink &&split_args(Sink &&out, string_range str) {
/** @brief Thrown on errors in ostd::subprocess. */
struct subprocess_error: std::runtime_error {
using std::runtime_error::runtime_error;
/* empty, for vtable placement */
virtual ~subprocess_error();
};
/** @brief The mode used for standard streams in ostd::subprocess.

View File

@ -90,6 +90,8 @@ struct stream_range;
/** @brief Thrown on stream errors. */
struct stream_error: std::system_error {
using std::system_error::system_error;
/* empty, for vtable placement */
virtual ~stream_error();
};
template<typename T = char, typename TC = std::basic_string<T>>
@ -105,7 +107,7 @@ struct stream {
using offset_type = stream_off_t;
/** @brief Does nothing by default. */
virtual ~stream() {}
virtual ~stream();
/** @brief Closes the stream.
*

View File

@ -747,6 +747,8 @@ namespace utf {
/** @brief Thrown on UTF-8 decoding failure. */
struct utf_error: std::runtime_error {
using std::runtime_error::runtime_error;
/* empty, for vtable placement */
virtual ~utf_error();
};
/* @brief Get the Unicode code point for a UTF-8 sequence.

22
src/argparse.cc 100644
View File

@ -0,0 +1,22 @@
/* Argparse implementation details.
*
* This file is part of libostd. See COPYING.md for futher information.
*/
#include "ostd/argparse.hh"
namespace ostd {
/* place the vtables in here */
arg_error::~arg_error() {}
arg_description::~arg_description() {}
arg_argument::~arg_argument() {}
arg_optional::~arg_optional() {}
arg_positional::~arg_positional() {}
arg_mutually_exclusive_group::~arg_mutually_exclusive_group() {}
arg_group::~arg_group() {}
} /* namespace ostd */

19
src/channel.cc 100644
View File

@ -0,0 +1,19 @@
/* Channel implementation bits.
*
* This file is part of libostd. See COPYING.md for futher information.
*/
#include "ostd/generic_condvar.hh"
#include "ostd/channel.hh"
namespace ostd {
/* place the vtable in here */
channel_error::~channel_error() {}
namespace detail {
/* vtable placement for generic_condvar */
cond_iface::~cond_iface() {}
} /* namespace detail */
} /* namespace ostd */

View File

@ -6,10 +6,24 @@
#include "ostd/concurrency.hh"
namespace ostd {
/* place the vtable in here */
coroutine_error::~coroutine_error() {}
/* non-inline for vtable placement */
coroutine_context::~coroutine_context() {
unwind();
free_stack();
}
namespace detail {
/* place the vtable here, derived from coroutine_context */
csched_task::~csched_task() {}
OSTD_EXPORT scheduler *current_scheduler = nullptr;
OSTD_EXPORT thread_local csched_task *current_csched_task = nullptr;
OSTD_EXPORT scheduler *current_scheduler = nullptr;
OSTD_EXPORT thread_local csched_task *current_csched_task = nullptr;
} /* namespace detail */
scheduler::~scheduler() {}
} /* namespace ostd */

View File

@ -8,10 +8,15 @@
#include <cstdlib>
#include <cerrno>
#include "ostd/stream.hh"
#include "ostd/io.hh"
namespace ostd {
/* place the vtable in here */
stream_error::~stream_error() {}
stream::~stream() {}
static char const *filemodes[] = {
"rb", "wb", "ab", "rb+", "wb+", "ab+"
};

View File

@ -12,3 +12,11 @@
#else
# error "Unsupported platform"
#endif
namespace ostd {
/* place the vtable in here */
word_error::~word_error() {}
subprocess_error::~subprocess_error() {}
} /* namespace ostd */

View File

@ -6,10 +6,14 @@
#include <cstdint>
#include <cstdlib>
#include "ostd/string.hh"
#include "ostd/format.hh"
namespace ostd {
namespace utf {
/* place the vtable in here */
utf_error::~utf_error() {}
constexpr char32_t MaxCodepoint = 0x10FFFF;
namespace detail {
@ -461,4 +465,8 @@ int case_compare(u32string_range s1, u32string_range s2) noexcept {
}
} /* namespace utf */
/* place the vtable in here */
format_error::~format_error() {}
} /* namespace ostd */