[PATCH] D49656: [analyzer] Add support for more pointer invalidating functions in InnerPointerChecker

Reka Kovacs via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 23 17:30:03 PDT 2018


rnkovacs added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp:213
+  if (const auto *FC = dyn_cast<AnyFunctionCall>(&Call)) {
+    const FunctionDecl *FD = FC->getDecl();
+    for (unsigned I = 0, E = FD->getNumParams(); I != E; ++I) {
----------------
xazax.hun wrote:
> I am not sure if we always have a `Decl` here, I am afraid this might return null sometimes. Please add a test case with a function pointer (received as an argument in a top level function).
Um, yes, I'd already seen a crash here on a project before I saw your comment. Thanks!


================
Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2934
+            } else if (const auto *CallE = dyn_cast<CallExpr>(S)) {
+              OS << CallE->getDirectCallee()->getNameAsString();
             }
----------------
xazax.hun wrote:
> I think `getDirectCallee` might fail and return `nullptr`. One more reason to test function pointers :)
You're right. Also, it needed a bit more effort to dig up the function pointer's name. Or should I go further and somehow find out the name of the function it points to?


https://reviews.llvm.org/D49656





More information about the cfe-commits mailing list