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

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 16:51:34 PST 2025


Author: Nathan Ridge
Date: 2025-01-27T19:51:30-05:00
New Revision: 194c74e0166876ef2c5e0ff5e98a4b5a5442138c

URL: https://github.com/llvm/llvm-project/commit/194c74e0166876ef2c5e0ff5e98a4b5a5442138c
DIFF: https://github.com/llvm/llvm-project/commit/194c74e0166876ef2c5e0ff5e98a4b5a5442138c.diff

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

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

Added: 
    

Modified: 
    clang/lib/Sema/HeuristicResolver.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp
index 87c7274e7aefa6..947cf3f2f0a02b 100644
--- a/clang/lib/Sema/HeuristicResolver.cpp
+++ b/clang/lib/Sema/HeuristicResolver.cpp
@@ -231,15 +231,17 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr(
   QualType BaseType = ME->getBaseType();
   if (ME->isArrow()) {
     BaseType = getPointeeType(BaseType);
+    if (BaseType.isNull())
+      return {};
   }
-  if (BaseType.isNull())
-    return {};
   if (const auto *BT = BaseType->getAs<BuiltinType>()) {
     // If BaseType is the type of a dependent expression, it's just
     // represented as BuiltinType::Dependent which gives us no information. We
     // can get further by analyzing the dependent expression.
     if (Base && BT->getKind() == BuiltinType::Dependent) {
       BaseType = resolveExprToType(Base);
+      if (BaseType.isNull())
+        return {};
     }
   }
   if (const auto *AT = BaseType->getContainedAutoType()) {


        


More information about the cfe-commits mailing list