[clang] [clang][dataflow] Fix smart pointer accessor caching to handle aliases (PR #124964)

2025-01-29 Thread Jan Voung via cfe-commits
https://github.com/jvoung ready_for_review https://github.com/llvm/llvm-project/pull/124964 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Fix smart pointer accessor caching to handle aliases (PR #124964)

2025-01-29 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/124964 Check the canonical type in the matchers to handle aliases. For example std::optional uses add_pointer_t<...>. >From f5414bee931510d530c440f0590226367ba7913c Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed,

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-24 Thread Jan Voung via cfe-commits
jvoung wrote: > It would be better to use `GtestCmp` if you really want clang-tidy support > gtest in this check. Here is an unfinished example which can match > > ``` > TEST(a, b) { > std::optional a; > if (v) { > a = 1; > } > ASSERT_NE(a, std::nullopt); > a.value(); > } > ``` >

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-24 Thread Jan Voung via cfe-commits
jvoung wrote: > > I'm not really that opposed to this solution, but the other solutions sound > > better to me, though with their own caveats (time, work, GTest macros are > > only for GTest). I'm fine with this, if all other options are not feasible > > to implement in the near to mid term, b

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-14 Thread Jan Voung via cfe-commits
@@ -239,6 +239,10 @@ Changes in existing checks ` to support ``bsl::optional`` and ``bdlb::NullableValue`` from _. + Fixed false positives from smart pointer accessors repeated in checking + ``has_value`` and accessing ``value``, by cac

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-14 Thread Jan Voung via cfe-commits
@@ -232,6 +232,10 @@ Changes in existing checks ` to support `bsl::optional` and `bdlb::NullableValue` from _. + Fixed false positives from smart pointer accessors repeated in checking + ``has_value`` and accessing ``value``, by caching

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-14 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/122290 >From 342ff1a05caa6943fe8a86415f30b433ac30106f Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 9 Jan 2025 14:10:30 + Subject: [PATCH 1/5] [clang-tidy] Add a release note about unchecked-optional-access s

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-14 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/122290 >From 342ff1a05caa6943fe8a86415f30b433ac30106f Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 9 Jan 2025 14:10:30 + Subject: [PATCH 1/5] [clang-tidy] Add a release note about unchecked-optional-access s

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-13 Thread Jan Voung via cfe-commits
@@ -81,10 +81,12 @@ Exception: accessor methods The check assumes *accessor* methods of a class are stable, with a heuristic to determine which methods are accessors. Specifically, parameter-free ``const`` -methods are treated as accessors. Note that this is not guaranteed to

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-13 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/122290 >From 342ff1a05caa6943fe8a86415f30b433ac30106f Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 9 Jan 2025 14:10:30 + Subject: [PATCH 1/4] [clang-tidy] Add a release note about unchecked-optional-access s

[clang-tools-extra] [clang-tidy] sort / reorder a part of release notes (PR #122475)

2025-01-10 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed https://github.com/llvm/llvm-project/pull/122475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-10 Thread Jan Voung via cfe-commits
jvoung wrote: > program:run-clang-tidy Sure thing -- Done separately in https://github.com/llvm/llvm-project/pull/122475 (I kept the "Improved" cluster together, vs moving `run-clang-tidy` to be after the "Removed" block including the table) For `readability-identifier-naming` it looks like

[clang-tools-extra] [clang-tidy] sort / reorder a part of release notes (PR #122475)

2025-01-10 Thread Jan Voung via cfe-commits
https://github.com/jvoung ready_for_review https://github.com/llvm/llvm-project/pull/122475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] sort / reorder a part of release notes (PR #122475)

2025-01-10 Thread Jan Voung via cfe-commits
https://github.com/jvoung edited https://github.com/llvm/llvm-project/pull/122475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] sort a bit more parts of release notes (PR #122475)

2025-01-10 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/122475 and remove a trailing space >From a11558489842cbde57a5237cd28be44fbcb4d211 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Fri, 10 Jan 2025 15:23:46 + Subject: [PATCH] [clang-tidy] sort a bit more parts of r

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-10 Thread Jan Voung via cfe-commits
jvoung wrote: > does check doc need to be changed also? Good question -- I don't see the option IgnoreSmartPointerDereference advertised in the check docs. Otherwise, we partially updated the check docs about earlier accessor caching. Updated more to mention smart pointer like APIs. Also prev

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-10 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/122290 >From 342ff1a05caa6943fe8a86415f30b433ac30106f Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 9 Jan 2025 14:10:30 + Subject: [PATCH 1/3] [clang-tidy] Add a release note about unchecked-optional-access s

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-09 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/122290 >From 342ff1a05caa6943fe8a86415f30b433ac30106f Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 9 Jan 2025 14:10:30 + Subject: [PATCH 1/2] [clang-tidy] Add a release note about unchecked-optional-access s

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-09 Thread Jan Voung via cfe-commits
https://github.com/jvoung edited https://github.com/llvm/llvm-project/pull/122290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Add a release note about unchecked-optional-access smart pointer caching (PR #122290)

2025-01-09 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/122290 With caching added in https://github.com/llvm/llvm-project/pull/120249, inform in notes that the `IgnoreSmartPointerDereference` option shouldn't be needed anymore. Other caching also added earlier: https://githu

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-08 Thread Jan Voung via cfe-commits
jvoung wrote: > Sorry for the delay. > > I think, that we can probably all agree that the best solution would be to > have the model support the macros, e.g., by recognizing the patterns that are > behind these macros. However, that is currently not something that people can > find time to do

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-08 Thread Jan Voung via cfe-commits
@@ -27,19 +29,44 @@ class UncheckedOptionalAccessCheck : public ClangTidyCheck { UncheckedOptionalAccessCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), ModelOptions{ -Options.getLocalOrGlobal("IgnoreSmartPointerDeref

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-08 Thread Jan Voung via cfe-commits
@@ -27,19 +29,44 @@ class UncheckedOptionalAccessCheck : public ClangTidyCheck { UncheckedOptionalAccessCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), ModelOptions{ -Options.getLocalOrGlobal("IgnoreSmartPointerDeref

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-08 Thread Jan Voung via cfe-commits
jvoung wrote: Done (there was a false-negative example in `unchecked_value_access` but also added the ASSERT_FALSE) https://github.com/llvm/llvm-project/pull/115051 ___ cfe-commits mailing list cfe-commits@lists.llvm

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-08 Thread Jan Voung via cfe-commits
@@ -40,11 +40,30 @@ void UncheckedOptionalAccessCheck::registerMatchers(MatchFinder *Finder) { this); } +void UncheckedOptionalAccessCheck::onStartOfTranslationUnit() { + // Reset the flag for each TU. + is_test_tu_ = false; +} + void UncheckedOptionalAccessCheck::ch

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-08 Thread Jan Voung via cfe-commits
@@ -40,11 +40,30 @@ void UncheckedOptionalAccessCheck::registerMatchers(MatchFinder *Finder) { this); } +void UncheckedOptionalAccessCheck::onStartOfTranslationUnit() { + // Reset the flag for each TU. + is_test_tu_ = false; +} + void UncheckedOptionalAccessCheck::ch

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-08 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/115051 >From 8d83ec25ccdedad5f6a48e4a23176435f71a3e72 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 5 Nov 2024 19:20:36 + Subject: [PATCH 1/6] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-opti

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2025-01-08 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/115051 >From 8d83ec25ccdedad5f6a48e4a23176435f71a3e72 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 5 Nov 2024 19:20:36 + Subject: [PATCH 1/5] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-opti

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2025-01-08 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed https://github.com/llvm/llvm-project/pull/120249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2025-01-07 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/120249 >From c526263a7accc434dbf6e93c2995ceb2f95873b8 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 17 Dec 2024 15:38:19 + Subject: [PATCH 1/7] [clang][dataflow] Use smart pointer caching in unchecked optiona

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2025-01-07 Thread Jan Voung via cfe-commits
@@ -58,6 +63,106 @@ ast_matchers::StatementMatcher isSmartPointerLikeOperatorArrow(); ast_matchers::StatementMatcher isSmartPointerLikeValueMethodCall(); ast_matchers::StatementMatcher isSmartPointerLikeGetMethodCall(); +// Common transfer functions. + +/// Returns the "canon

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2025-01-07 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/120249 >From c526263a7accc434dbf6e93c2995ceb2f95873b8 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 17 Dec 2024 15:38:19 + Subject: [PATCH 1/7] [clang][dataflow] Use smart pointer caching in unchecked optiona

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-23 Thread Jan Voung via cfe-commits
https://github.com/jvoung commented: Thanks Gábor! https://github.com/llvm/llvm-project/pull/120249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-23 Thread Jan Voung via cfe-commits
@@ -555,24 +557,26 @@ void handleConstMemberCall(const CallExpr *CE, LatticeTransferState &State) { // If the const method returns an optional or reference to an optional. if (RecordLoc != nullptr && isSupportedOptionalType(CE->getType())) { -

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-23 Thread Jan Voung via cfe-commits
@@ -71,10 +73,28 @@ template class CachedConstAccessorsLattice : public Base { /// Requirements: /// /// - `CE` should return a location (GLValue or a record type). + /// + /// DEPRECATED: switch users to the below overload which takes Callee and Type + /// directl

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-23 Thread Jan Voung via cfe-commits
https://github.com/jvoung edited https://github.com/llvm/llvm-project/pull/120249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-23 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/120249 >From c526263a7accc434dbf6e93c2995ceb2f95873b8 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 17 Dec 2024 15:38:19 + Subject: [PATCH 1/6] [clang][dataflow] Use smart pointer caching in unchecked optiona

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-23 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/120249 >From c526263a7accc434dbf6e93c2995ceb2f95873b8 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 17 Dec 2024 15:38:19 + Subject: [PATCH 1/5] [clang][dataflow] Use smart pointer caching in unchecked optiona

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-20 Thread Jan Voung via cfe-commits
https://github.com/jvoung ready_for_review https://github.com/llvm/llvm-project/pull/120249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-20 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/120249 >From c526263a7accc434dbf6e93c2995ceb2f95873b8 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 17 Dec 2024 15:38:19 + Subject: [PATCH 1/4] [clang][dataflow] Use smart pointer caching in unchecked optiona

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-20 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/120249 >From c526263a7accc434dbf6e93c2995ceb2f95873b8 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 17 Dec 2024 15:38:19 + Subject: [PATCH 1/2] [clang][dataflow] Use smart pointer caching in unchecked optiona

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-20 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/120249 >From c526263a7accc434dbf6e93c2995ceb2f95873b8 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 17 Dec 2024 15:38:19 + Subject: [PATCH] [clang][dataflow] Use smart pointer caching in unchecked optional ac

[clang] [clang][dataflow] Fix a missing break from a switch case -Wimplicit-fallthrough (PR #120739)

2024-12-20 Thread Jan Voung via cfe-commits
jvoung wrote: > Thanks for the fix! Thanks for helping merge! And sorry again about the breakage! https://github.com/llvm/llvm-project/pull/120739 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-20 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed https://github.com/llvm/llvm-project/pull/120102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-19 Thread Jan Voung via cfe-commits
@@ -0,0 +1,63 @@ +//===-- SmartPointerAccessorCaching.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apa

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-19 Thread Jan Voung via cfe-commits
@@ -0,0 +1,134 @@ +#include "clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h" + +#include "clang/AST/CanonicalType.h" +#include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Basic/OperatorKinds.h" + +namespace clang::dataflow { + +na

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-19 Thread Jan Voung via cfe-commits
@@ -0,0 +1,133 @@ +#include "clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h" + +#include "clang/AST/CanonicalType.h" +#include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Basic/OperatorKinds.h" + +namespace clang::dataflow { + +na

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-17 Thread Jan Voung via cfe-commits
@@ -0,0 +1,134 @@ +#include "clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h" + +#include "clang/AST/CanonicalType.h" +#include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Basic/OperatorKinds.h" + +namespace clang::dataflow { + +na

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-17 Thread Jan Voung via cfe-commits
@@ -0,0 +1,134 @@ +#include "clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h" + +#include "clang/AST/CanonicalType.h" +#include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Basic/OperatorKinds.h" + +namespace clang::dataflow { + +na

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-17 Thread Jan Voung via cfe-commits
@@ -0,0 +1,134 @@ +#include "clang/Analysis/FlowSensitive/SmartPointerAccessorCaching.h" + +#include "clang/AST/CanonicalType.h" +#include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Basic/OperatorKinds.h" + +namespace clang::dataflow { + +na

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-17 Thread Jan Voung via cfe-commits
@@ -0,0 +1,194 @@ +//===- unittests/Analysis/FlowSensitive/SmartPointerAccessorCachingTest.cpp ==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

2024-12-17 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/120249 Part 2 (and final part) following https://github.com/llvm/llvm-project/pull/120102 Allows users to do things like: ``` if (o->x.has_value()) { ((*o).x).value(); } ``` where the `->` and `*` are operator overlo

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-17 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/120102 >From f9b8cbaed4c01c2051cdcde105d6a9bca1684388 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Mon, 16 Dec 2024 16:06:43 + Subject: [PATCH 1/2] [clang][dataflow] Add matchers for smart pointer accessors to be

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-16 Thread Jan Voung via cfe-commits
https://github.com/jvoung ready_for_review https://github.com/llvm/llvm-project/pull/120102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Add matchers for smart pointer accessors to be cached (PR #120102)

2024-12-16 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/120102 This is part 1 of caching for smart pointer accessors, building on top of the CachedConstAccessorsLattice, which caches "normal" accessors. Smart pointer accessors are a bit different in that they may: - have ali

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-06 Thread Jan Voung via cfe-commits
https://github.com/jvoung edited https://github.com/llvm/llvm-project/pull/115051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-06 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/115051 >From 8d83ec25ccdedad5f6a48e4a23176435f71a3e72 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 5 Nov 2024 19:20:36 + Subject: [PATCH 1/5] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-opti

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-06 Thread Jan Voung via cfe-commits
jvoung wrote: Thanks! Ok that does that look useful (and I think the our other reviewer ymand@ wrote it =) https://reviews.llvm.org/D74840). - I'll work on using those in parallel - It will need to be extended a little to handle a few more matches (right now it's the binary comparison eq/ne, e

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-06 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/115051 >From 8d83ec25ccdedad5f6a48e4a23176435f71a3e72 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 5 Nov 2024 19:20:36 + Subject: [PATCH 1/4] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-opti

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-02 Thread Jan Voung via cfe-commits
jvoung wrote: Hi @5chmidti and @HerrCai0907 any thoughts on the "Would it help if this was instead a checker option?"? Given the volume of false positives right now, I think skip by default, but can turn on if needed. I updated the description to include the point of "we are currently seeing m

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-02 Thread Jan Voung via cfe-commits
https://github.com/jvoung edited https://github.com/llvm/llvm-project/pull/115051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-02 Thread Jan Voung via cfe-commits
https://github.com/jvoung edited https://github.com/llvm/llvm-project/pull/115051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-02 Thread Jan Voung via cfe-commits
https://github.com/jvoung edited https://github.com/llvm/llvm-project/pull/115051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [LLVM][NFC] Use `used`'s element type if available (PR #116804)

2024-11-20 Thread Jan Voung via cfe-commits
https://github.com/jvoung approved this pull request. https://github.com/llvm/llvm-project/pull/116804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-14 Thread Jan Voung via cfe-commits
jvoung wrote: > I don't think we can ignore a TU simply because it has the Google Test header > included, which this will do. This would ignore real problems, such as That is true (and we've considered that -- FWIW, ymand and our team have been maintaining this checker). But as is, we are curr

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-13 Thread Jan Voung via cfe-commits
jvoung wrote: Any other concerns? I think I've elaborated on why the ignore/exclude alternative is not better. Otherwise, eventually, it would be great to be able to understand the various macros and how they could serve as checks for later accesses, but I think this is an improvement on the

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-11 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/115051 >From 8d83ec25ccdedad5f6a48e4a23176435f71a3e72 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 5 Nov 2024 19:20:36 + Subject: [PATCH 1/3] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-opti

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-07 Thread Jan Voung via cfe-commits
jvoung wrote: > > > we're not (fully) understanding the content > > > > > > My thinking was that we don't even need to understand the content, we > > simply exclude code that is contained within any of the problematic public > > macros. This sounds like it should be possible to do? Unfortunat

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-06 Thread Jan Voung via cfe-commits
jvoung wrote: > > but these are not internal implementation details - these are key elements > > of the public API > > In the unit test, you have copied internal code from here: > https://github.com/google/googletest/blob/d144031940543e15423a25ae5a8a74141044862f/googletest/include/gtest/intern

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-06 Thread Jan Voung via cfe-commits
jvoung wrote: > > we're not (fully) understanding the content > > My thinking was that we don't even need to understand the content, we simply > exclude code that is contained within any of the problematic public macros. > This sounds like it should be possible to do? Unfortunately I don't kno

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-06 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/115051 >From 8d83ec25ccdedad5f6a48e4a23176435f71a3e72 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 5 Nov 2024 19:20:36 + Subject: [PATCH 1/3] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-opti

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-05 Thread Jan Voung via cfe-commits
jvoung wrote: > Relying on Google-test internal implementation details that are outside of > our control and may change at any point in time does not feel good. > > The patch should instead fix the root cause of the problem. I agree that it's not good to rely on implementation details, but the

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-05 Thread Jan Voung via cfe-commits
jvoung wrote: > A quick middle-point solution is to add an option to allow ignoring code that > is executed from within macros, or even allow the user to specify which > macros to ignore. Unfortunately, the problem is exactly that we're not (fully) understanding the content of `ASSERT_TRUE` a

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung ready_for_review https://github.com/llvm/llvm-project/pull/115051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/115051 >From 8d83ec25ccdedad5f6a48e4a23176435f71a3e72 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Tue, 5 Nov 2024 19:20:36 + Subject: [PATCH 1/2] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-opti

[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-11-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/115051 We currently do not handle ASSERT_TRUE(opt.has_value()) macros from googletest (and other macros), so would see lots of false positives in test TUs. >From 8d83ec25ccdedad5f6a48e4a23176435f71a3e72 Mon Sep 17 00:0

[clang] [clang][dataflow] Cache accessors returning pointers in bugprone-unchecked-optional-access (PR #113922)

2024-10-28 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed https://github.com/llvm/llvm-project/pull/113922 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Cache accessors returning pointers in bugprone-unchecked-optional-access (PR #113922)

2024-10-28 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/113922 >From 21f15146b8a7941781b6d728cdbb0d0be50b02fc Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Mon, 28 Oct 2024 14:45:39 + Subject: [PATCH 1/2] [clang][dataflow] Cache accessors returning pointers in bugprone

[clang] [clang][dataflow] Cache accessors returning pointers in bugprone-unchecked-optional-access (PR #113922)

2024-10-28 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/113922 Previously, we covered returning refs, or copies of optional, and bools. Now cover returning pointers (to any type). This is useful for cases like operator-> of smart pointers. Addresses more of issue llvm#58510

[clang] [clang][dataflow] Don't clear cached field state if field is const (PR #113698)

2024-10-28 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed https://github.com/llvm/llvm-project/pull/113698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Don't clear cached field state if field is const (PR #113698)

2024-10-25 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/113698 ... in the unchecked optional access model. >From 8b955ead1e7445a7226f51078ba2d05e52f15c23 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Fri, 25 Oct 2024 14:56:49 + Subject: [PATCH] [clang][dataflow] Don't

[clang] [clang][dataflow] Disambiguate a ref to "internal" in CachedConstAccessorsLattice (PR #113601)

2024-10-25 Thread Jan Voung via cfe-commits
jvoung wrote: > AST_MATCHER_P_OVERLOAD Ah, missed the part where the macro is generating the `internal` namespaces. I don't think we want to move to the top of the file exactly (the instantiation refers to some functions defined right above, so would need fwd decls?), but we can change the na

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-24 Thread Jan Voung via cfe-commits
@@ -0,0 +1,218 @@ +//===-- CachedConstAccessorsLattice.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang][dataflow] Disambiguate a ref to "internal" in CachedConstAccessorsLattice (PR #113601)

2024-10-24 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed https://github.com/llvm/llvm-project/pull/113601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-24 Thread Jan Voung via cfe-commits
@@ -0,0 +1,218 @@ +//===-- CachedConstAccessorsLattice.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang][dataflow] Disambiguate a ref to "internal" in CachedConstAccessorsLattice (PR #113601)

2024-10-24 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/113601 Disambiguate to fix a build error (e.g., on windows with clang-cl) >From f5470d4bee2ab991942d6640dd48631ca343bc85 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 24 Oct 2024 17:37:03 + Subject: [PATCH]

[clang] [clang-tools-extra] [clang][dataflow] Cache accessors for bugprone-unchecked-optional-access (PR #112605)

2024-10-22 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed https://github.com/llvm/llvm-project/pull/112605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang][dataflow] Cache accessors for bugprone-unchecked-optional-access (PR #112605)

2024-10-22 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/112605 >From 57a913c8870b338fa127f323be65fda972d65a96 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 16 Oct 2024 19:38:45 + Subject: [PATCH 1/4] [clang][dataflow] Cache accessors for bugprone-unchecked-optiona

[clang] [clang-tools-extra] [clang][dataflow] Cache accessors for bugprone-unchecked-optional-access (PR #112605)

2024-10-21 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/112605 >From 57a913c8870b338fa127f323be65fda972d65a96 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 16 Oct 2024 19:38:45 + Subject: [PATCH 1/4] [clang][dataflow] Cache accessors for bugprone-unchecked-optiona

[clang] [clang-tools-extra] [clang][dataflow] Cache accessors for bugprone-unchecked-optional-access (PR #112605)

2024-10-21 Thread Jan Voung via cfe-commits
@@ -523,6 +544,99 @@ void transferCallReturningOptional(const CallExpr *E, setHasValue(*Loc, State.Env.makeAtomicBoolValue(), State.Env); } +void handleConstMemberCall(const CallExpr *CE, + dataflow::RecordStorageLocation *RecordLoc, +

[clang] [clang-tools-extra] [clang][dataflow] Cache accessors for bugprone-unchecked-optional-access (PR #112605)

2024-10-21 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/112605 >From 57a913c8870b338fa127f323be65fda972d65a96 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 16 Oct 2024 19:38:45 + Subject: [PATCH 1/3] [clang][dataflow] Cache accessors for bugprone-unchecked-optiona

[clang] [clang-tools-extra] [clang][dataflow] Cache accessors for bugprone-unchecked-optional-access (PR #112605)

2024-10-16 Thread Jan Voung via cfe-commits
https://github.com/jvoung ready_for_review https://github.com/llvm/llvm-project/pull/112605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang][dataflow] Cache accessors for bugprone-unchecked-optional-access (PR #112605)

2024-10-16 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/112605 >From 57a913c8870b338fa127f323be65fda972d65a96 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 16 Oct 2024 19:38:45 + Subject: [PATCH 1/2] [clang][dataflow] Cache accessors for bugprone-unchecked-optiona

[clang] [clang-tools-extra] [clang][dataflow] Cache accessors for bugprone-unchecked-optional-access (PR #112605)

2024-10-16 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/112605 Treat calls to zero-param const methods as having stable return values (with a cache) to address issue #58510. The cache is invalidated when non-const methods are called. This uses the infrastructure from PR #1110

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-16 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed https://github.com/llvm/llvm-project/pull/111006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-16 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/111006 >From f82e63e470f704f29f4c161579fd592c27301868 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 3 Oct 2024 15:21:32 + Subject: [PATCH 1/4] [clang][dataflow] Add a lattice to help represent cache const acc

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-15 Thread Jan Voung via cfe-commits
@@ -0,0 +1,218 @@ +//===-- CachedConstAccessorsLattice.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-15 Thread Jan Voung via cfe-commits
@@ -0,0 +1,218 @@ +//===-- CachedConstAccessorsLattice.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-15 Thread Jan Voung via cfe-commits
@@ -0,0 +1,217 @@ +//===- unittests/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp ==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang][dataflow] Add a lattice to help cache const accessor methods (PR #111006)

2024-10-15 Thread Jan Voung via cfe-commits
@@ -0,0 +1,217 @@ +//===- unittests/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp ==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

  1   2   >