[clang][bytecode] Fix comparing member pointers for redeclared FieldDecls (#208660)

Use the first decl to compare.
This commit is contained in:
Timm Baeder 2026-07-10 13:08:24 +02:00 committed by GitHub
parent 15df0ca2f9
commit 41a35a7d99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -89,8 +89,20 @@ APValue MemberPointer::toAPValue(const ASTContext &ASTCtx) const {
ComparisonCategoryResult
MemberPointer::compare(const MemberPointer &RHS) const {
if (this->getDecl() == RHS.getDecl()) {
assert(!isZero());
assert(!RHS.isZero());
const auto getCmpDecl = [](const MemberPointer &P) -> const Decl * {
const Decl *D = P.getDecl()->getMostRecentDecl();
if (const auto *FD = dyn_cast<FieldDecl>(D))
D = FD->getFirstDecl();
return D;
};
const Decl *LHSCmpDecl = getCmpDecl(*this);
const Decl *RHSCmpDecl = getCmpDecl(RHS);
if (LHSCmpDecl == RHSCmpDecl) {
if (this->PathLength != RHS.PathLength)
return ComparisonCategoryResult::Unordered;

View file

@ -1,6 +1,9 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -verify %s -Wno-objc-root-class
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -verify %s -Wno-objc-root-class -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class -fexperimental-new-constant-interpreter | FileCheck %s
// expected-no-diagnostics
// REQUIRES: x86-registered-target
@import templates_left;