Check if a BugReporterVisitor has already been added to a BugReporterContext.
This avoids redundant diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99063 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Checker/BugReporter.cpp b/lib/Checker/BugReporter.cpp
index 0cf593b..f26d161 100644
--- a/lib/Checker/BugReporter.cpp
+++ b/lib/Checker/BugReporter.cpp
@@ -36,6 +36,21 @@
if ((*I)->isOwnedByReporterContext()) delete *I;
}
+void BugReporterContext::addVisitor(BugReporterVisitor* visitor) {
+ if (!visitor)
+ return;
+
+ llvm::FoldingSetNodeID ID;
+ visitor->Profile(ID);
+ void *InsertPos;
+
+ if (CallbacksSet.FindNodeOrInsertPos(ID, InsertPos))
+ return;
+
+ CallbacksSet.InsertNode(visitor, InsertPos);
+ Callbacks = F.Add(visitor, Callbacks);
+}
+
//===----------------------------------------------------------------------===//
// Helper routines for walking the ExplodedGraph and fetching statements.
//===----------------------------------------------------------------------===//