From: Anna Zaks Date: Fri, 4 May 2012 17:37:16 +0000 (+0000) Subject: [analyzer]Fixup r156134: Handle the case when FunctionDecl isn't avail. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84d43848e39eab9e3386cbfb3906ba2d6a382f24;p=clang [analyzer]Fixup r156134: Handle the case when FunctionDecl isn't avail. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156183 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/ObjCMessage.cpp b/lib/StaticAnalyzer/Core/ObjCMessage.cpp index 0c6d8a8b63..994e6fbe62 100644 --- a/lib/StaticAnalyzer/Core/ObjCMessage.cpp +++ b/lib/StaticAnalyzer/Core/ObjCMessage.cpp @@ -139,7 +139,7 @@ bool CallOrObjCMessage::hasNonZeroCallbackArg() const { FD = Ctor->getConstructor(); const CallExpr * CE = CallE.get(); - FD = dyn_cast(CE->getCalleeDecl()); + FD = dyn_cast_or_null(CE->getCalleeDecl()); // If calling using a function pointer, assume the function does not // have a callback. TODO: We could check the types of the arguments here. diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index a7d5b0b0e9..3257d3d95a 100644 --- a/test/Analysis/malloc.c +++ b/test/Analysis/malloc.c @@ -829,6 +829,12 @@ void r11160612_6(StWithCallback St) { dealocateMemWhenDoneByRef(&St, x); } +int mySub(int, int); +int myAdd(int, int); +int fPtr(unsigned cond, int x) { + return (cond ? mySub : myAdd)(x, x); +} + // ---------------------------------------------------------------------------- // Below are the known false positives.