xref: /llvm-project/flang/runtime/non-tbp-dio.cpp (revision 7cf1608b4d8f7f4d20c994dd13451efb7c9560b5)
1 //===-- flang/runtime/non-tbp-dio.cpp ---------------------------*- 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 #include "non-tbp-dio.h"
10 #include "type-info.h"
11 
12 namespace Fortran::runtime::io {
13 
Find(const typeInfo::DerivedType & type,common::DefinedIo definedIo) const14 const NonTbpDefinedIo *NonTbpDefinedIoTable::Find(
15     const typeInfo::DerivedType &type, common::DefinedIo definedIo) const {
16   std::size_t j{items};
17   for (const auto *p{item}; j-- > 0; ++p) {
18     if (&p->derivedType == &type && p->definedIo == definedIo) {
19       return p;
20     } else if (p->isDtvArgPolymorphic) {
21       for (const typeInfo::DerivedType *t{type.GetParentType()}; t;
22            t = t->GetParentType()) {
23         if (&p->derivedType == t && p->definedIo == definedIo) {
24           return p;
25         }
26       }
27     }
28   }
29   return nullptr;
30 }
31 
32 } // namespace Fortran::runtime::io
33