mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Frontend: set up output file .swiftsourceinfo
This patch will focus on teaching driver and frontend to emit this file. The actual content and de-serialization parts will come later. More details: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794
This commit is contained in:
@@ -4738,6 +4738,7 @@ void swift::serializeToBuffers(
|
||||
ModuleOrSourceFile DC, const SerializationOptions &options,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
|
||||
const SILModule *M) {
|
||||
|
||||
assert(!StringRef::withNullAsEmpty(options.OutputPath).empty());
|
||||
@@ -4774,6 +4775,22 @@ void swift::serializeToBuffers(
|
||||
*moduleDocBuffer = llvm::make_unique<llvm::SmallVectorMemoryBuffer>(
|
||||
std::move(buf), options.DocOutputPath);
|
||||
}
|
||||
|
||||
if (!StringRef::withNullAsEmpty(options.SourceInfoOutputPath).empty()) {
|
||||
SharedTimer timer("Serialization, swiftsourceinfo, to buffer");
|
||||
llvm::SmallString<1024> buf;
|
||||
llvm::raw_svector_ostream stream(buf);
|
||||
writeSourceInfoToStream(stream, DC);
|
||||
(void)withOutputFile(getContext(DC).Diags,
|
||||
options.SourceInfoOutputPath,
|
||||
[&](raw_ostream &out) {
|
||||
out << stream.str();
|
||||
return false;
|
||||
});
|
||||
if (moduleSourceInfoBuffer)
|
||||
*moduleSourceInfoBuffer = llvm::make_unique<llvm::SmallVectorMemoryBuffer>(
|
||||
std::move(buf), options.SourceInfoOutputPath);
|
||||
}
|
||||
}
|
||||
|
||||
void swift::serialize(ModuleOrSourceFile DC,
|
||||
@@ -4807,4 +4824,14 @@ void swift::serialize(ModuleOrSourceFile DC,
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
if (!StringRef::withNullAsEmpty(options.SourceInfoOutputPath).empty()) {
|
||||
(void)withOutputFile(getContext(DC).Diags,
|
||||
options.SourceInfoOutputPath,
|
||||
[&](raw_ostream &out) {
|
||||
SharedTimer timer("Serialization, swiftsourceinfo");
|
||||
writeSourceInfoToStream(out, DC);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user