diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-09-10 20:55:30 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-09-10 20:55:30 +0000 |
commit | 200121569dc6cff10a1fb6ed7500098770b9dd25 (patch) | |
tree | 5becafa4680d4ef2b8d763319fba0139f50c3e19 | |
parent | 68d114dc3e1d9ef0c0b073edcb824d4d7f37d416 (diff) |
Make CallExpr::getCalleeDecl look through pointer derefs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113620 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Expr.h | 1 | ||||
-rw-r--r-- | lib/AST/Expr.cpp | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 1f3a1bac97..debc637745 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -2295,6 +2295,7 @@ public: static OverloadedOperatorKind getOverloadedOperator(Opcode Opc); /// predicates to categorize the respective opcodes. + bool isPtrMemOp() const { return Opc == BO_PtrMemD || Opc == BO_PtrMemI; } bool isMultiplicativeOp() const { return Opc >= BO_Mul && Opc <= BO_Rem; } static bool isAdditiveOp(Opcode Opc) { return Opc == BO_Add || Opc==BO_Sub; } bool isAdditiveOp() const { return isAdditiveOp(getOpcode()); } diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 5feef1c803..cf3eea959e 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -559,6 +559,14 @@ CallExpr::CallExpr(ASTContext &C, StmtClass SC, EmptyShell Empty) Decl *CallExpr::getCalleeDecl() { Expr *CEE = getCallee()->IgnoreParenCasts(); + // If we're calling a dereference, look at the pointer instead. + if (BinaryOperator *BO = dyn_cast<BinaryOperator>(CEE)) { + if (BO->isPtrMemOp()) + CEE = BO->getRHS()->IgnoreParenCasts(); + } else if (UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) { + if (UO->getOpcode() == UO_Deref) + CEE = UO->getSubExpr()->IgnoreParenCasts(); + } if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) return DRE->getDecl(); if (MemberExpr *ME = dyn_cast<MemberExpr>(CEE)) |