aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/DeclarationContainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/analysis/DeclarationContainer.cpp')
-rw-r--r--libsolidity/analysis/DeclarationContainer.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp
index 7339ad5d..ac56562e 100644
--- a/libsolidity/analysis/DeclarationContainer.cpp
+++ b/libsolidity/analysis/DeclarationContainer.cpp
@@ -28,15 +28,19 @@ using namespace std;
using namespace dev;
using namespace dev::solidity;
-Declaration const* DeclarationContainer::conflictingDeclaration(Declaration const& _declaration) const
+Declaration const* DeclarationContainer::conflictingDeclaration(
+ Declaration const& _declaration,
+ ASTString const* _name
+) const
{
- ASTString const& declarationName(_declaration.name());
- solAssert(!declarationName.empty(), "");
+ if (!_name)
+ _name = &_declaration.name();
+ solAssert(!_name->empty(), "");
vector<Declaration const*> declarations;
- if (m_declarations.count(declarationName))
- declarations += m_declarations.at(declarationName);
- if (m_invisibleDeclarations.count(declarationName))
- declarations += m_invisibleDeclarations.at(declarationName);
+ if (m_declarations.count(*_name))
+ declarations += m_declarations.at(*_name);
+ if (m_invisibleDeclarations.count(*_name))
+ declarations += m_invisibleDeclarations.at(*_name);
if (dynamic_cast<FunctionDefinition const*>(&_declaration))
{
@@ -51,25 +55,31 @@ Declaration const* DeclarationContainer::conflictingDeclaration(Declaration cons
return nullptr;
}
-bool DeclarationContainer::registerDeclaration(Declaration const& _declaration, bool _invisible, bool _update)
+bool DeclarationContainer::registerDeclaration(
+ Declaration const& _declaration,
+ ASTString const* _name,
+ bool _invisible,
+ bool _update
+)
{
- ASTString const& declarationName(_declaration.name());
- if (declarationName.empty())
+ if (!_name)
+ _name = &_declaration.name();
+ if (_name->empty())
return true;
if (_update)
{
solAssert(!dynamic_cast<FunctionDefinition const*>(&_declaration), "Attempt to update function definition.");
- m_declarations.erase(declarationName);
- m_invisibleDeclarations.erase(declarationName);
+ m_declarations.erase(*_name);
+ m_invisibleDeclarations.erase(*_name);
}
else if (conflictingDeclaration(_declaration))
return false;
if (_invisible)
- m_invisibleDeclarations[declarationName].push_back(&_declaration);
+ m_invisibleDeclarations[*_name].push_back(&_declaration);
else
- m_declarations[declarationName].push_back(&_declaration);
+ m_declarations[*_name].push_back(&_declaration);
return true;
}