[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / AST / ast-dump-static-operators.cpp
blobe8454bdac02f7b6efb98ac1605eaaf3335bbe460
1 // RUN: %clang_cc1 -std=c++23 %s -ast-dump -triple x86_64-unknown-unknown -o - | FileCheck -strict-whitespace %s
3 struct Functor {
4 static int operator()(int x, int y) {
5 return x + y;
7 static int operator[](int x, int y) {
8 return x + y;
12 Functor& get_functor() {
13 static Functor functor;
14 return functor;
17 void call_static_operators() {
18 Functor functor;
20 int z1 = functor(1, 2);
21 // CHECK: CXXOperatorCallExpr {{.*}} 'int' '()'
22 // CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:19, col:24> 'int (*)(int, int)' <FunctionToPointerDecay>
23 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:19, col:24> 'int (int, int)' lvalue CXXMethod {{.*}} 'operator()' 'int (int, int)'
24 // CHECK-NEXT: |-DeclRefExpr {{.*}} <col:12> 'Functor' lvalue Var {{.*}} 'functor' 'Functor'
25 // CHECK-NEXT: |-IntegerLiteral {{.*}} <col:20> 'int' 1
26 // CHECK-NEXT: `-IntegerLiteral {{.*}} <col:23> 'int' 2
28 int z2 = functor[1, 2];
29 // CHECK: CXXOperatorCallExpr {{.*}} 'int' '[]'
30 // CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:19, col:24> 'int (*)(int, int)' <FunctionToPointerDecay>
31 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:19, col:24> 'int (int, int)' lvalue CXXMethod {{.*}} 'operator[]' 'int (int, int)'
32 // CHECK-NEXT: |-DeclRefExpr {{.*}} <col:12> 'Functor' lvalue Var {{.*}} 'functor' 'Functor'
33 // CHECK-NEXT: |-IntegerLiteral {{.*}} <col:20> 'int' 1
34 // CHECK-NEXT: `-IntegerLiteral {{.*}} <col:23> 'int' 2
36 int z3 = get_functor()(1, 2);
37 // CHECK: CXXOperatorCallExpr {{.*}} 'int' '()'
38 // CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:25, col:30> 'int (*)(int, int)' <FunctionToPointerDecay>
39 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:25, col:30> 'int (int, int)' lvalue CXXMethod {{.*}} 'operator()' 'int (int, int)'
40 // CHECK-NEXT: |-CallExpr {{.*}} <col:12, col:24> 'Functor' lvalue
41 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:12> 'Functor &(*)()' <FunctionToPointerDecay>
42 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:12> 'Functor &()' lvalue Function {{.*}} 'get_functor' 'Functor &()'
43 // CHECK-NEXT: |-IntegerLiteral {{.*}} <col:26> 'int' 1
44 // CHECK-NEXT: `-IntegerLiteral {{.*}} <col:29> 'int' 2
46 int z4 = get_functor()[1, 2];
47 // CHECK: CXXOperatorCallExpr {{.*}} 'int' '[]'
48 // CHECK-NEXT: |-ImplicitCastExpr {{.*}} <col:25, col:30> 'int (*)(int, int)' <FunctionToPointerDecay>
49 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:25, col:30> 'int (int, int)' lvalue CXXMethod {{.*}} 'operator[]' 'int (int, int)'
50 // CHECK-NEXT: |-CallExpr {{.*}} <col:12, col:24> 'Functor' lvalue
51 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:12> 'Functor &(*)()' <FunctionToPointerDecay>
52 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:12> 'Functor &()' lvalue Function {{.*}} 'get_functor' 'Functor &()'
53 // CHECK-NEXT: |-IntegerLiteral {{.*}} <col:26> 'int' 1
54 // CHECK-NEXT: `-IntegerLiteral {{.*}} <col:29> 'int' 2