[PATCH] D138713: Fix assertion failure "PathDiagnosticSpotPiece's must have a valid location." in ReturnPtrRange checker on builtin functions

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 28 13:14:37 PST 2022


NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!

This patch seems obvious but please upload with context next time (https://llvm.org/docs/Phabricator.html#phabricator-request-review-web).



================
Comment at: clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp:48
+          dyn_cast_or_null<CallExpr>(C.getStackFrame()->getCallSite());
+      CE && CE->getBuiltinCallee() != 0)
+    return;
----------------
I suspect that you might run into more similar problems with functions coming from "body farms". A direct check like
```lang=c++
RetE->getBeginLoc().isValid()
```
might be more reliable.

You might need to check the entire range though. We probably need a unified solution for such checks, because many checkers end up implementing them.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138713/new/

https://reviews.llvm.org/D138713



More information about the cfe-commits mailing list