components/llvm/patches/008-solaris-clang-libclangAST.patch
changeset 6512 92717ce71105
equal deleted inserted replaced
6511:d283aa33e131 6512:92717ce71105
       
     1 # Miscellaenous alignment assertions and fixes.
       
     2 # Remove bitfields if possible (not always possible).
       
     3 # Upstream loves bitfields.
       
     4 # 3.9.X upstream.
       
     5 --- tools/clang/include/clang/AST/DeclCXX.h	2015-12-29 22:24:14.000000000 -0500
       
     6 +++ tools/clang/include/clang/AST/DeclCXX.h	2016-05-08 23:19:20.540430947 -0400
       
     7 @@ -2120,6 +2120,10 @@
       
     8  
       
     9    friend TrailingObjects;
       
    10  };
       
    11 +static_assert(
       
    12 +    llvm::AlignOf<CXXCtorInitializer>::Alignment >=
       
    13 +        llvm::AlignOf<VarDecl *>::Alignment,
       
    14 +    "Alignment is insufficient for objects appended to CXXCtorInitializer");
       
    15  
       
    16  /// \brief Represents a C++ constructor within a class.
       
    17  ///
       
    18 --- tools/clang/include/clang/AST/DeclFriend.h	2015-12-29 17:13:13.000000000 -0500
       
    19 +++ tools/clang/include/clang/AST/DeclFriend.h	2016-05-08 23:19:20.540430947 -0400
       
    20 @@ -168,6 +168,9 @@
       
    21    friend class ASTDeclWriter;
       
    22    friend TrailingObjects;
       
    23  };
       
    24 +static_assert(llvm::AlignOf<FriendDecl>::Alignment >=
       
    25 +                  llvm::AlignOf<TemplateParameterList *>::Alignment,
       
    26 +              "Alignment is insufficient for objects appended to FriendDecl");
       
    27  
       
    28  /// An iterator over the friend declarations of a class.
       
    29  class CXXRecordDecl::friend_iterator {
       
    30 --- tools/clang/include/clang/AST/DeclGroup.h	2015-12-29 17:13:13.000000000 -0500
       
    31 +++ tools/clang/include/clang/AST/DeclGroup.h	2016-05-08 23:19:20.541430972 -0400
       
    32 @@ -14,6 +14,7 @@
       
    33  #ifndef LLVM_CLANG_AST_DECLGROUP_H
       
    34  #define LLVM_CLANG_AST_DECLGROUP_H
       
    35  
       
    36 +#include "llvm/Support/AlignOf.h"
       
    37  #include "llvm/Support/DataTypes.h"
       
    38  #include "llvm/Support/TrailingObjects.h"
       
    39  #include <cassert>
       
    40 @@ -50,6 +51,9 @@
       
    41  
       
    42    friend TrailingObjects;
       
    43  };
       
    44 +static_assert(llvm::AlignOf<DeclGroup>::Alignment >=
       
    45 +                  llvm::AlignOf<Decl *>::Alignment,
       
    46 +              "Alignment is insufficient for objects appended to DeclGroup");
       
    47  
       
    48  class DeclGroupRef {
       
    49    // Note this is not a PointerIntPair because we need the address of the
       
    50 --- tools/clang/include/clang/AST/Decl.h	2016-01-06 17:49:11.000000000 -0500
       
    51 +++ tools/clang/include/clang/AST/Decl.h	2016-05-08 23:19:20.542430996 -0400
       
    52 @@ -3713,6 +3713,9 @@
       
    53    static bool classof(const Decl *D) { return classofKind(D->getKind()); }
       
    54    static bool classofKind(Kind K) { return K == Import; }
       
    55  };
       
    56 +static_assert(llvm::AlignOf<ImportDecl>::Alignment >=
       
    57 +                  llvm::AlignOf<SourceLocation>::Alignment,
       
    58 +              "Alignment is insufficient for objects appended to ImportDecl");
       
    59  
       
    60  /// \brief Represents an empty-declaration.
       
    61  class EmptyDecl : public Decl {
       
    62 --- tools/clang/include/clang/AST/DeclOpenMP.h	2015-12-29 17:13:13.000000000 -0500
       
    63 +++ tools/clang/include/clang/AST/DeclOpenMP.h	2016-05-08 23:19:20.542430996 -0400
       
    64 @@ -85,6 +85,10 @@
       
    65    static bool classof(const Decl *D) { return classofKind(D->getKind()); }
       
    66    static bool classofKind(Kind K) { return K == OMPThreadPrivate; }
       
    67  };
       
    68 +static_assert(
       
    69 +    llvm::AlignOf<OMPThreadPrivateDecl>::Alignment >=
       
    70 +        llvm::AlignOf<Expr *>::Alignment,
       
    71 +    "Alignment is insufficient for objects appended to OMPThreadPrivateDecl");
       
    72  
       
    73  }  // end namespace clang
       
    74  
       
    75 ###
       
    76 --- tools/clang/include/clang/AST/DeclTemplate.h	2015-12-29 14:13:13.000000000 -0800
       
    77 +++ tools/clang/include/clang/AST/DeclTemplate.h	2016-05-09 13:56:11.451547165 -0700
       
    78 @@ -56,11 +56,11 @@
       
    79  
       
    80    /// The number of template parameters in this template
       
    81    /// parameter list.
       
    82 -  unsigned NumParams : 31;
       
    83 +  unsigned NumParams;
       
    84  
       
    85    /// Whether this template parameter list contains an unexpanded parameter
       
    86    /// pack.
       
    87 -  unsigned ContainsUnexpandedParameterPack : 1;
       
    88 +  bool ContainsUnexpandedParameterPack;
       
    89  
       
    90  protected:
       
    91    size_t numTrailingObjects(OverloadToken<NamedDecl *>) const {
       
    92 @@ -138,6 +138,10 @@
       
    93    friend TrailingObjects;
       
    94    template <size_t N> friend class FixedSizeTemplateParameterListStorage;
       
    95  };
       
    96 +static_assert(
       
    97 +    llvm::AlignOf<TemplateParameterList>::Alignment >=
       
    98 +        llvm::AlignOf<NamedDecl *>::Alignment,
       
    99 +    "Insufficient alignment for objects appended to TemplateParameterList");
       
   100  
       
   101  /// \brief Stores a list of template parameters for a TemplateDecl and its
       
   102  /// derived classes. Suitable for creating on the stack.
       
   103 @@ -582,6 +586,21 @@
       
   104    Create(ASTContext &Context, const UnresolvedSetImpl &Templates,
       
   105           const TemplateArgumentListInfo &TemplateArgs);
       
   106  
       
   107 +  DependentFunctionTemplateSpecializationInfo(
       
   108 +    const DependentFunctionTemplateSpecializationInfo &RHS)
       
   109 +    : NumTemplates(RHS.NumTemplates), NumArgs(RHS.NumArgs),
       
   110 +    AngleLocs(RHS.AngleLocs) { }
       
   111 +
       
   112 +  DependentFunctionTemplateSpecializationInfo
       
   113 +    &operator=(const DependentFunctionTemplateSpecializationInfo &RHS) {
       
   114 +      if (this != &RHS) {
       
   115 +        NumTemplates = RHS.NumTemplates;
       
   116 +        NumArgs = RHS.NumArgs;
       
   117 +        AngleLocs = RHS.AngleLocs;
       
   118 +      }
       
   119 +      return *this;
       
   120 +    }
       
   121 +
       
   122    /// \brief Returns the number of function templates that this might
       
   123    /// be a specialization of.
       
   124    unsigned getNumTemplates() const { return NumTemplates; }
       
   125 @@ -617,6 +636,16 @@
       
   126    friend TrailingObjects;
       
   127  };
       
   128  
       
   129 +static_assert(
       
   130 +  llvm::AlignOf<DependentFunctionTemplateSpecializationInfo>::Alignment >=
       
   131 +  llvm::AlignOf<TemplateArgumentLoc>::Alignment,
       
   132 +  "Insufficient alignment for objects appended to "
       
   133 +  "DependentFunctionTemplateSpecializationInfo");
       
   134 +static_assert(llvm::AlignOf<TemplateArgumentLoc>::Alignment >=
       
   135 +              llvm::AlignOf<FunctionTemplateDecl *>::Alignment,
       
   136 +              "Insufficient alignment for objects appended to "
       
   137 +              "DependentFunctionTemplateSpecializationInfo");
       
   138 +
       
   139  /// Declaration of a redeclarable template.
       
   140  class RedeclarableTemplateDecl : public TemplateDecl, 
       
   141                                   public Redeclarable<RedeclarableTemplateDecl> 
       
   142 @@ -1310,6 +1339,10 @@
       
   143    static bool classof(const Decl *D) { return classofKind(D->getKind()); }
       
   144    static bool classofKind(Kind K) { return K == NonTypeTemplateParm; }
       
   145  };
       
   146 +static_assert(llvm::AlignOf<NonTypeTemplateParmDecl>::Alignment >=
       
   147 +                  llvm::AlignOf<void *>::Alignment,
       
   148 +              "Insufficient alignment for objects appended to "
       
   149 +              "NonTypeTemplateParmDecl");
       
   150  
       
   151  /// TemplateTemplateParmDecl - Declares a template template parameter,
       
   152  /// e.g., "T" in
       
   153 @@ -1478,6 +1511,10 @@
       
   154    friend class ASTDeclWriter;
       
   155    friend TrailingObjects;
       
   156  };
       
   157 +static_assert(llvm::AlignOf<TemplateTemplateParmDecl>::Alignment >=
       
   158 +                  llvm::AlignOf<TemplateParameterList *>::Alignment,
       
   159 +              "Insufficient alignment for objects appended to "
       
   160 +              "TemplateTemplateParmDecl");
       
   161  
       
   162  /// \brief Represents the builtin template declaration which is used to
       
   163  /// implement __make_integer_seq.  It serves no real purpose beyond existing as
       
   164 ###
       
   165 --- tools/clang/include/clang/AST/ExprCXX.h	2016-01-06 14:34:54.000000000 -0800
       
   166 +++ tools/clang/include/clang/AST/ExprCXX.h	2016-05-09 14:06:13.555769345 -0700
       
   167 @@ -1013,6 +1013,11 @@
       
   168    friend class ASTStmtWriter;
       
   169  };
       
   170  
       
   171 +static_assert(llvm::AlignOf<CXXDefaultArgExpr>::Alignment >=
       
   172 +              llvm::AlignOf<Expr *>::Alignment,
       
   173 +              "Insufficient alignment for objects appended to "
       
   174 +              "CXXDefaultArgExpr");
       
   175 +
       
   176  /// \brief A use of a default initializer in a constructor or in aggregate
       
   177  /// initialization.
       
   178  ///
       
   179 @@ -1678,6 +1683,17 @@
       
   180    friend class ASTStmtWriter;
       
   181  };
       
   182  
       
   183 +static_assert(llvm::AlignOf<LambdaExpr>::Alignment >=
       
   184 +              llvm::AlignOf<Stmt *>::Alignment,
       
   185 +              "Insufficient alignment for objects appended to LambdaExpr");
       
   186 +static_assert(llvm::AlignOf<Stmt *>::Alignment >=
       
   187 +                  llvm::AlignOf<unsigned>::Alignment,
       
   188 +              "Insufficient alignment for objects appended to LambdaExpr");
       
   189 +// Code re-aligns before VarDecl *[]
       
   190 +static_assert(llvm::AlignOf<LambdaExpr>::Alignment >=
       
   191 +                  llvm::AlignOf<VarDecl *>::Alignment,
       
   192 +              "Insufficient alignment for objects appended to LambdaExpr");
       
   193 +
       
   194  /// An expression "T()" which creates a value-initialized rvalue of type
       
   195  /// T, which is a non-class type.  See (C++98 [5.2.3p2]).
       
   196  class CXXScalarValueInitExpr : public Expr {
       
   197 @@ -2264,6 +2280,11 @@
       
   198    friend class ASTStmtWriter;
       
   199  };
       
   200  
       
   201 +static_assert(
       
   202 +    llvm::AlignOf<TypeTraitExpr>::Alignment >=
       
   203 +    llvm::AlignOf<TypeSourceInfo *>::Alignment,
       
   204 +    "Insufficient alignment for objects appended to TypeTraitExpr");
       
   205 +
       
   206  /// \brief An Embarcadero array type trait, as used in the implementation of
       
   207  /// __array_rank and __array_extent.
       
   208  ///
       
   209 @@ -2399,7 +2420,7 @@
       
   210  
       
   211  /// \brief A reference to an overloaded function set, either an
       
   212  /// \c UnresolvedLookupExpr or an \c UnresolvedMemberExpr.
       
   213 -class OverloadExpr : public Expr {
       
   214 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) OverloadExpr : public Expr {
       
   215    /// \brief The common name of these declarations.
       
   216    DeclarationNameInfo NameInfo;
       
   217  
       
   218 @@ -2689,6 +2710,11 @@
       
   219    }
       
   220  };
       
   221  
       
   222 +static_assert(llvm::AlignOf<UnresolvedLookupExpr>::Alignment >=
       
   223 +              llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment,
       
   224 +              "Insufficient alignment for objects appended to "
       
   225 +              "UnresolvedLookupExpr");
       
   226 +
       
   227  /// \brief A qualified reference to a name whose declaration cannot
       
   228  /// yet be resolved.
       
   229  ///
       
   230 @@ -2834,6 +2860,11 @@
       
   231    friend class ASTStmtWriter;
       
   232  };
       
   233  
       
   234 +static_assert(llvm::AlignOf<DependentScopeDeclRefExpr>::Alignment >=
       
   235 +              llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment,
       
   236 +              "Insufficient alignment for objects appended to "
       
   237 +              "DependentScopeDeclRefExpr");
       
   238 +
       
   239  /// Represents an expression -- generally a full-expression -- that
       
   240  /// introduces cleanups to be run at the end of the sub-expression's
       
   241  /// evaluation.  The most common source of expression-introduced
       
   242 @@ -2903,6 +2934,11 @@
       
   243    child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
       
   244  };
       
   245  
       
   246 +static_assert(llvm::AlignOf<ExprWithCleanups>::Alignment >=
       
   247 +              llvm::AlignOf<ExprWithCleanups::CleanupObject>::Alignment,
       
   248 +              "Insufficient alignment for objects appended to "
       
   249 +              "ExprWithCleanups");
       
   250 +
       
   251  /// \brief Describes an explicit type conversion that uses functional
       
   252  /// notion but could not be resolved because one or more arguments are
       
   253  /// type-dependent.
       
   254 @@ -3024,6 +3060,11 @@
       
   255    }
       
   256  };
       
   257  
       
   258 +static_assert(llvm::AlignOf<CXXUnresolvedConstructExpr>::Alignment >=
       
   259 +              llvm::AlignOf<Expr *>::Alignment,
       
   260 +              "Insufficient alignment for objects appended to "
       
   261 +              "CXXUnresolvedConstructExpr");
       
   262 +
       
   263  /// \brief Represents a C++ member access expression where the actual
       
   264  /// member referenced could not be resolved because the base
       
   265  /// expression or the member name was dependent.
       
   266 @@ -3046,11 +3087,11 @@
       
   267  
       
   268    /// \brief Whether this member expression used the '->' operator or
       
   269    /// the '.' operator.
       
   270 -  bool IsArrow : 1;
       
   271 +  bool IsArrow;
       
   272  
       
   273    /// \brief Whether this member expression has info for explicit template
       
   274    /// keyword and arguments.
       
   275 -  bool HasTemplateKWAndArgsInfo : 1;
       
   276 +  bool HasTemplateKWAndArgsInfo;
       
   277  
       
   278    /// \brief The location of the '->' or '.' operator.
       
   279    SourceLocation OperatorLoc;
       
   280 @@ -3250,6 +3291,11 @@
       
   281    friend class ASTStmtWriter;
       
   282  };
       
   283  
       
   284 +static_assert(llvm::AlignOf<CXXDependentScopeMemberExpr>::Alignment >=
       
   285 +              llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment,
       
   286 +              "Insufficient alignment for objects appended to "
       
   287 +              "CXXDependentScopeMemberExpr");
       
   288 +
       
   289  /// \brief Represents a C++ member access expression for which lookup
       
   290  /// produced a set of overloaded functions.
       
   291  ///
       
   292 @@ -3271,11 +3317,11 @@
       
   293            UnresolvedMemberExpr, ASTTemplateKWAndArgsInfo, TemplateArgumentLoc> {
       
   294    /// \brief Whether this member expression used the '->' operator or
       
   295    /// the '.' operator.
       
   296 -  bool IsArrow : 1;
       
   297 +  bool IsArrow;
       
   298  
       
   299    /// \brief Whether the lookup results contain an unresolved using
       
   300    /// declaration.
       
   301 -  bool HasUnresolvedUsing : 1;
       
   302 +  bool HasUnresolvedUsing;
       
   303  
       
   304    /// \brief The expression for the base pointer or class reference,
       
   305    /// e.g., the \c x in x.f.
       
   306 @@ -3399,6 +3445,11 @@
       
   307    }
       
   308  };
       
   309  
       
   310 +static_assert(llvm::AlignOf<UnresolvedMemberExpr>::Alignment >=
       
   311 +              llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment,
       
   312 +              "Insufficient alignment for objects appended to "
       
   313 +              "UnresolvedMemberExpr");
       
   314 +
       
   315  inline ASTTemplateKWAndArgsInfo *
       
   316  OverloadExpr::getTrailingASTTemplateKWAndArgsInfo() {
       
   317    if (!HasTemplateKWAndArgsInfo)
       
   318 @@ -3841,6 +3892,11 @@
       
   319    }
       
   320  };
       
   321  
       
   322 +static_assert(llvm::AlignOf<FunctionParmPackExpr>::Alignment >=
       
   323 +              llvm::AlignOf<ParmVarDecl *>::Alignment,
       
   324 +              "Insufficient alignment for objects appended to "
       
   325 +              "FunctionParmPackExpr");
       
   326 +
       
   327  /// \brief Represents a prvalue temporary that is written into memory so that
       
   328  /// a reference can bind to it.
       
   329  ///
       
   330 ###
       
   331 --- tools/clang/include/clang/AST/Expr.h	2016-01-07 12:59:26.000000000 -0800
       
   332 +++ tools/clang/include/clang/AST/Expr.h	2016-05-09 13:48:08.744463290 -0700
       
   333 @@ -1142,6 +1142,17 @@
       
   334    friend class ASTStmtWriter;
       
   335  };
       
   336  
       
   337 +static_assert(llvm::AlignOf<DeclRefExpr>::Alignment >=
       
   338 +                  llvm::AlignOf<NestedNameSpecifierLoc>::Alignment,
       
   339 +              "Alignment is insufficient for objects appended to DeclRefExpr");
       
   340 +static_assert(llvm::AlignOf<NestedNameSpecifierLoc>::Alignment >=
       
   341 +                  llvm::AlignOf<NamedDecl *>::Alignment,
       
   342 +              "Alignment is insufficient for objects appended to NestedNameSpecifierLoc");
       
   343 +// Code re-aligns before ASTTemplateKWAndArgsInfo
       
   344 +static_assert(llvm::AlignOf<DeclRefExpr>::Alignment >=
       
   345 +                  llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment,
       
   346 +              "Alignment is insufficient for objects appended to DeclRefExpr");
       
   347 +
       
   348  /// \brief [C99 6.4.2.2] - A predefined identifier such as __func__.
       
   349  class PredefinedExpr : public Expr {
       
   350  public:
       
   351 @@ -1753,7 +1764,7 @@
       
   352  /// Helper class for OffsetOfExpr.
       
   353  
       
   354  // __builtin_offsetof(type, identifier(.identifier|[expr])*)
       
   355 -class OffsetOfNode {
       
   356 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) OffsetOfNode {
       
   357  public:
       
   358    /// \brief The kind of offsetof node we have.
       
   359    enum Kind {
       
   360 @@ -1857,7 +1868,7 @@
       
   361  /// @endcode
       
   362  /// we can represent and evaluate the expression @c offsetof(struct T, s[2].d).
       
   363  
       
   364 -class OffsetOfExpr final
       
   365 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) OffsetOfExpr final
       
   366      : public Expr,
       
   367        private llvm::TrailingObjects<OffsetOfExpr, OffsetOfNode, Expr *> {
       
   368    SourceLocation OperatorLoc, RParenLoc;
       
   369 @@ -1954,6 +1965,22 @@
       
   370    friend TrailingObjects;
       
   371  };
       
   372  
       
   373 +static_assert(llvm::AlignOf<OffsetOfExpr>::Alignment >=
       
   374 +                  llvm::AlignOf<OffsetOfNode*>::Alignment,
       
   375 +              "Insufficient aligment for objects appended to OffsetOfExpr");
       
   376 +static_assert(llvm::AlignOf<OffsetOfNode>::Alignment >=
       
   377 +                  llvm::AlignOf<Expr*>::Alignment,
       
   378 +              "Insufficient alignment for objects appended to OffsetOfExpr");
       
   379 +
       
   380 +#if 0
       
   381 +static_assert(llvm::AlignOf<OffsetOfExpr>::Alignment >=
       
   382 +                  llvm::AlignOf<OffsetOfExpr::OffsetOfNode *>::Alignment,
       
   383 +              "Alignment is insufficient for objects appended to OffsetOfExpr");
       
   384 +static_assert(llvm::AlignOf<OffsetOfExpr::OffsetOfNode>::Alignment >=
       
   385 +                  llvm::AlignOf<Expr *>::Alignment,
       
   386 +              "Alignment is insufficient for objects appended to OffsetOfExpr");
       
   387 +#endif
       
   388 +
       
   389  /// UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated)
       
   390  /// expression operand.  Used for sizeof/alignof (C99 6.5.3.4) and
       
   391  /// vec_step (OpenCL 1.1 6.11.12).
       
   392 @@ -2318,24 +2345,24 @@
       
   393    SourceLocation OperatorLoc;
       
   394  
       
   395    /// IsArrow - True if this is "X->F", false if this is "X.F".
       
   396 -  bool IsArrow : 1;
       
   397 +  bool IsArrow;
       
   398  
       
   399    /// \brief True if this member expression used a nested-name-specifier to
       
   400    /// refer to the member, e.g., "x->Base::f", or found its member via a using
       
   401    /// declaration.  When true, a MemberExprNameQualifier
       
   402    /// structure is allocated immediately after the MemberExpr.
       
   403 -  bool HasQualifierOrFoundDecl : 1;
       
   404 +  bool HasQualifierOrFoundDecl;
       
   405  
       
   406    /// \brief True if this member expression specified a template keyword
       
   407    /// and/or a template argument list explicitly, e.g., x->f<int>,
       
   408    /// x->template f, x->template f<int>.
       
   409    /// When true, an ASTTemplateKWAndArgsInfo structure and its
       
   410    /// TemplateArguments (if any) are present.
       
   411 -  bool HasTemplateKWAndArgsInfo : 1;
       
   412 +  bool HasTemplateKWAndArgsInfo;
       
   413  
       
   414    /// \brief True if this member expression refers to a method that
       
   415    /// was resolved from an overloaded set having size greater than 1.
       
   416 -  bool HadMultipleCandidates : 1;
       
   417 +  bool HadMultipleCandidates;
       
   418  
       
   419    size_t numTrailingObjects(OverloadToken<MemberExprNameQualifier>) const {
       
   420      return HasQualifierOrFoundDecl ? 1 : 0;
       
   421 @@ -2688,6 +2715,11 @@
       
   422    // Iterators
       
   423    child_range children() { return child_range(&Op, &Op+1); }
       
   424  };
       
   425 +static_assert(llvm::AlignOf<CastExpr>::Alignment >=
       
   426 +                  llvm::AlignOf<CXXBaseSpecifier *>::Alignment,
       
   427 +              "Alignment is insufficient for objects appended to CastExpr");
       
   428 +// (Note that the data is actually tacked onto one of its subclasses,
       
   429 +// but they'll inherit alignment)
       
   430  
       
   431  /// ImplicitCastExpr - Allows us to explicitly represent implicit type
       
   432  /// conversions, which have no direct representation in the original
       
   433 @@ -4316,6 +4348,10 @@
       
   434      return child_range(&BaseAndUpdaterExprs[0], &BaseAndUpdaterExprs[0] + 2);
       
   435    }
       
   436  };
       
   437 +static_assert(
       
   438 +    llvm::AlignOf<DesignatedInitExpr>::Alignment >=
       
   439 +        llvm::AlignOf<Stmt *>::Alignment,
       
   440 +    "Alignment is insufficient for objects appended to DesignatedInitExpr");
       
   441  
       
   442  /// \brief Represents an implicitly-generated value initialization of
       
   443  /// an object of a given type.
       
   444 @@ -4808,6 +4844,10 @@
       
   445    friend TrailingObjects;
       
   446    friend class ASTStmtReader;
       
   447  };
       
   448 +static_assert(
       
   449 +    llvm::AlignOf<PseudoObjectExpr>::Alignment >=
       
   450 +        llvm::AlignOf<Expr *>::Alignment,
       
   451 +    "Alignment is insufficient for objects appended to PseudoObjectExpr");
       
   452  
       
   453  /// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*,
       
   454  /// __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the
       
   455 ###
       
   456 --- tools/clang/include/clang/AST/ExprObjC.h	2015-12-30 20:43:19.000000000 -0800
       
   457 +++ tools/clang/include/clang/AST/ExprObjC.h	2016-05-09 14:56:41.962219122 -0700
       
   458 @@ -206,6 +206,10 @@
       
   459    friend TrailingObjects;
       
   460    friend class ASTStmtReader;
       
   461  };
       
   462 +static_assert(
       
   463 +    llvm::AlignOf<ObjCArrayLiteral>::Alignment >=
       
   464 +        llvm::AlignOf<Expr *>::Alignment,
       
   465 +    "Alignment is insufficient for objects appended to ObjCArrayLiteral");
       
   466  
       
   467  /// \brief An element in an Objective-C dictionary literal.
       
   468  ///
       
   469 @@ -260,7 +264,7 @@
       
   470                                      ObjCDictionaryLiteral_KeyValuePair,
       
   471                                      ObjCDictionaryLiteral_ExpansionData> {
       
   472    /// \brief The number of elements in this dictionary literal.
       
   473 -  unsigned NumElements : 31;
       
   474 +  unsigned NumElements;
       
   475  
       
   476    /// \brief Determine whether this dictionary literal has any pack expansions.
       
   477    ///
       
   478 @@ -269,11 +273,12 @@
       
   479    /// key/value pairs, which provide the locations of the ellipses (if
       
   480    /// any) and number of elements in the expansion (if known). If
       
   481    /// there are no pack expansions, we optimize away this storage.
       
   482 -  unsigned HasPackExpansions : 1;
       
   483 +  bool HasPackExpansions;
       
   484  
       
   485    SourceRange Range;
       
   486    ObjCMethodDecl *DictWithObjectsMethod;
       
   487  
       
   488 +public:
       
   489    typedef ObjCDictionaryLiteral_KeyValuePair KeyValuePair;
       
   490    typedef ObjCDictionaryLiteral_ExpansionData ExpansionData;
       
   491  
       
   492 @@ -347,7 +352,14 @@
       
   493    friend class ASTStmtWriter;
       
   494    friend TrailingObjects;
       
   495  };
       
   496 -
       
   497 +static_assert(
       
   498 +    llvm::AlignOf<ObjCDictionaryLiteral>::Alignment >=
       
   499 +        llvm::AlignOf<ObjCDictionaryLiteral::KeyValuePair>::Alignment,
       
   500 +    "Alignment is insufficient for objects appended to ObjCDictionaryLiteral");
       
   501 +static_assert(
       
   502 +    llvm::AlignOf<ObjCDictionaryLiteral::KeyValuePair>::Alignment >=
       
   503 +        llvm::AlignOf<ObjCDictionaryLiteral::ExpansionData>::Alignment,
       
   504 +    "Alignment is insufficient for objects appended to ObjCDictionaryLiteral");
       
   505  
       
   506  /// ObjCEncodeExpr, used for \@encode in Objective-C.  \@encode has the same
       
   507  /// type and behavior as StringLiteral except that the string initializer is
       
   508 @@ -1377,6 +1389,17 @@
       
   509    friend class ASTStmtReader;
       
   510    friend class ASTStmtWriter;
       
   511  };
       
   512 +static_assert(
       
   513 +    llvm::AlignOf<ObjCMessageExpr>::Alignment >=
       
   514 +        llvm::AlignOf<void *>::Alignment,
       
   515 +    "Alignment is insufficient for objects appended to ObjCMessageExpr");
       
   516 +static_assert(
       
   517 +    llvm::AlignOf<void *>::Alignment >= llvm::AlignOf<Expr *>::Alignment,
       
   518 +    "Alignment is insufficient for objects appended to ObjCMessageExpr");
       
   519 +static_assert(
       
   520 +    llvm::AlignOf<Expr *>::Alignment >=
       
   521 +        llvm::AlignOf<SourceLocation>::Alignment,
       
   522 +    "Alignment is insufficient for objects appended to ObjCMessageExpr");
       
   523  
       
   524  /// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
       
   525  /// (similar in spirit to MemberExpr).
       
   526 ### NO PACE
       
   527 --- tools/clang/include/clang/AST/Mangle.h	2015-12-31 00:36:54.000000000 -0500
       
   528 +++ tools/clang/include/clang/AST/Mangle.h	2016-05-08 23:19:20.547431117 -0400
       
   529 @@ -129,6 +129,8 @@
       
   530  
       
   531    virtual void mangleDynamicInitializer(const VarDecl *D, raw_ostream &) = 0;
       
   532  
       
   533 +  virtual void mangleGCCDynamicInitializer(const VarDecl *D, raw_ostream &) = 0;
       
   534 +
       
   535    virtual void mangleDynamicAtExitDestructor(const VarDecl *D,
       
   536                                               raw_ostream &) = 0;
       
   537  
       
   538 --- tools/clang/include/clang/AST/StmtCXX.h	2015-11-23 21:34:39.000000000 -0500
       
   539 +++ tools/clang/include/clang/AST/StmtCXX.h	2016-05-08 23:19:20.547431117 -0400
       
   540 @@ -118,6 +118,9 @@
       
   541  
       
   542    friend class ASTStmtReader;
       
   543  };
       
   544 +static_assert(llvm::AlignOf<CXXTryStmt>::Alignment >=
       
   545 +                  llvm::AlignOf<Stmt *>::Alignment,
       
   546 +              "Alignment is insufficient for objects appended to CXXTryStmt");
       
   547  
       
   548  /// CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for
       
   549  /// statement, represented as 'for (range-declarator : range-expression)'.
       
   550 --- tools/clang/include/clang/AST/Stmt.h	2016-01-07 15:59:26.000000000 -0500
       
   551 +++ tools/clang/include/clang/AST/Stmt.h	2016-05-08 23:19:20.548431142 -0400
       
   552 @@ -862,7 +862,10 @@
       
   553      return T->getStmtClass() == AttributedStmtClass;
       
   554    }
       
   555  };
       
   556 -
       
   557 +static_assert(
       
   558 +    llvm::AlignOf<AttributedStmt>::Alignment >=
       
   559 +        llvm::AlignOf<Attr *>::Alignment,
       
   560 +    "Alignment is insufficient for objects appended to AttributedStmt");
       
   561  
       
   562  /// IfStmt - This represents an if/then/else.
       
   563  ///
       
   564 @@ -2190,6 +2193,13 @@
       
   565  
       
   566    friend class ASTStmtReader;
       
   567  };
       
   568 +static_assert(llvm::AlignOf<CapturedStmt>::Alignment >=
       
   569 +                  llvm::AlignOf<Stmt *>::Alignment,
       
   570 +              "Alignment is insufficient for objects appended to CapturedStmt");
       
   571 +// Code re-aligns before Capture[]
       
   572 +static_assert(llvm::AlignOf<CapturedStmt>::Alignment >=
       
   573 +                  llvm::AlignOf<CapturedStmt::Capture>::Alignment,
       
   574 +              "Alignment is insufficient for objects appended to CapturedStmt");
       
   575  
       
   576  }  // end namespace clang
       
   577  
       
   578 --- tools/clang/include/clang/AST/StmtObjC.h	2015-04-02 11:29:07.000000000 -0400
       
   579 +++ tools/clang/include/clang/AST/StmtObjC.h	2016-05-08 23:19:20.549431166 -0400
       
   580 @@ -250,6 +250,9 @@
       
   581                         getStmts() + 1 + NumCatchStmts + HasFinally);
       
   582    }
       
   583  };
       
   584 +static_assert(
       
   585 +    llvm::AlignOf<ObjCAtTryStmt>::Alignment >= llvm::AlignOf<Stmt *>::Alignment,
       
   586 +    "Alignment is insufficient for objects appended to ObjCAtTryStmt");
       
   587  
       
   588  /// \brief Represents Objective-C's \@synchronized statement.
       
   589  ///
       
   590 ###
       
   591 --- tools/clang/include/clang/AST/TemplateBase.h	2015-12-29 10:15:14.000000000 -0800
       
   592 +++ tools/clang/include/clang/AST/TemplateBase.h	2016-05-09 13:37:13.627921073 -0700
       
   593 @@ -85,8 +85,8 @@
       
   594      // We store a decomposed APSInt with the data allocated by ASTContext if
       
   595      // BitWidth > 64. The memory may be shared between multiple
       
   596      // TemplateArgument instances.
       
   597 -    unsigned BitWidth : 31;
       
   598 -    unsigned IsUnsigned : 1;
       
   599 +    unsigned BitWidth;
       
   600 +    bool IsUnsigned;
       
   601      union {
       
   602        uint64_t VAL;          ///< Used to store the <= 64 bits integer value.
       
   603        const uint64_t *pVal;  ///< Used to store the >64 bits integer value.
       
   604 @@ -113,19 +113,36 @@
       
   605      struct A Args;
       
   606      struct TA TemplateArg;
       
   607      struct TV TypeOrValue;
       
   608 +    uint64_t Buffer[8];
       
   609    };
       
   610  
       
   611    TemplateArgument(TemplateName, bool) = delete;
       
   612 -  
       
   613 +
       
   614  public:
       
   615    /// \brief Construct an empty, invalid template argument.
       
   616    TemplateArgument() {
       
   617 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   618      TypeOrValue.Kind = Null;
       
   619      TypeOrValue.V = 0;
       
   620    }
       
   621  
       
   622 +
       
   623 +  TemplateArgument(const TemplateArgument &RHS) {
       
   624 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   625 +    (void) std::memcpy(Buffer, RHS.Buffer, sizeof(Buffer));
       
   626 +  }
       
   627 +
       
   628 +  TemplateArgument &operator=(const TemplateArgument &RHS) {
       
   629 +    if (this != &RHS) {
       
   630 +      (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   631 +      (void) std::memcpy(Buffer, RHS.Buffer, sizeof(Buffer));
       
   632 +    }
       
   633 +    return *this;
       
   634 +  }
       
   635 +
       
   636    /// \brief Construct a template type argument.
       
   637    TemplateArgument(QualType T, bool isNullPtr = false) {
       
   638 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   639      TypeOrValue.Kind = isNullPtr ? NullPtr : Type;
       
   640      TypeOrValue.V = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
       
   641    }
       
   642 @@ -135,6 +152,7 @@
       
   643    /// template declaration.
       
   644    TemplateArgument(ValueDecl *D, QualType QT) {
       
   645      assert(D && "Expected decl");
       
   646 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   647      DeclArg.Kind = Declaration;
       
   648      DeclArg.QT = QT.getAsOpaquePtr();
       
   649      DeclArg.D = D;
       
   650 @@ -147,6 +165,7 @@
       
   651    /// \brief Construct an integral constant template argument with the same
       
   652    /// value as Other but a different type.
       
   653    TemplateArgument(const TemplateArgument &Other, QualType Type) {
       
   654 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   655      Integer = Other.Integer;
       
   656      Integer.Type = Type.getAsOpaquePtr();
       
   657    }
       
   658 @@ -160,6 +179,7 @@
       
   659    ///
       
   660    /// \param Name The template name.
       
   661    TemplateArgument(TemplateName Name) {
       
   662 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   663      TemplateArg.Kind = Template;
       
   664      TemplateArg.Name = Name.getAsVoidPointer();
       
   665      TemplateArg.NumExpansions = 0;
       
   666 @@ -177,6 +197,7 @@
       
   667    /// \param NumExpansions The number of expansions that will be generated by
       
   668    /// instantiating
       
   669    TemplateArgument(TemplateName Name, Optional<unsigned> NumExpansions) {
       
   670 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   671      TemplateArg.Kind = TemplateExpansion;
       
   672      TemplateArg.Name = Name.getAsVoidPointer();
       
   673      if (NumExpansions)
       
   674 @@ -191,6 +212,7 @@
       
   675    /// lists used for dependent types and for expression; it will not
       
   676    /// occur in a non-dependent, canonical template argument list.
       
   677    TemplateArgument(Expr *E) {
       
   678 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   679      TypeOrValue.Kind = Expression;
       
   680      TypeOrValue.V = reinterpret_cast<uintptr_t>(E);
       
   681    }
       
   682 @@ -200,6 +222,7 @@
       
   683    /// We assume that storage for the template arguments provided
       
   684    /// outlives the TemplateArgument itself.
       
   685    explicit TemplateArgument(ArrayRef<TemplateArgument> Args) {
       
   686 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   687      this->Args.Kind = Pack;
       
   688      this->Args.Args = Args.data();
       
   689      this->Args.NumArgs = Args.size();
       
   690 @@ -358,6 +381,20 @@
       
   691    void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const;
       
   692  };
       
   693  
       
   694 +static_assert(llvm::AlignOf<TemplateSpecializationType>::Alignment >=
       
   695 +                  llvm::AlignOf<TemplateArgument>::Alignment,
       
   696 +              "Alignment is insufficient for objects appended to "
       
   697 +              "TemplateSpecializationType");
       
   698 +static_assert(llvm::AlignOf<TemplateArgument>::Alignment >=
       
   699 +                  llvm::AlignOf<QualType>::Alignment,
       
   700 +              "Alignment is insufficient for objects appended to "
       
   701 +              "TemplateSpecializationType");
       
   702 +
       
   703 +static_assert(llvm::AlignOf<DependentTemplateSpecializationType>::Alignment >=
       
   704 +                  llvm::AlignOf<TemplateArgument>::Alignment,
       
   705 +              "Alignment is insufficient for objects appended to "
       
   706 +              "DependentTemplateSpecializationType");
       
   707 +
       
   708  /// Location information for a TemplateArgument.
       
   709  struct TemplateArgumentLocInfo {
       
   710  private:
       
   711 @@ -375,25 +412,55 @@
       
   712      struct T Template;
       
   713      Expr *Expression;
       
   714      TypeSourceInfo *Declarator;
       
   715 +    unsigned long Buffer[4];
       
   716    };
       
   717  
       
   718  public:
       
   719    TemplateArgumentLocInfo();
       
   720 -  
       
   721 -  TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {}
       
   722 -  
       
   723 -  TemplateArgumentLocInfo(Expr *E) : Expression(E) {}
       
   724 -  
       
   725 +
       
   726 +  TemplateArgumentLocInfo(TypeSourceInfo *TInfo) {
       
   727 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   728 +    Declarator = TInfo;
       
   729 +  }
       
   730 +
       
   731 +  TemplateArgumentLocInfo(Expr *E) {
       
   732 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   733 +    Expression = E;
       
   734 +  }
       
   735 +
       
   736    TemplateArgumentLocInfo(NestedNameSpecifierLoc QualifierLoc,
       
   737                            SourceLocation TemplateNameLoc,
       
   738 -                          SourceLocation EllipsisLoc)
       
   739 -  {
       
   740 +                          SourceLocation EllipsisLoc) {
       
   741 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   742      Template.Qualifier = QualifierLoc.getNestedNameSpecifier();
       
   743      Template.QualifierLocData = QualifierLoc.getOpaqueData();
       
   744      Template.TemplateNameLoc = TemplateNameLoc.getRawEncoding();
       
   745      Template.EllipsisLoc = EllipsisLoc.getRawEncoding();
       
   746    }
       
   747  
       
   748 +  TemplateArgumentLocInfo(const TemplateArgumentLocInfo &RHS) {
       
   749 +    (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   750 +    Template.Qualifier = RHS.Template.Qualifier;
       
   751 +    Template.QualifierLocData = RHS.Template.QualifierLocData;
       
   752 +    Template.TemplateNameLoc = RHS.Template.TemplateNameLoc;
       
   753 +    Template.EllipsisLoc = RHS.Template.EllipsisLoc;
       
   754 +    Expression = RHS.Expression;
       
   755 +    Declarator = RHS.Declarator;
       
   756 +  }
       
   757 +
       
   758 +    TemplateArgumentLocInfo &operator=(const TemplateArgumentLocInfo &RHS) {
       
   759 +      if (this != &RHS) {
       
   760 +        (void) std::memset(Buffer, 0, sizeof(Buffer));
       
   761 +        Template.Qualifier = RHS.Template.Qualifier;
       
   762 +        Template.QualifierLocData = RHS.Template.QualifierLocData;
       
   763 +        Template.TemplateNameLoc = RHS.Template.TemplateNameLoc;
       
   764 +        Template.EllipsisLoc = RHS.Template.EllipsisLoc;
       
   765 +        Expression = RHS.Expression;
       
   766 +        Declarator = RHS.Declarator;
       
   767 +      }
       
   768 +      return *this;
       
   769 +    }
       
   770 +
       
   771    TypeSourceInfo *getAsTypeSourceInfo() const {
       
   772      return Declarator;
       
   773    }
       
   774 @@ -403,14 +470,14 @@
       
   775    }
       
   776  
       
   777    NestedNameSpecifierLoc getTemplateQualifierLoc() const {
       
   778 -    return NestedNameSpecifierLoc(Template.Qualifier, 
       
   779 +    return NestedNameSpecifierLoc(Template.Qualifier,
       
   780                                    Template.QualifierLocData);
       
   781    }
       
   782 -  
       
   783 +
       
   784    SourceLocation getTemplateNameLoc() const {
       
   785      return SourceLocation::getFromRawEncoding(Template.TemplateNameLoc);
       
   786    }
       
   787 -  
       
   788 +
       
   789    SourceLocation getTemplateEllipsisLoc() const {
       
   790      return SourceLocation::getFromRawEncoding(Template.EllipsisLoc);
       
   791    }
       
   792 @@ -593,6 +660,10 @@
       
   793    static const ASTTemplateArgumentListInfo *
       
   794    Create(ASTContext &C, const TemplateArgumentListInfo &List);
       
   795  };
       
   796 +static_assert(llvm::AlignOf<ASTTemplateArgumentListInfo>::Alignment >=
       
   797 +                  llvm::AlignOf<TemplateArgumentLoc>::Alignment,
       
   798 +              "Alignment is insufficient for objects appended to "
       
   799 +              "ASTTemplateArgumentListInfo");
       
   800  
       
   801  /// \brief Represents an explicit template argument list in C++, e.g.,
       
   802  /// the "<int>" in "sort<int>".
       
   803 @@ -601,7 +672,7 @@
       
   804  /// as such, doesn't contain the array of TemplateArgumentLoc itself,
       
   805  /// but expects the containing object to also provide storage for
       
   806  /// that.
       
   807 -struct LLVM_ALIGNAS(LLVM_PTR_SIZE) ASTTemplateKWAndArgsInfo {
       
   808 +struct LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) ASTTemplateKWAndArgsInfo {
       
   809    /// \brief The source location of the left angle bracket ('<').
       
   810    SourceLocation LAngleLoc;
       
   811  
       
   812 @@ -630,6 +701,18 @@
       
   813    void copyInto(const TemplateArgumentLoc *ArgArray,
       
   814                  TemplateArgumentListInfo &List) const;
       
   815  };
       
   816 +static_assert(llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment >=
       
   817 +                  llvm::AlignOf<TemplateArgumentLoc>::Alignment,
       
   818 +              "Alignment is insufficient for objects appended to "
       
   819 +              "ASTTemplateKWAndArgsInfo");
       
   820 +static_assert(llvm::AlignOf<ASTTemplateKWAndArgsInfo>::Alignment >=
       
   821 +                  llvm::AlignOf<SourceLocation>::Alignment,
       
   822 +              "Alignment is insufficient for objects appended to "
       
   823 +              "ASTTemplateKWAndArgsInfo");
       
   824 +static_assert(llvm::AlignOf<TemplateArgumentLoc>::Alignment >=
       
   825 +                  llvm::AlignOf<SourceLocation>::Alignment,
       
   826 +              "Alignment is insufficient for objects appended to "
       
   827 +              "ASTTemplateKWAndArgsInfo");
       
   828  
       
   829  const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
       
   830                                      const TemplateArgument &Arg);
       
   831 ###
       
   832 --- tools/clang/include/clang/AST/TemplateName.h	2015-12-30 01:21:02.000000000 -0500
       
   833 +++ tools/clang/include/clang/AST/TemplateName.h	2016-05-08 23:19:20.550431191 -0400
       
   834 @@ -108,6 +108,10 @@
       
   835    iterator begin() const { return getStorage(); }
       
   836    iterator end() const { return getStorage() + size(); }
       
   837  };
       
   838 +static_assert(llvm::AlignOf<OverloadedTemplateStorage>::Alignment >=
       
   839 +                  llvm::AlignOf<NamedDecl *>::Alignment,
       
   840 +              "Alignment is insufficient for objects appended to "
       
   841 +              "OverloadedTemplateStorage");
       
   842  
       
   843  /// \brief A structure for storing an already-substituted template template
       
   844  /// parameter pack.
       
   845 --- tools/clang/include/clang/AST/Type.h	2016-01-09 07:53:17.000000000 -0500
       
   846 +++ tools/clang/include/clang/AST/Type.h	2016-05-08 23:19:20.551431215 -0400
       
   847 @@ -3324,6 +3324,30 @@
       
   848                        const ExtProtoInfo &EPI, const ASTContext &Context);
       
   849  };
       
   850  
       
   851 +static_assert(
       
   852 +  llvm::AlignOf<FunctionProtoType>::Alignment >=
       
   853 +  llvm::AlignOf<QualType>::Alignment,
       
   854 +  "Alignment is insufficient for objects appended to FunctionProtoType");
       
   855 +// After QualType[], there can be one of 4 options: more QualType, Expr*, 2x
       
   856 +// FunctionDecl*, FunctionDecl*
       
   857 +static_assert(
       
   858 +  llvm::AlignOf<QualType>::Alignment >= llvm::AlignOf<Expr *>::Alignment,
       
   859 +  "Alignment is insufficient for objects appended to FunctionProtoType");
       
   860 +static_assert(
       
   861 +  llvm::AlignOf<QualType>::Alignment >=
       
   862 +  llvm::AlignOf<FunctionDecl *>::Alignment,
       
   863 +  "Alignment is insufficient for objects appended to FunctionProtoType");
       
   864 +// And then, after any of those options, comes bool[]
       
   865 +static_assert(
       
   866 +  llvm::AlignOf<QualType>::Alignment >= llvm::AlignOf<bool>::Alignment,
       
   867 +  "Alignment is insufficient for objects appended to FunctionProtoType");
       
   868 +static_assert(
       
   869 +  llvm::AlignOf<Expr *>::Alignment >= llvm::AlignOf<bool>::Alignment,
       
   870 +  "Alignment is insufficient for objects appended to FunctionProtoType");
       
   871 +static_assert(
       
   872 +  llvm::AlignOf<FunctionDecl *>::Alignment >= llvm::AlignOf<bool>::Alignment,
       
   873 +  "Alignment is insufficient for objects appended to FunctionProtoType");
       
   874 +
       
   875  /// \brief Represents the dependent type named by a dependently-scoped
       
   876  /// typename using declaration, e.g.
       
   877  ///   using typename Base<T>::foo;
       
   878 @@ -3985,7 +4009,7 @@
       
   879  /// TemplateArguments, followed by a QualType representing the
       
   880  /// non-canonical aliased type when the template is a type alias
       
   881  /// template.
       
   882 -class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) TemplateSpecializationType
       
   883 +class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) TemplateSpecializationType
       
   884      : public Type,
       
   885        public llvm::FoldingSetNode {
       
   886    /// The name of the template being specialized.  This is
       
   887 @@ -3999,10 +4023,10 @@
       
   888  
       
   889    /// The number of template arguments named in this class template
       
   890    /// specialization.
       
   891 -  unsigned NumArgs : 31;
       
   892 +  unsigned NumArgs;
       
   893  
       
   894    /// Whether this template specialization type is a substituted type alias.
       
   895 -  bool TypeAlias : 1;
       
   896 +  bool TypeAlias;
       
   897  
       
   898    TemplateSpecializationType(TemplateName T,
       
   899                               const TemplateArgument *Args,
       
   900 @@ -4108,6 +4132,14 @@
       
   901    }
       
   902  };
       
   903  
       
   904 +// static_assert(llvm::AlignOf<TemplateSpecializationType>::Alignment >=
       
   905 +// llvm::AlignOf<TemplateArgument>::Alignment, "Alignment is insufficient for
       
   906 +// objects appended to TemplateSpecializationType");
       
   907 +// static_assert(llvm::AlignOf<TemplateArgument>::Alignment >=
       
   908 +// llvm::AlignOf<QualType>::Alignment, "Alignment is insufficient for objects
       
   909 +// appended to TemplateSpecializationType");
       
   910 +// ^ Moved after class TemplateArgument, as it is is forward declared here.
       
   911 +
       
   912  /// The injected class name of a C++ class template or class
       
   913  /// template partial specialization.  Used to record that a type was
       
   914  /// spelled with a bare identifier rather than as a template-id; the
       
   915 @@ -4446,6 +4478,11 @@
       
   916    }
       
   917  };
       
   918  
       
   919 +// static_assert(llvm::AlignOf<DependentTemplateSpecializationType>::Alignment
       
   920 +// >= llvm::AlignOf<TemplateArgument>::Alignment, "Alignment is insufficient for
       
   921 +// objects appended to DependentTemplateSpecializationType");
       
   922 +// ^ Moved after class TemplateArgument, as it is is forward declared here.
       
   923 +
       
   924  /// \brief Represents a pack expansion of types.
       
   925  ///
       
   926  /// Pack expansions are part of C++11 variadic templates. A pack
       
   927 @@ -4742,6 +4779,11 @@
       
   928                        bool isKindOf);
       
   929  };
       
   930  
       
   931 +static_assert(
       
   932 +  llvm::AlignOf<ObjCObjectTypeImpl>::Alignment >=
       
   933 +  llvm::AlignOf<ObjCProtocolDecl *>::Alignment,
       
   934 +  "Alignment is insufficient for objects appended to ObjCObjectTypeImpl");
       
   935 +
       
   936  inline QualType *ObjCObjectType::getTypeArgStorage() {
       
   937    return reinterpret_cast<QualType *>(static_cast<ObjCObjectTypeImpl*>(this)+1);
       
   938  }
       
   939 --- tools/clang/lib/AST/DeclBase.cpp	2016-01-06 17:49:11.000000000 -0500
       
   940 +++ tools/clang/lib/AST/DeclBase.cpp	2016-05-08 23:19:20.556431336 -0400
       
   941 @@ -46,9 +46,9 @@
       
   942  }
       
   943  
       
   944  #define DECL(DERIVED, BASE)                                                    \
       
   945 -  static_assert(Decl::DeclObjAlignment >=                                      \
       
   946 +  static_assert(llvm::AlignOf<uint64_t>::Alignment >=                          \
       
   947                      llvm::AlignOf<DERIVED##Decl>::Alignment,                   \
       
   948 -                "Alignment sufficient after objects prepended to " #DERIVED);
       
   949 +                "Alignment is insufficient for objects prepended to " #DERIVED);
       
   950  #define ABSTRACT_DECL(DECL)
       
   951  #include "clang/AST/DeclNodes.inc"
       
   952  
       
   953 @@ -56,12 +56,15 @@
       
   954                           unsigned ID, std::size_t Extra) {
       
   955    // Allocate an extra 8 bytes worth of storage, which ensures that the
       
   956    // resulting pointer will still be 8-byte aligned.
       
   957 -  static_assert(sizeof(unsigned) * 2 >= DeclObjAlignment,
       
   958 +  static_assert(sizeof(unsigned) * 2 >= llvm::AlignOf<uint64_t>::Alignment,
       
   959                  "Decl won't be misaligned");
       
   960 -  void *Start = Context.Allocate(Size + Extra + 8);
       
   961 -  void *Result = (char*)Start + 8;
       
   962 +  void *Start = Context.Allocate(Size + Extra + 8, 8U);
       
   963 +  void *Result = reinterpret_cast<void*>(
       
   964 +    reinterpret_cast<unsigned char*>(
       
   965 +      reinterpret_cast<unsigned char*>(Start) + 8));
       
   966  
       
   967 -  unsigned *PrefixPtr = (unsigned *)Result - 2;
       
   968 +  unsigned *PrefixPtr =
       
   969 +    reinterpret_cast<unsigned*>(reinterpret_cast<unsigned*>(Result) - 2);
       
   970  
       
   971    // Zero out the first 4 bytes; this is used to store the owning module ID.
       
   972    PrefixPtr[0] = 0;
       
   973 --- tools/clang/lib/AST/Decl.cpp	2016-01-12 04:01:25.000000000 -0500
       
   974 +++ tools/clang/lib/AST/Decl.cpp	2016-05-08 23:19:20.557431361 -0400
       
   975 @@ -3240,8 +3240,8 @@
       
   976  
       
   977  DependentFunctionTemplateSpecializationInfo *
       
   978  DependentFunctionTemplateSpecializationInfo::Create(
       
   979 -    ASTContext &Context, const UnresolvedSetImpl &Ts,
       
   980 -    const TemplateArgumentListInfo &TArgs) {
       
   981 +  ASTContext &Context, const UnresolvedSetImpl &Ts,
       
   982 +  const TemplateArgumentListInfo &TArgs) {
       
   983    void *Buffer = Context.Allocate(
       
   984        totalSizeToAlloc<TemplateArgumentLoc, FunctionTemplateDecl *>(
       
   985            TArgs.size(), Ts.size()));
       
   986 diff: tools/clang/lib/AST/Expr.cpp: No such file or directory
       
   987 --- tools/clang/lib/AST/ExprCXX.cpp	2016-01-06 17:34:54.000000000 -0500
       
   988 +++ tools/clang/lib/AST/ExprCXX.cpp	2016-05-08 23:19:20.558431385 -0400
       
   989 @@ -1083,7 +1083,7 @@
       
   990      *const_cast<clang::Stmt **>(&getStoredStmts()[NumCaptures]) =
       
   991          getCallOperator()->getBody();
       
   992  
       
   993 -  return static_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]);
       
   994 +  return reinterpret_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]);
       
   995  }
       
   996  
       
   997  bool LambdaExpr::isMutable() const {
       
   998 --- tools/clang/lib/AST/ItaniumMangle.cpp	2016-01-09 07:53:17.000000000 -0500
       
   999 +++ tools/clang/lib/AST/ItaniumMangle.cpp	2016-05-08 23:19:20.559431409 -0400
       
  1000 @@ -162,6 +162,8 @@
       
  1001    void mangleCXXDtorComdat(const CXXDestructorDecl *D, raw_ostream &) override;
       
  1002    void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &) override;
       
  1003    void mangleDynamicInitializer(const VarDecl *D, raw_ostream &Out) override;
       
  1004 +  void mangleGCCDynamicInitializer(const VarDecl *D, raw_ostream &Out) override;
       
  1005 +
       
  1006    void mangleDynamicAtExitDestructor(const VarDecl *D,
       
  1007                                       raw_ostream &Out) override;
       
  1008    void mangleSEHFilterExpression(const NamedDecl *EnclosingDecl,
       
  1009 @@ -4133,6 +4135,17 @@
       
  1010    Out << "__cxx_global_var_init";
       
  1011  }
       
  1012  
       
  1013 +void ItaniumMangleContextImpl::mangleGCCDynamicInitializer(const VarDecl *MD,
       
  1014 +                                                           raw_ostream &Out) {
       
  1015 +  static unsigned SEQ = 0UL;
       
  1016 +
       
  1017 +  // Mangle GCC's __static_initialiation_and_destruction_<X>
       
  1018 +  // .init_array function.
       
  1019 +  Out << "_Z41" << "__static_initialization_and_destruction_"
       
  1020 +    << SEQ << "ii";
       
  1021 +  ++SEQ;
       
  1022 +}
       
  1023 +
       
  1024  void ItaniumMangleContextImpl::mangleDynamicAtExitDestructor(const VarDecl *D,
       
  1025                                                               raw_ostream &Out) {
       
  1026    // Prefix the mangling of D with __dtor_.
       
  1027 --- tools/clang/lib/AST/MicrosoftMangle.cpp	2016-01-09 07:53:17.000000000 -0500
       
  1028 +++ tools/clang/lib/AST/MicrosoftMangle.cpp	2016-05-08 23:19:20.560431434 -0400
       
  1029 @@ -152,6 +152,8 @@
       
  1030    void mangleThreadSafeStaticGuardVariable(const VarDecl *D, unsigned GuardNum,
       
  1031                                             raw_ostream &Out) override;
       
  1032    void mangleDynamicInitializer(const VarDecl *D, raw_ostream &Out) override;
       
  1033 +  void mangleGCCDynamicInitializer(const VarDecl *D, raw_ostream &Out) override;
       
  1034 +
       
  1035    void mangleDynamicAtExitDestructor(const VarDecl *D,
       
  1036                                       raw_ostream &Out) override;
       
  1037    void mangleSEHFilterExpression(const NamedDecl *EnclosingDecl,
       
  1038 @@ -2857,6 +2859,12 @@
       
  1039  }
       
  1040  
       
  1041  void
       
  1042 +MicrosoftMangleContextImpl::mangleGCCDynamicInitializer(const VarDecl *D,
       
  1043 +                                                        raw_ostream &Out) {
       
  1044 +  this->mangleDynamicInitializer(D, Out);
       
  1045 +}
       
  1046 +
       
  1047 +void
       
  1048  MicrosoftMangleContextImpl::mangleDynamicAtExitDestructor(const VarDecl *D,
       
  1049                                                            raw_ostream &Out) {
       
  1050    // <destructor-name> ::= ?__F <name> YAXXZ
       
  1051 --- tools/clang/lib/AST/NestedNameSpecifier.cpp	2015-12-27 09:34:22.000000000 -0500
       
  1052 +++ tools/clang/lib/AST/NestedNameSpecifier.cpp	2016-05-08 23:19:20.560431434 -0400
       
  1053 @@ -445,22 +445,41 @@
       
  1054  
       
  1055      if (BufferSize + (End - Start) > BufferCapacity) {
       
  1056        // Reallocate the buffer.
       
  1057 -      unsigned NewCapacity = std::max(
       
  1058 -          (unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2),
       
  1059 -          (unsigned)(BufferSize + (End - Start)));
       
  1060 -      char *NewBuffer = static_cast<char *>(malloc(NewCapacity));
       
  1061 -      if (BufferCapacity) {
       
  1062 -        memcpy(NewBuffer, Buffer, BufferSize);
       
  1063 -        free(Buffer);
       
  1064 -      }
       
  1065 +      unsigned NewCapacity =
       
  1066 +        std::max((unsigned)(BufferCapacity ? BufferCapacity * 2
       
  1067 +            : sizeof(void*) * 2), (unsigned)(BufferSize + (End - Start)));
       
  1068 +
       
  1069 +      NewCapacity =
       
  1070 +        llvm::RoundUpToAlignment(NewCapacity, llvm::alignOf<uint64_t>());
       
  1071 +      unsigned Alignment = ((NewCapacity < 5) ? 4 : 8);
       
  1072 +      if (NewCapacity < Alignment)
       
  1073 +        NewCapacity = Alignment;
       
  1074 +
       
  1075 +      char *NewBuffer;
       
  1076 +#if defined(_MSC_VER)
       
  1077 +      NewBuffer = _aligned_malloc((size_t) NewCapacity, (size_t) Alignment);
       
  1078 +      assert(NewBuffer && "_aligned_malloc failed!");
       
  1079 +#else
       
  1080 +      int R = posix_memalign((void**) &NewBuffer, Alignment, NewCapacity);
       
  1081 +
       
  1082 +      assert((R == 0) && "posix_memalign failed!");
       
  1083 +      assert(NewBuffer && "Memory allocation failed!");
       
  1084 +#endif
       
  1085 +
       
  1086 +      if ((Buffer != 0) && (BufferSize > 0))
       
  1087 +        (void) std::memcpy(NewBuffer, Buffer, BufferSize);
       
  1088 +
       
  1089 +      if ((Buffer != 0) && (BufferSize > 0))
       
  1090 +        std::free(static_cast<void*>(Buffer));
       
  1091 +
       
  1092        Buffer = NewBuffer;
       
  1093        BufferCapacity = NewCapacity;
       
  1094      }
       
  1095 -    
       
  1096 -    memcpy(Buffer + BufferSize, Start, End - Start);
       
  1097 +
       
  1098 +    (void) std::memcpy(Buffer + BufferSize, Start, End - Start);
       
  1099      BufferSize += End-Start;
       
  1100    }
       
  1101 -  
       
  1102 +
       
  1103    /// \brief Save a source location to the given buffer.
       
  1104    void SaveSourceLocation(SourceLocation Loc, char *&Buffer,
       
  1105                            unsigned &BufferSize, unsigned &BufferCapacity) {
       
  1106 @@ -469,7 +488,7 @@
       
  1107             reinterpret_cast<char *>(&Raw) + sizeof(unsigned),
       
  1108             Buffer, BufferSize, BufferCapacity);
       
  1109    }
       
  1110 -  
       
  1111 +
       
  1112    /// \brief Save a pointer to the given buffer.
       
  1113    void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize,
       
  1114                     unsigned &BufferCapacity) {
       
  1115 @@ -480,13 +499,13 @@
       
  1116  }
       
  1117  
       
  1118  NestedNameSpecifierLocBuilder::
       
  1119 -NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other) 
       
  1120 +NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other)
       
  1121    : Representation(Other.Representation), Buffer(nullptr),
       
  1122      BufferSize(0), BufferCapacity(0)
       
  1123  {
       
  1124    if (!Other.Buffer)
       
  1125      return;
       
  1126 -  
       
  1127 +
       
  1128    if (Other.BufferCapacity == 0) {
       
  1129      // Shallow copy is okay.
       
  1130      Buffer = Other.Buffer;
       
  1131 diff: tools/clang/lib/AST/Stmt.cpp: No such file or directory
       
  1132 --- tools/clang/lib/AST/TemplateBase.cpp	2015-12-29 13:15:14.000000000 -0500
       
  1133 +++ tools/clang/lib/AST/TemplateBase.cpp	2016-05-08 23:19:20.561431458 -0400
       
  1134 @@ -71,6 +71,7 @@
       
  1135  
       
  1136  TemplateArgument::TemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value,
       
  1137                                     QualType Type) {
       
  1138 +  (void) std::memset(Buffer, 0, sizeof(Buffer));
       
  1139    Integer.Kind = Integral;
       
  1140    // Copy the APSInt value into our decomposed form.
       
  1141    Integer.BitWidth = Value.getBitWidth();
       
  1142 @@ -78,9 +79,9 @@
       
  1143    // If the value is large, we have to get additional memory from the ASTContext
       
  1144    unsigned NumWords = Value.getNumWords();
       
  1145    if (NumWords > 1) {
       
  1146 -    void *Mem = Ctx.Allocate(NumWords * sizeof(uint64_t));
       
  1147 +    void *Mem = Ctx.Allocate(NumWords * sizeof(uint64_t), alignof(uint64_t));
       
  1148      std::memcpy(Mem, Value.getRawData(), NumWords * sizeof(uint64_t));
       
  1149 -    Integer.pVal = static_cast<uint64_t *>(Mem);
       
  1150 +    Integer.pVal = reinterpret_cast<uint64_t *>(Mem);
       
  1151    } else {
       
  1152      Integer.VAL = Value.getZExtValue();
       
  1153    }
       
  1154 @@ -420,7 +421,9 @@
       
  1155  //===----------------------------------------------------------------------===//
       
  1156  
       
  1157  TemplateArgumentLocInfo::TemplateArgumentLocInfo() {
       
  1158 -  memset((void*)this, 0, sizeof(TemplateArgumentLocInfo));
       
  1159 +  (void) std::memset(Buffer, 0, sizeof(Buffer));
       
  1160 +  Expression = nullptr;
       
  1161 +  Declarator = nullptr;
       
  1162  }
       
  1163  
       
  1164  SourceRange TemplateArgumentLoc::getSourceRange() const {
       
  1165 --- tools/clang/lib/AST/Type.cpp	2016-01-09 07:53:17.000000000 -0500
       
  1166 +++ tools/clang/lib/AST/Type.cpp	2016-05-08 23:19:20.562431482 -0400
       
  1167 @@ -2466,7 +2466,10 @@
       
  1168      if (Args[I].containsUnexpandedParameterPack())
       
  1169        setContainsUnexpandedParameterPack();
       
  1170  
       
  1171 -    new (&getArgBuffer()[I]) TemplateArgument(Args[I]);
       
  1172 +    TemplateArgument *TA = getArgBuffer();
       
  1173 +    TA = &(TA[I]);
       
  1174 +    TA = new (TA) TemplateArgument();
       
  1175 +    *TA = Args[I];
       
  1176    }
       
  1177  }
       
  1178