15339029fSEric Schweitz //===-- InternalNames.cpp -------------------------------------------------===//
25339029fSEric Schweitz //
35339029fSEric Schweitz // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45339029fSEric Schweitz // See https://llvm.org/LICENSE.txt for license information.
55339029fSEric Schweitz // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65339029fSEric Schweitz //
75339029fSEric Schweitz //===----------------------------------------------------------------------===//
8c68d2895SEric Schweitz //
9c68d2895SEric Schweitz // Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10c68d2895SEric Schweitz //
11c68d2895SEric Schweitz //===----------------------------------------------------------------------===//
125339029fSEric Schweitz
135339029fSEric Schweitz #include "flang/Optimizer/Support/InternalNames.h"
14e090182fSEric Schweitz #include "flang/Optimizer/Dialect/FIRType.h"
15e090182fSEric Schweitz #include "mlir/IR/BuiltinTypes.h"
165339029fSEric Schweitz #include "mlir/IR/Diagnostics.h"
175339029fSEric Schweitz #include "llvm/Support/CommandLine.h"
185339029fSEric Schweitz
195339029fSEric Schweitz static llvm::cl::opt<std::string> mainEntryName(
205339029fSEric Schweitz "main-entry-name",
215339029fSEric Schweitz llvm::cl::desc("override the name of the default PROGRAM entry (may be "
225339029fSEric Schweitz "helpful for using other runtimes)"));
235339029fSEric Schweitz
241e96c4b5SValentin Clement constexpr std::int64_t badValue = -1;
255339029fSEric Schweitz
prefix()265339029fSEric Schweitz inline std::string prefix() { return "_Q"; }
275339029fSEric Schweitz
doModules(llvm::ArrayRef<llvm::StringRef> mods)285339029fSEric Schweitz static std::string doModules(llvm::ArrayRef<llvm::StringRef> mods) {
295339029fSEric Schweitz std::string result;
305339029fSEric Schweitz auto *token = "M";
315339029fSEric Schweitz for (auto mod : mods) {
3230db1776SEric Schweitz result.append(token).append(mod.lower());
335339029fSEric Schweitz token = "S";
345339029fSEric Schweitz }
355339029fSEric Schweitz return result;
365339029fSEric Schweitz }
375339029fSEric Schweitz
doModulesHost(llvm::ArrayRef<llvm::StringRef> mods,llvm::Optional<llvm::StringRef> host)385339029fSEric Schweitz static std::string doModulesHost(llvm::ArrayRef<llvm::StringRef> mods,
395339029fSEric Schweitz llvm::Optional<llvm::StringRef> host) {
405339029fSEric Schweitz std::string result = doModules(mods);
415413bf1bSKazu Hirata if (host)
4230db1776SEric Schweitz result.append("F").append(host->lower());
435339029fSEric Schweitz return result;
445339029fSEric Schweitz }
455339029fSEric Schweitz
4664d7d5a5SValentin Clement inline llvm::SmallVector<llvm::StringRef>
convertToStringRef(llvm::ArrayRef<std::string> from)475339029fSEric Schweitz convertToStringRef(llvm::ArrayRef<std::string> from) {
485339029fSEric Schweitz return {from.begin(), from.end()};
495339029fSEric Schweitz }
505339029fSEric Schweitz
515339029fSEric Schweitz inline llvm::Optional<llvm::StringRef>
convertToStringRef(const llvm::Optional<std::string> & from)525339029fSEric Schweitz convertToStringRef(const llvm::Optional<std::string> &from) {
535339029fSEric Schweitz llvm::Optional<llvm::StringRef> to;
5486b8c1d9SKazu Hirata if (from)
55*009ab172SKazu Hirata to = *from;
565339029fSEric Schweitz return to;
575339029fSEric Schweitz }
585339029fSEric Schweitz
readName(llvm::StringRef uniq,std::size_t & i,std::size_t init,std::size_t end)595339029fSEric Schweitz static std::string readName(llvm::StringRef uniq, std::size_t &i,
605339029fSEric Schweitz std::size_t init, std::size_t end) {
6130db1776SEric Schweitz for (i = init; i < end && (uniq[i] < 'A' || uniq[i] > 'Z'); ++i) {
625339029fSEric Schweitz // do nothing
635339029fSEric Schweitz }
6430db1776SEric Schweitz return uniq.substr(init, i - init).str();
655339029fSEric Schweitz }
665339029fSEric Schweitz
readInt(llvm::StringRef uniq,std::size_t & i,std::size_t init,std::size_t end)675339029fSEric Schweitz static std::int64_t readInt(llvm::StringRef uniq, std::size_t &i,
685339029fSEric Schweitz std::size_t init, std::size_t end) {
695339029fSEric Schweitz for (i = init; i < end && uniq[i] >= '0' && uniq[i] <= '9'; ++i) {
705339029fSEric Schweitz // do nothing
715339029fSEric Schweitz }
721e96c4b5SValentin Clement std::int64_t result = badValue;
7330db1776SEric Schweitz if (uniq.substr(init, i - init).getAsInteger(10, result))
741e96c4b5SValentin Clement return badValue;
755339029fSEric Schweitz return result;
765339029fSEric Schweitz }
775339029fSEric Schweitz
toLower(llvm::StringRef name)785339029fSEric Schweitz std::string fir::NameUniquer::toLower(llvm::StringRef name) {
795339029fSEric Schweitz return name.lower();
805339029fSEric Schweitz }
815339029fSEric Schweitz
intAsString(std::int64_t i)825339029fSEric Schweitz std::string fir::NameUniquer::intAsString(std::int64_t i) {
835339029fSEric Schweitz assert(i >= 0);
845339029fSEric Schweitz return std::to_string(i);
855339029fSEric Schweitz }
865339029fSEric Schweitz
doKind(std::int64_t kind)875339029fSEric Schweitz std::string fir::NameUniquer::doKind(std::int64_t kind) {
885339029fSEric Schweitz std::string result = "K";
895339029fSEric Schweitz if (kind < 0)
905339029fSEric Schweitz return result.append("N").append(intAsString(-kind));
915339029fSEric Schweitz return result.append(intAsString(kind));
925339029fSEric Schweitz }
935339029fSEric Schweitz
doKinds(llvm::ArrayRef<std::int64_t> kinds)945339029fSEric Schweitz std::string fir::NameUniquer::doKinds(llvm::ArrayRef<std::int64_t> kinds) {
955339029fSEric Schweitz std::string result;
965339029fSEric Schweitz for (auto i : kinds)
975339029fSEric Schweitz result.append(doKind(i));
985339029fSEric Schweitz return result;
995339029fSEric Schweitz }
1005339029fSEric Schweitz
doCommonBlock(llvm::StringRef name)1015339029fSEric Schweitz std::string fir::NameUniquer::doCommonBlock(llvm::StringRef name) {
1025339029fSEric Schweitz std::string result = prefix();
1035339029fSEric Schweitz return result.append("B").append(toLower(name));
1045339029fSEric Schweitz }
1055339029fSEric Schweitz
doBlockData(llvm::StringRef name)106e090182fSEric Schweitz std::string fir::NameUniquer::doBlockData(llvm::StringRef name) {
107e090182fSEric Schweitz std::string result = prefix();
108e090182fSEric Schweitz return result.append("L").append(toLower(name));
109e090182fSEric Schweitz }
110e090182fSEric Schweitz
1115339029fSEric Schweitz std::string
doConstant(llvm::ArrayRef<llvm::StringRef> modules,llvm::Optional<llvm::StringRef> host,llvm::StringRef name)1125339029fSEric Schweitz fir::NameUniquer::doConstant(llvm::ArrayRef<llvm::StringRef> modules,
11330db1776SEric Schweitz llvm::Optional<llvm::StringRef> host,
1145339029fSEric Schweitz llvm::StringRef name) {
1155339029fSEric Schweitz std::string result = prefix();
11630db1776SEric Schweitz result.append(doModulesHost(modules, host)).append("EC");
11730db1776SEric Schweitz return result.append(toLower(name));
1185339029fSEric Schweitz }
1195339029fSEric Schweitz
1205339029fSEric Schweitz std::string
doDispatchTable(llvm::ArrayRef<llvm::StringRef> modules,llvm::Optional<llvm::StringRef> host,llvm::StringRef name,llvm::ArrayRef<std::int64_t> kinds)1215339029fSEric Schweitz fir::NameUniquer::doDispatchTable(llvm::ArrayRef<llvm::StringRef> modules,
1225339029fSEric Schweitz llvm::Optional<llvm::StringRef> host,
1235339029fSEric Schweitz llvm::StringRef name,
1245339029fSEric Schweitz llvm::ArrayRef<std::int64_t> kinds) {
1255339029fSEric Schweitz std::string result = prefix();
1265339029fSEric Schweitz result.append(doModulesHost(modules, host)).append("DT");
1275339029fSEric Schweitz return result.append(toLower(name)).append(doKinds(kinds));
1285339029fSEric Schweitz }
1295339029fSEric Schweitz
doGenerated(llvm::StringRef name)1305339029fSEric Schweitz std::string fir::NameUniquer::doGenerated(llvm::StringRef name) {
1315339029fSEric Schweitz std::string result = prefix();
1325339029fSEric Schweitz return result.append("Q").append(name);
1335339029fSEric Schweitz }
1345339029fSEric Schweitz
doIntrinsicTypeDescriptor(llvm::ArrayRef<llvm::StringRef> modules,llvm::Optional<llvm::StringRef> host,IntrinsicType type,std::int64_t kind)1355339029fSEric Schweitz std::string fir::NameUniquer::doIntrinsicTypeDescriptor(
1365339029fSEric Schweitz llvm::ArrayRef<llvm::StringRef> modules,
1375339029fSEric Schweitz llvm::Optional<llvm::StringRef> host, IntrinsicType type,
1385339029fSEric Schweitz std::int64_t kind) {
1395339029fSEric Schweitz const char *name = nullptr;
1405339029fSEric Schweitz switch (type) {
1415339029fSEric Schweitz case IntrinsicType::CHARACTER:
1425339029fSEric Schweitz name = "character";
1435339029fSEric Schweitz break;
1445339029fSEric Schweitz case IntrinsicType::COMPLEX:
1455339029fSEric Schweitz name = "complex";
1465339029fSEric Schweitz break;
1475339029fSEric Schweitz case IntrinsicType::INTEGER:
1485339029fSEric Schweitz name = "integer";
1495339029fSEric Schweitz break;
1505339029fSEric Schweitz case IntrinsicType::LOGICAL:
1515339029fSEric Schweitz name = "logical";
1525339029fSEric Schweitz break;
1535339029fSEric Schweitz case IntrinsicType::REAL:
1545339029fSEric Schweitz name = "real";
1555339029fSEric Schweitz break;
1565339029fSEric Schweitz }
1575339029fSEric Schweitz assert(name && "unknown intrinsic type");
1585339029fSEric Schweitz std::string result = prefix();
1595339029fSEric Schweitz result.append(doModulesHost(modules, host)).append("C");
1605339029fSEric Schweitz return result.append(name).append(doKind(kind));
1615339029fSEric Schweitz }
1625339029fSEric Schweitz
1635339029fSEric Schweitz std::string
doProcedure(llvm::ArrayRef<llvm::StringRef> modules,llvm::Optional<llvm::StringRef> host,llvm::StringRef name)1645339029fSEric Schweitz fir::NameUniquer::doProcedure(llvm::ArrayRef<llvm::StringRef> modules,
1655339029fSEric Schweitz llvm::Optional<llvm::StringRef> host,
1665339029fSEric Schweitz llvm::StringRef name) {
1675339029fSEric Schweitz std::string result = prefix();
1685339029fSEric Schweitz result.append(doModulesHost(modules, host)).append("P");
1695339029fSEric Schweitz return result.append(toLower(name));
1705339029fSEric Schweitz }
1715339029fSEric Schweitz
doType(llvm::ArrayRef<llvm::StringRef> modules,llvm::Optional<llvm::StringRef> host,llvm::StringRef name,llvm::ArrayRef<std::int64_t> kinds)1725339029fSEric Schweitz std::string fir::NameUniquer::doType(llvm::ArrayRef<llvm::StringRef> modules,
1735339029fSEric Schweitz llvm::Optional<llvm::StringRef> host,
1745339029fSEric Schweitz llvm::StringRef name,
1755339029fSEric Schweitz llvm::ArrayRef<std::int64_t> kinds) {
1765339029fSEric Schweitz std::string result = prefix();
1775339029fSEric Schweitz result.append(doModulesHost(modules, host)).append("T");
1785339029fSEric Schweitz return result.append(toLower(name)).append(doKinds(kinds));
1795339029fSEric Schweitz }
1805339029fSEric Schweitz
1815339029fSEric Schweitz std::string
doTypeDescriptor(llvm::ArrayRef<llvm::StringRef> modules,llvm::Optional<llvm::StringRef> host,llvm::StringRef name,llvm::ArrayRef<std::int64_t> kinds)1825339029fSEric Schweitz fir::NameUniquer::doTypeDescriptor(llvm::ArrayRef<llvm::StringRef> modules,
1835339029fSEric Schweitz llvm::Optional<llvm::StringRef> host,
1845339029fSEric Schweitz llvm::StringRef name,
1855339029fSEric Schweitz llvm::ArrayRef<std::int64_t> kinds) {
1865339029fSEric Schweitz std::string result = prefix();
1875339029fSEric Schweitz result.append(doModulesHost(modules, host)).append("CT");
1885339029fSEric Schweitz return result.append(toLower(name)).append(doKinds(kinds));
1895339029fSEric Schweitz }
1905339029fSEric Schweitz
doTypeDescriptor(llvm::ArrayRef<std::string> modules,llvm::Optional<std::string> host,llvm::StringRef name,llvm::ArrayRef<std::int64_t> kinds)1915339029fSEric Schweitz std::string fir::NameUniquer::doTypeDescriptor(
1925339029fSEric Schweitz llvm::ArrayRef<std::string> modules, llvm::Optional<std::string> host,
1935339029fSEric Schweitz llvm::StringRef name, llvm::ArrayRef<std::int64_t> kinds) {
1945339029fSEric Schweitz auto rmodules = convertToStringRef(modules);
1955339029fSEric Schweitz auto rhost = convertToStringRef(host);
1965339029fSEric Schweitz return doTypeDescriptor(rmodules, rhost, name, kinds);
1975339029fSEric Schweitz }
1985339029fSEric Schweitz
1995339029fSEric Schweitz std::string
doVariable(llvm::ArrayRef<llvm::StringRef> modules,llvm::Optional<llvm::StringRef> host,llvm::StringRef name)2005339029fSEric Schweitz fir::NameUniquer::doVariable(llvm::ArrayRef<llvm::StringRef> modules,
2015339029fSEric Schweitz llvm::Optional<llvm::StringRef> host,
2025339029fSEric Schweitz llvm::StringRef name) {
2035339029fSEric Schweitz std::string result = prefix();
2045339029fSEric Schweitz result.append(doModulesHost(modules, host)).append("E");
2055339029fSEric Schweitz return result.append(toLower(name));
2065339029fSEric Schweitz }
2075339029fSEric Schweitz
20862cc6b0dSValentin Clement std::string
doNamelistGroup(llvm::ArrayRef<llvm::StringRef> modules,llvm::Optional<llvm::StringRef> host,llvm::StringRef name)20962cc6b0dSValentin Clement fir::NameUniquer::doNamelistGroup(llvm::ArrayRef<llvm::StringRef> modules,
21062cc6b0dSValentin Clement llvm::Optional<llvm::StringRef> host,
21162cc6b0dSValentin Clement llvm::StringRef name) {
21262cc6b0dSValentin Clement std::string result = prefix();
21362cc6b0dSValentin Clement result.append(doModulesHost(modules, host)).append("G");
21462cc6b0dSValentin Clement return result.append(toLower(name));
21562cc6b0dSValentin Clement }
21662cc6b0dSValentin Clement
doProgramEntry()2175339029fSEric Schweitz llvm::StringRef fir::NameUniquer::doProgramEntry() {
2185339029fSEric Schweitz if (mainEntryName.size())
2195339029fSEric Schweitz return mainEntryName;
2205339029fSEric Schweitz return "_QQmain";
2215339029fSEric Schweitz }
2225339029fSEric Schweitz
2235339029fSEric Schweitz std::pair<fir::NameUniquer::NameKind, fir::NameUniquer::DeconstructedName>
deconstruct(llvm::StringRef uniq)2245339029fSEric Schweitz fir::NameUniquer::deconstruct(llvm::StringRef uniq) {
2255339029fSEric Schweitz if (uniq.startswith("_Q")) {
2261e96c4b5SValentin Clement llvm::SmallVector<std::string> modules;
2275339029fSEric Schweitz llvm::Optional<std::string> host;
2285339029fSEric Schweitz std::string name;
2291e96c4b5SValentin Clement llvm::SmallVector<std::int64_t> kinds;
2305339029fSEric Schweitz NameKind nk = NameKind::NOT_UNIQUED;
2315339029fSEric Schweitz for (std::size_t i = 2, end{uniq.size()}; i != end;) {
2325339029fSEric Schweitz switch (uniq[i]) {
2335339029fSEric Schweitz case 'B':
2345339029fSEric Schweitz nk = NameKind::COMMON;
2355339029fSEric Schweitz name = readName(uniq, i, i + 1, end);
2365339029fSEric Schweitz break;
2375339029fSEric Schweitz case 'C':
2385339029fSEric Schweitz if (uniq[i + 1] == 'T') {
2395339029fSEric Schweitz nk = NameKind::TYPE_DESC;
2405339029fSEric Schweitz name = readName(uniq, i, i + 2, end);
2415339029fSEric Schweitz } else {
2425339029fSEric Schweitz nk = NameKind::INTRINSIC_TYPE_DESC;
2435339029fSEric Schweitz name = readName(uniq, i, i + 1, end);
2445339029fSEric Schweitz }
2455339029fSEric Schweitz break;
2465339029fSEric Schweitz case 'D':
2475339029fSEric Schweitz nk = NameKind::DISPATCH_TABLE;
2485339029fSEric Schweitz assert(uniq[i + 1] == 'T');
2495339029fSEric Schweitz name = readName(uniq, i, i + 2, end);
2505339029fSEric Schweitz break;
2515339029fSEric Schweitz case 'E':
2525339029fSEric Schweitz if (uniq[i + 1] == 'C') {
2535339029fSEric Schweitz nk = NameKind::CONSTANT;
2545339029fSEric Schweitz name = readName(uniq, i, i + 2, end);
2555339029fSEric Schweitz } else {
2565339029fSEric Schweitz nk = NameKind::VARIABLE;
2575339029fSEric Schweitz name = readName(uniq, i, i + 1, end);
2585339029fSEric Schweitz }
2595339029fSEric Schweitz break;
260e090182fSEric Schweitz case 'L':
261e090182fSEric Schweitz nk = NameKind::BLOCK_DATA_NAME;
262e090182fSEric Schweitz name = readName(uniq, i, i + 1, end);
263e090182fSEric Schweitz break;
2645339029fSEric Schweitz case 'P':
2655339029fSEric Schweitz nk = NameKind::PROCEDURE;
2665339029fSEric Schweitz name = readName(uniq, i, i + 1, end);
2675339029fSEric Schweitz break;
2685339029fSEric Schweitz case 'Q':
2695339029fSEric Schweitz nk = NameKind::GENERATED;
2705339029fSEric Schweitz name = uniq;
2715339029fSEric Schweitz i = end;
2725339029fSEric Schweitz break;
2735339029fSEric Schweitz case 'T':
2745339029fSEric Schweitz nk = NameKind::DERIVED_TYPE;
2755339029fSEric Schweitz name = readName(uniq, i, i + 1, end);
2765339029fSEric Schweitz break;
2775339029fSEric Schweitz
2785339029fSEric Schweitz case 'M':
2795339029fSEric Schweitz case 'S':
2805339029fSEric Schweitz modules.push_back(readName(uniq, i, i + 1, end));
2815339029fSEric Schweitz break;
2825339029fSEric Schweitz case 'F':
2835339029fSEric Schweitz host = readName(uniq, i, i + 1, end);
2845339029fSEric Schweitz break;
2855339029fSEric Schweitz case 'K':
2865339029fSEric Schweitz if (uniq[i + 1] == 'N')
2875339029fSEric Schweitz kinds.push_back(-readInt(uniq, i, i + 2, end));
2885339029fSEric Schweitz else
2895339029fSEric Schweitz kinds.push_back(readInt(uniq, i, i + 1, end));
2905339029fSEric Schweitz break;
29162cc6b0dSValentin Clement case 'G':
29262cc6b0dSValentin Clement nk = NameKind::NAMELIST_GROUP;
29362cc6b0dSValentin Clement name = readName(uniq, i, i + 1, end);
29462cc6b0dSValentin Clement break;
2955339029fSEric Schweitz
2965339029fSEric Schweitz default:
2975339029fSEric Schweitz assert(false && "unknown uniquing code");
2985339029fSEric Schweitz break;
2995339029fSEric Schweitz }
3005339029fSEric Schweitz }
3015339029fSEric Schweitz return {nk, DeconstructedName(modules, host, name, kinds)};
3025339029fSEric Schweitz }
3035339029fSEric Schweitz return {NameKind::NOT_UNIQUED, DeconstructedName(uniq)};
3045339029fSEric Schweitz }
305fc66dbbaSValentin Clement
isExternalFacingUniquedName(const std::pair<fir::NameUniquer::NameKind,fir::NameUniquer::DeconstructedName> & deconstructResult)306fc66dbbaSValentin Clement bool fir::NameUniquer::isExternalFacingUniquedName(
307fc66dbbaSValentin Clement const std::pair<fir::NameUniquer::NameKind,
308fc66dbbaSValentin Clement fir::NameUniquer::DeconstructedName> &deconstructResult) {
309fc66dbbaSValentin Clement return (deconstructResult.first == NameKind::PROCEDURE ||
310fc66dbbaSValentin Clement deconstructResult.first == NameKind::COMMON) &&
311fc66dbbaSValentin Clement deconstructResult.second.modules.empty() &&
312fc66dbbaSValentin Clement !deconstructResult.second.host;
313fc66dbbaSValentin Clement }
314fc66dbbaSValentin Clement
needExternalNameMangling(llvm::StringRef uniquedName)315fc66dbbaSValentin Clement bool fir::NameUniquer::needExternalNameMangling(llvm::StringRef uniquedName) {
316fc66dbbaSValentin Clement auto result = fir::NameUniquer::deconstruct(uniquedName);
317fc66dbbaSValentin Clement return result.first != fir::NameUniquer::NameKind::NOT_UNIQUED &&
318fc66dbbaSValentin Clement fir::NameUniquer::isExternalFacingUniquedName(result);
319fc66dbbaSValentin Clement }
3207dd7ccd2SJean Perier
belongsToModule(llvm::StringRef uniquedName,llvm::StringRef moduleName)3217dd7ccd2SJean Perier bool fir::NameUniquer::belongsToModule(llvm::StringRef uniquedName,
3227dd7ccd2SJean Perier llvm::StringRef moduleName) {
3237dd7ccd2SJean Perier auto result = fir::NameUniquer::deconstruct(uniquedName);
3247dd7ccd2SJean Perier return !result.second.modules.empty() &&
3257dd7ccd2SJean Perier result.second.modules[0] == moduleName;
3267dd7ccd2SJean Perier }
327013160f6SJean Perier
328013160f6SJean Perier static std::string
mangleTypeDescriptorKinds(llvm::ArrayRef<std::int64_t> kinds)329013160f6SJean Perier mangleTypeDescriptorKinds(llvm::ArrayRef<std::int64_t> kinds) {
330013160f6SJean Perier if (kinds.empty())
331013160f6SJean Perier return "";
332013160f6SJean Perier std::string result = "";
333013160f6SJean Perier for (std::int64_t kind : kinds)
334013160f6SJean Perier result += "." + std::to_string(kind);
335013160f6SJean Perier return result;
336013160f6SJean Perier }
337013160f6SJean Perier
338013160f6SJean Perier std::string
getTypeDescriptorName(llvm::StringRef mangledTypeName)339013160f6SJean Perier fir::NameUniquer::getTypeDescriptorName(llvm::StringRef mangledTypeName) {
340013160f6SJean Perier auto result = deconstruct(mangledTypeName);
341013160f6SJean Perier if (result.first != NameKind::DERIVED_TYPE)
342013160f6SJean Perier return "";
343013160f6SJean Perier std::string varName = ".dt." + result.second.name +
344013160f6SJean Perier mangleTypeDescriptorKinds(result.second.kinds);
345013160f6SJean Perier llvm::SmallVector<llvm::StringRef> modules;
346013160f6SJean Perier for (const std::string &mod : result.second.modules)
347013160f6SJean Perier modules.push_back(mod);
348013160f6SJean Perier llvm::Optional<llvm::StringRef> host;
349013160f6SJean Perier if (result.second.host)
350013160f6SJean Perier host = *result.second.host;
351013160f6SJean Perier return doVariable(modules, host, varName);
352013160f6SJean Perier }
353