forked from OSchip/llvm-project
[clang][CodeComplete] Perform approximate member search in bases
Differential Revision: https://reviews.llvm.org/D117037
This commit is contained in:
parent
57e714bcc8
commit
612f5ed882
|
@ -5519,11 +5519,17 @@ QualType getApproximateType(const Expr *E) {
|
|||
: getApproximateType(CDSME->getBase());
|
||||
if (CDSME->isArrow() && !Base.isNull())
|
||||
Base = Base->getPointeeType(); // could handle unique_ptr etc here?
|
||||
RecordDecl *RD = Base.isNull() ? nullptr : getAsRecordDecl(Base);
|
||||
auto *RD = Base.isNull()
|
||||
? nullptr
|
||||
: llvm::dyn_cast<CXXRecordDecl>(getAsRecordDecl(Base));
|
||||
if (RD && RD->isCompleteDefinition()) {
|
||||
for (const auto *Member : RD->lookup(CDSME->getMember()))
|
||||
if (const ValueDecl *VD = llvm::dyn_cast<ValueDecl>(Member))
|
||||
return VD->getType().getNonReferenceType();
|
||||
// Look up member heuristically, including in bases.
|
||||
for (const auto *Member : RD->lookupDependentName(
|
||||
CDSME->getMember(), [](const NamedDecl *Member) {
|
||||
return llvm::isa<ValueDecl>(Member);
|
||||
})) {
|
||||
return llvm::cast<ValueDecl>(Member)->getType().getNonReferenceType();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Unresolved;
|
||||
|
|
|
@ -296,3 +296,18 @@ void fooDependent(T t) {
|
|||
}
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:295:17 %s -o - | FileCheck -check-prefix=CHECK-OVERLOAD %s
|
||||
// CHECK-OVERLOAD: [#int#]member
|
||||
|
||||
struct Base4 {
|
||||
Base4 base4();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Derived2 : Base4 {};
|
||||
|
||||
template <typename T>
|
||||
void testMembersFromBasesInDependentContext() {
|
||||
Derived2<T> X;
|
||||
(void)X.base4().base4();
|
||||
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:310:19 %s -o - | FileCheck -check-prefix=CHECK-MEMBERS-FROM-BASE-DEPENDENT %s
|
||||
// CHECK-MEMBERS-FROM-BASE-DEPENDENT: [#Base4#]base4
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue