18 #include <gtest/gtest.h>
27 void TestDemangling(
const string& mangled,
const string& expected_demangled) {
29 EXPECT_EQ(result, expected_demangled);
34 EXPECT_EQ(result, expected_demangled);
40 ColumnType* ret_arg_type,
const string& expected_mangled,
41 const string& expected_demangled) {
46 EXPECT_TRUE(!demangled.empty()) << demangled;
47 EXPECT_EQ(mangled, expected_mangled);
48 EXPECT_EQ(demangled, expected_demangled);
52 const string& expected_demangled) {
57 EXPECT_TRUE(!demangled.empty()) << demangled;
58 EXPECT_EQ(mangled, expected_mangled);
59 EXPECT_EQ(demangled, expected_demangled);
66 "NoArgs(impala_udf::FunctionContext*)");
67 TestDemangling(
"_Z8IdentityPN10impala_udf15FunctionContextERKNS_10TinyIntValE",
68 "Identity(impala_udf::FunctionContext*, impala_udf::TinyIntVal const&)");
69 TestDemangling(
"_Z8IdentityPN10impala_udf15FunctionContextERKNS_9StringValE",
70 "Identity(impala_udf::FunctionContext*, impala_udf::StringVal const&)");
71 TestDemangling(
"_ZN3Foo4TESTEPN10impala_udf15FunctionContextERKNS0_6IntValES5_",
72 "Foo::TEST(impala_udf::FunctionContext*, impala_udf::IntVal const&, "
73 "impala_udf::IntVal const&)");
75 "_Z14VarSumMultiplyPN10impala_udf15FunctionContextERKNS_9DoubleValEiPKNS_6IntValE",
76 "VarSumMultiply(impala_udf::FunctionContext*, impala_udf::DoubleVal const&, int, "
77 "impala_udf::IntVal const*)");
92 "_Z14VarSumMultiplyPN10impala_udf15FunctionContextERKNS_9DoubleValEiPKNS_6IntValE",
102 vector<ColumnType> args;
103 TestMangling(
"Foo",
false, args, NULL,
"_Z3FooPN10impala_udf15FunctionContextE",
104 "Foo(impala_udf::FunctionContext*)");
106 "_Z3FooPN10impala_udf15FunctionContextEPNS_6IntValE",
107 "Foo(impala_udf::FunctionContext*, impala_udf::IntVal*)");
108 TestMangling(
"A::B",
false, args, NULL,
"_ZN1A1BEPN10impala_udf15FunctionContextE",
109 "A::B(impala_udf::FunctionContext*)");
110 TestMangling(
"A::B::C",
false, args, NULL,
"_ZN1A1B1CEPN10impala_udf15FunctionContextE",
111 "A::B::C(impala_udf::FunctionContext*)");
113 "_ZN1A1B1CEPN10impala_udf15FunctionContextEPNS1_6IntValE",
114 "A::B::C(impala_udf::FunctionContext*, impala_udf::IntVal*)");
119 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValE",
120 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&)");
122 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValEPS2_",
123 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&, impala_udf::IntVal*)");
125 "_Z1FPN10impala_udf15FunctionContextEiPKNS_6IntValE",
126 "F(impala_udf::FunctionContext*, int, impala_udf::IntVal const*)");
128 "_Z1FPN10impala_udf15FunctionContextEiPKNS_6IntValEPS2_",
129 "F(impala_udf::FunctionContext*, int, impala_udf::IntVal const*, "
130 "impala_udf::IntVal*)");
132 "_ZN1F1BEPN10impala_udf15FunctionContextERKNS0_6IntValE",
133 "F::B(impala_udf::FunctionContext*, impala_udf::IntVal const&)");
135 "_ZN1F1B1C1DEPN10impala_udf15FunctionContextERKNS2_6IntValE",
136 "F::B::C::D(impala_udf::FunctionContext*, impala_udf::IntVal const&)");
138 "_ZN1F1BEPN10impala_udf15FunctionContextEiPKNS0_6IntValE",
139 "F::B(impala_udf::FunctionContext*, int, impala_udf::IntVal const*)");
141 "_ZN1F1BEPN10impala_udf15FunctionContextEiPKNS0_6IntValEPS3_",
142 "F::B(impala_udf::FunctionContext*, int, impala_udf::IntVal const*, "
143 "impala_udf::IntVal*)");
148 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValES4_",
149 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&, "
150 "impala_udf::IntVal const&)");
152 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValES4_PS2_",
153 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&, "
154 "impala_udf::IntVal const&, impala_udf::IntVal*)");
156 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValEiPS3_",
157 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&, int, "
158 "impala_udf::IntVal const*)");
160 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValEiPS3_PS2_",
161 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&, int, "
162 "impala_udf::IntVal const*, impala_udf::IntVal*)");
164 "_ZN1F1BEPN10impala_udf15FunctionContextERKNS0_6IntValES5_",
165 "F::B(impala_udf::FunctionContext*, impala_udf::IntVal const&, "
166 "impala_udf::IntVal const&)");
170 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValES4_S4_",
171 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&, "
172 "impala_udf::IntVal const&, impala_udf::IntVal const&)");
174 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValES4_S4_PS2_",
175 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&, "
176 "impala_udf::IntVal const&, impala_udf::IntVal const&, "
177 "impala_udf::IntVal*)");
179 "_Z1FPN10impala_udf15FunctionContextERKNS_6IntValES4_S4_PNS_9DoubleValE",
180 "F(impala_udf::FunctionContext*, impala_udf::IntVal const&, "
181 "impala_udf::IntVal const&, impala_udf::IntVal const&, "
182 "impala_udf::DoubleVal*)");
192 "_Z4TESTPN10impala_udf15FunctionContextERKNS_9DoubleValES4_RKNS_6IntValES7_",
193 "TEST(impala_udf::FunctionContext*, impala_udf::DoubleVal const&, "
194 "impala_udf::DoubleVal const&, impala_udf::IntVal const&, "
195 "impala_udf::IntVal const&)");
197 "_Z4TESTPN10impala_udf15FunctionContextERKNS_9DoubleValES4_RKNS_6IntValEiPS6_",
198 "TEST(impala_udf::FunctionContext*, impala_udf::DoubleVal const&, "
199 "impala_udf::DoubleVal const&, impala_udf::IntVal const&, int, "
200 "impala_udf::IntVal const*)");
202 "_Z4TESTPN10impala_udf15FunctionContextERKNS_9DoubleValES4_RKNS_6IntValES7_PS5_",
203 "TEST(impala_udf::FunctionContext*, impala_udf::DoubleVal const&, "
204 "impala_udf::DoubleVal const&, impala_udf::IntVal const&, "
205 "impala_udf::IntVal const&, impala_udf::IntVal*)");
207 "_Z4TESTPN10impala_udf15FunctionContextERKNS_9DoubleValES4_RKNS_6IntValEiPS6_PS2_",
208 "TEST(impala_udf::FunctionContext*, impala_udf::DoubleVal const&, "
209 "impala_udf::DoubleVal const&, impala_udf::IntVal const&, int, "
210 "impala_udf::IntVal const*, impala_udf::DoubleVal*)");
219 "_Z4TESTPN10impala_udf15FunctionContextERKNS_6IntValERKNS_9DoubleValES7_S4_",
220 "TEST(impala_udf::FunctionContext*, impala_udf::IntVal const&, impala_udf::"
221 "DoubleVal const&, impala_udf::DoubleVal const&, impala_udf::IntVal const&)");
223 "_Z4TESTPN10impala_udf15FunctionContextERKNS_6IntValERKNS_9DoubleValES7_iPS3_",
224 "TEST(impala_udf::FunctionContext*, impala_udf::IntVal const&, impala_udf::"
225 "DoubleVal const&, impala_udf::DoubleVal const&, int, "
226 "impala_udf::IntVal const*)");
241 "_Z8AllTypesPN10impala_udf15FunctionContextERKNS_9StringValERKNS_10"
242 "BooleanValERKNS_10TinyIntValERKNS_11SmallIntValERKNS_6IntValERKNS_9BigIntVal"
243 "ERKNS_8FloatValERKNS_9DoubleValERKNS_12TimestampValERKNS_9StringValE",
244 "AllTypes(impala_udf::FunctionContext*, impala_udf::StringVal const&, "
245 "impala_udf::BooleanVal const&, impala_udf::TinyIntVal const&, "
246 "impala_udf::SmallIntVal const&, impala_udf::IntVal const&, "
247 "impala_udf::BigIntVal const&, impala_udf::FloatVal const&, "
248 "impala_udf::DoubleVal const&, impala_udf::TimestampVal const&, "
249 "impala_udf::StringVal const&)");
251 "_Z8AllTypesPN10impala_udf15FunctionContextERKNS_9StringValERKNS_10BooleanValE"
252 "RKNS_10TinyIntValERKNS_11SmallIntValERKNS_6IntValERKNS_9BigIntValE"
253 "RKNS_8FloatValERKNS_9DoubleValERKNS_12TimestampValERKNS_9StringValEPSE_",
254 "AllTypes(impala_udf::FunctionContext*, impala_udf::StringVal const&, "
255 "impala_udf::BooleanVal const&, impala_udf::TinyIntVal const&, "
256 "impala_udf::SmallIntVal const&, impala_udf::IntVal const&, "
257 "impala_udf::BigIntVal const&, impala_udf::FloatVal const&, "
258 "impala_udf::DoubleVal const&, impala_udf::TimestampVal const&, "
259 "impala_udf::StringVal const&, impala_udf::IntVal*)");
261 "_Z8AllTypesPN10impala_udf15FunctionContextERKNS_9StringValERKNS_10BooleanValE"
262 "RKNS_10TinyIntValERKNS_11SmallIntValERKNS_6IntValERKNS_9BigIntValE"
263 "RKNS_8FloatValERKNS_9DoubleValERKNS_12TimestampValERKNS_9StringValEPSN_",
264 "AllTypes(impala_udf::FunctionContext*, impala_udf::StringVal const&, "
265 "impala_udf::BooleanVal const&, impala_udf::TinyIntVal const&, "
266 "impala_udf::SmallIntVal const&, impala_udf::IntVal const&, "
267 "impala_udf::BigIntVal const&, impala_udf::FloatVal const&, "
268 "impala_udf::DoubleVal const&, impala_udf::TimestampVal const&, "
269 "impala_udf::StringVal const&, impala_udf::DoubleVal*)");
275 "_Z4TESTPN10impala_udf15FunctionContextEPNS_9StringValE",
276 "TEST(impala_udf::FunctionContext*, impala_udf::StringVal*)");
279 "_Z4TESTPN10impala_udf15FunctionContextERKNS_9StringValEPS2_",
280 "TEST(impala_udf::FunctionContext*, impala_udf::StringVal const&, "
281 "impala_udf::StringVal*)");
286 "_Z12CountPreparePN10impala_udf15FunctionContextENS0_18FunctionStateScopeE",
287 "CountPrepare(impala_udf::FunctionContext*,"
288 " impala_udf::FunctionContext::FunctionStateScope)");
290 "_ZN3foo3barEPN10impala_udf15FunctionContextENS1_18FunctionStateScopeE",
291 "foo::bar(impala_udf::FunctionContext*,"
292 " impala_udf::FunctionContext::FunctionStateScope)");
297 int main(
int argc,
char **argv) {
298 ::testing::InitGoogleTest(&argc, argv);
300 return RUN_ALL_TESTS();
static std::string ManglePrepareOrCloseFunction(const std::string &fn_name)
Utility class to manipulate c++/IR symbols, mangling and demangling names.
static ColumnType CreateCharType(int len)
static std::string Demangle(const std::string &name)
void TestDemanglingNameOnly(const string &mangled, const string &expected_demangled)
void TestDemangling(const string &mangled, const string &expected_demangled)
static void InitializeLlvm(bool load_backend=false)
void TestMangling(const string &name, bool var_args, const vector< ColumnType > args, ColumnType *ret_arg_type, const string &expected_mangled, const string &expected_demangled)
void TestManglingPrepareOrClose(const string &name, const string &expected_mangled, const string &expected_demangled)
int main(int argc, char **argv)
static std::string MangleUserFunction(const std::string &fn_name, const std::vector< ColumnType > &arg_types, bool has_var_args=false, ColumnType *ret_argument=NULL)
static std::string DemangleNameOnly(const std::string &symbol)