Use StringMap in EditorDiagConsumer

As noted by the comment, storing a `StringRef` is
indeed brittle. Update to use a StringMap.

rdar://111589090
This commit is contained in:
Hamish Knight
2023-09-15 18:27:49 +01:00
parent 2d37e5bd03
commit 746128c7aa
4 changed files with 11 additions and 12 deletions

View File

@@ -91,10 +91,6 @@ BufferInfoSharedPtr
EditorDiagConsumer::getBufferInfo(StringRef FileName,
llvm::Optional<unsigned> BufferID,
swift::SourceManager &SM) {
// NOTE: Using StringRef as a key here relies on SourceMgr using const char*
// as buffer identifiers. This is fast, but may be brittle. We can always
// switch over to using a StringMap. Note that the logic in
// SerializedDiagnosticConsumer::getEmitFile will also need changing.
auto Result = BufferInfos.find(FileName);
if (Result != BufferInfos.end())
return Result->second;