Skip to content

Commit e16959c

Browse files
committed
Don't delete default constructor of PathDiagnosticConsumerOptions
This type is used as an aggregate, i.e. it has no member functions. Starting with C++20 types with deleted default constructors are not aggregate types anymore which means that aggregate initialization will not work for this class anymore. This leads to a compile error in clang::AnalyzerOptions::getDiagOpts() for example. Also set the boolean flags to false by default to avoid undefined behavior. Previously this was prevented by deleting the default constructor, now we explicitly initialize them. Differential Revision: https://reviews.llvm.org/D92221
1 parent d972d4c commit e16959c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

clang/include/clang/Analysis/PathDiagnostic.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ struct PathDiagnosticConsumerOptions {
6868
/// Whether to include additional information about macro expansions
6969
/// with the diagnostics, because otherwise they can be hard to obtain
7070
/// without re-compiling the program under analysis.
71-
bool ShouldDisplayMacroExpansions;
71+
bool ShouldDisplayMacroExpansions = false;
7272

7373
/// Whether to include LLVM statistics of the process in the diagnostic.
7474
/// Useful for profiling the tool on large real-world codebases.
75-
bool ShouldSerializeStats;
75+
bool ShouldSerializeStats = false;
7676

7777
/// If the consumer intends to produce multiple output files, should it
7878
/// use randomly generated file names for these files (with the tiny risk of
@@ -82,21 +82,19 @@ struct PathDiagnosticConsumerOptions {
8282
/// because deterministic mode is always superior when done right, but
8383
/// for some consumers this mode is experimental and needs to be
8484
/// off by default.
85-
bool ShouldWriteStableReportFilename;
85+
bool ShouldWriteStableReportFilename = false;
8686

8787
/// Whether the consumer should treat consumed diagnostics as hard errors.
8888
/// Useful for breaking your build when issues are found.
89-
bool ShouldDisplayWarningsAsErrors;
89+
bool ShouldDisplayWarningsAsErrors = false;
9090

9191
/// Whether the consumer should attempt to rewrite the source file
9292
/// with fix-it hints attached to the diagnostics it consumes.
93-
bool ShouldApplyFixIts;
93+
bool ShouldApplyFixIts = false;
9494

9595
/// Whether the consumer should present the name of the entity that emitted
9696
/// the diagnostic (eg., a checker) so that the user knew how to disable it.
97-
bool ShouldDisplayDiagnosticName;
98-
99-
PathDiagnosticConsumerOptions() = delete;
97+
bool ShouldDisplayDiagnosticName = false;
10098
};
10199

102100
class PathDiagnosticConsumer {

0 commit comments

Comments
 (0)