Skip to content

Commit

Permalink
Address gcc warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fsaintjacques committed Jan 28, 2020
1 parent 6d62f45 commit 701a32a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/jitmap/query/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <utility>
#include <vector>

#include <jitmap/util/exception.h>

namespace jitmap {
namespace query {

Expand Down Expand Up @@ -205,6 +207,8 @@ auto Expr::Visit(Visitor&& v) const {
case XOR_OPERATOR:
return v(dynamic_cast<const XorOpExpr*>(this));
}

throw Exception("Unknown type: ", type());
}

template <typename Visitor>
Expand All @@ -225,6 +229,8 @@ auto Expr::Visit(Visitor&& v) {
case XOR_OPERATOR:
return v(dynamic_cast<XorOpExpr*>(this));
}

throw Exception("Unknown type: ", type());
}

std::ostream& operator<<(std::ostream& os, const Expr& e);
Expand Down
16 changes: 16 additions & 0 deletions include/jitmap/util/compiler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2020 RStudio, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http:https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once

#define JITMAP_UNUSED(e) (void)(e);
7 changes: 7 additions & 0 deletions src/jitmap/query/expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "jitmap/query/matcher.h"
#include "jitmap/query/type_traits.h"
#include "jitmap/util/compiler.h"

namespace jitmap {
namespace query {
Expand Down Expand Up @@ -72,6 +73,10 @@ bool Expr::operator==(const Expr& rhs) const {
using E = std::decay_t<std::remove_pointer_t<decltype(left)>>;
const E* right = static_cast<const E*>(&rhs);

// GCC warns about unused `right`. This is due to the conditional constexpr
// in the literal case.
JITMAP_UNUSED(right);

if constexpr (is_literal<E>::value) return true;
if constexpr (is_variable<E>::value) return left->value() == right->value();
if constexpr (is_unary_op<E>::value) return *left->operand() == *right->operand();
Expand Down Expand Up @@ -102,6 +107,8 @@ static const char* OpToChar(Expr::Type op) {
case Expr::XOR_OPERATOR:
return "^";
}

throw Exception("Unkonwn operator type: ", op);
}

std::string Expr::ToString() const {
Expand Down
2 changes: 2 additions & 0 deletions src/jitmap/query/matcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ bool ChainMatcher::Match(const Expr& expr) const {
case ANY:
return std::any_of(matchers_.cbegin(), matchers_.cend(), match);
}

throw Exception("Unknown match type: ", mode_);
}

} // namespace query
Expand Down
2 changes: 2 additions & 0 deletions src/jitmap/query/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const char* TokenTypeToString(Token::Type type) {
case Token::Type::END_OF_STREAM:
return "EOS";
}

throw ParserException("Unkonwn token type: ", type);
}

std::ostream& operator<<(std::ostream& os, Token::Type type) {
Expand Down

0 comments on commit 701a32a

Please sign in to comment.