X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/be2d18ff8c8ee4ccf6b713010f8999e7613dcdf5..5a006fa396cfcc8a91a8284f0d625b2a9a2565c9:/src/mc/inspect/DwarfExpression.hpp diff --git a/src/mc/inspect/DwarfExpression.hpp b/src/mc/inspect/DwarfExpression.hpp index 3a94b47239..2e8de126d0 100644 --- a/src/mc/inspect/DwarfExpression.hpp +++ b/src/mc/inspect/DwarfExpression.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -9,6 +9,7 @@ #include #include +#include #include // runtime_error #include #include @@ -24,8 +25,7 @@ * Evaluation of DWARF location expressions. */ -namespace simgrid { -namespace dwarf { +namespace simgrid::dwarf { /** A DWARF expression * @@ -62,12 +62,12 @@ public: */ class ExpressionStack { public: - using value_type = std::uintptr_t; - static const std::size_t max_size = 64; + using value_type = std::uintptr_t; + static constexpr std::size_t MAX_SIZE = 64; private: // Values of the stack (the top is stack_[size_ - 1]): - uintptr_t stack_[max_size]{0}; + std::array stack_{{0}}; size_t size_ = 0; public: @@ -97,9 +97,10 @@ public: /** Push a value on the top of the stack */ void push(value_type value) { - if (size_ == max_size) + if (size_ == stack_.size()) throw evaluation_error("DWARF stack overflow"); - stack_[size_++] = value; + stack_[size_] = value; + size_++; } /* Pop a value from the top of the stack */ @@ -107,7 +108,8 @@ public: { if (size_ == 0) throw evaluation_error("DWARF stack underflow"); - return stack_[--size_]; + --size_; + return stack_[size_]; } // These are DWARF operations (DW_OP_foo): @@ -140,7 +142,6 @@ inline void execute(simgrid::dwarf::DwarfExpression const& expression, Expressio execute(expression.data(), expression.size(), context, stack); } -} // namespace dwarf -} // namespace simgrid +} // namespace simgrid::dwarf #endif