aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ABIFunctions.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-01-17 19:05:43 +0800
committerchriseth <chris@ethereum.org>2018-10-17 20:12:10 +0800
commit5e01d767d02d064a064a67dcf95ee299c46f741f (patch)
tree055a2533fa92111b85203eff0f1f1e8c63e38492 /libsolidity/codegen/ABIFunctions.cpp
parentba1588828f45b242bc09899e4f307f7fda9c5ab6 (diff)
downloaddexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.tar.gz
dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.tar.zst
dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.zip
Prevent externally used functions from being removed.
Diffstat (limited to 'libsolidity/codegen/ABIFunctions.cpp')
-rw-r--r--libsolidity/codegen/ABIFunctions.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp
index 6c27533c..bd29b382 100644
--- a/libsolidity/codegen/ABIFunctions.cpp
+++ b/libsolidity/codegen/ABIFunctions.cpp
@@ -49,7 +49,7 @@ string ABIFunctions::tupleEncoder(
if (_encodeAsLibraryTypes)
functionName += "_library";
- return createFunction(functionName, [&]() {
+ return createExternallyUsedFunction(functionName, [&]() {
solAssert(!_givenTypes.empty(), "");
// Note that the values are in reverse due to the difference in calling semantics.
@@ -113,7 +113,7 @@ string ABIFunctions::tupleDecoder(TypePointers const& _types, bool _fromMemory)
solAssert(!_types.empty(), "");
- return createFunction(functionName, [&]() {
+ return createExternallyUsedFunction(functionName, [&]() {
TypePointers decodingTypes;
for (auto const& t: _types)
decodingTypes.emplace_back(t->decodingType());
@@ -176,13 +176,13 @@ string ABIFunctions::tupleDecoder(TypePointers const& _types, bool _fromMemory)
});
}
-string ABIFunctions::requestedFunctions()
+pair<string, set<string>> ABIFunctions::requestedFunctions()
{
string result;
for (auto const& f: m_requestedFunctions)
result += f.second;
m_requestedFunctions.clear();
- return result;
+ return make_pair(result, std::move(m_externallyUsedFunctions));
}
string ABIFunctions::cleanupFunction(Type const& _type, bool _revertOnFailure)
@@ -1697,6 +1697,13 @@ string ABIFunctions::createFunction(string const& _name, function<string ()> con
return _name;
}
+string ABIFunctions::createExternallyUsedFunction(string const& _name, function<string ()> const& _creator)
+{
+ string name = createFunction(_name, _creator);
+ m_externallyUsedFunctions.insert(name);
+ return name;
+}
+
size_t ABIFunctions::headSize(TypePointers const& _targetTypes)
{
size_t headSize = 0;