Skip to content

Commit e35472c

Browse files
committed
Create and register SourceFiles for pretty-printed buffers
This will allow the macro system to find them.
1 parent 593f1de commit e35472c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,6 +3350,7 @@ SourceLoc PrettyPrintDeclRequest::evaluate(Evaluator &eval, const Decl *decl) co
33503350
getBufferAccessLevel(decl),
33513351
ctx.TypeCheckerOpts.PrintFullConvention);
33523352
decl->print(printer, options);
3353+
33533354
// Close all of the enclosing types.
33543355
for (const auto & enclosingType: enclosingTypes) {
33553356
(void)enclosingType;
@@ -3381,5 +3382,11 @@ SourceLoc PrettyPrintDeclRequest::evaluate(Evaluator &eval, const Decl *decl) co
33813382
}
33823383
);
33833384

3385+
// Add a source file for the buffer.
3386+
auto moduleDecl = decl->getDeclContext()->getParentModule();
3387+
auto sourceFile = new (ctx) SourceFile(
3388+
*moduleDecl, SourceFileKind::Library, bufferID);
3389+
sourceFile->setImports({ });
3390+
33843391
return memBufferStartLoc.getAdvancedLoc(targetDeclOffsetInBuffer);
33853392
}

0 commit comments

Comments
 (0)