clang: Enable -Weverything, fix all warnings

This change fixes the following warnings:

```
    -Wc++98-compat-extra-semi
    -Wc++98-compat-local-type-template-args
    -Wc++98-compat-pedantic
    -Wc++98-compat
    -Wcomma
    -Wdeprecated-copy-dtor
    -Wexit-time-destructors
    -Wextra-semi-stmt
    -Wextra-semi
    -Wfloat-conversion
    -Wfloat-equal
    -Wformat-nonliteral
    -Wglobal-constructors
    -Winconsistent-missing-destructor-override
    -Wnon-virtual-dtor
    -Wold-style-cast
    -Wpadded
    -Wreturn-std-move-in-c++11
    -Wshadow-field-in-constructor
    -Wshadow-uncaptured-local
    -Wshift-sign-overflow
    -Wsign-conversion
    -Wundef
    -Wunreachable-code-return
    -Wused-but-marked-unused
    -Wweak-vtables
    -Wzero-as-null-pointer-constant
```
This commit is contained in:
Ben Clayton
2020-06-10 12:31:43 +01:00
parent bb3dbcd2c3
commit 9d3f5c8f1d
15 changed files with 76 additions and 755 deletions

View File

@@ -89,7 +89,7 @@ class future {
};
template <typename T>
future<T>::future(const std::shared_ptr<State>& state) : state(state) {}
future<T>::future(const std::shared_ptr<State>& s) : state(s) {}
template <typename T>
bool future<T>::valid() const {

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,8 @@ struct Field {
// Methods that return a bool use this to indicate success.
class Deserializer {
public:
virtual ~Deserializer() = default;
// deserialization methods for simple data types.
// If the stored object is not of the correct type, then these function will
// return false.
@@ -104,7 +106,7 @@ bool Deserializer::deserialize(dap::optional<T>* opt) const {
T v;
if (deserialize(&v)) {
*opt = v;
};
}
return true;
}
@@ -132,6 +134,8 @@ class FieldSerializer;
// Methods that return a bool use this to indicate success.
class Serializer {
public:
virtual ~Serializer() = default;
// serialization methods for simple data types.
virtual bool serialize(boolean) = 0;
virtual bool serialize(integer) = 0;
@@ -215,6 +219,8 @@ class FieldSerializer {
template <typename T>
using IsSerializeFunc = std::is_convertible<T, SerializeFunc>;
virtual ~FieldSerializer() = default;
// field() encodes a field to the struct object referenced by this Serializer.
// The SerializeFunc will be called with a Serializer used to encode the
// field's data.

View File

@@ -98,14 +98,13 @@ struct ResponseOrError {
};
template <typename T>
ResponseOrError<T>::ResponseOrError(const T& response) : response(response) {}
ResponseOrError<T>::ResponseOrError(const T& resp) : response(resp) {}
template <typename T>
ResponseOrError<T>::ResponseOrError(T&& response)
: response(std::move(response)) {}
ResponseOrError<T>::ResponseOrError(T&& resp) : response(std::move(resp)) {}
template <typename T>
ResponseOrError<T>::ResponseOrError(const Error& error) : error(error) {}
ResponseOrError<T>::ResponseOrError(const Error& err) : error(err) {}
template <typename T>
ResponseOrError<T>::ResponseOrError(Error&& error) : error(std::move(error)) {}
ResponseOrError<T>::ResponseOrError(Error&& err) : error(std::move(err)) {}
template <typename T>
ResponseOrError<T>::ResponseOrError(const ResponseOrError& other)
: response(other.response), error(other.error) {}
@@ -148,7 +147,7 @@ class Session {
using ArgTy = typename detail::ArgTy<F>::type;
public:
virtual ~Session() = default;
virtual ~Session();
// ErrorHandler is the type of callback function used for reporting protocol
// errors.

View File

@@ -28,6 +28,7 @@ class Serializer;
// types. TypeInfo is used by the serialization system to encode and decode DAP
// requests, responses, events and structs.
struct TypeInfo {
virtual ~TypeInfo();
virtual std::string name() const = 0;
virtual size_t size() const = 0;
virtual size_t alignment() const = 0;

View File

@@ -26,7 +26,7 @@ namespace dap {
// template type T.
template <typename T>
struct BasicTypeInfo : public TypeInfo {
BasicTypeInfo(const std::string& name) : name_(name) {}
constexpr BasicTypeInfo(std::string&& name) : name_(std::move(name)) {}
// TypeInfo compliance
inline std::string name() const { return name_; }
@@ -88,6 +88,15 @@ struct TypeOf<null> {
static const TypeInfo* type();
};
// TypeOf for template types requires dynamic generation of type information,
// triggering the clang -Wexit-time-destructors warning.
// TODO(bclayton): See if there's a way to avoid this, without requiring manual
// instantiation of each type.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif // __clang__
template <typename T>
struct TypeOf<array<T>> {
static inline const TypeInfo* type() {
@@ -114,6 +123,10 @@ struct TypeOf<optional<T>> {
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif // __clang__
// DAP_OFFSETOF() macro is a generalization of the offsetof() macro defined in
// <cstddef>. It evaluates to the offset of the given field, with fewer
// restrictions than offsetof(). We cast the address '32' and subtract it again,

View File

@@ -72,7 +72,7 @@ variant<T0, Types...>::variant() : value(T0()) {}
template <typename T0, typename... Types>
template <typename T>
variant<T0, Types...>::variant(const T& value) : value(value) {
variant<T0, Types...>::variant(const T& v) : value(v) {
static_assert(accepts<T>(), "variant does not accept template type T");
}