diff options
author | CarolineConcatto <51754594+CarolineConcatto@users.noreply.github.com> | 2020-02-25 15:11:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-25 07:11:52 -0800 |
commit | 64ab3302d5a130c00b66a6957b2e7f0c9b9c537d (patch) | |
tree | 7658afe96fac3d6dabd9c6aa2b471294c3ddfa7c /flang/lib/Parser/tools.cpp | |
parent | 456a61d188e9cdf43bd44e28e11708773d838798 (diff) | |
download | llvm-64ab3302d5a130c00b66a6957b2e7f0c9b9c537d.zip llvm-64ab3302d5a130c00b66a6957b2e7f0c9b9c537d.tar.gz llvm-64ab3302d5a130c00b66a6957b2e7f0c9b9c537d.tar.bz2 |
[flang] [LLVMify F18] Compiler module folders should have capitalised names (flang-compiler/f18#980)
This patch renames the modules in f18 to use a capital letter in the
module name
Signed-off-by: Caroline Concatto <caroline.concatto@arm.com>
Original-commit: flang-compiler/f18@d2eb7a1c443d1539ef12b6f027074a0eb15b1ea0
Reviewed-on: https://github.com/flang-compiler/f18/pull/980
Diffstat (limited to 'flang/lib/Parser/tools.cpp')
-rw-r--r-- | flang/lib/Parser/tools.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/flang/lib/Parser/tools.cpp b/flang/lib/Parser/tools.cpp new file mode 100644 index 0000000..7fb7379 --- /dev/null +++ b/flang/lib/Parser/tools.cpp @@ -0,0 +1,94 @@ +//===-- lib/Parser/tools.cpp ----------------------------------------------===// +// +// 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/Parser/tools.h" + +namespace Fortran::parser { + +const Name &GetLastName(const Name &x) { return x; } + +const Name &GetLastName(const StructureComponent &x) { + return GetLastName(x.component); +} + +const Name &GetLastName(const DataRef &x) { + return std::visit( + common::visitors{ + [](const Name &name) -> const Name & { return name; }, + [](const common::Indirection<StructureComponent> &sc) + -> const Name & { return GetLastName(sc.value()); }, + [](const common::Indirection<ArrayElement> &sc) -> const Name & { + return GetLastName(sc.value().base); + }, + [](const common::Indirection<CoindexedNamedObject> &ci) + -> const Name & { return GetLastName(ci.value().base); }, + }, + x.u); +} + +const Name &GetLastName(const Substring &x) { + return GetLastName(std::get<DataRef>(x.t)); +} + +const Name &GetLastName(const Designator &x) { + return std::visit( + [](const auto &y) -> const Name & { return GetLastName(y); }, x.u); +} + +const Name &GetLastName(const ProcComponentRef &x) { + return GetLastName(x.v.thing); +} + +const Name &GetLastName(const ProcedureDesignator &x) { + return std::visit( + [](const auto &y) -> const Name & { return GetLastName(y); }, x.u); +} + +const Name &GetLastName(const Call &x) { + return GetLastName(std::get<ProcedureDesignator>(x.t)); +} + +const Name &GetLastName(const FunctionReference &x) { return GetLastName(x.v); } + +const Name &GetLastName(const Variable &x) { + return std::visit( + [](const auto &indirection) -> const Name & { + return GetLastName(indirection.value()); + }, + x.u); +} + +const Name &GetLastName(const AllocateObject &x) { + return std::visit( + [](const auto &y) -> const Name & { return GetLastName(y); }, x.u); +} + +const CoindexedNamedObject *GetCoindexedNamedObject(const DataRef &base) { + return std::visit( + common::visitors{ + [](const Name &) -> const CoindexedNamedObject * { return nullptr; }, + [](const common::Indirection<CoindexedNamedObject> &x) + -> const CoindexedNamedObject * { return &x.value(); }, + [](const auto &x) -> const CoindexedNamedObject * { + return GetCoindexedNamedObject(x.value().base); + }, + }, + base.u); +} +const CoindexedNamedObject *GetCoindexedNamedObject( + const AllocateObject &allocateObject) { + return std::visit( + common::visitors{ + [](const StructureComponent &x) -> const CoindexedNamedObject * { + return GetCoindexedNamedObject(x.base); + }, + [](const auto &) -> const CoindexedNamedObject * { return nullptr; }, + }, + allocateObject.u); +} +} |