Skip to content

Commit ee40055

Browse files
[Caching] Temporarily using llvm style diagnostics in caching
When caching is enabled, using swift style diagnotics can lead to crashes due to some uninitialized variables. Even more, the swift style diagnostics is not going to render the same when replay from the cache since the currect caching diagnostics processor is not capture all information that is needed to render diagnostis from SwiftSyntax. Temprarily using llvm style for caching builds. rdar://127530204
1 parent dcc13d4 commit ee40055

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

include/swift/Basic/SourceManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ class GeneratedSourceInfo {
6161
CharSourceRange generatedSourceRange;
6262

6363
/// The opaque pointer for an ASTNode for which this buffer was generated.
64-
void *astNode;
64+
void *astNode = nullptr;
6565

6666
/// The declaration context in which this buffer logically resides.
67-
DeclContext *declContext;
67+
DeclContext *declContext = nullptr;
6868

6969
/// The custom attribute for an attached macro.
7070
CustomAttr *attachedMacroCustomAttr = nullptr;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,8 +2107,11 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
21072107
Args.hasFlag(OPT_color_diagnostics,
21082108
OPT_no_color_diagnostics,
21092109
/*Default=*/llvm::sys::Process::StandardErrHasColors());
2110-
// If no style options are specified, default to LLVM style.
2111-
Opts.PrintedFormattingStyle = DiagnosticOptions::FormattingStyle::Swift;
2110+
// If no style options are specified, default to Swift style, unless we are in
2111+
// caching mode which currently on supports LLVM style.
2112+
Opts.PrintedFormattingStyle = Args.hasArg(OPT_cache_compile_job)
2113+
? DiagnosticOptions::FormattingStyle::LLVM
2114+
: DiagnosticOptions::FormattingStyle::Swift;
21122115
if (const Arg *arg = Args.getLastArg(OPT_diagnostic_style)) {
21132116
StringRef contents = arg->getValue();
21142117
if (contents == "llvm") {

tools/libSwiftScan/SwiftCaching.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,10 +926,10 @@ static llvm::Error replayCompilation(SwiftScanReplayInstance &Instance,
926926
PDC.forceColors();
927927
PDC.setPrintEducationalNotes(
928928
Invocation.getDiagnosticOptions().PrintEducationalNotes);
929-
PDC.setFormattingStyle(
930-
Invocation.getDiagnosticOptions().PrintedFormattingStyle);
931929
PDC.setEmitMacroExpansionFiles(
932930
Invocation.getDiagnosticOptions().EmitMacroExpansionFiles);
931+
// Only supports LLVM diagnostics style for now.
932+
PDC.setFormattingStyle(DiagnosticOptions::FormattingStyle::LLVM);
933933

934934
std::string InstanceSetupError;
935935
if (Inst.setupForReplay(Instance.Invocation, InstanceSetupError,

0 commit comments

Comments
 (0)