AnalysisFramework: Make it possible to customize CompilerStack creation

This commit is contained in:
Kamil Śliwak 2023-08-04 16:25:33 +02:00
parent aecb11eff4
commit f87bef2431
2 changed files with 11 additions and 2 deletions

View File

@ -75,6 +75,11 @@ AnalysisFramework::parseAnalyseAndReturnError(
return make_pair(&compiler().ast(""), std::move(errors));
}
std::unique_ptr<CompilerStack> AnalysisFramework::createStack() const
{
return std::make_unique<CompilerStack>();
}
ErrorList AnalysisFramework::filterErrors(ErrorList const& _errorList, bool _includeWarningsAndInfos) const
{
ErrorList errors;

View File

@ -76,7 +76,7 @@ protected:
solidity::frontend::CompilerStack& compiler()
{
if (!m_compiler)
m_compiler = std::make_unique<solidity::frontend::CompilerStack>();
m_compiler = createStack();
return *m_compiler;
}
@ -84,10 +84,14 @@ protected:
solidity::frontend::CompilerStack const& compiler() const
{
if (!m_compiler)
m_compiler = std::make_unique<solidity::frontend::CompilerStack>();
m_compiler = createStack();
return *m_compiler;
}
/// Creates a new instance of @p CompilerStack. Override if your test case needs to pass in
/// custom constructor arguments.
virtual std::unique_ptr<CompilerStack> createStack() const;
private:
mutable std::unique_ptr<solidity::frontend::CompilerStack> m_compiler;
};