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

2025-02-28 Thread Valentyn Yukhymenko via cfe-commits
BaLiKfromUA wrote: Could someone merge it? Or do we need another reviewer? I don't have merge permissions :) https://github.com/llvm/llvm-project/pull/128437 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

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

2025-02-28 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/128437 >From 319ad0b803b8c6c6c5405178335bd1f2258be4b8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 23 Feb 2025 12:08:02 + Subject: [PATCH 1/9] first implementation and basic tests --- .../Mod

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

2025-02-27 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA 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-tools-extra] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

2025-02-27 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/128437 >From 319ad0b803b8c6c6c5405178335bd1f2258be4b8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 23 Feb 2025 12:08:02 + Subject: [PATCH 1/7] first implementation and basic tests --- .../Mod

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

2025-02-26 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA ready_for_review 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-26 Thread Valentyn Yukhymenko via cfe-commits
BaLiKfromUA wrote: Addressed all comments. Thanks for the initial feedback! Regarding documentation: looks like we need to merge https://github.com/llvm/llvm-project/pull/122290 first and then update docs in my PR https://github.com/llvm/llvm-project/pull/128437 __

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

2025-02-26 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/128437 >From 319ad0b803b8c6c6c5405178335bd1f2258be4b8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 23 Feb 2025 12:08:02 + Subject: [PATCH 1/7] first implementation and basic tests --- .../Mod

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

2025-02-26 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/128437 >From 319ad0b803b8c6c6c5405178335bd1f2258be4b8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 23 Feb 2025 12:08:02 + Subject: [PATCH 1/6] first implementation and basic tests --- .../Mod

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

2025-02-26 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/128437 >From 319ad0b803b8c6c6c5405178335bd1f2258be4b8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 23 Feb 2025 12:08:02 + Subject: [PATCH 1/5] first implementation and basic tests --- .../Mod

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

2025-02-26 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/128437 >From 319ad0b803b8c6c6c5405178335bd1f2258be4b8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 23 Feb 2025 12:08:02 + Subject: [PATCH 1/4] first implementation and basic tests --- .../Mod

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

2025-02-23 Thread Valentyn Yukhymenko 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-23 Thread Valentyn Yukhymenko 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-23 Thread Valentyn Yukhymenko 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-23 Thread Valentyn Yukhymenko via cfe-commits
BaLiKfromUA wrote: TODO: update release notes and `clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst` if needed https://github.com/llvm/llvm-project/pull/128437 ___ cfe-commits mailing list cfe-commits@lists.llvm.org htt

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

2025-02-23 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA created https://github.com/llvm/llvm-project/pull/128437 Fixes https://github.com/llvm/llvm-project/issues/126283 Extending https://github.com/llvm/llvm-project/pull/112605 to cache const getters which return references. This should fix false positive cases when

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-24 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/123533 >From e451a8869420d9240f9006eb2adb599a3e6fd9f8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 19 Jan 2025 23:13:46 + Subject: [PATCH 1/6] [Clang] Reject declaring an alias template with th

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-24 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/123533 >From e451a8869420d9240f9006eb2adb599a3e6fd9f8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 19 Jan 2025 23:13:46 + Subject: [PATCH 1/5] [Clang] Reject declaring an alias template with th

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-24 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-24 Thread Valentyn Yukhymenko via cfe-commits
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, AccessSpecifier AS, } TemplateParameterList *TemplateParams = TemplateParamLists[0]; +// Check shadowing of a template parameter name +for (NamedDecl *TP : TemplateParams->asArray()) { +

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-24 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-24 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/123533 >From e451a8869420d9240f9006eb2adb599a3e6fd9f8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 19 Jan 2025 23:13:46 + Subject: [PATCH 1/4] [Clang] Reject declaring an alias template with th

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-24 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/123533 >From e451a8869420d9240f9006eb2adb599a3e6fd9f8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 19 Jan 2025 23:13:46 + Subject: [PATCH 1/4] [Clang] Reject declaring an alias template with th

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-21 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-21 Thread Valentyn Yukhymenko via cfe-commits
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, AccessSpecifier AS, } TemplateParameterList *TemplateParams = TemplateParamLists[0]; +// Check shadowing of a template parameter name +for (NamedDecl *TP : TemplateParams->asArray()) { +

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-20 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-20 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-20 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-20 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-20 Thread Valentyn Yukhymenko via cfe-commits
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, AccessSpecifier AS, } TemplateParameterList *TemplateParams = TemplateParamLists[0]; +// Check shadowing of a template parameter name +for (NamedDecl *TP : TemplateParams->asArray()) { +

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA ready_for_review https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA updated https://github.com/llvm/llvm-project/pull/123533 >From e451a8869420d9240f9006eb2adb599a3e6fd9f8 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhymenko Date: Sun, 19 Jan 2025 23:13:46 + Subject: [PATCH] [Clang] Reject declaring an alias template with the sa

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA converted_to_draft https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA edited https://github.com/llvm/llvm-project/pull/123533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits
@@ -65,7 +65,8 @@ namespace InFunctions { template struct S3 { // expected-note {{template parameter is declared here}} template using T = int; // expected-error {{declaration of 'T' shadows template parameter}} }; - template using Z = Z; + template // expected-note

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Valentyn Yukhymenko via cfe-commits
https://github.com/BaLiKfromUA created https://github.com/llvm/llvm-project/pull/123533 Fixes llvm#123423 **How did I test it?** Modified existing test and checked an example from the issue manually. >From 0852c8ca587e772d5f851ac0983f43bdeec2ebd5 Mon Sep 17 00:00:00 2001 From: Valentyn Yukhy