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 {
7171
7272 // / The name of the source file on disk that was created to hold the
7373 // / contents of this file for external clients.
74- StringRef onDiskBufferCopyFileName = StringRef();
74+ mutable StringRef onDiskBufferCopyFileName = StringRef();
7575
7676 // / Contains the ancestors of this source buffer, starting with the root source
7777 // / buffer and ending at this source buffer.
@@ -209,8 +209,7 @@ class SourceManager {
209209 bool hasGeneratedSourceInfo (unsigned bufferID);
210210
211211 // / 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 ;
214213
215214 // / Retrieve the list of ancestors of the given source buffer, starting with
216215 // / 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 {
906906
907907 SourceLoc startLoc = loc;
908908 unsigned startBufferID = bufferID;
909- while (std::optional< GeneratedSourceInfo> info =
909+ while (const GeneratedSourceInfo * info =
910910 SM.getGeneratedSourceInfo (bufferID)) {
911911 switch (info->kind ) {
912912#define MACRO_ROLE (Name, Description ) \
Original file line number Diff line number Diff line change @@ -287,7 +287,8 @@ StringRef SourceManager::getIdentifierForBuffer(
287287 // If this is generated source code, and we're supposed to force it to disk
288288 // so external clients can see it, do so now.
289289 if (ForceGeneratedSourceToDisk) {
290- if (auto generatedInfo = getGeneratedSourceInfo (bufferID)) {
290+ if (const GeneratedSourceInfo *generatedInfo =
291+ getGeneratedSourceInfo (bufferID)) {
291292 // We only care about macros, so skip everything else.
292293 if (generatedInfo->kind == GeneratedSourceInfo::ReplacedFunctionBody ||
293294 generatedInfo->kind == GeneratedSourceInfo::PrettyPrinted ||
@@ -402,12 +403,12 @@ bool SourceManager::hasGeneratedSourceInfo(unsigned bufferID) {
402403 return GeneratedSourceInfos.count (bufferID);
403404}
404405
405- std::optional< GeneratedSourceInfo>
406+ const GeneratedSourceInfo *
406407SourceManager::getGeneratedSourceInfo (unsigned bufferID) const {
407408 auto known = GeneratedSourceInfos.find (bufferID);
408409 if (known == GeneratedSourceInfos.end ())
409- return std:: nullopt ;
410- return known->second ;
410+ return nullptr ;
411+ return & known->second ;
411412}
412413
413414namespace {
Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ static DeclContext *getInnermostFunctionContext(DeclContext *DC) {
284284}
285285
286286// / Return location of the macro expansion and the macro name.
287- static MacroInfo getMacroInfo (GeneratedSourceInfo &Info,
287+ static MacroInfo getMacroInfo (const GeneratedSourceInfo &Info,
288288 DeclContext *FunctionDC) {
289289 MacroInfo Result (Info.generatedSourceRange .getStart (),
290290 Info.originalSourceRange .getStart ());
You can’t perform that action at this time.
0 commit comments