Skip to content

Commit cc08383

Browse files
committed
fix: support SFINAE detection for compound types
1 parent 3a22947 commit cc08383

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/lib/AST/ASTVisitor.cpp

+15-7
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,9 @@ class ASTVisitor
18761876
std::optional<std::pair<QualType, std::vector<TemplateArgument>>>
18771877
isSFINAEType(QualType T)
18781878
{
1879+
if(! config_->detectSfinae)
1880+
return std::nullopt;
1881+
18791882
auto sfinae_info = getSFINAETemplate(T, true);
18801883
if(! sfinae_info)
18811884
return std::nullopt;
@@ -1904,6 +1907,12 @@ class ASTVisitor
19041907
return std::make_pair(param_arg->getAsType(), std::move(ControllingArgs));
19051908
}
19061909

1910+
std::optional<std::pair<QualType, std::vector<TemplateArgument>>>
1911+
isSFINAEType(const Type* T)
1912+
{
1913+
return isSFINAEType(QualType(T, 0));
1914+
}
1915+
19071916
std::string extractName(DeclarationName N)
19081917
{
19091918
std::string result;
@@ -3849,6 +3858,9 @@ class TerminalTypeVisitor
38493858
VisitDependentNameType(
38503859
const DependentNameType* T)
38513860
{
3861+
if(auto SFINAE = getASTVisitor().isSFINAEType(T); SFINAE.has_value())
3862+
return getDerived().Visit(SFINAE->first);
3863+
38523864
if(auto* NNS = T->getQualifier())
38533865
NNS_ = NNS;
38543866
getDerived().buildTerminal(NNS_, T->getIdentifier(),
@@ -3871,6 +3883,9 @@ class TerminalTypeVisitor
38713883
VisitTemplateSpecializationType(
38723884
const TemplateSpecializationType* T)
38733885
{
3886+
if(auto SFINAE = getASTVisitor().isSFINAEType(T); SFINAE.has_value())
3887+
return getDerived().Visit(SFINAE->first);
3888+
38743889
TemplateName TN = T->getTemplateName();
38753890
MRDOCS_ASSERT(! TN.isNull());
38763891
NamedDecl* ND = TN.getAsTemplateDecl();
@@ -4296,13 +4311,6 @@ buildTypeInfo(
42964311
ExtractionScope scope = enterMode(extract_mode);
42974312
// build the TypeInfo representation for the type
42984313
TypeInfoBuilder Builder(*this);
4299-
4300-
if(config_->detectSfinae)
4301-
{
4302-
if(auto SFINAE = isSFINAEType(qt); SFINAE.has_value())
4303-
qt = SFINAE->first.withFastQualifiers(qt.getLocalFastQualifiers());
4304-
}
4305-
43064314
Builder.Visit(qt);
43074315
return Builder.result();
43084316
}

0 commit comments

Comments
 (0)