diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-09-07 00:42:53 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-09-07 00:42:53 +0000 |
commit | 5f8d361c9cb718a1001d52442bdf88cd046b6174 (patch) | |
tree | 2cacfadd9ab0e6173abb98708298e5dcae6bbd89 /clang/lib/StaticAnalyzer/Core | |
parent | 98bee0229749b9164c70579c34f6258f4fcb639b (diff) | |
download | bcm5719-llvm-5f8d361c9cb718a1001d52442bdf88cd046b6174.tar.gz bcm5719-llvm-5f8d361c9cb718a1001d52442bdf88cd046b6174.zip |
[analyzer] Push updating-the-executed-lines logic into the BugReporter.
So it can be reused across different consumers.
Differential Revision: https://reviews.llvm.org/D51514
llvm-svn: 341617
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 16 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp | 17 |
2 files changed, 17 insertions, 16 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 5a518ef12db..19e9b4af900 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1881,6 +1881,21 @@ static void dropFunctionEntryEdge(PathPieces &Path, LocationContextMap &LCM, using VisitorsDiagnosticsTy = llvm::DenseMap<const ExplodedNode *, std::vector<std::shared_ptr<PathDiagnosticPiece>>>; +/// Populate executes lines with lines containing at least one diagnostics. +static void updateExecutedLinesWithDiagnosticPieces( + PathDiagnostic &PD) { + + PathPieces path = PD.path.flatten(/*ShouldFlattenMacros=*/true); + FilesToLineNumsMap &ExecutedLines = PD.getExecutedLines(); + + for (const auto &P : path) { + FullSourceLoc Loc = P->getLocation().asLocation().getExpansionLoc(); + FileID FID = Loc.getFileID(); + unsigned LineNo = Loc.getLineNumber(); + ExecutedLines[FID.getHashValue()].insert(LineNo); + } +} + /// This function is responsible for generating diagnostic pieces that are /// *not* provided by bug report visitors. /// These diagnostics may differ depending on the consumer's settings, @@ -2985,6 +3000,7 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) { for (const auto &i : Meta) PD->addMeta(i); + updateExecutedLinesWithDiagnosticPieces(*PD); Consumer->HandlePathDiagnostic(std::move(PD)); } } diff --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index b733e70daff..77ea2a00ef6 100644 --- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -337,23 +337,8 @@ static void serializeExecutedLines( const PathDiagnostic &D, const PathPieces &path, llvm::raw_string_ostream &os) { - // Copy executed lines from path diagnostics. - std::map<unsigned, std::set<unsigned>> ExecutedLines; - for (auto I = D.executedLines_begin(), - E = D.executedLines_end(); I != E; ++I) { - std::set<unsigned> &LinesInFile = ExecutedLines[I->first]; - for (unsigned LineNo : I->second) { - LinesInFile.insert(LineNo); - } - } - // We need to include all lines for which any kind of diagnostics appears. - for (const auto &P : path) { - FullSourceLoc Loc = P->getLocation().asLocation().getExpansionLoc(); - FileID FID = Loc.getFileID(); - unsigned LineNo = Loc.getLineNumber(); - ExecutedLines[FID.getHashValue()].insert(LineNo); - } + const FilesToLineNumsMap &ExecutedLines = D.getExecutedLines(); os << "var relevant_lines = {"; for (auto I = ExecutedLines.begin(), |