Index: COFF/Config.h =================================================================== --- COFF/Config.h +++ COFF/Config.h @@ -90,6 +90,7 @@ bool NoEntry = false; std::string OutputFile; std::string ImportName; + bool Demangle = true; bool DoGC = true; bool DoICF = true; bool TailMerge; Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -1081,6 +1081,9 @@ Config->Incremental = true; } + // Handle /demangle + Config->Demangle = Args.hasFlag(OPT_demangle, OPT_demangle_no); + // Handle /debugtype Config->DebugTypes = parseDebugTypes(Args); Index: COFF/Options.td =================================================================== --- COFF/Options.td +++ COFF/Options.td @@ -154,6 +154,9 @@ // LLD extensions def exclude_all_symbols : F<"exclude-all-symbols">; def export_all_symbols : F<"export-all-symbols">; +defm demangle : B<"demangle", + "Demangle symbols in output (default)", + "Do not demangle symbols in output">; def kill_at : F<"kill-at">; def lldmingw : F<"lldmingw">; def output_def : Joined<["/", "-"], "output-def:">; @@ -178,11 +181,6 @@ class QF : Joined<["/", "-", "-?"], name#":">; -multiclass QB { - def "" : F; - def _no : F; -} - def ignoreidl : F<"ignoreidl">; def nologo : F<"nologo">; def throwingnew : F<"throwingnew">; Index: COFF/Symbols.cpp =================================================================== --- COFF/Symbols.cpp +++ COFF/Symbols.cpp @@ -18,10 +18,13 @@ using namespace llvm; using namespace llvm::object; +using namespace lld::coff; + // Returns a symbol name for an error message. std::string lld::toString(coff::Symbol &B) { - if (Optional S = lld::demangleMSVC(B.getName())) - return ("\"" + *S + "\" (" + B.getName() + ")").str(); + if (Config->Demangle) + if (Optional S = lld::demangleMSVC(B.getName())) + return *S; return B.getName(); } Index: test/COFF/undefined-symbol-cv.s =================================================================== --- test/COFF/undefined-symbol-cv.s +++ test/COFF/undefined-symbol-cv.s @@ -2,19 +2,19 @@ # RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s # RUN: not lld-link /out:%t.exe %t.obj 2>&1 | FileCheck %s -# CHECK: error: undefined symbol: "int __cdecl foo(void)" (?foo@@YAHXZ) +# CHECK: error: undefined symbol: int __cdecl foo(void) # CHECK-NEXT: >>> referenced by file1.cpp:1 # CHECK-NEXT: >>> {{.*}}.obj:(main) # CHECK-NEXT: >>> referenced by file1.cpp:2 # CHECK-NEXT: >>> {{.*}}.obj:(main) # CHECK-EMPTY: -# CHECK-NEXT: error: undefined symbol: "int __cdecl bar(void)" (?bar@@YAHXZ) +# CHECK-NEXT: error: undefined symbol: int __cdecl bar(void) # CHECK-NEXT: >>> referenced by file2.cpp:3 # CHECK-NEXT: >>> {{.*}}.obj:(main) # CHECK-NEXT: >>> referenced by file1.cpp:4 # CHECK-NEXT: >>> {{.*}}.obj:(f1) # CHECK-EMPTY: -# CHECK-NEXT: error: undefined symbol: "int __cdecl baz(void)" (?baz@@YAHXZ) +# CHECK-NEXT: error: undefined symbol: int __cdecl baz(void) # CHECK-NEXT: >>> referenced by file1.cpp:5 # CHECK-NEXT: >>> {{.*}}.obj:(f2) Index: test/COFF/undefined-symbol.s =================================================================== --- test/COFF/undefined-symbol.s +++ test/COFF/undefined-symbol.s @@ -1,16 +1,22 @@ # REQUIRES: x86 # RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s # RUN: not lld-link /out:%t.exe %t.obj 2>&1 | FileCheck %s +# RUN: not lld-link /out:%t.exe /demangle %t.obj 2>&1 | FileCheck %s +# RUN: not lld-link /out:%t.exe /demangle:no %t.obj 2>&1 | FileCheck --check-prefix=NODEMANGLE %s -# CHECK: error: undefined symbol: "int __cdecl foo(void)" (?foo@@YAHXZ) +# NODEMANGLE: error: undefined symbol: ?foo@@YAHXZ +# NODEMANGLE: error: undefined symbol: ?bar@@YAHXZ +# NODEMANGLE: error: undefined symbol: __imp_?baz@@YAHXZ + +# CHECK: error: undefined symbol: int __cdecl foo(void) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(main) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(main) # CHECK-EMPTY: -# CHECK-NEXT: error: undefined symbol: "int __cdecl bar(void)" (?bar@@YAHXZ) +# CHECK-NEXT: error: undefined symbol: int __cdecl bar(void) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(main) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(f1) # CHECK-EMPTY: -# CHECK-NEXT: error: undefined symbol: "__declspec(dllimport) int __cdecl baz(void)" (__imp_?baz@@YAHXZ) +# CHECK-NEXT: error: undefined symbol: __declspec(dllimport) int __cdecl baz(void) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(f2) .section .text,"xr",one_only,main