summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/OpenMPClause.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/OpenMPClause.cpp')
-rw-r--r--clang/lib/AST/OpenMPClause.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index f062c3e463a..790b4401229 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -1162,8 +1162,8 @@ OMPNontemporalClause *OMPNontemporalClause::Create(const ASTContext &C,
SourceLocation LParenLoc,
SourceLocation EndLoc,
ArrayRef<Expr *> VL) {
- // Allocate space for nontemporal variables.
- void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
+ // Allocate space for nontemporal variables + private references.
+ void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
auto *Clause =
new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
Clause->setVarRefs(VL);
@@ -1172,10 +1172,16 @@ OMPNontemporalClause *OMPNontemporalClause::Create(const ASTContext &C,
OMPNontemporalClause *OMPNontemporalClause::CreateEmpty(const ASTContext &C,
unsigned N) {
- void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
+ void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
return new (Mem) OMPNontemporalClause(N);
}
+void OMPNontemporalClause::setPrivateRefs(ArrayRef<Expr *> VL) {
+ assert(VL.size() == varlist_size() && "Number of private references is not "
+ "the same as the preallocated buffer");
+ std::copy(VL.begin(), VL.end(), varlist_end());
+}
+
//===----------------------------------------------------------------------===//
// OpenMP clauses printing methods
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud