diff --git a/test/tools/llvm-cxxfilt/coff-import.test b/test/tools/llvm-cxxfilt/coff-import.test new file mode 100644 index 00000000000..35494d7a832 --- /dev/null +++ b/test/tools/llvm-cxxfilt/coff-import.test @@ -0,0 +1,5 @@ +RUN: llvm-cxxfilt -_ ___imp__ZSt6futureIvE | FileCheck %s +RUN: llvm-cxxfilt __imp__ZSt6futureIvE | FileCheck %s + +CHECK: import thunk for std::future + diff --git a/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/tools/llvm-cxxfilt/llvm-cxxfilt.cpp index 8be2a6d3b45..13024fbeaea 100644 --- a/tools/llvm-cxxfilt/llvm-cxxfilt.cpp +++ b/tools/llvm-cxxfilt/llvm-cxxfilt.cpp @@ -68,6 +68,12 @@ static void demangle(llvm::raw_ostream &OS, const std::string &Mangled) { (DecoratedLength >= 4 && strncmp(Decorated, "___Z", 4) == 0))) Undecorated = itaniumDemangle(Decorated, nullptr, nullptr, &Status); + if (!Undecorated && + (DecoratedLength > 6 && strncmp(Decorated, "__imp_", 6) == 0)) { + OS << "import thunk for "; + Undecorated = itaniumDemangle(Decorated + 6, nullptr, nullptr, &Status); + } + OS << (Undecorated ? Undecorated : Mangled) << '\n'; free(Undecorated);