1 //===------------------ ItaniumDemangleTest.cpp ---------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Demangle/ItaniumDemangle.h"
10 #include "llvm/Support/Allocator.h"
11 #include "gmock/gmock.h"
12 #include "gtest/gtest.h"
17 using namespace llvm::itanium_demangle
;
21 BumpPtrAllocator Alloc
;
24 void reset() { Alloc
.Reset(); }
26 template <typename T
, typename
... Args
> T
*makeNode(Args
&&... args
) {
27 return new (Alloc
.Allocate(sizeof(T
), alignof(T
)))
28 T(std::forward
<Args
>(args
)...);
31 void *allocateNodeArray(size_t sz
) {
32 return Alloc
.Allocate(sizeof(Node
*) * sz
, alignof(Node
*));
37 TEST(ItaniumDemangle
, MethodOverride
) {
38 struct TestParser
: AbstractManglingParser
<TestParser
, TestAllocator
> {
39 std::vector
<char> Types
;
41 TestParser(const char *Str
)
42 : AbstractManglingParser(Str
, Str
+ strlen(Str
)) {}
45 Types
.push_back(*First
);
46 return AbstractManglingParser
<TestParser
, TestAllocator
>::parseType();
50 TestParser
Parser("_Z1fIiEjl");
51 ASSERT_NE(nullptr, Parser
.parse());
52 EXPECT_THAT(Parser
.Types
, testing::ElementsAre('i', 'j', 'l'));