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

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 28 14:13:45 PST 2022


steakhal added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp:48
+          dyn_cast_or_null<CallExpr>(C.getStackFrame()->getCallSite());
+      CE && CE->getBuiltinCallee() != 0)
+    return;
----------------
NoQ wrote:
> 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.
We were actually considering it. We decided against it to keep the impact of this fix minimal.

That being said, I wonder if a similar check should be at some higher level API, lets say inside the emitReport.
That way no chevker would experience such crashes. WDYT?


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