summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2009-12-20 23:11:08 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2009-12-20 23:11:08 +0000
commit518e37071916d433aea03a8bd33087fd68abd7e5 (patch)
tree93637d1fa20056dbf64bb6718878b5bd2b84ddb1 /clang/lib/AST/Expr.cpp
parent1576850a7636fd7b4b77ea31762b58fb140ac969 (diff)
downloadbcm5719-llvm-518e37071916d433aea03a8bd33087fd68abd7e5.tar.gz
bcm5719-llvm-518e37071916d433aea03a8bd33087fd68abd7e5.zip
fix PR4010: add support for the warn_unused_result for function pointers
llvm-svn: 91803
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 034b91ed0f5..466ddc663f2 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -398,14 +398,18 @@ void CallExpr::DoDestroy(ASTContext& C) {
C.Deallocate(this);
}
-FunctionDecl *CallExpr::getDirectCallee() {
+Decl *CallExpr::getCalleeDecl() {
Expr *CEE = getCallee()->IgnoreParenCasts();
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
- return dyn_cast<FunctionDecl>(DRE->getDecl());
+ return DRE->getDecl();
return 0;
}
+FunctionDecl *CallExpr::getDirectCallee() {
+ return dyn_cast_or_null<FunctionDecl>(getCalleeDecl());
+}
+
/// 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.
@@ -858,7 +862,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
case CXXMemberCallExprClass: {
// If this is a direct call, get the callee.
const CallExpr *CE = cast<CallExpr>(this);
- if (const FunctionDecl *FD = CE->getDirectCallee()) {
+ if (const Decl *FD = CE->getCalleeDecl()) {
// If the callee has attribute pure, const, or warn_unused_result, warn
// about it. void foo() { strlen("bar"); } should warn.
//
OpenPOWER on IntegriCloud