Skip to content

Commit 35a2c04

Browse files
committed
[Parser] Delete ASTContext of ParserUnit
This resolves a memory leak.
1 parent c78d2c2 commit 35a2c04

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
@@ -1011,6 +1011,13 @@ struct ParserUnit::Implementation {
10111011
Opts.CollectParsedToken,
10121012
Opts.BuildSyntaxTree)) {
10131013
}
1014+
1015+
~Implementation() {
1016+
// We need to delete the parser before the context so that it can finalize
1017+
// its SourceFileSyntax while it is still alive
1018+
TheParser.reset();
1019+
delete &Ctx;
1020+
}
10141021
};
10151022

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

0 commit comments

Comments
 (0)