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 @@ -75,7 +75,7 @@ class GeneratedSourceInfo {
7575
7676 // / The name of the source file on disk that was created to hold the
7777 // / contents of this file for external clients.
78- StringRef onDiskBufferCopyFileName = StringRef();
78+ mutable StringRef onDiskBufferCopyFileName = StringRef();
7979
8080 // / Contains the ancestors of this source buffer, starting with the root source
8181 // / buffer and ending at this source buffer.
@@ -213,8 +213,7 @@ class SourceManager {
213213 bool hasGeneratedSourceInfo (unsigned bufferID);
214214
215215 // / Retrieve the generated source information for the given buffer.
216- std::optional<GeneratedSourceInfo>
217- getGeneratedSourceInfo (unsigned bufferID) const ;
216+ const GeneratedSourceInfo *getGeneratedSourceInfo (unsigned bufferID) const ;
218217
219218 // / Retrieve the list of ancestors of the given source buffer, starting with
220219 // / 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 {
907907
908908 SourceLoc startLoc = loc;
909909 unsigned startBufferID = bufferID;
910- while (std::optional< GeneratedSourceInfo> info =
910+ while (const GeneratedSourceInfo * info =
911911 SM.getGeneratedSourceInfo (bufferID)) {
912912 switch (info->kind ) {
913913#define MACRO_ROLE (Name, Description ) \
Original file line number Diff line number Diff line change @@ -288,7 +288,8 @@ StringRef SourceManager::getIdentifierForBuffer(
288288 // If this is generated source code, and we're supposed to force it to disk
289289 // so external clients can see it, do so now.
290290 if (ForceGeneratedSourceToDisk) {
291- if (auto generatedInfo = getGeneratedSourceInfo (bufferID)) {
291+ if (const GeneratedSourceInfo *generatedInfo =
292+ getGeneratedSourceInfo (bufferID)) {
292293 // We only care about macros, so skip everything else.
293294 if (generatedInfo->kind == GeneratedSourceInfo::ReplacedFunctionBody ||
294295 generatedInfo->kind == GeneratedSourceInfo::PrettyPrinted ||
@@ -403,12 +404,12 @@ bool SourceManager::hasGeneratedSourceInfo(unsigned bufferID) {
403404 return GeneratedSourceInfos.count (bufferID);
404405}
405406
406- std::optional< GeneratedSourceInfo>
407+ const GeneratedSourceInfo *
407408SourceManager::getGeneratedSourceInfo (unsigned bufferID) const {
408409 auto known = GeneratedSourceInfos.find (bufferID);
409410 if (known == GeneratedSourceInfos.end ())
410- return std:: nullopt ;
411- return known->second ;
411+ return nullptr ;
412+ return & known->second ;
412413}
413414
414415namespace {
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ static DeclContext *getInnermostFunctionContext(DeclContext *DC) {
285285}
286286
287287// / Return location of the macro expansion and the macro name.
288- static MacroInfo getMacroInfo (GeneratedSourceInfo &Info,
288+ static MacroInfo getMacroInfo (const GeneratedSourceInfo &Info,
289289 DeclContext *FunctionDC) {
290290 MacroInfo Result (Info.generatedSourceRange .getStart (),
291291 Info.originalSourceRange .getStart ());
You can’t perform that action at this time.
0 commit comments