r256683 - [TrailingObjects] Convert classes in OpenMPClause.h

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 31 16:38:25 PST 2015


Author: jyknight
Date: Thu Dec 31 18:38:24 2015
New Revision: 256683

URL: http://llvm.org/viewvc/llvm-project?rev=256683&view=rev
Log:
[TrailingObjects] Convert classes in OpenMPClause.h

Modified:
    cfe/trunk/include/clang/AST/OpenMPClause.h
    cfe/trunk/lib/AST/OpenMPClause.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=256683&r1=256682&r2=256683&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Dec 31 18:38:24 2015
@@ -84,21 +84,15 @@ protected:
   /// \brief Fetches list of variables associated with this clause.
   MutableArrayRef<Expr *> getVarRefs() {
     return MutableArrayRef<Expr *>(
-        reinterpret_cast<Expr **>(
-            reinterpret_cast<char *>(this) +
-            llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>())),
-        NumVars);
+        static_cast<T *>(this)->template getTrailingObjects<Expr *>(), NumVars);
   }
 
   /// \brief Sets the list of variables for this clause.
   void setVarRefs(ArrayRef<Expr *> VL) {
     assert(VL.size() == NumVars &&
            "Number of variables is not the same as the preallocated buffer");
-    std::copy(
-        VL.begin(), VL.end(),
-        reinterpret_cast<Expr **>(
-            reinterpret_cast<char *>(this) +
-            llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>())));
+    std::copy(VL.begin(), VL.end(),
+              static_cast<T *>(this)->template getTrailingObjects<Expr *>());
   }
 
   /// \brief Build a clause with \a N variables
@@ -142,9 +136,7 @@ public:
   /// \brief Fetches list of all variables in the clause.
   ArrayRef<const Expr *> getVarRefs() const {
     return llvm::makeArrayRef(
-        reinterpret_cast<const Expr *const *>(
-            reinterpret_cast<const char *>(this) +
-            llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<const Expr *>())),
+        static_cast<const T *>(this)->template getTrailingObjects<Expr *>(),
         NumVars);
   }
 };
@@ -1160,7 +1152,11 @@ public:
 /// In this example directive '#pragma omp parallel' has clause 'private'
 /// with the variables 'a' and 'b'.
 ///
