Add a basic "re-mangler", which turns a parsed

demangling tree back into a mangled string.

Also, extend the demangling API in a few obvious
ways, and simplify testing for failure in the
node-returning APIs by having them simply return
null instead of a spurious Failure node.

Also, preserve slightly more information in the
demangling tree.  The goal here is eventually to
always allow a perfect round-trip through the
demangler parse tree.  This patch gets us close,
but we're not quite there yet.

Tests to follow.

Swift SVN r24473
This commit is contained in:
John McCall
2015-01-16 06:33:08 +00:00
parent cb702a9035
commit bb675b6ac9
9 changed files with 1821 additions and 502 deletions

View File

@@ -1129,18 +1129,20 @@ static int doPrintAST(const CompilerInvocation &InitInvok,
demangle_wrappers::demangleSymbolAsNode(MangledNameToFind);
using NodeKind = Demangle::Node::Kind;
if (node->getKind() != NodeKind::Global) {
if (!node) {
llvm::errs() << "Unable to demangle name.\n";
return EXIT_FAILURE;
}
node = node->getFirstChild();
// FIXME: Look up things other than types.
if (node->getKind() != NodeKind::Type) {
if (node->getKind() != NodeKind::TypeMangling) {
llvm::errs() << "Name does not refer to a type.\n";
return EXIT_FAILURE;
}
node = node->getFirstChild();
assert(node->getKind() == NodeKind::Type);
node = node->getFirstChild();
switch (node->getKind()) {
case NodeKind::Class: