Disallow language keywords to be used as identifiers by NameDispenser and VarNameCleaner

Also introduce isRestrictedIdentifier helper in OptimizerUtilities
This commit is contained in:
Alex Beregszaszi
2020-08-31 12:52:17 +01:00
parent 2ebc4bb9a7
commit 2426616859
5 changed files with 21 additions and 6 deletions
+9
View File
@@ -21,15 +21,19 @@
#include <libyul/optimiser/OptimizerUtilities.h>
#include <libyul/Dialect.h>
#include <libyul/AsmData.h>
#include <liblangutil/Token.h>
#include <libsolutil/CommonData.h>
#include <boost/range/algorithm_ext/erase.hpp>
using namespace std;
using namespace solidity;
using namespace solidity::langutil;
using namespace solidity::util;
using namespace solidity::yul;
void yul::removeEmptyBlocks(Block& _block)
{
@@ -38,3 +42,8 @@ void yul::removeEmptyBlocks(Block& _block)
};
boost::range::remove_erase_if(_block.statements, isEmptyBlock);
}
bool yul::isRestrictedIdentifier(Dialect const& _dialect, YulString const& _identifier)
{
return _identifier.empty() || TokenTraits::isYulKeyword(_identifier.str()) || _dialect.builtin(_identifier);
}