mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Basic] Don't rewrite source buffer copy multiple times
The on-disc buffer file name was not recorded correctly. rdar://130478685
This commit is contained in:
@@ -288,7 +288,8 @@ StringRef SourceManager::getIdentifierForBuffer(
|
||||
// If this is generated source code, and we're supposed to force it to disk
|
||||
// so external clients can see it, do so now.
|
||||
if (ForceGeneratedSourceToDisk) {
|
||||
if (auto generatedInfo = getGeneratedSourceInfo(bufferID)) {
|
||||
if (const GeneratedSourceInfo *generatedInfo =
|
||||
getGeneratedSourceInfo(bufferID)) {
|
||||
// We only care about macros, so skip everything else.
|
||||
if (generatedInfo->kind == GeneratedSourceInfo::ReplacedFunctionBody ||
|
||||
generatedInfo->kind == GeneratedSourceInfo::PrettyPrinted ||
|
||||
@@ -403,12 +404,12 @@ bool SourceManager::hasGeneratedSourceInfo(unsigned bufferID) {
|
||||
return GeneratedSourceInfos.count(bufferID);
|
||||
}
|
||||
|
||||
std::optional<GeneratedSourceInfo>
|
||||
const GeneratedSourceInfo *
|
||||
SourceManager::getGeneratedSourceInfo(unsigned bufferID) const {
|
||||
auto known = GeneratedSourceInfos.find(bufferID);
|
||||
if (known == GeneratedSourceInfos.end())
|
||||
return std::nullopt;
|
||||
return known->second;
|
||||
return nullptr;
|
||||
return &known->second;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
Reference in New Issue
Block a user