FLANG
derived-api.h
1//===-- include/flang/Runtime/derived-api.h ---------------------*- C++ -*-===//
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// API for lowering to use for operations on derived type objects.
10// Initialiaztion and finalization are implied for pointer and allocatable
11// ALLOCATE()/DEALLOCATE() respectively, so these APIs should be used only for
12// local variables. Whole allocatable assignment should use AllocatableAssign()
13// instead of this Assign().
14
15#ifndef FORTRAN_RUNTIME_DERIVED_API_H_
16#define FORTRAN_RUNTIME_DERIVED_API_H_
17
18#include "flang/Runtime/entry-names.h"
19
20namespace Fortran::runtime {
21class Descriptor;
22
23namespace typeInfo {
24class DerivedType;
25}
26
27extern "C" {
28
29// Initializes and allocates an object's components, if it has a derived type
30// with any default component initialization or automatic components.
31// The descriptor must be initialized and non-null.
32void RTDECL(Initialize)(
33 const Descriptor &, const char *sourceFile = nullptr, int sourceLine = 0);
34
35// Initializes an object clone from the original object.
36// Each allocatable member of the clone is allocated with the same bounds as
37// in the original object, if it is also allocated in it.
38// The descriptor must be initialized and non-null.
39void RTDECL(InitializeClone)(const Descriptor &, const Descriptor &,
40 const char *sourceFile = nullptr, int sourceLine = 0);
41
42// Finalizes an object and its components. Deallocates any
43// allocatable/automatic components. Does not deallocate the descriptor's
44// storage.
45void RTDECL(Destroy)(const Descriptor &);
46
47// Finalizes the object and its components.
48void RTDECL(Finalize)(
49 const Descriptor &, const char *sourceFile = nullptr, int sourceLine = 0);
50
54void RTDECL(DestroyWithoutFinalization)(const Descriptor &);
55
56// Intrinsic or defined assignment, with scalar expansion but not type
57// conversion.
58void RTDECL(Assign)(const Descriptor &, const Descriptor &,
59 const char *sourceFile = nullptr, int sourceLine = 0);
60
61// Perform the test of the CLASS IS type guard statement of the SELECT TYPE
62// construct.
63bool RTDECL(ClassIs)(const Descriptor &, const typeInfo::DerivedType &);
64
65// Perform the test of the SAME_TYPE_AS intrinsic.
66bool RTDECL(SameTypeAs)(const Descriptor &, const Descriptor &);
67
68// Perform the test of the EXTENDS_TYPE_OF intrinsic.
69bool RTDECL(ExtendsTypeOf)(const Descriptor &, const Descriptor &);
70
71} // extern "C"
72} // namespace Fortran::runtime
73#endif // FORTRAN_RUNTIME_DERIVED_API_H_