/// If returns NULL the default implementation will be used.
/// Also note that at most one visitor of a BugReport should generate a
/// non-NULL end of path diagnostic piece.
- virtual PathDiagnosticPiece *getEndPath(BugReporterContext &BRC,
- const ExplodedNode *N,
- BugReport &BR);
+ virtual std::unique_ptr<PathDiagnosticPiece>
+ getEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR);
virtual void Profile(llvm::FoldingSetNodeID &ID) const = 0;
/// \brief Generates the default final diagnostic piece.
- static PathDiagnosticPiece *getDefaultEndPath(BugReporterContext &BRC,
- const ExplodedNode *N,
- BugReport &BR);
-
+ static std::unique_ptr<PathDiagnosticPiece>
+ getDefaultEndPath(BugReporterContext &BRC, const ExplodedNode *N,
+ BugReport &BR);
};
/// This class provides a convenience implementation for clone() using the
return nullptr;
}
- PathDiagnosticPiece *getEndPath(BugReporterContext &BRC,
- const ExplodedNode *N,
- BugReport &BR) override;
+ std::unique_ptr<PathDiagnosticPiece> getEndPath(BugReporterContext &BRC,
+ const ExplodedNode *N,
+ BugReport &BR) override;
};
/// \brief When a region containing undefined value or '0' value is passed
BugReporterContext &BRC,
BugReport &BR) override;
- PathDiagnosticPiece* getEndPath(BugReporterContext &BRC,
- const ExplodedNode *EndPathNode,
- BugReport &BR) override {
+ std::unique_ptr<PathDiagnosticPiece>
+ getEndPath(BugReporterContext &BRC, const ExplodedNode *EndPathNode,
+ BugReport &BR) override {
if (!IsLeak)
return nullptr;
PathDiagnosticLocation::createEndOfPath(EndPathNode,
BRC.getSourceManager());
// Do not add the statement itself as a range in case of leak.
- return new PathDiagnosticEventPiece(L, BR.getDescription(), false);
+ return llvm::make_unique<PathDiagnosticEventPiece>(L, BR.getDescription(),
+ false);
}
private:
BugReporterContext &BRC,
BugReport &BR) override;
- PathDiagnosticPiece *getEndPath(BugReporterContext &BRC,
- const ExplodedNode *N,
- BugReport &BR) override;
+ std::unique_ptr<PathDiagnosticPiece> getEndPath(BugReporterContext &BRC,
+ const ExplodedNode *N,
+ BugReport &BR) override;
};
class CFRefLeakReportVisitor : public CFRefReportVisitor {
const SummaryLogTy &log)
: CFRefReportVisitor(sym, GCEnabled, log) {}
- PathDiagnosticPiece *getEndPath(BugReporterContext &BRC,
- const ExplodedNode *N,
- BugReport &BR) override;
+ std::unique_ptr<PathDiagnosticPiece> getEndPath(BugReporterContext &BRC,
+ const ExplodedNode *N,
+ BugReport &BR) override;
BugReporterVisitor *clone() const override {
// The curiously-recurring template pattern only works for one level of
InterestingMethodContext);
}
-PathDiagnosticPiece*
+std::unique_ptr<PathDiagnosticPiece>
CFRefReportVisitor::getEndPath(BugReporterContext &BRC,
- const ExplodedNode *EndN,
- BugReport &BR) {
+ const ExplodedNode *EndN, BugReport &BR) {
BR.markInteresting(Sym);
return BugReporterVisitor::getDefaultEndPath(BRC, EndN, BR);
}
-PathDiagnosticPiece*
+std::unique_ptr<PathDiagnosticPiece>
CFRefLeakReportVisitor::getEndPath(BugReporterContext &BRC,
- const ExplodedNode *EndN,
- BugReport &BR) {
+ const ExplodedNode *EndN, BugReport &BR) {
// Tell the BugReporterContext to report cases when the tracked symbol is
// assigned to different variables, etc.
os << " is not referenced later in this execution path and has a retain "
"count of +" << RV->getCount();
- return new PathDiagnosticEventPiece(L, os.str());
+ return llvm::make_unique<PathDiagnosticEventPiece>(L, os.str());
}
CFRefLeakReport::CFRefLeakReport(CFRefBug &D, const LangOptions &LOpts,
std::unique_ptr<PathDiagnosticPiece> LastPiece;
for (BugReport::visitor_iterator I = visitors.begin(), E = visitors.end();
I != E; ++I) {
- if (PathDiagnosticPiece *Piece = (*I)->getEndPath(PDB, N, *R)) {
+ if (std::unique_ptr<PathDiagnosticPiece> Piece =
+ (*I)->getEndPath(PDB, N, *R)) {
assert (!LastPiece &&
"There can only be one final piece in a diagnostic.");
- LastPiece.reset(Piece);
+ LastPiece = std::move(Piece);
}
}
if (ActiveScheme != PathDiagnosticConsumer::None) {
if (!LastPiece)
- LastPiece.reset(BugReporterVisitor::getDefaultEndPath(PDB, N, *R));
+ LastPiece = BugReporterVisitor::getDefaultEndPath(PDB, N, *R);
assert(LastPiece);
PD.setEndOfPath(LastPiece.release());
}
// Definitions for bug reporter visitors.
//===----------------------------------------------------------------------===//
-PathDiagnosticPiece*
+std::unique_ptr<PathDiagnosticPiece>
BugReporterVisitor::getEndPath(BugReporterContext &BRC,
- const ExplodedNode *EndPathNode,
- BugReport &BR) {
+ const ExplodedNode *EndPathNode, BugReport &BR) {
return nullptr;
}
-PathDiagnosticPiece*
-BugReporterVisitor::getDefaultEndPath(BugReporterContext &BRC,
- const ExplodedNode *EndPathNode,
- BugReport &BR) {
+std::unique_ptr<PathDiagnosticPiece> BugReporterVisitor::getDefaultEndPath(
+ BugReporterContext &BRC, const ExplodedNode *EndPathNode, BugReport &BR) {
PathDiagnosticLocation L =
PathDiagnosticLocation::createEndOfPath(EndPathNode,BRC.getSourceManager());
// Only add the statement itself as a range if we didn't specify any
// special ranges for this report.
- PathDiagnosticPiece *P = new PathDiagnosticEventPiece(L,
- BR.getDescription(),
- Beg == End);
+ auto P = llvm::make_unique<PathDiagnosticEventPiece>(L, BR.getDescription(),
+ Beg == End);
for (; Beg != End; ++Beg)
P->addRange(*Beg);
- return P;
+ return std::move(P);
}
llvm_unreachable("Invalid visit mode!");
}
- PathDiagnosticPiece *getEndPath(BugReporterContext &BRC,
- const ExplodedNode *N,
- BugReport &BR) override {
+ std::unique_ptr<PathDiagnosticPiece> getEndPath(BugReporterContext &BRC,
+ const ExplodedNode *N,
+ BugReport &BR) override {
if (EnableNullFPSuppression)
BR.markInvalid(ReturnVisitor::getTag(), StackFrame);
return nullptr;
return ND->isStdNamespace();
}
-
-PathDiagnosticPiece *
+std::unique_ptr<PathDiagnosticPiece>
LikelyFalsePositiveSuppressionBRVisitor::getEndPath(BugReporterContext &BRC,
const ExplodedNode *N,
BugReport &BR) {