[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-04-08 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/127116 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-04-08 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/127116 >From b5b9b158e7e379f2d430584e3ccf519677bf27a3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Jan 2025 17:13:30 -0800 Subject: [PATCH 1/6] [Clang][counted_by] Add support for 'counted_by' on struc

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-03-12 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/127116 >From b5b9b158e7e379f2d430584e3ccf519677bf27a3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Jan 2025 17:13:30 -0800 Subject: [PATCH 1/6] [Clang][counted_by] Add support for 'counted_by' on struc

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-03-07 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/127116 >From b5b9b158e7e379f2d430584e3ccf519677bf27a3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Jan 2025 17:13:30 -0800 Subject: [PATCH 1/6] [Clang][counted_by] Add support for 'counted_by' on struc

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-03-05 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/127116 >From b5b9b158e7e379f2d430584e3ccf519677bf27a3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Jan 2025 17:13:30 -0800 Subject: [PATCH 1/6] [Clang][counted_by] Add support for 'counted_by' on struc

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-03-05 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/127116 >From b5b9b158e7e379f2d430584e3ccf519677bf27a3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Jan 2025 17:13:30 -0800 Subject: [PATCH 1/5] [Clang][counted_by] Add support for 'counted_by' on struc

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-02-25 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/127116 >From b5b9b158e7e379f2d430584e3ccf519677bf27a3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Jan 2025 17:13:30 -0800 Subject: [PATCH 1/3] [Clang][counted_by] Add support for 'counted_by' on struc

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-02-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/127116 >From b5b9b158e7e379f2d430584e3ccf519677bf27a3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Jan 2025 17:13:30 -0800 Subject: [PATCH 1/3] [Clang][counted_by] Add support for 'counted_by' on struc

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-02-13 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/127116 >From b5b9b158e7e379f2d430584e3ccf519677bf27a3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 10 Jan 2025 17:13:30 -0800 Subject: [PATCH 1/2] [Clang][counted_by] Add support for 'counted_by' on struc

[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)

2025-02-13 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/127116 The 'counted_by' attribute is now available for structs. It generates code for sanity checks as well as __builtin_dynamic_object_size() calculations. For example: struct annotated_ptr { int count;

[clang] Thread Safety Analysis: Support warning on obtaining address of guarded variables (PR #123063)

2025-02-04 Thread Bill Wendling via cfe-commits
bwendling wrote: Our current `counted_by` implementation is for flexible array members only, which are always at the end of the struct (or supposed to be). When we start applying them to pointers in structs (coming soon), we'll need to use that flag. However, I think that Apple is __finally__

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-02-04 Thread Bill Wendling via cfe-commits
bwendling wrote: This was superseded by https://github.com/llvm/llvm-project/pull/125571. https://github.com/llvm/llvm-project/pull/125298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-02-04 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/125298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted-by] Bail out of visitor for LValueToRValue cast (PR #125571)

2025-02-04 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/125571 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted-by] Bail out of visitor for LValueToRValue cast (PR #125571)

2025-02-03 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/125571 >From f5086e8af7b370aae43bee98493ded9c9f7aa9b2 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 3 Feb 2025 12:15:07 -0800 Subject: [PATCH 1/2] [Clang][counted-by] Bail out of visitor for LValueToRValue

[clang] [Clang][counted-by] Bail out of visitor for LValueToRValue cast (PR #125571)

2025-02-03 Thread Bill Wendling via cfe-commits
bwendling wrote: Those tests are meant to bail out if the MemberExpr is a pointer. That patch may be superseded by this patch? https://github.com/llvm/llvm-project/pull/125571 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.

[clang] [Clang][counted-by] Bail out of visitor for LValueToRValue cast (PR #125571)

2025-02-03 Thread Bill Wendling via cfe-commits
bwendling wrote: This change didn't affect the tests, which is either good or bad, depending on your point of view. I assume that it's okay because we're looking for a `MemberExpr`, and they don't appear to have the LValueToRValue cast, at least for the instances we care about. I'm actively wo

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-02-03 Thread Bill Wendling via cfe-commits
bwendling wrote: @efriedma-quic Created https://github.com/llvm/llvm-project/pull/125571 https://github.com/llvm/llvm-project/pull/125298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

[clang] [Clang][counted-by] Bail out of visitor for LValueToRValue cast (PR #125571)

2025-02-03 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/125571 An LValueToRValue cast shouldn't be ignored, so bail out of the visitor if we encounter one. >From f5086e8af7b370aae43bee98493ded9c9f7aa9b2 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 3 Feb 2025

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-02-03 Thread Bill Wendling via cfe-commits
bwendling wrote: @efriedma-quic Thanks, I'll send a patch. https://github.com/llvm/llvm-project/pull/125298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-02-03 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/125298 >From df6b80c82f1a9ce4f1eef580f008c86fd691ba71 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 31 Jan 2025 12:48:36 -0800 Subject: [PATCH 1/4] [Clang][counted_by] Don't treat a pointer as an array If

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-02-03 Thread Bill Wendling via cfe-commits
@@ -0,0 +1,85 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -DCOUNTED_BY -O2 -Wall -Wno-int-conversion -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-01-31 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/125298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-01-31 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/125298 >From df6b80c82f1a9ce4f1eef580f008c86fd691ba71 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 31 Jan 2025 12:48:36 -0800 Subject: [PATCH 1/3] [Clang][counted_by] Don't treat a pointer as an array If

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-01-31 Thread Bill Wendling via cfe-commits
bwendling wrote: Oops! I forgot to push the testcases :) https://github.com/llvm/llvm-project/pull/125298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-01-31 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/125298 >From df6b80c82f1a9ce4f1eef580f008c86fd691ba71 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 31 Jan 2025 12:48:36 -0800 Subject: [PATCH 1/2] [Clang][counted_by] Don't treat a pointer as an array If

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-01-31 Thread Bill Wendling via cfe-commits
bwendling wrote: I got a testcase from creduce. It's similar to your testcase. Basically, it's indexing into a pointer field, which isn't going to give the correct result either way. I expect that it's indexing into an array instead. https://github.com/llvm/llvm-project/pull/125298 ___

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-01-31 Thread Bill Wendling via cfe-commits
bwendling wrote: Note that the early placement of this code is so that no executable code is generated if we have to bail out. https://github.com/llvm/llvm-project/pull/125298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.

[clang] [Clang][counted_by] Don't treat a __bdos argument as an array if it isn't (PR #125298)

2025-01-31 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/125298 If the __bdos argument isn't an array (e.g. a pointer), due to '-Wno-int-conversion' or some other shenanigans, default to using the llvm.objectsize intrinsic. Fixes: cff0a460ae86 ("[Clang][counted_by] Refacto

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-31 Thread Bill Wendling via cfe-commits
bwendling wrote: I'll look into it. https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-30 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-29 Thread Bill Wendling via cfe-commits
bwendling wrote: Friendly ping for any further comments. https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-27 Thread Bill Wendling via cfe-commits
bwendling wrote: > I still think we may need to triple check how this extension behaves with > count fields that do not get extended AND are negative at runtime (if we > don't already have tests for that), but perhaps is orthogonal to this initial > refactoring. I'll look into test cases with

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-27 Thread Bill Wendling via cfe-commits
bwendling wrote: @nickdesaulniers I understand what you're saying, and it was addressed in the original patch. I do my best to carry the signed-ness of the variables through to the end so that the checks work out (i.e. the checks for negatives aren't removed after optimizations, which they wou

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-27 Thread Bill Wendling via cfe-commits
@@ -1049,236 +1050,362 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-27 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-27 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-27 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,362 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-27 Thread Bill Wendling via cfe-commits
bwendling wrote: Friendly Ping. https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-22 Thread Bill Wendling via cfe-commits
bwendling wrote: Are there anymore comments? https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,348 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,358 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,358 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,355 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,348 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,355 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,355 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,355 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,355 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,236 +1061,355 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/122198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,348 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,348 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,348 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,348 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-14 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,348 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-09 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,331 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-09 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,331 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-09 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,331 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-09 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,331 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-09 Thread Bill Wendling via cfe-commits
@@ -1343,6 +1430,12 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, assert(Ptr->getType()->isPointerTy() && "Non-pointer passed to __builtin_object_size?"); + if (IsDynamic) bwendling wrote: At this point, we know that `Em

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-09 Thread Bill Wendling via cfe-commits
@@ -1060,238 +1061,331 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-08 Thread Bill Wendling via cfe-commits
bwendling wrote: Howdy! This is essentially a complete rewrite of 00b6d032a22196bc14e4e30e413c040eb1b65da4. The original was overly complex and fragile. The main difference with this PR is basing the calculations off of the already emitted `Expr` instead of doing it within this function. It a

[clang] [Clang][CodeGen] Remove extraneous dot prefixes [NFC] (PR #119275)

2024-12-09 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/119275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][CodeGen] Remove extraneous dot prefixes [NFC] (PR #119275)

2024-12-09 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/119275 None >From 7db6b68013c70e0b048171bb11f17bdc703b5bb7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 9 Dec 2024 13:59:02 -0800 Subject: [PATCH] [Clang][CodeGen] Remove extraneous dot prefixes [NFC] --

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-27 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-27 Thread Bill Wendling via cfe-commits
bwendling wrote: Fine. https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-27 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/9] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-26 Thread Bill Wendling via cfe-commits
@@ -14690,6 +14690,13 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) { } } + // The result of __builtin_counted_by_ref cannot be assigned to a variable. + // It allows leaking and modification of bounds safety information. + if (IsBuiltinCountedByRef(VD->getInit())

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-25 Thread Bill Wendling via cfe-commits
bwendling wrote: Ah, okay. Thanks. https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-25 Thread Bill Wendling via cfe-commits
bwendling wrote: Yeah, but I'd like to get this off my plate. :-) https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-25 Thread Bill Wendling via cfe-commits
bwendling wrote: I image @AaronBallman is on vacation this week. @Sirraide would you be willing to LGTM this so that I can move it along? It's certainly better than what we have and I can address any concerns Aaron has afterwards. https://github.com/llvm/llvm-project/pull/116719 __

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/8] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via cfe-commits
bwendling wrote: > I think this might honestly be fine the way it is now Yeah. It's going kind of the opposite way from what you suggested with the placeholder, just instead of allowing for different uses at various places in Sema we disallow without using the placeholder. https://github.com/

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via cfe-commits
@@ -14690,6 +14690,14 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) { } } + // The result of __builtin_counted_by_ref cannot be assigned to a variable. + // It allows leaking and modification of bounds safety information. + if (const auto *CE = dyn_cast_if_present

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/4] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/5] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/6] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/7] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
bwendling wrote: > > Could you point to a place in the code where it creates a placeholder? > > I mean, e.g. `CheckPointerToMemberOperands()` can return `BoundMemberTy` as > the type of a `.*` expression, and `CreateBuiltinMatrixSubscriptExpr()` > creates a `MatrixSubscriptExpr` with type `Inc

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
bwendling wrote: > The main thing I’m concerned about here is that I feel like there ought to be > a better way of doing this than checking for and disallowing it in every > place where we can have a subexpression in C. Yeah, but we don't have such a method, partially due to the languages Clan

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
bwendling wrote: I removed the Placeholder code. It's a much smaller patch and has the better timing profile. PTAL. https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/3] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/2] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
@@ -14690,6 +14690,17 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) { } } + // The result of __builtin_counted_by_ref cannot be assigned to a variable. + // It allows leaking and modification of bounds safety information. + if (const auto *CE = dyn_cast_if_present

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
@@ -755,6 +755,7 @@ static ExprResult BuiltinDumpStruct(Sema &S, CallExpr *TheCall) { case BuiltinType::PseudoObject: case BuiltinType::UnknownAny: case BuiltinType::BuiltinFn: +case BuiltinType::BuiltinCountedByRef: bwendling wrote: Then shou

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
bwendling wrote: > Hmm, I don’t think this is the right way of going about it—copy-pasting the > check across 6 or so different places seems like it’s missing the point of > using a placeholder in the first place. Could you point to a place in the code where it creates a placeholder? I'm unab

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-18 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/116719 Implement the sema checks with a placeholder. We then check for that placeholder in all of the places we care to emit a diagnostic. Fixes: #115520 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 0

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -13,7 +13,10 @@ void init(void * __attribute__((pass_dynamic_object_size(0; // CHECK-LABEL: define dso_local void @_ZN3foo3barC1Ev( // CHECK-SAME: ptr noundef nonnull align 4 dereferenceable(1) [[THIS:%.*]]) unnamed_addr #[[ATTR0:[0-9]+]] align 2 { // CHECK-NEXT: entr

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -16,6 +16,8 @@ void test1(struct fam_struct *ptr, int size, int idx) { *__builtin_counted_by_ref(ptr->array) = size; // ok *__builtin_counted_by_ref(&ptr->array[idx]) = size; // ok + *__builtin_counted_by_ref(&ptr->array) = size;// ok

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -4914,3 +4914,9 @@ def ArithmeticFence : LangBuiltin<"ALL_LANGUAGES"> { let Attributes = [CustomTypeChecking, Constexpr]; let Prototype = "void(...)"; } + +def CountedByRef : Builtin { + let Spellings = ["__builtin_counted_by_ref"]; + let Attributes = [NoThrow, CustomT

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -16,6 +16,8 @@ void test1(struct fam_struct *ptr, int size, int idx) { *__builtin_counted_by_ref(ptr->array) = size; // ok *__builtin_counted_by_ref(&ptr->array[idx]) = size; // ok + *__builtin_counted_by_ref(&ptr->array) = size;// ok

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -0,0 +1,182 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=X86_64 +// RUN: %clang_cc1 -triple i386-unknown-unknown

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
bwendling wrote: -ast-print testcase added. https://github.com/llvm/llvm-project/pull/114495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-01 Thread Bill Wendling via cfe-commits
bwendling wrote: @AaronBallman @rapidsna -- I think I covered all of the comments you made on the other PR (stupid git!). PTAL. https://github.com/llvm/llvm-project/pull/114495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-10-31 Thread Bill Wendling via cfe-commits
bwendling wrote: This is a new PR, because GitHub messed up. Here's the original: https://github.com/llvm/llvm-project/pull/102549 https://github.com/llvm/llvm-project/pull/114495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.l

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Bill Wendling via cfe-commits
@@ -197,6 +197,18 @@ static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) { if (!Op.mayHaveIntegerOverflow()) return true; + if (Op.Ty->isSignedIntegerType() && bwendling wrote: Does this (and the following if-then) need a com

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-25 Thread Bill Wendling via cfe-commits
bwendling wrote: I think the calculation in https://github.com/llvm/llvm-project/pull/112636#issuecomment-2436559387 is correct. It's probably worthwhile to perform some analysis to see if using that to calculate the new size results in allocation size changes in the kernel. If not, then perh

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-17 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/112636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

  1   2   3   4   5   6   7   >