23
23
#include " clang/Lex/Token.h"
24
24
#include " clang/Rewrite/Core/HTMLRewrite.h"
25
25
#include " clang/Rewrite/Core/Rewriter.h"
26
- #include " clang/StaticAnalyzer/Core/AnalyzerOptions.h"
27
26
#include " clang/StaticAnalyzer/Core/IssueHash.h"
28
27
#include " clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
29
28
#include " llvm/ADT/ArrayRef.h"
@@ -58,17 +57,18 @@ using namespace ento;
58
57
namespace {
59
58
60
59
class HTMLDiagnostics : public PathDiagnosticConsumer {
60
+ PathDiagnosticConsumerOptions DiagOpts;
61
61
std::string Directory;
62
62
bool createdDir = false ;
63
63
bool noDir = false ;
64
64
const Preprocessor &PP;
65
- AnalyzerOptions &AnalyzerOpts;
66
65
const bool SupportsCrossFileDiagnostics;
67
66
68
67
public:
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),
72
72
SupportsCrossFileDiagnostics (supportsMultipleFiles) {}
73
73
74
74
~HTMLDiagnostics () override { FlushDiagnostics (nullptr ); }
@@ -133,7 +133,7 @@ class HTMLDiagnostics : public PathDiagnosticConsumer {
133
133
} // namespace
134
134
135
135
void ento::createHTMLDiagnosticConsumer (
136
- AnalyzerOptions &AnalyzerOpts , PathDiagnosticConsumers &C,
136
+ PathDiagnosticConsumerOptions DiagOpts , PathDiagnosticConsumers &C,
137
137
const std::string &OutputDir, const Preprocessor &PP,
138
138
const cross_tu::CrossTranslationUnitContext &CTU) {
139
139
@@ -142,37 +142,38 @@ void ento::createHTMLDiagnosticConsumer(
142
142
// output mode. This doesn't make much sense, we should have the minimal text
143
143
// as our default. In the case of backward compatibility concerns, this could
144
144
// be preserved with -analyzer-config-compatibility-mode=true.
145
- createTextMinimalPathDiagnosticConsumer (AnalyzerOpts , C, OutputDir, PP, CTU);
145
+ createTextMinimalPathDiagnosticConsumer (DiagOpts , C, OutputDir, PP, CTU);
146
146
147
147
// TODO: Emit an error here.
148
148
if (OutputDir.empty ())
149
149
return ;
150
150
151
- C.push_back (new HTMLDiagnostics (AnalyzerOpts , OutputDir, PP, true ));
151
+ C.push_back (new HTMLDiagnostics (std::move (DiagOpts) , OutputDir, PP, true ));
152
152
}
153
153
154
154
void ento::createHTMLSingleFileDiagnosticConsumer (
155
- AnalyzerOptions &AnalyzerOpts , PathDiagnosticConsumers &C,
155
+ PathDiagnosticConsumerOptions DiagOpts , PathDiagnosticConsumers &C,
156
156
const std::string &OutputDir, const Preprocessor &PP,
157
157
const cross_tu::CrossTranslationUnitContext &CTU) {
158
+ createTextMinimalPathDiagnosticConsumer (DiagOpts, C, OutputDir, PP, CTU);
158
159
159
160
// TODO: Emit an error here.
160
161
if (OutputDir.empty ())
161
162
return ;
162
163
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 ));
165
165
}
166
166
167
167
void ento::createPlistHTMLDiagnosticConsumer (
168
- AnalyzerOptions &AnalyzerOpts , PathDiagnosticConsumers &C,
168
+ PathDiagnosticConsumerOptions DiagOpts , PathDiagnosticConsumers &C,
169
169
const std::string &prefix, const Preprocessor &PP,
170
170
const cross_tu::CrossTranslationUnitContext &CTU) {
171
171
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,
173
173
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);
176
177
}
177
178
178
179
// ===----------------------------------------------------------------------===//
@@ -245,7 +246,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
245
246
int FD;
246
247
SmallString<128 > Model, ResultPath;
247
248
248
- if (!AnalyzerOpts .ShouldWriteStableReportFilename ) {
249
+ if (!DiagOpts .ShouldWriteStableReportFilename ) {
249
250
llvm::sys::path::append (Model, Directory, " report-%%%%%%.html" );
250
251
if (std::error_code EC =
251
252
llvm::sys::fs::make_absolute (Model)) {
@@ -535,7 +536,7 @@ void HTMLDiagnostics::FinalizeHTML(const PathDiagnostic& D, Rewriter &R,
535
536
<input type="checkbox" class="spoilerhider" id="showinvocation" />
536
537
<label for="showinvocation" >Show analyzer invocation</label>
537
538
<div class="spoiler">clang -cc1 )<<<" ;
538
- os << html::EscapeText (AnalyzerOpts. FullCompilerInvocation );
539
+ os << html::EscapeText (DiagOpts. ToolInvocation );
539
540
os << R"<<<(
540
541
</div>
541
542
<div id='tooltiphint' hidden="true">
0 commit comments