clang  6.0.0svn
DeclOpenMP.cpp
Go to the documentation of this file.
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 
30  DeclContext *DC,
32  ArrayRef<Expr *> VL) {
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 
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 
64  QualType T, OMPDeclareReductionDecl *PrevDeclInScope) {
65  return new (C, DC) OMPDeclareReductionDecl(OMPDeclareReduction, DC, L, Name,
66  T, PrevDeclInScope);
67 }
68 
71  return new (C, ID) OMPDeclareReductionDecl(
72  OMPDeclareReduction, /*DC=*/nullptr, SourceLocation(), DeclarationName(),
73  QualType(), /*PrevDeclInScope=*/nullptr);
74 }
75 
77  return cast_or_null<OMPDeclareReductionDecl>(
78  PrevDeclInScope.get(getASTContext().getExternalSource()));
79 }
82  return cast_or_null<OMPDeclareReductionDecl>(
83  PrevDeclInScope.get(getASTContext().getExternalSource()));
84 }
85 
86 //===----------------------------------------------------------------------===//
87 // OMPCapturedExprDecl Implementation.
88 //===----------------------------------------------------------------------===//
89 
90 void OMPCapturedExprDecl::anchor() {}
91 
94  SourceLocation StartLoc) {
95  return new (C, DC) OMPCapturedExprDecl(C, DC, Id, T, StartLoc);
96 }
97 
99  unsigned ID) {
100  return new (C, ID)
101  OMPCapturedExprDecl(C, nullptr, nullptr, QualType(), SourceLocation());
102 }
103 
105  assert(hasInit());
106  return SourceRange(getInit()->getLocStart(), getInit()->getLocEnd());
107 }
Defines the clang::ASTContext interface.
A (possibly-)qualified type.
Definition: Type.h:653
static OMPDeclareReductionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, QualType T, OMPDeclareReductionDecl *PrevDeclInScope)
Create declare reduction node.
Definition: DeclOpenMP.cpp:62
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:412
One of these records is kept for each identifier that is lexed.
static OMPThreadPrivateDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned N)
Definition: DeclOpenMP.cpp:41
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:149
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclOpenMP.cpp:104
static OMPCapturedExprDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Definition: DeclOpenMP.cpp:98
int Id
Definition: ASTDiff.cpp:191
const FunctionProtoType * T
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name...
Definition: DeclOpenMP.cpp:76
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclBase.h:408
Encodes a location in the source.
This represents &#39;#pragma omp declare reduction ...&#39; directive.
Definition: DeclOpenMP.h:102
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:187
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:365
This file defines OpenMP nodes for declarative directives.
static OMPCapturedExprDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, QualType T, SourceLocation StartLoc)
Definition: DeclOpenMP.cpp:92
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1252
static OMPThreadPrivateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef< Expr *> VL)
Definition: DeclOpenMP.cpp:29
DeclarationName - The name of a declaration.
static OMPDeclareReductionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Create deserialized declare reduction node.
Definition: DeclOpenMP.cpp:70
A trivial tuple used to represent a source range.
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:39