xref: /freebsd/contrib/llvm-project/clang/lib/AST/DeclOpenACC.cpp (revision 700637cbb5e582861067a11aaca4d053546871d2)
1*700637cbSDimitry Andric //===--- DeclOpenACC.cpp - Classes for OpenACC Constructs -----------------===//
2*700637cbSDimitry Andric //
3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*700637cbSDimitry Andric //
7*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
8*700637cbSDimitry Andric //
9*700637cbSDimitry Andric // This file implements the subclasses of Decl class declared in Decl.h
10*700637cbSDimitry Andric //
11*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
12*700637cbSDimitry Andric 
13*700637cbSDimitry Andric #include "clang/AST/DeclOpenACC.h"
14*700637cbSDimitry Andric #include "clang/AST/ASTContext.h"
15*700637cbSDimitry Andric #include "clang/AST/Attr.h"
16*700637cbSDimitry Andric #include "clang/AST/OpenACCClause.h"
17*700637cbSDimitry Andric 
18*700637cbSDimitry Andric using namespace clang;
19*700637cbSDimitry Andric 
classofKind(Kind K)20*700637cbSDimitry Andric bool OpenACCConstructDecl::classofKind(Kind K) {
21*700637cbSDimitry Andric   return OpenACCDeclareDecl::classofKind(K) ||
22*700637cbSDimitry Andric          OpenACCRoutineDecl::classofKind(K);
23*700637cbSDimitry Andric }
24*700637cbSDimitry Andric 
25*700637cbSDimitry Andric OpenACCDeclareDecl *
Create(ASTContext & Ctx,DeclContext * DC,SourceLocation StartLoc,SourceLocation DirLoc,SourceLocation EndLoc,ArrayRef<const OpenACCClause * > Clauses)26*700637cbSDimitry Andric OpenACCDeclareDecl::Create(ASTContext &Ctx, DeclContext *DC,
27*700637cbSDimitry Andric                            SourceLocation StartLoc, SourceLocation DirLoc,
28*700637cbSDimitry Andric                            SourceLocation EndLoc,
29*700637cbSDimitry Andric                            ArrayRef<const OpenACCClause *> Clauses) {
30*700637cbSDimitry Andric   return new (Ctx, DC,
31*700637cbSDimitry Andric               additionalSizeToAlloc<const OpenACCClause *>(Clauses.size()))
32*700637cbSDimitry Andric       OpenACCDeclareDecl(DC, StartLoc, DirLoc, EndLoc, Clauses);
33*700637cbSDimitry Andric }
34*700637cbSDimitry Andric 
35*700637cbSDimitry Andric OpenACCDeclareDecl *
CreateDeserialized(ASTContext & Ctx,GlobalDeclID ID,unsigned NumClauses)36*700637cbSDimitry Andric OpenACCDeclareDecl::CreateDeserialized(ASTContext &Ctx, GlobalDeclID ID,
37*700637cbSDimitry Andric                                        unsigned NumClauses) {
38*700637cbSDimitry Andric   return new (Ctx, ID, additionalSizeToAlloc<const OpenACCClause *>(NumClauses))
39*700637cbSDimitry Andric       OpenACCDeclareDecl(NumClauses);
40*700637cbSDimitry Andric }
41*700637cbSDimitry Andric 
42*700637cbSDimitry Andric OpenACCRoutineDecl *
Create(ASTContext & Ctx,DeclContext * DC,SourceLocation StartLoc,SourceLocation DirLoc,SourceLocation LParenLoc,Expr * FuncRef,SourceLocation RParenLoc,SourceLocation EndLoc,ArrayRef<const OpenACCClause * > Clauses)43*700637cbSDimitry Andric OpenACCRoutineDecl::Create(ASTContext &Ctx, DeclContext *DC,
44*700637cbSDimitry Andric                            SourceLocation StartLoc, SourceLocation DirLoc,
45*700637cbSDimitry Andric                            SourceLocation LParenLoc, Expr *FuncRef,
46*700637cbSDimitry Andric                            SourceLocation RParenLoc, SourceLocation EndLoc,
47*700637cbSDimitry Andric                            ArrayRef<const OpenACCClause *> Clauses) {
48*700637cbSDimitry Andric   return new (Ctx, DC,
49*700637cbSDimitry Andric               additionalSizeToAlloc<const OpenACCClause *>(Clauses.size()))
50*700637cbSDimitry Andric       OpenACCRoutineDecl(DC, StartLoc, DirLoc, LParenLoc, FuncRef, RParenLoc,
51*700637cbSDimitry Andric                          EndLoc, Clauses);
52*700637cbSDimitry Andric }
53*700637cbSDimitry Andric 
54*700637cbSDimitry Andric OpenACCRoutineDecl *
CreateDeserialized(ASTContext & Ctx,GlobalDeclID ID,unsigned NumClauses)55*700637cbSDimitry Andric OpenACCRoutineDecl::CreateDeserialized(ASTContext &Ctx, GlobalDeclID ID,
56*700637cbSDimitry Andric                                        unsigned NumClauses) {
57*700637cbSDimitry Andric   return new (Ctx, ID, additionalSizeToAlloc<const OpenACCClause *>(NumClauses))
58*700637cbSDimitry Andric       OpenACCRoutineDecl(NumClauses);
59*700637cbSDimitry Andric }
60*700637cbSDimitry Andric 
printPrettyPragma(llvm::raw_ostream & OS,const clang::PrintingPolicy & P) const61*700637cbSDimitry Andric void OpenACCRoutineDeclAttr::printPrettyPragma(
62*700637cbSDimitry Andric     llvm::raw_ostream &OS, const clang::PrintingPolicy &P) const {
63*700637cbSDimitry Andric   if (Clauses.size() > 0) {
64*700637cbSDimitry Andric     OS << ' ';
65*700637cbSDimitry Andric     OpenACCClausePrinter Printer{OS, P};
66*700637cbSDimitry Andric     Printer.VisitClauseList(Clauses);
67*700637cbSDimitry Andric   }
68*700637cbSDimitry Andric }
69