diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 9781b6278..fbaa39eed 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -442,17 +442,15 @@ void CompilerStack::importASTs(map const& _sources) void CompilerStack::importFromEVMAssemblyStack(std::string const& _sourceName, std::string const& _source) { solRequire(m_stackState == Empty, CompilerError, ""); - m_evmAssemblyStack = std::make_unique(m_evmVersion); + m_evmAssemblyStack = make_unique(m_evmVersion); Json::Value evmAsmJson; if (m_evmAssemblyStack->parseAndAnalyze(_sourceName, _source)) { m_evmAssemblyStack->assemble(); string const name{m_evmAssemblyStack->name()}; - Json::Value const& json = m_evmAssemblyStack->json(); - m_sourceJsons[name] = json; Contract& contract = m_contracts[name]; contract.evmAssembly = m_evmAssemblyStack->evmAssembly(); - contract.evmRuntimeAssembly= m_evmAssemblyStack->evmRuntimeAssembly(); + contract.evmRuntimeAssembly = m_evmAssemblyStack->evmRuntimeAssembly(); contract.object = m_evmAssemblyStack->object(); contract.runtimeObject = m_evmAssemblyStack->runtimeObject(); @@ -739,7 +737,7 @@ bool CompilerStack::compile(State _stopAfter) { if ( SourceLocation const* sourceLocation = - boost::get_error_info(_unimplementedError) + boost::get_error_info(_unimplementedError) ) { string const* comment = _unimplementedError.comment(); @@ -981,8 +979,8 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const Contract const& currentContract = contract(_contractName); if (currentContract.evmAssembly) { - std::vector sources = sourceNames(); - if (std::find(sources.begin(), sources.end(), CompilerContext::yulUtilityFileName()) == sources.end()) + vector sources = sourceNames(); + if (find(sources.begin(), sources.end(), CompilerContext::yulUtilityFileName()) == sources.end()) sources.emplace_back(CompilerContext::yulUtilityFileName()); currentContract.evmAssembly->setSourceList(sources); return currentContract.evmAssembly->assemblyJSON(); @@ -993,6 +991,9 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const vector CompilerStack::sourceNames() const { + if (m_evmAssemblyStack) + return m_evmAssemblyStack->evmAssembly()->sourceList(); + return ranges::to(m_sources | ranges::views::keys); } diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 2ac6fac4d..2046f8390 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -940,7 +940,8 @@ void CommandLineInterface::handleCombinedJSON() ); if (m_options.compiler.combinedJsonRequests->funDebugRuntime && m_compiler->compilationSuccessful()) contractData[g_strFunDebugRuntime] = StandardCompiler::formatFunctionDebugData( - m_compiler->runtimeObject(contractName).functionDebugData); + m_compiler->runtimeObject(contractName).functionDebugData + ); if (m_options.compiler.combinedJsonRequests->signatureHashes) contractData[g_strSignatureHashes] = m_compiler->interfaceSymbols(contractName)["methods"]; if (m_options.compiler.combinedJsonRequests->natspecDev) @@ -950,8 +951,8 @@ void CommandLineInterface::handleCombinedJSON() } bool needsSourceList = m_options.compiler.combinedJsonRequests->ast || - m_options.compiler.combinedJsonRequests->srcMap || - m_options.compiler.combinedJsonRequests->srcMapRuntime; + m_options.compiler.combinedJsonRequests->srcMap || + m_options.compiler.combinedJsonRequests->srcMapRuntime; if (needsSourceList) { // Indices into this array are used to abbreviate source names in source locations. @@ -1212,7 +1213,7 @@ void CommandLineInterface::assembleYul(yul::YulStack::Language _language, yul::Y shared_ptr assembly{stack.assembleEVMWithDeployed().first}; if (assembly) { - std::function(yul::Object const&)> collectSourceIndices = + function(yul::Object const&)> collectSourceIndices = [&](yul::Object const& _object) -> map { map sourceIndices; if (_object.debugData && _object.debugData->sourceNames.has_value()) diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index ba9110678..df39a0bda 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -30,6 +30,8 @@ #include #include +#include + using namespace std; using namespace solidity::langutil; @@ -1049,7 +1051,11 @@ void CommandLineParser::processArgs() if (!option.second.defaulted() && !supportedByEvmAsmJsonImport.count(option.first)) solThrow( CommandLineValidationError, - "Option --" + option.first + " is not supported with --"+g_strImportEvmAssemblerJson+"." + fmt::format( + "Option --{} is not supported with --{}.", + g_strCombinedJson, + g_strImportEvmAssemblerJson + ) ); } @@ -1419,7 +1425,8 @@ void CommandLineParser::processArgs() solAssert( m_options.input.mode == InputMode::Compiler || m_options.input.mode == InputMode::CompilerWithASTImport || - m_options.input.mode == InputMode::EVMAssemblerJSON); + m_options.input.mode == InputMode::EVMAssemblerJSON + ); } void CommandLineParser::parseCombinedJsonOption() @@ -1456,7 +1463,13 @@ void CommandLineParser::parseCombinedJsonOption() if (m_options.compiler.combinedJsonRequests.value().*invalidOption) solThrow( CommandLineValidationError, - "Invalid option to --" + g_strCombinedJson + ": " + CombinedJsonRequests::componentName(invalidOption) + " for --" + g_strImportEvmAssemblerJson); + fmt::format( + "Invalid option to --{}: {} for --{}", + g_strCombinedJson, + CombinedJsonRequests::componentName(invalidOption), + g_strImportEvmAssemblerJson + ) + ); } }