@@ -103,12 +103,15 @@ struct SharedState : llvm::RefCountedBase<SharedState> {
103103class SerializedDiagnosticConsumer : public DiagnosticConsumer {
104104 // / State shared among the various clones of this diagnostic consumer.
105105 llvm::IntrusiveRefCntPtr<SharedState> State;
106+ bool EmitMacroExpansionFiles = false ;
106107 bool CalledFinishProcessing = false ;
107108 bool CompilationWasComplete = true ;
108109
109110public:
110- SerializedDiagnosticConsumer (StringRef serializedDiagnosticsPath)
111- : State(new SharedState(serializedDiagnosticsPath)) {
111+ SerializedDiagnosticConsumer (StringRef serializedDiagnosticsPath,
112+ bool emitMacroExpansionFiles)
113+ : State(new SharedState(serializedDiagnosticsPath)),
114+ EmitMacroExpansionFiles (emitMacroExpansionFiles) {
112115 emitPreamble ();
113116 }
114117
@@ -213,8 +216,11 @@ class SerializedDiagnosticConsumer : public DiagnosticConsumer {
213216
214217namespace swift {
215218namespace serialized_diagnostics {
216- std::unique_ptr<DiagnosticConsumer> createConsumer (StringRef outputPath) {
217- return std::make_unique<SerializedDiagnosticConsumer>(outputPath);
219+ std::unique_ptr<DiagnosticConsumer> createConsumer (
220+ StringRef outputPath, bool emitMacroExpansionFiles
221+ ) {
222+ return std::make_unique<SerializedDiagnosticConsumer>(
223+ outputPath, emitMacroExpansionFiles);
218224 }
219225} // namespace serialized_diagnostics
220226} // namespace swift
@@ -256,7 +262,8 @@ unsigned SerializedDiagnosticConsumer::getEmitFile(
256262 // The source range that this buffer was generated from, expressed as
257263 // offsets into the original buffer.
258264 if (generatedInfo->originalSourceRange .isValid ()) {
259- auto originalFilename = SM.getDisplayNameForLoc (generatedInfo->originalSourceRange .Start );
265+ auto originalFilename = SM.getDisplayNameForLoc (generatedInfo->originalSourceRange .Start ,
266+ EmitMacroExpansionFiles);
260267 addRangeToRecord (
261268 Lexer::getCharSourceRangeFromSourceRange (
262269 SM, generatedInfo->originalSourceRange ),
@@ -532,7 +539,7 @@ emitDiagnosticMessage(SourceManager &SM,
532539
533540 StringRef filename = " " ;
534541 if (Loc.isValid ())
535- filename = SM.getDisplayNameForLoc (Loc);
542+ filename = SM.getDisplayNameForLoc (Loc, EmitMacroExpansionFiles );
536543
537544 // Emit the RECORD_DIAG record.
538545 Record.clear ();
0 commit comments