@@ -121,22 +121,14 @@ const char *ContentCache::getInvalidBOM(StringRef BufStr) {
121
121
llvm::Optional<llvm::MemoryBufferRef>
122
122
ContentCache::getBufferOrNone (DiagnosticsEngine &Diag, FileManager &FM,
123
123
SourceLocation Loc) const {
124
- if (auto *B = getBufferPointer (Diag, FM, Loc))
125
- return B->getMemBufferRef ();
126
- return None;
127
- }
128
-
129
- const llvm::MemoryBuffer *
130
- ContentCache::getBufferPointer (DiagnosticsEngine &Diag, FileManager &FM,
131
- SourceLocation Loc) const {
132
124
// Lazily create the Buffer for ContentCaches that wrap files. If we already
133
125
// computed it, just return what we have.
134
126
if (isBufferInvalid ())
135
- return nullptr ;
127
+ return None ;
136
128
if (auto *B = Buffer.getPointer ())
137
- return B;
129
+ return B-> getMemBufferRef () ;
138
130
if (!ContentsEntry)
139
- return nullptr ;
131
+ return None ;
140
132
141
133
// Check that the file's size fits in an 'unsigned' (with room for a
142
134
// past-the-end value). This is deeply regrettable, but various parts of
@@ -153,7 +145,7 @@ ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM,
153
145
<< ContentsEntry->getName ();
154
146
155
147
Buffer.setInt (Buffer.getInt () | InvalidFlag);
156
- return nullptr ;
148
+ return None ;
157
149
}
158
150
159
151
auto BufferOrError = FM.getBufferForFile (ContentsEntry, IsFileVolatile);
@@ -173,7 +165,7 @@ ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM,
173
165
<< ContentsEntry->getName () << BufferOrError.getError ().message ();
174
166
175
167
Buffer.setInt (Buffer.getInt () | InvalidFlag);
176
- return nullptr ;
168
+ return None ;
177
169
}
178
170
179
171
Buffer.setPointer (BufferOrError->release ());
@@ -189,7 +181,7 @@ ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM,
189
181
<< ContentsEntry->getName ();
190
182
191
183
Buffer.setInt (Buffer.getInt () | InvalidFlag);
192
- return nullptr ;
184
+ return None ;
193
185
}
194
186
195
187
// If the buffer is valid, check to see if it has a UTF Byte Order Mark
@@ -202,10 +194,10 @@ ContentCache::getBufferPointer(DiagnosticsEngine &Diag, FileManager &FM,
202
194
Diag.Report (Loc, diag::err_unsupported_bom)
203
195
<< InvalidBOM << ContentsEntry->getName ();
204
196
Buffer.setInt (Buffer.getInt () | InvalidFlag);
205
- return nullptr ;
197
+ return None ;
206
198
}
207
199
208
- return Buffer.getPointer ();
200
+ return Buffer.getPointer ()-> getMemBufferRef () ;
209
201
}
210
202
211
203
unsigned LineTableInfo::getLineTableFilenameID (StringRef Name) {
0 commit comments