[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-24 Thread Dan Liew via cfe-commits
@@ -8641,22 +8641,33 @@ enum class CountedByInvalidPointeeTypeKind { VALID, }; -static bool CheckCountedByAttrOnField( -Sema , FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl ) { +static bool +CheckCountedByAttrOnField(Sema , FieldDecl *FD, Expr *E, +

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-24 Thread Dan Liew via cfe-commits
@@ -8641,22 +8641,33 @@ enum class CountedByInvalidPointeeTypeKind { VALID, }; -static bool CheckCountedByAttrOnField( -Sema , FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl ) { +static bool +CheckCountedByAttrOnField(Sema , FieldDecl *FD, Expr *E, +

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -8697,9 +8708,10 @@ static bool CheckCountedByAttrOnField( InvalidTypeKind = CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER; } - if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID) { + if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -425,6 +425,12 @@ Attribute Changes in Clang size_t count; }; +- The attributes ``sized_by``, ``counted_by_or_null`` and ``sized_by_or_null``` + have been added as variants on ``counted_by``, each with slightly different semantics. + ``sized_by`` takes a

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -8641,22 +8641,33 @@ enum class CountedByInvalidPointeeTypeKind { VALID, }; -static bool CheckCountedByAttrOnField( -Sema , FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl ) { +static bool +CheckCountedByAttrOnField(Sema , FieldDecl *FD, Expr *E, +

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/93231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -8641,22 +8641,33 @@ enum class CountedByInvalidPointeeTypeKind { VALID, }; -static bool CheckCountedByAttrOnField( -Sema , FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl ) { +static bool +CheckCountedByAttrOnField(Sema , FieldDecl *FD, Expr *E, +

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -8641,22 +8641,33 @@ enum class CountedByInvalidPointeeTypeKind { VALID, }; -static bool CheckCountedByAttrOnField( -Sema , FieldDecl *FD, Expr *E, -llvm::SmallVectorImpl ) { +static bool +CheckCountedByAttrOnField(Sema , FieldDecl *FD, Expr *E, +

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher requested changes to this pull request. Looks pretty good. I have some minor comments. https://github.com/llvm/llvm-project/pull/93231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)

2024-05-23 Thread Dan Liew via cfe-commits
delcypher wrote: @hnrklssn #93121 has been landed. Let's hope it sticks this time 爛 https://github.com/llvm/llvm-project/pull/93231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed https://github.com/llvm/llvm-project/pull/93121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/93121 >From c1f0914b1f8ae8416cebdf7f0573b4ff11f6110d Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 17 May 2024 12:07:40 -0700 Subject: [PATCH] [BoundsSafety] Reland #93121 Allow 'counted_by' attribute on

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
delcypher wrote: Filed to #93263 to track the potential refactor. https://github.com/llvm/llvm-project/pull/93121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/93121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/93121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/93121 >From 9e1a9e49b33d4b77d75cee243244dd66a40ea209 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 17 May 2024 12:07:40 -0700 Subject: [PATCH] [BoundsSafety] Reland #93121 Allow 'counted_by' attribute on

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/93121 >From f9c8abdb243096b6fe0c2ad1a42023039ca7f1f2 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 17 May 2024 12:07:40 -0700 Subject: [PATCH] [BoundsSafety] Reland #93121 Allow 'counted_by' attribute on

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/93121 >From bc5b8bc34b50e2e98d2c6103c7b1c232a3e765b4 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 17 May 2024 12:07:40 -0700 Subject: [PATCH] [BoundsSafety] Reland #93121 Allow 'counted_by' attribute on

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -4944,6 +4944,26 @@ void Parser::ParseStructDeclaration( } } +// TODO: All callers of this function should be moved to +// `Parser::ParseLexedAttributeList`. +void Parser::ParseLexedCAttributeList(LateParsedAttrList , bool EnterScope, +

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -4944,6 +4944,26 @@ void Parser::ParseStructDeclaration( } } +// TODO: All callers of this function should be moved to +// `Parser::ParseLexedAttributeList`. +void Parser::ParseLexedCAttributeList(LateParsedAttrList , bool EnterScope, +

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -4944,6 +4944,26 @@ void Parser::ParseStructDeclaration( } } +// TODO: All callers of this function should be moved to +// `Parser::ParseLexedAttributeList`. +void Parser::ParseLexedCAttributeList(LateParsedAttrList , bool EnterScope, +

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -4944,6 +4944,26 @@ void Parser::ParseStructDeclaration( } } +// TODO: All callers of this function should be moved to +// `Parser::ParseLexedAttributeList`. +void Parser::ParseLexedCAttributeList(LateParsedAttrList , bool EnterScope, +

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/93121 >From 7f5af7cc180825e07b5f5292e3f6b860c8e8591e Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 17 May 2024 12:07:40 -0700 Subject: [PATCH 1/7] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
delcypher wrote: Hmm looks like I'll have to tweak the assert. Looks like some unit tests don't specify the language. ``` FAIL: Clang-Unit :: CodeGen/./ClangCodeGenTests/5/16 (19428 of 19653) TEST 'Clang-Unit :: CodeGen/./ClangCodeGenTests/5/16' FAILED

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
@@ -4993,20 +4993,8 @@ void Parser::ParseLexedCAttribute(LateParsedAttribute , "late field attribute expects to have at most one declaration."); // Dispatch based on the attribute and parse it - const AttributeCommonInfo::Form ParsedForm =

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/93121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/93121 >From 7f5af7cc180825e07b5f5292e3f6b860c8e8591e Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 17 May 2024 12:07:40 -0700 Subject: [PATCH 1/7] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/93121 >From 7f5af7cc180825e07b5f5292e3f6b860c8e8591e Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 17 May 2024 12:07:40 -0700 Subject: [PATCH 1/6] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-23 Thread Dan Liew via cfe-commits
delcypher wrote: Okay this is interesting... ``` FAIL: Clang :: SemaObjC/warn-thread-safety-analysis.m (15515 of 19369) TEST 'Clang :: SemaObjC/warn-thread-safety-analysis.m' FAILED Exit Code: 134 Command Output (stderr): -- RUN:

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-22 Thread Dan Liew via cfe-commits
delcypher wrote: Hmm looks like I broke ``` Clang :: Sema/attr-capabilities.c Clang :: Sema/diagnose_if.c Clang :: Sema/warn-thread-safety-analysis.c Clang :: SemaObjC/warn-thread-safety-analysis.m ``` Let's see if I can figure out what I did...

[clang] [BoundsSafety] Add `-fexperimental-bounds-safety` CC1 and language option and use it to tweak `counted_by`'s semantics (PR #92623)

2024-05-22 Thread Dan Liew via cfe-commits
delcypher wrote: This is blocked by #93121 https://github.com/llvm/llvm-project/pull/92623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-22 Thread Dan Liew via cfe-commits
delcypher wrote: @rapidsna Please check 604e274a5bc37b18c3bc89eed5749c8617de36e7 to check you are happy with the way I'm fixing the memory leak. https://github.com/llvm/llvm-project/pull/93121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-22 Thread Dan Liew via cfe-commits
@@ -744,7 +744,13 @@ void Parser::ParseLexedAttributeList(LateParsedAttrList , Decl *D, for (unsigned i = 0, ni = LAs.size(); i < ni; ++i) { if (D) LAs[i]->addDecl(D); -ParseLexedAttribute(*LAs[i], EnterScope, OnDefinition); +// FIXME: There has to be a

[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

2024-05-22 Thread Dan Liew via cfe-commits
https://github.com/delcypher created https://github.com/llvm/llvm-project/pull/93121 This PR attempts to reland https://github.com/llvm/llvm-project/pull/90786 that was reverted due to a memory leak. This PR includes the following commits 1. The original commit in #90786 (originally

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-05-20 Thread Dan Liew via cfe-commits
delcypher wrote: @erichkeane I posted the comment on the wrong PR. The memory leak is in #90786 not this PR so I deleted the comment i made here. #90786 has already been reverted. https://github.com/llvm/llvm-project/pull/88596 ___ cfe-commits

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-20 Thread Dan Liew via cfe-commits
delcypher wrote: I'll put up a new version of this PR with the memory leak fixed soon. https://github.com/llvm/llvm-project/pull/90786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-18 Thread Dan Liew via cfe-commits
delcypher wrote: Ok. Now I see what's happening. These lines here are basically giving ownership of `LateParsedAttribute` to the `LateParsedAttrList` ``` // Handle attributes with arguments that require late parsing. LateParsedAttribute *LA = new

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: The leak via `clang::Parser::ParseLexedCAttribute` is ```c++ LA.Toks.push_back(AttrEnd); ``` and the leak via `clang::Parser::ParseGNUAttributes` is ``` LateParsedAttribute *LA = new LateParsedAttribute(this, *AttrName, AttrNameLoc); ``` which is really

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: Hmm. Apparently there's a memory leak. https://lab.llvm.org/buildbot/#/builders/239/builds/7043 ``` -- Testing: 79948 of 79949 tests, 48 workers -- Testing: FAIL: Clang :: AST/attr-counted-by-late-parsed-struct-ptrs.c (480 of 79948) TEST 'Clang ::

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: Hmm. Apparently there's a memory leak. https://lab.llvm.org/buildbot/#/builders/239/builds/7043 ``` -- Testing: 79948 of 79949 tests, 48 workers -- Testing: FAIL: Clang :: AST/attr-counted-by-late-parsed-struct-ptrs.c (480 of 79948) TEST 'Clang ::

[clang] [BoundsSafety] Add `-fexperimental-bounds-safety` CC1 and language option and use it to tweak `counted_by`'s semantics (PR #92623)

2024-05-17 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/92623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety] Add `-fexperimental-bounds-safety` CC1 and language option and use it to tweak `counted_by`'s semantics (PR #92623)

2024-05-17 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/92623 >From ef46dd51c5c54cf5a76d83b9c15f8f3aee052e42 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 17 May 2024 17:15:48 -0700 Subject: [PATCH] [BoundsSafety] Add `-fexperimental-bounds-safety` CC1 and language

[clang] [BoundsSafety] Add `-fexperimental-bounds-safety` CC1 and language option and use it to tweak `counted_by`'s semantics (PR #92623)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: This is based on #70480 but removes the driver part of the change and makes the flag a CC1 flag only. https://github.com/llvm/llvm-project/pull/92623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [BoundsSafety] Add `-fexperimental-bounds-safety` CC1 and language option and use it to tweak `counted_by`'s semantics (PR #92623)

2024-05-17 Thread Dan Liew via cfe-commits
https://github.com/delcypher created https://github.com/llvm/llvm-project/pull/92623 This adds the `-fexperimental-bounds-safety` cc1 and corresponding language option. This language option enables "-fbounds-safety" which is a bounds-safety extension for C that is being incrementally

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: @kees @bwendling @rapidsna The workaround to downgrade this error to a warning has landed https://github.com/llvm/llvm-project/commit/cef6387e52578366c2332275dad88b9953b55336 https://github.com/llvm/llvm-project/pull/90786 ___

[clang] cef6387 - [Bounds-Safety] Temporarily relax a `counted_by` attribute restriction on flexible array members

2024-05-17 Thread Dan Liew via cfe-commits
Author: Dan Liew Date: 2024-05-17T16:23:24-07:00 New Revision: cef6387e52578366c2332275dad88b9953b55336 URL: https://github.com/llvm/llvm-project/commit/cef6387e52578366c2332275dad88b9953b55336 DIFF: https://github.com/llvm/llvm-project/commit/cef6387e52578366c2332275dad88b9953b55336.diff

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: @bwendling This is unfortunate ``` drivers/gpu/drm/radeon/pptable.h:442:5: error: 'counted_by' cannot be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member 442 |

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: Test fixed by `112eadd55f06bee15caadff688ea0b45acbfa804`. https://github.com/llvm/llvm-project/pull/90786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] 112eadd - [Bounds-Safety] Fix `pragma-attribute-supported-attributes-list.test`

2024-05-17 Thread Dan Liew via cfe-commits
Author: Dan Liew Date: 2024-05-17T13:09:22-07:00 New Revision: 112eadd55f06bee15caadff688ea0b45acbfa804 URL: https://github.com/llvm/llvm-project/commit/112eadd55f06bee15caadff688ea0b45acbfa804 DIFF: https://github.com/llvm/llvm-project/commit/112eadd55f06bee15caadff688ea0b45acbfa804.diff

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: Looks like I broke the `clang/test/Misc/pragma-attribute-supported-attributes-list.test` test. I'll push a follow up fix to that test once I've confirmed I've fixed it. https://github.com/llvm/llvm-project/pull/90786 ___ cfe-commits

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed https://github.com/llvm/llvm-project/pull/90786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/90786 >From 80dbab4c4b43eb78f29b7b8fa577f04772a7f52c Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 1 May 2024 13:56:52 -0700 Subject: [PATCH] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-17 Thread Dan Liew via cfe-commits
delcypher wrote: @kees Thanks for approving. I'm going to resolve the merge conflict in `clang/docs/ReleaseNotes.rst` and then merge. I'll start looking at supporting `__counted_by()` on incomplete pointee types next. @hnrklssn is going to start working on upstreaming the `__sized_by`

[clang] [Bounds-Safety] Reserve slot in SanitizerHandler enum for Bounds-Safety (PR #91032)

2024-05-16 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed https://github.com/llvm/llvm-project/pull/91032 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-15 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/90786 >From e6fb7a3374ada3d02b4c89263ffd14a037a7e56a Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 1 May 2024 13:56:52 -0700 Subject: [PATCH] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-14 Thread Dan Liew via cfe-commits
delcypher wrote: @bwendling @kees Any further feedback? If not, can you approve? As @rapidsna said we'll follow up this PR with additional PRs to address the two major concerns you had. https://github.com/llvm/llvm-project/pull/90786 ___ cfe-commits

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-14 Thread Dan Liew via cfe-commits
@@ -0,0 +1,187 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +#define __counted_by(f) __attribute__((counted_by(f))) + +struct bar; + +struct not_found { + int count; + struct bar *fam[] __counted_by(bork); // expected-error {{use of undeclared identifier 'bork'}} +}; +

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-14 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/90786 >From 1f4d924768409d6bc61d160c6161e6acebf62b60 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 1 May 2024 13:56:52 -0700 Subject: [PATCH 1/4] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-10 Thread Dan Liew via cfe-commits
delcypher wrote: > It's not a lie, because the contents of a pointer don't contribute to the > size of the struct containing that pointer. Consider this example. It tries to illustrate why putting `__counted_by()` on a pointer to a structs containing flexible array members doesn't make sense.

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-10 Thread Dan Liew via cfe-commits
delcypher wrote: > @rapidsna @delcypher @apple-fcloutier @kees: > > Okay, I think I see what the complication is. Are you trying to prevent the > use case of someone writing something like: > > ```c > struct bar; > > struct foo { > size_t count; > struct bar *ptr __counted_by(count); >

[clang] [Bounds-Safety] Reserve slot in SanitizerHandler enum for Bounds-Safety (PR #91032)

2024-05-10 Thread Dan Liew via cfe-commits
delcypher wrote: @vitalybuka Ping https://github.com/llvm/llvm-project/pull/91032 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add support for builtin_verbose_trap (PR #79230)

2024-05-10 Thread Dan Liew via cfe-commits
@@ -172,6 +172,27 @@ static bool checkArgCount(Sema , CallExpr *Call, unsigned DesiredArgCount) { << /*is non object*/ 0 << Call->getArg(1)->getSourceRange(); } +static bool checkBuiltinVerboseTrap(CallExpr *Call, Sema ) { delcypher wrote:

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-09 Thread Dan Liew via cfe-commits
delcypher wrote: @bwendling > I've been thinking about this restriction. Why is this necessary? My > assumption was that applying counted_by to a pointer causes a bounds check on > an index into the pointer rather than its underlying type. @rapidsna Please add additional points if I

[clang] [Bounds-Safety] Reserve slot in SanitizerHandler enum for Bounds-Safety (PR #91032)

2024-05-03 Thread Dan Liew via cfe-commits
https://github.com/delcypher created https://github.com/llvm/llvm-project/pull/91032 Due to how `CodeGenFunction::EmitTrapCheck` is implemented `SanitizerHandler` with numeric value 0x19 needs to be reserved because `-fbounds-safety` generates trap instructions with that value embedded in the

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-03 Thread Dan Liew via cfe-commits
@@ -335,6 +336,22 @@ Attribute Changes in Clang - Clang now warns that the ``exclude_from_explicit_instantiation`` attribute is ignored when applied to a local class or a member thereof. +- The ``counted_by`` attribute can now be late parsed in C when

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-03 Thread Dan Liew via cfe-commits
@@ -6534,6 +6536,15 @@ def err_counted_by_attr_refer_to_union : Error< "'counted_by' argument cannot refer to a union member">; def note_flexible_array_counted_by_attr_field : Note< "field %0 declared here">; +def err_counted_by_attr_pointee_unknown_size : Error< +

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-03 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/90786 >From 1f4d924768409d6bc61d160c6161e6acebf62b60 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 1 May 2024 13:56:52 -0700 Subject: [PATCH 1/3] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-03 Thread Dan Liew via cfe-commits
@@ -631,6 +631,18 @@ bool Type::isStructureType() const { return false; } +bool Type::isStructureTypeWithFlexibleArrayMember() const { + const auto *RT = getAs(); + if (!RT) +return false; + const auto *Decl = RT->getDecl(); + if (!Decl->isStruct()) +return

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-03 Thread Dan Liew via cfe-commits
@@ -6534,6 +6536,15 @@ def err_counted_by_attr_refer_to_union : Error< "'counted_by' argument cannot refer to a union member">; def note_flexible_array_counted_by_attr_field : Note< "field %0 declared here">; +def err_counted_by_attr_pointee_unknown_size : Error< +

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-03 Thread Dan Liew via cfe-commits
@@ -335,6 +336,22 @@ Attribute Changes in Clang - Clang now warns that the ``exclude_from_explicit_instantiation`` attribute is ignored when applied to a local class or a member thereof. +- The ``counted_by`` attribute can now be late parsed in C when

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-03 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/90786 >From 1f4d924768409d6bc61d160c6161e6acebf62b60 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 1 May 2024 13:56:52 -0700 Subject: [PATCH 1/2] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-03 Thread Dan Liew via cfe-commits
@@ -8588,31 +8588,71 @@ static const RecordDecl *GetEnclosingNamedOrTopAnonRecord(const FieldDecl *FD) { return RD; } -static bool -CheckCountExpr(Sema , FieldDecl *FD, Expr *E, - llvm::SmallVectorImpl ) { +enum class CountedByInvalidPointeeTypeKind { +

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-05-01 Thread Dan Liew via cfe-commits
delcypher wrote: @rapidsna You may want to close this PR but I'll leave this up to you. https://github.com/llvm/llvm-project/pull/87596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-05-01 Thread Dan Liew via cfe-commits
delcypher wrote: @rapidsna I've put my version of this PR in my own pull request because when I edit the PR summary here it looks like you wrote it which is weird: https://github.com/llvm/llvm-project/pull/90786 https://github.com/llvm/llvm-project/pull/87596

[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)

2024-05-01 Thread Dan Liew via cfe-commits
https://github.com/delcypher created https://github.com/llvm/llvm-project/pull/90786 Previously the attribute was only allowed on flexible array members. This patch patch changes this to also allow the attribute on pointer fields in structs and also allows late parsing of the attribute in

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-05-01 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/87596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-05-01 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/87596 >From a89cca7fecae5ef5130cd9c8da834a186e99dbb5 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 1 May 2024 13:56:52 -0700 Subject: [PATCH] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-05-01 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/87596 >From 50e628d2d6fb496c1cb2fa188b653529508e383c Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 1 May 2024 13:56:52 -0700 Subject: [PATCH] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-05-01 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/87596 >From 4e6130ea07e655081df3f2ca9c89fd1be035a68d Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 1 May 2024 13:56:52 -0700 Subject: [PATCH] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-04-30 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/87596 >From 03266b74d973075eb5dfa27f32bb9c1bb75d73f9 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 29 Apr 2024 16:46:31 -0700 Subject: [PATCH 1/4] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-04-30 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/87596 >From 03266b74d973075eb5dfa27f32bb9c1bb75d73f9 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 29 Apr 2024 16:46:31 -0700 Subject: [PATCH 1/4] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-04-29 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/87596 >From 03266b74d973075eb5dfa27f32bb9c1bb75d73f9 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 29 Apr 2024 16:46:31 -0700 Subject: [PATCH 1/3] [BoundsSafety] Allow 'counted_by' attribute on pointers in

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-29 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed https://github.com/llvm/llvm-project/pull/88596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-29 Thread Dan Liew via cfe-commits
delcypher wrote: @erichkeane Thanks for approving. I'll rebase, check this builds and then land this. @AaronBallman When you're back please let me know if there's any follow up changes you want. https://github.com/llvm/llvm-project/pull/88596 ___

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-29 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/88596 >From 07ab74ac8829e6c3e4365e1a87148d21800437d3 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 23 Apr 2024 14:57:46 -0700 Subject: [PATCH] [Attributes] Support Attributes being declared as supporting an

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-04-29 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/87596 >From b859cf056df24daa85f3fd305ef56f32e0f266ed Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 12 Apr 2024 17:36:19 -0700 Subject: [PATCH 1/4] [Attributes] Support Attributes being declared as supporting

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-29 Thread Dan Liew via cfe-commits
delcypher wrote: @AaronBallman @erichkeane Ping. Is this ready to land? https://github.com/llvm/llvm-project/pull/88596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add support for builtin_verbose_trap (PR #79230)

2024-04-27 Thread Dan Liew via cfe-commits
@@ -27,6 +27,9 @@ namespace llvm { } } +// Prefix for __builtin_verbose_trap. +#define CLANG_VERBOSE_TRAP_PREFIX "__llvm_verbose_trap" delcypher wrote: @ahatanak Nit: Why does the macro name mention `CLANG` but the string mentions `llvm` instead of Clang?

[clang] Add support for builtin_verbose_trap (PR #79230)

2024-04-27 Thread Dan Liew via cfe-commits
@@ -27,6 +27,9 @@ namespace llvm { } } +// Prefix for __builtin_verbose_trap. delcypher wrote: @ahatanak Does this comment need updating? The prefix isn’t just for __builtin_verbose_trap anymore. https://github.com/llvm/llvm-project/pull/79230

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-23 Thread Dan Liew via cfe-commits
@@ -214,6 +214,10 @@ New Compiler Flags This diagnostic can be disabled to make ``-Wmissing-field-initializers`` behave like it did before Clang 18.x. Fixes (`#56628 `_) +- ``-fexperimental-late-parse-attributes``

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-23 Thread Dan Liew via cfe-commits
@@ -1822,28 +1822,100 @@ void WriteSemanticSpellingSwitch(const std::string , OS << " }\n"; } +enum class LateAttrParseKind { Never = 0, Standard = 1, ExperimentalExt = 2 }; + +static LateAttrParseKind getLateAttrParseKind(const Record *Attr) { + // This function

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/88596 >From a6d390cc4f109ee0a19779ba11b33f2caf8904c3 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 23 Apr 2024 14:57:46 -0700 Subject: [PATCH] [Attributes] Support Attributes being declared as supporting an

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-23 Thread Dan Liew via cfe-commits
@@ -592,6 +592,48 @@ class AttrSubjectMatcherAggregateRule { def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule; +// Late Attribute parsing mode enum +class LateAttrParseKind { + int Kind = val; +} + +// Never late parsed +def LateAttrParseNever :

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-23 Thread Dan Liew via cfe-commits
delcypher wrote: @AaronBallman Thanks for the feedback > We should probably add a release note to tell users about the new command > line option, unless you think it makes more sense to do so after something > uses `LateAttrParseExperimentalExt`? I had a think about it and I'll add a release

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-04-22 Thread Dan Liew via cfe-commits
delcypher wrote: @rapidsna I've addressed the "Make it an error to use 'counted_by' on size-less types (e.g., forward declared structs)" TODO. I still need to test this PR properly and write a proper commit message explaining what this does. https://github.com/llvm/llvm-project/pull/87596

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-04-22 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/87596 >From b859cf056df24daa85f3fd305ef56f32e0f266ed Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 12 Apr 2024 17:36:19 -0700 Subject: [PATCH 1/2] [Attributes] Support Attributes being declared as supporting

[clang] [BoundsSafety] WIP: Make 'counted_by' work for pointer fields; late parsing for 'counted_by' on decl attr position (PR #87596)

2024-04-19 Thread Dan Liew via cfe-commits
delcypher wrote: The implementation of the experimental late attribute changed (#88596) so I've rebased this PR on it and fixed it up to work as intended. https://github.com/llvm/llvm-project/pull/87596 ___ cfe-commits mailing list

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-19 Thread Dan Liew via cfe-commits
delcypher wrote: @rapidsna I've re-implemented this patch with the new semantics that we discussed offline. I have also reworked #87596 to use this new implementation. https://github.com/llvm/llvm-project/pull/88596 ___ cfe-commits mailing list

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-19 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/88596 >From b859cf056df24daa85f3fd305ef56f32e0f266ed Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 12 Apr 2024 17:36:19 -0700 Subject: [PATCH] [Attributes] Support Attributes being declared as supporting an

[clang] [Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (PR #88596)

2024-04-19 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/88596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

  1   2   3   >