Skip to content

Commit 381c221

Browse files
committed
try optimize
1 parent f4cebe5 commit 381c221

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

clang/lib/AST/Expr.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,16 @@ unsigned CallExpr::offsetToTrailingObjects(StmtClass SC) {
15441544
}
15451545

15461546
Decl *Expr::getReferencedDeclOfCallee() {
1547-
Expr *CEE = IgnoreParenImpCasts();
1547+
1548+
// Optimize for the common case first
1549+
// (simple function or member function call)
1550+
// then try more exotic possibilities
1551+
Expr *CEE = IgnoreImpCasts();
1552+
if (auto *DRE = dyn_cast<DeclRefExpr>(CEE))
1553+
return DRE->getDecl();
1554+
1555+
if (auto *ME = dyn_cast<MemberExpr>(CEE))
1556+
return ME->getMemberDecl();
15481557

15491558
while (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE))
15501559
CEE = NTTP->getReplacement()->IgnoreParenImpCasts();

0 commit comments

Comments
 (0)