[clang] fix typo correction not looking for candidates in base classes.

RecordMemberExprValidator was not looking through ElaboratedType
nodes when looking for candidates which occur in base classes.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D111830
This commit is contained in:
Matheus Izvekov 2021-10-14 21:49:22 +02:00
parent 1830ec94ac
commit 489561d463
No known key found for this signature in database
GPG Key ID: 5C771D2BB8AB9907
2 changed files with 4 additions and 5 deletions

View File

@ -611,11 +611,10 @@ public:
if (Record->containsDecl(ND))
return true;
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Record)) {
if (const auto *RD = dyn_cast<CXXRecordDecl>(Record)) {
// Accept candidates that occur in any of the current class' base classes.
for (const auto &BS : RD->bases()) {
if (const RecordType *BSTy =
dyn_cast_or_null<RecordType>(BS.getType().getTypePtrOrNull())) {
if (const auto *BSTy = BS.getType()->getAs<RecordType>()) {
if (BSTy->getDecl()->containsDecl(ND))
return true;
}

View File

@ -477,7 +477,7 @@ namespace dr140 { // dr140: yes
namespace dr141 { // dr141: yes
template<typename T> void f();
template<typename T> struct S { int n; };
template<typename T> struct S { int n; }; // expected-note {{'::dr141::S<int>::n' declared here}}
struct A : S<int> {
template<typename T> void f();
template<typename T> struct S {};
@ -485,7 +485,7 @@ namespace dr141 { // dr141: yes
struct B : S<int> {} b;
void g() {
a.f<int>();
(void)a.S<int>::n; // expected-error {{no member named 'n'}}
(void)a.S<int>::n; // expected-error {{no member named 'n' in 'dr141::A::S<int>'; did you mean '::dr141::S<int>::n'?}}
#if __cplusplus < 201103L
// expected-error@-2 {{ambiguous}}
// expected-note@-11 {{lookup from the current scope}}