@@ -39,6 +39,10 @@ struct GetEnumPattern {
39
39
using DeclTy = EnumDecl;
40
40
BindableMatcher<Decl> operator ()() { return enumDecl (hasName (" E" )); }
41
41
};
42
+ struct GetTypedefNamePattern {
43
+ using DeclTy = TypedefNameDecl;
44
+ BindableMatcher<Decl> operator ()() { return typedefNameDecl (hasName (" T" )); }
45
+ };
42
46
43
47
// Values for the value-parameterized test fixtures.
44
48
// FunctionDecl:
@@ -55,6 +59,11 @@ const auto *AnonC = "namespace { class X; }";
55
59
// EnumDecl:
56
60
const auto *ExternE = " enum E {};" ;
57
61
const auto *AnonE = " namespace { enum E {}; }" ;
62
+ // TypedefNameDecl:
63
+ const auto *ExternTypedef = " typedef int T;" ;
64
+ const auto *AnonTypedef = " namespace { typedef int T; }" ;
65
+ const auto *ExternUsing = " using T = int;" ;
66
+ const auto *AnonUsing = " namespace { using T = int; }" ;
58
67
59
68
// First value in tuple: Compile options.
60
69
// Second value in tuple: Source code to be used in the test.
@@ -243,6 +252,7 @@ using ImportFunctionsVisibility = ImportVisibility<GetFunPattern>;
243
252
using ImportVariablesVisibility = ImportVisibility<GetVarPattern>;
244
253
using ImportClassesVisibility = ImportVisibility<GetClassPattern>;
245
254
using ImportEnumsVisibility = ImportVisibility<GetEnumPattern>;
255
+ using ImportTypedefNameVisibility = ImportVisibility<GetTypedefNamePattern>;
246
256
247
257
// FunctionDecl.
248
258
TEST_P (ImportFunctionsVisibility, ImportAfter) {
@@ -272,6 +282,13 @@ TEST_P(ImportEnumsVisibility, ImportAfter) {
272
282
TEST_P (ImportEnumsVisibility, ImportAfterImport) {
273
283
TypedTest_ImportAfterImportWithMerge ();
274
284
}
285
+ // TypedefNameDecl.
286
+ TEST_P (ImportTypedefNameVisibility, ImportAfter) {
287
+ TypedTest_ImportAfterWithMerge ();
288
+ }
289
+ TEST_P (ImportTypedefNameVisibility, ImportAfterImport) {
290
+ TypedTest_ImportAfterImportWithMerge ();
291
+ }
275
292
276
293
const bool ExpectLink = true ;
277
294
const bool ExpectNotLink = false ;
@@ -318,6 +335,30 @@ INSTANTIATE_TEST_CASE_P(
318
335
std::make_tuple(ExternE, AnonE, ExpectNotLink),
319
336
std::make_tuple(AnonE, ExternE, ExpectNotLink),
320
337
std::make_tuple(AnonE, AnonE, ExpectNotLink))), );
338
+ INSTANTIATE_TEST_CASE_P (
339
+ ParameterizedTests, ImportTypedefNameVisibility,
340
+ ::testing::Combine (
341
+ DefaultTestValuesForRunOptions,
342
+ ::testing::Values (
343
+ std::make_tuple (ExternTypedef, ExternTypedef, ExpectLink),
344
+ std::make_tuple(ExternTypedef, AnonTypedef, ExpectNotLink),
345
+ std::make_tuple(AnonTypedef, ExternTypedef, ExpectNotLink),
346
+ std::make_tuple(AnonTypedef, AnonTypedef, ExpectNotLink),
347
+
348
+ std::make_tuple(ExternUsing, ExternUsing, ExpectLink),
349
+ std::make_tuple(ExternUsing, AnonUsing, ExpectNotLink),
350
+ std::make_tuple(AnonUsing, ExternUsing, ExpectNotLink),
351
+ std::make_tuple(AnonUsing, AnonUsing, ExpectNotLink),
352
+
353
+ std::make_tuple(ExternUsing, ExternTypedef, ExpectLink),
354
+ std::make_tuple(ExternUsing, AnonTypedef, ExpectNotLink),
355
+ std::make_tuple(AnonUsing, ExternTypedef, ExpectNotLink),
356
+ std::make_tuple(AnonUsing, AnonTypedef, ExpectNotLink),
357
+
358
+ std::make_tuple(ExternTypedef, ExternUsing, ExpectLink),
359
+ std::make_tuple(ExternTypedef, AnonUsing, ExpectNotLink),
360
+ std::make_tuple(AnonTypedef, ExternUsing, ExpectNotLink),
361
+ std::make_tuple(AnonTypedef, AnonUsing, ExpectNotLink))), );
321
362
322
363
} // end namespace ast_matchers
323
364
} // end namespace clang
0 commit comments