aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorKrystian Stasiowski <sdkrystian@gmail.com>2024-11-01 14:15:33 -0600
committerGitHub <noreply@github.com>2024-11-01 16:15:33 -0400
commitb24650e814e55d90acfc40acf045456c98f32b9c (patch)
tree31c276991f2a1c7590efecaf66560e541b7cac43 /clang/lib/Sema/SemaDecl.cpp
parent308c00749ddb76b2e77934e986001b7fd4ad5cdc (diff)
downloadllvm-b24650e814e55d90acfc40acf045456c98f32b9c.zip
llvm-b24650e814e55d90acfc40acf045456c98f32b9c.tar.gz
llvm-b24650e814e55d90acfc40acf045456c98f32b9c.tar.bz2
Reapply "[Clang][Sema] Always use latest redeclaration of primary template" (#114569)
This patch reapplies #114258, fixing an infinite recursion bug in `ASTImporter` that occurs when importing the primary template of a class template specialization when the latest redeclaration of that template is a friend declaration in the primary template.
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0cdace2..1aa3e8e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4694,8 +4694,10 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
// Keep a chain of previous declarations.
New->setPreviousDecl(Old);
- if (NewTemplate)
+ if (NewTemplate) {
+ NewTemplate->mergePrevDecl(OldTemplate);
NewTemplate->setPreviousDecl(OldTemplate);
+ }
// Inherit access appropriately.
New->setAccess(Old->getAccess());