1+ // FileCheck lines automatically generated using make-ast-dump-check-v2.py
2+ // REQUIRES: apple-disclosure-ios
3+
4+ // RUN: %clang_cc1 -triple x86_64-apple-mac -ast-dump -fbounds-safety %s 2>&1 | FileCheck %s
5+ // RUN: %clang_cc1 -triple x86_64-apple-mac -ast-dump -fbounds-safety -x objective-c -fbounds-attributes-objc-experimental %s 2>&1 | FileCheck %s
6+ #include <ptrcheck.h>
7+
8+ struct S {
9+ int * end ;
10+ int * __ended_by (end ) iter ;
11+ };
12+
13+ // CHECK-LABEL:|-FunctionDecl {{.+}} used foo 'void (int *__single __ended_by(end)const, int *__single /* __started_by(start) */ const)'
14+ // CHECK-NEXT: | |-ParmVarDecl {{.+}} used start 'int *__single __ended_by(end)const':'int *__singleconst'
15+ // CHECK-NEXT: | |-ParmVarDecl {{.+}} used end 'int *__single /* __started_by(start) */ const':'int *__singleconst'
16+ // CHECK-NEXT: | `-CompoundStmt {{.+}}
17+ // CHECK-NEXT: | `-DeclStmt {{.+}}
18+ // CHECK-NEXT: | `-VarDecl {{.+}} local 'int *__bidi_indexable' cinit
19+ // CHECK-NEXT: | `-FirebloomPointerPromotionExpr {{.+}} 'int *__bidi_indexable'
20+ // CHECK-NEXT: | |-DeclRefExpr {{.+}} 'int *__single /* __started_by(start) */ const':'int *__singleconst' lvalue ParmVar {{.+}} 'end' 'int *__single /* __started_by(start) */ const':'int *__singleconst'
21+ // CHECK-NEXT: | |-ImplicitCastExpr {{.+}} 'int *__single /* __started_by(start) */ const':'int *__singleconst' <LValueToRValue>
22+ // CHECK-NEXT: | | `-DeclRefExpr {{.+}} 'int *__single /* __started_by(start) */ const':'int *__singleconst' lvalue ParmVar {{.+}} 'end' 'int *__single /* __started_by(start) */ const':'int *__singleconst'
23+ // CHECK-NEXT: | `-ImplicitCastExpr {{.+}} <<invalid sloc>> 'int *__single __ended_by(end)const':'int *__singleconst' <LValueToRValue>
24+ // CHECK-NEXT: | `-DeclRefExpr {{.+}} <<invalid sloc>> 'int *__single __ended_by(end)const':'int *__singleconst' lvalue ParmVar {{.+}} 'start' 'int *__single __ended_by(end)const':'int *__singleconst'
25+ void foo (int * const __ended_by (end ) start , int * const end ) {
26+ int * local = end ;
27+ }
28+
29+ // CHECK-LABEL:`-FunctionDecl {{.+}} bar 'void (void)'
30+ // CHECK-NEXT: `-CompoundStmt {{.+}}
31+ // CHECK-NEXT: |-DeclStmt {{.+}}
32+ // CHECK-NEXT: | `-VarDecl {{.+}} used arr 'int[40]'
33+ // CHECK-NEXT: `-MaterializeSequenceExpr {{.+}} 'void' <Unbind>
34+ // CHECK-NEXT: |-MaterializeSequenceExpr {{.+}} 'void' <Bind>
35+ // CHECK-NEXT: | |-BoundsCheckExpr {{.+}} 'void' 'arr + 40 <= __builtin_get_pointer_upper_bound(arr) && arr <= arr + 40'
36+ // CHECK-NEXT: | | |-CallExpr {{.+}} 'void'
37+ // CHECK-NEXT: | | | |-ImplicitCastExpr {{.+}} 'void (*__single)(int *__single __ended_by(end)const, int *__single /* __started_by(start) */ const)' <FunctionToPointerDecay>
38+ // CHECK-NEXT: | | | | `-DeclRefExpr {{.+}} 'void (int *__single __ended_by(end)const, int *__single /* __started_by(start) */ const)' Function {{.+}} 'foo' 'void (int *__single __ended_by(end)const, int *__single /* __started_by(start) */ const)'
39+ // CHECK-NEXT: | | | |-ImplicitCastExpr {{.+}} 'int *__single __ended_by(end)':'int *__single' <FirebloomPointerCast>
40+ // CHECK-NEXT: | | | | `-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
41+ // CHECK-NEXT: | | | | `-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
42+ // CHECK-NEXT: | | | | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
43+ // CHECK-NEXT: | | | `-ImplicitCastExpr {{.+}} 'int *__single /* __started_by(start) */ ':'int *__single' <FirebloomPointerCast>
44+ // CHECK-NEXT: | | | `-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
45+ // CHECK-NEXT: | | | `-BinaryOperator {{.+}} 'int *__bidi_indexable' '+'
46+ // CHECK-NEXT: | | | |-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
47+ // CHECK-NEXT: | | | | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
48+ // CHECK-NEXT: | | | `-IntegerLiteral {{.+}} 'int' 40
49+ // CHECK-NEXT: | | `-BinaryOperator {{.+}} 'int' '&&'
50+ // CHECK-NEXT: | | |-BinaryOperator {{.+}} 'int' '<='
51+ // CHECK-NEXT: | | | |-ImplicitCastExpr {{.+}} 'int *' <FirebloomPointerCast>
52+ // CHECK-NEXT: | | | | `-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
53+ // CHECK-NEXT: | | | | `-BinaryOperator {{.+}} 'int *__bidi_indexable' '+'
54+ // CHECK-NEXT: | | | | |-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
55+ // CHECK-NEXT: | | | | | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
56+ // CHECK-NEXT: | | | | `-IntegerLiteral {{.+}} 'int' 40
57+ // CHECK-NEXT: | | | `-ImplicitCastExpr {{.+}} 'int *' <FirebloomPointerCast>
58+ // CHECK-NEXT: | | | `-GetBoundExpr {{.+}} 'int *__bidi_indexable' upper
59+ // CHECK-NEXT: | | | `-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
60+ // CHECK-NEXT: | | | `-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
61+ // CHECK-NEXT: | | | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
62+ // CHECK-NEXT: | | `-BinaryOperator {{.+}} 'int' '<='
63+ // CHECK-NEXT: | | |-ImplicitCastExpr {{.+}} 'int *' <FirebloomPointerCast>
64+ // CHECK-NEXT: | | | `-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
65+ // CHECK-NEXT: | | | `-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
66+ // CHECK-NEXT: | | | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
67+ // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} 'int *' <FirebloomPointerCast>
68+ // CHECK-NEXT: | | `-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
69+ // CHECK-NEXT: | | `-BinaryOperator {{.+}} 'int *__bidi_indexable' '+'
70+ // CHECK-NEXT: | | |-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
71+ // CHECK-NEXT: | | | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
72+ // CHECK-NEXT: | | `-IntegerLiteral {{.+}} 'int' 40
73+ // CHECK-NEXT: | |-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
74+ // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
75+ // CHECK-NEXT: | | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
76+ // CHECK-NEXT: | `-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
77+ // CHECK-NEXT: | `-BinaryOperator {{.+}} 'int *__bidi_indexable' '+'
78+ // CHECK-NEXT: | |-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
79+ // CHECK-NEXT: | | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
80+ // CHECK-NEXT: | `-IntegerLiteral {{.+}} 'int' 40
81+ // CHECK-NEXT: |-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
82+ // CHECK-NEXT: | `-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
83+ // CHECK-NEXT: | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
84+ // CHECK-NEXT: `-OpaqueValueExpr {{.+}} 'int *__bidi_indexable'
85+ // CHECK-NEXT: `-BinaryOperator {{.+}} 'int *__bidi_indexable' '+'
86+ // CHECK-NEXT: |-ImplicitCastExpr {{.+}} 'int *__bidi_indexable' <ArrayToPointerDecay>
87+ // CHECK-NEXT: | `-DeclRefExpr {{.+}} 'int[40]' lvalue Var {{.+}} 'arr' 'int[40]'
88+ // CHECK-NEXT: `-IntegerLiteral {{.+}} 'int' 40
89+ void bar (void ) {
90+ int arr [40 ];
91+ foo (arr , arr + 40 );
92+ }
0 commit comments