File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ class GeneratedSourceInfo {
71
71
72
72
// / The name of the source file on disk that was created to hold the
73
73
// / contents of this file for external clients.
74
- StringRef onDiskBufferCopyFileName = StringRef();
74
+ mutable StringRef onDiskBufferCopyFileName = StringRef();
75
75
76
76
// / Contains the ancestors of this source buffer, starting with the root source
77
77
// / buffer and ending at this source buffer.
@@ -209,8 +209,7 @@ class SourceManager {
209
209
bool hasGeneratedSourceInfo (unsigned bufferID);
210
210
211
211
// / Retrieve the generated source information for the given buffer.
212
- std::optional<GeneratedSourceInfo>
213
- getGeneratedSourceInfo (unsigned bufferID) const ;
212
+ const GeneratedSourceInfo *getGeneratedSourceInfo (unsigned bufferID) const ;
214
213
215
214
// / Retrieve the list of ancestors of the given source buffer, starting with
216
215
// / the root buffer and proceding to the given buffer ID at the end.
Original file line number Diff line number Diff line change @@ -907,7 +907,7 @@ ModuleDecl::getOriginalLocation(SourceLoc loc) const {
907
907
908
908
SourceLoc startLoc = loc;
909
909
unsigned startBufferID = bufferID;
910
- while (std::optional< GeneratedSourceInfo> info =
910
+ while (const GeneratedSourceInfo * info =
911
911
SM.getGeneratedSourceInfo (bufferID)) {
912
912
switch (info->kind ) {
913
913
#define MACRO_ROLE (Name, Description ) \
Original file line number Diff line number Diff line change @@ -288,7 +288,8 @@ StringRef SourceManager::getIdentifierForBuffer(
288
288
// If this is generated source code, and we're supposed to force it to disk
289
289
// so external clients can see it, do so now.
290
290
if (ForceGeneratedSourceToDisk) {
291
- if (auto generatedInfo = getGeneratedSourceInfo (bufferID)) {
291
+ if (const GeneratedSourceInfo *generatedInfo =
292
+ getGeneratedSourceInfo (bufferID)) {
292
293
// We only care about macros, so skip everything else.
293
294
if (generatedInfo->kind == GeneratedSourceInfo::ReplacedFunctionBody ||
294
295
generatedInfo->kind == GeneratedSourceInfo::PrettyPrinted ||
@@ -403,12 +404,12 @@ bool SourceManager::hasGeneratedSourceInfo(unsigned bufferID) {
403
404
return GeneratedSourceInfos.count (bufferID);
404
405
}
405
406
406
- std::optional< GeneratedSourceInfo>
407
+ const GeneratedSourceInfo *
407
408
SourceManager::getGeneratedSourceInfo (unsigned bufferID) const {
408
409
auto known = GeneratedSourceInfos.find (bufferID);
409
410
if (known == GeneratedSourceInfos.end ())
410
- return std::nullopt ;
411
- return known->second ;
411
+ return nullptr ;
412
+ return & known->second ;
412
413
}
413
414
414
415
namespace {
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ static DeclContext *getInnermostFunctionContext(DeclContext *DC) {
285
285
}
286
286
287
287
// / Return location of the macro expansion and the macro name.
288
- static MacroInfo getMacroInfo (GeneratedSourceInfo &Info,
288
+ static MacroInfo getMacroInfo (const GeneratedSourceInfo &Info,
289
289
DeclContext *FunctionDC) {
290
290
MacroInfo Result (Info.generatedSourceRange .getStart (),
291
291
Info.originalSourceRange .getStart ());
You can’t perform that action at this time.
0 commit comments