Skip to content

Commit

Permalink
fix: dependency extraction for templates
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkrystian committed May 27, 2024
1 parent 7820d6a commit a28f265
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/lib/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ class ASTVisitor
Decl* D,
SymbolID& id)
{
if(TemplateDecl* TD = D->getDescribedTemplate())
D = TD;

if(D->isImplicit() ||
isa<TemplateTemplateParmDecl>(D) ||
isa<BuiltinTemplateDecl>(D))
Expand Down Expand Up @@ -502,6 +505,9 @@ class ASTVisitor
}
while((DC = DC->getParent()));

if(TemplateDecl* TD = Outer->getDescribedTemplate())
Outer = TD;

// add the adjusted declaration to the set of dependencies
if(! isa<NamespaceDecl, TranslationUnitDecl>(Outer))
dependencies_.insert(Outer);
Expand Down
31 changes: 20 additions & 11 deletions test-files/old-tests/dependency-propagation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@
</base>
</struct>
<namespace name="N" id="rjlMNXAaWNMkQYMTJzRA1DR0DiE=">
<alias name="C" id="1aINBgFfB9zQVkEDJdB0DyLWTmQ=">
<file path="dependency-propagation.cpp" line="10" class="def"/>
<type id="YZjBn7yW7NyL8yCKqswVvbiptNM=" name="N::B&lt;T&gt;"/>
</alias>
<alias name="B" id="YZjBn7yW7NyL8yCKqswVvbiptNM=">
<file path="dependency-propagation.cpp" line="7" class="def"/>
<type id="P3wHAbrIf4CGxTZs+lXT5a3t2K0=" name="N::A&lt;T&gt;"/>
</alias>
<struct name="A" id="P3wHAbrIf4CGxTZs+lXT5a3t2K0=">
<file path="dependency-propagation.cpp" line="4" class="def"/>
</struct>
<template>
<tparam name="T" class="type"/>
<alias name="C" id="1aINBgFfB9zQVkEDJdB0DyLWTmQ=">
<file path="dependency-propagation.cpp" line="10" class="def"/>
<type id="YZjBn7yW7NyL8yCKqswVvbiptNM=" name="N::B&lt;T&gt;"/>
</alias>
</template>
<template>
<tparam name="T" class="type"/>
<alias name="B" id="YZjBn7yW7NyL8yCKqswVvbiptNM=">
<file path="dependency-propagation.cpp" line="7" class="def"/>
<type id="P3wHAbrIf4CGxTZs+lXT5a3t2K0=" name="N::A&lt;T&gt;"/>
</alias>
</template>
<template>
<tparam name="T" class="type"/>
<struct name="A" id="P3wHAbrIf4CGxTZs+lXT5a3t2K0=">
<file path="dependency-propagation.cpp" line="4" class="def"/>
</struct>
</template>
</namespace>
</namespace>
</mrdocs>

0 comments on commit a28f265

Please sign in to comment.