Remove checkLibraryNameClashes()

The library name clash checker throws errors when two libraries of the
same name are spotted.  In a previous commit, this function was
rewritten to use fully-qualified names instead, which makes it redundant
to the checker for multiply-declared identifiers.  Since it no longer
serves a clear purpose, the function is being dropped.
This commit is contained in:
Rhett Aultman 2016-12-21 11:40:13 -08:00 committed by Rhett Aultman
parent 1f30982ab5
commit 5a2331a9f6
2 changed files with 0 additions and 37 deletions

View File

@ -191,9 +191,6 @@ bool CompilerStack::parse()
m_contracts[contract->fullyQualifiedName()].contract = contract;
}
if (!checkLibraryNameClashes())
noErrors = false;
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
@ -604,37 +601,6 @@ void CompilerStack::resolveImports()
swap(m_sourceOrder, sourceOrder);
}
bool CompilerStack::checkLibraryNameClashes()
{
bool clashFound = false;
map<string, SourceLocation> libraries;
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
if (contract->isLibrary())
{
if (libraries.count(contract->fullyQualifiedName()))
{
auto err = make_shared<Error>(Error::Type::DeclarationError);
*err <<
errinfo_sourceLocation(contract->location()) <<
errinfo_comment(
"Library \"" + contract->name() + "\" declared twice "
"(will create ambiguities during linking)."
) <<
errinfo_secondarySourceLocation(SecondarySourceLocation().append(
"The other declaration is here:", libraries[contract->name()]
));
m_errors.push_back(err);
clashFound = true;
}
else
libraries[contract->fullyQualifiedName()] = contract->location();
}
return !clashFound;
}
string CompilerStack::absolutePath(string const& _path, string const& _reference) const
{
using path = boost::filesystem::path;

View File

@ -234,9 +234,6 @@ private:
StringMap loadMissingSources(SourceUnit const& _ast, std::string const& _path);
std::string applyRemapping(std::string const& _path, std::string const& _context);
void resolveImports();
/// Checks whether there are libraries with the same name, reports that as an error and
/// @returns false in this case.
bool checkLibraryNameClashes();
/// @returns the absolute path corresponding to @a _path relative to @a _reference.
std::string absolutePath(std::string const& _path, std::string const& _reference) const;
/// Helper function to return path converted strings.