aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/openmp-dsa.cpp
blob: 48aa36febe5c5b338f99b739174e13a39807e0b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//===-- flang/lib/Semantics/openmp-dsa.cpp ----------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "flang/Semantics/openmp-dsa.h"

namespace Fortran::semantics {

Symbol::Flags GetSymbolDSA(const Symbol &symbol) {
  Symbol::Flags dsaFlags{Symbol::Flag::OmpPrivate,
      Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate,
      Symbol::Flag::OmpShared, Symbol::Flag::OmpLinear,
      Symbol::Flag::OmpReduction};
  Symbol::Flags dsa{symbol.flags() & dsaFlags};
  if (dsa.any()) {
    return dsa;
  }
  // If no DSA are set use those from the host associated symbol, if any.
  if (const auto *details{symbol.detailsIf<HostAssocDetails>()}) {
    return GetSymbolDSA(details->symbol());
  }
  return {};
}

} // namespace Fortran::semantics