aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/SolidityOptimizer.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-04-24 17:42:30 +0800
committerchriseth <c@ethdev.com>2015-04-27 16:08:55 +0800
commitcfe24c3c2a60d59c0075e82fed044232baec4974 (patch)
tree46abf96b25ed4a3bb28c4005dab0851f5b04d731 /libsolidity/SolidityOptimizer.cpp
parentb129a201dbc7c7b8370f47af758e295e173b4e78 (diff)
downloaddexon-solidity-cfe24c3c2a60d59c0075e82fed044232baec4974.tar
dexon-solidity-cfe24c3c2a60d59c0075e82fed044232baec4974.tar.gz
dexon-solidity-cfe24c3c2a60d59c0075e82fed044232baec4974.tar.bz2
dexon-solidity-cfe24c3c2a60d59c0075e82fed044232baec4974.tar.lz
dexon-solidity-cfe24c3c2a60d59c0075e82fed044232baec4974.tar.xz
dexon-solidity-cfe24c3c2a60d59c0075e82fed044232baec4974.tar.zst
dexon-solidity-cfe24c3c2a60d59c0075e82fed044232baec4974.zip
Try to keep source location during optimization.
Diffstat (limited to 'libsolidity/SolidityOptimizer.cpp')
-rw-r--r--libsolidity/SolidityOptimizer.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/libsolidity/SolidityOptimizer.cpp b/libsolidity/SolidityOptimizer.cpp
index af9b5146..ceb9c68d 100644
--- a/libsolidity/SolidityOptimizer.cpp
+++ b/libsolidity/SolidityOptimizer.cpp
@@ -22,6 +22,7 @@
#include <string>
#include <tuple>
+#include <memory>
#include <boost/test/unit_test.hpp>
#include <boost/lexical_cast.hpp>
#include <test/libsolidity/solidityExecutionFramework.h>
@@ -84,9 +85,20 @@ public:
AssemblyItems getCSE(AssemblyItems const& _input)
{
+ // add dummy locations to each item so that we can check that they are not deleted
+ AssemblyItems input = _input;
+ for (AssemblyItem& item: input)
+ item.setLocation(SourceLocation(1, 3, make_shared<string>("")));
+
eth::CommonSubexpressionEliminator cse;
- BOOST_REQUIRE(cse.feedItems(_input.begin(), _input.end()) == _input.end());
- return cse.getOptimizedItems();
+ BOOST_REQUIRE(cse.feedItems(input.begin(), input.end()) == input.end());
+ AssemblyItems output = cse.getOptimizedItems();
+
+ for (AssemblyItem const& item: output)
+ {
+ BOOST_CHECK(item == Instruction::POP || !item.getLocation().isEmpty());
+ }
+ return output;
}
void checkCSE(AssemblyItems const& _input, AssemblyItems const& _expectation)