clang API Documentation

DeclOpenMP.cpp
Go to the documentation of this file.
00001 //===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 /// \file
00010 /// \brief This file implements OMPThreadPrivateDecl class.
00011 ///
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "clang/AST/ASTContext.h"
00015 #include "clang/AST/Decl.h"
00016 #include "clang/AST/DeclBase.h"
00017 #include "clang/AST/DeclOpenMP.h"
00018 #include "clang/AST/Expr.h"
00019 
00020 using namespace clang;
00021 
00022 //===----------------------------------------------------------------------===//
00023 // OMPThreadPrivateDecl Implementation.
00024 //===----------------------------------------------------------------------===//
00025 
00026 void OMPThreadPrivateDecl::anchor() { }
00027 
00028 OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
00029                                                    DeclContext *DC,
00030                                                    SourceLocation L,
00031                                                    ArrayRef<Expr *> VL) {
00032   OMPThreadPrivateDecl *D = new (C, DC, VL.size() * sizeof(Expr *))
00033       OMPThreadPrivateDecl(OMPThreadPrivate, DC, L);
00034   D->NumVars = VL.size();
00035   D->setVars(VL);
00036   return D;
00037 }
00038 
00039 OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
00040                                                                unsigned ID,
00041                                                                unsigned N) {
00042   OMPThreadPrivateDecl *D = new (C, ID, N * sizeof(Expr *))
00043       OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, SourceLocation());
00044   D->NumVars = N;
00045   return D;
00046 }
00047 
00048 void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
00049   assert(VL.size() == NumVars &&
00050          "Number of variables is not the same as the preallocated buffer");
00051   Expr **Vars = reinterpret_cast<Expr **>(this + 1);
00052   std::copy(VL.begin(), VL.end(), Vars);
00053 }
00054