Skip to content

Commit 63509fb

Browse files
committed
[analyzer]Fixup r156134: Handle the case when FunctionDecl isn't avail.
llvm-svn: 156183
1 parent df7aad4 commit 63509fb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ bool CallOrObjCMessage::hasNonZeroCallbackArg() const {
139139
FD = Ctor->getConstructor();
140140

141141
const CallExpr * CE = CallE.get<const CallExpr *>();
142-
FD = dyn_cast<FunctionDecl>(CE->getCalleeDecl());
142+
FD = dyn_cast_or_null<FunctionDecl>(CE->getCalleeDecl());
143143

144144
// If calling using a function pointer, assume the function does not
145145
// have a callback. TODO: We could check the types of the arguments here.

clang/test/Analysis/malloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,12 @@ void r11160612_6(StWithCallback St) {
829829
dealocateMemWhenDoneByRef(&St, x);
830830
}
831831

832+
int mySub(int, int);
833+
int myAdd(int, int);
834+
int fPtr(unsigned cond, int x) {
835+
return (cond ? mySub : myAdd)(x, x);
836+
}
837+
832838
// ----------------------------------------------------------------------------
833839
// Below are the known false positives.
834840

0 commit comments

Comments
 (0)