Skip to content

Commit 2aad9fc

Browse files
committed
call Decl::setImplicit for implicit instantiations of variables and functions
1 parent 022cce3 commit 2aad9fc

File tree

2 files changed

+20
-44
lines changed

2 files changed

+20
-44
lines changed

source/AST/ASTVisitor.cpp

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -569,20 +569,6 @@ shouldExtract(
569569
return true;
570570
}
571571

572-
template<typename DeclTy>
573-
bool
574-
ASTVisitor::
575-
isImplicitInstantiation(
576-
const DeclTy* D)
577-
{
578-
if constexpr(requires { { D->getTemplateSpecializationKind() } ->
579-
std::same_as<TemplateSpecializationKind>; })
580-
return D->getTemplateSpecializationKind() ==
581-
TemplateSpecializationKind::TSK_ImplicitInstantiation;
582-
else
583-
return false;
584-
}
585-
586572
bool
587573
ASTVisitor::
588574
extractInfo(
@@ -1198,10 +1184,6 @@ Traverse(
11981184
AccessSpecifier A,
11991185
std::unique_ptr<TemplateInfo>&& Template = nullptr)
12001186
{
1201-
// implicit instantiations should *only* have their Info
1202-
// extracted via buildSpecialization calls from getParentNamespaces
1203-
if(isImplicitInstantiation(D))
1204-
return true;
12051187
if(! shouldExtract(D))
12061188
return true;
12071189

@@ -1258,13 +1240,6 @@ Traverse(
12581240
AccessSpecifier A,
12591241
std::unique_ptr<TemplateInfo>&& Template = nullptr)
12601242
{
1261-
// implicitly instantiated definitions of non-inline
1262-
// static data members of class templates are added to
1263-
// the end of the TU DeclContext. Decl::isImplicit returns
1264-
// false for these VarDecls, so we must check whether this
1265-
// variable is an implicit instantiation & skip such Decls
1266-
if(isImplicitInstantiation(D))
1267-
return true;
12681243
if(! shouldExtract(D))
12691244
return true;
12701245

@@ -1283,8 +1258,6 @@ Traverse(
12831258
AccessSpecifier A,
12841259
std::unique_ptr<TemplateInfo>&& Template = nullptr)
12851260
{
1286-
if(isImplicitInstantiation(D))
1287-
return true;
12881261
if(! shouldExtract(D))
12891262
return true;
12901263

@@ -1304,8 +1277,6 @@ Traverse(
13041277
AccessSpecifier A,
13051278
std::unique_ptr<TemplateInfo>&& Template = nullptr)
13061279
{
1307-
if(isImplicitInstantiation(D))
1308-
return true;
13091280
if(! shouldExtract(D))
13101281
return true;
13111282

@@ -1331,8 +1302,6 @@ Traverse(
13311302
if(DN)
13321303
s = DN.getAsString();
13331304
*/
1334-
if(isImplicitInstantiation(D))
1335-
return true;
13361305
if(! shouldExtract(D))
13371306
return true;
13381307

@@ -1351,8 +1320,6 @@ Traverse(
13511320
AccessSpecifier A,
13521321
std::unique_ptr<TemplateInfo>&& Template = nullptr)
13531322
{
1354-
if(isImplicitInstantiation(D))
1355-
return true;
13561323
if(! shouldExtract(D))
13571324
return true;
13581325

@@ -1371,8 +1338,6 @@ Traverse(
13711338
AccessSpecifier A,
13721339
std::unique_ptr<TemplateInfo>&& Template = nullptr)
13731340
{
1374-
if(isImplicitInstantiation(D))
1375-
return true;
13761341
if(! shouldExtract(D))
13771342
return true;
13781343

@@ -1387,8 +1352,6 @@ Traverse(
13871352
CXXDestructorDecl* D,
13881353
AccessSpecifier A)
13891354
{
1390-
if(isImplicitInstantiation(D))
1391-
return true;
13921355
if(! shouldExtract(D))
13931356
return true;
13941357

@@ -1415,8 +1378,6 @@ Traverse(
14151378
EnumDecl* D,
14161379
AccessSpecifier A)
14171380
{
1418-
if(isImplicitInstantiation(D))
1419-
return true;
14201381
if(! shouldExtract(D))
14211382
return true;
14221383

@@ -1812,5 +1773,23 @@ ForgetSema()
18121773
sema_ = nullptr;
18131774
}
18141775

1776+
void
1777+
ASTVisitor::
1778+
HandleCXXStaticMemberVarInstantiation(VarDecl* D)
1779+
{
1780+
// implicitly instantiated definitions of non-inline
1781+
// static data members of class templates are added to
1782+
// the end of the TU DeclContext. Decl::isImplicit returns
1783+
// false for these VarDecls, so we manually set it here.
1784+
D->setImplicit();
1785+
}
1786+
1787+
void
1788+
ASTVisitor::
1789+
HandleCXXImplicitFunctionInstantiation(FunctionDecl* D)
1790+
{
1791+
D->setImplicit();
1792+
}
1793+
18151794
} // mrdox
18161795
} // clang

source/AST/ASTVisitor.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ class ASTVisitor
8585
shouldExtract(
8686
const Decl* D);
8787

88-
template<typename DeclTy>
89-
bool
90-
isImplicitInstantiation(
91-
const DeclTy* D);
92-
9388
bool
9489
extractInfo(
9590
Info& I,
@@ -303,6 +298,8 @@ class ASTVisitor
303298
void InitializeSema(Sema& S) override;
304299
void ForgetSema() override;
305300

301+
void HandleCXXStaticMemberVarInstantiation(VarDecl* D) override;
302+
void HandleCXXImplicitFunctionInstantiation(FunctionDecl* D) override;
306303
};
307304

308305
} // mrdox

0 commit comments

Comments
 (0)