File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,21 @@ SourceLoc ModuleFile::getSourceLoc() const {
189189 return SourceMgr.getLocForBufferStart (*bufferID);
190190}
191191
192+ SourceLoc ModularizationError::getSourceLoc () const {
193+ auto &SourceMgr = referenceModule->getContext ().Diags .SourceMgr ;
194+ auto filename = referenceModule->getModuleFilename ();
195+
196+ // Synthesize some context. We don't have an actual decl here
197+ // so try to print a simple representation of the reference.
198+ std::string S;
199+ llvm::raw_string_ostream OS (S);
200+ OS << expectedModule->getName () << " ." << name;
201+
202+ // If we enable these remarks by default we may want to reuse these buffers.
203+ auto bufferID = SourceMgr.addMemBufferCopy (S, filename);
204+ return SourceMgr.getLocForBufferStart (bufferID);
205+ }
206+
192207void
193208ModularizationError::diagnose (const ModuleFile *MF,
194209 DiagnosticBehavior limit) const {
Original file line number Diff line number Diff line change @@ -402,6 +402,8 @@ class ModularizationError : public llvm::ErrorInfo<ModularizationError> {
402402 path.print (OS);
403403 }
404404
405+ SourceLoc getSourceLoc () const ;
406+
405407 std::error_code convertToErrorCode () const override {
406408 return llvm::inconvertibleErrorCode ();
407409 }
You can’t perform that action at this time.
0 commit comments