Skip to content

Commit

Permalink
Merge pull request #418 from wasmx/clion
Browse files Browse the repository at this point in the history
Suggestions made by CLion's analyzer
  • Loading branch information
axic authored Jul 15, 2020
2 parents aab830d + c0e738a commit 776ce47
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
3 changes: 1 addition & 2 deletions lib/fizzy/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ inline parser_result<FuncType> parse(const uint8_t* pos, const uint8_t* end)
return {result, pos};
}

inline std::tuple<GlobalType, const uint8_t*> parse_global_type(
const uint8_t* pos, const uint8_t* end)
inline parser_result<GlobalType> parse_global_type(const uint8_t* pos, const uint8_t* end)
{
GlobalType type;
std::tie(type.value_type, pos) = parse<ValType>(pos, end);
Expand Down
3 changes: 1 addition & 2 deletions lib/fizzy/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
#include "exceptions.hpp"
#include "leb128.hpp"
#include "module.hpp"
#include <tuple>

namespace fizzy
{
constexpr uint8_t wasm_prefix_data[]{0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00};
constexpr bytes_view wasm_prefix{wasm_prefix_data, sizeof(wasm_prefix_data)};

template <typename T>
using parser_result = std::tuple<T, const uint8_t*>;
using parser_result = std::pair<T, const uint8_t*>;

Module parse(bytes_view input);

Expand Down
3 changes: 1 addition & 2 deletions lib/fizzy/parser_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ inline void validate_branch_stack_height(
}


void push_branch_immediates(
const ControlFrame& branch_frame, int stack_height, bytes& immediates) noexcept
void push_branch_immediates(const ControlFrame& branch_frame, int stack_height, bytes& immediates)
{
const auto arity = get_branch_arity(branch_frame);

Expand Down
2 changes: 1 addition & 1 deletion lib/fizzy/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class span
constexpr T& operator[](std::size_t index) const noexcept { return m_begin[index]; }

constexpr T* data() const noexcept { return m_begin; }
[[nodiscard]] constexpr std::size_t size() const noexcept { return m_size; }
constexpr std::size_t size() const noexcept { return m_size; }

constexpr iterator begin() const noexcept { return m_begin; }
constexpr iterator end() const noexcept { return m_begin + m_size; }
Expand Down
10 changes: 5 additions & 5 deletions lib/fizzy/stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ class OperandStack
OperandStack& operator=(const OperandStack&) = delete;

/// The current number of items on the stack (aka stack height).
[[nodiscard]] size_t size() noexcept { return static_cast<size_t>(m_top + 1 - bottom()); }
size_t size() noexcept { return static_cast<size_t>(m_top + 1 - bottom()); }

/// Returns the reference to the top item.
/// Requires non-empty stack.
[[nodiscard]] auto& top() noexcept
auto& top() noexcept
{
assert(size() != 0);
return *m_top;
}

/// Returns the reference to the stack item on given position from the stack top.
/// Requires index < size().
[[nodiscard]] auto& operator[](size_t index) noexcept
auto& operator[](size_t index) noexcept
{
assert(index < size());
return *(m_top - index);
Expand Down Expand Up @@ -146,9 +146,9 @@ class OperandStack
}

/// Returns iterator to the bottom of the stack.
[[nodiscard]] const uint64_t* rbegin() const noexcept { return bottom(); }
const uint64_t* rbegin() const noexcept { return bottom(); }

/// Returns end iterator counting from the bottom of the stack.
[[nodiscard]] const uint64_t* rend() const noexcept { return m_top + 1; }
const uint64_t* rend() const noexcept { return m_top + 1; }
};
} // namespace fizzy

0 comments on commit 776ce47

Please sign in to comment.