llvm-project/clang/lib/Parse
Ted Kremenek 5eec2b0bd3 Region-allocate all AttributeList objects from a factory object instead of manually managing them
using new/delete and OwningPtrs.  After memory profiling Clang, I witnessed periodic leaks of these
objects; digging deeper into the code, it was clear that our management of these objects was a mess.  The ownership rules were murky at best, and not always followed.  Worse, there are plenty of error paths where we could screw up.

This patch introduces AttributeList::Factory, which is a factory class that creates AttributeList
objects and then blows them away all at once.  While conceptually simple, most of the changes in
this patch just have to do with migrating over to the new interface.  Most of the changes have resulted in some nice simplifications.

This new strategy currently holds on to all AttributeList objects during the lifetime of the Parser
object.  This is easily tunable.  If we desire to have more bound the lifetime of AttributeList
objects more precisely, we can have the AttributeList::Factory object (in Parser) push/pop its
underlying allocator as we enter/leave key methods in the Parser.  This means that we get
simple memory management while still having the ability to finely control memory use if necessary.

Note that because AttributeList objects are now BumpPtrAllocated, we may reduce malloc() traffic
in many large files with attributes.

This fixes the leak reported in: <rdar://problem/8650003>

llvm-svn: 118675
2010-11-10 05:59:39 +00:00
..
CMakeLists.txt Revert "CMake: Update to use standard CMake dependency tracking facilities instead" 2010-09-13 23:54:41 +00:00
Makefile BUILD_ARCHIVE is the default for libraries, no need to set it. 2010-07-18 00:14:47 +00:00
ParseAST.cpp Remove Sema.h's dependency on DeclCXX.h. 2010-08-25 07:42:41 +00:00
ParseCXXInlineMethods.cpp Parse default arguments within member functions in source order, from 2010-10-12 16:25:54 +00:00
ParseDecl.cpp Region-allocate all AttributeList objects from a factory object instead of manually managing them 2010-11-10 05:59:39 +00:00
ParseDeclCXX.cpp Region-allocate all AttributeList objects from a factory object instead of manually managing them 2010-11-10 05:59:39 +00:00
ParseExpr.cpp Provide code completion for types after the '^' that starts a block 2010-10-18 21:34:55 +00:00
ParseExprCXX.cpp Make this error less specific but also less likely to cause confusion. Fixes 2010-11-03 17:52:57 +00:00
ParseInit.cpp Implement bracket insertion for Objective-C instance message sends as 2010-09-15 14:51:05 +00:00
ParseObjc.cpp Region-allocate all AttributeList objects from a factory object instead of manually managing them 2010-11-10 05:59:39 +00:00
ParsePragma.cpp When we parse a pragma, keep track of how that pragma was originally 2010-09-09 22:45:38 +00:00
ParsePragma.h When we parse a pragma, keep track of how that pragma was originally 2010-09-09 22:45:38 +00:00
ParseStmt.cpp Region-allocate all AttributeList objects from a factory object instead of manually managing them 2010-11-10 05:59:39 +00:00
ParseTemplate.cpp Diagnose attempst to template using declarations and using directives. 2010-11-10 02:40:36 +00:00
ParseTentative.cpp Teach the C++ simple-type-specifier parser and tentative parses about 2010-10-21 23:17:00 +00:00
Parser.cpp Add parsing support for Microsoft attributes. MS attributes will just be skipped and not inserted into the AST for now. 2010-10-11 12:59:39 +00:00
RAIIObjectsForParser.h Implement bracket insertion for Objective-C instance message sends as 2010-09-15 14:51:05 +00:00