[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-16 Thread Dana Jansens via cfe-commits
https://github.com/danakj closed https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-15 Thread Artem Dergachev via cfe-commits
@@ -1315,9 +1374,9 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { virtual std::optional getFixits(const FixitStrategy ) const final; - - // TODO remove this method from FixableGadget interface haoNoQ wrote: Right!

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-15 Thread Dana Jansens via cfe-commits
@@ -1315,9 +1374,9 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { virtual std::optional getFixits(const FixitStrategy ) const final; - - // TODO remove this method from FixableGadget interface danakj wrote: Also it's slightly

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-15 Thread Dana Jansens via cfe-commits
https://github.com/danakj updated https://github.com/llvm/llvm-project/pull/91777 >From 8b318dadac6d0ec53b5d26461edfe19a391845ec Mon Sep 17 00:00:00 2001 From: danakj Date: Fri, 10 May 2024 13:31:17 -0400 Subject: [PATCH 1/4] Respect the [[clang::unsafe_buffer_usage]] attribute for

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-15 Thread Dana Jansens via cfe-commits
https://github.com/danakj updated https://github.com/llvm/llvm-project/pull/91777 >From 8b318dadac6d0ec53b5d26461edfe19a391845ec Mon Sep 17 00:00:00 2001 From: danakj Date: Fri, 10 May 2024 13:31:17 -0400 Subject: [PATCH 1/4] Respect the [[clang::unsafe_buffer_usage]] attribute for

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-15 Thread Dana Jansens via cfe-commits
@@ -2856,7 +2916,7 @@ getFixIts(FixableGadgetSets , const FixitStrategy , } #ifndef NDEBUG Handler.addDebugNoteForVar( - VD, F->getBaseStmt()->getBeginLoc(), + VD, F->getSourceLoc(), danakj wrote: I will leave this for a

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-15 Thread Dana Jansens via cfe-commits
@@ -1315,9 +1374,9 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { virtual std::optional getFixits(const FixitStrategy ) const final; - - // TODO remove this method from FixableGadget interface danakj wrote: This one used to return

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -2856,7 +2916,7 @@ getFixIts(FixableGadgetSets , const FixitStrategy , } #ifndef NDEBUG Handler.addDebugNoteForVar( - VD, F->getBaseStmt()->getBeginLoc(), + VD, F->getSourceLoc(), haoNoQ wrote: Hmm right, this is literally

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -1315,9 +1374,9 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { virtual std::optional getFixits(const FixitStrategy ) const final; - - // TODO remove this method from FixableGadget interface haoNoQ wrote: Still relevant tbh.

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Aha ok everything makes sense now! I think this is good to go so LGTM! Let me see the other PR too. https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Dana Jansens via cfe-commits
@@ -921,10 +937,55 @@ class UnsafeBufferUsageAttrGadget : public WarningGadget { } static Matcher matcher() { -return stmt(callExpr(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage -.bind(OpTag)); +auto HasUnsafeFnDecl = +

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Dana Jansens via cfe-commits
@@ -2856,7 +2916,7 @@ getFixIts(FixableGadgetSets , const FixitStrategy , } #ifndef NDEBUG Handler.addDebugNoteForVar( - VD, F->getBaseStmt()->getBeginLoc(), + VD, F->getSourceLoc(), danakj wrote: Yeah, this is the only callsite

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Dana Jansens via cfe-commits
@@ -2295,6 +2292,23 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { } } + void handleUnsafeOperationInContainer(const Stmt *Operation, +bool IsRelatedToDecl, +

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Dana Jansens via cfe-commits
danakj wrote: > > https://github.com/llvm/llvm-project/blob/2ff43ce87e66d9324370e35ea6743ef57400c76e/clang/lib/Analysis/UnsafeBufferUsage.cpp#L1373-L1374 > > > > These assert that exactly one gadget matched. I think it's kinda worthwhile > > keeping the warnings independent too, so I don't see

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Dana Jansens via cfe-commits
https://github.com/danakj updated https://github.com/llvm/llvm-project/pull/91777 >From 8b318dadac6d0ec53b5d26461edfe19a391845ec Mon Sep 17 00:00:00 2001 From: danakj Date: Fri, 10 May 2024 13:31:17 -0400 Subject: [PATCH 1/3] Respect the [[clang::unsafe_buffer_usage]] attribute for

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -2295,6 +2292,23 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { } } + void handleUnsafeOperationInContainer(const Stmt *Operation, +bool IsRelatedToDecl, +

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -921,10 +937,55 @@ class UnsafeBufferUsageAttrGadget : public WarningGadget { } static Matcher matcher() { -return stmt(callExpr(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage -.bind(OpTag)); +auto HasUnsafeFnDecl = +

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -2856,7 +2916,7 @@ getFixIts(FixableGadgetSets , const FixitStrategy , } #ifndef NDEBUG Handler.addDebugNoteForVar( - VD, F->getBaseStmt()->getBeginLoc(), + VD, F->getSourceLoc(), haoNoQ wrote: This is the only place where we

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: > https://github.com/llvm/llvm-project/blob/2ff43ce87e66d9324370e35ea6743ef57400c76e/clang/lib/Analysis/UnsafeBufferUsage.cpp#L1373-L1374 > > These assert that exactly one gadget matched. I think it's kinda worthwhile > keeping the warnings independent too,

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Dana Jansens via cfe-commits
danakj wrote: > Hi! Thank you for digging into this! Sorry for the delay. > > > The new UnsafeBufferUsageCtorAttrGadget gadget explicitly avoids matching > > against the std::span(ptr, size) constructor because that is handled by > > SpanTwoParamConstructorGadget and we never want two gadgets

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-13 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Hi! Thank you for digging into this! Sorry for the delay. > The new UnsafeBufferUsageCtorAttrGadget gadget explicitly avoids matching > against the std::span(ptr, size) constructor because that is handled by > SpanTwoParamConstructorGadget and we never want two gadgets to match

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-13 Thread Dana Jansens via cfe-commits
https://github.com/danakj edited https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-10 Thread Dana Jansens via cfe-commits
https://github.com/danakj updated https://github.com/llvm/llvm-project/pull/91777 >From 8b318dadac6d0ec53b5d26461edfe19a391845ec Mon Sep 17 00:00:00 2001 From: danakj Date: Fri, 10 May 2024 13:31:17 -0400 Subject: [PATCH 1/2] Respect the [[clang::unsafe_buffer_usage]] attribute for

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-10 Thread Dana Jansens via cfe-commits
https://github.com/danakj updated https://github.com/llvm/llvm-project/pull/91777 >From 8b318dadac6d0ec53b5d26461edfe19a391845ec Mon Sep 17 00:00:00 2001 From: danakj Date: Fri, 10 May 2024 13:31:17 -0400 Subject: [PATCH] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-10 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 317e6ff6290c4c3065cb79c3eaf52f171e40cdfd d7694d70393fd49792470147c7ca136fd33f194e --

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-10 Thread Dana Jansens via cfe-commits
https://github.com/danakj updated https://github.com/llvm/llvm-project/pull/91777 >From 1c835f4cc77823360762b8e53e2bbfe027c977cf Mon Sep 17 00:00:00 2001 From: danakj Date: Fri, 10 May 2024 13:31:17 -0400 Subject: [PATCH] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-10 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-analysis Author: Dana Jansens (danakj) Changes The -Wunsafe-buffer-usage warning should fire on any call to a function annotated with [[clang::unsafe_buffer_usage]], however it omitted calls to constructors, since the expression is a

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-10 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Dana Jansens (danakj) Changes The -Wunsafe-buffer-usage warning should fire on any call to a function annotated with [[clang::unsafe_buffer_usage]], however it omitted calls to constructors, since the expression is a CXXConstructExpr

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-10 Thread Dana Jansens via cfe-commits
danakj wrote: cc: @haoNoQ https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-10 Thread Dana Jansens via cfe-commits
https://github.com/danakj created https://github.com/llvm/llvm-project/pull/91777 The -Wunsafe-buffer-usage warning should fire on any call to a function annotated with [[clang::unsafe_buffer_usage]], however it omitted calls to constructors, since the expression is a CXXConstructExpr which