{"action":"created","comment":{"url":"https://api.github.com/repos/ethereum/solidity/pulls/comments/210630700","pull_request_review_id":146886017,"id":210630700,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDYzMDcwMA==","diff_hunk":"@@ -0,0 +1,368 @@\n+/*\n+\tThis file is part of solidity.\n+\n+\tsolidity is free software: you can redistribute it and/or modify\n+\tit under the terms of the GNU General Public License as published by\n+\tthe Free Software Foundation, either version 3 of the License, or\n+\t(at your option) any later version.\n+\n+\tsolidity is distributed in the hope that it will be useful,\n+\tbut WITHOUT ANY WARRANTY; without even the implied warranty of\n+\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+\tGNU General Public License for more details.\n+\n+\tYou should have received a copy of the GNU General Public License\n+\talong with solidity.  If not, see <http://www.gnu.org/licenses/>.\n+*/\n+\n+#include <libevmasm/ThirdOptimizerTesting.h>\n+#include \"ThirdOptimizerTesting.h\"\n+#include <algorithm>\n+#include <tuple>\n+\n+template<typename It, typename = typename std::enable_if<is_assembly_item<decltype(*std::declval<It>())>::value>::type>\n+It noReturnValueBegin(It _begin, It _end);\n+\n+template<typename It, typename = typename std::enable_if<is_assembly_item<decltype(*std::declval<It>())>::value>::type>\n+It backExpressionBegin(It _begin, It _end, bool _allowNoReturn = false)\n+{\n+\tAssemblyItem const& topLevelItem = *(_end - 1);\n+\n+\tsigned arguments = topLevelItem.arguments();\n+\tauto currentEnd = _end - 1 /* top-level operation */;\n+\twhile (arguments > 0)\n+\t{\n+\t\t// TODO this code might break if anything returns more than 1 value, since we can't split things up\n+\t\tcurrentEnd = noReturnValueBegin(_begin, currentEnd);\n+\t\targuments -= static_cast<AssemblyItem const&>(*(currentEnd - 1)).returnValues();\n+\t\tcurrentEnd = backExpressionBegin(_begin, currentEnd, false);\n+\t\tassertThrow(currentEnd >= _begin, OptimizerException, \"currentEnd is before begin\");\n+\t}\n+\n+\tif (!_allowNoReturn && topLevelItem.returnValues() == 0) return backExpressionBegin(_begin, currentEnd, false);\n+\n+\treturn currentEnd;\n+}\n+\n+template<typename It, typename = typename std::enable_if<is_assembly_item<decltype(*std::declval<It>())>::value>::type>\n+It noReturnValueBegin(It _begin, It _end)\n+{\n+\tassertThrow(_begin != _end, OptimizerException, \"expression is empty\");\n+\tAssemblyItem const& topLevelItem = *(_end - 1);\n+\tif (topLevelItem.returnValues() != 0) return _end;\n+\treturn backExpressionBegin(_begin, _end, true);\n+}\n+\n+template<typename It, typename = typename std::enable_if<is_assembly_item<decltype(*std::declval<It>())>::value>::type>\n+vector<It> parseExpressions(It _begin, It _end, signed _limit = -1, bool _allowNoReturn = false)\n+{\n+\tauto currentEnd = _end;\n+\tstd::vector<It> expressions{};\n+\twhile (currentEnd != _begin && (_limit == -1 || signed(expressions.size()) < _limit))\n+\t{\n+\t\tauto oldEnd = currentEnd;\n+\t\tcurrentEnd = backExpressionBegin(_begin, oldEnd, _allowNoReturn);\n+\t\texpressions.push_back(currentEnd);\n+\t\tassertThrow(currentEnd >= _begin, OptimizerException, \"currentEnd is before begin\");\n+\t}\n+\n+\treturn expressions;\n+}\n+\n+template<typename It, typename = typename std::enable_if<is_assembly_item<decltype(*std::declval<It>())>::value>::type>\n+vector<It> parseArguments(It _begin, It _end)\n+{\n+\tauto size = _end - _begin;\n+\tassertThrow(size > 0, OptimizerException, \"cannot get arguments from empty _items vector\");\n+\n+\tunsigned neededArguments = (_end - 1)->arguments();\n+\n+\tauto expressions = parseExpressions(_begin, _end - 1, neededArguments, false);\n+\tassertThrow(expressions.size() >= neededArguments, OptimizerException, \"more arguments needed than provided\");\n+\n+\texpressions = vector<It>(expressions.begin(), expressions.begin() + neededArguments);","path":"libevmasm/ThirdOptimizerTesting.cpp","position":83,"original_position":83,"commit_id":"8976dda9db4ff645b0bbdc72a5927642a50c495a","original_commit_id":"8976dda9db4ff645b0bbdc72a5927642a50c495a","user":{"login":"meowingtwurtle","id":1988485,"node_id":"MDQ6VXNlcjE5ODg0ODU=","avatar_url":"https://avatars2.githubusercontent.com/u/1988485?v=4","gravatar_id":"","url":"https://api.github.com/users/meowingtwurtle","html_url":"https://github.com/meowingtwurtle","followers_url":"https://api.github.com/users/meowingtwurtle/followers","following_url":"https://api.github.com/users/meowingtwurtle/following{/other_user}","gists_url":"https://api.github.com/users/meowingtwurtle/gists{/gist_id}","starred_url":"https://api.github.com/users/meowingtwurtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meowingtwurtle/subscriptions","organizations_url":"https://api.github.com/users/meowingtwurtle/orgs","repos_url":"https://api.github.com/users/meowingtwurtle/repos","events_url":"https://api.github.com/users/meowingtwurtle/events{/privacy}","received_events_url":"https://api.github.com/users/meowingtwurtle/received_events","type":"User","site_admin":false},"body":"Oh, and the vector is dead at that point, so you would have iterators into a destructed vector.","created_at":"2018-08-16T14:59:55Z","updated_at":"2018-08-16T14:59:55Z","html_url":"https://github.com/ethereum/solidity/pull/4795#discussion_r210630700","pull_request_url":"https://api.github.com/repos/ethereum/solidity/pulls/4795","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/comments/210630700"},"html":{"href":"https://github.com/ethereum/solidity/pull/4795#discussion_r210630700"},"pull_request":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/4795"}},"in_reply_to_id":210629412},"pull_request":{"url":"https://api.github.com/repos/ethereum/solidity/pulls/4795","id":207448889,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NDQ4ODg5","html_url":"https://github.com/ethereum/solidity/pull/4795","diff_url":"https://github.com/ethereum/solidity/pull/4795.diff","patch_url":"https://github.com/ethereum/solidity/pull/4795.patch","issue_url":"https://api.github.com/repos/ethereum/solidity/issues/4795","number":4795,"state":"open","locked":false,"title":"[WIP] Add extra optimizer stage","user":{"login":"meowingtwurtle","id":1988485,"node_id":"MDQ6VXNlcjE5ODg0ODU=","avatar_url":"https://avatars2.githubusercontent.com/u/1988485?v=4","gravatar_id":"","url":"https://api.github.com/users/meowingtwurtle","html_url":"https://github.com/meowingtwurtle","followers_url":"https://api.github.com/users/meowingtwurtle/followers","following_url":"https://api.github.com/users/meowingtwurtle/following{/other_user}","gists_url":"https://api.github.com/users/meowingtwurtle/gists{/gist_id}","starred_url":"https://api.github.com/users/meowingtwurtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meowingtwurtle/subscriptions","organizations_url":"https://api.github.com/users/meowingtwurtle/orgs","repos_url":"https://api.github.com/users/meowingtwurtle/repos","events_url":"https://api.github.com/users/meowingtwurtle/events{/privacy}","received_events_url":"https://api.github.com/users/meowingtwurtle/received_events","type":"User","site_admin":false},"body":"Closes #4674.\n\nVery WIP. Please do not merge.","created_at":"2018-08-09T21:27:13Z","updated_at":"2018-08-16T14:59:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"46e6cac9aaf015e7d63d0a55038696eae555919f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ethereum/solidity/pulls/4795/commits","review_comments_url":"https://api.github.com/repos/ethereum/solidity/pulls/4795/comments","review_comment_url":"https://api.github.com/repos/ethereum/solidity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethereum/solidity/issues/4795/comments","statuses_url":"https://api.github.com/repos/ethereum/solidity/statuses/8976dda9db4ff645b0bbdc72a5927642a50c495a","head":{"label":"meowingtwurtle:thirdOptimizer","ref":"thirdOptimizer","sha":"8976dda9db4ff645b0bbdc72a5927642a50c495a","user":{"login":"meowingtwurtle","id":1988485,"node_id":"MDQ6VXNlcjE5ODg0ODU=","avatar_url":"https://avatars2.githubusercontent.com/u/1988485?v=4","gravatar_id":"","url":"https://api.github.com/users/meowingtwurtle","html_url":"https://github.com/meowingtwurtle","followers_url":"https://api.github.com/users/meowingtwurtle/followers","following_url":"https://api.github.com/users/meowingtwurtle/following{/other_user}","gists_url":"https://api.github.com/users/meowingtwurtle/gists{/gist_id}","starred_url":"https://api.github.com/users/meowingtwurtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meowingtwurtle/subscriptions","organizations_url":"https://api.github.com/users/meowingtwurtle/orgs","repos_url":"https://api.github.com/users/meowingtwurtle/repos","events_url":"https://api.github.com/users/meowingtwurtle/events{/privacy}","received_events_url":"https://api.github.com/users/meowingtwurtle/received_events","type":"User","site_admin":false},"repo":{"id":117014401,"node_id":"MDEwOlJlcG9zaXRvcnkxMTcwMTQ0MDE=","name":"solidity","full_name":"meowingtwurtle/solidity","owner":{"login":"meowingtwurtle","id":1988485,"node_id":"MDQ6VXNlcjE5ODg0ODU=","avatar_url":"https://avatars2.githubusercontent.com/u/1988485?v=4","gravatar_id":"","url":"https://api.github.com/users/meowingtwurtle","html_url":"https://github.com/meowingtwurtle","followers_url":"https://api.github.com/users/meowingtwurtle/followers","following_url":"https://api.github.com/users/meowingtwurtle/following{/other_user}","gists_url":"https://api.github.com/users/meowingtwurtle/gists{/gist_id}","starred_url":"https://api.github.com/users/meowingtwurtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meowingtwurtle/subscriptions","organizations_url":"https://api.github.com/users/meowingtwurtle/orgs","repos_url":"https://api.github.com/users/meowingtwurtle/repos","events_url":"https://api.github.com/users/meowingtwurtle/events{/privacy}","received_events_url":"https://api.github.com/users/meowingtwurtle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/meowingtwurtle/solidity","description":"The Solidity Contract-Oriented Programming Language","fork":true,"url":"https://api.github.com/repos/meowingtwurtle/solidity","forks_url":"https://api.github.com/repos/meowingtwurtle/solidity/forks","keys_url":"https://api.github.com/repos/meowingtwurtle/solidity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/meowingtwurtle/solidity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/meowingtwurtle/solidity/teams","hooks_url":"https://api.github.com/repos/meowingtwurtle/solidity/hooks","issue_events_url":"https://api.github.com/repos/meowingtwurtle/solidity/issues/events{/number}","events_url":"https://api.github.com/repos/meowingtwurtle/solidity/events","assignees_url":"https://api.github.com/repos/meowingtwurtle/solidity/assignees{/user}","branches_url":"https://api.github.com/repos/meowingtwurtle/solidity/branches{/branch}","tags_url":"https://api.github.com/repos/meowingtwurtle/solidity/tags","blobs_url":"https://api.github.com/repos/meowingtwurtle/solidity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/meowingtwurtle/solidity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/meowingtwurtle/solidity/git/refs{/sha}","trees_url":"https://api.github.com/repos/meowingtwurtle/solidity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/meowingtwurtle/solidity/statuses/{sha}","languages_url":"https://api.github.com/repos/meowingtwurtle/solidity/languages","stargazers_url":"https://api.github.com/repos/meowingtwurtle/solidity/stargazers","contributors_url":"https://api.github.com/repos/meowingtwurtle/solidity/contributors","subscribers_url":"https://api.github.com/repos/meowingtwurtle/solidity/subscribers","subscription_url":"https://api.github.com/repos/meowingtwurtle/solidity/subscription","commits_url":"https://api.github.com/repos/meowingtwurtle/solidity/commits{/sha}","git_commits_url":"https://api.github.com/repos/meowingtwurtle/solidity/git/commits{/sha}","comments_url":"https://api.github.com/repos/meowingtwurtle/solidity/comments{/number}","issue_comment_url":"https://api.github.com/repos/meowingtwurtle/solidity/issues/comments{/number}","contents_url":"https://api.github.com/repos/meowingtwurtle/solidity/contents/{+path}","compare_url":"https://api.github.com/repos/meowingtwurtle/solidity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/meowingtwurtle/solidity/merges","archive_url":"https://api.github.com/repos/meowingtwurtle/solidity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/meowingtwurtle/solidity/downloads","issues_url":"https://api.github.com/repos/meowingtwurtle/solidity/issues{/number}","pulls_url":"https://api.github.com/repos/meowingtwurtle/solidity/pulls{/number}","milestones_url":"https://api.github.com/repos/meowingtwurtle/solidity/milestones{/number}","notifications_url":"https://api.github.com/repos/meowingtwurtle/solidity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/meowingtwurtle/solidity/labels{/name}","releases_url":"https://api.github.com/repos/meowingtwurtle/solidity/releases{/id}","deployments_url":"https://api.github.com/repos/meowingtwurtle/solidity/deployments","created_at":"2018-01-10T21:43:19Z","updated_at":"2018-01-10T21:43:24Z","pushed_at":"2018-08-16T02:38:24Z","git_url":"git://github.com/meowingtwurtle/solidity.git","ssh_url":"git@github.com:meowingtwurtle/solidity.git","clone_url":"https://github.com/meowingtwurtle/solidity.git","svn_url":"https://github.com/meowingtwurtle/solidity","homepage":"","size":21791,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"ethereum:develop","ref":"develop","sha":"43db88b8363d73ee2f5ffa094ff506414261bd11","user":{"login":"ethereum","id":6250754,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYyNTA3NTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6250754?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":40892817,"node_id":"MDEwOlJlcG9zaXRvcnk0MDg5MjgxNw==","name":"solidity","full_name":"ethereum/solidity","owner":{"login":"ethereum","id":6250754,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYyNTA3NTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6250754?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereum/solidity","description":"Solidity, the Contract-Oriented Programming Language","fork":false,"url":"https://api.github.com/repos/ethereum/solidity","forks_url":"https://api.github.com/repos/ethereum/solidity/forks","keys_url":"https://api.github.com/repos/ethereum/solidity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/solidity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/solidity/teams","hooks_url":"https://api.github.com/repos/ethereum/solidity/hooks","issue_events_url":"https://api.github.com/repos/ethereum/solidity/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/solidity/events","assignees_url":"https://api.github.com/repos/ethereum/solidity/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/solidity/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/solidity/tags","blobs_url":"https://api.github.com/repos/ethereum/solidity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/solidity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/solidity/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/solidity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/solidity/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/solidity/languages","stargazers_url":"https://api.github.com/repos/ethereum/solidity/stargazers","contributors_url":"https://api.github.com/repos/ethereum/solidity/contributors","subscribers_url":"https://api.github.com/repos/ethereum/solidity/subscribers","subscription_url":"https://api.github.com/repos/ethereum/solidity/subscription","commits_url":"https://api.github.com/repos/ethereum/solidity/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/solidity/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/solidity/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/solidity/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereum/solidity/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/solidity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/solidity/merges","archive_url":"https://api.github.com/repos/ethereum/solidity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/solidity/downloads","issues_url":"https://api.github.com/repos/ethereum/solidity/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/solidity/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/solidity/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/solidity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/solidity/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/solidity/releases{/id}","deployments_url":"https://api.github.com/repos/ethereum/solidity/deployments","created_at":"2015-08-17T12:27:26Z","updated_at":"2018-08-16T13:56:25Z","pushed_at":"2018-08-16T14:42:05Z","git_url":"git://github.com/ethereum/solidity.git","ssh_url":"git@github.com:ethereum/solidity.git","clone_url":"https://github.com/ethereum/solidity.git","svn_url":"https://github.com/ethereum/solidity","homepage":"https://solidity.readthedocs.io","size":22632,"stargazers_count":5716,"watchers_count":5716,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1532,"mirror_url":null,"archived":false,"open_issues_count":575,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":1532,"open_issues":575,"watchers":5716,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/4795"},"html":{"href":"https://github.com/ethereum/solidity/pull/4795"},"issue":{"href":"https://api.github.com/repos/ethereum/solidity/issues/4795"},"comments":{"href":"https://api.github.com/repos/ethereum/solidity/issues/4795/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/4795/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/4795/commits"},"statuses":{"href":"https://api.github.com/repos/ethereum/solidity/statuses/8976dda9db4ff645b0bbdc72a5927642a50c495a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"meowingtwurtle"}}