[demangler] Use a back-patching scheme to resolve forward references.
authorErik Pilkington <erik.pilkington@gmail.com>
Sun, 25 Mar 2018 22:50:33 +0000 (22:50 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Sun, 25 Mar 2018 22:50:33 +0000 (22:50 +0000)
commit8a1cb33ba5ab5c649253d2fb032cb2569e1f76ff
treeff133e25ce8cb4ee6fca202b532d26973a3f0c3b
parent8c7013d4cadf6fa7c164768fc88127442a3b54c9
[demangler] Use a back-patching scheme to resolve forward references.

Strictly in a conversion operator's type, a <template-param> refers to a
<template-arg> that is further ahead in the mangled name. Instead of
doing a second parse to resolve these, introduce a
ForwardTemplateReference Node and back-patch the referenced
<template-arg> when we're in the right context.

This is also a correctness fix, previously we would only do a second
parse if the <template-param> was out of bounds in the current set of
<template-args>. This lead to misdemangles (gasp!) when the conversion
operator was a member of a templated struct, for instance.

llvm-svn: 328464
libcxxabi/src/cxa_demangle.cpp
libcxxabi/test/test_demangle.pass.cpp
llvm/lib/Demangle/ItaniumDemangle.cpp