DeclOpenMP.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include "clang/AST/ASTContext.h"
  14. #include "clang/AST/Decl.h"
  15. #include "clang/AST/DeclBase.h"
  16. #include "clang/AST/DeclOpenMP.h"
  17. #include "clang/AST/Expr.h"
  18. using namespace clang;
  19. //===----------------------------------------------------------------------===//
  20. // OMPThreadPrivateDecl Implementation.
  21. //===----------------------------------------------------------------------===//
  22. void OMPThreadPrivateDecl::anchor() { }
  23. OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C,
  24. DeclContext *DC,
  25. SourceLocation L,
  26. ArrayRef<Expr *> VL) {
  27. OMPThreadPrivateDecl *D = new (C, DC, VL.size() * sizeof(Expr *))
  28. OMPThreadPrivateDecl(OMPThreadPrivate, DC, L);
  29. D->NumVars = VL.size();
  30. D->setVars(VL);
  31. return D;
  32. }
  33. OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C,
  34. unsigned ID,
  35. unsigned N) {
  36. OMPThreadPrivateDecl *D = new (C, ID, N * sizeof(Expr *))
  37. OMPThreadPrivateDecl(OMPThreadPrivate, nullptr, SourceLocation());
  38. D->NumVars = N;
  39. return D;
  40. }
  41. void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) {
  42. assert(VL.size() == NumVars &&
  43. "Number of variables is not the same as the preallocated buffer");
  44. Expr **Vars = reinterpret_cast<Expr **>(this + 1);
  45. std::copy(VL.begin(), VL.end(), Vars);
  46. }