diff options
author | Steven Wu <stevenwu@apple.com> | 2019-12-16 09:48:00 -0800 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2019-12-16 09:50:04 -0800 |
commit | 2597135571ecae435e10e9136d1eb0435beca8ee (patch) | |
tree | 10ba69d0ad265b10214a67727c62227fa7c876b5 /llvm/tools/llvm-cxxfilt | |
parent | 878ab6df033d44430939c02075ee00800995dc3b (diff) | |
download | bcm5719-llvm-2597135571ecae435e10e9136d1eb0435beca8ee.tar.gz bcm5719-llvm-2597135571ecae435e10e9136d1eb0435beca8ee.zip |
[llvm-cxxfilt] Correctly demangle COFF import thunk
Summary:
llvm-cxxfilt wasn't correctly demangle COFF import thunk in those two
cases before:
* demangle in split mode (multiple words from commandline)
* the import thunk prefix was added no matter the later part of the
string can be demangled or not
Now llvm-cxxfilt should handle both case correctly.
Reviewers: compnerd, erik.pilkington, jhenderson
Reviewed By: jhenderson
Subscribers: jkorous, dexonsmith, ributzka, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71425
Diffstat (limited to 'llvm/tools/llvm-cxxfilt')
-rw-r--r-- | llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp index 75d6985133a..6de512fc18d 100644 --- a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp +++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp @@ -74,8 +74,9 @@ static bool shouldStripUnderscore() { return Triple(sys::getProcessTriple()).isOSBinFormatMachO(); } -static std::string demangle(llvm::raw_ostream &OS, const std::string &Mangled) { +static std::string demangle(const std::string &Mangled) { int Status; + std::string Prefix; const char *DecoratedStr = Mangled.c_str(); if (shouldStripUnderscore()) @@ -92,11 +93,11 @@ static std::string demangle(llvm::raw_ostream &OS, const std::string &Mangled) { if (!Undecorated && (DecoratedLength > 6 && strncmp(DecoratedStr, "__imp_", 6) == 0)) { - OS << "import thunk for "; + Prefix = "import thunk for "; Undecorated = itaniumDemangle(DecoratedStr + 6, nullptr, nullptr, &Status); } - std::string Result(Undecorated ? Undecorated : Mangled); + std::string Result(Undecorated ? Prefix + Undecorated : Mangled); free(Undecorated); return Result; } @@ -144,9 +145,9 @@ static void demangleLine(llvm::raw_ostream &OS, StringRef Mangled, bool Split) { SmallVector<std::pair<StringRef, StringRef>, 16> Words; SplitStringDelims(Mangled, Words, IsLegalItaniumChar); for (const auto &Word : Words) - Result += demangle(OS, Word.first) + Word.second.str(); + Result += ::demangle(Word.first) + Word.second.str(); } else - Result = demangle(OS, Mangled); + Result = ::demangle(Mangled); OS << Result << '\n'; OS.flush(); } |