From d2ddc694ff94743d9735aaf07edcaf6db8aaca04 Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Wed, 6 Jan 2021 06:35:09 -0800 Subject: [PATCH] Revert "Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis."" This reverts commit 5663bf201f5c444d6fb56fb1bd471bc53c17d837. The cyclic dependency problem is addressed now. This is the ~fifth attempt to land this change. --- .../include/clang/Analysis/CrossTUAnalysisHelper.h | 41 ++++++++ .../clang/Analysis/PathDiagnosticConsumers.def | 50 ++++++++++ .../Core => Analysis}/PathDiagnosticConsumers.h | 13 ++- clang/include/clang/CrossTU/CrossTranslationUnit.h | 21 +++- .../include/clang/StaticAnalyzer/Core/Analyses.def | 37 ------- .../clang/StaticAnalyzer/Core/AnalyzerOptions.h | 2 +- .../Core/PathSensitive/AnalysisManager.h | 2 +- clang/include/clang/module.modulemap | 1 + clang/lib/Analysis/CMakeLists.txt | 7 ++ .../HTMLPathDiagnosticConsumer.cpp} | 111 ++++++++++----------- .../Analysis/PlistHTMLPathDiagnosticConsumer.cpp | 35 +++++++ .../PlistPathDiagnosticConsumer.cpp} | 62 ++++++------ .../SarifPathDiagnosticConsumer.cpp} | 30 ++++-- .../TextPathDiagnosticConsumer.cpp} | 42 ++++---- clang/lib/CrossTU/CrossTranslationUnit.cpp | 13 ++- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- clang/lib/StaticAnalyzer/Core/CMakeLists.txt | 4 - .../StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 4 +- 18 files changed, 299 insertions(+), 178 deletions(-) create mode 100644 clang/include/clang/Analysis/CrossTUAnalysisHelper.h create mode 100644 clang/include/clang/Analysis/PathDiagnosticConsumers.def rename clang/include/clang/{StaticAnalyzer/Core => Analysis}/PathDiagnosticConsumers.h (78%) rename clang/lib/{StaticAnalyzer/Core/HTMLDiagnostics.cpp => Analysis/HTMLPathDiagnosticConsumer.cpp} (91%) create mode 100644 clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp rename clang/lib/{StaticAnalyzer/Core/PlistDiagnostics.cpp => Analysis/PlistPathDiagnosticConsumer.cpp} (96%) rename clang/lib/{StaticAnalyzer/Core/SarifDiagnostics.cpp => Analysis/SarifPathDiagnosticConsumer.cpp} (93%) rename clang/lib/{StaticAnalyzer/Core/TextDiagnostics.cpp => Analysis/TextPathDiagnosticConsumer.cpp} (79%) diff --git a/clang/include/clang/Analysis/CrossTUAnalysisHelper.h b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h new file mode 100644 index 0000000..500e78d --- /dev/null +++ b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h @@ -0,0 +1,41 @@ +//===- CrossTUAnalysisHelper.h - Abstraction layer for CTU ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H +#define LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H + +#include "llvm/ADT/Optional.h" +#include "clang/Basic/SourceManager.h" + +namespace clang { + +class ASTUnit; + +/// This class is an abstract interface acting as a bridge between +/// an analysis that requires lookups across translation units (a user +/// of that interface) and the facility that implements such lookups +/// (an implementation of that interface). This is useful to break direct +/// link-time dependencies between the (possibly shared) libraries in which +/// the user and the implementation live. +class CrossTUAnalysisHelper { +public: + /// Determine the original source location in the original TU for an + /// imported source location. + /// \p ToLoc Source location in the imported-to AST. + /// \return Source location in the imported-from AST and the corresponding + /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit + /// object that is returned here). + /// If any error happens (ToLoc is a non-imported source location) empty is + /// returned. + virtual llvm::Optional> + getImportedFromSourceLocationWithPreprocessor(SourceLocation ToLoc) const = 0; + + virtual ~CrossTUAnalysisHelper() {} +}; +} // namespace clang + +#endif // LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H diff --git a/clang/include/clang/Analysis/PathDiagnosticConsumers.def b/clang/include/clang/Analysis/PathDiagnosticConsumers.def new file mode 100644 index 0000000..33d2072 --- /dev/null +++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.def @@ -0,0 +1,50 @@ +//===-- PathDiagnosticConsumers.def - Visualizing warnings ------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the set of path diagnostic consumers - objects that +// implement different representations of static analysis results. +// +//===----------------------------------------------------------------------===// + +#ifndef ANALYSIS_DIAGNOSTICS +#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN) +#endif + +ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML", + createHTMLDiagnosticConsumer) + +ANALYSIS_DIAGNOSTICS( + HTML_SINGLE_FILE, "html-single-file", + "Output analysis results using HTML (not allowing for multi-file bugs)", + createHTMLSingleFileDiagnosticConsumer) + +ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists", + createPlistDiagnosticConsumer) + +ANALYSIS_DIAGNOSTICS( + PLIST_MULTI_FILE, "plist-multi-file", + "Output analysis results using Plists (allowing for multi-file bugs)", + createPlistMultiFileDiagnosticConsumer) + +ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html", + "Output analysis results using HTML wrapped with Plists", + createPlistHTMLDiagnosticConsumer) + +ANALYSIS_DIAGNOSTICS(SARIF, "sarif", "Output analysis results in a SARIF file", + createSarifDiagnosticConsumer) + +ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results to stderr", + createTextPathDiagnosticConsumer) + +ANALYSIS_DIAGNOSTICS(TEXT_MINIMAL, "text-minimal", + "Emits minimal diagnostics to stderr, stating only the " + "warning message and the associated notes. Usually " + "used in addition to other analysis types", + createTextMinimalPathDiagnosticConsumer) + +#undef ANALYSIS_DIAGNOSTICS diff --git a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h b/clang/include/clang/Analysis/PathDiagnosticConsumers.h similarity index 78% rename from clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h rename to clang/include/clang/Analysis/PathDiagnosticConsumers.h index f40f88e..fde2e34 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h +++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.h @@ -18,25 +18,24 @@ #include #include +#include "clang/Analysis/PathDiagnostic.h" + namespace clang { class AnalyzerOptions; class Preprocessor; -namespace cross_tu { -class CrossTranslationUnitContext; -} +class CrossTUAnalysisHelper; namespace ento { class PathDiagnosticConsumer; -typedef std::vector PathDiagnosticConsumers; +typedef std::vector PathDiagnosticConsumers; #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN) \ void CREATEFN(PathDiagnosticConsumerOptions Diagopts, \ PathDiagnosticConsumers &C, const std::string &Prefix, \ - const Preprocessor &PP, \ - const cross_tu::CrossTranslationUnitContext &CTU); -#include "clang/StaticAnalyzer/Core/Analyses.def" + const Preprocessor &PP, const CrossTUAnalysisHelper &CTU); +#include "clang/Analysis/PathDiagnosticConsumers.def" } // end 'ento' namespace } // end 'clang' namespace diff --git a/clang/include/clang/CrossTU/CrossTranslationUnit.h b/clang/include/clang/CrossTU/CrossTranslationUnit.h index 027c6f1..21201f6 100644 --- a/clang/include/clang/CrossTU/CrossTranslationUnit.h +++ b/clang/include/clang/CrossTU/CrossTranslationUnit.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H #define LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H +#include "clang/Analysis/CrossTUAnalysisHelper.h" #include "clang/AST/ASTImporterSharedState.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/DenseMap.h" @@ -120,10 +121,10 @@ bool containsConst(const VarDecl *VD, const ASTContext &ACtx); /// the locations of the AST files for each definition. /// /// Note that this class also implements caching. -class CrossTranslationUnitContext { +class CrossTranslationUnitContext : public CrossTUAnalysisHelper { public: CrossTranslationUnitContext(CompilerInstance &CI); - ~CrossTranslationUnitContext(); + ~CrossTranslationUnitContext() override; /// This function loads a function or variable definition from an /// external AST file and merges it into the original AST. @@ -186,12 +187,24 @@ public: /// imported source location. /// \p ToLoc Source location in the imported-to AST. /// \return Source location in the imported-from AST and the corresponding - /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit + /// ASTUnit object (the AST was loaded from a file using an internal ASTUni /// object that is returned here). /// If any error happens (ToLoc is a non-imported source location) empty is /// returned. llvm::Optional> - getImportedFromSourceLocation(const clang::SourceLocation &ToLoc) const; + getImportedFromSourceLocation(SourceLocation ToLoc) const; + + /// Determine the original source location in the original TU for an + /// imported source location. + /// \p ToLoc Source location in the imported-to AST. + /// \return Source location in the imported-from AST and the Preprocessor + /// corresponding to the AST unit that originally contained the imported-from + /// source location. + /// If any error happens (ToLoc is a non-imported source location) empty is + /// returned. + llvm::Optional> + getImportedFromSourceLocationWithPreprocessor( + SourceLocation ToLoc) const override; private: using ImportedFileIDMap = diff --git a/clang/include/clang/StaticAnalyzer/Core/Analyses.def b/clang/include/clang/StaticAnalyzer/Core/Analyses.def index c4e5f5b..2e98cbb 100644 --- a/clang/include/clang/StaticAnalyzer/Core/Analyses.def +++ b/clang/include/clang/StaticAnalyzer/Core/Analyses.def @@ -28,42 +28,6 @@ ANALYSIS_CONSTRAINTS(RangeConstraints, "range", ANALYSIS_CONSTRAINTS(Z3Constraints, "z3", "Use Z3 contraint solver", CreateZ3ConstraintManager) -#ifndef ANALYSIS_DIAGNOSTICS -#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN) -#endif - -ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML", - createHTMLDiagnosticConsumer) - -ANALYSIS_DIAGNOSTICS( - HTML_SINGLE_FILE, "html-single-file", - "Output analysis results using HTML (not allowing for multi-file bugs)", - createHTMLSingleFileDiagnosticConsumer) - -ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists", - createPlistDiagnosticConsumer) - -ANALYSIS_DIAGNOSTICS( - PLIST_MULTI_FILE, "plist-multi-file", - "Output analysis results using Plists (allowing for multi-file bugs)", - createPlistMultiFileDiagnosticConsumer) - -ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html", - "Output analysis results using HTML wrapped with Plists", - createPlistHTMLDiagnosticConsumer) - -ANALYSIS_DIAGNOSTICS(SARIF, "sarif", "Output analysis results in a SARIF file", - createSarifDiagnosticConsumer) - -ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results to stderr", - createTextPathDiagnosticConsumer) - -ANALYSIS_DIAGNOSTICS(TEXT_MINIMAL, "text-minimal", - "Emits minimal diagnostics to stderr, stating only the " - "warning message and the associated notes. Usually " - "used in addition to other analysis types", - createTextMinimalPathDiagnosticConsumer) - #ifndef ANALYSIS_PURGE #define ANALYSIS_PURGE(NAME, CMDFLAG, DESC) #endif @@ -91,7 +55,6 @@ ANALYSIS_INLINING_MODE( #undef ANALYSIS_STORE #undef ANALYSIS_CONSTRAINTS -#undef ANALYSIS_DIAGNOSTICS #undef ANALYSIS_PURGE #undef ANALYSIS_INLINING_MODE #undef ANALYSIS_IPA diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h index ccf35e0..0dd2c86 100644 --- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -58,7 +58,7 @@ NumConstraints /// analysis results. enum AnalysisDiagClients { #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN) PD_##NAME, -#include "clang/StaticAnalyzer/Core/Analyses.def" +#include "clang/Analysis/PathDiagnosticConsumers.def" PD_NONE, NUM_ANALYSIS_DIAG_CLIENTS }; diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h index c76e9c0..7e8b9de 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h @@ -16,10 +16,10 @@ #include "clang/Analysis/AnalysisDeclContext.h" #include "clang/Analysis/PathDiagnostic.h" +#include "clang/Analysis/PathDiagnosticConsumers.h" #include "clang/Lex/Preprocessor.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" -#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" namespace clang { diff --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap index 332e533..ec396e1 100644 --- a/clang/include/clang/module.modulemap +++ b/clang/include/clang/module.modulemap @@ -3,6 +3,7 @@ module Clang_Analysis { umbrella "Analysis" textual header "Analysis/Analyses/ThreadSafetyOps.def" + textual header "Analysis/PathDiagnosticConsumers.def" module * { export * } diff --git a/clang/lib/Analysis/CMakeLists.txt b/clang/lib/Analysis/CMakeLists.txt index ed626a6..94c6e32 100644 --- a/clang/lib/Analysis/CMakeLists.txt +++ b/clang/lib/Analysis/CMakeLists.txt @@ -18,14 +18,19 @@ add_clang_library(clangAnalysis CodeInjector.cpp Dominators.cpp ExprMutationAnalyzer.cpp + HTMLPathDiagnosticConsumer.cpp IssueHash.cpp LiveVariables.cpp ObjCNoReturn.cpp PathDiagnostic.cpp + PlistPathDiagnosticConsumer.cpp + PlistHTMLPathDiagnosticConsumer.cpp PostOrderCFGView.cpp ProgramPoint.cpp ReachableCode.cpp RetainSummaryManager.cpp + SarifPathDiagnosticConsumer.cpp + TextPathDiagnosticConsumer.cpp ThreadSafety.cpp ThreadSafetyCommon.cpp ThreadSafetyLogical.cpp @@ -37,6 +42,8 @@ add_clang_library(clangAnalysis clangASTMatchers clangBasic clangLex + clangRewrite + clangToolingCore DEPENDS omp_gen diff --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp similarity index 91% rename from clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp rename to clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp index 149459c..fb60819 100644 --- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp @@ -1,4 +1,4 @@ -//===- HTMLDiagnostics.cpp - HTML Diagnostics for Paths -------------------===// +//===- HTMLPathDiagnosticConsumer.cpp - HTML Diagnostics for Paths --------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,12 +6,13 @@ // //===----------------------------------------------------------------------===// // -// This file defines the HTMLDiagnostics object. +// This file defines the HTMLPathDiagnosticConsumer object. // //===----------------------------------------------------------------------===// #include "clang/Analysis/IssueHash.h" #include "clang/Analysis/PathDiagnostic.h" +#include "clang/Analysis/PathDiagnosticConsumers.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclBase.h" #include "clang/AST/Stmt.h" @@ -24,7 +25,6 @@ #include "clang/Lex/Token.h" #include "clang/Rewrite/Core/HTMLRewrite.h" #include "clang/Rewrite/Core/Rewriter.h" -#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" @@ -50,13 +50,17 @@ using namespace clang; using namespace ento; +namespace clang { +class CrossTUAnalysisHelper; +} + //===----------------------------------------------------------------------===// // Boilerplate. //===----------------------------------------------------------------------===// namespace { -class HTMLDiagnostics : public PathDiagnosticConsumer { +class HTMLPathDiagnosticConsumer : public PathDiagnosticConsumer { PathDiagnosticConsumerOptions DiagOpts; std::string Directory; bool createdDir = false; @@ -65,20 +69,18 @@ class HTMLDiagnostics : public PathDiagnosticConsumer { const bool SupportsCrossFileDiagnostics; public: - HTMLDiagnostics(PathDiagnosticConsumerOptions DiagOpts, - const std::string &OutputDir, const Preprocessor &pp, - bool supportsMultipleFiles) - : DiagOpts(std::move(DiagOpts)), Directory(OutputDir), PP(pp), - SupportsCrossFileDiagnostics(supportsMultipleFiles) {} + HTMLPathDiagnosticConsumer(PathDiagnosticConsumerOptions DiagOpts, + const std::string &OutputDir, + const Preprocessor &PP, bool SupportsMultipleFiles) + : DiagOpts(std::move(DiagOpts)), Directory(OutputDir), PP(PP), + SupportsCrossFileDiagnostics(SupportsMultipleFiles) {} - ~HTMLDiagnostics() override { FlushDiagnostics(nullptr); } + ~HTMLPathDiagnosticConsumer() override { FlushDiagnostics(nullptr); } void FlushDiagnosticsImpl(std::vector &Diags, FilesMade *filesMade) override; - StringRef getName() const override { - return "HTMLDiagnostics"; - } + StringRef getName() const override { return "HTMLPathDiagnosticConsumer"; } bool supportsCrossFileDiagnostics() const override { return SupportsCrossFileDiagnostics; @@ -135,7 +137,7 @@ private: void ento::createHTMLDiagnosticConsumer( PathDiagnosticConsumerOptions DiagOpts, PathDiagnosticConsumers &C, const std::string &OutputDir, const Preprocessor &PP, - const cross_tu::CrossTranslationUnitContext &CTU) { + const CrossTUAnalysisHelper &CTU) { // FIXME: HTML is currently our default output type, but if the output // directory isn't specified, it acts like if it was in the minimal text @@ -148,47 +150,36 @@ void ento::createHTMLDiagnosticConsumer( if (OutputDir.empty()) return; - C.push_back(new HTMLDiagnostics(std::move(DiagOpts), OutputDir, PP, true)); + C.push_back( + new HTMLPathDiagnosticConsumer(std::move(DiagOpts), OutputDir, PP, true)); } void ento::createHTMLSingleFileDiagnosticConsumer( PathDiagnosticConsumerOptions DiagOpts, PathDiagnosticConsumers &C, const std::string &OutputDir, const Preprocessor &PP, - const cross_tu::CrossTranslationUnitContext &CTU) { + const CrossTUAnalysisHelper &CTU) { createTextMinimalPathDiagnosticConsumer(DiagOpts, C, OutputDir, PP, CTU); // TODO: Emit an error here. if (OutputDir.empty()) return; - C.push_back(new HTMLDiagnostics(std::move(DiagOpts), OutputDir, PP, false)); -} - -void ento::createPlistHTMLDiagnosticConsumer( - PathDiagnosticConsumerOptions DiagOpts, PathDiagnosticConsumers &C, - const std::string &prefix, const Preprocessor &PP, - const cross_tu::CrossTranslationUnitContext &CTU) { - createHTMLDiagnosticConsumer( - DiagOpts, C, std::string(llvm::sys::path::parent_path(prefix)), PP, - CTU); - createPlistMultiFileDiagnosticConsumer(DiagOpts, C, prefix, PP, CTU); - createTextMinimalPathDiagnosticConsumer(std::move(DiagOpts), C, prefix, PP, - CTU); + C.push_back(new HTMLPathDiagnosticConsumer(std::move(DiagOpts), OutputDir, PP, + false)); } //===----------------------------------------------------------------------===// // Report processing. //===----------------------------------------------------------------------===// -void HTMLDiagnostics::FlushDiagnosticsImpl( - std::vector &Diags, - FilesMade *filesMade) { +void HTMLPathDiagnosticConsumer::FlushDiagnosticsImpl( + std::vector &Diags, FilesMade *filesMade) { for (const auto Diag : Diags) ReportDiag(*Diag, filesMade); } -void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, - FilesMade *filesMade) { +void HTMLPathDiagnosticConsumer::ReportDiag(const PathDiagnostic &D, + FilesMade *filesMade) { // Create the HTML directory if it is missing. if (!createdDir) { createdDir = true; @@ -296,8 +287,11 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, os << report; } -std::string HTMLDiagnostics::GenerateHTML(const PathDiagnostic& D, Rewriter &R, - const SourceManager& SMgr, const PathPieces& path, const char *declName) { +std::string HTMLPathDiagnosticConsumer::GenerateHTML(const PathDiagnostic &D, + Rewriter &R, + const SourceManager &SMgr, + const PathPieces &path, + const char *declName) { // Rewrite source files as HTML for every new file the path crosses std::vector FileIDs; for (auto I : path) { @@ -369,9 +363,8 @@ std::string HTMLDiagnostics::GenerateHTML(const PathDiagnostic& D, Rewriter &R, return os.str(); } -void HTMLDiagnostics::dumpCoverageData( - const PathDiagnostic &D, - const PathPieces &path, +void HTMLPathDiagnosticConsumer::dumpCoverageData( + const PathDiagnostic &D, const PathPieces &path, llvm::raw_string_ostream &os) { const FilesToLineNumsMap &ExecutedLines = D.getExecutedLines(); @@ -395,8 +388,8 @@ void HTMLDiagnostics::dumpCoverageData( os << "};"; } -std::string HTMLDiagnostics::showRelevantLinesJavascript( - const PathDiagnostic &D, const PathPieces &path) { +std::string HTMLPathDiagnosticConsumer::showRelevantLinesJavascript( + const PathDiagnostic &D, const PathPieces &path) { std::string s; llvm::raw_string_ostream os(s); os << "