Skip to content

Commit 05ae109

Browse files
committed
[Parser] Delete ASTContext of ParserUnit
This resolves a memory leak.
1 parent e5c8440 commit 05ae109

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Parse/Parser.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,13 @@ struct ParserUnit::Implementation {
10161016
Opts.CollectParsedToken,
10171017
Opts.BuildSyntaxTree)) {
10181018
}
1019+
1020+
~Implementation() {
1021+
// We need to delete the parser before the context so that it can finalize
1022+
// its SourceFileSyntax while it is still alive
1023+
TheParser.reset();
1024+
delete &Ctx;
1025+
}
10191026
};
10201027

10211028
ParserUnit::ParserUnit(SourceManager &SM, unsigned BufferID)

0 commit comments

Comments
 (0)