From: Alexey Samsonov Date: Thu, 28 Aug 2014 22:59:39 +0000 (+0000) Subject: Properly align inline space for ImplicitConversionSequences in OverloadSet. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3148d46ee3ce39ca1cedd189586c31ed922cdc21;p=clang Properly align inline space for ImplicitConversionSequences in OverloadSet. This bug was reported by UBSan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216694 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h index 7c221a2336..b04b996b7f 100644 --- a/include/clang/Sema/Overload.h +++ b/include/clang/Sema/Overload.h @@ -25,6 +25,7 @@ #include "clang/Sema/TemplateDeduction.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/AlignOf.h" #include "llvm/Support/Allocator.h" namespace clang { @@ -718,7 +719,8 @@ namespace clang { CandidateSetKind Kind; unsigned NumInlineSequences; - char InlineSpace[16 * sizeof(ImplicitConversionSequence)]; + llvm::AlignedCharArray::Alignment, + 16 * sizeof(ImplicitConversionSequence)> InlineSpace; OverloadCandidateSet(const OverloadCandidateSet &) LLVM_DELETED_FUNCTION; void operator=(const OverloadCandidateSet &) LLVM_DELETED_FUNCTION; @@ -759,7 +761,7 @@ namespace clang { // available. if (NumConversions + NumInlineSequences <= 16) { ImplicitConversionSequence *I = - (ImplicitConversionSequence*)InlineSpace; + (ImplicitConversionSequence *)InlineSpace.buffer; C.Conversions = &I[NumInlineSequences]; NumInlineSequences += NumConversions; } else {