mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Pass DebugInfoSelection down to the code handling assembly printing
This commit is contained in:
parent
f7c4ed849d
commit
bcfefc79d9
@ -75,6 +75,7 @@ public:
|
|||||||
RevertStrings _revertStrings,
|
RevertStrings _revertStrings,
|
||||||
OptimiserSettings _optimiserSettings,
|
OptimiserSettings _optimiserSettings,
|
||||||
std::map<std::string, unsigned> _sourceIndices,
|
std::map<std::string, unsigned> _sourceIndices,
|
||||||
|
langutil::DebugInfoSelection const& _debugInfoSelection,
|
||||||
langutil::CharStreamProvider const* _soliditySourceProvider
|
langutil::CharStreamProvider const* _soliditySourceProvider
|
||||||
):
|
):
|
||||||
m_evmVersion(_evmVersion),
|
m_evmVersion(_evmVersion),
|
||||||
@ -82,6 +83,7 @@ public:
|
|||||||
m_revertStrings(_revertStrings),
|
m_revertStrings(_revertStrings),
|
||||||
m_optimiserSettings(std::move(_optimiserSettings)),
|
m_optimiserSettings(std::move(_optimiserSettings)),
|
||||||
m_sourceIndices(std::move(_sourceIndices)),
|
m_sourceIndices(std::move(_sourceIndices)),
|
||||||
|
m_debugInfoSelection(_debugInfoSelection),
|
||||||
m_soliditySourceProvider(_soliditySourceProvider)
|
m_soliditySourceProvider(_soliditySourceProvider)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -222,7 +224,7 @@ private:
|
|||||||
|
|
||||||
std::set<ContractDefinition const*, ASTNode::CompareByID> m_subObjects;
|
std::set<ContractDefinition const*, ASTNode::CompareByID> m_subObjects;
|
||||||
|
|
||||||
langutil::DebugInfoSelection m_debugInfoSelection = langutil::DebugInfoSelection::Default();
|
langutil::DebugInfoSelection m_debugInfoSelection = {};
|
||||||
langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr;
|
langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,7 +95,12 @@ pair<string, string> IRGenerator::run(
|
|||||||
{
|
{
|
||||||
string const ir = yul::reindent(generate(_contract, _cborMetadata, _otherYulSources));
|
string const ir = yul::reindent(generate(_contract, _cborMetadata, _otherYulSources));
|
||||||
|
|
||||||
yul::AssemblyStack asmStack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, m_optimiserSettings);
|
yul::AssemblyStack asmStack(
|
||||||
|
m_evmVersion,
|
||||||
|
yul::AssemblyStack::Language::StrictAssembly,
|
||||||
|
m_optimiserSettings,
|
||||||
|
m_context.debugInfoSelection()
|
||||||
|
);
|
||||||
if (!asmStack.parseAndAnalyze("", ir))
|
if (!asmStack.parseAndAnalyze("", ir))
|
||||||
{
|
{
|
||||||
string errorMessage;
|
string errorMessage;
|
||||||
@ -1103,6 +1108,7 @@ void IRGenerator::resetContext(ContractDefinition const& _contract, ExecutionCon
|
|||||||
m_context.revertStrings(),
|
m_context.revertStrings(),
|
||||||
m_optimiserSettings,
|
m_optimiserSettings,
|
||||||
m_context.sourceIndices(),
|
m_context.sourceIndices(),
|
||||||
|
m_context.debugInfoSelection(),
|
||||||
m_context.soliditySourceProvider()
|
m_context.soliditySourceProvider()
|
||||||
);
|
);
|
||||||
newContext.copyFunctionIDsFrom(m_context);
|
newContext.copyFunctionIDsFrom(m_context);
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
RevertStrings _revertStrings,
|
RevertStrings _revertStrings,
|
||||||
OptimiserSettings _optimiserSettings,
|
OptimiserSettings _optimiserSettings,
|
||||||
std::map<std::string, unsigned> _sourceIndices,
|
std::map<std::string, unsigned> _sourceIndices,
|
||||||
|
langutil::DebugInfoSelection const& _debugInfoSelection,
|
||||||
langutil::CharStreamProvider const* _soliditySourceProvider
|
langutil::CharStreamProvider const* _soliditySourceProvider
|
||||||
):
|
):
|
||||||
m_evmVersion(_evmVersion),
|
m_evmVersion(_evmVersion),
|
||||||
@ -59,6 +60,7 @@ public:
|
|||||||
_revertStrings,
|
_revertStrings,
|
||||||
std::move(_optimiserSettings),
|
std::move(_optimiserSettings),
|
||||||
std::move(_sourceIndices),
|
std::move(_sourceIndices),
|
||||||
|
_debugInfoSelection,
|
||||||
_soliditySourceProvider
|
_soliditySourceProvider
|
||||||
),
|
),
|
||||||
m_utils(_evmVersion, m_context.revertStrings(), m_context.functionCollector())
|
m_utils(_evmVersion, m_context.revertStrings(), m_context.functionCollector())
|
||||||
|
@ -271,6 +271,13 @@ void CompilerStack::setMetadataHash(MetadataHash _metadataHash)
|
|||||||
m_metadataHash = _metadataHash;
|
m_metadataHash = _metadataHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompilerStack::selectDebugInfo(DebugInfoSelection _debugInfoSelection)
|
||||||
|
{
|
||||||
|
if (m_stackState >= CompilationSuccessful)
|
||||||
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Must select debug info components before compilation."));
|
||||||
|
m_debugInfoSelection = _debugInfoSelection;
|
||||||
|
}
|
||||||
|
|
||||||
void CompilerStack::addSMTLib2Response(h256 const& _hash, string const& _response)
|
void CompilerStack::addSMTLib2Response(h256 const& _hash, string const& _response)
|
||||||
{
|
{
|
||||||
if (m_stackState >= ParsedAndImported)
|
if (m_stackState >= ParsedAndImported)
|
||||||
@ -882,7 +889,7 @@ string CompilerStack::assemblyString(string const& _contractName, StringMap cons
|
|||||||
|
|
||||||
Contract const& currentContract = contract(_contractName);
|
Contract const& currentContract = contract(_contractName);
|
||||||
if (currentContract.evmAssembly)
|
if (currentContract.evmAssembly)
|
||||||
return currentContract.evmAssembly->assemblyString(DebugInfoSelection::Default(), _sourceCodes);
|
return currentContract.evmAssembly->assemblyString(m_debugInfoSelection, _sourceCodes);
|
||||||
else
|
else
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
@ -1319,7 +1326,7 @@ void CompilerStack::generateIR(ContractDefinition const& _contract)
|
|||||||
for (auto const& pair: m_contracts)
|
for (auto const& pair: m_contracts)
|
||||||
otherYulSources.emplace(pair.second.contract, pair.second.yulIR);
|
otherYulSources.emplace(pair.second.contract, pair.second.yulIR);
|
||||||
|
|
||||||
IRGenerator generator(m_evmVersion, m_revertStrings, m_optimiserSettings, sourceIndices(), this);
|
IRGenerator generator(m_evmVersion, m_revertStrings, m_optimiserSettings, sourceIndices(), m_debugInfoSelection, this);
|
||||||
tie(compiledContract.yulIR, compiledContract.yulIROptimized) = generator.run(
|
tie(compiledContract.yulIR, compiledContract.yulIROptimized) = generator.run(
|
||||||
_contract,
|
_contract,
|
||||||
createCBORMetadata(compiledContract, /* _forIR */ true),
|
createCBORMetadata(compiledContract, /* _forIR */ true),
|
||||||
@ -1342,7 +1349,12 @@ void CompilerStack::generateEVMFromIR(ContractDefinition const& _contract)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Re-parse the Yul IR in EVM dialect
|
// Re-parse the Yul IR in EVM dialect
|
||||||
yul::AssemblyStack stack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, m_optimiserSettings);
|
yul::AssemblyStack stack(
|
||||||
|
m_evmVersion,
|
||||||
|
yul::AssemblyStack::Language::StrictAssembly,
|
||||||
|
m_optimiserSettings,
|
||||||
|
m_debugInfoSelection
|
||||||
|
);
|
||||||
stack.parseAndAnalyze("", compiledContract.yulIROptimized);
|
stack.parseAndAnalyze("", compiledContract.yulIROptimized);
|
||||||
stack.optimize();
|
stack.optimize();
|
||||||
|
|
||||||
@ -1369,7 +1381,12 @@ void CompilerStack::generateEwasm(ContractDefinition const& _contract)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Re-parse the Yul IR in EVM dialect
|
// Re-parse the Yul IR in EVM dialect
|
||||||
yul::AssemblyStack stack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, m_optimiserSettings);
|
yul::AssemblyStack stack(
|
||||||
|
m_evmVersion,
|
||||||
|
yul::AssemblyStack::Language::StrictAssembly,
|
||||||
|
m_optimiserSettings,
|
||||||
|
m_debugInfoSelection
|
||||||
|
);
|
||||||
stack.parseAndAnalyze("", compiledContract.yulIROptimized);
|
stack.parseAndAnalyze("", compiledContract.yulIROptimized);
|
||||||
|
|
||||||
stack.optimize();
|
stack.optimize();
|
||||||
|
@ -35,10 +35,11 @@
|
|||||||
|
|
||||||
#include <libsmtutil/SolverInterface.h>
|
#include <libsmtutil/SolverInterface.h>
|
||||||
|
|
||||||
|
#include <liblangutil/CharStreamProvider.h>
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
#include <liblangutil/SourceLocation.h>
|
#include <liblangutil/SourceLocation.h>
|
||||||
#include <liblangutil/CharStreamProvider.h>
|
|
||||||
|
|
||||||
#include <libevmasm/LinkerObject.h>
|
#include <libevmasm/LinkerObject.h>
|
||||||
|
|
||||||
@ -203,6 +204,9 @@ public:
|
|||||||
/// @param _metadataHash can be IPFS, Bzzr1, None
|
/// @param _metadataHash can be IPFS, Bzzr1, None
|
||||||
void setMetadataHash(MetadataHash _metadataHash);
|
void setMetadataHash(MetadataHash _metadataHash);
|
||||||
|
|
||||||
|
/// Select components of debug info that should be included in comments in generated assembly.
|
||||||
|
void selectDebugInfo(langutil::DebugInfoSelection _debugInfoSelection);
|
||||||
|
|
||||||
/// Sets the sources. Must be set before parsing.
|
/// Sets the sources. Must be set before parsing.
|
||||||
void setSources(StringMap _sources);
|
void setSources(StringMap _sources);
|
||||||
|
|
||||||
@ -505,6 +509,7 @@ private:
|
|||||||
langutil::ErrorReporter m_errorReporter;
|
langutil::ErrorReporter m_errorReporter;
|
||||||
bool m_metadataLiteralSources = false;
|
bool m_metadataLiteralSources = false;
|
||||||
MetadataHash m_metadataHash = MetadataHash::IPFS;
|
MetadataHash m_metadataHash = MetadataHash::IPFS;
|
||||||
|
langutil::DebugInfoSelection m_debugInfoSelection = langutil::DebugInfoSelection::Default();
|
||||||
bool m_parserErrorRecovery = false;
|
bool m_parserErrorRecovery = false;
|
||||||
State m_stackState = Empty;
|
State m_stackState = Empty;
|
||||||
bool m_importedSources = false;
|
bool m_importedSources = false;
|
||||||
|
@ -28,9 +28,14 @@
|
|||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/AssemblyStack.h>
|
||||||
#include <libyul/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
#include <libyul/optimiser/Suite.h>
|
#include <libyul/optimiser/Suite.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
|
|
||||||
#include <libsmtutil/Exceptions.h>
|
#include <libsmtutil/Exceptions.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
|
|
||||||
#include <libsolutil/JSON.h>
|
#include <libsolutil/JSON.h>
|
||||||
#include <libsolutil/Keccak256.h>
|
#include <libsolutil/Keccak256.h>
|
||||||
#include <libsolutil/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
@ -1358,7 +1363,8 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
_inputsAndSettings.evmVersion,
|
_inputsAndSettings.evmVersion,
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
_inputsAndSettings.optimiserSettings
|
_inputsAndSettings.optimiserSettings,
|
||||||
|
DebugInfoSelection::Default()
|
||||||
);
|
);
|
||||||
string const& sourceName = _inputsAndSettings.sources.begin()->first;
|
string const& sourceName = _inputsAndSettings.sources.begin()->first;
|
||||||
string const& sourceContents = _inputsAndSettings.sources.begin()->second;
|
string const& sourceContents = _inputsAndSettings.sources.begin()->second;
|
||||||
|
@ -304,14 +304,12 @@ string AsmPrinter::formatSourceLocation(
|
|||||||
|
|
||||||
string AsmPrinter::formatDebugData(shared_ptr<DebugData const> const& _debugData, bool _statement)
|
string AsmPrinter::formatDebugData(shared_ptr<DebugData const> const& _debugData, bool _statement)
|
||||||
{
|
{
|
||||||
DebugInfoSelection debugInfoSelection = DebugInfoSelection::Default();
|
if (!_debugData || m_debugInfoSelection.none())
|
||||||
|
|
||||||
if (!_debugData || debugInfoSelection.none())
|
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
vector<string> items;
|
vector<string> items;
|
||||||
if (auto id = _debugData->astID)
|
if (auto id = _debugData->astID)
|
||||||
if (debugInfoSelection.astID)
|
if (m_debugInfoSelection.astID)
|
||||||
items.emplace_back("@ast-id " + to_string(*id));
|
items.emplace_back("@ast-id " + to_string(*id));
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -324,7 +322,7 @@ string AsmPrinter::formatDebugData(shared_ptr<DebugData const> const& _debugData
|
|||||||
items.emplace_back(formatSourceLocation(
|
items.emplace_back(formatSourceLocation(
|
||||||
_debugData->originLocation,
|
_debugData->originLocation,
|
||||||
m_nameToSourceIndex,
|
m_nameToSourceIndex,
|
||||||
debugInfoSelection,
|
m_debugInfoSelection,
|
||||||
m_soliditySourceProvider
|
m_soliditySourceProvider
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,11 @@ public:
|
|||||||
explicit AsmPrinter(
|
explicit AsmPrinter(
|
||||||
Dialect const* _dialect = nullptr,
|
Dialect const* _dialect = nullptr,
|
||||||
std::optional<std::map<unsigned, std::shared_ptr<std::string const>>> _sourceIndexToName = {},
|
std::optional<std::map<unsigned, std::shared_ptr<std::string const>>> _sourceIndexToName = {},
|
||||||
|
langutil::DebugInfoSelection const& _debugInfoSelection = langutil::DebugInfoSelection::Default(),
|
||||||
langutil::CharStreamProvider const* _soliditySourceProvider = nullptr
|
langutil::CharStreamProvider const* _soliditySourceProvider = nullptr
|
||||||
):
|
):
|
||||||
m_dialect(_dialect),
|
m_dialect(_dialect),
|
||||||
|
m_debugInfoSelection(_debugInfoSelection),
|
||||||
m_soliditySourceProvider(_soliditySourceProvider)
|
m_soliditySourceProvider(_soliditySourceProvider)
|
||||||
{
|
{
|
||||||
if (_sourceIndexToName)
|
if (_sourceIndexToName)
|
||||||
@ -59,12 +61,12 @@ public:
|
|||||||
m_nameToSourceIndex[*name] = index;
|
m_nameToSourceIndex[*name] = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
explicit AsmPrinter(
|
explicit AsmPrinter(
|
||||||
Dialect const& _dialect,
|
Dialect const& _dialect,
|
||||||
std::optional<std::map<unsigned, std::shared_ptr<std::string const>>> _sourceIndexToName = {},
|
std::optional<std::map<unsigned, std::shared_ptr<std::string const>>> _sourceIndexToName = {},
|
||||||
|
langutil::DebugInfoSelection const& _debugInfoSelection = langutil::DebugInfoSelection::Default(),
|
||||||
langutil::CharStreamProvider const* _soliditySourceProvider = nullptr
|
langutil::CharStreamProvider const* _soliditySourceProvider = nullptr
|
||||||
): AsmPrinter(&_dialect, _sourceIndexToName, _soliditySourceProvider) {}
|
): AsmPrinter(&_dialect, _sourceIndexToName, _debugInfoSelection, _soliditySourceProvider) {}
|
||||||
|
|
||||||
std::string operator()(Literal const& _literal);
|
std::string operator()(Literal const& _literal);
|
||||||
std::string operator()(Identifier const& _identifier);
|
std::string operator()(Identifier const& _identifier);
|
||||||
@ -102,6 +104,7 @@ private:
|
|||||||
Dialect const* const m_dialect = nullptr;
|
Dialect const* const m_dialect = nullptr;
|
||||||
std::map<std::string, unsigned> m_nameToSourceIndex;
|
std::map<std::string, unsigned> m_nameToSourceIndex;
|
||||||
langutil::SourceLocation m_lastLocation = {};
|
langutil::SourceLocation m_lastLocation = {};
|
||||||
|
langutil::DebugInfoSelection m_debugInfoSelection = {};
|
||||||
langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr;
|
langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ AssemblyStack::assembleWithDeployed(optional<string_view> _deployName) const
|
|||||||
MachineAssemblyObject creationObject;
|
MachineAssemblyObject creationObject;
|
||||||
creationObject.bytecode = make_shared<evmasm::LinkerObject>(creationAssembly->assemble());
|
creationObject.bytecode = make_shared<evmasm::LinkerObject>(creationAssembly->assemble());
|
||||||
yulAssert(creationObject.bytecode->immutableReferences.empty(), "Leftover immutables.");
|
yulAssert(creationObject.bytecode->immutableReferences.empty(), "Leftover immutables.");
|
||||||
creationObject.assembly = creationAssembly->assemblyString();
|
creationObject.assembly = creationAssembly->assemblyString(m_debugInfoSelection);
|
||||||
creationObject.sourceMappings = make_unique<string>(
|
creationObject.sourceMappings = make_unique<string>(
|
||||||
evmasm::AssemblyItem::computeSourceMapping(
|
evmasm::AssemblyItem::computeSourceMapping(
|
||||||
creationAssembly->items(),
|
creationAssembly->items(),
|
||||||
@ -261,7 +261,7 @@ AssemblyStack::assembleWithDeployed(optional<string_view> _deployName) const
|
|||||||
if (deployedAssembly)
|
if (deployedAssembly)
|
||||||
{
|
{
|
||||||
deployedObject.bytecode = make_shared<evmasm::LinkerObject>(deployedAssembly->assemble());
|
deployedObject.bytecode = make_shared<evmasm::LinkerObject>(deployedAssembly->assemble());
|
||||||
deployedObject.assembly = deployedAssembly->assemblyString();
|
deployedObject.assembly = deployedAssembly->assemblyString(m_debugInfoSelection);
|
||||||
deployedObject.sourceMappings = make_unique<string>(
|
deployedObject.sourceMappings = make_unique<string>(
|
||||||
evmasm::AssemblyItem::computeSourceMapping(
|
evmasm::AssemblyItem::computeSourceMapping(
|
||||||
deployedAssembly->items(),
|
deployedAssembly->items(),
|
||||||
@ -314,11 +314,13 @@ AssemblyStack::assembleEVMWithDeployed(optional<string_view> _deployName) const
|
|||||||
return {make_shared<evmasm::Assembly>(assembly), {}};
|
return {make_shared<evmasm::Assembly>(assembly), {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
string AssemblyStack::print(CharStreamProvider const* _soliditySourceProvider) const
|
string AssemblyStack::print(
|
||||||
|
CharStreamProvider const* _soliditySourceProvider
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
yulAssert(m_parserResult, "");
|
yulAssert(m_parserResult, "");
|
||||||
yulAssert(m_parserResult->code, "");
|
yulAssert(m_parserResult->code, "");
|
||||||
return m_parserResult->toString(&languageToDialect(m_language, m_evmVersion), _soliditySourceProvider) + "\n";
|
return m_parserResult->toString(&languageToDialect(m_language, m_evmVersion), m_debugInfoSelection, _soliditySourceProvider) + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Object> AssemblyStack::parserResult() const
|
shared_ptr<Object> AssemblyStack::parserResult() const
|
||||||
|
@ -22,9 +22,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <liblangutil/CharStreamProvider.h>
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
#include <liblangutil/CharStreamProvider.h>
|
|
||||||
|
|
||||||
#include <libyul/Object.h>
|
#include <libyul/Object.h>
|
||||||
#include <libyul/ObjectParser.h>
|
#include <libyul/ObjectParser.h>
|
||||||
@ -69,12 +70,24 @@ public:
|
|||||||
enum class Machine { EVM, Ewasm };
|
enum class Machine { EVM, Ewasm };
|
||||||
|
|
||||||
AssemblyStack():
|
AssemblyStack():
|
||||||
AssemblyStack(langutil::EVMVersion{}, Language::Assembly, solidity::frontend::OptimiserSettings::none())
|
AssemblyStack(
|
||||||
|
langutil::EVMVersion{},
|
||||||
|
Language::Assembly,
|
||||||
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
|
langutil::DebugInfoSelection::Default()
|
||||||
|
)
|
||||||
{}
|
{}
|
||||||
AssemblyStack(langutil::EVMVersion _evmVersion, Language _language, solidity::frontend::OptimiserSettings _optimiserSettings):
|
|
||||||
|
AssemblyStack(
|
||||||
|
langutil::EVMVersion _evmVersion,
|
||||||
|
Language _language,
|
||||||
|
solidity::frontend::OptimiserSettings _optimiserSettings,
|
||||||
|
langutil::DebugInfoSelection const& _debugInfoSelection
|
||||||
|
):
|
||||||
m_language(_language),
|
m_language(_language),
|
||||||
m_evmVersion(_evmVersion),
|
m_evmVersion(_evmVersion),
|
||||||
m_optimiserSettings(std::move(_optimiserSettings)),
|
m_optimiserSettings(std::move(_optimiserSettings)),
|
||||||
|
m_debugInfoSelection(_debugInfoSelection),
|
||||||
m_errorReporter(m_errors)
|
m_errorReporter(m_errors)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -116,7 +129,9 @@ public:
|
|||||||
langutil::ErrorList const& errors() const { return m_errors; }
|
langutil::ErrorList const& errors() const { return m_errors; }
|
||||||
|
|
||||||
/// Pretty-print the input after having parsed it.
|
/// Pretty-print the input after having parsed it.
|
||||||
std::string print(langutil::CharStreamProvider const* _soliditySourceProvider = nullptr) const;
|
std::string print(
|
||||||
|
langutil::CharStreamProvider const* _soliditySourceProvider = nullptr
|
||||||
|
) const;
|
||||||
|
|
||||||
/// Return the parsed and analyzed object.
|
/// Return the parsed and analyzed object.
|
||||||
std::shared_ptr<Object> parserResult() const;
|
std::shared_ptr<Object> parserResult() const;
|
||||||
@ -132,6 +147,7 @@ private:
|
|||||||
Language m_language = Language::Assembly;
|
Language m_language = Language::Assembly;
|
||||||
langutil::EVMVersion m_evmVersion;
|
langutil::EVMVersion m_evmVersion;
|
||||||
solidity::frontend::OptimiserSettings m_optimiserSettings;
|
solidity::frontend::OptimiserSettings m_optimiserSettings;
|
||||||
|
langutil::DebugInfoSelection m_debugInfoSelection{};
|
||||||
|
|
||||||
std::unique_ptr<langutil::CharStream> m_charStream;
|
std::unique_ptr<langutil::CharStream> m_charStream;
|
||||||
|
|
||||||
|
@ -51,13 +51,14 @@ string indent(std::string const& _input)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Data::toString(Dialect const*, CharStreamProvider const*) const
|
string Data::toString(Dialect const*, DebugInfoSelection const&, CharStreamProvider const*) const
|
||||||
{
|
{
|
||||||
return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\"";
|
return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
string Object::toString(
|
string Object::toString(
|
||||||
Dialect const* _dialect,
|
Dialect const* _dialect,
|
||||||
|
DebugInfoSelection const& _debugInfoSelection,
|
||||||
CharStreamProvider const* _soliditySourceProvider
|
CharStreamProvider const* _soliditySourceProvider
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -74,10 +75,15 @@ string Object::toString(
|
|||||||
})) +
|
})) +
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
string inner = "code " + AsmPrinter{_dialect, debugData->sourceNames, _soliditySourceProvider}(*code);
|
string inner = "code " + AsmPrinter(
|
||||||
|
_dialect,
|
||||||
|
debugData->sourceNames,
|
||||||
|
_debugInfoSelection,
|
||||||
|
_soliditySourceProvider
|
||||||
|
)(*code);
|
||||||
|
|
||||||
for (auto const& obj: subObjects)
|
for (auto const& obj: subObjects)
|
||||||
inner += "\n" + obj->toString(_dialect, _soliditySourceProvider);
|
inner += "\n" + obj->toString(_dialect, _debugInfoSelection, _soliditySourceProvider);
|
||||||
|
|
||||||
return useSrcComment + "object \"" + name.str() + "\" {\n" + indent(inner) + "\n}";
|
return useSrcComment + "object \"" + name.str() + "\" {\n" + indent(inner) + "\n}";
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <libyul/YulString.h>
|
#include <libyul/YulString.h>
|
||||||
|
|
||||||
#include <liblangutil/CharStreamProvider.h>
|
#include <liblangutil/CharStreamProvider.h>
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
|
|
||||||
#include <libsolutil/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ struct ObjectNode
|
|||||||
YulString name;
|
YulString name;
|
||||||
virtual std::string toString(
|
virtual std::string toString(
|
||||||
Dialect const* _dialect,
|
Dialect const* _dialect,
|
||||||
|
langutil::DebugInfoSelection const& _debugInfoSelection,
|
||||||
langutil::CharStreamProvider const* _soliditySourceProvider
|
langutil::CharStreamProvider const* _soliditySourceProvider
|
||||||
) const = 0;
|
) const = 0;
|
||||||
};
|
};
|
||||||
@ -69,6 +71,7 @@ struct Data: public ObjectNode
|
|||||||
|
|
||||||
std::string toString(
|
std::string toString(
|
||||||
Dialect const* _dialect,
|
Dialect const* _dialect,
|
||||||
|
langutil::DebugInfoSelection const& _debugInfoSelection,
|
||||||
langutil::CharStreamProvider const* _soliditySourceProvider
|
langutil::CharStreamProvider const* _soliditySourceProvider
|
||||||
) const override;
|
) const override;
|
||||||
};
|
};
|
||||||
@ -89,6 +92,7 @@ public:
|
|||||||
/// @returns a (parseable) string representation.
|
/// @returns a (parseable) string representation.
|
||||||
std::string toString(
|
std::string toString(
|
||||||
Dialect const* _dialect,
|
Dialect const* _dialect,
|
||||||
|
langutil::DebugInfoSelection const& _debugInfoSelection = langutil::DebugInfoSelection::Default(),
|
||||||
langutil::CharStreamProvider const* _soliditySourceProvider = nullptr
|
langutil::CharStreamProvider const* _soliditySourceProvider = nullptr
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
@ -972,7 +972,8 @@ bool CommandLineInterface::assemble(yul::AssemblyStack::Language _language, yul:
|
|||||||
auto& stack = assemblyStacks[src.first] = yul::AssemblyStack(
|
auto& stack = assemblyStacks[src.first] = yul::AssemblyStack(
|
||||||
m_options.output.evmVersion,
|
m_options.output.evmVersion,
|
||||||
_language,
|
_language,
|
||||||
m_options.optimiserSettings()
|
m_options.optimiserSettings(),
|
||||||
|
DebugInfoSelection::Default()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!stack.parseAndAnalyze(src.first, src.second))
|
if (!stack.parseAndAnalyze(src.first, src.second))
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/AssemblyStack.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/Scanner.h>
|
#include <liblangutil/Scanner.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
@ -59,7 +60,12 @@ std::optional<Error> parseAndReturnFirstError(
|
|||||||
AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM
|
AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), _language, solidity::frontend::OptimiserSettings::none());
|
AssemblyStack stack(
|
||||||
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
|
_language,
|
||||||
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
|
DebugInfoSelection::None()
|
||||||
|
);
|
||||||
bool success = false;
|
bool success = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -125,7 +131,12 @@ Error expectError(
|
|||||||
|
|
||||||
void parsePrintCompare(string const& _source, bool _canWarn = false)
|
void parsePrintCompare(string const& _source, bool _canWarn = false)
|
||||||
{
|
{
|
||||||
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
|
AssemblyStack stack(
|
||||||
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
|
AssemblyStack::Language::Assembly,
|
||||||
|
OptimiserSettings::none(),
|
||||||
|
DebugInfoSelection::None()
|
||||||
|
);
|
||||||
BOOST_REQUIRE(stack.parseAndAnalyze("", _source));
|
BOOST_REQUIRE(stack.parseAndAnalyze("", _source));
|
||||||
if (_canWarn)
|
if (_canWarn)
|
||||||
BOOST_REQUIRE(!Error::containsErrors(stack.errors()));
|
BOOST_REQUIRE(!Error::containsErrors(stack.errors()));
|
||||||
@ -210,7 +221,12 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode)
|
|||||||
{
|
{
|
||||||
string source = "{ let x := \"\\u1bac\" }";
|
string source = "{ let x := \"\\u1bac\" }";
|
||||||
string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n";
|
string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n";
|
||||||
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
|
AssemblyStack stack(
|
||||||
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
|
AssemblyStack::Language::Assembly,
|
||||||
|
OptimiserSettings::none(),
|
||||||
|
DebugInfoSelection::None()
|
||||||
|
);
|
||||||
BOOST_REQUIRE(stack.parseAndAnalyze("", source));
|
BOOST_REQUIRE(stack.parseAndAnalyze("", source));
|
||||||
BOOST_REQUIRE(stack.errors().empty());
|
BOOST_REQUIRE(stack.errors().empty());
|
||||||
BOOST_CHECK_EQUAL(stack.print(), parsed);
|
BOOST_CHECK_EQUAL(stack.print(), parsed);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <test/libsolidity/SolidityExecutionFramework.h>
|
#include <test/libsolidity/SolidityExecutionFramework.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
|
|
||||||
@ -34,6 +35,7 @@
|
|||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
using namespace solidity::frontend;
|
using namespace solidity::frontend;
|
||||||
using namespace solidity::frontend::test;
|
using namespace solidity::frontend::test;
|
||||||
|
using namespace solidity::langutil;
|
||||||
using namespace solidity::test;
|
using namespace solidity::test;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -94,8 +96,12 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
|
|||||||
else if (forceEnableOptimizer)
|
else if (forceEnableOptimizer)
|
||||||
optimiserSettings = OptimiserSettings::full();
|
optimiserSettings = OptimiserSettings::full();
|
||||||
|
|
||||||
yul::AssemblyStack
|
yul::AssemblyStack asmStack(
|
||||||
asmStack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, optimiserSettings);
|
m_evmVersion,
|
||||||
|
yul::AssemblyStack::Language::StrictAssembly,
|
||||||
|
optimiserSettings,
|
||||||
|
DebugInfoSelection::All()
|
||||||
|
);
|
||||||
bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName));
|
bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName));
|
||||||
solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors");
|
solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors");
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/backends/wasm/WasmDialect.h>
|
#include <libyul/backends/wasm/WasmDialect.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
#include <liblangutil/Scanner.h>
|
#include <liblangutil/Scanner.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
@ -59,7 +60,8 @@ pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(strin
|
|||||||
_yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly,
|
_yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::test::CommonOptions::get().optimize ?
|
solidity::test::CommonOptions::get().optimize ?
|
||||||
solidity::frontend::OptimiserSettings::standard() :
|
solidity::frontend::OptimiserSettings::standard() :
|
||||||
solidity::frontend::OptimiserSettings::minimal()
|
solidity::frontend::OptimiserSettings::minimal(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
if (!stack.parseAndAnalyze("", _source) || !stack.errors().empty())
|
if (!stack.parseAndAnalyze("", _source) || !stack.errors().empty())
|
||||||
BOOST_FAIL("Invalid source.");
|
BOOST_FAIL("Invalid source.");
|
||||||
|
@ -47,7 +47,12 @@ TestCase::TestResult EVMCodeTransformTest::run(ostream& _stream, string const& _
|
|||||||
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::none();
|
solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::none();
|
||||||
settings.runYulOptimiser = false;
|
settings.runYulOptimiser = false;
|
||||||
settings.optimizeStackAllocation = m_stackOpt;
|
settings.optimizeStackAllocation = m_stackOpt;
|
||||||
AssemblyStack stack(EVMVersion{}, AssemblyStack::Language::StrictAssembly, settings);
|
AssemblyStack stack(
|
||||||
|
EVMVersion{},
|
||||||
|
AssemblyStack::Language::StrictAssembly,
|
||||||
|
settings,
|
||||||
|
DebugInfoSelection::All()
|
||||||
|
);
|
||||||
if (!stack.parseAndAnalyze("", m_source))
|
if (!stack.parseAndAnalyze("", m_source))
|
||||||
{
|
{
|
||||||
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
|
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/Object.h>
|
#include <libyul/Object.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
|
|
||||||
@ -82,7 +83,8 @@ bool EwasmTranslationTest::parse(ostream& _stream, string const& _linePrefix, bo
|
|||||||
m_stack = AssemblyStack(
|
m_stack = AssemblyStack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none()
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
if (m_stack.parseAndAnalyze("", m_source))
|
if (m_stack.parseAndAnalyze("", m_source))
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <libevmasm/Instruction.h>
|
#include <libevmasm/Instruction.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
@ -64,7 +65,8 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
EVMVersion(),
|
EVMVersion(),
|
||||||
m_wasm ? AssemblyStack::Language::Ewasm : AssemblyStack::Language::StrictAssembly,
|
m_wasm ? AssemblyStack::Language::Ewasm : AssemblyStack::Language::StrictAssembly,
|
||||||
OptimiserSettings::preset(m_optimisationPreset)
|
OptimiserSettings::preset(m_optimisationPreset),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
if (!stack.parseAndAnalyze("source", m_source))
|
if (!stack.parseAndAnalyze("source", m_source))
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <test/libsolidity/ErrorCheck.h>
|
#include <test/libsolidity/ErrorCheck.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Scanner.h>
|
#include <liblangutil/Scanner.h>
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/AssemblyStack.h>
|
||||||
@ -60,7 +61,8 @@ pair<bool, ErrorList> parse(string const& _source)
|
|||||||
AssemblyStack asmStack(
|
AssemblyStack asmStack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none()
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
bool success = asmStack.parseAndAnalyze("source", _source);
|
bool success = asmStack.parseAndAnalyze("source", _source);
|
||||||
return {success, asmStack.errors()};
|
return {success, asmStack.errors()};
|
||||||
@ -181,7 +183,8 @@ BOOST_AUTO_TEST_CASE(to_string)
|
|||||||
AssemblyStack asmStack(
|
AssemblyStack asmStack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none()
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
BOOST_REQUIRE(asmStack.parseAndAnalyze("source", code));
|
BOOST_REQUIRE(asmStack.parseAndAnalyze("source", code));
|
||||||
BOOST_CHECK_EQUAL(asmStack.print(), expectation);
|
BOOST_CHECK_EQUAL(asmStack.print(), expectation);
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/AssemblyStack.h>
|
||||||
#include <libyul/AsmAnalysisInfo.h>
|
#include <libyul/AsmAnalysisInfo.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
|
|
||||||
@ -67,7 +68,8 @@ bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
solidity::test::CommonOptions::get().evmVersion(),
|
solidity::test::CommonOptions::get().evmVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none()
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
if (stack.parseAndAnalyze("", m_source))
|
if (stack.parseAndAnalyze("", m_source))
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include <libsolidity/interface/OptimiserSettings.h>
|
#include <libsolidity/interface/OptimiserSettings.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
|
|
||||||
namespace solidity::test::fuzzer
|
namespace solidity::test::fuzzer
|
||||||
{
|
{
|
||||||
class YulAssembler
|
class YulAssembler
|
||||||
@ -36,7 +38,8 @@ public:
|
|||||||
m_stack(
|
m_stack(
|
||||||
_version,
|
_version,
|
||||||
solidity::yul::AssemblyStack::Language::StrictAssembly,
|
solidity::yul::AssemblyStack::Language::StrictAssembly,
|
||||||
_optSettings
|
_optSettings,
|
||||||
|
langutil::DebugInfoSelection::All()
|
||||||
),
|
),
|
||||||
m_yulProgram(_yulSource),
|
m_yulProgram(_yulSource),
|
||||||
m_optimiseYul(_optSettings.runYulOptimiser)
|
m_optimiseYul(_optSettings.runYulOptimiser)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/AssemblyStack.h>
|
||||||
#include <libyul/backends/evm/EVMCodeTransform.h>
|
#include <libyul/backends/evm/EVMCodeTransform.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
|
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
@ -39,7 +40,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
langutil::EVMVersion(),
|
langutil::EVMVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full()
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
|
langutil::DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!stack.parseAndAnalyze("source", input))
|
if (!stack.parseAndAnalyze("source", input))
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/AssemblyStack.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
|
|
||||||
@ -61,7 +62,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
langutil::EVMVersion(),
|
langutil::EVMVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full()
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -17,9 +17,12 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/AssemblyStack.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
|
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
|
using namespace solidity::langutil;
|
||||||
using namespace solidity::util;
|
using namespace solidity::util;
|
||||||
using namespace solidity::yul;
|
using namespace solidity::yul;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -38,7 +41,8 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
langutil::EVMVersion(),
|
langutil::EVMVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full()
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!stack.parseAndAnalyze("source", input))
|
if (!stack.parseAndAnalyze("source", input))
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
|
|
||||||
#include <src/libfuzzer/libfuzzer_macro.h>
|
#include <src/libfuzzer/libfuzzer_macro.h>
|
||||||
@ -64,7 +65,8 @@ DEFINE_PROTO_FUZZER(Program const& _input)
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
version,
|
version,
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full()
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Parse protobuf mutated YUL code
|
// Parse protobuf mutated YUL code
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
|
|
||||||
@ -63,7 +64,8 @@ DEFINE_PROTO_FUZZER(Program const& _input)
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
version,
|
version,
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::full()
|
solidity::frontend::OptimiserSettings::full(),
|
||||||
|
DebugInfoSelection::All()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Parse protobuf mutated YUL code
|
// Parse protobuf mutated YUL code
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
#include <libyul/AssemblyStack.h>
|
#include <libyul/AssemblyStack.h>
|
||||||
|
|
||||||
|
#include <liblangutil/DebugInfoSelection.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/EVMVersion.h>
|
#include <liblangutil/EVMVersion.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
@ -58,7 +59,8 @@ pair<shared_ptr<Block>, shared_ptr<AsmAnalysisInfo>> parse(string const& _source
|
|||||||
AssemblyStack stack(
|
AssemblyStack stack(
|
||||||
langutil::EVMVersion(),
|
langutil::EVMVersion(),
|
||||||
AssemblyStack::Language::StrictAssembly,
|
AssemblyStack::Language::StrictAssembly,
|
||||||
solidity::frontend::OptimiserSettings::none()
|
solidity::frontend::OptimiserSettings::none(),
|
||||||
|
DebugInfoSelection::Default()
|
||||||
);
|
);
|
||||||
if (stack.parseAndAnalyze("--INPUT--", _source))
|
if (stack.parseAndAnalyze("--INPUT--", _source))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user