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

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of clang/lib/AST/DeclOpenACC.cpp