From 9101881e58504fbfcf826f4a7d896a70a9afc1fb Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 27 Nov 2018 16:11:24 +0000 Subject: [PATCH] [Demangle] remove itaniumFindTypesInMangledName Summary: This (very specialized) function was added to enable an LLDB use case. Now that a more generic interface (overriding of parser functions - D52992) is available, and LLDB has been converted to use that (D54074), the function is unused and can be removed. Reviewers: erik.pilkington, sgraenitz, rsmith Subscribers: mgorny, hiraditya, christof, libcxx-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D54893 llvm-svn: 347670 --- include/llvm/Demangle/Demangle.h | 5 --- include/llvm/Demangle/ItaniumDemangle.h | 6 ---- lib/Demangle/ItaniumDemangle.cpp | 9 ----- unittests/Demangle/CMakeLists.txt | 1 - .../Demangle/FindTypesInMangledNameTest.cpp | 34 ------------------- 5 files changed, 55 deletions(-) delete mode 100644 unittests/Demangle/FindTypesInMangledNameTest.cpp diff --git a/include/llvm/Demangle/Demangle.h b/include/llvm/Demangle/Demangle.h index b9b4d158e2a..4c9dc9569e1 100644 --- a/include/llvm/Demangle/Demangle.h +++ b/include/llvm/Demangle/Demangle.h @@ -31,11 +31,6 @@ enum : int { char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n, int *status); -/// Calls the callback \c Callback with \c Ctx as an argument whenever a type is -/// encountered. Returns true if \c MangledName couldn't be parsed. -bool itaniumFindTypesInMangledName(const char *MangledName, void *Ctx, - void (*Callback)(void *, const char *)); - enum MSDemangleFlags { MSDF_None = 0, MSDF_DumpBackrefs = 1 << 0 }; char *microsoftDemangle(const char *mangled_name, char *buf, size_t *n, diff --git a/include/llvm/Demangle/ItaniumDemangle.h b/include/llvm/Demangle/ItaniumDemangle.h index c5619a15bbe..0b9187f30a5 100644 --- a/include/llvm/Demangle/ItaniumDemangle.h +++ b/include/llvm/Demangle/ItaniumDemangle.h @@ -2157,9 +2157,6 @@ template struct AbstractManglingParser { // conversion operator's type, and are resolved in the enclosing . PODSmallVector ForwardTemplateRefs; - void (*TypeCallback)(void *, const char *) = nullptr; - void *TypeCallbackContext = nullptr; - bool TryToParseTemplateArgs = true; bool PermitForwardTemplateReferences = false; bool ParsingLambdaParams = false; @@ -3453,9 +3450,6 @@ template Node *AbstractManglingParser::parseType() { Node *Result = nullptr; - if (TypeCallback != nullptr) - TypeCallback(TypeCallbackContext, First); - switch (look()) { // ::= case 'r': diff --git a/lib/Demangle/ItaniumDemangle.cpp b/lib/Demangle/ItaniumDemangle.cpp index e3bd3b87633..b2de0be2b70 100644 --- a/lib/Demangle/ItaniumDemangle.cpp +++ b/lib/Demangle/ItaniumDemangle.cpp @@ -356,15 +356,6 @@ char *llvm::itaniumDemangle(const char *MangledName, char *Buf, return InternalStatus == demangle_success ? Buf : nullptr; } -bool llvm::itaniumFindTypesInMangledName(const char *MangledName, void *Ctx, - void (*Callback)(void *, - const char *)) { - Demangler Parser(MangledName, MangledName + std::strlen(MangledName)); - Parser.TypeCallback = Callback; - Parser.TypeCallbackContext = Ctx; - return Parser.parse() == nullptr; -} - ItaniumPartialDemangler::ItaniumPartialDemangler() : RootNode(nullptr), Context(new Demangler{nullptr, nullptr}) {} diff --git a/unittests/Demangle/CMakeLists.txt b/unittests/Demangle/CMakeLists.txt index 2f9d71a37e9..954f3d05eac 100644 --- a/unittests/Demangle/CMakeLists.txt +++ b/unittests/Demangle/CMakeLists.txt @@ -6,5 +6,4 @@ set(LLVM_LINK_COMPONENTS add_llvm_unittest(DemangleTests ItaniumDemangleTest.cpp PartialDemangleTest.cpp - FindTypesInMangledNameTest.cpp ) diff --git a/unittests/Demangle/FindTypesInMangledNameTest.cpp b/unittests/Demangle/FindTypesInMangledNameTest.cpp deleted file mode 100644 index a2f77dc6d96..00000000000 --- a/unittests/Demangle/FindTypesInMangledNameTest.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===------------------ FindTypesInMangledNameTest.cpp --------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include -#include -#include "llvm/Demangle/Demangle.h" -#include "gtest/gtest.h" - -TEST(FindTypesInMangledNameTest, Test) { - std::vector Types; - const char *Mangled = "_Z1fiv"; - EXPECT_FALSE(llvm::itaniumFindTypesInMangledName( - Mangled, static_cast(&Types), [](void *Ty, const char *P) { - static_cast *>(Ty)->push_back(P); - })); - EXPECT_EQ(Types.size(), size_t(2)); - EXPECT_EQ(Mangled + 4, Types.front()); - EXPECT_EQ(Mangled + 5, Types.back()); - - EXPECT_TRUE(llvm::itaniumFindTypesInMangledName( - "Not a mangled name!", nullptr, [](void *, const char *) {})); - - int TC = 0; - EXPECT_FALSE(llvm::itaniumFindTypesInMangledName( - "_Z1fPRic", static_cast(&TC), - [](void *Ctx, const char *) { ++*static_cast(Ctx); })); - EXPECT_EQ(TC, 4); // pointer, reference, int, char. -}