From ce5b5b486a71939913b1a0909498f216b5528401 Mon Sep 17 00:00:00 2001 From: James Henderson Date: Thu, 17 Jan 2019 15:18:44 +0000 Subject: Move demangling function from llvm-objdump to Demangle library This allows it to be used in an upcoming llvm-readobj change. A small change in internal behaviour of the function is to always call the microsoftDemangle function if the string does not have an itanium encoding prefix, rather than only if it starts with '?'. This is harmless because the microsoftDemangle function does the same check already. Reviewed by: grimar, erik.pilkington Differential Revision: https://reviews.llvm.org/D56721 llvm-svn: 351448 --- llvm/unittests/Demangle/DemangleTest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 llvm/unittests/Demangle/DemangleTest.cpp (limited to 'llvm/unittests/Demangle/DemangleTest.cpp') diff --git a/llvm/unittests/Demangle/DemangleTest.cpp b/llvm/unittests/Demangle/DemangleTest.cpp new file mode 100644 index 00000000000..f60122cc137 --- /dev/null +++ b/llvm/unittests/Demangle/DemangleTest.cpp @@ -0,0 +1,19 @@ +//===-- DemangleTest.cpp --------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Demangle/Demangle.h" +#include "gmock/gmock.h" + +using namespace llvm; + +TEST(Demangle, demangleTest) { + EXPECT_EQ(demangle("_Z3fooi"), "foo(int)"); + EXPECT_EQ(demangle("?foo@@YAXH@Z"), "void __cdecl foo(int)"); + EXPECT_EQ(demangle("foo"), "foo"); +} -- cgit v1.2.3