/src/solidity/libsolidity/interface/DebugSettings.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | This file is part of solidity. |
3 | | |
4 | | solidity is free software: you can redistribute it and/or modify |
5 | | it under the terms of the GNU General Public License as published by |
6 | | the Free Software Foundation, either version 3 of the License, or |
7 | | (at your option) any later version. |
8 | | |
9 | | solidity is distributed in the hope that it will be useful, |
10 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | GNU General Public License for more details. |
13 | | |
14 | | You should have received a copy of the GNU General Public License |
15 | | along with solidity. If not, see <http://www.gnu.org/licenses/>. |
16 | | */ |
17 | | // SPDX-License-Identifier: GPL-3.0 |
18 | | /** |
19 | | * Settings to aid debugging. |
20 | | */ |
21 | | |
22 | | #pragma once |
23 | | |
24 | | #include <cstddef> |
25 | | #include <string> |
26 | | #include <optional> |
27 | | |
28 | | namespace solidity::frontend |
29 | | { |
30 | | |
31 | | enum class RevertStrings |
32 | | { |
33 | | |
34 | | Default, // no compiler-generated strings, keep user-supplied strings |
35 | | Strip, // no compiler-generated strings, remove user-supplied strings (if possible) |
36 | | Debug, // add strings for internal reverts, keep user-supplied strings |
37 | | VerboseDebug // add strings for internal reverts, add user-supplied strings if not provided |
38 | | }; |
39 | | |
40 | | inline std::string revertStringsToString(RevertStrings _str) |
41 | 0 | { |
42 | 0 | switch (_str) |
43 | 0 | { |
44 | 0 | case RevertStrings::Default: return "default"; |
45 | 0 | case RevertStrings::Strip: return "strip"; |
46 | 0 | case RevertStrings::Debug: return "debug"; |
47 | 0 | case RevertStrings::VerboseDebug: return "verboseDebug"; |
48 | 0 | } |
49 | | // Cannot reach this. |
50 | 0 | return "INVALID"; |
51 | 0 | } |
52 | | |
53 | | inline std::optional<RevertStrings> revertStringsFromString(std::string const& _str) |
54 | 0 | { |
55 | 0 | for (auto i: {RevertStrings::Default, RevertStrings::Strip, RevertStrings::Debug, RevertStrings::VerboseDebug}) |
56 | 0 | if (revertStringsToString(i) == _str) |
57 | 0 | return i; |
58 | 0 | return std::nullopt; |
59 | 0 | } |
60 | | |
61 | | } |