@@ -17,117 +17,136 @@ using namespace lldb_private;
17
17
TEST (CPlusPlusLanguage, MethodNameParsing) {
18
18
struct TestCase {
19
19
std::string input;
20
- std::string context, basename, arguments, qualifiers, scope_qualified_name;
20
+ std::string return_type, context, basename, arguments, qualifiers,
21
+ scope_qualified_name;
21
22
};
22
23
23
24
TestCase test_cases[] = {
24
- {" main(int, char *[]) " , " " , " main" , " (int, char *[])" , " " , " main" },
25
- {" foo::bar(baz) const" , " foo" , " bar" , " (baz)" , " const" , " foo::bar" },
26
- {" foo::~bar(baz)" , " foo" , " ~bar" , " (baz)" , " " , " foo::~bar" },
27
- {" a::b::c::d(e,f)" , " a::b::c" , " d" , " (e,f)" , " " , " a::b::c::d" },
28
- {" void f(int)" , " " , " f" , " (int)" , " " , " f" },
25
+ {" main(int, char *[]) " , " " , " " , " main" , " (int, char *[])" , " " , " main" },
26
+ {" foo::bar(baz) const" , " " , " foo" , " bar" , " (baz)" , " const" , " foo::bar" },
27
+ {" foo::~bar(baz)" , " " , " foo" , " ~bar" , " (baz)" , " " , " foo::~bar" },
28
+ {" a::b::c::d(e,f)" , " " , " a::b::c" , " d" , " (e,f)" , " " , " a::b::c::d" },
29
+ {" void f(int)" , " void " , " " , " f" , " (int)" , " " , " f" },
29
30
30
31
// Operators
31
32
{" std::basic_ostream<char, std::char_traits<char> >& "
32
- " std::operator<<<std::char_traits<char> >"
33
- " (std::basic_ostream<char, std::char_traits<char> >&, char const*)" ,
34
- " std" , " operator<<<std::char_traits<char> >" ,
33
+ " std::operator<<<std::char_traits<char> >(std::basic_ostream<char, "
34
+ " std::char_traits<char> >&, char const*)" ,
35
+ " std::basic_ostream<char, std::char_traits<char> >&" , " std" ,
36
+ " operator<<<std::char_traits<char> >" ,
35
37
" (std::basic_ostream<char, std::char_traits<char> >&, char const*)" , " " ,
36
38
" std::operator<<<std::char_traits<char> >" },
37
39
{" operator delete[](void*, clang::ASTContext const&, unsigned long)" , " " ,
38
- " operator delete[]" , " (void*, clang::ASTContext const&, unsigned long)" ,
39
- " " , " operator delete[]" },
40
- {" llvm::Optional<clang::PostInitializer>::operator bool() const" ,
40
+ " " , " operator delete[]" ,
41
+ " (void*, clang::ASTContext const&, unsigned long)" , " " ,
42
+ " operator delete[]" },
43
+ {" llvm::Optional<clang::PostInitializer>::operator bool() const" , " " ,
41
44
" llvm::Optional<clang::PostInitializer>" , " operator bool" , " ()" , " const" ,
42
45
" llvm::Optional<clang::PostInitializer>::operator bool" },
43
- {" (anonymous namespace)::FactManager::operator[](unsigned short)" ,
46
+ {" (anonymous namespace)::FactManager::operator[](unsigned short)" , " " ,
44
47
" (anonymous namespace)::FactManager" , " operator[]" , " (unsigned short)" ,
45
48
" " , " (anonymous namespace)::FactManager::operator[]" },
46
49
{" const int& std::map<int, pair<short, int>>::operator[](short) const" ,
47
- " std::map<int, pair<short, int>>" , " operator[]" , " (short)" , " const " ,
48
- " std::map<int, pair<short, int>>::operator[]" },
49
- {" CompareInsn::operator()(llvm::StringRef, InsnMatchEntry const&)" ,
50
+ " const int& " , " std::map<int, pair<short, int>>" , " operator[]" , " (short)" ,
51
+ " const " , " std::map<int, pair<short, int>>::operator[]" },
52
+ {" CompareInsn::operator()(llvm::StringRef, InsnMatchEntry const&)" , " " ,
50
53
" CompareInsn" , " operator()" , " (llvm::StringRef, InsnMatchEntry const&)" ,
51
54
" " , " CompareInsn::operator()" },
52
- {" llvm::Optional<llvm::MCFixupKind>::operator*() const &" ,
55
+ {" llvm::Optional<llvm::MCFixupKind>::operator*() const &" , " " ,
53
56
" llvm::Optional<llvm::MCFixupKind>" , " operator*" , " ()" , " const &" ,
54
57
" llvm::Optional<llvm::MCFixupKind>::operator*" },
58
+ {" auto std::__1::ranges::__begin::__fn::operator()[abi:v160000]<char "
59
+ " const, 18ul>(char const (&) [18ul]) const" ,
60
+ " auto" , " std::__1::ranges::__begin::__fn" ,
61
+ " operator()[abi:v160000]<char const, 18ul>" , " (char const (&) [18ul])" ,
62
+ " const" ,
63
+ " std::__1::ranges::__begin::__fn::operator()[abi:v160000]<char const, "
64
+ " 18ul>" },
55
65
// Internal classes
56
- {" operator<<(Cls, Cls)::Subclass::function()" ,
66
+ {" operator<<(Cls, Cls)::Subclass::function()" , " " ,
57
67
" operator<<(Cls, Cls)::Subclass" , " function" , " ()" , " " ,
58
68
" operator<<(Cls, Cls)::Subclass::function" },
59
- {" SAEC::checkFunction(context&) const::CallBack::CallBack(int)" ,
69
+ {" SAEC::checkFunction(context&) const::CallBack::CallBack(int)" , " " ,
60
70
" SAEC::checkFunction(context&) const::CallBack" , " CallBack" , " (int)" , " " ,
61
71
" SAEC::checkFunction(context&) const::CallBack::CallBack" },
62
72
// Anonymous namespace
63
- {" XX::(anonymous namespace)::anon_class::anon_func() const" ,
73
+ {" XX::(anonymous namespace)::anon_class::anon_func() const" , " " ,
64
74
" XX::(anonymous namespace)::anon_class" , " anon_func" , " ()" , " const" ,
65
75
" XX::(anonymous namespace)::anon_class::anon_func" },
66
76
67
77
// Lambda
68
78
{" main::{lambda()#1}::operator()() const::{lambda()#1}::operator()() "
69
79
" const" ,
70
- " main::{lambda()#1}::operator()() const::{lambda()#1}" , " operator()" ,
80
+ " " , " main::{lambda()#1}::operator()() const::{lambda()#1}" , " operator()" ,
71
81
" ()" , " const" ,
72
82
" main::{lambda()#1}::operator()() const::{lambda()#1}::operator()" },
73
83
74
84
// Function pointers
75
- {" string (*f(vector<int>&&))(float)" , " " , " f " , " (vector<int>&&) " , " " ,
76
- " f" },
77
- {" void (*&std::_Any_data::_M_access<void (*)()>())()" , " std::_Any_data " ,
78
- " _M_access<void (*)()>" , " ()" , " " ,
85
+ {" string (*f(vector<int>&&))(float)" , " " , " " , " f " ,
86
+ " (vector<int>&&) " , " " , " f" },
87
+ {" void (*&std::_Any_data::_M_access<void (*)()>())()" , " " ,
88
+ " std::_Any_data " , " _M_access<void (*)()>" , " ()" , " " ,
79
89
" std::_Any_data::_M_access<void (*)()>" },
80
90
{" void (*(*(*(*(*(*(*(* const&func1(int))())())())())())())())()" , " " ,
81
- " func1" , " (int)" , " " , " func1" },
91
+ " " , " func1" , " (int)" , " " , " func1" },
82
92
83
93
// Decltype
84
94
{" decltype(nullptr)&& std::forward<decltype(nullptr)>"
85
95
" (std::remove_reference<decltype(nullptr)>::type&)" ,
86
- " std" , " forward<decltype(nullptr)>" ,
96
+ " decltype(nullptr)&& " , " std" , " forward<decltype(nullptr)>" ,
87
97
" (std::remove_reference<decltype(nullptr)>::type&)" , " " ,
88
98
" std::forward<decltype(nullptr)>" },
89
99
90
100
// Templates
91
101
{" void llvm::PM<llvm::Module, llvm::AM<llvm::Module>>::"
92
102
" addPass<llvm::VP>(llvm::VP)" ,
93
- " llvm::PM<llvm::Module, llvm::AM<llvm::Module>> " , " addPass<llvm::VP >" ,
94
- " (llvm::VP)" , " " ,
103
+ " void " , " llvm::PM<llvm::Module, llvm::AM<llvm::Module>>" ,
104
+ " addPass<llvm::VP> " , " (llvm::VP)" , " " ,
95
105
" llvm::PM<llvm::Module, llvm::AM<llvm::Module>>::"
96
106
" addPass<llvm::VP>" },
97
107
{" void std::vector<Class, std::allocator<Class> >"
98
108
" ::_M_emplace_back_aux<Class const&>(Class const&)" ,
99
- " std::vector<Class, std::allocator<Class> >" ,
109
+ " void " , " std::vector<Class, std::allocator<Class> >" ,
100
110
" _M_emplace_back_aux<Class const&>" , " (Class const&)" , " " ,
101
111
" std::vector<Class, std::allocator<Class> >::"
102
112
" _M_emplace_back_aux<Class const&>" },
103
113
{" unsigned long llvm::countTrailingOnes<unsigned int>"
104
114
" (unsigned int, llvm::ZeroBehavior)" ,
105
- " llvm" , " countTrailingOnes<unsigned int>" ,
115
+ " unsigned long " , " llvm" , " countTrailingOnes<unsigned int>" ,
106
116
" (unsigned int, llvm::ZeroBehavior)" , " " ,
107
117
" llvm::countTrailingOnes<unsigned int>" },
108
118
{" std::enable_if<(10u)<(64), bool>::type llvm::isUInt<10u>(unsigned "
109
119
" long)" ,
110
- " llvm" , " isUInt<10u>" , " (unsigned long)" , " " , " llvm::isUInt<10u>" },
111
- {" f<A<operator<(X,Y)::Subclass>, sizeof(B)<sizeof(C)>()" , " " ,
120
+ " std::enable_if<(10u)<(64), bool>::type" , " llvm" , " isUInt<10u>" ,
121
+ " (unsigned long)" , " " , " llvm::isUInt<10u>" },
122
+ {" f<A<operator<(X,Y)::Subclass>, sizeof(B)<sizeof(C)>()" , " " , " " ,
112
123
" f<A<operator<(X,Y)::Subclass>, sizeof(B)<sizeof(C)>" , " ()" , " " ,
113
124
" f<A<operator<(X,Y)::Subclass>, sizeof(B)<sizeof(C)>" },
114
- {" llvm::Optional<llvm::MCFixupKind>::operator*() const volatile &&" ,
125
+ {" llvm::Optional<llvm::MCFixupKind>::operator*() const volatile &&" , " " ,
115
126
" llvm::Optional<llvm::MCFixupKind>" , " operator*" , " ()" ,
116
127
" const volatile &&" , " llvm::Optional<llvm::MCFixupKind>::operator*" },
117
- {" void foo<Dummy<char [10]>>()" , " " , " foo<Dummy<char [10]>>" , " ()" , " " ,
118
- " foo<Dummy<char [10]>>" },
128
+ {" void foo<Dummy<char [10]>>()" , " void" , " " , " foo<Dummy<char [10]>>" ,
129
+ " ()" , " " , " foo<Dummy<char [10]>>" },
130
+ {" void foo<Bar<Bar<int>[10]>>()" , " void" , " " , " foo<Bar<Bar<int>[10]>>" ,
131
+ " ()" , " " , " foo<Bar<Bar<int>[10]>>" },
132
+ {" void foo<Bar[10]>()" , " void" , " " , " foo<Bar[10]>" , " ()" , " " ,
133
+ " foo<Bar[10]>" },
134
+ {" void foo<Bar[]>()" , " void" , " " , " foo<Bar[]>" , " ()" , " " , " foo<Bar[]>" },
119
135
120
136
// auto return type
121
- {" auto std::test_return_auto<int>() const" , " std" ,
137
+ {" auto std::test_return_auto<int>() const" , " auto " , " std" ,
122
138
" test_return_auto<int>" , " ()" , " const" , " std::test_return_auto<int>" },
123
- {" decltype(auto) std::test_return_auto<int>(int) const" , " std" ,
124
- " test_return_auto<int>" , " (int)" , " const" , " std::test_return_auto<int>" },
139
+ {" decltype(auto) std::test_return_auto<int>(int) const" , " decltype(auto)" ,
140
+ " std" , " test_return_auto<int>" , " (int)" , " const" ,
141
+ " std::test_return_auto<int>" },
125
142
126
143
// abi_tag on class method
127
144
{" v1::v2::Dummy[abi:c1][abi:c2]<v1::v2::Dummy[abi:c1][abi:c2]<int>> "
128
145
" v1::v2::Dummy[abi:c1][abi:c2]<v1::v2::Dummy[abi:c1][abi:c2]<int>>"
129
146
" ::method2<v1::v2::Dummy[abi:c1][abi:c2]<v1::v2::Dummy[abi:c1][abi:c2]<"
130
147
" int>>>(int, v1::v2::Dummy<int>) const &&" ,
148
+ // Return type
149
+ " v1::v2::Dummy[abi:c1][abi:c2]<v1::v2::Dummy[abi:c1][abi:c2]<int>>" ,
131
150
// Context
132
151
" v1::v2::Dummy[abi:c1][abi:c2]<v1::v2::Dummy[abi:c1][abi:c2]<int>>" ,
133
152
// Basename
@@ -145,6 +164,8 @@ TEST(CPlusPlusLanguage, MethodNameParsing) {
145
164
" v1::v2::with_tag_in_ns[abi:f1][abi:f2]<v1::v2::Dummy[abi:c1][abi:c2]"
146
165
" <v1::v2::Dummy[abi:c1][abi:c2]<int>>>(int, v1::v2::Dummy<int>) const "
147
166
" &&" ,
167
+ // Return type
168
+ " v1::v2::Dummy[abi:c1][abi:c2]<v1::v2::Dummy[abi:c1][abi:c2]<int>>" ,
148
169
// Context
149
170
" v1::v2" ,
150
171
// Basename
@@ -160,6 +181,8 @@ TEST(CPlusPlusLanguage, MethodNameParsing) {
160
181
{" auto ns::with_tag_in_ns[abi:special tag,0.0][abi:special "
161
182
" tag,1.0]<Dummy<int>>"
162
183
" (float) const &&" ,
184
+ // Return type
185
+ " auto" ,
163
186
// Context
164
187
" ns" ,
165
188
// Basename
@@ -171,15 +194,15 @@ TEST(CPlusPlusLanguage, MethodNameParsing) {
171
194
" tag,1.0]<Dummy<int>>" },
172
195
173
196
// abi_tag on operator overloads
174
- {" std::__1::error_code::operator bool[abi:v160000]() const" ,
197
+ {" std::__1::error_code::operator bool[abi:v160000]() const" , " " ,
175
198
" std::__1::error_code" , " operator bool[abi:v160000]" , " ()" , " const" ,
176
199
" std::__1::error_code::operator bool[abi:v160000]" },
177
200
178
- {" auto ns::foo::operator[][abi:v160000](size_t) const" , " ns::foo" ,
201
+ {" auto ns::foo::operator[][abi:v160000](size_t) const" , " auto " , " ns::foo" ,
179
202
" operator[][abi:v160000]" , " (size_t)" , " const" ,
180
203
" ns::foo::operator[][abi:v160000]" },
181
204
182
- {" auto Foo[abi:abc]<int>::operator<<<Foo[abi:abc]<int>>(int) &" ,
205
+ {" auto Foo[abi:abc]<int>::operator<<<Foo[abi:abc]<int>>(int) &" , " auto " ,
183
206
" Foo[abi:abc]<int>" , " operator<<<Foo[abi:abc]<int>>" , " (int)" , " &" ,
184
207
" Foo[abi:abc]<int>::operator<<<Foo[abi:abc]<int>>" },
185
208
@@ -191,6 +214,7 @@ TEST(CPlusPlusLanguage, MethodNameParsing) {
191
214
CPlusPlusLanguage::MethodName method (ConstString (test.input ));
192
215
EXPECT_TRUE (method.IsValid ()) << test.input ;
193
216
if (method.IsValid ()) {
217
+ EXPECT_EQ (test.return_type , method.GetReturnType ().str ());
194
218
EXPECT_EQ (test.context , method.GetContext ().str ());
195
219
EXPECT_EQ (test.basename , method.GetBasename ().str ());
196
220
EXPECT_EQ (test.arguments , method.GetArguments ().str ());
0 commit comments