Demangler library: add a function swift_demangle_getModuleName to get the module name of a mangled symbol.

rdar://problem/47560963
This commit is contained in:
Erik Eckstein
2019-02-19 11:26:26 -08:00
parent de86e4f79e
commit 706f4c8622
6 changed files with 116 additions and 19 deletions

View File

@@ -87,3 +87,21 @@ TEST(FunctionNameDemangleTests, IgnoresNonMangledInputs) {
EXPECT_STREQ("0123456789abcdef", OutputBuffer);
}
TEST(FunctionNameDemangleTests, ModuleName) {
const char *Sym1 = "_TtCs5Class";
const char *ModuleName1 = "Swift";
const char *Sym2 = "_TtCC3Mod7ExampleP33_211017DA67536A354F5F5EB94C7AC12E2Pv";
const char *ModuleName2 = "Mod";
char OutputBuffer[128];
size_t Result = swift_demangle_getModuleName(Sym1, OutputBuffer,
sizeof(OutputBuffer));
EXPECT_STREQ(ModuleName1, OutputBuffer);
EXPECT_EQ(Result, strlen(ModuleName1));
Result = swift_demangle_getModuleName(Sym2, OutputBuffer,
sizeof(OutputBuffer));
EXPECT_STREQ(ModuleName2, OutputBuffer);
EXPECT_EQ(Result, strlen(ModuleName2));
}