diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-10 19:27:02 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-10 19:27:02 +0900 |
commit | c4a2ca9b936391fb930ecbb3d5c5d34e371e45fb (patch) | |
tree | f7bbf2b44d3dc178bcbaefdc56254e2220237737 /clang/lib/AST/OpenACCClause.cpp | |
parent | 5633a2072696b20c554ff5568c5a1d25aa7e8db3 (diff) | |
parent | 0350c1eba1c1a6b73a8d9c271a7f3c8b33202579 (diff) | |
download | llvm-users/chapuni/cov/merge/forfile-base.zip llvm-users/chapuni/cov/merge/forfile-base.tar.gz llvm-users/chapuni/cov/merge/forfile-base.tar.bz2 |
Merge branch 'users/chapuni/cov/merge/region_segment' into users/chapuni/cov/merge/forfile-baseusers/chapuni/cov/merge/forfile-base
Diffstat (limited to 'clang/lib/AST/OpenACCClause.cpp')
-rw-r--r-- | clang/lib/AST/OpenACCClause.cpp | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/clang/lib/AST/OpenACCClause.cpp b/clang/lib/AST/OpenACCClause.cpp index 76fea1f..da63b47 100644 --- a/clang/lib/AST/OpenACCClause.cpp +++ b/clang/lib/AST/OpenACCClause.cpp @@ -20,7 +20,7 @@ using namespace clang; bool OpenACCClauseWithParams::classof(const OpenACCClause *C) { return OpenACCDeviceTypeClause::classof(C) || OpenACCClauseWithCondition::classof(C) || - OpenACCClauseWithExprs::classof(C); + OpenACCClauseWithExprs::classof(C) || OpenACCSelfClause::classof(C); } bool OpenACCClauseWithExprs::classof(const OpenACCClause *C) { return OpenACCWaitClause::classof(C) || OpenACCNumGangsClause::classof(C) || @@ -41,7 +41,7 @@ bool OpenACCClauseWithVarList::classof(const OpenACCClause *C) { OpenACCReductionClause::classof(C) || OpenACCCreateClause::classof(C); } bool OpenACCClauseWithCondition::classof(const OpenACCClause *C) { - return OpenACCIfClause::classof(C) || OpenACCSelfClause::classof(C); + return OpenACCIfClause::classof(C); } bool OpenACCClauseWithSingleIntExpr::classof(const OpenACCClause *C) { return OpenACCNumWorkersClause::classof(C) || @@ -87,19 +87,43 @@ OpenACCSelfClause *OpenACCSelfClause::Create(const ASTContext &C, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc) { - void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause)); + void *Mem = C.Allocate(OpenACCSelfClause::totalSizeToAlloc<Expr *>(1)); return new (Mem) OpenACCSelfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc); } +OpenACCSelfClause *OpenACCSelfClause::Create(const ASTContext &C, + SourceLocation BeginLoc, + SourceLocation LParenLoc, + ArrayRef<Expr *> VarList, + SourceLocation EndLoc) { + void *Mem = + C.Allocate(OpenACCSelfClause::totalSizeToAlloc<Expr *>(VarList.size())); + return new (Mem) OpenACCSelfClause(BeginLoc, LParenLoc, VarList, EndLoc); +} + +OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc, + SourceLocation LParenLoc, + llvm::ArrayRef<Expr *> VarList, + SourceLocation EndLoc) + : OpenACCClauseWithParams(OpenACCClauseKind::Self, BeginLoc, LParenLoc, + EndLoc), + HasConditionExpr(std::nullopt), NumExprs(VarList.size()) { + std::uninitialized_copy(VarList.begin(), VarList.end(), + getTrailingObjects<Expr *>()); +} + OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc) - : OpenACCClauseWithCondition(OpenACCClauseKind::Self, BeginLoc, LParenLoc, - ConditionExpr, EndLoc) { + : OpenACCClauseWithParams(OpenACCClauseKind::Self, BeginLoc, LParenLoc, + EndLoc), + HasConditionExpr(ConditionExpr != nullptr), NumExprs(1) { assert((!ConditionExpr || ConditionExpr->isInstantiationDependent() || ConditionExpr->getType()->isScalarType()) && "Condition expression type not scalar/dependent"); + std::uninitialized_copy(&ConditionExpr, &ConditionExpr + 1, + getTrailingObjects<Expr *>()); } OpenACCClause::child_range OpenACCClause::children() { @@ -555,9 +579,17 @@ void OpenACCClausePrinter::VisitIfClause(const OpenACCIfClause &C) { void OpenACCClausePrinter::VisitSelfClause(const OpenACCSelfClause &C) { OS << "self"; - if (const Expr *CondExpr = C.getConditionExpr()) { + + if (C.isConditionExprClause()) { + if (const Expr *CondExpr = C.getConditionExpr()) { + OS << "("; + printExpr(CondExpr); + OS << ")"; + } + } else { OS << "("; - printExpr(CondExpr); + llvm::interleaveComma(C.getVarList(), OS, + [&](const Expr *E) { printExpr(E); }); OS << ")"; } } |