Skip to content

Commit

Permalink
[Bounds Safety][NFC] Add some missing coverage for `-fexperimental-la…
Browse files Browse the repository at this point in the history
…te-parse-attributes` (#102236)

Previously we weren't properly checking that using
`-fexperimental-late-parse-attributes` worked on source code that didn't
need late parsing.

For example we weren't testing that the attribute appearing in the type
position generated the right AST with
`-fexperimental-late-parse-attributes` off.

This patch adds additional `RUN` lines to re-run the relevant test cases
with `-fexperimental-late-parse-attributes` enabled.

rdar://133325597
  • Loading branch information
delcypher authored Aug 8, 2024
1 parent 3e71357 commit 876ee11
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 8 deletions.
1 change: 1 addition & 0 deletions clang/test/AST/attr-counted-by-or-null-struct-ptrs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s

#define __counted_by_or_null(f) __attribute__((counted_by_or_null(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/AST/attr-counted-by-struct-ptrs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s

#define __counted_by(f) __attribute__((counted_by(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/AST/attr-sized-by-or-null-struct-ptrs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s

#define __sized_by_or_null(f) __attribute__((sized_by_or_null(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/AST/attr-sized-by-struct-ptrs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s

#define __sized_by(f) __attribute__((sized_by(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-counted-by-bounds-safety-vlas.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -fexperimental-bounds-safety -verify %s
// RUN: %clang_cc1 -fsyntax-only -fexperimental-bounds-safety -fexperimental-late-parse-attributes -verify %s
//
// This is a portion of the `attr-counted-by-vla.c` test but is checked
// under the semantics of `-fexperimental-bounds-safety` which has different
Expand Down
7 changes: 5 additions & 2 deletions clang/test/Sema/attr-counted-by-or-null-last-field.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes -verify=expected,late %s

#define __counted_by_or_null(f) __attribute__((counted_by_or_null(f)))

Expand Down Expand Up @@ -82,7 +83,9 @@ struct found_outside_of_struct {

struct self_referrential {
int bork;
struct bar *self[] __counted_by_or_null(self); // expected-error {{use of undeclared identifier 'self'}}
// immediate-error@+2{{use of undeclared identifier 'self'}}
// late-error@+1{{'counted_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
struct bar *self[] __counted_by_or_null(self);
};

struct non_int_count {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// __SVInt8_t is specific to ARM64 so specify that in the target triple
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s

#define __counted_by_or_null(f) __attribute__((counted_by_or_null(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s

#define __counted_by_or_null(f) __attribute__((counted_by_or_null(f)))
#define __counted_by(f) __attribute__((counted_by(f)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// __SVInt8_t is specific to ARM64 so specify that in the target triple
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s

#define __counted_by_or_null(f) __attribute__((counted_by_or_null(f)))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// __SVInt8_t is specific to ARM64 so specify that in the target triple
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s

#define __counted_by(f) __attribute__((counted_by(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-counted-by-struct-ptrs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes %s -verify

#define __counted_by(f) __attribute__((counted_by(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-counted-by-vla-sizeless-types.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// __SVInt8_t is specific to ARM64 so specify that in the target triple
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple arm64-apple-darwin -fexperimental-late-parse-attributes -fsyntax-only -verify %s

#define __counted_by(f) __attribute__((counted_by(f)))

Expand Down
7 changes: 5 additions & 2 deletions clang/test/Sema/attr-counted-by-vla.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes %s -verify=expected,late

#define __counted_by(f) __attribute__((counted_by(f)))

Expand Down Expand Up @@ -80,7 +81,9 @@ struct found_outside_of_struct {

struct self_referrential {
int bork;
struct bar *self[] __counted_by(self); // expected-error {{use of undeclared identifier 'self'}}
// immediate-error@+2{{use of undeclared identifier 'self'}}
// late-error@+1{{'counted_by' requires a non-boolean integer type argument}}
struct bar *self[] __counted_by(self);
};

struct non_int_count {
Expand Down
7 changes: 5 additions & 2 deletions clang/test/Sema/attr-sized-by-last-field.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify=expected,late %s

#define __sized_by(f) __attribute__((sized_by(f)))

Expand Down Expand Up @@ -82,7 +83,9 @@ struct found_outside_of_struct {

struct self_referrential {
int bork;
struct bar *self[] __sized_by(self); // expected-error {{use of undeclared identifier 'self'}}
// immediate-error@+2{{use of undeclared identifier 'self'}}
// late-error@+1{{'sized_by' only applies to pointers; did you mean to use 'counted_by'?}}
struct bar *self[] __sized_by(self);
};

struct non_int_size {
Expand Down
7 changes: 5 additions & 2 deletions clang/test/Sema/attr-sized-by-or-null-last-field.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes -verify=expected,late %s

#define __sized_by_or_null(f) __attribute__((sized_by_or_null(f)))

Expand Down Expand Up @@ -82,7 +83,9 @@ struct found_outside_of_struct {

struct self_referrential {
int bork;
struct bar *self[] __sized_by_or_null(self); // expected-error {{use of undeclared identifier 'self'}}
// immediate-error@+2{{use of undeclared identifier 'self'}}
// late-error@+1{{'sized_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
struct bar *self[] __sized_by_or_null(self);
};

struct non_int_size {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// __SVInt8_t is specific to ARM64 so specify that in the target triple
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s

#define __sized_by_or_null(f) __attribute__((sized_by_or_null(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s

#define __sized_by_or_null(f) __attribute__((sized_by_or_null(f)))
#define __counted_by(f) __attribute__((counted_by(f)))
Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// __SVInt8_t is specific to ARM64 so specify that in the target triple
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s

#define __sized_by_or_null(f) __attribute__((sized_by_or_null(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// __SVInt8_t is specific to ARM64 so specify that in the target triple
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s

#define __sized_by(f) __attribute__((sized_by(f)))

Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-sized-by-struct-ptrs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s

#define __sized_by(f) __attribute__((sized_by(f)))
#define __counted_by(f) __attribute__((counted_by(f)))
Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/attr-sized-by-vla-sizeless-types.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// __SVInt8_t is specific to ARM64 so specify that in the target triple
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s

#define __sized_by(f) __attribute__((sized_by(f)))

Expand Down

0 comments on commit 876ee11

Please sign in to comment.