r216694 - Properly align inline space for ImplicitConversionSequences in OverloadSet.

Alexey Samsonov vonosmas at gmail.com
Thu Aug 28 15:59:40 PDT 2014


Author: samsonov
Date: Thu Aug 28 17:59:39 2014
New Revision: 216694

URL: http://llvm.org/viewvc/llvm-project?rev=216694&view=rev
Log:
Properly align inline space for ImplicitConversionSequences in OverloadSet.

This bug was reported by UBSan.

Modified:
    cfe/trunk/include/clang/Sema/Overload.h

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=216694&r1=216693&r2=216694&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Thu Aug 28 17:59:39 2014
@@ -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<llvm::AlignOf<ImplicitConversionSequence>::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 {





More information about the cfe-commits mailing list