https://github.com/nicovank created 
https://github.com/llvm/llvm-project/pull/105976

Fix #104883.
Fix #104800.

Thanks @Endilll for the reduced reproducer. Bisection points to 
0cb7e7ca0c864e052bf49978f3bcd667c9e16930 as the faulty commit, but nothing 
there seems to indicate what the problem is. After some print debugging, `Decl` 
on [this 
line](https://github.com/llvm/llvm-project/blob/f22b1da8791edd557ce34c87190e329df2e1c892/clang/lib/Sema/SemaOverload.cpp#L7429)
 is a `UsingDecl`, not a `CXXMethodDecl`, and the cast fails.

Add a conditional case for `UsingDecl`.

I am not familiar with Clang/Sema so please make sure this fix makes sense.

>From c4d185916fcf12f7f5584e7556829a8f9cbf4eb3 Mon Sep 17 00:00:00 2001
From: Nicolas van Kempen <nvank...@gmail.com>
Date: Sun, 25 Aug 2024 02:52:06 -0400
Subject: [PATCH] [clang][Sema] Fix particular operator overload crash

Fix #104883.
Fix #104800.
---
 clang/lib/Sema/SemaOverload.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1ce0fa091938d7..a2cf334bd176fe 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7425,6 +7425,13 @@ void Sema::AddMethodCandidate(DeclAccessPair FoundDecl, 
QualType ObjectType,
                                /*ExplicitArgs*/ nullptr, ObjectType,
                                ObjectClassification, Args, CandidateSet,
                                SuppressUserConversions, false, PO);
+  } else if (UsingDecl *UD = dyn_cast<UsingDecl>(Decl)) {
+    for (auto *Shadow : UD->shadows()) {
+      AddMethodCandidate(cast<CXXMethodDecl>(Shadow->getTargetDecl()),
+                         FoundDecl, ActingContext, ObjectType,
+                         ObjectClassification, Args, CandidateSet,
+                         SuppressUserConversions, false, std::nullopt, PO);
+    }
   } else {
     AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
                        ObjectType, ObjectClassification, Args, CandidateSet,

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to