2323#include " clang/Lex/Token.h"
2424#include " clang/Rewrite/Core/HTMLRewrite.h"
2525#include " clang/Rewrite/Core/Rewriter.h"
26- #include " clang/StaticAnalyzer/Core/AnalyzerOptions.h"
2726#include " clang/StaticAnalyzer/Core/IssueHash.h"
2827#include " clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
2928#include " llvm/ADT/ArrayRef.h"
@@ -58,17 +57,18 @@ using namespace ento;
5857namespace {
5958
6059class HTMLDiagnostics : public PathDiagnosticConsumer {
60+ PathDiagnosticConsumerOptions DiagOpts;
6161 std::string Directory;
6262 bool createdDir = false ;
6363 bool noDir = false ;
6464 const Preprocessor &PP ;
65- AnalyzerOptions &AnalyzerOpts;
6665 const bool SupportsCrossFileDiagnostics;
6766
6867public:
69- HTMLDiagnostics (AnalyzerOptions &AnalyzerOpts, const std::string &OutputDir,
70- const Preprocessor &pp, bool supportsMultipleFiles)
71- : Directory(OutputDir), PP (pp), AnalyzerOpts(AnalyzerOpts),
68+ HTMLDiagnostics (PathDiagnosticConsumerOptions DiagOpts,
69+ const std::string &OutputDir, const Preprocessor &pp,
70+ bool supportsMultipleFiles)
71+ : DiagOpts(std::move(DiagOpts)), Directory(OutputDir), PP (pp),
7272 SupportsCrossFileDiagnostics (supportsMultipleFiles) {}
7373
7474 ~HTMLDiagnostics () override { FlushDiagnostics (nullptr ); }
@@ -133,7 +133,7 @@ class HTMLDiagnostics : public PathDiagnosticConsumer {
133133} // namespace
134134
135135void ento::createHTMLDiagnosticConsumer (
136- AnalyzerOptions &AnalyzerOpts , PathDiagnosticConsumers &C,
136+ PathDiagnosticConsumerOptions DiagOpts , PathDiagnosticConsumers &C,
137137 const std::string &OutputDir, const Preprocessor &PP ,
138138 const cross_tu::CrossTranslationUnitContext &CTU ) {
139139
@@ -142,37 +142,38 @@ void ento::createHTMLDiagnosticConsumer(
142142 // output mode. This doesn't make much sense, we should have the minimal text
143143 // as our default. In the case of backward compatibility concerns, this could
144144 // be preserved with -analyzer-config-compatibility-mode=true.
145- createTextMinimalPathDiagnosticConsumer (AnalyzerOpts , C, OutputDir, PP , CTU );
145+ createTextMinimalPathDiagnosticConsumer (DiagOpts , C, OutputDir, PP , CTU );
146146
147147 // TODO: Emit an error here.
148148 if (OutputDir.empty ())
149149 return ;
150150
151- C.push_back (new HTMLDiagnostics (AnalyzerOpts , OutputDir, PP , true ));
151+ C.push_back (new HTMLDiagnostics (std::move (DiagOpts) , OutputDir, PP , true ));
152152}
153153
154154void ento::createHTMLSingleFileDiagnosticConsumer (
155- AnalyzerOptions &AnalyzerOpts , PathDiagnosticConsumers &C,
155+ PathDiagnosticConsumerOptions DiagOpts , PathDiagnosticConsumers &C,
156156 const std::string &OutputDir, const Preprocessor &PP ,
157157 const cross_tu::CrossTranslationUnitContext &CTU ) {
158+ createTextMinimalPathDiagnosticConsumer (DiagOpts, C, OutputDir, PP , CTU );
158159
159160 // TODO: Emit an error here.
160161 if (OutputDir.empty ())
161162 return ;
162163
163- C.push_back (new HTMLDiagnostics (AnalyzerOpts, OutputDir, PP , false ));
164- createTextMinimalPathDiagnosticConsumer (AnalyzerOpts, C, OutputDir, PP , CTU );
164+ C.push_back (new HTMLDiagnostics (std::move (DiagOpts), OutputDir, PP , false ));
165165}
166166
167167void ento::createPlistHTMLDiagnosticConsumer (
168- AnalyzerOptions &AnalyzerOpts , PathDiagnosticConsumers &C,
168+ PathDiagnosticConsumerOptions DiagOpts , PathDiagnosticConsumers &C,
169169 const std::string &prefix, const Preprocessor &PP ,
170170 const cross_tu::CrossTranslationUnitContext &CTU ) {
171171 createHTMLDiagnosticConsumer (
172- AnalyzerOpts , C, std::string (llvm::sys::path::parent_path (prefix)), PP ,
172+ DiagOpts , C, std::string (llvm::sys::path::parent_path (prefix)), PP ,
173173 CTU );
174- createPlistMultiFileDiagnosticConsumer (AnalyzerOpts, C, prefix, PP , CTU );
175- createTextMinimalPathDiagnosticConsumer (AnalyzerOpts, C, prefix, PP , CTU );
174+ createPlistMultiFileDiagnosticConsumer (DiagOpts, C, prefix, PP , CTU );
175+ createTextMinimalPathDiagnosticConsumer (std::move (DiagOpts), C, prefix, PP ,
176+ CTU );
176177}
177178
178179// ===----------------------------------------------------------------------===//
@@ -245,7 +246,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
245246 int FD ;
246247 SmallString<128 > Model, ResultPath;
247248
248- if (!AnalyzerOpts .ShouldWriteStableReportFilename ) {
249+ if (!DiagOpts .ShouldWriteStableReportFilename ) {
249250 llvm::sys::path::append (Model, Directory, " report-%%%%%%.html" );
250251 if (std::error_code EC =
251252 llvm::sys::fs::make_absolute (Model)) {
@@ -535,7 +536,7 @@ void HTMLDiagnostics::FinalizeHTML(const PathDiagnostic& D, Rewriter &R,
535536<input type="checkbox" class="spoilerhider" id="showinvocation" />
536537<label for="showinvocation" >Show analyzer invocation</label>
537538<div class="spoiler">clang -cc1 )<<<" ;
538- os << html::EscapeText (AnalyzerOpts. FullCompilerInvocation );
539+ os << html::EscapeText (DiagOpts. ToolInvocation );
539540 os << R"<<<(
540541</div>
541542<div id='tooltiphint' hidden="true">
0 commit comments