MCPcopy Create free account
hub / github.com/argotorg/solidity / runCompiler

Method runCompiler

test/tools/fuzzer_common.cpp:129–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129void FuzzerUtil::runCompiler(std::string const& _input, bool _quiet)
130{
131 if (!_quiet)
132 std::cout << "Input JSON: " << _input << std::endl;
133 std::string outputString(solidity_compile(_input.c_str(), nullptr, nullptr));
134 if (!_quiet)
135 std::cout << "Output JSON: " << outputString << std::endl;
136
137 // This should be safe given the above copies the output.
138 solidity_reset();
139
140 Json output;
141 if (!jsonParseStrict(outputString, output))
142 {
143 std::string msg{"Compiler produced invalid JSON output."};
144 std::cout << msg << std::endl;
145 BOOST_THROW_EXCEPTION(std::runtime_error(std::move(msg)));
146 }
147 if (output.contains("errors"))
148 for (auto const& error: output["errors"])
149 {
150 std::string invalid = findAnyOf(error["type"].get<std::string>(), std::vector<std::string>{
151 "Exception",
152 "InternalCompilerError"
153 });
154 if (!invalid.empty())
155 {
156 std::string msg = "Invalid error: \"" + error["type"].get<std::string>() + "\"";
157 std::cout << msg << std::endl;
158 BOOST_THROW_EXCEPTION(std::runtime_error(std::move(msg)));
159 }
160 }
161}
162
163void FuzzerUtil::testConstantOptimizer(std::string const& _input, bool _quiet)
164{

Callers

nothing calls this directly

Calls 6

solidity_compileFunction · 0.85
solidity_resetFunction · 0.85
jsonParseStrictFunction · 0.85
findAnyOfFunction · 0.85
containsMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected