Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop_060
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Dec 9, 2019
2 parents da192e6 + 2579a12 commit f6916a6
Show file tree
Hide file tree
Showing 98 changed files with 562 additions and 307 deletions.
18 changes: 9 additions & 9 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,32 @@ Compiler Features:
* ABIEncoderV2: Do not warn about enabled ABIEncoderV2 anymore (the pragma is still needed, though).


### 0.5.14 (unreleased)
### 0.5.14 (2019-12-09)

Language Features:
* Allow to obtain the selector of public or external library functions via a member ``.selector``.
* Parser: Allow splitting string and hexadecimal string literals into multiple parts.
* Inline Assembly: Support referencing other constants.
* Inline Assembly: Support constants that reference other constants.
* Parser: Allow splitting hexadecimal and regular string literals into multiple parts.


Compiler Features:
* Set the default EVM version to "Istanbul".
* Commandline Interface: Allow translation from yul / strict assembly to EWasm using ``solc --yul --yul-dialect evm --machine eWasm``
* Set the default EVM version to "Istanbul".
* SMTChecker: Add support to constructors including constructor inheritance.
* Yul: When compiling via Yul, string literals from the Solidity code are kept as string literals if every character is safely printable.
* Yul Optimizer: Perform loop-invariant code motion.


Build System:
* Update to emscripten version 1.39.3.


Bugfixes:
* SMTChecker: Fix internal error when using ``abi.decode``.
* SMTChecker: Fix internal error when using arrays or mappings of functions.
* SMTChecker: Fix internal error in array of structs type.
* Version Checker: ``^0`` should match ``0.5.0``, but no prerelease.
* Yul: Consider infinite loops and recursion to be not removable.
* Version Checker: 0.5.x-prerelease will match `pragma solidity ^0.5`.


Build System:
* Update to emscripten version 1.39.3.


