4646#include " swift/Basic/Defer.h"
4747#include " swift/Basic/PrettyStackTrace.h"
4848#include " swift/Basic/SourceLoc.h"
49+ #include " swift/Basic/SourceManager.h"
4950#include " swift/Basic/Statistic.h"
5051#include " swift/Basic/StringExtras.h"
5152#include " swift/Basic/Version.h"
@@ -8648,17 +8649,16 @@ bool importer::hasSameUnderlyingType(const clang::Type *a,
86488649}
86498650
86508651SourceFile &ClangImporter::Implementation::getClangSwiftAttrSourceFile (
8651- ModuleDecl &module ,
8652- StringRef attributeText,
8653- bool cached
8654- ) {
8652+ Decl *MappedDecl, StringRef attributeText, bool cached) {
8653+ auto *module = MappedDecl->getDeclContext ()->getParentModule ();
8654+
86558655 ::TinyPtrVector<SourceFile *> *sourceFiles = nullptr ;
86568656 if (cached) {
86578657 sourceFiles = &ClangSwiftAttrSourceFiles[attributeText];
86588658
86598659 // Check whether we've already created a source file.
86608660 for (auto sourceFile : *sourceFiles) {
8661- if (sourceFile->getParentModule () == & module )
8661+ if (sourceFile->getParentModule () == module )
86628662 return *sourceFile;
86638663 }
86648664 }
@@ -8668,20 +8668,17 @@ SourceFile &ClangImporter::Implementation::getClangSwiftAttrSourceFile(
86688668 auto &sourceMgr = SwiftContext.SourceMgr ;
86698669 auto bufferID = sourceMgr.addMemBufferCopy (attributeText);
86708670
8671- // Note that this is for an attribute.
8672- sourceMgr.setGeneratedSourceInfo (
8673- bufferID,
8674- {
8675- GeneratedSourceInfo::AttributeFromClang,
8676- CharSourceRange (),
8677- sourceMgr.getRangeForBuffer (bufferID),
8678- &module
8679- }
8680- );
8671+ auto info = GeneratedSourceInfo{GeneratedSourceInfo::AttributeFromClang,
8672+ CharSourceRange (),
8673+ sourceMgr.getRangeForBuffer (bufferID)};
8674+ info.astNode = static_cast <void *>(module );
8675+ info.clangNode = MappedDecl->getClangNode ();
8676+
8677+ sourceMgr.setGeneratedSourceInfo (bufferID, info);
86818678
86828679 // Create the source file.
8683- auto sourceFile = new (SwiftContext)
8684- SourceFile (module , SourceFileKind::Library, bufferID);
8680+ auto sourceFile =
8681+ new (SwiftContext) SourceFile (* module , SourceFileKind::Library, bufferID);
86858682
86868683 if (cached)
86878684 sourceFiles->push_back (sourceFile);
@@ -8704,8 +8701,8 @@ void ClangImporter::Implementation::importNontrivialAttribute(
87048701 bool cached = true ;
87058702 while (true ) {
87068703 // Dig out a source file we can use for parsing.
8707- auto &sourceFile = getClangSwiftAttrSourceFile (
8708- *MappedDecl-> getDeclContext ()-> getParentModule () , AttrString, cached);
8704+ auto &sourceFile =
8705+ getClangSwiftAttrSourceFile (MappedDecl , AttrString, cached);
87098706
87108707 auto topLevelDecls = sourceFile.getTopLevelDecls ();
87118708
0 commit comments