@@ -1484,6 +1484,8 @@ CallExpr::CallExpr(StmtClass SC, Expr *Fn, ArrayRef<Expr *> PreArgs,
14841484
14851485 CallExprBits.HasFPFeatures = FPFeatures.requiresTrailingStorage ();
14861486 CallExprBits.IsCoroElideSafe = false ;
1487+ CallExprBits.ExplicitObjectMemFunUsingMemberSyntax = false ;
1488+
14871489 if (hasStoredFPFeatures ())
14881490 setStoredFPFeatures (FPFeatures);
14891491}
@@ -1549,12 +1551,15 @@ Decl *Expr::getReferencedDeclOfCallee() {
15491551 // (simple function or member function call)
15501552 // then try more exotic possibilities
15511553 Expr *CEE = IgnoreImpCasts ();
1554+
15521555 if (auto *DRE = dyn_cast<DeclRefExpr>(CEE))
15531556 return DRE->getDecl ();
15541557
15551558 if (auto *ME = dyn_cast<MemberExpr>(CEE))
15561559 return ME->getMemberDecl ();
15571560
1561+ CEE = CEE->IgnoreParens ();
1562+
15581563 while (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE))
15591564 CEE = NTTP->getReplacement ()->IgnoreParenImpCasts ();
15601565
@@ -1658,20 +1663,14 @@ SourceLocation CallExpr::getBeginLoc() const {
16581663 // begin location should come from the first argument.
16591664 // This does not apply to dependent calls, which are modelled with `o.f`
16601665 // being the callee.
1661- if (!isTypeDependent ()) {
1662- if (const auto *Method =
1663- dyn_cast_if_present<const CXXMethodDecl>(getCalleeDecl ());
1664- Method && Method->isExplicitObjectMemberFunction ()) {
1665- if (auto FirstArgLoc = getArg (0 )->getBeginLoc (); FirstArgLoc.isValid ()) {
1666- return FirstArgLoc;
1667- }
1666+ // Because this check is expennsive, we cache the result.
1667+ if (usesMemberSyntax ()) {
1668+ if (auto FirstArgLoc = getArg (0 )->getBeginLoc (); FirstArgLoc.isValid ()) {
1669+ return FirstArgLoc;
16681670 }
16691671 }
16701672
1671- SourceLocation begin = getCallee ()->getBeginLoc ();
1672- if (begin.isInvalid () && getNumArgs () > 0 && getArg (0 ))
1673- begin = getArg (0 )->getBeginLoc ();
1674- return begin;
1673+ return getCallee ()->getBeginLoc ();
16751674}
16761675
16771676SourceLocation CallExpr::getEndLoc () const {
0 commit comments