[cfe-commits] r110474 - /cfe/trunk/include/clang/AST/DeclTemplate.h

Ted Kremenek kremenek at apple.com
Fri Aug 6 14:12:58 PDT 2010


Author: kremenek
Date: Fri Aug  6 16:12:58 2010
New Revision: 110474

URL: http://llvm.org/viewvc/llvm-project?rev=110474&view=rev
Log:
Fix leaks of ExplicitSpecializationInfo objects by allocating them with 'new (ASTContext)' instead of 'new'.

Modified:
    cfe/trunk/include/clang/AST/DeclTemplate.h

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=110474&r1=110473&r2=110474&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Aug  6 16:12:58 2010
@@ -1367,7 +1367,8 @@
   /// \brief Sets the type of this specialization as it was written by
   /// the user. This will be a class template specialization type.
   void setTypeAsWritten(TypeSourceInfo *T) {
-    if (!ExplicitInfo) ExplicitInfo = new ExplicitSpecializationInfo;
+    if (!ExplicitInfo)
+      ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
     ExplicitInfo->TypeAsWritten = T;
   }
   /// \brief Gets the type of this specialization as it was written by
@@ -1382,13 +1383,15 @@
   }
   /// \brief Sets the location of the extern keyword.
   void setExternLoc(SourceLocation Loc) {
-    if (!ExplicitInfo) ExplicitInfo = new ExplicitSpecializationInfo;
+    if (!ExplicitInfo)
+      ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
     ExplicitInfo->ExternLoc = Loc;
   }
 
   /// \brief Sets the location of the template keyword.
   void setTemplateKeywordLoc(SourceLocation Loc) {
-    if (!ExplicitInfo) ExplicitInfo = new ExplicitSpecializationInfo;
+    if (!ExplicitInfo)
+      ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo;
     ExplicitInfo->TemplateKeywordLoc = Loc;
   }
   /// \brief Gets the location of the template keyword, if present.





More information about the cfe-commits mailing list