1 //===-- Lower/Utils.h -- utilities ------------------------------*- 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 #ifndef FORTRAN_LOWER_UTILS_H 10 #define FORTRAN_LOWER_UTILS_H 11 12 #include "flang/Common/indirection.h" 13 #include "flang/Parser/char-block.h" 14 #include "llvm/ADT/StringRef.h" 15 16 /// Convert an F18 CharBlock to an LLVM StringRef toStringRef(const Fortran::parser::CharBlock & cb)17inline llvm::StringRef toStringRef(const Fortran::parser::CharBlock &cb) { 18 return {cb.begin(), cb.size()}; 19 } 20 21 /// Template helper to remove Fortran::common::Indirection wrappers. 22 template <typename A> removeIndirection(const A & a)23const A &removeIndirection(const A &a) { 24 return a; 25 } 26 template <typename A> removeIndirection(const Fortran::common::Indirection<A> & a)27const A &removeIndirection(const Fortran::common::Indirection<A> &a) { 28 return a.value(); 29 } 30 31 #endif // FORTRAN_LOWER_UTILS_H 32