diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-02-11 02:19:13 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-02-11 02:19:13 +0000 |
commit | 1e37765c9257ef1d051f54a674eaa964bdba9693 (patch) | |
tree | c52fc41c38bd124445be4f69a46e298dbede75df /lib/Parse/Parser.cpp | |
parent | 75042398c34413594a9f5f56f5f3761ea37fd2d0 (diff) |
Clean up ownership of 'AttributeList' objects in Parser. Apparently
we would just leak them all over the place, with no clear ownership of
these objects at all. AttributeList objects would get leaked on both
error and non-error paths.
Note: I introduced the usage of llvm::OwningPtr<AttributeList> to
manage these objects, which is particularly useful for methods with
multiple return sites. In at least one method I used them even when
they weren't strictly necessary because it clarified the ownership
semantics and made the code easier to read. Should the excessive
'take()' and 'reset()' calls become a performance issue we can always
re-evaluate.
Note+1: I believe I have not introduced any double-frees, but it would
be nice for someone to review this.
This fixes <rdar://problem/7635046>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95847 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r-- | lib/Parse/Parser.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index e5bed3096d..30899c5ddd 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -742,11 +742,11 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { // Handle the full declarator list. while (1) { - Action::AttrTy *AttrList; // If attributes are present, parse them. + llvm::OwningPtr<AttributeList> AttrList; if (Tok.is(tok::kw___attribute)) // FIXME: attach attributes too. - AttrList = ParseGNUAttributes(); + AttrList.reset(ParseGNUAttributes()); // Ask the actions module to compute the type for this declarator. Action::DeclPtrTy Param = |