r371451 - [analyzer] NFC: Simplify bug report equivalence classes to not be ilists.
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 9 13:34:45 PDT 2019
Author: dergachev
Date: Mon Sep 9 13:34:44 2019
New Revision: 371451
URL: http://llvm.org/viewvc/llvm-project?rev=371451&view=rev
Log:
[analyzer] NFC: Simplify bug report equivalence classes to not be ilists.
Use a vector of unique pointers instead.
Differential Revision: https://reviews.llvm.org/D67024
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=371451&r1=371450&r2=371451&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Mon Sep 9 13:34:44 2019
@@ -72,7 +72,7 @@ using DiagnosticForConsumerMapTy =
/// This class provides an interface through which checkers can create
/// individual bug reports.
-class BugReport : public llvm::ilist_node<BugReport> {
+class BugReport {
public:
enum class Kind { Basic, PathSensitive };
@@ -465,28 +465,21 @@ class BugReportEquivClass : public llvm:
friend class BugReporter;
/// List of *owned* BugReport objects.
- llvm::ilist<BugReport> Reports;
+ llvm::SmallVector<std::unique_ptr<BugReport>, 4> Reports;
- void AddReport(std::unique_ptr<BugReport> R) {
- Reports.push_back(R.release());
+ void AddReport(std::unique_ptr<BugReport> &&R) {
+ Reports.push_back(std::move(R));
}
public:
BugReportEquivClass(std::unique_ptr<BugReport> R) { AddReport(std::move(R)); }
+ ArrayRef<std::unique_ptr<BugReport>> getReports() const { return Reports; }
+
void Profile(llvm::FoldingSetNodeID& ID) const {
assert(!Reports.empty());
- Reports.front().Profile(ID);
+ Reports.front()->Profile(ID);
}
-
- using iterator = llvm::ilist<BugReport>::iterator;
- using const_iterator = llvm::ilist<BugReport>::const_iterator;
-
- iterator begin() { return Reports.begin(); }
- iterator end() { return Reports.end(); }
-
- const_iterator begin() const { return Reports.begin(); }
- const_iterator end() const { return Reports.end(); }
};
//===----------------------------------------------------------------------===//
@@ -573,7 +566,7 @@ private:
virtual BugReport *
findReportInEquivalenceClass(BugReportEquivClass &eqClass,
SmallVectorImpl<BugReport *> &bugReports) {
- return &*eqClass.begin();
+ return eqClass.getReports()[0].get();
}
protected:
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=371451&r1=371450&r2=371451&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Mon Sep 9 13:34:44 2019
@@ -2798,17 +2798,15 @@ struct FRIEC_WLItem {
BugReport *PathSensitiveBugReporter::findReportInEquivalenceClass(
BugReportEquivClass &EQ, SmallVectorImpl<BugReport *> &bugReports) {
- BugReportEquivClass::iterator I = EQ.begin(), E = EQ.end();
- assert(I != E);
- const BugType& BT = I->getBugType();
-
// If we don't need to suppress any of the nodes because they are
// post-dominated by a sink, simply add all the nodes in the equivalence class
// to 'Nodes'. Any of the reports will serve as a "representative" report.
+ assert(EQ.getReports().size() > 0);
+ const BugType& BT = EQ.getReports()[0]->getBugType();
if (!BT.isSuppressOnSink()) {
- BugReport *R = &*I;
- for (auto &I : EQ) {
- if (auto *PR = dyn_cast<PathSensitiveBugReport>(&I)) {
+ BugReport *R = EQ.getReports()[0].get();
+ for (auto &J : EQ.getReports()) {
+ if (auto *PR = dyn_cast<PathSensitiveBugReport>(J.get())) {
R = PR;
bugReports.push_back(PR);
}
@@ -2824,8 +2822,8 @@ BugReport *PathSensitiveBugReporter::fin
// stack for very long paths.
BugReport *exampleReport = nullptr;
- for (; I != E; ++I) {
- auto *R = dyn_cast<PathSensitiveBugReport>(&*I);
+ for (const auto &I: EQ.getReports()) {
+ auto *R = dyn_cast<PathSensitiveBugReport>(I.get());
if (!R)
continue;
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=371451&r1=371450&r2=371451&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Sep 9 13:34:44 2019
@@ -3004,8 +3004,8 @@ struct DOTGraphTraits<ExplodedGraph*> :
llvm::make_range(BR.EQClasses_begin(), BR.EQClasses_end());
for (const auto &EQ : EQClasses) {
- for (const BugReport &R : EQ) {
- const auto *PR = dyn_cast<PathSensitiveBugReport>(&R);
+ for (const auto &I : EQ.getReports()) {
+ const auto *PR = dyn_cast<PathSensitiveBugReport>(I.get());
if (!PR)
continue;
const ExplodedNode *EN = PR->getErrorNode();
@@ -3135,7 +3135,8 @@ std::string ExprEngine::DumpGraph(bool t
// Iterate through the reports and get their nodes.
for (BugReporter::EQClasses_iterator
EI = BR.EQClasses_begin(), EE = BR.EQClasses_end(); EI != EE; ++EI) {
- const auto *R = dyn_cast<PathSensitiveBugReport>(&*EI->begin());
+ const auto *R =
+ dyn_cast<PathSensitiveBugReport>(EI->getReports()[0].get());
if (!R)
continue;
const auto *N = const_cast<ExplodedNode *>(R->getErrorNode());
More information about the cfe-commits
mailing list