[PATCH] D27985: Add demangling support for C++11 thread_local variables

Dave Bozier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 20 05:37:52 PST 2016


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>
                 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27985.82100.patch
Type: text/x-patch
Size: 2420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161220/7cc9b3d6/attachment-0001.bin>


More information about the cfe-commits mailing list