Skip to content

Commit

Permalink
demo hack for #9
Browse files Browse the repository at this point in the history
  • Loading branch information
nico committed Sep 20, 2019
1 parent 3ee555c commit 9f3329b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 4 additions & 3 deletions demumble.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main(int argc, char* argv[]) {
char* end = cur + strlen(cur);

while (cur != end) {
size_t special = strcspn(cur, "_?");
size_t special = strcspn(cur, "_?.");
if (print_mode == kPrintAll)
printf("%.*s", static_cast<int>(special), cur);
else if (need_separator)
Expand All @@ -112,9 +112,10 @@ int main(int argc, char* argv[]) {
break;

size_t n_sym = 0;
if (*cur == '?')
while (cur + n_sym != end && is_mangle_char_win(cur[n_sym]))
if (*cur == '?' || *cur == '.')
do
++n_sym;
while (cur + n_sym != end && is_mangle_char_win(cur[n_sym]));
else if (is_plausible_itanium_prefix(cur))
while (cur + n_sym != end && is_mangle_char_itanium(cur[n_sym]))
++n_sym;
Expand Down
2 changes: 1 addition & 1 deletion third_party/llvm/include/llvm/Demangle/MicrosoftDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Demangler {

void dumpBackReferences();

private:
//private:
SymbolNode *demangleEncodedSymbol(StringView &MangledName,
QualifiedNameNode *QN);
SymbolNode *demangleDeclarator(StringView &MangledName);
Expand Down
10 changes: 9 additions & 1 deletion third_party/llvm/lib/Demangle/MicrosoftDemangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,13 @@ char *llvm::microsoftDemangle(const char *MangledName, char *Buf, size_t *N,
OutputStream S;

StringView Name{MangledName};
SymbolNode *AST = D.parse(Name);
Node *AST = nullptr;
bool wasTypeinfoName = false;
if (Name.consumeFront('.')) {
wasTypeinfoName = true;
AST = D.demangleType(Name, QualifierMangleMode::Result);
} else
AST = D.parse(Name);

if (Flags & MSDF_DumpBackrefs)
D.dumpBackReferences();
Expand All @@ -2333,6 +2339,8 @@ char *llvm::microsoftDemangle(const char *MangledName, char *Buf, size_t *N,
else if (!initializeOutputStream(Buf, N, S, 1024))
InternalStatus = demangle_memory_alloc_failure;
else {
if (wasTypeinfoName)
S << "typeinfo name for ";
AST->output(S, OF_Default);
S += '\0';
if (N != nullptr)
Expand Down

0 comments on commit 9f3329b

Please sign in to comment.