diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-17 07:29:51 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-17 07:29:51 +0000 |
commit | a00425414e8c209cabc25d1826b200aeb94259af (patch) | |
tree | 9f57b8d4eea42fdb6ddcfd0d9fa0f3e7d8538614 /lib/AST/Expr.cpp | |
parent | 6fc45052986633e0ba0cc375c9a9eba909888412 (diff) |
Refactor code into a new CallExpr::getDirectCallee() method. Simplify some
code with the new method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 63a6d3153c..320a4f1f72 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -224,6 +224,16 @@ void CallExpr::Destroy(ASTContext& C) { C.Deallocate(this); } +FunctionDecl *CallExpr::getDirectCallee() { + Expr *CEE = getCallee()->IgnoreParenCasts(); + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) { + // FIXME: We can follow objective-c methods and C++ member functions... + return dyn_cast<FunctionDecl>(DRE->getDecl()); + } + + return 0; +} + /// setNumArgs - This changes the number of arguments present in this call. /// Any orphaned expressions are deleted by this, and any new operands are set /// to null. |