### 0.5.13 (2019-11-14)
Expand Down
4 changes: 4 additions & 0 deletions docs/bugs_by_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,10 @@
"bugs": [],
"released": "2019-11-14"
},
"0.5.14": {
"bugs": [],
"released": "2019-12-09"
},
"0.5.2": {
"bugs": [
"SignedArrayStorageCopy",
Expand Down
12 changes: 1 addition & 11 deletions liblangutil/SemVerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool SemVerMatchExpression::MatchComponent::matches(SemVerVersion const& _versio
if (!comp.matches(_version))
return false;

if (comp.version.numbers[0] == 0)
if (comp.version.numbers[0] == 0 && comp.levelsPresent != 1)
comp.levelsPresent = 2;
else
comp.levelsPresent = 1;
Expand All @@ -107,17 +107,7 @@ bool SemVerMatchExpression::MatchComponent::matches(SemVerVersion const& _versio
}

if (cmp == 0 && !_version.prerelease.empty() && didCompare)
{
cmp = -1;
for (unsigned i = levelsPresent; i < 3; i++)
{
if (_version.numbers[i] > 0)
{
cmp = 0;
break;
}
}
}

switch (prefix)
{
Expand Down
24 changes: 16 additions & 8 deletions libsolidity/formal/CHC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ CHC::CHC(
#else
m_interface(make_shared<smt::CHCSmtLib2Interface>(_smtlib2Responses, _smtCallback)),
#endif
m_outerErrorReporter(_errorReporter)
m_outerErrorReporter(_errorReporter),
m_enabledSolvers(_enabledSolvers)
{
(void)_smtlib2Responses;
(void)_enabledSolvers;
Expand All @@ -60,15 +61,22 @@ void CHC::analyze(SourceUnit const& _source)
{
solAssert(_source.annotation().experimentalFeatures.count(ExperimentalFeature::SMTChecker), "");

bool usesZ3 = false;
#ifdef HAVE_Z3
auto z3Interface = dynamic_pointer_cast<smt::Z3CHCInterface>(m_interface);
solAssert(z3Interface, "");
m_context.setSolver(z3Interface->z3Interface());
#else
auto smtlib2Interface = dynamic_pointer_cast<smt::CHCSmtLib2Interface>(m_interface);
solAssert(smtlib2Interface, "");
m_context.setSolver(smtlib2Interface->smtlib2Interface());
usesZ3 = m_enabledSolvers.z3;
if (usesZ3)
{
auto z3Interface = dynamic_pointer_cast<smt::Z3CHCInterface>(m_interface);
solAssert(z3Interface, "");
m_context.setSolver(z3Interface->z3Interface());
}
#endif
if (!usesZ3)
{
auto smtlib2Interface = dynamic_pointer_cast<smt::CHCSmtLib2Interface>(m_interface);
solAssert(smtlib2Interface, "");
m_context.setSolver(smtlib2Interface->smtlib2Interface());
}
m_context.clear();
m_context.setAssertionAccumulation(false);
m_variableUsage.setFunctionInlining(false);
Expand Down
3 changes: 3 additions & 0 deletions libsolidity/formal/CHC.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ class CHC: public SMTEncoder

/// ErrorReporter that comes from CompilerStack.
langutil::ErrorReporter& m_outerErrorReporter;

/// SMT solvers that are chosen at runtime.
smt::SMTSolverChoice m_enabledSolvers;
};

}
Expand Down
12 changes: 12 additions & 0 deletions libsolidity/formal/ModelChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,15 @@ vector<string> ModelChecker::unhandledQueries()
{
return m_bmc.unhandledQueries() + m_chc.unhandledQueries();
}

smt::SMTSolverChoice ModelChecker::availableSolvers()
{
smt::SMTSolverChoice available = smt::SMTSolverChoice::None();
#ifdef HAVE_Z3
available.z3 = true;
#endif
#ifdef HAVE_CVC4
available.cvc4 = true;
#endif
return available;
}
3 changes: 3 additions & 0 deletions libsolidity/formal/ModelChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class ModelChecker
/// the constructor.
std::vector<std::string> unhandledQueries();

/// @returns SMT solvers that are available via the C++ API.
static smt::SMTSolverChoice availableSolvers();

private:
/// Bounded Model Checker engine.
BMC m_bmc;
Expand Down
11 changes: 10 additions & 1 deletion libsolidity/interface/CompilerStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static int g_compilerStackCounts = 0;

CompilerStack::CompilerStack(ReadCallback::Callback const& _readFile):
m_readFile{_readFile},
m_enabledSMTSolvers{smt::SMTSolverChoice::All()},
m_generateIR{false},
m_generateEWasm{false},
m_errorList{},
Expand Down Expand Up @@ -132,6 +133,13 @@ void CompilerStack::setEVMVersion(langutil::EVMVersion _version)
m_evmVersion = _version;
}

void CompilerStack::setSMTSolverChoice(smt::SMTSolverChoice _enabledSMTSolvers)
{
if (m_stackState >= ParsingPerformed)
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Must set enabled SMT solvers before parsing."));
m_enabledSMTSolvers = _enabledSMTSolvers;
}

void CompilerStack::setLibraries(std::map<std::string, h160> const& _libraries)
{
if (m_stackState >= ParsingPerformed)
Expand Down Expand Up @@ -194,6 +202,7 @@ void CompilerStack::reset(bool _keepSettings)
m_remappings.clear();
m_libraries.clear();
m_evmVersion = langutil::EVMVersion();
m_enabledSMTSolvers = smt::SMTSolverChoice::All();
m_generateIR = false;
m_generateEWasm = false;
m_revertStrings = RevertStrings::Default;
Expand Down Expand Up @@ -383,7 +392,7 @@ bool CompilerStack::analyze()

if (noErrors)
{
ModelChecker modelChecker(m_errorReporter, m_smtlib2Responses, m_readFile);
ModelChecker modelChecker(m_errorReporter, m_smtlib2Responses, m_readFile, m_enabledSMTSolvers);
for (Source const* source: m_sourceOrder)
modelChecker.analyze(*source->ast);
m_unhandledSMTLib2Queries += modelChecker.unhandledQueries();
Expand Down
5 changes: 5 additions & 0 deletions libsolidity/interface/CompilerStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <libsolidity/interface/OptimiserSettings.h>
#include <libsolidity/interface/Version.h>
#include <libsolidity/interface/DebugSettings.h>
#include <libsolidity/formal/SolverInterface.h>

#include <liblangutil/ErrorReporter.h>
#include <liblangutil/EVMVersion.h>
Expand Down Expand Up @@ -162,6 +163,9 @@ class CompilerStack: boost::noncopyable
/// Must be set before parsing.
void setEVMVersion(langutil::EVMVersion _version = langutil::EVMVersion{});

/// Set which SMT solvers should be enabled.
void setSMTSolverChoice(smt::SMTSolverChoice _enabledSolvers);

/// Sets the requested contract names by source.
/// If empty, no filtering is performed and every contract
/// found in the supplied sources is compiled.
Expand Down Expand Up @@ -429,6 +433,7 @@ class CompilerStack: boost::noncopyable
OptimiserSettings m_optimiserSettings;
RevertStrings m_revertStrings = RevertStrings::Default;
langutil::EVMVersion m_evmVersion;
smt::SMTSolverChoice m_enabledSMTSolvers;
std::map<std::string, std::set<std::string>> m_requestedContractNames;
bool m_generateIR;
bool m_generateEWasm;
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ set(libsolidity_sources
libsolidity/SMTChecker.cpp
libsolidity/SMTCheckerJSONTest.cpp
libsolidity/SMTCheckerJSONTest.h
libsolidity/SMTCheckerTest.cpp
libsolidity/SMTCheckerTest.h
libsolidity/SolidityCompiler.cpp
libsolidity/SolidityEndToEndTest.cpp
libsolidity/SolidityExecutionFramework.cpp
Expand Down
5 changes: 3 additions & 2 deletions test/InteractiveTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <test/libsolidity/GasTest.h>
#include <test/libsolidity/SyntaxTest.h>
#include <test/libsolidity/SemanticTest.h>
#include <test/libsolidity/SMTCheckerTest.h>
#include <test/libsolidity/SMTCheckerJSONTest.h>
#include <test/libyul/EWasmTranslationTest.h>
#include <test/libyul/YulOptimizerTest.h>
Expand Down Expand Up @@ -65,8 +66,8 @@ Testsuite const g_interactiveTestsuites[] = {
{"Semantic", "libsolidity", "semanticTests", false, true, &SemanticTest::create},
{"JSON AST", "libsolidity", "ASTJSON", false, false, &ASTJSONTest::create},
{"JSON ABI", "libsolidity", "ABIJson", false, false, &ABIJsonTest::create},
{"SMT Checker", "libsolidity", "smtCheckerTests", true, false, &SyntaxTest::create},
{"SMT Checker JSON", "libsolidity", "smtCheckerTestsJSON", true, false, &SMTCheckerTest::create},
{"SMT Checker", "libsolidity", "smtCheckerTests", true, false, &SMTCheckerTest::create},
{"SMT Checker JSON", "libsolidity", "smtCheckerTestsJSON", true, false, &SMTCheckerJSONTest::create},
{"Gas Estimates", "libsolidity", "gasTests", false, false, &GasTest::create}
};

Expand Down
13 changes: 0 additions & 13 deletions test/libsolidity/AnalysisFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,6 @@ do \
} \
while(0)

#define CHECK_SUCCESS_OR_WARNING(text, substring) \
do \
{ \
auto sourceAndError = parseAnalyseAndReturnError((text), true); \
auto const& errors = sourceAndError.second; \
if (!errors.empty()) \
{ \
auto message = searchErrors(errors, {{(Error::Type::Warning), (substring)}}); \
BOOST_CHECK_MESSAGE(message.empty(), message); \
} \
} \
while(0)

}
}
}
Loading

0 comments on commit f6916a6

Please sign in to comment.