]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/AST/DeclOpenMP.cpp
Update clang to release_39 branch r276489, and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / AST / DeclOpenMP.cpp
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, OMPCapturedExprDecl
11 /// classes.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Decl.h"
17 #include "clang/AST/DeclBase.h"
18 #include "clang/AST/DeclOpenMP.h"
19 #include "clang/AST/Expr.h"
20
21 using namespace clang;
22
23 //===----------------------------------------------------------------------===//
24 // OMPThreadPrivateDecl Implementation.
25 //===----------------------------------------------------------------------===//
26
27 void OMPThreadPrivateDecl::anchor() { }
28
29 OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
30                                                    DeclContext *DC,
31                                                    SourceLocation L,
32                                                    ArrayRef<Expr *> VL) {
33   OMPThreadPrivateDecl *D =
34       new (C, DC, additionalSizeToAlloc<Expr *>(VL.size()))
35           OMPThreadPrivateDecl(OMPThreadPrivate, DC, L);
36   D->NumVars = VL.size();
37   D->setVars(VL);
38   return D;
39 }
40
41 OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
42                                                                unsigned ID,
43                                                                unsigned N) {
44   OMPThreadPrivateDecl *D = new (C, ID, additionalSizeToAlloc<Expr *>(N))
45       OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, SourceLocation());
46   D->NumVars = N;
47   return D;
48 }
49
50 void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
51   assert(VL.size() == NumVars &&
52          "Number of variables is not the same as the preallocated buffer");
53   std::uninitialized_copy(VL.begin(), VL.end(), getTrailingObjects<Expr *>());
54 }
55
56 //===----------------------------------------------------------------------===//
57 // OMPDeclareReductionDecl Implementation.
58 //===----------------------------------------------------------------------===//
59
60 void OMPDeclareReductionDecl::anchor() {}
61
62 OMPDeclareReductionDecl *OMPDeclareReductionDecl::Create(
63     ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name,
64     QualType T, OMPDeclareReductionDecl *PrevDeclInScope) {
65   return new (C, DC) OMPDeclareReductionDecl(OMPDeclareReduction, DC, L, Name,
66                                              T, PrevDeclInScope);
67 }
68
69 OMPDeclareReductionDecl *
70 OMPDeclareReductionDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
71   return new (C, ID) OMPDeclareReductionDecl(
72       OMPDeclareReduction, /*DC=*/nullptr, SourceLocation(), DeclarationName(),
73       QualType(), /*PrevDeclInScope=*/nullptr);
74 }
75
76 OMPDeclareReductionDecl *OMPDeclareReductionDecl::getPrevDeclInScope() {
77   return cast_or_null<OMPDeclareReductionDecl>(
78       PrevDeclInScope.get(getASTContext().getExternalSource()));
79 }
80 const OMPDeclareReductionDecl *
81 OMPDeclareReductionDecl::getPrevDeclInScope() const {
82   return cast_or_null<OMPDeclareReductionDecl>(
83       PrevDeclInScope.get(getASTContext().getExternalSource()));
84 }
85
86 //===----------------------------------------------------------------------===//
87 // OMPCapturedExprDecl Implementation.
88 //===----------------------------------------------------------------------===//
89
90 void OMPCapturedExprDecl::anchor() {}
91
92 OMPCapturedExprDecl *OMPCapturedExprDecl::Create(ASTContext &C, DeclContext *DC,
93                                                  IdentifierInfo *Id,
94                                                  QualType T) {
95   return new (C, DC) OMPCapturedExprDecl(C, DC, Id, T);
96 }
97
98 OMPCapturedExprDecl *OMPCapturedExprDecl::CreateDeserialized(ASTContext &C,
99                                                              unsigned ID) {
100   return new (C, ID) OMPCapturedExprDecl(C, nullptr, nullptr, QualType());
101 }
102