@@ -39,7 +39,7 @@ class SourceManager {
39
39
// / to speed up stats.
40
40
mutable llvm::StringMap<clang::vfs::Status> StatusCache;
41
41
42
- // #line directive handling.
42
+ // \c #sourceLocation directive handling.
43
43
struct VirtualFile {
44
44
CharSourceRange Range;
45
45
std::string Name;
@@ -112,17 +112,17 @@ class SourceManager {
112
112
// / Adds a memory buffer to the SourceManager, taking ownership of it.
113
113
unsigned addNewSourceBuffer (std::unique_ptr<llvm::MemoryBuffer> Buffer);
114
114
115
- // / Add a #line -defined virtual file region.
115
+ // / Add a \c #sourceLocation -defined virtual file region.
116
116
// /
117
117
// / By default, this region continues to the end of the buffer.
118
118
// /
119
119
// / \returns True if the new file was added, false if the file already exists.
120
120
// / The name and line offset must match exactly in that case.
121
121
// /
122
- // / \sa closeVirtualFile.
122
+ // / \sa closeVirtualFile
123
123
bool openVirtualFile (SourceLoc loc, StringRef name, int lineOffset);
124
124
125
- // / Close a #line -defined virtual file region.
125
+ // / Close a \c #sourceLocation -defined virtual file region.
126
126
void closeVirtualFile (SourceLoc end);
127
127
128
128
// / Creates a copy of a \c MemoryBuffer and adds it to the \c SourceManager,
@@ -143,6 +143,11 @@ class SourceManager {
143
143
// / Returns the identifier for the buffer with the given ID.
144
144
// /
145
145
// / \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.
146
151
StringRef getIdentifierForBuffer (unsigned BufferID) const ;
147
152
148
153
// / \brief Returns a SourceRange covering the entire specified buffer.
@@ -175,26 +180,16 @@ class SourceManager {
175
180
// / Returns a buffer identifier suitable for display to the user containing
176
181
// / the given source location.
177
182
// /
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.
180
186
StringRef getDisplayNameForLoc (SourceLoc Loc) const ;
181
187
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
-
193
188
// / Returns the line and column represented by the given source location.
194
189
// /
195
190
// / If \p BufferID is provided, \p Loc must come from that source buffer.
196
191
// /
197
- // / This respects #line directives.
192
+ // / This respects \c #sourceLocation directives.
198
193
std::pair<unsigned , unsigned >
199
194
getLineAndColumn (SourceLoc Loc, unsigned BufferID = 0 ) const {
200
195
assert (Loc.isValid ());
@@ -209,7 +204,7 @@ class SourceManager {
209
204
// /
210
205
// / If \p BufferID is provided, \p Loc must come from that source buffer.
211
206
// /
212
- // / This does not respect #line directives.
207
+ // / This does not respect \c #sourceLocation directives.
213
208
unsigned getLineNumber (SourceLoc Loc, unsigned BufferID = 0 ) const {
214
209
assert (Loc.isValid ());
215
210
return LLVMSourceMgr.FindLineNumber (Loc.Value , BufferID);
0 commit comments