[clang] [clang][Sema] Null-check type in resolveMemberExpr() before checking for auto type (PR #124628)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 13:09:55 PST 2025


https://github.com/HighCommander4 created https://github.com/llvm/llvm-project/pull/124628

Fixes https://github.com/clangd/clangd/issues/2301

>From 5ecde7be72659f66c45b4cfdc9e398bdb850e862 Mon Sep 17 00:00:00 2001
From: Nathan Ridge <zeratul976 at hotmail.com>
Date: Mon, 27 Jan 2025 16:07:34 -0500
Subject: [PATCH] [clang][Sema] Null-check type in resolveMemberExpr() before
 checking for auto type

---
 clang/lib/Sema/HeuristicResolver.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp
index 87c7274e7aefa6..8c8c5d90f8245c 100644
--- a/clang/lib/Sema/HeuristicResolver.cpp
+++ b/clang/lib/Sema/HeuristicResolver.cpp
@@ -242,6 +242,8 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr(
       BaseType = resolveExprToType(Base);
     }
   }
+  if (BaseType.isNull())
+    return {};
   if (const auto *AT = BaseType->getContainedAutoType()) {
     // If BaseType contains a dependent `auto` type, deduction will not have
     // been performed on it yet. In simple cases (e.g. `auto` variable with



More information about the cfe-commits mailing list