Skip to content

Commit ac1c1dc

Browse files
committed
Simplify the path lookup code by using the SourceManager.getDisplayNameForLoc() function instead.
1 parent ca32c07 commit ac1c1dc

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lib/Sema/PlaygroundTransform.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -829,17 +829,7 @@ class Instrumenter : InstrumenterBase {
829829
LoggerRef->setImplicit(true);
830830

831831
if (ExtendedCallbacks) {
832-
auto SourceLocBufferId = Context.SourceMgr.findBufferContainingLoc(SR.Start);
833-
StringRef filePath;
834-
835-
// Use #sourceLocation if it exists.
836-
SourceLoc sl = SR.Start;
837-
auto *vf = Context.SourceMgr.getVirtualFile(sl);
838-
if (vf) {
839-
filePath = StringRef(vf->Name);
840-
} else {
841-
filePath = Context.SourceMgr.getIdentifierForBuffer(SourceLocBufferId);
842-
}
832+
StringRef filePath = Context.SourceMgr.getDisplayNameForLoc(SR.Start);
843833

844834
Expr *FilePathExpr = new (Context) StringLiteralExpr(
845835
Context.AllocateCopy(filePath), SourceRange(), /*implicit=*/true);

0 commit comments

Comments
 (0)