]> granicus.if.org Git - clang/commit
Plug a long standing memory leak in TemplateArgument.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 7 Jun 2012 15:09:51 +0000 (15:09 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 7 Jun 2012 15:09:51 +0000 (15:09 +0000)
commit855243789cb44799c03f4c7216d3d6308805f549
treeddfaf2e09c5404dd1a1caa9447984cdc7382dd97
parent575b66a8e07984ff21c1d3ed0da704043b9390bd
Plug a long standing memory leak in TemplateArgument.

The integral APSInt value is now stored in a decomposed form and the backing
store for large values is allocated via the ASTContext. This way its not
leaked as TemplateArguments are never destructed when they are allocated in
the ASTContext. Since the integral data is immutable it is now shared between
instances, making copying TemplateArguments a trivial operation.

Currently getting the integral data out of a TemplateArgument requires creating
a new APSInt object. This is cheap when the value is small but can be expensive
if it's not. If this turns out to be an issue a more efficient accessor could
be added.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158150 91177308-0d34-0410-b5e6-96231b3b80d8
17 files changed:
include/clang/AST/TemplateBase.h
include/clang/Sema/Template.h
lib/AST/ASTContext.cpp
lib/AST/ASTImporter.cpp
lib/AST/DumpXML.cpp
lib/AST/ItaniumMangle.cpp
lib/AST/MicrosoftMangle.cpp
lib/AST/StmtPrinter.cpp
lib/AST/StmtProfile.cpp
lib/AST/TemplateBase.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
tools/libclang/CIndexUSRs.cpp