]> granicus.if.org Git - clang/commitdiff
Fix misaligned allocation of TemplateParameterList objects.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 16 Aug 2012 22:51:34 +0000 (22:51 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 16 Aug 2012 22:51:34 +0000 (22:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162056 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclTemplate.cpp

index 5aebc2b764c012a669dac265d74fc28c3dd25f61..a7e89994afe847caeb87b1d0cf2884b2c5f99796 100644 (file)
@@ -43,7 +43,8 @@ TemplateParameterList::Create(const ASTContext &C, SourceLocation TemplateLoc,
                               unsigned NumParams, SourceLocation RAngleLoc) {
   unsigned Size = sizeof(TemplateParameterList) 
                 + sizeof(NamedDecl *) * NumParams;
-  unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment;
+  unsigned Align = std::max(llvm::alignOf<TemplateParameterList>(),
+                            llvm::alignOf<NamedDecl*>());
   void *Mem = C.Allocate(Size, Align);
   return new (Mem) TemplateParameterList(TemplateLoc, LAngleLoc, Params,
                                          NumParams, RAngleLoc);