r369451 - [analyzer] NFC: Remove the BugTypes set from BugReporter.
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 20 14:41:20 PDT 2019
Author: dergachev
Date: Tue Aug 20 14:41:20 2019
New Revision: 369451
URL: http://llvm.org/viewvc/llvm-project?rev=369451&view=rev
Log:
[analyzer] NFC: Remove the BugTypes set from BugReporter.
Its only purpose was to avoid a bug that's caused by
making a virtual call in BugReporter's destructor.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.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=369451&r1=369450&r2=369451&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Tue Aug 20 14:41:20 2019
@@ -408,11 +408,6 @@ public:
enum Kind { BasicBRKind, PathSensitiveBRKind };
private:
- using BugTypesTy = llvm::ImmutableSet<BugType *>;
-
- BugTypesTy::Factory F;
- BugTypesTy BugTypes;
-
const Kind kind;
BugReporterData& D;
@@ -433,11 +428,10 @@ private:
protected:
BugReporter(BugReporterData& d, Kind k)
- : BugTypes(F.getEmptySet()), kind(k), D(d) {}
+ : kind(k), D(d) {}
public:
- BugReporter(BugReporterData& d)
- : BugTypes(F.getEmptySet()), kind(BasicBRKind), D(d) {}
+ BugReporter(BugReporterData &d) : kind(BasicBRKind), D(d) {}
virtual ~BugReporter();
/// Generate and flush diagnostics for all bug reports.
@@ -453,11 +447,6 @@ public:
return D.getPathDiagnosticConsumers();
}
- /// Iterator over the set of BugTypes tracked by the BugReporter.
- using iterator = BugTypesTy::iterator;
- iterator begin() { return BugTypes.begin(); }
- iterator end() { return BugTypes.end(); }
-
/// Iterator over the set of BugReports tracked by the BugReporter.
using EQClasses_iterator = llvm::FoldingSet<BugReportEquivClass>::iterator;
EQClasses_iterator EQClasses_begin() { return EQClasses.begin(); }
@@ -475,8 +464,6 @@ public:
return {};
}
- void Register(const BugType *BT);
-
/// Add the given report to the set of reports tracked by BugReporter.
///
/// The reports are usually generated by the checkers. Further, they are
@@ -511,8 +498,6 @@ public:
PathSensitiveBugReporter(BugReporterData& d, ExprEngine& eng)
: BugReporter(d, PathSensitiveBRKind), Eng(eng) {}
- ~PathSensitiveBugReporter() override = default;
-
/// getGraph - Get the exploded graph created by the analysis engine
/// for the analyzed method or function.
const ExplodedGraph &getGraph() const;
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=369451&r1=369450&r2=369451&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Tue Aug 20 14:41:20 2019
@@ -2227,7 +2227,9 @@ ProgramStateManager &PathSensitiveBugRep
}
BugReporter::~BugReporter() {
- FlushReports();
+ // Make sure reports are flushed.
+ assert(StrBugTypes.empty() &&
+ "Destroying BugReporter before diagnostics are emitted!");
// Free the bug reports we are tracking.
for (const auto I : EQClassesVector)
@@ -2235,9 +2237,6 @@ BugReporter::~BugReporter() {
}
void BugReporter::FlushReports() {
- if (BugTypes.isEmpty())
- return;
-
// We need to flush reports in deterministic order to ensure the order
// of the reports is consistent between runs.
for (const auto EQ : EQClassesVector)
@@ -2248,9 +2247,6 @@ void BugReporter::FlushReports() {
// FIXME: There are leaks from checkers that assume that the BugTypes they
// create will be destroyed by the BugReporter.
llvm::DeleteContainerSeconds(StrBugTypes);
-
- // Remove all references to the BugType objects.
- BugTypes = F.getEmptySet();
}
//===----------------------------------------------------------------------===//
@@ -2668,10 +2664,6 @@ PathSensitiveBugReporter::generatePathDi
return Out;
}
-void BugReporter::Register(const BugType *BT) {
- BugTypes = F.add(BugTypes, BT);
-}
-
void BugReporter::emitReport(std::unique_ptr<BugReport> R) {
if (const ExplodedNode *E = R->getErrorNode()) {
// An error node must either be a sink or have a tag, otherwise
@@ -2702,8 +2694,6 @@ void BugReporter::emitReport(std::unique
R->Profile(ID);
// Lookup the equivance class. If there isn't one, create it.
- const BugType& BT = R->getBugType();
- Register(&BT);
void *InsertPos;
BugReportEquivClass* EQ = EQClasses.FindNodeOrInsertPos(ID, InsertPos);
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=369451&r1=369450&r2=369451&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Tue Aug 20 14:41:20 2019
@@ -609,6 +609,7 @@ void AnalysisConsumer::runAnalysisOnTran
// After all decls handled, run checkers on the entire TranslationUnit.
checkerMgr->runCheckersOnEndOfTranslationUnit(TU, *Mgr, BR);
+ BR.FlushReports();
RecVisitorBR = nullptr;
}
@@ -766,6 +767,9 @@ void AnalysisConsumer::HandleCode(Decl *
if (SyntaxCheckTimer)
SyntaxCheckTimer->stopTimer();
}
+
+ BR.FlushReports();
+
if ((Mode & AM_Path) && checkerMgr->hasPathSensitiveCheckers()) {
RunPathSensitiveChecks(D, IMode, VisitedCallees);
if (IMode != ExprEngine::Inline_Minimal)
More information about the cfe-commits
mailing list