llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Nicolas van Kempen (nicovank)

<details>
<summary>Changes</summary>

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.

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaOverload.cpp (+7) 


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

``````````

</details>


https://github.com/llvm/llvm-project/pull/105976
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to