Revert "Merge pull request #26937 from rintaro/syntaxparse-leakfix"

This reverts commit e49401bbca, reversing
changes made to bd222ad71c.
This commit is contained in:
Robert Widmann
2019-09-16 15:07:19 -07:00
parent f302da0f9b
commit 362b21926c
4 changed files with 32 additions and 25 deletions

View File

@@ -256,9 +256,17 @@ ParsedRawSyntaxNode SyntaxParsingContext::finalizeSourceFile() {
Layout[1] = std::move(Parts.back());
Parts = Parts.drop_back();
assert(llvm::all_of(Parts, [](const ParsedRawSyntaxNode& node) {
return node.getKind() == SyntaxKind::CodeBlockItem;
}) && "all top level element must be 'CodeBlockItem'");
for (auto RawNode : Parts) {
if (RawNode.getKind() != SyntaxKind::CodeBlockItem) {
// FIXME: Skip toplevel garbage nodes for now. we shouldn't emit them in
// the first place.
if (RawNode.isRecorded())
getSyntaxCreator().finalizeNode(RawNode.getOpaqueNode());
continue;
}
AllTopLevel.push_back(RawNode);
}
Layout[0] = Recorder.recordRawSyntax(SyntaxKind::CodeBlockItemList, Parts);