[clang] [Clang] Fix a crash when incorrectly calling an explicit object member function template (PR #75913)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 19 01:47:10 PST 2023


================
@@ -253,6 +253,8 @@ static void diagnoseInstanceReference(Sema &SemaRef,
     SemaRef.Diag(Loc, diag::err_member_call_without_object)
         << Range << /*static*/ 0;
   else {
+    if (auto *Tpl = dyn_cast<FunctionTemplateDecl>(Rep))
+      Rep = Tpl->getTemplatedDecl();
     const auto *Callee = dyn_cast<CXXMethodDecl>(Rep);
----------------
tbaederr wrote:

Since `Callee` must be non-null after the cast, shouldn't we use `cast<>` instead of `dyn_cast` here?

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


More information about the cfe-commits mailing list