llvm.org GIT mirror llvm / 25cfd0d
[MS Demangler] Add support for $$Z parameter pack separator. $$Z appears between adjacent expanded parameter packs in the same template instantiation. We don't need to print it, it's only there to disambiguate between manglings that would otherwise be ambiguous. So we just need to parse it and throw it away. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341119 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 1 year, 18 days ago
2 changed file(s) with 36 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
519519 return VSN;
520520 }
521521
522 void dump(Node *N) {
523 OutputStream OS = OutputStream::create(nullptr, nullptr, 1024);
524 N->output(OS, OF_Default);
525 OS << '\0';
526 char *Name = OS.getBuffer();
527
528 printf(Name);
529 printf("\n");
530 std::free(Name);
531 }
532
522533 FunctionSymbolNode *Demangler::demangleInitFiniStub(StringView &MangledName,
523534 bool IsDestructor) {
524535 DynamicStructorIdentifierNode *DSIN =
525536 Arena.alloc();
526537 DSIN->IsDestructor = IsDestructor;
527538
528 // What follows is a main symbol name. This may include namespaces or class
529 // back references.
539 bool IsKnownStaticDataMember = false;
540 if (MangledName.consumeFront('?'))
541 IsKnownStaticDataMember = true;
542
530543 QualifiedNameNode *QN = demangleFullyQualifiedSymbolName(MangledName);
531544
532545 SymbolNode *Symbol = demangleEncodedSymbol(MangledName, QN);
535548
536549 if (Symbol->kind() == NodeKind::VariableSymbol) {
537550 DSIN->Variable = static_cast(Symbol);
538 if (!MangledName.consumeFront('@')) {
551
552 // Older versions of clang mangled this type of symbol incorrectly. They
553 // would omit the leading ? and they would only emit a single @ at the end.
554 // The correct mangling is a leading ? and 2 trailing @ signs. Handle
555 // both cases.
556 int AtCount = IsKnownStaticDataMember ? 2 : 1;
557 for (int I = 0; I < AtCount; ++I) {
558 if (MangledName.consumeFront('@'))
559 continue;
539560 Error = true;
540561 return nullptr;
541562 }
543564 FSN = demangleFunctionEncoding(MangledName);
544565 FSN->Name = synthesizeQualifiedName(Arena, DSIN);
545566 } else {
567 if (IsKnownStaticDataMember) {
568 // This was supposed to be a static data member, but we got a function.
569 Error = true;
570 return nullptr;
571 }
572
546573 FSN = static_cast(Symbol);
547574 DSIN->Name = Symbol->Name;
548575 FSN->Name = synthesizeQualifiedName(Arena, DSIN);
21472174
21482175 while (!Error && !MangledName.startsWith('@')) {
21492176 if (MangledName.consumeFront("$S") || MangledName.consumeFront("$$V") ||
2150 MangledName.consumeFront("$$$V")) {
2151 // Empty parameter pack.
2177 MangledName.consumeFront("$$$V") || MangledName.consumeFront("$$Z")) {
2178 // parameter pack separator
21522179 continue;
21532180 }
21542181
8585 ??$templ_fun_with_pack@$S@@YAXXZ
8686 ; CHECK: void __cdecl templ_fun_with_pack<>(void)
8787
88 ; $$Z is a parameter pack separator.
89 ??$func@H$$ZH@@YAHAEBU?$Foo@H@@0@Z
90 ; CHECK: int __cdecl func(struct Foo const &, struct Foo const &)
91
8892 ??$templ_fun_with_ty_pack@$$$V@@YAXXZ
8993 ; CHECK: void __cdecl templ_fun_with_ty_pack<>(void)
9094 ??$templ_fun_with_ty_pack@$$V@@YAXXZ