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

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 13:10:30 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Nathan Ridge (HighCommander4)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/124628.diff


1 Files Affected:

- (modified) clang/lib/Sema/HeuristicResolver.cpp (+2) 


``````````diff
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

``````````

</details>


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


More information about the cfe-commits mailing list