Skip to content

Commit 2f6b4cd

Browse files
authored
Merge pull request #19054 from jrose-apple/nocturnal
Honor #sourceLocation filenames in several more places
2 parents 296afc7 + 4a93ab5 commit 2f6b4cd

File tree

17 files changed

+148
-51
lines changed

17 files changed

+148
-51
lines changed

include/swift/Basic/SourceManager.h

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SourceManager {
3939
/// to speed up stats.
4040
mutable llvm::StringMap<clang::vfs::Status> StatusCache;
4141

42-
// #line directive handling.
42+
// \c #sourceLocation directive handling.
4343
struct VirtualFile {
4444
CharSourceRange Range;
4545
std::string Name;
@@ -112,17 +112,17 @@ class SourceManager {
112112
/// Adds a memory buffer to the SourceManager, taking ownership of it.
113113
unsigned addNewSourceBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer);
114114

115-
/// Add a #line-defined virtual file region.
115+
/// Add a \c #sourceLocation-defined virtual file region.
116116
///
117117
/// By default, this region continues to the end of the buffer.
118118
///
119119
/// \returns True if the new file was added, false if the file already exists.
120120
/// The name and line offset must match exactly in that case.
121121
///
122-
/// \sa closeVirtualFile.
122+
/// \sa closeVirtualFile
123123
bool openVirtualFile(SourceLoc loc, StringRef name, int lineOffset);
124124

125-
/// Close a #line-defined virtual file region.
125+
/// Close a \c #sourceLocation-defined virtual file region.
126126
void closeVirtualFile(SourceLoc end);
127127

128128
/// Creates a copy of a \c MemoryBuffer and adds it to the \c SourceManager,
@@ -143,6 +143,11 @@ class SourceManager {
143143
/// Returns the identifier for the buffer with the given ID.
144144
///
145145
/// \p BufferID must be a valid buffer ID.
146+
///
147+
/// This should not be used for displaying information about the \e contents
148+
/// of a buffer, since lines within the buffer may be marked as coming from
149+
/// other files using \c #sourceLocation. Use #getDisplayNameForLoc instead
150+
/// in that case.
146151
StringRef getIdentifierForBuffer(unsigned BufferID) const;
147152

148153
/// \brief Returns a SourceRange covering the entire specified buffer.
@@ -175,26 +180,16 @@ class SourceManager {
175180
/// Returns a buffer identifier suitable for display to the user containing
176181
/// the given source location.
177182
///
178-
/// This respects #line directives and the 'use-external-names' directive in
179-
/// VFS overlay files.
183+
/// This respects \c #sourceLocation directives and the 'use-external-names'
184+
/// directive in VFS overlay files. If you need an on-disk file name, use
185+
/// #getIdentifierForBuffer instead.
180186
StringRef getDisplayNameForLoc(SourceLoc Loc) const;
181187

182-
/// Returns the identifier string for the buffer containing the given source
183-
/// location.
184-
///
185-
/// This respects #line directives.
186-
StringRef getBufferIdentifierForLoc(SourceLoc Loc) const {
187-
if (auto VFile = getVirtualFile(Loc))
188-
return VFile->Name;
189-
else
190-
return getIdentifierForBuffer(findBufferContainingLoc(Loc));
191-
}
192-
193188
/// Returns the line and column represented by the given source location.
194189
///
195190
/// If \p BufferID is provided, \p Loc must come from that source buffer.
196191
///
197-
/// This respects #line directives.
192+
/// This respects \c #sourceLocation directives.
198193
std::pair<unsigned, unsigned>
199194
getLineAndColumn(SourceLoc Loc, unsigned BufferID = 0) const {
200195
assert(Loc.isValid());
@@ -209,7 +204,7 @@ class SourceManager {
209204
///
210205
/// If \p BufferID is provided, \p Loc must come from that source buffer.
211206
///
212-
/// This does not respect #line directives.
207+
/// This does not respect \c #sourceLocation directives.
213208
unsigned getLineNumber(SourceLoc Loc, unsigned BufferID = 0) const {
214209
assert(Loc.isValid());
215210
return LLVMSourceMgr.FindLineNumber(Loc.Value, BufferID);

lib/IDE/CommentConversion.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ void CommentToXMLConverter::visitDocComment(const DocComment *DC) {
317317
auto Loc = D->getLoc();
318318
if (Loc.isValid()) {
319319
const auto &SM = D->getASTContext().SourceMgr;
320-
unsigned BufferID = SM.findBufferContainingLoc(Loc);
321-
StringRef FileName = SM.getIdentifierForBuffer(BufferID);
320+
StringRef FileName = SM.getDisplayNameForLoc(Loc);
322321
auto LineAndColumn = SM.getLineAndColumn(Loc);
323322
OS << " file=\"";
324323
appendWithXMLEscaping(OS, FileName);

lib/IDE/Utils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,7 @@ class ClangFileRewriterHelper {
904904
}
905905

906906
void replaceText(SourceManager &SM, CharSourceRange Range, StringRef Text) {
907-
auto BufferId = SM.getIDForBufferIdentifier(SM.
908-
getBufferIdentifierForLoc(Range.getStart())).getValue();
907+
auto BufferId = SM.findBufferContainingLoc(Range.getStart());
909908
if (BufferId == InterestedId) {
910909
HasChange = true;
911910
auto StartLoc = SM.getLocOffsetInBuffer(Range.getStart(), BufferId);

lib/Parse/Lexer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,12 +2579,11 @@ static const char *findStartOfLine(const char *bufStart, const char *current) {
25792579
}
25802580

25812581
SourceLoc Lexer::getLocForStartOfToken(SourceManager &SM, SourceLoc Loc) {
2582-
Optional<unsigned> BufferIdOp = SM.getIDForBufferIdentifier(SM.
2583-
getBufferIdentifierForLoc(Loc));
2584-
if (!BufferIdOp.hasValue())
2582+
if (!Loc.isValid())
25852583
return SourceLoc();
2586-
return getLocForStartOfToken(SM, BufferIdOp.getValue(),
2587-
SM.getLocOffsetInBuffer(Loc, BufferIdOp.getValue()));
2584+
unsigned BufferId = SM.findBufferContainingLoc(Loc);
2585+
return getLocForStartOfToken(SM, BufferId,
2586+
SM.getLocOffsetInBuffer(Loc, BufferId));
25882587
}
25892588

25902589
SourceLoc Lexer::getLocForStartOfToken(SourceManager &SM, unsigned BufferID,

lib/SIL/OptimizationRemark.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,9 @@ template <> struct MappingTraits<SourceLoc> {
162162
assert(io.outputting() && "input not yet implemented");
163163

164164
SourceManager *SM = static_cast<SourceManager *>(io.getContext());
165-
unsigned BufferID = SM->findBufferContainingLoc(Loc);
166-
StringRef File = SM->getIdentifierForBuffer(BufferID);
165+
StringRef File = SM->getDisplayNameForLoc(Loc);
167166
unsigned Line, Col;
168-
std::tie(Line, Col) = SM->getLineAndColumn(Loc, BufferID);
167+
std::tie(Line, Col) = SM->getLineAndColumn(Loc);
169168

170169
io.mapRequired("File", File);
171170
io.mapRequired("Line", Line);

lib/SILGen/SILGenConvert.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ auto SILGenFunction::emitSourceLocationArgs(SourceLoc sourceLoc,
144144
unsigned line = 0;
145145
unsigned column = 0;
146146
if (sourceLoc.isValid()) {
147-
unsigned bufferID = ctx.SourceMgr.findBufferContainingLoc(sourceLoc);
148-
filename = ctx.SourceMgr.getIdentifierForBuffer(bufferID);
147+
filename = ctx.SourceMgr.getDisplayNameForLoc(sourceLoc);
149148
std::tie(line, column) = ctx.SourceMgr.getLineAndColumn(sourceLoc);
150149
}
151150

test/Driver/opt-record.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,38 @@
88

99
var a: Int = 1
1010

11+
#sourceLocation(file: "custom.swuft", line: 2000)
1112
func foo() {
1213
a = 2
1314
}
15+
#sourceLocation() // reset
1416

1517
public func bar() {
18+
foo()
1619
// YAML: --- !Passed
1720
// YAML-NEXT: Pass: sil-inliner
1821
// YAML-NEXT: Name: sil.Inlined
1922
// YAML-NEXT: DebugLoc:
2023
// YAML-NEXT: File: {{.*}}opt-record.swift
21-
// YAML-NEXT: Line: 42
24+
// YAML-NEXT: Line: [[@LINE-6]]
2225
// YAML-NEXT: Column: 3
2326
// YAML-NEXT: Function: 'bar()'
2427
// YAML-NEXT: Args:
2528
// YAML-NEXT: - Callee: '"optrecordmod.foo()"'
2629
// YAML-NEXT: DebugLoc:
27-
// YAML-NEXT: File: {{.*}}opt-record.swift
28-
// YAML-NEXT: Line: 11
30+
// YAML-NEXT: File: custom.swuft
31+
// YAML-NEXT: Line: 2000
2932
// YAML-NEXT: Column: 6
3033
// YAML-NEXT: - String: ' inlined into '
3134
// YAML-NEXT: - Caller: '"optrecordmod.bar()"'
3235
// YAML-NEXT: DebugLoc:
3336
// YAML-NEXT: File: {{.*}}opt-record.swift
34-
// YAML-NEXT: Line: 15
37+
// YAML-NEXT: Line: [[@LINE-20]]
3538
// YAML-NEXT: Column: 13
3639
// YAML-NEXT: - String: ' (cost = '
3740
// YAML-NEXT: - Cost: '{{.*}}'
3841
// YAML-NEXT: - String: ', benefit = '
3942
// YAML-NEXT: - Benefit: '{{.*}}'
4043
// YAML-NEXT: - String: ')'
4144
// YAML-NEXT: ...
42-
foo()
4345
}

test/IDE/comment_attach.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ func weirdBlockDocComment() {}
216216
// ###line 1010
217217
func docCommentWithGybLineNumber() {}
218218

219+
#sourceLocation(file: "custom.swuft", line: 2000)
220+
/// Oooh, custom!
221+
func customSourceLocation() {}
222+
#sourceLocation() // reset
223+
219224
/**
220225
func unterminatedBlockDocComment() {}
221226

@@ -307,3 +312,4 @@ func unterminatedBlockDocComment() {}
307312
// CHECK-NEXT: comment_attach.swift:207:6: Func/emptyBlockDocComment RawComment=[/***/]
308313
// CHECK-NEXT: comment_attach.swift:210:6: Func/weirdBlockDocComment RawComment=[/**/]
309314
// CHECK-NEXT: comment_attach.swift:217:6: Func/docCommentWithGybLineNumber RawComment=[/// docCommentWithGybLineNumber Aaa.\n/// Bbb.\n/// Ccc.\n]
315+
// CHECK-NEXT: custom.swuft:2001:6: Func/customSourceLocation RawComment=[/// Oooh, custom!\n]

test/Inputs/comment_to_something_conversion.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,10 @@ public func localizationKeyShouldNotAppearInDocComments2() {}
492492
/// - TAG: TAG_C
493493
public func tags() {}
494494
// CHECK: DocCommentAsXML=[<Function file="{{.*}}" line="{{.*}}" column="{{.*}}"><Name>tags()</Name><USR>s:14comment_to_xml4tagsyyF</USR><Declaration>public func tags()</Declaration><CommentParts><Abstract><Para>Brief.</Para></Abstract><Tags><Tag>Tag_A</Tag><Tag>Tag B</Tag><Tag>Dedupe tag</Tag><Tag>TAG_C</Tag></Tags><Discussion><Para>Intentional break</Para></Discussion></CommentParts></Function>]
495+
496+
497+
#sourceLocation(file: "custom.swuft", line: 20)
498+
/// Oooh, custom!
499+
public func customLocation() {}
500+
// CHECK: DocCommentAsXML=[<Function file="custom.swuft" line="21" column="{{.*}}"><Name>customLocation()</Name><USR>s:14comment_to_xml14customLocationyyF</USR><Declaration>public func customLocation()</Declaration><CommentParts><Abstract><Para>Oooh, custom!</Para></Abstract></CommentParts></Function>]
501+
#sourceLocation() // reset

test/SILGen/optional.swift

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func crash_on_dealloc(_ dict : [Int : [Int]] = [:]) {
107107
func use_unwrapped(_: Int) {}
108108

109109
// CHECK-LABEL: sil hidden @$S8optional15explicit_unwrap{{[_0-9a-zA-Z]*}}F
110-
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "
110+
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "{{.*}}optional.swift"
111111
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
112112
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
113113
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
@@ -120,7 +120,7 @@ func explicit_unwrap(_ value: Int?) {
120120
}
121121

122122
// CHECK-LABEL: sil hidden @$S8optional19explicit_iuo_unwrap{{[_0-9a-zA-Z]*}}F
123-
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "
123+
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "{{.*}}optional.swift"
124124
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
125125
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
126126
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
@@ -133,7 +133,7 @@ func explicit_iuo_unwrap(_ value: Int!) {
133133
}
134134

135135
// CHECK-LABEL: sil hidden @$S8optional19implicit_iuo_unwrap{{[_0-9a-zA-Z]*}}F
136-
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "
136+
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "{{.*}}optional.swift"
137137
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
138138
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
139139
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
@@ -144,3 +144,18 @@ func explicit_iuo_unwrap(_ value: Int!) {
144144
func implicit_iuo_unwrap(_ value: Int!) {
145145
use_unwrapped(value)
146146
}
147+
148+
// CHECK-LABEL: sil hidden @$S8optional34implicit_iuo_unwrap_sourceLocation{{[_0-9a-zA-Z]*}}F
149+
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "custom.swuft"
150+
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
151+
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
152+
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word, 2000
153+
// CHECK-NEXT: [[COLUMN:%.*]] = integer_literal $Builtin.Word,
154+
// CHECK-NEXT: [[IMPLICIT:%.*]] = integer_literal $Builtin.Int1, -1
155+
// CHECK: [[PRECOND:%.*]] = function_ref @$Ss30_diagnoseUnexpectedNilOptional{{[_0-9a-zA-Z]*}}F
156+
// CHECK: apply [[PRECOND]]([[FILESTR]], [[FILESIZ]], [[FILEASC]], [[LINE]], [[IMPLICIT]])
157+
func implicit_iuo_unwrap_sourceLocation(_ value: Int!) {
158+
#sourceLocation(file: "custom.swuft", line: 2000)
159+
use_unwrapped(value)
160+
#sourceLocation() // reset
161+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#sourceLocation(file: "custom.swuft", line: 2000)
2+
func 1() {}
3+
#sourceLocation() // reset

test/SourceKit/CompileNotifications/diagnostics.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
// PARSE-NEXT: }
1818
// PARSE-NEXT: ]
1919

20+
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %S/Inputs/parse-error-with-sourceLocation.swift -- %S/Inputs/parse-error-with-sourceLocation.swift | %FileCheck %s -check-prefix=PARSE-WITH-SOURCELOCATION
21+
// PARSE-WITH-SOURCELOCATION: key.notification: source.notification.compile-did-finish
22+
// PARSE-WITH-SOURCELOCATION-NEXT: key.diagnostics: [
23+
// PARSE-WITH-SOURCELOCATION-NEXT: {
24+
// PARSE-WITH-SOURCELOCATION-NEXT: key.line: 2000
25+
// PARSE-WITH-SOURCELOCATION-NEXT: key.column: 6
26+
// PARSE-WITH-SOURCELOCATION-NEXT: key.filepath: "custom.swuft"
27+
// PARSE-WITH-SOURCELOCATION-NEXT: key.severity: source.diagnostic.severity.error
28+
// PARSE-WITH-SOURCELOCATION-NEXT: key.description: "function name
29+
// PARSE-WITH-SOURCELOCATION-NEXT: }
30+
// PARSE-WITH-SOURCELOCATION-NEXT: ]
31+
2032
// Diagnostic from other file.
2133
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %s -- %s %S/Inputs/parse-error.swift | %FileCheck %s -check-prefix=PARSE
2234

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
func simpleParams(a: Int, b theB: Int) {}
2+
3+
struct AccessorTest {
4+
subscript(a: Int, b theB: Int) -> Int { return a }
5+
var prop: Int {
6+
get { return 0 }
7+
set(v) {}
8+
}
9+
}
10+
11+
#sourceLocation(file: "custom.swuft", line: 2000)
12+
func customSourceLocation(a: Int) {}
13+
#sourceLocation()
14+
15+
// RUN: %sourcekitd-test -req=cursor -pos=1:19 %s -- %s | %FileCheck -check-prefix=CHECK-FUNC-A %s
16+
// CHECK-FUNC-A: s:17cursor_info_param12simpleParams1a1bySi_SitFACL_Sivp
17+
// CHECK-FUNC-A: PARENT OFFSET: 5
18+
19+
// RUN: %sourcekitd-test -req=cursor -pos=1:27 %s -- %s | %FileCheck -check-prefix=CHECK-FUNC-B %s
20+
// CHECK-FUNC-B: s:17cursor_info_param12simpleParams1a1bySi_SitF{{$}}
21+
22+
// RUN: %sourcekitd-test -req=cursor -pos=1:29 %s -- %s | %FileCheck -check-prefix=CHECK-FUNC-THEB %s
23+
// CHECK-FUNC-THEB: s:17cursor_info_param12simpleParams1a1bySi_SitF4theBL_Sivp
24+
// CHECK-FUNC-THEB-NOT: PARENT OFFSET
25+
26+
// RUN: %sourcekitd-test -req=cursor -pos=4:13 %s -- %s | %FileCheck -check-prefix=CHECK-SUBSCRIPT-A %s
27+
// FIXME: This USR is wrong; see https://bugs.swift.org/browse/SR-8660.
28+
// CHECK-SUBSCRIPT-A: s:17cursor_info_param12AccessorTestV1aL_Sivp
29+
// CHECK-SUBSCRIPT-A: PARENT OFFSET: 67
30+
31+
// RUN: %sourcekitd-test -req=cursor -pos=4:21 %s -- %s | %FileCheck -check-prefix=CHECK-SUBSCRIPT-B %s
32+
// CHECK-SUBSCRIPT-B: s:17cursor_info_param12AccessorTestV
33+
34+
// RUN: %sourcekitd-test -req=cursor -pos=4:23 %s -- %s | %FileCheck -check-prefix=CHECK-SUBSCRIPT-THEB %s
35+
// FIXME: This USR is wrong; see https://bugs.swift.org/browse/SR-8660.
36+
// CHECK-SUBSCRIPT-THEB: s:17cursor_info_param12AccessorTestV4theBL_Sivp
37+
// CHECK-SUBSCRIPT-THEB-NOT: PARENT OFFSET
38+
39+
// RUN: %sourcekitd-test -req=cursor -pos=7:9 %s -- %s | %FileCheck -check-prefix=CHECK-SETTER-V %s
40+
// CHECK-SETTER-V: s:17cursor_info_param12AccessorTestV4propSivs1vL_Sivp
41+
// CHECK-SETTER-V: PARENT OFFSET: 161
42+
43+
// RUN: %sourcekitd-test -req=cursor -pos=12:27 %s -- %s | %FileCheck -check-prefix=CHECK-CUSTOM-SOURCELOCATION %s
44+
// CHECK-CUSTOM-SOURCELOCATION: s:17cursor_info_param20customSourceLocation1aySi_tFACL_Sivp
45+
// CHECK-CUSTOM-SOURCELOCATION: PARENT OFFSET: 233

tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void EditorDiagConsumer::handleDiagnostic(
146146

147147
SKInfo.Offset = SM.getLocOffsetInBuffer(Loc, BufferID);
148148
std::tie(SKInfo.Line, SKInfo.Column) = SM.getLineAndColumn(Loc, BufferID);
149-
SKInfo.Filename = SM.getIdentifierForBuffer(BufferID);
149+
SKInfo.Filename = SM.getDisplayNameForLoc(Loc);
150150

151151
for (auto R : Info.Ranges) {
152152
if (R.isInvalid() || SM.findBufferContainingLoc(R.getStart()) != BufferID)

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,7 @@ getParamParentNameOffset(const ValueDecl *VD, SourceLoc Cursor) {
684684
if (Loc.isInvalid())
685685
return None;
686686
auto &SM = VD->getASTContext().SourceMgr;
687-
return SM.getLocOffsetInBuffer(Loc, SM.getIDForBufferIdentifier(SM.
688-
getBufferIdentifierForLoc(Loc)).getValue());
687+
return SM.getLocOffsetInBuffer(Loc, SM.findBufferContainingLoc(Loc));
689688
}
690689

691690
/// Returns true for failure to resolve.

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,11 +2147,6 @@ class ASTCommentPrinter : public ASTWalker {
21472147
ASTCommentPrinter(SourceManager &SM, XMLValidator &TheXMLValidator)
21482148
: OS(llvm::outs()), SM(SM), TheXMLValidator(TheXMLValidator) {}
21492149

2150-
StringRef getBufferIdentifier(SourceLoc Loc) {
2151-
unsigned BufferID = SM.findBufferContainingLoc(Loc);
2152-
return SM.getIdentifierForBuffer(BufferID);
2153-
}
2154-
21552150
void printWithEscaping(StringRef Str) {
21562151
for (char C : Str) {
21572152
switch (C) {
@@ -2290,7 +2285,7 @@ class ASTCommentPrinter : public ASTWalker {
22902285
SourceLoc Loc = D->getLoc();
22912286
if (Loc.isValid()) {
22922287
auto LineAndColumn = SM.getLineAndColumn(Loc);
2293-
OS << getBufferIdentifier(VD->getLoc())
2288+
OS << SM.getDisplayNameForLoc(VD->getLoc())
22942289
<< ":" << LineAndColumn.first << ":" << LineAndColumn.second << ": ";
22952290
}
22962291
OS << Decl::getKindName(VD->getKind()) << "/";
@@ -2307,7 +2302,7 @@ class ASTCommentPrinter : public ASTWalker {
23072302
SourceLoc Loc = D->getLoc();
23082303
if (Loc.isValid()) {
23092304
auto LineAndColumn = SM.getLineAndColumn(Loc);
2310-
OS << getBufferIdentifier(D->getLoc())
2305+
OS << SM.getDisplayNameForLoc(D->getLoc())
23112306
<< ":" << LineAndColumn.first << ":" << LineAndColumn.second << ": ";
23122307
}
23132308
OS << Decl::getKindName(D->getKind()) << "/";

0 commit comments

Comments
 (0)