Author: Dan Liew Date: 2024-08-08T09:57:47-07:00 New Revision: 876ee11eeeb2b6a7ccfefea00265b4bfd5f9b6dd
URL: https://github.com/llvm/llvm-project/commit/876ee11eeeb2b6a7ccfefea00265b4bfd5f9b6dd DIFF: https://github.com/llvm/llvm-project/commit/876ee11eeeb2b6a7ccfefea00265b4bfd5f9b6dd.diff LOG: [Bounds Safety][NFC] Add some missing coverage for `-fexperimental-late-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 Added: Modified: clang/test/AST/attr-counted-by-or-null-struct-ptrs.c clang/test/AST/attr-counted-by-struct-ptrs.c clang/test/AST/attr-sized-by-or-null-struct-ptrs.c clang/test/AST/attr-sized-by-struct-ptrs.c clang/test/Sema/attr-counted-by-bounds-safety-vlas.c clang/test/Sema/attr-counted-by-or-null-last-field.c clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c clang/test/Sema/attr-counted-by-struct-ptrs.c clang/test/Sema/attr-counted-by-vla-sizeless-types.c clang/test/Sema/attr-counted-by-vla.c clang/test/Sema/attr-sized-by-last-field.c clang/test/Sema/attr-sized-by-or-null-last-field.c clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c clang/test/Sema/attr-sized-by-struct-ptrs.c clang/test/Sema/attr-sized-by-vla-sizeless-types.c Removed: ################################################################################ diff --git a/clang/test/AST/attr-counted-by-or-null-struct-ptrs.c b/clang/test/AST/attr-counted-by-or-null-struct-ptrs.c index cedb3f1192eda..075f583784fe1 100644 --- a/clang/test/AST/attr-counted-by-or-null-struct-ptrs.c +++ b/clang/test/AST/attr-counted-by-or-null-struct-ptrs.c @@ -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))) diff --git a/clang/test/AST/attr-counted-by-struct-ptrs.c b/clang/test/AST/attr-counted-by-struct-ptrs.c index 79a453d239cd5..0c05258234143 100644 --- a/clang/test/AST/attr-counted-by-struct-ptrs.c +++ b/clang/test/AST/attr-counted-by-struct-ptrs.c @@ -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))) diff --git a/clang/test/AST/attr-sized-by-or-null-struct-ptrs.c b/clang/test/AST/attr-sized-by-or-null-struct-ptrs.c index 6189799b85ccb..73b8a71f23503 100644 --- a/clang/test/AST/attr-sized-by-or-null-struct-ptrs.c +++ b/clang/test/AST/attr-sized-by-or-null-struct-ptrs.c @@ -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))) diff --git a/clang/test/AST/attr-sized-by-struct-ptrs.c b/clang/test/AST/attr-sized-by-struct-ptrs.c index 5d9ed0094c685..7f7e3dfea2ac7 100644 --- a/clang/test/AST/attr-sized-by-struct-ptrs.c +++ b/clang/test/AST/attr-sized-by-struct-ptrs.c @@ -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))) diff --git a/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c b/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c index 7d9c9a90880ff..5a739f9c6bc04 100644 --- a/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c +++ b/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c @@ -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 diff erent diff --git a/clang/test/Sema/attr-counted-by-or-null-last-field.c b/clang/test/Sema/attr-counted-by-or-null-last-field.c index dd3a6422521c0..12c0b6de44f72 100644 --- a/clang/test/Sema/attr-counted-by-or-null-last-field.c +++ b/clang/test/Sema/attr-counted-by-or-null-last-field.c @@ -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))) @@ -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 { diff --git a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c index 301977300b06a..4b898e7369c19 100644 --- a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c +++ b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c @@ -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))) diff --git a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c index 017aafe0c9396..708bb727ce09d 100644 --- a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c +++ b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c @@ -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))) diff --git a/clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c b/clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c index 8abd4476fe597..1e8c7179e7903 100644 --- a/clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c +++ b/clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c @@ -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))) diff --git a/clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c b/clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c index 9b0f2eafb13c2..1de93640cf458 100644 --- a/clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c +++ b/clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c @@ -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))) diff --git a/clang/test/Sema/attr-counted-by-struct-ptrs.c b/clang/test/Sema/attr-counted-by-struct-ptrs.c index cd2bfe36938b2..321d6aafbeba2 100644 --- a/clang/test/Sema/attr-counted-by-struct-ptrs.c +++ b/clang/test/Sema/attr-counted-by-struct-ptrs.c @@ -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))) diff --git a/clang/test/Sema/attr-counted-by-vla-sizeless-types.c b/clang/test/Sema/attr-counted-by-vla-sizeless-types.c index 31c0007501c48..8cc5f64482548 100644 --- a/clang/test/Sema/attr-counted-by-vla-sizeless-types.c +++ b/clang/test/Sema/attr-counted-by-vla-sizeless-types.c @@ -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))) diff --git a/clang/test/Sema/attr-counted-by-vla.c b/clang/test/Sema/attr-counted-by-vla.c index 571d6e6291e6b..35737c03f3222 100644 --- a/clang/test/Sema/attr-counted-by-vla.c +++ b/clang/test/Sema/attr-counted-by-vla.c @@ -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))) @@ -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 { diff --git a/clang/test/Sema/attr-sized-by-last-field.c b/clang/test/Sema/attr-sized-by-last-field.c index 6af29e9f31435..f2e74f7fdf4b5 100644 --- a/clang/test/Sema/attr-sized-by-last-field.c +++ b/clang/test/Sema/attr-sized-by-last-field.c @@ -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))) @@ -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 { diff --git a/clang/test/Sema/attr-sized-by-or-null-last-field.c b/clang/test/Sema/attr-sized-by-or-null-last-field.c index 96bbe847b910b..08ef5263a05cf 100644 --- a/clang/test/Sema/attr-sized-by-or-null-last-field.c +++ b/clang/test/Sema/attr-sized-by-or-null-last-field.c @@ -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))) @@ -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 { diff --git a/clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c b/clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c index 4a360b9722a0b..d960c0d31b65c 100644 --- a/clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c +++ b/clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c @@ -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))) diff --git a/clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c b/clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c index 2c7578b5ecbe6..4200c9275a180 100644 --- a/clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c +++ b/clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c @@ -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))) diff --git a/clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c b/clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c index 398b1df592fe3..7d16c2d456a02 100644 --- a/clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c +++ b/clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c @@ -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))) diff --git a/clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c b/clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c index 2e916bdb04720..7038330e60eee 100644 --- a/clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c +++ b/clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c @@ -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))) diff --git a/clang/test/Sema/attr-sized-by-struct-ptrs.c b/clang/test/Sema/attr-sized-by-struct-ptrs.c index 01195469c6fe4..07373b247d0f7 100644 --- a/clang/test/Sema/attr-sized-by-struct-ptrs.c +++ b/clang/test/Sema/attr-sized-by-struct-ptrs.c @@ -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))) diff --git a/clang/test/Sema/attr-sized-by-vla-sizeless-types.c b/clang/test/Sema/attr-sized-by-vla-sizeless-types.c index 37e91639bb4a1..8a94b1217c906 100644 --- a/clang/test/Sema/attr-sized-by-vla-sizeless-types.c +++ b/clang/test/Sema/attr-sized-by-vla-sizeless-types.c @@ -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))) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits