================
@@ -71,7 +71,8 @@ void DanglingPtrDeref::reportUseAfterScope(const MemRegion
*Region,
CheckerContext &C) const {
auto BR = std::make_unique<PathSensitiveBugReport>(
BugMsg,
- (llvm::Twine("Use of ") + lifetime_modeling::getRegionName(Region) +
+ (llvm::Twine("Use of ") +
+ Region->getDescriptiveName(/*UseQuotes=*/true, /*AllowFallback=*/true) +
" after its lifetime ended."),
N);
----------------
benedekaibas wrote:
I put my focus on the LCV implementation yesterady, but quickly I came back to
this. I agree with your question that the fallback mechanism can be
non-deterministic, especially compared to what we have now. If I want to use
`getDescriptiveName` directly with its own fallback mechanism then I still need
to "guard" it like:
```cpp
PathDiagnosticPieceRef
UseAfterLifetimeEndBRVisitor::getEndPath(const ExplodedNode *N,
BugReporterContext &BRC,
PathSensitiveBugReport &BR) {
std::string Message = SourceRegion->getDescriptiveName(
/*UseQuotes=*/true, /*AllowFallback=*/false);
if (Message.empty())
Message = "the region";
auto Piece = createSourcePiece(
N, BRC, (llvm::Twine("Lifetime of ") + Message + " ended here").str());
return Piece;
}
```
But this would also need a helper function basically very similar to
`getRegionName`. At this point I think it is better to keep `getRegionName`
since we do not really earn much with the change this PR would introduce.
https://github.com/llvm/llvm-project/pull/214245
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits