[CodeComplete] fix nullptr crash in 612f5ed882

This commit is contained in:
Sam McCall 2022-01-21 23:18:23 +01:00 committed by GitHub
parent 6df05697ca
commit 653b007dc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -5519,9 +5519,10 @@ QualType getApproximateType(const Expr *E) {
: getApproximateType(CDSME->getBase());
if (CDSME->isArrow() && !Base.isNull())
Base = Base->getPointeeType(); // could handle unique_ptr etc here?
auto *RD = Base.isNull()
? nullptr
: llvm::dyn_cast<CXXRecordDecl>(getAsRecordDecl(Base));
auto *RD =
Base.isNull()
? nullptr
: llvm::dyn_cast_or_null<CXXRecordDecl>(getAsRecordDecl(Base));
if (RD && RD->isCompleteDefinition()) {
// Look up member heuristically, including in bases.
for (const auto *Member : RD->lookupDependentName(