[clang][bytecode] Fix comparing member pointers for redeclared FieldDecls (#208660)
Use the first decl to compare.
This commit is contained in:
parent
15df0ca2f9
commit
41a35a7d99
2 changed files with 16 additions and 1 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue