xref: /llvm-project/clang/test/AST/ast-dump-sme-attributes.cpp (revision 8e7f073eb42c92aa7a2b651ca314d7fcebf296e3)
1 // Test without serialization:
2 // RUN: %clang_cc1 -triple aarch64 -target-feature +sme -std=c++2a -ast-dump -ast-dump-filter Foo %s | FileCheck -strict-whitespace %s
3 
4 // Test with serialization:
5 // RUN: %clang_cc1 -std=c++20 -triple aarch64 -target-feature +sme -emit-pch -o %t %s
6 // RUN: %clang_cc1 -x c++ -std=c++20 -triple aarch64 -target-feature +sme -include-pch %t -ast-dump-all -ast-dump-filter Foo /dev/null \
7 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
8 // RUN: | FileCheck --strict-whitespace %s
9 
10 struct Foo {
11 // CHECK:      |-CXXRecordDecl {{.*}} implicit struct Foo
12 // CHECK-NEXT: |-CXXMethodDecl {{.*}} f_streaming 'void () __arm_streaming'
13 // CHECK-NEXT: |-CXXMethodDecl {{.*}} f_streaming_compatible 'void () __arm_streaming_compatible'
14 // CHECK-NEXT: |-CXXMethodDecl {{.*}} f_locally_streaming 'void ()'
15 // CHECK-NEXT: | `-ArmLocallyStreamingAttr
16 // CHECK-NEXT: |-CXXMethodDecl {{.*}} f_shared_za 'void () __arm_inout("za")'
17 // CHECK-NEXT: |-CXXMethodDecl {{.*}} f_new_za 'void ()'
18 // CHECK-NEXT: | `-ArmNewAttr {{.*}} za
19 // CHECK-NEXT: |-CXXMethodDecl {{.*}} f_preserves_za 'void () __arm_preserves("za")'
20   void f_streaming() __arm_streaming;
21   void f_streaming_compatible() __arm_streaming_compatible;
22   __arm_locally_streaming void f_locally_streaming();
23   void f_shared_za() __arm_inout("za");
24   __arm_new("za") void f_new_za();
25   void f_preserves_za() __arm_preserves("za");
26 
27 
28 // CHECK:      |-CXXMethodDecl {{.*}} test_lambda 'int (int)' implicit-inline
29 // CHECK:         `-CompoundStmt
30 // CHECK-NEXT:     |-DeclStmt
31 // CHECK-NEXT:     | `-VarDecl
32 // CHECK-NEXT:     |   `-LambdaExpr
33 // CHECK-NEXT:     |     |-CXXRecordDecl
34 // CHECK:          |     | |-CXXMethodDecl {{.*}} used constexpr operator() 'int (int) __arm_streaming const' inline
35 // CHECK:          |     | |-CXXConversionDecl {{.*}} implicit constexpr operator int (*)(int) __arm_streaming 'int (*() const noexcept)(int) __arm_streaming' inline
36 // CHECK:          |     | |-CXXMethodDecl {{.*}} implicit __invoke 'int (int) __arm_streaming' static inline
37 // CHECK:          `-ReturnStmt
38 // CHECK:            `-CXXOperatorCallExpr
39 // CHECK-NEXT:         |-ImplicitCastExpr {{.*}} 'int (*)(int) __arm_streaming const' <FunctionToPointerDecay>
40 // CHECK-NEXT:         | `-DeclRefExpr {{.*}} 'int (int) __arm_streaming const' lvalue CXXMethod {{.*}} 'operator()' 'int (int) __arm_streaming const'
test_lambdaFoo41   int test_lambda(int x) {
42     auto F = [](int x) __arm_streaming { return x; };
43     return F(x);
44   }
45 
46 // CHECK: |-TypedefDecl {{.*}} referenced s_ptrty 'void (*)(int, int) __arm_streaming'
47 // CHECK-NEXT: | `-PointerType {{.*}} 'void (*)(int, int) __arm_streaming'
48 // CHECK-NEXT: |   `-ParenType {{.*}} 'void (int, int) __arm_streaming' sugar
49 // CHECK-NEXT: |     `-FunctionProtoType {{.*}} 'void (int, int) __arm_streaming' cdecl
50   typedef void (*s_ptrty) (int, int) __arm_streaming;
51 
52 // CHECK:      `-CXXMethodDecl {{.*}} test_streaming_ptrty 'void (s_ptrty, int, int)' implicit-inline
53 // CHECK-NEXT:   |-ParmVarDecl {{.*}} used f 's_ptrty':'void (*)(int, int) __arm_streaming'
54 // CHECK-NEXT:   |-ParmVarDecl {{.*}} used x 'int'
55 // CHECK-NEXT:   |-ParmVarDecl {{.*}} used y 'int'
56 // CHECK:        `-CompoundStmt
57 // CHECK-NEXT:     `-ReturnStmt
58 // CHECK-NEXT:       `-CallExpr
59 // CHECK-NEXT:         |-ImplicitCastExpr {{.*}} 's_ptrty':'void (*)(int, int) __arm_streaming' <LValueToRValue>
60 // CHECK-NEXT:         | `-DeclRefExpr {{.*}} 's_ptrty':'void (*)(int, int) __arm_streaming' lvalue ParmVar {{.*}} 'f' 's_ptrty':'void (*)(int, int) __arm_streaming'
61 // CHECK-NEXT:         |-ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
62 // CHECK-NEXT:         | `-DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'
63 // CHECK-NEXT:         `-ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
64 // CHECK-NEXT:           `-DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'y' 'int'
test_streaming_ptrtyFoo65   void test_streaming_ptrty(s_ptrty f, int x, int y) { return f(x, y); };
66 };
67