-class OMPPrivateClause : public OMPVarListClause<OMPPrivateClause> {
+class OMPPrivateClause final
+    : public OMPVarListClause<OMPPrivateClause>,
+      private llvm::TrailingObjects<OMPPrivateClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
   /// \brief Build clause with number of variables \a N.
   ///
@@ -1252,7 +1248,11 @@ public:
 /// In this example directive '#pragma omp parallel' has clause 'firstprivate'
 /// with the variables 'a' and 'b'.
 ///
-class OMPFirstprivateClause : public OMPVarListClause<OMPFirstprivateClause> {
+class OMPFirstprivateClause final
+    : public OMPVarListClause<OMPFirstprivateClause>,
+      private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
 
   /// \brief Build clause with number of variables \a N.
@@ -1372,7 +1372,9 @@ public:
 /// \endcode
 /// In this example directive '#pragma omp simd' has clause 'lastprivate'
 /// with the variables 'a' and 'b'.
-class OMPLastprivateClause : public OMPVarListClause<OMPLastprivateClause> {
+class OMPLastprivateClause final
+    : public OMPVarListClause<OMPLastprivateClause>,
+      private llvm::TrailingObjects<OMPLastprivateClause, Expr *> {
   // There are 4 additional tail-allocated arrays at the end of the class:
   // 1. Contains list of pseudo variables with the default initialization for
   // each non-firstprivate variables. Used in codegen for initialization of
@@ -1390,6 +1392,8 @@ class OMPLastprivateClause : public OMPV
   // Required for proper codegen of final assignment performed by the
   // lastprivate clause.
   //
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
 
   /// \brief Build clause with number of variables \a N.
@@ -1557,7 +1561,11 @@ public:
 /// In this example directive '#pragma omp parallel' has clause 'shared'
 /// with the variables 'a' and 'b'.
 ///
-class OMPSharedClause : public OMPVarListClause<OMPSharedClause> {
+class OMPSharedClause final
+    : public OMPVarListClause<OMPSharedClause>,
+      private llvm::TrailingObjects<OMPSharedClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   /// \brief Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -1617,7 +1625,11 @@ public:
 /// In this example directive '#pragma omp parallel' has clause 'reduction'
 /// with operator '+' and the variables 'a' and 'b'.
 ///
-class OMPReductionClause : public OMPVarListClause<OMPReductionClause> {
+class OMPReductionClause final
+    : public OMPVarListClause<OMPReductionClause>,
+      private llvm::TrailingObjects<OMPReductionClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
   /// \brief Location of ':'.
   SourceLocation ColonLoc;
@@ -1819,7 +1831,11 @@ public:
 /// In this example directive '#pragma omp simd' has clause 'linear'
 /// with variables 'a', 'b' and linear step '2'.
 ///
-class OMPLinearClause : public OMPVarListClause<OMPLinearClause> {
+class OMPLinearClause final
+    : public OMPVarListClause<OMPLinearClause>,
+      private llvm::TrailingObjects<OMPLinearClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
   /// \brief Modifier of 'linear' clause.
   OpenMPLinearClauseKind Modifier;
@@ -2039,7 +2055,11 @@ public:
 /// In this example directive '#pragma omp simd' has clause 'aligned'
 /// with variables 'a', 'b' and alignment '8'.
 ///
-class OMPAlignedClause : public OMPVarListClause<OMPAlignedClause> {
+class OMPAlignedClause final
+    : public OMPVarListClause<OMPAlignedClause>,
+      private llvm::TrailingObjects<OMPAlignedClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
   /// \brief Location of ':'.
   SourceLocation ColonLoc;
@@ -2123,7 +2143,9 @@ public:
 /// In this example directive '#pragma omp parallel' has clause 'copyin'
 /// with the variables 'a' and 'b'.
 ///
-class OMPCopyinClause : public OMPVarListClause<OMPCopyinClause> {
+class OMPCopyinClause final
+    : public OMPVarListClause<OMPCopyinClause>,
+      private llvm::TrailingObjects<OMPCopyinClause, Expr *> {
   // Class has 3 additional tail allocated arrays:
   // 1. List of helper expressions for proper generation of assignment operation
   // required for copyin clause. This list represents sources.
@@ -2137,6 +2159,8 @@ class OMPCopyinClause : public OMPVarLis
   // threadprivate variables to local instances of that variables in other
   // implicit threads.
 
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
   /// \brief Build clause with number of variables \a N.
   ///
@@ -2282,7 +2306,11 @@ public:
 /// In this example directive '#pragma omp single' has clause 'copyprivate'
 /// with the variables 'a' and 'b'.
 ///
-class OMPCopyprivateClause : public OMPVarListClause<OMPCopyprivateClause> {
+class OMPCopyprivateClause final
+    : public OMPVarListClause<OMPCopyprivateClause>,
+      private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
   /// \brief Build clause with number of variables \a N.
   ///
@@ -2431,7 +2459,11 @@ public:
 /// In this example directive '#pragma omp flush' has implicit clause 'flush'
 /// with the variables 'a' and 'b'.
 ///
-class OMPFlushClause : public OMPVarListClause<OMPFlushClause> {
+class OMPFlushClause final
+    : public OMPVarListClause<OMPFlushClause>,
+      private llvm::TrailingObjects<OMPFlushClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   /// \brief Build clause with number of variables \a N.
   ///
   /// \param StartLoc Starting location of the clause.
@@ -2491,7 +2523,11 @@ public:
 /// In this example directive '#pragma omp task' with clause 'depend' with the
 /// variables 'a' and 'b' with dependency 'in'.
 ///
-class OMPDependClause : public OMPVarListClause<OMPDependClause> {
+class OMPDependClause final
+    : public OMPVarListClause<OMPDependClause>,
+      private llvm::TrailingObjects<OMPDependClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
   /// \brief Dependency type (one of in, out, inout).
   OpenMPDependClauseKind DepKind;
@@ -2695,7 +2731,10 @@ public:
 /// In this example directive '#pragma omp target' has clause 'map'
 /// with the variables 'a' and 'b'.
 ///
-class OMPMapClause : public OMPVarListClause<OMPMapClause> {
+class OMPMapClause final : public OMPVarListClause<OMPMapClause>,
+                           private llvm::TrailingObjects<OMPMapClause, Expr *> {
+  friend TrailingObjects;
+  friend class OMPVarListClause;
   friend class OMPClauseReader;
 
   /// \brief Map type modifier for the 'map' clause.

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=256683&r1=256682&r2=256683&view=diff
==============================================================================
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Thu Dec 31 18:38:24 2015
@@ -40,9 +40,7 @@ OMPPrivateClause::Create(const ASTContex
                          SourceLocation LParenLoc, SourceLocation EndLoc,
                          ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
   // Allocate space for private variables and initializer expressions.
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPPrivateClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         2 * sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
   OMPPrivateClause *Clause =
       new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -52,9 +50,7 @@ OMPPrivateClause::Create(const ASTContex
 
 OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C,
                                                 unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPPrivateClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         2 * sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
   return new (Mem) OMPPrivateClause(N);
 }
 
@@ -75,9 +71,7 @@ OMPFirstprivateClause::Create(const ASTC
                               SourceLocation LParenLoc, SourceLocation EndLoc,
                               ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
                               ArrayRef<Expr *> InitVL) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFirstprivateClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         3 * sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
   OMPFirstprivateClause *Clause =
       new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -88,9 +82,7 @@ OMPFirstprivateClause::Create(const ASTC
 
 OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C,
                                                           unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFirstprivateClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         3 * sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
   return new (Mem) OMPFirstprivateClause(N);
 }
 
@@ -126,9 +118,7 @@ OMPLastprivateClause *OMPLastprivateClau
     const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
     SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
     ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLastprivateClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         5 * sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
   OMPLastprivateClause *Clause =
       new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -140,9 +130,7 @@ OMPLastprivateClause *OMPLastprivateClau
 
 OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C,
                                                         unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLastprivateClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         5 * sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
   return new (Mem) OMPLastprivateClause(N);
 }
 
@@ -151,9 +139,7 @@ OMPSharedClause *OMPSharedClause::Create
                                          SourceLocation LParenLoc,
                                          SourceLocation EndLoc,
                                          ArrayRef<Expr *> VL) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPSharedClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
   OMPSharedClause *Clause =
       new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -161,9 +147,7 @@ OMPSharedClause *OMPSharedClause::Create
 }
 
 OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPSharedClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
   return new (Mem) OMPSharedClause(N);
 }
 
@@ -198,9 +182,7 @@ OMPLinearClause *OMPLinearClause::Create
     ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep) {
   // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
   // (Step and CalcStep).
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLinearClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         (5 * VL.size() + 2) * sizeof(Expr *));
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
   OMPLinearClause *Clause = new (Mem) OMPLinearClause(
       StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -221,9 +203,7 @@ OMPLinearClause *OMPLinearClause::Create
                                               unsigned NumVars) {
   // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
   // (Step and CalcStep).
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLinearClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         (5 * NumVars + 2) * sizeof(Expr *));
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
   return new (Mem) OMPLinearClause(NumVars);
 }
 
@@ -231,9 +211,7 @@ OMPAlignedClause *
 OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc,
                          SourceLocation LParenLoc, SourceLocation ColonLoc,
                          SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPAlignedClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         sizeof(Expr *) * (VL.size() + 1));
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
   OMPAlignedClause *Clause = new (Mem)
       OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -243,9 +221,7 @@ OMPAlignedClause::Create(const ASTContex
 
 OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C,
                                                 unsigned NumVars) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPAlignedClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         sizeof(Expr *) * (NumVars + 1));
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
   return new (Mem) OMPAlignedClause(NumVars);
 }
 
@@ -275,9 +251,7 @@ OMPCopyinClause *OMPCopyinClause::Create
     const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
     SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
     ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyinClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         4 * sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
   OMPCopyinClause *Clause =
       new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -288,9 +262,7 @@ OMPCopyinClause *OMPCopyinClause::Create
 }
 
 OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyinClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         4 * sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
   return new (Mem) OMPCopyinClause(N);
 }
 
@@ -320,9 +292,7 @@ OMPCopyprivateClause *OMPCopyprivateClau
     const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
     SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
     ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyprivateClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         4 * sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
   OMPCopyprivateClause *Clause =
       new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -334,9 +304,7 @@ OMPCopyprivateClause *OMPCopyprivateClau
 
 OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C,
                                                         unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyprivateClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         4 * sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
   return new (Mem) OMPCopyprivateClause(N);
 }
 
@@ -373,9 +341,7 @@ OMPReductionClause *OMPReductionClause::
     NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
     ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
     ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPReductionClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         5 * sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
   OMPReductionClause *Clause = new (Mem) OMPReductionClause(
       StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
   Clause->setVarRefs(VL);
@@ -388,9 +354,7 @@ OMPReductionClause *OMPReductionClause::
 
 OMPReductionClause *OMPReductionClause::CreateEmpty(const ASTContext &C,
                                                     unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPReductionClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         5 * sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
   return new (Mem) OMPReductionClause(N);
 }
 
@@ -399,9 +363,7 @@ OMPFlushClause *OMPFlushClause::Create(c
                                        SourceLocation LParenLoc,
                                        SourceLocation EndLoc,
                                        ArrayRef<Expr *> VL) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFlushClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
   OMPFlushClause *Clause =
       new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -409,9 +371,7 @@ OMPFlushClause *OMPFlushClause::Create(c
 }
 
 OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFlushClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
   return new (Mem) OMPFlushClause(N);
 }
 
@@ -420,9 +380,7 @@ OMPDependClause::Create(const ASTContext
                         SourceLocation LParenLoc, SourceLocation EndLoc,
                         OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
                         SourceLocation ColonLoc, ArrayRef<Expr *> VL) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPDependClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
   OMPDependClause *Clause =
       new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -433,9 +391,7 @@ OMPDependClause::Create(const ASTContext
 }
 
 OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N) {
-  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPDependClause),
-                                                  llvm::alignOf<Expr *>()) +
-                         sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
   return new (Mem) OMPDependClause(N);
 }
 
@@ -445,9 +401,7 @@ OMPMapClause *OMPMapClause::Create(const
                                    OpenMPMapClauseKind TypeModifier,
                                    OpenMPMapClauseKind Type,
                                    SourceLocation TypeLoc) {
-  void *Mem = C.Allocate(
-      llvm::RoundUpToAlignment(sizeof(OMPMapClause), llvm::alignOf<Expr *>()) +
-      sizeof(Expr *) * VL.size());
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
   OMPMapClause *Clause = new (Mem) OMPMapClause(
       TypeModifier, Type, TypeLoc, StartLoc, LParenLoc, EndLoc, VL.size());
   Clause->setVarRefs(VL);
@@ -458,8 +412,6 @@ OMPMapClause *OMPMapClause::Create(const
 }
 
 OMPMapClause *OMPMapClause::CreateEmpty(const ASTContext &C, unsigned N) {
-  void *Mem = C.Allocate(
-      llvm::RoundUpToAlignment(sizeof(OMPMapClause), llvm::alignOf<Expr *>()) +
-      sizeof(Expr *) * N);
+  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
   return new (Mem) OMPMapClause(N);
 }




More information about the cfe-commits mailing list