[all-commits] [llvm/llvm-project] d1a80d: Reapply "[Clang] Fix dependent local class instant...
Younan Zhang via All-commits
all-commits at lists.llvm.org
Wed Apr 16 23:34:54 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d1a80deae674300d1011ccb6d6ee7030eaf8e713
https://github.com/llvm/llvm-project/commit/d1a80deae674300d1011ccb6d6ee7030eaf8e713
Author: Younan Zhang <zyn7109 at gmail.com>
Date: 2025-04-17 (Thu, 17 Apr 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Sema/SemaExprCXX.cpp
M clang/lib/Sema/SemaTemplateInstantiate.cpp
M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
A clang/test/CodeGenCXX/local-class-instantiation.cpp
M clang/test/SemaTemplate/instantiate-local-class.cpp
Log Message:
-----------
Reapply "[Clang] Fix dependent local class instantiation bugs" (#135914)
This reapplies #134038
Since the last patch, this fixes a null pointer dereference where the
TSI of the destructor wasn't properly propagated into the
DeclarationNameInfo. We now construct a LocInfoType for dependent cases,
as done elsewhere in getDestructorName, such that GetTypeFromParser can
correctly obtain the TSI.
---
This patch fixes two long-standing bugs that prevent Clang from
instantiating local class members inside a dependent context. These bugs
were introduced in commits
https://github.com/llvm/llvm-project/commit/21eb1af469c3257606aec2270d544e0e8ecf77b2
and
https://github.com/llvm/llvm-project/commit/919df9d75ac2a721a8072327c803f34486884571.
https://github.com/llvm/llvm-project/commit/21eb1af469c3257606aec2270d544e0e8ecf77b2
introduced a concept called eligible methods such that it did an attempt
to skip past ineligible method instantiation when instantiating class
members. Unfortunately, this broke the instantiation chain for local
classes - getTemplateInstantiationPattern() would fail to find the
correct definition pattern if the class was defined within a partially
transformed dependent context.
https://github.com/llvm/llvm-project/commit/919df9d75ac2a721a8072327c803f34486884571
introduced a separate issue by incorrectly copying the
DeclarationNameInfo during function definition instantiation from the
template pattern, even though that DNI might contain a transformed
TypeSourceInfo. Since that TSI was already updated when the declaration
was instantiated, this led to inconsistencies. As a result, the final
instantiated function could lose track of the transformed declarations,
hence we crash: https://compiler-explorer.com/z/vjvoG76Tf.
This PR corrects them by
1. Removing the bypass logic for method instantiation. The eligible flag
is independent of instantiation and can be updated properly afterward,
so skipping instantiation is unnecessary.
2. Carefully handling TypeSourceInfo by creating a new instance that
preserves the pattern's source location while using the already
transformed type.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list