@@ -108,17 +108,33 @@ struct DiagnosticSerializer {
108
108
ReplayFunc Fn = nullptr );
109
109
llvm::Error serializeEmittedDiagnostics (llvm::raw_ostream &os);
110
110
111
- static llvm::Error emitDiagnosticsFromCached (llvm::StringRef Buffer,
112
- SourceManager &SrcMgr,
113
- DiagnosticEngine &Diags) {
111
+ static llvm::Error
112
+ emitDiagnosticsFromCached (llvm::StringRef Buffer, SourceManager &SrcMgr,
113
+ DiagnosticEngine &Diags,
114
+ const FrontendInputsAndOutputs &InAndOut) {
114
115
// Create a new DiagnosticSerializer since this cannot be shared with a
115
116
// serialization instance.
116
117
DiagnosticSerializer DS (SrcMgr.getFileSystem ());
118
+ DS.addInputsToSourceMgr (InAndOut);
117
119
return DS.doEmitFromCached (Buffer, Diags);
118
120
}
119
121
120
122
SourceManager &getSourceMgr () { return SrcMgr; }
121
123
124
+ void addInputsToSourceMgr (const FrontendInputsAndOutputs &InAndOut) {
125
+ // Extract all the input file names so they can be added to the source
126
+ // manager when replaying the diagnostics. All input files are needed even
127
+ // they don't contain diagnostics because FileSpecificDiagConsumer need
128
+ // has references to input files to find subconsumer.
129
+ auto addInputToSourceMgr = [&](const InputFile &Input) {
130
+ if (Input.getFileName () != " -" )
131
+ SrcMgr.getExternalSourceBufferID (Input.getFileName ());
132
+ return false ;
133
+ };
134
+ InAndOut.forEachInputProducingSupplementaryOutput (addInputToSourceMgr);
135
+ InAndOut.forEachNonPrimaryInput (addInputToSourceMgr);
136
+ }
137
+
122
138
private:
123
139
// Serialization helper
124
140
unsigned getFileIDFromBufferID (SourceManager &SM, unsigned Idx);
@@ -632,7 +648,7 @@ class CachingDiagnosticsProcessor::Implementation
632
648
633
649
llvm::Error replayCachedDiagnostics (llvm::StringRef Buffer) {
634
650
return DiagnosticSerializer::emitDiagnosticsFromCached (
635
- Buffer, getDiagnosticSourceMgr (), Diags);
651
+ Buffer, getDiagnosticSourceMgr (), Diags, InAndOut );
636
652
}
637
653
638
654
void handleDiagnostic (SourceManager &SM,
@@ -683,18 +699,7 @@ class CachingDiagnosticsProcessor::Implementation
683
699
if (!Serializer) {
684
700
Serializer.reset (
685
701
new DiagnosticSerializer (InstanceSourceMgr.getFileSystem ()));
686
- auto &SM = Serializer->getSourceMgr ();
687
- // Extract all the input file names so they can be added to the source
688
- // manager when replaying the diagnostics. All input files are needed even
689
- // they don't contain diagnostics because FileSpecificDiagConsumer need
690
- // has references to input files to find subconsumer.
691
- auto addInputToSourceMgr = [&](const InputFile &Input) {
692
- if (Input.getFileName () != " -" )
693
- SM.getExternalSourceBufferID (Input.getFileName ());
694
- return false ;
695
- };
696
- InAndOut.forEachInputProducingSupplementaryOutput (addInputToSourceMgr);
697
- InAndOut.forEachNonPrimaryInput (addInputToSourceMgr);
702
+ Serializer->addInputsToSourceMgr (InAndOut);
698
703
}
699
704
700
705
return *Serializer;
0 commit comments