diff options
Diffstat (limited to 'lib/AST/StmtOpenMP.cpp')
-rw-r--r-- | lib/AST/StmtOpenMP.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/AST/StmtOpenMP.cpp b/lib/AST/StmtOpenMP.cpp index 85a2daa080..4e829897ce 100644 --- a/lib/AST/StmtOpenMP.cpp +++ b/lib/AST/StmtOpenMP.cpp @@ -1,9 +1,8 @@ //===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -23,6 +22,25 @@ void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) { std::copy(Clauses.begin(), Clauses.end(), getClauses().begin()); } +bool OMPExecutableDirective::isStandaloneDirective() const { + // Special case: 'omp target enter data', 'omp target exit data', + // 'omp target update' are stand-alone directives, but for implementation + // reasons they have empty synthetic structured block, to simplify codegen. + if (isa<OMPTargetEnterDataDirective>(this) || + isa<OMPTargetExitDataDirective>(this) || + isa<OMPTargetUpdateDirective>(this)) + return true; + return !hasAssociatedStmt() || !getAssociatedStmt(); +} + +const Stmt *OMPExecutableDirective::getStructuredBlock() const { + assert(!isStandaloneDirective() && + "Standalone Executable Directives don't have Structured Blocks."); + if (auto *LD = dyn_cast<OMPLoopDirective>(this)) + return LD->getBody(); + return getInnermostCapturedStmt()->getCapturedStmt(); +} + void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) { assert(A.size() == getCollapsedNumber() && "Number of loop counters is not the same as the collapsed number"); |