Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

HighCommander4
Copy link
Collaborator

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jan 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 27, 2025

@llvm/pr-subscribers-clang

Author: Nathan Ridge (HighCommander4)

Changes

Fixes clangd/clangd#2301


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

1 Files Affected:

  • (modified) clang/lib/Sema/HeuristicResolver.cpp (+2)
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

@HighCommander4
Copy link
Collaborator Author

No test case because there wasn't one in the bug report; I diagnosed the issue based on the stack trace only.

Copy link
Contributor

@zyn0217 zyn0217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, feel free to merge after addressing @cor3ntin 's concern

@HighCommander4 HighCommander4 force-pushed the users/HighCommander4/clangd-issue-2301 branch from 5ecde7b to a6abb64 Compare January 28, 2025 00:30
@HighCommander4 HighCommander4 merged commit 194c74e into main Jan 28, 2025
6 of 7 checks passed
@HighCommander4 HighCommander4 deleted the users/HighCommander4/clangd-issue-2301 branch January 28, 2025 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recurring crashes in HeuristicResolver
4 participants