davidb created this revision. davidb added reviewers: howard.hinnant, mclow.lists. davidb added a subscriber: cfe-commits. davidb set the repository for this revision to rL LLVM.
Add support for demangling C++11 thread_local variables. In clang, the grammar for mangling for these names are "<special-name> ::= TW <object name>" for wrapper variables or "<special-name> ::= TH <object name>" for initialization variables. Repository: rL LLVM https://reviews.llvm.org/D27985 Files: src/cxa_demangle.cpp test/test_demangle.pass.cpp Index: test/test_demangle.pass.cpp =================================================================== --- test/test_demangle.pass.cpp +++ test/test_demangle.pass.cpp @@ -29594,6 +29594,8 @@ // NOTE: disable this test since it is a negative test case, you cannot demangle a non-mangled symbol // {"\x6D", nullptr}, // This use to crash with ASAN {"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"}, + {"_ZTW1x", "thread-local wrapper routine for x"}, + {"_ZTHN3fooE", "thread-local initialization routine for foo"}, }; const unsigned N = sizeof(cases) / sizeof(cases[0]); Index: src/cxa_demangle.cpp =================================================================== --- src/cxa_demangle.cpp +++ src/cxa_demangle.cpp @@ -4343,6 +4343,8 @@ // # base is the nominal target function of thunk // ::= GV <object name> # Guard variable for one-time initialization // # No <type> +// ::= TW <object name> # Thread-local wrapper +// ::= TH <object name> # Thread-local initialization // extension ::= TC <first type> <number> _ <second type> # construction vtable for second-in-first // extension ::= GR <object name> # reference temporary for object @@ -4446,6 +4448,28 @@ } } break; + case 'W': + // TW <object name> # Thread-local wrapper + t = parse_name(first + 2, last, db); + if (t != first + 2) + { + if (db.names.empty()) + return first; + db.names.back().first.insert(0, "thread-local wrapper routine for "); + first = t; + } + break; + case 'H': + //TH <object name> # Thread-local initialization + t = parse_name(first + 2, last, db); + if (t != first + 2) + { + if (db.names.empty()) + return first; + db.names.back().first.insert(0, "thread-local initialization routine for "); + first = t; + } + break; default: // T <call-offset> <base encoding> {
Index: test/test_demangle.pass.cpp =================================================================== --- test/test_demangle.pass.cpp +++ test/test_demangle.pass.cpp @@ -29594,6 +29594,8 @@ // NOTE: disable this test since it is a negative test case, you cannot demangle a non-mangled symbol // {"\x6D", nullptr}, // This use to crash with ASAN {"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"}, + {"_ZTW1x", "thread-local wrapper routine for x"}, + {"_ZTHN3fooE", "thread-local initialization routine for foo"}, }; const unsigned N = sizeof(cases) / sizeof(cases[0]); Index: src/cxa_demangle.cpp =================================================================== --- src/cxa_demangle.cpp +++ src/cxa_demangle.cpp @@ -4343,6 +4343,8 @@ // # base is the nominal target function of thunk // ::= GV <object name> # Guard variable for one-time initialization // # No <type> +// ::= TW <object name> # Thread-local wrapper +// ::= TH <object name> # Thread-local initialization // extension ::= TC <first type> <number> _ <second type> # construction vtable for second-in-first // extension ::= GR <object name> # reference temporary for object @@ -4446,6 +4448,28 @@ } } break; + case 'W': + // TW <object name> # Thread-local wrapper + t = parse_name(first + 2, last, db); + if (t != first + 2) + { + if (db.names.empty()) + return first; + db.names.back().first.insert(0, "thread-local wrapper routine for "); + first = t; + } + break; + case 'H': + //TH <object name> # Thread-local initialization + t = parse_name(first + 2, last, db); + if (t != first + 2) + { + if (db.names.empty()) + return first; + db.names.back().first.insert(0, "thread-local initialization routine for "); + first = t; + } + break; default: // T <call-offset> <base encoding> {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits