aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast/AST.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-07-13 08:07:23 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-07-19 21:56:40 +0800
commit89a1e97e7dd8a9af5a5fe2c5530cf4217c79f43b (patch)
tree6abc7f120db94cba42bb052f08899043d3b0f9ad /libsolidity/ast/AST.cpp
parentc617336587b976afc3dbe388ebaa8605c3d6fe54 (diff)
downloaddexon-solidity-89a1e97e7dd8a9af5a5fe2c5530cf4217c79f43b.tar.gz
dexon-solidity-89a1e97e7dd8a9af5a5fe2c5530cf4217c79f43b.tar.zst
dexon-solidity-89a1e97e7dd8a9af5a5fe2c5530cf4217c79f43b.zip
Avoid cyclic imports in referencedSourceUnits
Diffstat (limited to 'libsolidity/ast/AST.cpp')
-rw-r--r--libsolidity/ast/AST.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index a126e6ed..f4ab6491 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -84,16 +84,21 @@ SourceUnitAnnotation& SourceUnit::annotation() const
return dynamic_cast<SourceUnitAnnotation&>(*m_annotation);
}
-set<SourceUnit const*> SourceUnit::referencedSourceUnits(bool _recurse) const
+set<SourceUnit const*> SourceUnit::referencedSourceUnits(bool _recurse, set<SourceUnit const*> _skipList) const
{
set<SourceUnit const*> sourceUnits;
for (ImportDirective const* importDirective: filteredNodes<ImportDirective>(nodes()))
{
- sourceUnits.insert(importDirective->annotation().sourceUnit);
- if (_recurse)
+ auto const& sourceUnit = importDirective->annotation().sourceUnit;
+ if (!_skipList.count(sourceUnit))
{
- set<SourceUnit const*> referencedSourceUnits = importDirective->annotation().sourceUnit->referencedSourceUnits(true);
- sourceUnits.insert(referencedSourceUnits.begin(), referencedSourceUnits.end());
+ _skipList.insert(sourceUnit);
+ sourceUnits.insert(sourceUnit);
+ if (_recurse)
+ {
+ set<SourceUnit const*> referencedSourceUnits = sourceUnit->referencedSourceUnits(true, _skipList);
+ sourceUnits.insert(referencedSourceUnits.begin(), referencedSourceUnits.end());
+ }
}
}
return sourceUnits;