@@ -2867,7 +2867,8 @@ uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset) {
2867
2867
return LocalOffset + M.GlobalBitOffset ;
2868
2868
}
2869
2869
2870
- static bool isSameTemplateParameterList (const TemplateParameterList *X,
2870
+ static bool isSameTemplateParameterList (const ASTContext &C,
2871
+ const TemplateParameterList *X,
2871
2872
const TemplateParameterList *Y);
2872
2873
2873
2874
// / Determine whether two template parameters are similar enough
@@ -2879,7 +2880,32 @@ static bool isSameTemplateParameter(const NamedDecl *X,
2879
2880
2880
2881
if (const auto *TX = dyn_cast<TemplateTypeParmDecl>(X)) {
2881
2882
const auto *TY = cast<TemplateTypeParmDecl>(Y);
2882
- return TX->isParameterPack () == TY->isParameterPack ();
2883
+ if (TX->isParameterPack () != TY->isParameterPack ())
2884
+ return false ;
2885
+ if (TX->hasTypeConstraint () != TY->hasTypeConstraint ())
2886
+ return false ;
2887
+ if (TX->hasTypeConstraint ()) {
2888
+ const TypeConstraint *TXTC = TX->getTypeConstraint ();
2889
+ const TypeConstraint *TYTC = TY->getTypeConstraint ();
2890
+ if (TXTC->getNamedConcept () != TYTC->getNamedConcept ())
2891
+ return false ;
2892
+ if (TXTC->hasExplicitTemplateArgs () != TYTC->hasExplicitTemplateArgs ())
2893
+ return false ;
2894
+ if (TXTC->hasExplicitTemplateArgs ()) {
2895
+ const auto *TXTCArgs = TXTC->getTemplateArgsAsWritten ();
2896
+ const auto *TYTCArgs = TYTC->getTemplateArgsAsWritten ();
2897
+ if (TXTCArgs->NumTemplateArgs != TYTCArgs->NumTemplateArgs )
2898
+ return false ;
2899
+ llvm::FoldingSetNodeID XID, YID;
2900
+ for (const auto &ArgLoc : TXTCArgs->arguments ())
2901
+ ArgLoc.getArgument ().Profile (XID, X->getASTContext ());
2902
+ for (const auto &ArgLoc : TYTCArgs->arguments ())
2903
+ ArgLoc.getArgument ().Profile (YID, Y->getASTContext ());
2904
+ if (XID != YID)
2905
+ return false ;
2906
+ }
2907
+ }
2908
+ return true ;
2883
2909
}
2884
2910
2885
2911
if (const auto *TX = dyn_cast<NonTypeTemplateParmDecl>(X)) {
@@ -2891,7 +2917,8 @@ static bool isSameTemplateParameter(const NamedDecl *X,
2891
2917
const auto *TX = cast<TemplateTemplateParmDecl>(X);
2892
2918
const auto *TY = cast<TemplateTemplateParmDecl>(Y);
2893
2919
return TX->isParameterPack () == TY->isParameterPack () &&
2894
- isSameTemplateParameterList (TX->getTemplateParameters (),
2920
+ isSameTemplateParameterList (TX->getASTContext (),
2921
+ TX->getTemplateParameters (),
2895
2922
TY->getTemplateParameters ());
2896
2923
}
2897
2924
@@ -2944,7 +2971,8 @@ static bool isSameQualifier(const NestedNameSpecifier *X,
2944
2971
2945
2972
// / Determine whether two template parameter lists are similar enough
2946
2973
// / that they may be used in declarations of the same template.
2947
- static bool isSameTemplateParameterList (const TemplateParameterList *X,
2974
+ static bool isSameTemplateParameterList (const ASTContext &C,
2975
+ const TemplateParameterList *X,
2948
2976
const TemplateParameterList *Y) {
2949
2977
if (X->size () != Y->size ())
2950
2978
return false ;
@@ -2953,6 +2981,18 @@ static bool isSameTemplateParameterList(const TemplateParameterList *X,
2953
2981
if (!isSameTemplateParameter (X->getParam (I), Y->getParam (I)))
2954
2982
return false ;
2955
2983
2984
+ const Expr *XRC = X->getRequiresClause ();
2985
+ const Expr *YRC = Y->getRequiresClause ();
2986
+ if (!XRC != !YRC)
2987
+ return false ;
2988
+ if (XRC) {
2989
+ llvm::FoldingSetNodeID XRCID, YRCID;
2990
+ XRC->Profile (XRCID, C, /* Canonical=*/ true );
2991
+ YRC->Profile (YRCID, C, /* Canonical=*/ true );
2992
+ if (XRCID != YRCID)
2993
+ return false ;
2994
+ }
2995
+
2956
2996
return true ;
2957
2997
}
2958
2998
@@ -2989,7 +3029,7 @@ static bool hasSameOverloadableAttrs(const FunctionDecl *A,
2989
3029
return true ;
2990
3030
}
2991
3031
2992
- // / Determine whether the two declarations refer to the same entity.
3032
+ // / Determine whether the two declarations refer to the same entity.pr
2993
3033
static bool isSameEntity (NamedDecl *X, NamedDecl *Y) {
2994
3034
assert (X->getDeclName () == Y->getDeclName () && " Declaration name mismatch!" );
2995
3035
@@ -3064,6 +3104,19 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
3064
3104
}
3065
3105
3066
3106
ASTContext &C = FuncX->getASTContext ();
3107
+
3108
+ const Expr *XRC = FuncX->getTrailingRequiresClause ();
3109
+ const Expr *YRC = FuncY->getTrailingRequiresClause ();
3110
+ if (!XRC != !YRC)
3111
+ return false ;
3112
+ if (XRC) {
3113
+ llvm::FoldingSetNodeID XRCID, YRCID;
3114
+ XRC->Profile (XRCID, C, /* Canonical=*/ true );
3115
+ YRC->Profile (YRCID, C, /* Canonical=*/ true );
3116
+ if (XRCID != YRCID)
3117
+ return false ;
3118
+ }
3119
+
3067
3120
auto GetTypeAsWritten = [](const FunctionDecl *FD) {
3068
3121
// Map to the first declaration that we've already merged into this one.
3069
3122
// The TSI of redeclarations might not match (due to calling conventions
@@ -3087,6 +3140,7 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
3087
3140
return true ;
3088
3141
return false ;
3089
3142
}
3143
+
3090
3144
return FuncX->getLinkageInternal () == FuncY->getLinkageInternal () &&
3091
3145
hasSameOverloadableAttrs (FuncX, FuncY);
3092
3146
}
@@ -3126,7 +3180,8 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
3126
3180
const auto *TemplateY = cast<TemplateDecl>(Y);
3127
3181
return isSameEntity (TemplateX->getTemplatedDecl (),
3128
3182
TemplateY->getTemplatedDecl ()) &&
3129
- isSameTemplateParameterList (TemplateX->getTemplateParameters (),
3183
+ isSameTemplateParameterList (TemplateX->getASTContext (),
3184
+ TemplateX->getTemplateParameters (),
3130
3185
TemplateY->getTemplateParameters ());
3131
3186
}
3132
3187
0 commit comments