================
@@ -51,10 +101,68 @@ void UseAfterLifetimeEnd::reportDanglingSource(const 
MemRegion *Source,
       (llvm::Twine("Returning value bound to ") +
        lifetime_modeling::getRegionName(Source) + " that will go out of 
scope"),
       N);
+
+  if (SourceRange Range = getRegionDeclRange(Source); Range.isValid())
+    BR->addRange(Range);
+
+  BR->addVisitor<UseAfterLifetimeEndBRVisitor>(RetVal, Source);
   bugreporter::trackStoredValue(RetVal, Source, *BR);
   C.emitReport(std::move(BR));
 }
 
+PathDiagnosticPieceRef UseAfterLifetimeEndBRVisitor::createSourcePiece(
+    const ExplodedNode *N, BugReporterContext &BRC, StringRef Message) const {
+  const Stmt *S = N->getStmtForDiagnostics();
+  if (!S)
+    return nullptr;
+
+  const Expr *RetExpr = dyn_cast_or_null<Expr>(S);
+  const Expr *Arg = getLifetimeBoundArg(RetExpr);
----------------
benedekaibas wrote:

I have the test for that case as well. Currently the issue is that for multiple 
annotations the range of highlighting is only for the first argument. I want to 
correct it and push it to this PR before getting merged tomorrow. 

https://github.com/llvm/llvm-project/pull/207052
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to