Enable more warnings (and fix them)
This brings the warnings settings in line with realm-cocoa's.
This commit is contained in:
parent
2ed029d74f
commit
bdc8dbc5b2
|
@ -1,9 +1,32 @@
|
|||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED on)
|
||||
set(CMAKE_CXX_EXTENSIONS off)
|
||||
add_compile_options(-Wall -DREALM_HAVE_CONFIG)
|
||||
add_compile_options("$<$<CONFIG:DEBUG>:-DREALM_DEBUG>")
|
||||
add_compile_options("$<$<CONFIG:COVERAGE>:-DREALM_DEBUG>")
|
||||
add_compile_options(
|
||||
-DREALM_HAVE_CONFIG
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-missing-field-initializers
|
||||
-Wempty-body
|
||||
-Wparentheses
|
||||
-Wunknown-pragmas
|
||||
-Wunreachable-code
|
||||
)
|
||||
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
add_compile_options(
|
||||
-Wassign-enum
|
||||
-Wbool-conversion
|
||||
-Wconditional-uninitialized
|
||||
-Wconstant-conversion
|
||||
-Wenum-conversion
|
||||
-Wint-conversion
|
||||
-Wmissing-prototypes
|
||||
-Wnewline-eof
|
||||
-Wshorten-64-to-32
|
||||
)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace realm {
|
|||
//
|
||||
// Deprecated
|
||||
//
|
||||
static Mixed to_mixed(ContextType ctx, ValueType &val) { throw std::runtime_error("'Any' type is unsupported"); }
|
||||
static Mixed to_mixed(ContextType, ValueType&) { throw std::runtime_error("'Any' type is unsupported"); }
|
||||
};
|
||||
|
||||
class InvalidatedObjectException : public std::runtime_error
|
||||
|
|
|
@ -201,14 +201,14 @@ template< typename Rule >
|
|||
struct action : nothing< Rule > {};
|
||||
|
||||
#ifdef REALM_PARSER_PRINT_TOKENS
|
||||
#define DEBUG_PRINT_TOKEN(string) std::cout << string << std::endl
|
||||
#define DEBUG_PRINT_TOKEN(string) do { std::cout << string << std::endl; while (0)
|
||||
#else
|
||||
#define DEBUG_PRINT_TOKEN(string)
|
||||
#define DEBUG_PRINT_TOKEN(string) do { static_cast<void>(string); } while (0)
|
||||
#endif
|
||||
|
||||
template<> struct action< and_op >
|
||||
{
|
||||
static void apply( const input & in, ParserState & state )
|
||||
static void apply(const input&, ParserState& state)
|
||||
{
|
||||
DEBUG_PRINT_TOKEN("<and>");
|
||||
state.next_type = Predicate::Type::And;
|
||||
|
@ -217,7 +217,7 @@ template<> struct action< and_op >
|
|||
|
||||
template<> struct action< or_op >
|
||||
{
|
||||
static void apply( const input & in, ParserState & state )
|
||||
static void apply(const input&, ParserState & state)
|
||||
{
|
||||
DEBUG_PRINT_TOKEN("<or>");
|
||||
state.next_type = Predicate::Type::Or;
|
||||
|
@ -227,7 +227,7 @@ template<> struct action< or_op >
|
|||
|
||||
#define EXPRESSION_ACTION(rule, type) \
|
||||
template<> struct action< rule > { \
|
||||
static void apply( const input & in, ParserState & state ) { \
|
||||
static void apply(const input& in, ParserState& state) { \
|
||||
DEBUG_PRINT_TOKEN(in.string()); \
|
||||
state.add_expression(Expression(type, in.string())); }};
|
||||
|
||||
|
@ -239,10 +239,10 @@ EXPRESSION_ACTION(true_value, Expression::Type::True)
|
|||
EXPRESSION_ACTION(false_value, Expression::Type::False)
|
||||
EXPRESSION_ACTION(null_value, Expression::Type::Null)
|
||||
EXPRESSION_ACTION(argument_index, Expression::Type::Argument)
|
||||
|
||||
|
||||
template<> struct action< true_pred >
|
||||
{
|
||||
static void apply( const input & in, ParserState & state )
|
||||
static void apply(const input& in, ParserState & state)
|
||||
{
|
||||
DEBUG_PRINT_TOKEN(in.string());
|
||||
state.current_group()->cpnd.sub_predicates.emplace_back(Predicate::Type::True);
|
||||
|
@ -251,7 +251,7 @@ template<> struct action< true_pred >
|
|||
|
||||
template<> struct action< false_pred >
|
||||
{
|
||||
static void apply( const input & in, ParserState & state )
|
||||
static void apply(const input& in, ParserState & state)
|
||||
{
|
||||
DEBUG_PRINT_TOKEN(in.string());
|
||||
state.current_group()->cpnd.sub_predicates.emplace_back(Predicate::Type::False);
|
||||
|
@ -260,7 +260,7 @@ template<> struct action< false_pred >
|
|||
|
||||
#define OPERATOR_ACTION(rule, oper) \
|
||||
template<> struct action< rule > { \
|
||||
static void apply( const input & in, ParserState & state ) { \
|
||||
static void apply(const input& in, ParserState& state) { \
|
||||
DEBUG_PRINT_TOKEN(in.string()); \
|
||||
state.last_predicate()->cmpr.op = oper; }};
|
||||
|
||||
|
@ -273,19 +273,19 @@ OPERATOR_ACTION(lt, Predicate::Operator::LessThan)
|
|||
OPERATOR_ACTION(begins, Predicate::Operator::BeginsWith)
|
||||
OPERATOR_ACTION(ends, Predicate::Operator::EndsWith)
|
||||
OPERATOR_ACTION(contains, Predicate::Operator::Contains)
|
||||
|
||||
|
||||
template<> struct action< case_insensitive >
|
||||
{
|
||||
static void apply( const input & in, ParserState & state )
|
||||
static void apply(const input& in, ParserState & state)
|
||||
{
|
||||
DEBUG_PRINT_TOKEN(in.string());
|
||||
state.last_predicate()->cmpr.option = Predicate::OperatorOption::CaseInsensitive;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<> struct action< one< '(' > >
|
||||
{
|
||||
static void apply( const input & in, ParserState & state )
|
||||
static void apply(const input&, ParserState & state)
|
||||
{
|
||||
DEBUG_PRINT_TOKEN("<begin_group>");
|
||||
state.add_predicate_to_current_group(Predicate::Type::And);
|
||||
|
@ -295,7 +295,7 @@ template<> struct action< one< '(' > >
|
|||
|
||||
template<> struct action< group_pred >
|
||||
{
|
||||
static void apply( const input & in, ParserState & state )
|
||||
static void apply(const input&, ParserState & state)
|
||||
{
|
||||
DEBUG_PRINT_TOKEN("<end_group>");
|
||||
state.group_stack.pop_back();
|
||||
|
@ -304,7 +304,7 @@ template<> struct action< group_pred >
|
|||
|
||||
template<> struct action< not_pre >
|
||||
{
|
||||
static void apply( const input & in, ParserState & state )
|
||||
static void apply(const input&, ParserState & state)
|
||||
{
|
||||
DEBUG_PRINT_TOKEN("<not>");
|
||||
state.negate_next = true;
|
||||
|
@ -317,9 +317,9 @@ struct error_message_control : pegtl::normal< Rule >
|
|||
static const std::string error_message;
|
||||
|
||||
template< typename Input, typename ... States >
|
||||
static void raise( const Input & in, States && ... )
|
||||
static void raise(const Input& in, States&&...)
|
||||
{
|
||||
throw pegtl::parse_error( error_message, in );
|
||||
throw pegtl::parse_error(error_message, in);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -351,5 +351,3 @@ void analyze_grammar()
|
|||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
|
|
@ -27,10 +27,11 @@
|
|||
#include <assert.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace realm {
|
||||
namespace query_builder {
|
||||
using namespace realm;
|
||||
using namespace parser;
|
||||
using namespace query_builder;
|
||||
|
||||
namespace {
|
||||
template<typename T>
|
||||
T stot(std::string const& s) {
|
||||
std::istringstream iss(s);
|
||||
|
@ -268,12 +269,12 @@ void add_link_constraint_to_query(realm::Query &query,
|
|||
}
|
||||
}
|
||||
|
||||
auto link_argument(const PropertyExpression &propExpr, const parser::Expression &argExpr, Arguments &args)
|
||||
auto link_argument(const PropertyExpression&, const parser::Expression &argExpr, Arguments &args)
|
||||
{
|
||||
return args.object_index_for_argument(stot<int>(argExpr.s));
|
||||
}
|
||||
|
||||
auto link_argument(const parser::Expression &argExpr, const PropertyExpression &propExpr, Arguments &args)
|
||||
auto link_argument(const parser::Expression &argExpr, const PropertyExpression&, Arguments &args)
|
||||
{
|
||||
return args.object_index_for_argument(stot<int>(argExpr.s));
|
||||
}
|
||||
|
@ -281,7 +282,7 @@ auto link_argument(const parser::Expression &argExpr, const PropertyExpression &
|
|||
|
||||
template <typename RetType, typename TableGetter>
|
||||
struct ColumnGetter {
|
||||
static Columns<RetType> convert(TableGetter&& table, const PropertyExpression & expr, Arguments &args)
|
||||
static Columns<RetType> convert(TableGetter&& table, const PropertyExpression& expr, Arguments&)
|
||||
{
|
||||
return table()->template column<RetType>(expr.prop->table_column);
|
||||
}
|
||||
|
@ -382,7 +383,7 @@ auto value_of_type_for_query(TableGetter&& tables, Value&& value, Arguments &arg
|
|||
}
|
||||
|
||||
template <typename A, typename B>
|
||||
void do_add_comparison_to_query(Query &query, const Schema &schema, const ObjectSchema &object_schema, Predicate::Comparison cmp,
|
||||
void do_add_comparison_to_query(Query &query, Predicate::Comparison cmp,
|
||||
const PropertyExpression &expr, A &lhs, B &rhs, Arguments &args)
|
||||
{
|
||||
auto type = expr.prop->type;
|
||||
|
@ -425,7 +426,7 @@ void do_add_comparison_to_query(Query &query, const Schema &schema, const Object
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void do_add_null_comparison_to_query(Query &query, Predicate::Operator op, const PropertyExpression &expr, Arguments &args)
|
||||
void do_add_null_comparison_to_query(Query &query, Predicate::Operator op, const PropertyExpression &expr)
|
||||
{
|
||||
Columns<T> column = expr.table_getter()->template column<T>(expr.prop->table_column);
|
||||
switch (op) {
|
||||
|
@ -441,7 +442,7 @@ void do_add_null_comparison_to_query(Query &query, Predicate::Operator op, const
|
|||
}
|
||||
|
||||
template<>
|
||||
void do_add_null_comparison_to_query<Binary>(Query &query, Predicate::Operator op, const PropertyExpression &expr, Arguments &args)
|
||||
void do_add_null_comparison_to_query<Binary>(Query &query, Predicate::Operator op, const PropertyExpression &expr)
|
||||
{
|
||||
precondition(expr.indexes.empty(), "KeyPath queries not supported for data comparisons.");
|
||||
Columns<Binary> column = expr.table_getter()->template column<Binary>(expr.prop->table_column);
|
||||
|
@ -458,7 +459,7 @@ void do_add_null_comparison_to_query<Binary>(Query &query, Predicate::Operator o
|
|||
}
|
||||
|
||||
template<>
|
||||
void do_add_null_comparison_to_query<Link>(Query &query, Predicate::Operator op, const PropertyExpression &expr, Arguments &args)
|
||||
void do_add_null_comparison_to_query<Link>(Query &query, Predicate::Operator op, const PropertyExpression &expr)
|
||||
{
|
||||
precondition(expr.indexes.empty(), "KeyPath queries not supported for object comparisons.");
|
||||
switch (op) {
|
||||
|
@ -473,40 +474,38 @@ void do_add_null_comparison_to_query<Link>(Query &query, Predicate::Operator op,
|
|||
}
|
||||
}
|
||||
|
||||
void do_add_null_comparison_to_query(Query &query, const Schema &schema, const ObjectSchema &object_schema, Predicate::Comparison cmp,
|
||||
const PropertyExpression &expr, Arguments &args)
|
||||
void do_add_null_comparison_to_query(Query &query, Predicate::Comparison cmp, const PropertyExpression &expr)
|
||||
{
|
||||
auto type = expr.prop->type;
|
||||
switch (type) {
|
||||
case realm::PropertyType::Bool:
|
||||
do_add_null_comparison_to_query<bool>(query, cmp.op, expr, args);
|
||||
do_add_null_comparison_to_query<bool>(query, cmp.op, expr);
|
||||
break;
|
||||
case realm::PropertyType::Date:
|
||||
do_add_null_comparison_to_query<Timestamp>(query, cmp.op, expr, args);
|
||||
do_add_null_comparison_to_query<Timestamp>(query, cmp.op, expr);
|
||||
break;
|
||||
case realm::PropertyType::Double:
|
||||
do_add_null_comparison_to_query<Double>(query, cmp.op, expr, args);
|
||||
do_add_null_comparison_to_query<Double>(query, cmp.op, expr);
|
||||
break;
|
||||
case realm::PropertyType::Float:
|
||||
do_add_null_comparison_to_query<Float>(query, cmp.op, expr, args);
|
||||
do_add_null_comparison_to_query<Float>(query, cmp.op, expr);
|
||||
break;
|
||||
case realm::PropertyType::Int:
|
||||
do_add_null_comparison_to_query<Int>(query, cmp.op, expr, args);
|
||||
do_add_null_comparison_to_query<Int>(query, cmp.op, expr);
|
||||
break;
|
||||
case realm::PropertyType::String:
|
||||
do_add_null_comparison_to_query<String>(query, cmp.op, expr, args);
|
||||
do_add_null_comparison_to_query<String>(query, cmp.op, expr);
|
||||
break;
|
||||
case realm::PropertyType::Data:
|
||||
do_add_null_comparison_to_query<Binary>(query, cmp.op, expr, args);
|
||||
do_add_null_comparison_to_query<Binary>(query, cmp.op, expr);
|
||||
break;
|
||||
case realm::PropertyType::Object:
|
||||
do_add_null_comparison_to_query<Link>(query, cmp.op, expr, args);
|
||||
do_add_null_comparison_to_query<Link>(query, cmp.op, expr);
|
||||
break;
|
||||
case realm::PropertyType::Array:
|
||||
throw std::runtime_error("Comparing Lists to 'null' is not supported");
|
||||
default: {
|
||||
throw std::runtime_error(std::string("Object type ") + string_for_property_type(type) + " not supported");
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error(util::format("Object type '%1' not supported", string_for_property_type(type)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,19 +527,19 @@ void add_comparison_to_query(Query &query, const Predicate &pred, Arguments &arg
|
|||
if (t0 == parser::Expression::Type::KeyPath && t1 != parser::Expression::Type::KeyPath) {
|
||||
PropertyExpression expr(query, schema, object_schema, cmpr.expr[0].s);
|
||||
if (expression_is_null(cmpr.expr[1], args)) {
|
||||
do_add_null_comparison_to_query(query, schema, *object_schema, cmpr, expr, args);
|
||||
do_add_null_comparison_to_query(query, cmpr, expr);
|
||||
}
|
||||
else {
|
||||
do_add_comparison_to_query(query, schema, *object_schema, cmpr, expr, expr, cmpr.expr[1], args);
|
||||
do_add_comparison_to_query(query, cmpr, expr, expr, cmpr.expr[1], args);
|
||||
}
|
||||
}
|
||||
else if (t0 != parser::Expression::Type::KeyPath && t1 == parser::Expression::Type::KeyPath) {
|
||||
PropertyExpression expr(query, schema, object_schema, cmpr.expr[1].s);
|
||||
if (expression_is_null(cmpr.expr[0], args)) {
|
||||
do_add_null_comparison_to_query(query, schema, *object_schema, cmpr, expr, args);
|
||||
do_add_null_comparison_to_query(query, cmpr, expr);
|
||||
}
|
||||
else {
|
||||
do_add_comparison_to_query(query, schema, *object_schema, cmpr, expr, cmpr.expr[0], expr, args);
|
||||
do_add_comparison_to_query(query, cmpr, expr, cmpr.expr[0], expr, args);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -594,6 +593,10 @@ void update_query_with_predicate(Query &query, const Predicate &pred, Arguments
|
|||
throw std::runtime_error("Invalid predicate type");
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
namespace realm {
|
||||
namespace query_builder {
|
||||
|
||||
void apply_predicate(Query &query, const Predicate &predicate, Arguments &arguments, const Schema &schema, const std::string &objectType)
|
||||
{
|
||||
|
@ -604,4 +607,5 @@ void apply_predicate(Query &query, const Predicate &predicate, Arguments &argume
|
|||
precondition(validateMessage.empty(), validateMessage.c_str());
|
||||
}
|
||||
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ TEST_CASE("list") {
|
|||
};
|
||||
|
||||
auto require_change = [&] {
|
||||
auto token = lst.add_notification_callback([&](CollectionChangeSet c, std::exception_ptr err) {
|
||||
auto token = lst.add_notification_callback([&](CollectionChangeSet c, std::exception_ptr) {
|
||||
change = c;
|
||||
});
|
||||
advance_and_notify(*r);
|
||||
|
@ -81,7 +81,7 @@ TEST_CASE("list") {
|
|||
|
||||
auto require_no_change = [&] {
|
||||
bool first = true;
|
||||
auto token = lst.add_notification_callback([&, first](CollectionChangeSet c, std::exception_ptr err) mutable {
|
||||
auto token = lst.add_notification_callback([&, first](CollectionChangeSet, std::exception_ptr) mutable {
|
||||
REQUIRE(first);
|
||||
first = false;
|
||||
});
|
||||
|
|
|
@ -549,7 +549,7 @@ TEST_CASE("[results] notifications after move") {
|
|||
auto results = std::make_unique<Results>(r, *config.schema->find("object"), *table);
|
||||
|
||||
int notification_calls = 0;
|
||||
auto token = results->add_notification_callback([&](CollectionChangeSet c, std::exception_ptr err) {
|
||||
auto token = results->add_notification_callback([&](CollectionChangeSet, std::exception_ptr err) {
|
||||
REQUIRE_FALSE(err);
|
||||
++notification_calls;
|
||||
});
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
Group const& m_group;
|
||||
|
||||
LinkViewRef m_linkview;
|
||||
std::vector<int> m_initial;
|
||||
std::vector<int_fast64_t> m_initial;
|
||||
|
||||
void validate(CollectionChangeSet const& info)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue