[clang] 489561d - [clang] fix typo correction not looking for candidates in base classes.
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 15 15:35:31 PDT 2021
Author: Matheus Izvekov
Date: 2021-10-16T00:35:22+02:00
New Revision: 489561d46381d41a068beed1a2e18e00f0660248
URL: https://github.com/llvm/llvm-project/commit/489561d46381d41a068beed1a2e18e00f0660248
DIFF: https://github.com/llvm/llvm-project/commit/489561d46381d41a068beed1a2e18e00f0660248.diff
LOG: [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 at gmail.com>
Reviewed By: rsmith
Differential Revision: https://reviews.llvm.org/D111830
Added:
Modified:
clang/lib/Sema/SemaExprMember.cpp
clang/test/CXX/drs/dr1xx.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 2a3b696417d8..83006f9d804a 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -611,11 +611,10 @@ class RecordMemberExprValidatorCCC final : public CorrectionCandidateCallback {
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;
}
diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp
index 4efa2e2fa943..51abb36dc9e3 100644
--- a/clang/test/CXX/drs/dr1xx.cpp
+++ b/clang/test/CXX/drs/dr1xx.cpp
@@ -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 at -2 {{ambiguous}}
// expected-note at -11 {{lookup from the current scope}}
More information about the cfe-commits
mailing list