From: Zachary Turner Date: Mon, 17 Dec 2018 16:14:50 +0000 (+0000) Subject: [MS Demangler] Add a helper function to print a Node as a string. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18f6a2ac130ad263c0381f0c62fbbfee63233261;p=llvm [MS Demangler] Add a helper function to print a Node as a string. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349359 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Demangle/MicrosoftDemangleNodes.h b/include/llvm/Demangle/MicrosoftDemangleNodes.h index 1d0b66a7bf4..1eca6762475 100644 --- a/include/llvm/Demangle/MicrosoftDemangleNodes.h +++ b/include/llvm/Demangle/MicrosoftDemangleNodes.h @@ -235,6 +235,8 @@ struct Node { virtual void output(OutputStream &OS, OutputFlags Flags) const = 0; + std::string toString() const; + private: NodeKind Kind; }; diff --git a/lib/Demangle/MicrosoftDemangleNodes.cpp b/lib/Demangle/MicrosoftDemangleNodes.cpp index c57f0cfaaa5..930c838753a 100644 --- a/lib/Demangle/MicrosoftDemangleNodes.cpp +++ b/lib/Demangle/MicrosoftDemangleNodes.cpp @@ -113,6 +113,14 @@ static void outputCallingConvention(OutputStream &OS, CallingConv CC) { } } +std::string Node::toString() const { + OutputStream OS; + initializeOutputStream(nullptr, nullptr, OS, 1024); + this->output(OS, llvm::ms_demangle::OF_Default); + OS << '\0'; + return {OS.getBuffer()}; +} + void TypeNode::outputQuals(bool SpaceBefore, bool SpaceAfter) const {} void PrimitiveTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {