mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[libSyntax] Make the ByteTree format forwards-compatible
This commit is contained in:
@@ -156,6 +156,15 @@ SerializeAsByteTree("serialize-byte-tree",
|
||||
"serialized in the ByteTree format instead "
|
||||
"of JSON."));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
AddByteTreeFields("add-bytetree-fields",
|
||||
llvm::cl::desc("If specified, further fields will be added "
|
||||
"to the syntax tree if it is serialized as a "
|
||||
"ByteTree. This is to test forward "
|
||||
"compatibility with future versions of "
|
||||
"SwiftSyntax that might add more fields to "
|
||||
"syntax nodes."));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
IncrementalSerialization("incremental-serialization",
|
||||
llvm::cl::desc("If specified, the serialized syntax "
|
||||
@@ -724,6 +733,9 @@ int doSerializeRawTree(const char *MainExecutablePath,
|
||||
llvm::BinaryStreamWriter Writer(Stream);
|
||||
std::map<void *, void *> UserInfo;
|
||||
UserInfo[swift::byteTree::UserInfoKeyReusedNodeIds] = &ReusedNodeIds;
|
||||
if (options::AddByteTreeFields) {
|
||||
UserInfo[swift::byteTree::UserInfoKeyAddInvalidFields] = (void *)true;
|
||||
}
|
||||
swift::byteTree::ByteTreeWriter::write(/*ProtocolVersion=*/1, Writer,
|
||||
*Root, UserInfo);
|
||||
auto OutputBufferOrError = llvm::FileOutputBuffer::create(
|
||||
|
||||
Reference in New Issue
Block a user