File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,15 @@ void ModuleFile::fatal(llvm::Error error) const {
179179 Core->fatal (diagnoseFatal (std::move (error)));
180180}
181181
182+ SourceLoc ModuleFile::getSourceLoc () const {
183+ auto &SourceMgr = getContext ().Diags .SourceMgr ;
184+ auto filename = getModuleFilename ();
185+ auto bufferID = SourceMgr.getIDForBufferIdentifier (filename);
186+ if (!bufferID)
187+ bufferID = SourceMgr.addMemBufferCopy (StringRef (), filename);
188+ return SourceMgr.getLocForBufferStart (*bufferID);
189+ }
190+
182191llvm::Error ModuleFile::diagnoseFatal (llvm::Error error) const {
183192 if (FileContext)
184193 getContext ().Diags .diagnose (SourceLoc (), diag::serialization_fatal,
Original file line number Diff line number Diff line change @@ -667,6 +667,9 @@ class ModuleFile
667667 getTransitiveLoadingBehavior (const Dependency &dependency,
668668 bool forTestable) const ;
669669
670+ // / Generate a \c SourceLoc pointing at the loaded swiftmodule file.
671+ SourceLoc getSourceLoc () const ;
672+
670673 // / Returns `true` if there is a buffer that might contain source code where
671674 // / other parts of the compiler could have emitted diagnostics, to indicate
672675 // / that the object must be kept alive as long as the diagnostics exist.
You can’t perform that action at this time.
0 commit comments