]> granicus.if.org Git - clang/commitdiff
Don't allocate unused storage for captures/capture initializers in lambda expressions
authorDouglas Gregor <dgregor@apple.com>
Mon, 13 Feb 2012 15:51:35 +0000 (15:51 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 13 Feb 2012 15:51:35 +0000 (15:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150394 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprCXX.cpp

index 29ff69d31237c4f624d95cd78034d79fbca33727..1f8a57a4e353bedeff356107a0104dafcf09ab65 100644 (file)
@@ -781,13 +781,10 @@ LambdaExpr *LambdaExpr::Create(ASTContext &Context,
   // Determine the type of the expression (i.e., the type of the
   // function object we're creating).
   QualType T = Context.getTypeDeclType(Class);
-  size_t Size = sizeof(LambdaExpr) + sizeof(Capture) * Captures.size()
-              + sizeof(Stmt *) * (Captures.size() + 1);
 
-  void *Mem = Context.Allocate(Size, llvm::alignOf<LambdaExpr>());
-  return new (Mem) LambdaExpr(T, IntroducerRange, CaptureDefault, 
-                              Captures, ExplicitParams, CaptureInits,
-                              ClosingBrace);
+  return new (Context) LambdaExpr(T, IntroducerRange, CaptureDefault, 
+                                  Captures, ExplicitParams, CaptureInits,
+                                  ClosingBrace);
 }
 
 LambdaExpr::capture_iterator LambdaExpr::capture_begin() const {