================
@@ -46,33 +47,31 @@ void ReportDanglingPtrDeref::checkLocation(SVal Loc, bool
IsLoad, const Stmt *S,
if (const MemRegion *LocRegion = Loc.getAsRegion()) {
if (lifetime_modeling::isDeallocated(State, LocRegion)) {
- if (ExplodedNode *N =
- C.generateNonFatalErrorNode(C.getState(), C.getPredecessor()))
- reportUseAfterScope(LocRegion, N, C);
+ if (ExplodedNode *N = C.generateNonFatalErrorNode(State))
+ reportUseAfterScope(LocRegion, Loc, N, C);
}
}
}
void ReportDanglingPtrDeref::reportUseAfterScope(const MemRegion *Region,
- ExplodedNode *N,
+ SVal Val, ExplodedNode *N,
CheckerContext &C) const {
auto BR = std::make_unique<PathSensitiveBugReport>(
BugMsg,
(llvm::Twine("Use of '") + Region->getString() +
- "' after its lifetime ended.")
- .str(),
+ "' after its lifetime ended."),
N);
+ BR->addVisitor(
+ std::make_unique<ReportDanglingPtrDerefBRVisitor>(Val, Region));
----------------
steakhal wrote:
The templated overload does this mk unique for you.
```
BR->addVisitor<ReportDanglingPtrDerefBRVisitor>(Val, Region);
```
https://github.com/llvm/llvm-project/pull/206460
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits