]> granicus.if.org Git - clang/commitdiff
[analyzer]Fixup r156134: Handle the case when FunctionDecl isn't avail.
authorAnna Zaks <ganna@apple.com>
Fri, 4 May 2012 17:37:16 +0000 (17:37 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 4 May 2012 17:37:16 +0000 (17:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156183 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ObjCMessage.cpp
test/Analysis/malloc.c

index 0c6d8a8b63dc95eb0ca1c0854a9bc11a295e48de..994e6fbe622c589c654aaac72bdef1abc65e7671 100644 (file)
@@ -139,7 +139,7 @@ bool CallOrObjCMessage::hasNonZeroCallbackArg() const {
     FD = Ctor->getConstructor();
 
   const CallExpr * CE = CallE.get<const CallExpr *>();
-  FD = dyn_cast<FunctionDecl>(CE->getCalleeDecl());
+  FD = dyn_cast_or_null<FunctionDecl>(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.
index a7d5b0b0e941cb679d243633532ae8c90cb4782a..3257d3d95a519928b540373967d4c4a6ac67fad6 100644 (file)
@@ -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.