INTRINSIC_TYPE_DESC,
PROCEDURE,
TYPE_DESC,
- VARIABLE,
- NAMELIST_GROUP
+ VARIABLE
};
/// Components of an unparsed unique name
llvm::Optional<llvm::StringRef> host,
llvm::StringRef name);
- /// Unique a namelist group name
- static std::string doNamelistGroup(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
- llvm::StringRef name);
-
/// Entry point for the PROGRAM (called by the runtime)
/// Can be overridden with the `--main-entry-name=<name>` option.
static llvm::StringRef doProgramEntry();
symbolName);
return fir::NameUniquer::doVariable(modNames, optHost, symbolName);
},
- [&](const Fortran::semantics::NamelistDetails &) {
- auto modNames = moduleNames(ultimateSymbol);
- auto optHost = hostName(ultimateSymbol);
- return fir::NameUniquer::doNamelistGroup(modNames, optHost,
- symbolName);
- },
[&](const Fortran::semantics::CommonBlockDetails &) {
return fir::NameUniquer::doCommonBlock(symbolName);
},
return result.append(toLower(name));
}
-std::string
-fir::NameUniquer::doNamelistGroup(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
- llvm::StringRef name) {
- std::string result = prefix();
- result.append(doModulesHost(modules, host)).append("G");
- return result.append(toLower(name));
-}
-
llvm::StringRef fir::NameUniquer::doProgramEntry() {
if (mainEntryName.size())
return mainEntryName;
else
kinds.push_back(readInt(uniq, i, i + 1, end));
break;
- case 'G':
- nk = NameKind::NAMELIST_GROUP;
- name = readName(uniq, i, i + 1, end);
- break;
default:
assert(false && "unknown uniquing code");
ASSERT_EQ(actual.str(), expectedMangledName);
}
-TEST(InternalNamesTest, doNamelistGroup) {
- llvm::StringRef actual = NameUniquer::doNamelistGroup({"mod1"}, {}, {"nlg"});
- std::string expectedMangledName = "_QMmod1Gnlg";
- ASSERT_EQ(actual, expectedMangledName);
-}
-
TEST(InternalNamesTest, deconstructTest) {
std::pair actual = NameUniquer::deconstruct("_QBhello");
auto expectedNameKind = NameUniquer::NameKind::COMMON;
expectedNameKind = NameKind::DISPATCH_TABLE;
expectedComponents = {{}, {}, "t", {}};
validateDeconstructedName(actual, expectedNameKind, expectedComponents);
-
- actual = NameUniquer::deconstruct("_QFmstartGmpitop");
- expectedNameKind = NameKind::NAMELIST_GROUP;
- expectedComponents = {{}, {"mstart"}, "mpitop", {}};
- validateDeconstructedName(actual, expectedNameKind, expectedComponents);
}
// main() from gtest_main