[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / AST / deduction-guides.cpp
blobffcde2b270163017a53a31ca22f2628c9ebd156a
1 // Test without serialization:
2 // RUN: %clang_cc1 -fsyntax-only %s -ast-dump -std=c++17 | FileCheck %s
3 //
4 // Test with serialization:
5 // RUN: %clang_cc1 -std=c++17 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -x c++ -std=c++17 -include-pch %t -ast-dump-all /dev/null \
7 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
8 // RUN: | FileCheck %s
10 namespace PR46111 {
11 template <typename>
12 struct S;
14 template <typename T>
15 struct HasDeductionGuide {
16 typedef PR46111::S<T> STy;
17 HasDeductionGuide(typename STy::Child);
20 // This causes deduction guides to be generated for all constructors.
21 HasDeductionGuide()->HasDeductionGuide<int>;
23 template <typename T>
24 struct HasDeductionGuideTypeAlias {
25 using STy = PR46111::S<T>;
26 HasDeductionGuideTypeAlias(typename STy::Child);
29 // This causes deduction guides to be generated for all constructors.
30 HasDeductionGuideTypeAlias()->HasDeductionGuideTypeAlias<int>;
32 // The parameter to this one shouldn't be an elaborated type.
33 // CHECK: CXXDeductionGuideDecl {{.*}} implicit <deduction guide for HasDeductionGuide> 'auto (typename STy::Child) -> HasDeductionGuide<T>'
34 // CHECK: CXXDeductionGuideDecl {{.*}} implicit <deduction guide for HasDeductionGuide> 'auto (HasDeductionGuide<T>) -> HasDeductionGuide<T>'
35 // CHECK: CXXDeductionGuideDecl {{.*}} <deduction guide for HasDeductionGuide> 'auto () -> HasDeductionGuide<int>'
36 // CHECK: CXXDeductionGuideDecl {{.*}} implicit <deduction guide for HasDeductionGuideTypeAlias> 'auto (typename STy::Child) -> HasDeductionGuideTypeAlias<T>'
37 // CHECK: CXXDeductionGuideDecl {{.*}} implicit <deduction guide for HasDeductionGuideTypeAlias> 'auto (HasDeductionGuideTypeAlias<T>) -> HasDeductionGuideTypeAlias<T>'
38 // CHECK: CXXDeductionGuideDecl {{.*}} <deduction guide for HasDeductionGuideTypeAlias> 'auto () -> HasDeductionGuideTypeAlias<int>'
39 } // namespace PR46111
42 namespace PR48177 {
43 template <class A> struct Base {
44 using type_alias = A;
46 template<class T, int S, class A>
47 struct Derived : Base<A> {
48 using type_alias = typename Derived::type_alias;
49 Derived(Derived &&, typename Derived::type_alias const&);
50 Derived(T);
53 template<class T, class A>
54 Derived(T, A) -> Derived<T, 1, A>;
56 void init() {
57 Derived d {1,2};
59 } // namespace PR48177
61 // CHECK: CXXRecordDecl {{.*}} struct Derived
62 // CHECK: TypeAliasDecl {{.*}} type_alias 'typename Derived<T, S, A>::type_alias'
63 // CHECK-NEXT: DependentNameType {{.*}} 'typename Derived<T, S, A>::type_alias' dependent
65 // CHECK: CXXRecordDecl {{.*}} struct Derived
66 // CHECK: TypeAliasDecl {{.*}} type_alias 'typename Derived<int, 1, int>::type_alias':'int'
67 // CHECK-NEXT: ElaboratedType {{.*}} 'typename Derived<int, 1, int>::type_alias' sugar
68 // CHECK-NEXT: TypedefType {{.*}} 'PR48177::Base<int>::type_alias' sugar
69 // CHECK-NEXT: TypeAlias {{.*}} 'type_alias'
70 // CHECK-NEXT: SubstTemplateTypeParmType {{.*}} 'int' sugar class depth 0 index 0 A
71 // CHECK-NEXT: ClassTemplateSpecialization {{.*}} 'Base'
72 // CHECK-NEXT: BuiltinType {{.*}} 'int'
74 // CHECK: CXXDeductionGuideDecl {{.*}} implicit <deduction guide for Derived> 'auto (Derived<T, S, A> &&, const typename Derived<T, S, A>::type_alias &) -> Derived<T, S, A>'
75 // CHECK: CXXDeductionGuideDecl {{.*}} implicit <deduction guide for Derived> 'auto (T) -> Derived<T, S, A>'
76 // CHECK: CXXDeductionGuideDecl {{.*}} implicit <deduction guide for Derived> 'auto (Derived<T, S, A>) -> Derived<T, S, A>'
77 // CHECK: CXXDeductionGuideDecl {{.*}} <deduction guide for Derived> 'auto (T, A) -> Derived<T, 1, A>'
78 // CHECK: CXXDeductionGuideDecl {{.*}} <deduction guide for Derived> 'auto (int, int) -> Derived<int, 1, int>'