This isn't the case when the callee is completely unknown,
eg. when it is a symbolic function pointer.
static Optional<FunctionData> create(const CallEvent &Call,
const CheckerContext &C) {
- assert(Call.getDecl());
+ if (!Call.getDecl())
+ return None;
+
const FunctionDecl *FDecl = Call.getDecl()->getAsFunction();
if (!FDecl || (FDecl->getKind() != Decl::Function &&
FDecl->getKind() != Decl::CXXMethod))
mySink(1, 2, x);
// expected-warning@-1 {{Untrusted data is passed to a user-defined sink}}
}
+
+void testUnknownFunction(void (*foo)(void)) {
+ foo(); // no-crash
+}