Skip to content

Commit

Permalink
Fix leaking of LexedMethod objects created for caching objc method de…
Browse files Browse the repository at this point in the history
…finitions tokens

for late parsing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145394 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
akyrtzi committed Nov 29, 2011
1 parent 7383550 commit 2fea224
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/clang/Parse/Parser.h
Expand Up @@ -402,6 +402,9 @@ class Parser : public CodeCompletionHandler {
Tok.setKind(tok::eof);
}

/// \brief Clear and free the cached objc methods.
void clearLateParsedObjCMethods();

/// \brief Handle the annotation token produced for #pragma unused(...)
void HandlePragmaUnused();

Expand Down
10 changes: 9 additions & 1 deletion lib/Parse/ParseObjc.cpp
Expand Up @@ -1500,7 +1500,7 @@ Parser::ParseObjCAtEndDeclaration(SourceRange atEnd) {
// missing @implementation
Diag(atEnd.getBegin(), diag::err_expected_implementation);

LateParsedObjCMethods.clear();
clearLateParsedObjCMethods();
ObjCImpDecl = 0;
return Actions.BuildDeclaratorGroup(
DeclsInGroup.data(), DeclsInGroup.size(), false);
Expand All @@ -1515,6 +1515,14 @@ Parser::DeclGroupPtrTy Parser::FinishPendingObjCActions() {
return Actions.ConvertDeclToDeclGroup(ImpDecl);
}

void Parser::clearLateParsedObjCMethods() {
for (LateParsedObjCMethodContainer::iterator
I = LateParsedObjCMethods.begin(),
E = LateParsedObjCMethods.end(); I != E; ++I)
delete *I;
LateParsedObjCMethods.clear();
}

/// compatibility-alias-decl:
/// @compatibility_alias alias-name class-name ';'
///
Expand Down
2 changes: 2 additions & 0 deletions lib/Parse/Parser.cpp
Expand Up @@ -370,6 +370,8 @@ Parser::~Parser() {
it != LateParsedTemplateMap.end(); ++it)
delete it->second;

clearLateParsedObjCMethods();

// Remove the pragma handlers we installed.
PP.RemovePragmaHandler(AlignHandler.get());
AlignHandler.reset();
Expand Down

0 comments on commit 2fea224

Please sign in to comment.