[clang] [clang][dataflow] Add matcher for pointer-like types to be cached (PR #132314)

2025-04-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung approved this pull request. https://github.com/llvm/llvm-project/pull/132314 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reland [clang][dataflow] Fix unsupported types always being equal (PR #131575)

2025-04-04 Thread Jan Voung via cfe-commits
jvoung wrote: Hi, just checking if you wanted to merge this, or if there were any other issues. Thanks! https://github.com/llvm/llvm-project/pull/131575 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/lis

[clang] [clang] Track final substitution for Subst* AST nodes (PR #132748)

2025-04-04 Thread Jan Voung via cfe-commits
jvoung wrote: > @ymand @jvoung I'd like to know if you tried this patch within google and > within your tooling, and if you can report whether it is suited and if there > is any noteworthy performance impact. Ok, I tried some experiments. Our nullability analysis tests do now pass without the

[clang] [clang] remove unused frontend flag -fretain-subst-template-type-parm-type-ast-nodes (PR #134177)

2025-04-03 Thread Jan Voung via cfe-commits
https://github.com/jvoung approved this pull request. Please go ahead (need to wait for 1 to 2 weeks) and thanks again for splitting! https://github.com/llvm/llvm-project/pull/134177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists

[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)

2025-03-28 Thread Jan Voung via cfe-commits
https://github.com/jvoung approved this pull request. https://github.com/llvm/llvm-project/pull/133350 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)

2025-03-28 Thread Jan Voung via cfe-commits
@@ -23,12 +24,27 @@ using ast_matchers::pointerType; using ast_matchers::referenceType; using ast_matchers::returns; -bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet, - bool &HasValue) { +CanQualType getLikeReturnType(QualType

[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)

2025-03-28 Thread Jan Voung via cfe-commits
@@ -164,16 +161,19 @@ ast_matchers::StatementMatcher isPointerLikeOperatorArrow() { ofClass(pointerClass(); } -ast_matchers::StatementMatcher isSmartPointerLikeValueMethodCall() { +ast_matchers::StatementMatcher +isSmartPointerLikeValueMethodCal

[clang] [clang][dataflow] Fix unsupported types always being equal (PR #129502)

2025-03-18 Thread Jan Voung via cfe-commits
jvoung wrote: Thanks, Martin, for the checking over the `nullptr`/`nullptr_t` modeling, and the suggestion for a `Value &getNullptrValue() const`! We can try that out and test it that as a followup cleanup for this special-casing. https://github.com/llvm/llvm-project/pull/129502 __

[clang] Reland [clang][dataflow] Fix unsupported types always being equal (PR #131575)

2025-03-18 Thread Jan Voung via cfe-commits
https://github.com/jvoung approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/131575 ___ 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] For bugprone-unchecked-optional-access report range (PR #131055)

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

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-15 Thread Jan Voung via cfe-commits
https://github.com/jvoung commented: Thanks! https://github.com/llvm/llvm-project/pull/129930 ___ 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] For bugprone-unchecked-optional-access report range (PR #131055)

2025-03-14 Thread Jan Voung via cfe-commits
jvoung wrote: Ah yes! Added an expectation annotation for ranges and a test case. https://github.com/llvm/llvm-project/pull/131055 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-14 Thread Jan Voung via cfe-commits
jvoung wrote: Thank you Owen for the review and helping merge, and thank you all for helping arrive at a solution! https://github.com/llvm/llvm-project/pull/130346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [clang-tools-extra] [clang][dataflow] For bugprone-unchecked-optional-access report range (PR #131055)

2025-03-14 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/131055 >From b93c10f029fb33e9f7261cbb174d097be4137006 Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 13 Mar 2025 02:26:41 + Subject: [PATCH 1/3] [clang][dataflow] For bugprone-unchecked-optional-access report

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-13 Thread Jan Voung via cfe-commits
@@ -3185,6 +3185,53 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributes) { EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen); } +TEST_F(TokenAnnotatorTest, UnderstandsNullabilityAttributes) { + auto Tokens = annotate("x = (foo *_Nullable)*v;"); + ASSERT_EQ(Tokens.s

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-13 Thread Jan Voung via cfe-commits
@@ -3185,6 +3185,53 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributes) { EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen); } +TEST_F(TokenAnnotatorTest, UnderstandsNullabilityAttributes) { + auto Tokens = annotate("x = (foo *_Nullable)*v;"); + ASSERT_EQ(Tokens.s

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-13 Thread Jan Voung via cfe-commits
@@ -3185,6 +3185,53 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributes) { EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen); } +TEST_F(TokenAnnotatorTest, UnderstandsNullabilityAttributes) { + auto Tokens = annotate("x = (foo *_Nullable)*v;"); + ASSERT_EQ(Tokens.s

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-13 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/130346 >From 10df1857532a6a27b0e5286e10c9f0724d6d7e1d Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Fri, 7 Mar 2025 21:02:16 + Subject: [PATCH 1/7] [clang-format] Add support for absl nullability macros --- clang

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-13 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/130346 >From 10df1857532a6a27b0e5286e10c9f0724d6d7e1d Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Fri, 7 Mar 2025 21:02:16 + Subject: [PATCH 1/8] [clang-format] Add support for absl nullability macros --- clang

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-13 Thread Jan Voung via cfe-commits
@@ -3185,6 +3185,53 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributes) { EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen); } +TEST_F(TokenAnnotatorTest, UnderstandsNullabilityAttributes) { + auto Tokens = annotate("x = (foo *_Nullable)*v;"); + ASSERT_EQ(Tokens.s

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-13 Thread Jan Voung via cfe-commits
@@ -3185,6 +3185,53 @@ TEST_F(TokenAnnotatorTest, UnderstandsAttributes) { EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_AttributeRParen); } +TEST_F(TokenAnnotatorTest, UnderstandsNullabilityAttributes) { + auto Tokens = annotate("x = (foo *_Nullable)*v;"); + ASSERT_EQ(Tokens.s

[clang] [clang-tools-extra] [clang][dataflow] For bugprone-unchecked-optional-access report range (PR #131055)

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

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-12 Thread Jan Voung via cfe-commits
@@ -12720,6 +12735,21 @@ TEST_F(FormatTest, UnderstandsPointerQualifiersInCast) { verifyFormat(("x = (foo *" + AllQualifiers + " __my_qualifier)&v;").str(), CustomQualifier); + // Check additional attribute macros in Google style: + FormatStyle LongPointerR

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-12 Thread Jan Voung via cfe-commits
@@ -12518,6 +12521,10 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("MACRO(A *_Nonnull a);"); verifyIndependentOfContext("MACRO(A *_Nullable a);"); verifyIndependentOfContext("MACRO(A *_Null_unspecified a);"); + verifyIndependentOfContex

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-12 Thread Jan Voung via cfe-commits
@@ -909,6 +909,12 @@ TEST(ConfigParseTest, ParsesConfiguration) { Style.AttributeMacros.clear(); CHECK_PARSE("BasedOnStyle: LLVM", AttributeMacros, std::vector{"__capability"}); + Style.AttributeMacros.clear(); jvoung wrote: Ok, done! https

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

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

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-12 Thread Jan Voung via cfe-commits
https://github.com/jvoung commented: Thanks for the review! https://github.com/llvm/llvm-project/pull/130346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-12 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/130346 >From 10df1857532a6a27b0e5286e10c9f0724d6d7e1d Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Fri, 7 Mar 2025 21:02:16 + Subject: [PATCH 1/6] [clang-format] Add support for absl nullability macros --- clang

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-11 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/130346 >From 10df1857532a6a27b0e5286e10c9f0724d6d7e1d Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Fri, 7 Mar 2025 21:02:16 + Subject: [PATCH 1/4] [clang-format] Add support for absl nullability macros --- clang

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-11 Thread Jan Voung via cfe-commits
@@ -577,57 +580,62 @@ void handleConstMemberCall(const CallExpr *CE, auto &ResultLoc = State.Env.getResultObjectLocation(*CE); copyRecord(cast(Loc), ResultLoc, State.Env); } -return; +return true; } // Cache if the const method returns a referenc

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

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

[clang] [clang][dataflow] Fix unsupported types always being equal (PR #129502)

2025-03-11 Thread Jan Voung via cfe-commits
jvoung wrote: Sorry for the delay! I ran a few more tests and the downstream null analysis over a corpus of code with a small change to the patch. The small tweak (below) seems to pass the tests and your fix helps cover more code, as expected =) (e.g., analyze both branches when there is an `i

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-10 Thread Jan Voung via cfe-commits
jvoung wrote: > I wish they had not been added to the default but can't take them off the > lists for backward compatibility. I don't think we should add more. The > reason is that people wouldn't be able to turn off the special meaning if > they wanted to use e.g. `absl_nonnull` as a regular

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-09 Thread Jan Voung via cfe-commits
jvoung wrote: It would be nice to to avoid having each project configure via `AttributeMacros`. The Abseil macro is meant to be a portable way to use the Clang-specific nullability attributes like `_Nonnull` (portable in that it will be empty for non-Clang compilers). So one would expect it t

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

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

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

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

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

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

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

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

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-07 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/130346 None >From 10df1857532a6a27b0e5286e10c9f0724d6d7e1d Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Fri, 7 Mar 2025 21:02:16 + Subject: [PATCH] [clang-format] Add support for absl nullability macros --- cla

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-07 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/130346 >From 10df1857532a6a27b0e5286e10c9f0724d6d7e1d Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Fri, 7 Mar 2025 21:02:16 + Subject: [PATCH 1/2] [clang-format] Add support for absl nullability macros --- clang

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

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

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-06 Thread Jan Voung via cfe-commits
@@ -577,57 +580,62 @@ void handleConstMemberCall(const CallExpr *CE, auto &ResultLoc = State.Env.getResultObjectLocation(*CE); copyRecord(cast(Loc), ResultLoc, State.Env); } -return; +return true; } // Cache if the const method returns a referenc

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-06 Thread Jan Voung via cfe-commits
@@ -551,91 +551,92 @@ void transferCallReturningOptional(const CallExpr *E, setHasValue(*Loc, State.Env.makeAtomicBoolValue(), State.Env); } +// Returns true if the const accessor is handled by caching. +// Returns false if we could not cache. We should perform default handl

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-06 Thread Jan Voung via cfe-commits
@@ -551,91 +551,92 @@ void transferCallReturningOptional(const CallExpr *E, setHasValue(*Loc, State.Env.makeAtomicBoolValue(), State.Env); } +// Returns true if the const accessor is handled by caching. +// Returns false if we could not cache. We should perform default handl

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-06 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/129930 >From 81f5cfde1029b3c9ddd62eb0587ed370d67cccab Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 5 Mar 2025 20:15:48 + Subject: [PATCH 1/7] [clang][dataflow] Add test for crash repro and clean up const acc

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-06 Thread Jan Voung via cfe-commits
@@ -551,15 +551,18 @@ void transferCallReturningOptional(const CallExpr *E, setHasValue(*Loc, State.Env.makeAtomicBoolValue(), State.Env); } -void handleConstMemberCall(const CallExpr *CE, +bool handleConstMemberCall(const CallExpr *CE, jvoung wrote: Done!

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-06 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/129930 >From 81f5cfde1029b3c9ddd62eb0587ed370d67cccab Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 5 Mar 2025 20:15:48 + Subject: [PATCH 1/5] [clang][dataflow] Add test for crash repro and clean up const acc

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

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

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

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

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

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

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/129930 >From 81f5cfde1029b3c9ddd62eb0587ed370d67cccab Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 5 Mar 2025 20:15:48 + Subject: [PATCH 1/4] [clang][dataflow] Add test for crash repro and clean up const acc

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/129930 >From 81f5cfde1029b3c9ddd62eb0587ed370d67cccab Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 5 Mar 2025 20:15:48 + Subject: [PATCH 1/3] [clang][dataflow] Add test for crash repro and clean up const acc

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/129930 >From 81f5cfde1029b3c9ddd62eb0587ed370d67cccab Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Wed, 5 Mar 2025 20:15:48 + Subject: [PATCH 1/2] [clang][dataflow] Add test for crash repro and clean up const acc

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

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

[clang] [clang][dataflow] Add test for crash repro and clean up const accessor handling (PR #129930)

2025-03-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/129930 Add test for https://github.com/llvm/llvm-project/issues/125589 The crash is actually incidentally fixed by https://github.com/llvm/llvm-project/pull/128437 since it added a branch for the reference case and woul

[clang] [clang-tools-extra] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

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

[clang] [clang-tools-extra] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-28 Thread Jan Voung via cfe-commits
https://github.com/jvoung approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/128437 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-27 Thread Jan Voung via cfe-commits
@@ -114,11 +114,12 @@ Changes in existing checks and accessing ``value``. The option `IgnoreSmartPointerDereference` should no longer be needed and will be removed. +- Improved :doc:`bugprone-unchecked-optional-access jvoung wrote: Instead of starting a n

[clang] [clang-tools-extra] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-27 Thread Jan Voung via cfe-commits
jvoung wrote: > Updated release notes. Not sure if I need to update > `clang-tidy/checks/bugprone/unchecked-optional-access.rst`. For me it looks > like current `Exception: accessor methods` section covers my fix as well. Agreed that the "`Exception: accessor methods` section covers" your fix

[clang] [clang-tools-extra] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-27 Thread Jan Voung via cfe-commits
jvoung wrote: > Addressed all comments. Thanks for the initial feedback! > > Regarding documentation: looks like we need to merge #122290 first and then > update docs in my PR Thanks for the reminder about #122290 ! Got back to that and merged. Can you update? It looked like the latest releas

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

2025-02-27 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed 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-02-27 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/6] [clang-tidy] Add a release note about unchecked-optional-access s

[clang] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-25 Thread Jan Voung via cfe-commits
https://github.com/jvoung commented: Thanks! https://github.com/llvm/llvm-project/pull/128437 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-25 Thread Jan Voung via cfe-commits
@@ -580,6 +580,26 @@ void handleConstMemberCall(const CallExpr *CE, return; } + // Cache if the const method returns a reference + if (RecordLoc != nullptr && CE->isGLValue()) { +const FunctionDecl *DirectCallee = CE->getDirectCallee(); +if (DirectCallee == nul

[clang] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

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

[clang] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-25 Thread Jan Voung via cfe-commits
@@ -580,6 +580,26 @@ void handleConstMemberCall(const CallExpr *CE, return; } + // Cache if the const method returns a reference + if (RecordLoc != nullptr && CE->isGLValue()) { +const FunctionDecl *DirectCallee = CE->getDirectCallee(); +if (DirectCallee == nul

[clang] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-25 Thread Jan Voung via cfe-commits
@@ -3863,6 +3863,192 @@ TEST_P(UncheckedOptionalAccessTest, ConstBoolAccessorWithModInBetween) { )cc"); } +TEST_P(UncheckedOptionalAccessTest, + ConstRefAccessorToOptionalViaConstRefAccessorToHoldingObject) { + ExpectDiagnosticsFor(R"cc( +#include "unchecked_opti

[clang] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-25 Thread Jan Voung via cfe-commits
@@ -3863,6 +3863,192 @@ TEST_P(UncheckedOptionalAccessTest, ConstBoolAccessorWithModInBetween) { )cc"); } +TEST_P(UncheckedOptionalAccessTest, + ConstRefAccessorToOptionalViaConstRefAccessorToHoldingObject) { + ExpectDiagnosticsFor(R"cc( +#include "unchecked_opti

[clang] Reapply "[Analyzer][CFG] Correctly handle rebuilt default arg and default init expression" (PR #127338)

2025-02-21 Thread Jan Voung via cfe-commits
jvoung wrote: Appreciate that, thank you! https://github.com/llvm/llvm-project/pull/127338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reapply "[Analyzer][CFG] Correctly handle rebuilt default arg and default init expression" (PR #127338)

2025-02-21 Thread Jan Voung via cfe-commits
jvoung wrote: > > In case others notice similar in ClangTidy > > (`bugprone-unchecked-optional-access`), we are seeing crashes after this > > change #128068 > > I'm not yet sure the best fix. > > Can you try to revert this change to see if the crash issue can be fixed? It > looks like I missi

[clang] [clang][dataflow] Add test repro for a crash (PR #128065)

2025-02-21 Thread Jan Voung via cfe-commits
https://github.com/jvoung updated https://github.com/llvm/llvm-project/pull/128065 >From a7002fb5a61c2f6f3c4df2347b6d5f861bf45f8e Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 20 Feb 2025 19:40:16 + Subject: [PATCH 1/3] [clang][dataflow] Add test repro for a crash An issue with looki

[clang] Reapply "[Analyzer][CFG] Correctly handle rebuilt default arg and default init expression" (PR #127338)

2025-02-21 Thread Jan Voung via cfe-commits
jvoung wrote: In case others notice similar in ClangTidy (`bugprone-unchecked-optional-access`), we are seeing crashes after this change https://github.com/llvm/llvm-project/issues/128068 I'm not yet sure the best fix. https://github.com/llvm/llvm-project/pull/127338 _

[clang] [clang][dataflow] Add test repro for a crash (PR #128065)

2025-02-20 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/128065 An issue with looking up the "this" when a default init of field2 refers to field1. >From a7002fb5a61c2f6f3c4df2347b6d5f861bf45f8e Mon Sep 17 00:00:00 2001 From: Jan Voung Date: Thu, 20 Feb 2025 19:40:16 +

[clang] [clang][dataflow] Remove a deprecated CachedConstAccessorsLattice API (PR #127001)

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

[clang] [clang][dataflow] Remove a deprecated CachedConstAccessorsLattice API (PR #127001)

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

[clang] [clang][dataflow] Remove a deprecated CachedConstAccessorsLattice API (PR #127001)

2025-02-12 Thread Jan Voung via cfe-commits
https://github.com/jvoung created https://github.com/llvm/llvm-project/pull/127001 We've already migrated known users from the old to the new version of getOrCreateConstMethodReturnStorageLocation. The conversion is pretty straightforward as well, if there are out-of-tree users: Previously: use

[clang] [clang] [dataflow] use unqualified type for smart pointer matching (PR #125958)

2025-02-05 Thread Jan Voung via cfe-commits
https://github.com/jvoung approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/125958 ___ 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-30 Thread Jan Voung via cfe-commits
https://github.com/jvoung closed 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 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

  1   2   3   >