diff options
| author | George Karpenkov <ekarpenkov@apple.com> | 2018-09-07 00:44:17 +0000 |
|---|---|---|
| committer | George Karpenkov <ekarpenkov@apple.com> | 2018-09-07 00:44:17 +0000 |
| commit | bb313b797dbdda4d2a18ed409bafe9dd559789c3 (patch) | |
| tree | bbb4e7b52ba8680a313a7846f8273830c014275e /clang/lib | |
| parent | 784c60ac81b6866b2fe0a79a6dc9ac934fc3fa3e (diff) | |
| download | bcm5719-llvm-bb313b797dbdda4d2a18ed409bafe9dd559789c3.tar.gz bcm5719-llvm-bb313b797dbdda4d2a18ed409bafe9dd559789c3.zip | |
[analyzer] Add coverage information to plist output, update tests
Split tests which were still using FileCheck to compare plists.
Differential Revision: https://reviews.llvm.org/D51515
llvm-svn: 341621
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp index 6be8c6ac680..b45dfcfb360 100644 --- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -328,6 +328,39 @@ static void ReportPiece(raw_ostream &o, } } +/// Print coverage information to output stream {@code o}. +/// May modify the used list of files {@code Fids} by inserting new ones. +static void printCoverage(const PathDiagnostic *D, + unsigned InputIndentLevel, + SmallVectorImpl<FileID> &Fids, + FIDMap &FM, + llvm::raw_fd_ostream &o) { + unsigned IndentLevel = InputIndentLevel; + + Indent(o, IndentLevel) << "<key>ExecutedLines</key>\n"; + Indent(o, IndentLevel) << "<dict>\n"; + IndentLevel++; + + // Mapping from file IDs to executed lines. + const FilesToLineNumsMap &ExecutedLines = D->getExecutedLines(); + for (auto I = ExecutedLines.begin(), E = ExecutedLines.end(); I != E; ++I) { + unsigned FileKey = AddFID(FM, Fids, I->first); + Indent(o, IndentLevel) << "<key>" << FileKey << "</key>\n"; + Indent(o, IndentLevel) << "<array>\n"; + IndentLevel++; + for (unsigned LineNo : I->second) { + Indent(o, IndentLevel); + EmitInteger(o, LineNo) << "\n"; + } + IndentLevel--; + Indent(o, IndentLevel) << "</array>\n"; + } + IndentLevel--; + Indent(o, IndentLevel) << "</dict>\n"; + + assert(IndentLevel == InputIndentLevel); +} + void PlistDiagnostics::FlushDiagnosticsImpl( std::vector<const PathDiagnostic *> &Diags, FilesMade *filesMade) { @@ -395,14 +428,7 @@ void PlistDiagnostics::FlushDiagnosticsImpl( o << "<dict>\n" << " <key>clang_version</key>\n"; EmitString(o, getClangFullVersion()) << '\n'; - o << " <key>files</key>\n" - " <array>\n"; - - for (FileID FID : Fids) - EmitString(o << " ", SM->getFileEntryForID(FID)->getName()) << '\n'; - - o << " </array>\n" - " <key>diagnostics</key>\n" + o << " <key>diagnostics</key>\n" " <array>\n"; for (std::vector<const PathDiagnostic*>::iterator DI=Diags.begin(), @@ -553,12 +579,20 @@ void PlistDiagnostics::FlushDiagnosticsImpl( } } + printCoverage(D, /*IndentLevel=*/2, Fids, FM, o); + // Close up the entry. o << " </dict>\n"; } o << " </array>\n"; + o << " <key>files</key>\n" + " <array>\n"; + for (FileID FID : Fids) + EmitString(o << " ", SM->getFileEntryForID(FID)->getName()) << '\n'; + o << " </array>\n"; + if (llvm::AreStatisticsEnabled() && SerializeStatistics) { o << " <key>statistics</key>\n"; std::string stats; |

