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 @@ -906,7 +906,7 @@ ModuleDecl::getOriginalLocation(SourceLoc loc) const {
906
906
907
907
SourceLoc startLoc = loc;
908
908
unsigned startBufferID = bufferID;
909
- while (std::optional< GeneratedSourceInfo> info =
909
+ while (const GeneratedSourceInfo * info =
910
910
SM.getGeneratedSourceInfo (bufferID)) {
911
911
switch (info->kind ) {
912
912
#define MACRO_ROLE (Name, Description ) \
Original file line number Diff line number Diff line change @@ -287,7 +287,8 @@ StringRef SourceManager::getIdentifierForBuffer(
287
287
// If this is generated source code, and we're supposed to force it to disk
288
288
// so external clients can see it, do so now.
289
289
if (ForceGeneratedSourceToDisk) {
290
- if (auto generatedInfo = getGeneratedSourceInfo (bufferID)) {
290
+ if (const GeneratedSourceInfo *generatedInfo =
291
+ getGeneratedSourceInfo (bufferID)) {
291
292
// We only care about macros, so skip everything else.
292
293
if (generatedInfo->kind == GeneratedSourceInfo::ReplacedFunctionBody ||
293
294
generatedInfo->kind == GeneratedSourceInfo::PrettyPrinted ||
@@ -402,12 +403,12 @@ bool SourceManager::hasGeneratedSourceInfo(unsigned bufferID) {
402
403
return GeneratedSourceInfos.count (bufferID);
403
404
}
404
405
405
- std::optional< GeneratedSourceInfo>
406
+ const GeneratedSourceInfo *
406
407
SourceManager::getGeneratedSourceInfo (unsigned bufferID) const {
407
408
auto known = GeneratedSourceInfos.find (bufferID);
408
409
if (known == GeneratedSourceInfos.end ())
409
- return std::nullopt ;
410
- return known->second ;
410
+ return nullptr ;
411
+ return & known->second ;
411
412
}
412
413
413
414
namespace {
Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ static DeclContext *getInnermostFunctionContext(DeclContext *DC) {
284
284
}
285
285
286
286
// / Return location of the macro expansion and the macro name.
287
- static MacroInfo getMacroInfo (GeneratedSourceInfo &Info,
287
+ static MacroInfo getMacroInfo (const GeneratedSourceInfo &Info,
288
288
DeclContext *FunctionDC) {
289
289
MacroInfo Result (Info.generatedSourceRange .getStart (),
290
290
Info.originalSourceRange .getStart ());
You can’t perform that action at this time.
0 commit comments