[Support] Remove unused includes (NFC) (#116752)
[llvm-project.git] / flang / runtime / support.cpp
bloba607120256d9d93a0f68045bbde35fc69d5bc6e3
1 //===-- runtime/support.cpp -----------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "flang/Runtime/support.h"
10 #include "ISO_Fortran_util.h"
11 #include "type-info.h"
12 #include "flang/Runtime/descriptor.h"
14 namespace Fortran::runtime {
15 extern "C" {
16 RT_EXT_API_GROUP_BEGIN
18 bool RTDEF(IsContiguous)(const Descriptor &descriptor) {
19 return descriptor.IsContiguous();
22 bool RTDEF(IsAssumedSize)(const Descriptor &descriptor) {
23 return ISO::IsAssumedSize(&descriptor.raw());
26 void RTDEF(CopyAndUpdateDescriptor)(Descriptor &to, const Descriptor &from,
27 const typeInfo::DerivedType *newDynamicType,
28 ISO::CFI_attribute_t newAttribute, enum LowerBoundModifier newLowerBounds) {
29 to = from;
30 if (newDynamicType) {
31 DescriptorAddendum *toAddendum{to.Addendum()};
32 INTERNAL_CHECK(toAddendum);
33 toAddendum->set_derivedType(newDynamicType);
34 to.raw().elem_len = newDynamicType->sizeInBytes();
36 to.raw().attribute = newAttribute;
37 if (newLowerBounds != LowerBoundModifier::Preserve) {
38 const ISO::CFI_index_t newLowerBound{
39 newLowerBounds == LowerBoundModifier::SetToOnes ? 1 : 0};
40 const int rank{to.rank()};
41 for (int i = 0; i < rank; ++i) {
42 to.GetDimension(i).SetLowerBound(newLowerBound);
47 RT_EXT_API_GROUP_END
48 } // extern "C"
49 } // namespace Fortran::runtime