aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/StaticAnalyzer/Core/PathDiagnostic.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/PathDiagnostic.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
index b971fff642d4..c4900313cad4 100644
--- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -432,11 +432,15 @@ void PathDiagnosticConsumer::FlushDiagnostics(
// Sort the diagnostics so that they are always emitted in a deterministic
// order.
- if (!BatchDiags.empty())
- std::sort(BatchDiags.begin(), BatchDiags.end(),
- [](const PathDiagnostic *X, const PathDiagnostic *Y) {
- return X != Y && compare(*X, *Y);
- });
+ int (*Comp)(const PathDiagnostic *const *, const PathDiagnostic *const *) =
+ [](const PathDiagnostic *const *X, const PathDiagnostic *const *Y) {
+ assert(*X != *Y && "PathDiagnostics not uniqued!");
+ if (compare(**X, **Y))
+ return -1;
+ assert(compare(**Y, **X) && "Not a total order!");
+ return 1;
+ };
+ array_pod_sort(BatchDiags.begin(), BatchDiags.end(), Comp);
FlushDiagnosticsImpl(BatchDiags, Files);
@@ -452,7 +456,7 @@ void PathDiagnosticConsumer::FlushDiagnostics(
}
PathDiagnosticConsumer::FilesMade::~FilesMade() {
- for (PDFileEntry &Entry : *this)
+ for (PDFileEntry &Entry : Set)
Entry.~PDFileEntry();
}
@@ -462,11 +466,11 @@ void PathDiagnosticConsumer::FilesMade::addDiagnostic(const PathDiagnostic &PD,
llvm::FoldingSetNodeID NodeID;
NodeID.Add(PD);
void *InsertPos;
- PDFileEntry *Entry = FindNodeOrInsertPos(NodeID, InsertPos);
+ PDFileEntry *Entry = Set.FindNodeOrInsertPos(NodeID, InsertPos);
if (!Entry) {
Entry = Alloc.Allocate<PDFileEntry>();
Entry = new (Entry) PDFileEntry(NodeID);
- InsertNode(Entry, InsertPos);
+ Set.InsertNode(Entry, InsertPos);
}
// Allocate persistent storage for the file name.
@@ -483,7 +487,7 @@ PathDiagnosticConsumer::FilesMade::getFiles(const PathDiagnostic &PD) {
llvm::FoldingSetNodeID NodeID;
NodeID.Add(PD);
void *InsertPos;
- PDFileEntry *Entry = FindNodeOrInsertPos(NodeID, InsertPos);
+ PDFileEntry *Entry = Set.FindNodeOrInsertPos(NodeID, InsertPos);
if (!Entry)
return nullptr;
return &Entry->files;