aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/TreeTransform.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/TreeTransform.h')
-rw-r--r--clang/lib/Sema/TreeTransform.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 51b55b8..940324b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -16364,16 +16364,21 @@ ExprResult TreeTransform<Derived>::TransformSubstNonTypeTemplateParmExpr(
AssociatedDecl == E->getAssociatedDecl())
return E;
+ auto getParamAndType = [Index = E->getIndex()](Decl *AssociatedDecl)
+ -> std::tuple<NonTypeTemplateParmDecl *, QualType> {
+ auto [PDecl, Arg] = getReplacedTemplateParameter(AssociatedDecl, Index);
+ auto *Param = cast<NonTypeTemplateParmDecl>(PDecl);
+ return {Param, Arg.isNull() ? Param->getType()
+ : Arg.getNonTypeTemplateArgumentType()};
+ };
+
// If the replacement expression did not change, and the parameter type
// did not change, we can skip the semantic action because it would
// produce the same result anyway.
- auto *Param = cast<NonTypeTemplateParmDecl>(
- getReplacedTemplateParameterList(AssociatedDecl)
- ->asArray()[E->getIndex()]);
- if (QualType ParamType = Param->getType();
- !SemaRef.Context.hasSameType(ParamType, E->getParameter()->getType()) ||
+ if (auto [Param, ParamType] = getParamAndType(AssociatedDecl);
+ !SemaRef.Context.hasSameType(
+ ParamType, std::get<1>(getParamAndType(E->getAssociatedDecl()))) ||
Replacement.get() != OrigReplacement) {
-
// When transforming the replacement expression previously, all Sema
// specific annotations, such as implicit casts, are discarded. Calling the
// corresponding sema action is necessary to recover those. Otherwise,