Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 1 | //===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// \file |
| 10 | /// \brief This file implements OMPThreadPrivateDecl class. |
| 11 | /// |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/AST/ASTContext.h" |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 15 | #include "clang/AST/Decl.h" |
Chandler Carruth | 5553d0d | 2014-01-07 11:51:46 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclBase.h" |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclOpenMP.h" |
| 18 | #include "clang/AST/Expr.h" |
| 19 | |
| 20 | using namespace clang; |
| 21 | |
| 22 | //===----------------------------------------------------------------------===// |
| 23 | // OMPThreadPrivateDecl Implementation. |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | |
| 26 | void OMPThreadPrivateDecl::anchor() { } |
| 27 | |
| 28 | OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C, |
| 29 | DeclContext *DC, |
| 30 | SourceLocation L, |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 31 | ArrayRef<Expr *> VL) { |
Richard Smith | f798172 | 2013-11-22 09:01:48 +0000 | [diff] [blame] | 32 | OMPThreadPrivateDecl *D = new (C, DC, VL.size() * sizeof(Expr *)) |
| 33 | OMPThreadPrivateDecl(OMPThreadPrivate, DC, L); |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 34 | D->NumVars = VL.size(); |
| 35 | D->setVars(VL); |
| 36 | return D; |
| 37 | } |
| 38 | |
| 39 | OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C, |
| 40 | unsigned ID, |
| 41 | unsigned N) { |
Richard Smith | f798172 | 2013-11-22 09:01:48 +0000 | [diff] [blame] | 42 | OMPThreadPrivateDecl *D = new (C, ID, N * sizeof(Expr *)) |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 43 | OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, SourceLocation()); |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 44 | D->NumVars = N; |
| 45 | return D; |
| 46 | } |
| 47 | |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 48 | void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) { |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 49 | assert(VL.size() == NumVars && |
| 50 | "Number of variables is not the same as the preallocated buffer"); |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 51 | Expr **Vars = reinterpret_cast<Expr **>(this + 1); |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 52 | std::copy(VL.begin(), VL.end(), Vars); |
| 53 | } |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 54 | |