OSDN Git Service

Subzero: Deal with substitutions in the primitive remangler.
authorJim Stichnoth <stichnot@chromium.org>
Fri, 11 Jul 2014 21:06:55 +0000 (14:06 -0700)
committerJim Stichnoth <stichnot@chromium.org>
Fri, 11 Jul 2014 21:06:55 +0000 (14:06 -0700)
commit217dc082d5cc2af1cc7c544f51ef15b4abe5be8b
tree97561c7f6ee5583fb1876c0cdde34aa65ebfaed3
parentb164d2085e870e2458c73c70c08ab69e56e2e081
Subzero: Deal with substitutions in the primitive remangler.

https://refspecs.linuxbase.org/cxxabi-1.75.html#mangling-compression
describes the mechanism for compressing mangled strings by using substitutions of the form S[0-9A-Z]*_ to represent repeated components.

When the prefix is handled as wrapping inside a namespace, the base-36 substitution numbers all have to be incremented.

This is implemented in a very simple way by scanning the string only for instances of the substitution pattern.

Unfortunately, false matches are possible because the S[0-9A-Z]*_ pattern can be a substring of the type name, or can span other components of the mangled name.  Getting this completely right would essentially require a full demangling parser - see the ~4000 lines of code in cxa_demangle.cpp and ItaniumMangle.cpp.

Since this is just for testing, any false matches will likely cause a linking error and the test can be rewritten to avoid false matches.

BUG= none
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/385273002
src/IceGlobalContext.cpp
src/IceGlobalContext.h
tests_lit/llvm2ice_tests/mangle.ll