commit | d1a80deae674300d1011ccb6d6ee7030eaf8e713 | [log] [tgz] |
---|---|---|
author | Younan Zhang <zyn7109@gmail.com> | Thu Apr 17 14:34:32 2025 +0800 |
committer | GitHub <noreply@github.com> | Thu Apr 17 14:34:32 2025 +0800 |
tree | 4595bf24728fc277520e55bb951ff88e363ae1cd | |
parent | 8e67d8fdf3a31b42f52ec12d995490f866b4449b [diff] |
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.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.