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"
@@ -8669,17 +8670,16 @@ bool importer::hasSameUnderlyingType(const clang::Type *a,
86698670}
86708671
86718672SourceFile &ClangImporter::Implementation::getClangSwiftAttrSourceFile (
8672- ModuleDecl &module ,
8673- StringRef attributeText,
8674- bool cached
8675- ) {
8673+ Decl *MappedDecl, StringRef attributeText, bool cached) {
8674+ auto *module = MappedDecl->getDeclContext ()->getParentModule ();
8675+
86768676 ::TinyPtrVector<SourceFile *> *sourceFiles = nullptr ;
86778677 if (cached) {
86788678 sourceFiles = &ClangSwiftAttrSourceFiles[attributeText];
86798679
86808680 // Check whether we've already created a source file.
86818681 for (auto sourceFile : *sourceFiles) {
8682- if (sourceFile->getParentModule () == & module )
8682+ if (sourceFile->getParentModule () == module )
86838683 return *sourceFile;
86848684 }
86858685 }
@@ -8689,20 +8689,17 @@ SourceFile &ClangImporter::Implementation::getClangSwiftAttrSourceFile(
86898689 auto &sourceMgr = SwiftContext.SourceMgr ;
86908690 auto bufferID = sourceMgr.addMemBufferCopy (attributeText);
86918691
8692- // Note that this is for an attribute.
8693- sourceMgr.setGeneratedSourceInfo (
8694- bufferID,
8695- {
8696- GeneratedSourceInfo::AttributeFromClang,
8697- CharSourceRange (),
8698- sourceMgr.getRangeForBuffer (bufferID),
8699- &module
8700- }
8701- );
8692+ auto info = GeneratedSourceInfo{GeneratedSourceInfo::AttributeFromClang,
8693+ CharSourceRange (),
8694+ sourceMgr.getRangeForBuffer (bufferID)};
8695+ info.astNode = static_cast <void *>(module );
8696+ info.clangNode = MappedDecl->getClangNode ();
8697+
8698+ sourceMgr.setGeneratedSourceInfo (bufferID, info);
87028699
87038700 // Create the source file.
8704- auto sourceFile = new (SwiftContext)
8705- SourceFile (module , SourceFileKind::Library, bufferID);
8701+ auto sourceFile =
8702+ new (SwiftContext) SourceFile (* module , SourceFileKind::Library, bufferID);
87068703
87078704 if (cached)
87088705 sourceFiles->push_back (sourceFile);
@@ -8725,8 +8722,8 @@ void ClangImporter::Implementation::importNontrivialAttribute(
87258722 bool cached = true ;
87268723 while (true ) {
87278724 // Dig out a source file we can use for parsing.
8728- auto &sourceFile = getClangSwiftAttrSourceFile (
8729- *MappedDecl-> getDeclContext ()-> getParentModule () , AttrString, cached);
8725+ auto &sourceFile =
8726+ getClangSwiftAttrSourceFile (MappedDecl , AttrString, cached);
87308727
87318728 auto topLevelDecls = sourceFile.getTopLevelDecls ();
87328729
0 commit comments