[clang] [Clang] Stop changing DC when instantiating dependent friend specializations (PR #139436)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Mon May 12 02:38:02 PDT 2025
================
@@ -5751,14 +5751,16 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
RebuildTypeSourceInfoForDefaultSpecialMembers();
SetDeclDefaulted(Function, PatternDecl->getLocation());
} else {
- NamedDecl *ND = Function;
- DeclContext *DC = ND->getLexicalDeclContext();
+ DeclContext *DC = Function->getLexicalDeclContext();
std::optional<ArrayRef<TemplateArgument>> Innermost;
- if (auto *Primary = Function->getPrimaryTemplate();
- Primary &&
+ bool NeedDCFromPrimaryTemplate =
!isGenericLambdaCallOperatorOrStaticInvokerSpecialization(Function) &&
Function->getTemplateSpecializationKind() !=
- TSK_ExplicitSpecialization) {
+ TSK_ExplicitSpecialization &&
+ !PatternDecl->getDependentSpecializationInfo();
----------------
zyn0217 wrote:
I am also considering to have these instantiations 1) never track the primary template in these cases 2) or track the invalid explicit specialization as its primary template (this likely isn't doable because the specialization is not a template).
Neither option seems ideal to me
https://github.com/llvm/llvm-project/pull/139436
More information about the cfe-commits
mailing list