diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-08-24 19:35:19 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-08-24 19:35:19 +0000 |
commit | b75e2602e246b44bb285be8cc31166302d77998f (patch) | |
tree | 3874104d9b0d49062247c4b8c0f2b5d66580ec7a /lib/StaticAnalyzer/Core/PathDiagnostic.cpp | |
parent | 81e6cfddcbb32eb9bbbee5c3f5156fc19ca7e774 (diff) |
Rework how PathDiagnosticConsumers pass knowledge of what files they
generated for a given diagnostic to another. Because PathDiagnostics
are specific to a give PathDiagnosticConsumer, store in
a FoldingSet a unique hash for a PathDiagnostic (that will be the same
for the same bug for different PathDiagnosticConsumers) that
stores a list of files generated. This can then be read by the
other PathDiagnosticConsumers.
This fixes breakage in the PLIST-HTML output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162580 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/PathDiagnostic.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index c849778e7f..97ef906cac 100644 --- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -271,6 +271,46 @@ void PathDiagnosticConsumer::FlushDiagnostics( } } +static void ProfileDiagnostic(const PathDiagnostic &PD, + llvm::FoldingSetNodeID &NodeID) { + NodeID.AddString(PD.getBugType()); + NodeID.AddString(PD.getDescription()); + NodeID.Add(PD.getLocation()); +} + +void PathDiagnosticConsumer::FilesMade::addDiagnostic(const PathDiagnostic &PD, + StringRef ConsumerName, + StringRef FileName) { + llvm::FoldingSetNodeID NodeID; + ProfileDiagnostic(PD, NodeID); + void *InsertPos; + PDFileEntry *Entry = FindNodeOrInsertPos(NodeID, InsertPos); + if (!Entry) { + Entry = Alloc.Allocate<PDFileEntry>(); + Entry = new (Entry) PDFileEntry(NodeID); + InsertNode(Entry, InsertPos); + } + + // Allocate persistent storage for the file name. + char *FileName_cstr = (char*) Alloc.Allocate(FileName.size(), 1); + memcpy(FileName_cstr, FileName.data(), FileName.size()); + + Entry->files.push_back(std::make_pair(ConsumerName, + StringRef(FileName_cstr, + FileName.size()))); +} + +PathDiagnosticConsumer::PDFileEntry::ConsumerFiles * +PathDiagnosticConsumer::FilesMade::getFiles(const PathDiagnostic &PD) { + llvm::FoldingSetNodeID NodeID; + ProfileDiagnostic(PD, NodeID); + void *InsertPos; + PDFileEntry *Entry = FindNodeOrInsertPos(NodeID, InsertPos); + if (!Entry) + return 0; + return &Entry->files; +} + //===----------------------------------------------------------------------===// // PathDiagnosticLocation methods. //===----------------------------------------------------------------------===// |