[clang-tools-extra] [clang-tidy] exclude CXXParenListInitExpr from RedundantCastingCheck (PR #109741)

2024-09-24 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/109741
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] exclude CXXParenListInitExpr from RedundantCastingCheck (PR #109741)

2024-09-24 Thread Piotr Zegar via cfe-commits


@@ -1,8 +1,8 @@
-// RUN: %check_clang_tidy -std=c++11-or-later %s readability-redundant-casting 
%t -- -- -fno-delayed-template-parsing
-// RUN: %check_clang_tidy -std=c++11-or-later -check-suffix=,MACROS %s 
readability-redundant-casting %t -- \
+// RUN: %check_clang_tidy -std=c++20-or-later %s readability-redundant-casting 
%t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -std=c++20-or-later -check-suffix=,MACROS %s 
readability-redundant-casting %t -- \
 // RUN:   -config='{CheckOptions: { 
readability-redundant-casting.IgnoreMacros: false }}' \
 // RUN:   -- -fno-delayed-template-parsing
-// RUN: %check_clang_tidy -std=c++11-or-later -check-suffix=,ALIASES %s 
readability-redundant-casting %t -- \
+// RUN: %check_clang_tidy -std=c++20-or-later -check-suffix=,ALIASES %s 
readability-redundant-casting %t -- \

PiotrZSL wrote:

Consider keeping tests for C++11, C++17. Add new entry/file for C++20.

https://github.com/llvm/llvm-project/pull/109741
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] exclude CXXParenListInitExpr from RedundantCastingCheck (PR #109741)

2024-09-24 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.

Except single comment, looks fine.

https://github.com/llvm/llvm-project/pull/109741
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Support member functions with modernize-use-std-print/format (PR #104675)

2024-08-18 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL closed 
https://github.com/llvm/llvm-project/pull/104675
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Support member functions with modernize-use-std-print/format (PR #104675)

2024-08-17 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.


https://github.com/llvm/llvm-project/pull/104675
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Support member functions with modernize-use-std-print/format (PR #104675)

2024-08-17 Thread Piotr Zegar via cfe-commits


@@ -104,6 +104,12 @@ New check aliases
 Changes in existing checks
 ^^
 
+- Improved :doc:`modernize-use-std-print
+  ` and

PiotrZSL wrote:

wrong name, and split that entry into 2, even if you would need to duplicate 
description

https://github.com/llvm/llvm-project/pull/104675
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Support member functions with modernize-use-std-print/format (PR #104675)

2024-08-17 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.


https://github.com/llvm/llvm-project/pull/104675
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Workaround for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-08-16 Thread Piotr Zegar via cfe-commits


@@ -23,8 +23,12 @@ void ProTypeUnionAccessCheck::registerMatchers(MatchFinder 
*Finder) {
 
 void ProTypeUnionAccessCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *Matched = Result.Nodes.getNodeAs("expr");
-  diag(Matched->getMemberLoc(),
-   "do not access members of unions; use (boost::)variant instead");
+  if (auto MemberLoc = Matched->getMemberLoc(); MemberLoc.isValid())
+diag(MemberLoc,
+ "do not access members of unions; use (boost::)variant instead");
+  else
+diag(Matched->getBeginLoc(),
+ "do not access members of unions; use (boost::)variant instead");

PiotrZSL wrote:

```suggestion
  SourceLocation Loc = Matched->getMemberLoc();
  if (Loc.isInvalid())
 Loc = Matched->getBeginLoc();
  diag(Loc, "do not access members of unions; use (boost::)variant instead");
```

re-format may be needed

https://github.com/llvm/llvm-project/pull/104540
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Workaround for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-08-16 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

Missing release notes entry, about what's fixed in check.
For me this is an full-fix, not an workaround.

https://github.com/llvm/llvm-project/pull/104540
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Workaround for cppcoreguidelines-pro-type-union-access if memLoc is invalid (PR #104540)

2024-08-16 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/104540
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {
+VisitCXXBaseSpecifier(Base, RDecl);
+  }
+  for (const auto &Base : RDecl->bases()) {
+const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+if (BaseType && BaseType->getQualifiedNameAsString() ==
+"std::enable_shared_from_this") {
+  EnableSharedClassSet.insert(RDecl->getCanonicalDecl());
+  return true;
+}
+  }
+  return true;
+}
+
+bool VisitCXXBaseSpecifier(const CXXBaseSpecifier &Base,
+   CXXRecordDecl *RDecl) {
+  const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+  const clang::AccessSpecifier AccessSpec = Base.getAccessSpecifier();
+
+  if (BaseType &&
+  BaseType->getQualifiedNameAsString() == "enable_shared_from_this") {
+if (AccessSpec == clang::AS_public) {
+  const SourceLocation InsertLocation = Base.getBaseTypeLoc();
+  const FixItHint Hint = FixItHint::CreateInsertion(InsertLocation, 
"std::");
+  Check.diag(RDecl->getLocation(),
+ "Should be std::enable_shared_from_this",
+ DiagnosticIDs::Warning)
+  << Hint;
+
+} else {
+  const SourceRange ReplacementRange = Base.getSourceRange();
+  const std::string ReplacementString =
+  "public std::" + Base.getType().getAsString();

PiotrZSL wrote:

doesn't make sense, why not write then `public std::enable_shared_from_this`

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {
+VisitCXXBaseSpecifier(Base, RDecl);
+  }
+  for (const auto &Base : RDecl->bases()) {
+const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+if (BaseType && BaseType->getQualifiedNameAsString() ==
+"std::enable_shared_from_this") {
+  EnableSharedClassSet.insert(RDecl->getCanonicalDecl());
+  return true;
+}
+  }
+  return true;
+}
+
+bool VisitCXXBaseSpecifier(const CXXBaseSpecifier &Base,
+   CXXRecordDecl *RDecl) {
+  const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+  const clang::AccessSpecifier AccessSpec = Base.getAccessSpecifier();
+
+  if (BaseType &&
+  BaseType->getQualifiedNameAsString() == "enable_shared_from_this") {

PiotrZSL wrote:

why no `::std::``

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {
+VisitCXXBaseSpecifier(Base, RDecl);
+  }
+  for (const auto &Base : RDecl->bases()) {
+const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+if (BaseType && BaseType->getQualifiedNameAsString() ==
+"std::enable_shared_from_this") {
+  EnableSharedClassSet.insert(RDecl->getCanonicalDecl());

PiotrZSL wrote:

instead of getCanonicalDecl would be better to take definition, as 
getCanonicalDecl is a first declaration (if i remember correctly)

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {
+VisitCXXBaseSpecifier(Base, RDecl);
+  }
+  for (const auto &Base : RDecl->bases()) {
+const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+if (BaseType && BaseType->getQualifiedNameAsString() ==

PiotrZSL wrote:

that getQualifiedNameAsStringis ugly, and did you check if getAsCXXRecordDecl 
will work with typedefs ?

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {
+VisitCXXBaseSpecifier(Base, RDecl);

PiotrZSL wrote:

shouldn't this be called anyway ? Maybe try with traverse instead of visit

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {
+VisitCXXBaseSpecifier(Base, RDecl);
+  }
+  for (const auto &Base : RDecl->bases()) {
+const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+if (BaseType && BaseType->getQualifiedNameAsString() ==
+"std::enable_shared_from_this") {
+  EnableSharedClassSet.insert(RDecl->getCanonicalDecl());
+  return true;
+}
+  }
+  return true;
+}
+
+bool VisitCXXBaseSpecifier(const CXXBaseSpecifier &Base,
+   CXXRecordDecl *RDecl) {
+  const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+  const clang::AccessSpecifier AccessSpec = Base.getAccessSpecifier();
+
+  if (BaseType &&
+  BaseType->getQualifiedNameAsString() == "enable_shared_from_this") {
+if (AccessSpec == clang::AS_public) {
+  const SourceLocation InsertLocation = Base.getBaseTypeLoc();
+  const FixItHint Hint = FixItHint::CreateInsertion(InsertLocation, 
"std::");
+  Check.diag(RDecl->getLocation(),
+ "Should be std::enable_shared_from_this",
+ DiagnosticIDs::Warning)
+  << Hint;
+
+} else {
+  const SourceRange ReplacementRange = Base.getSourceRange();
+  const std::string ReplacementString =
+  "public std::" + Base.getType().getAsString();
+  const FixItHint Hint =
+  FixItHint::CreateReplacement(ReplacementRange, 
ReplacementString);
+  Check.diag(
+  RDecl->getLocation(),
+  "Should be std::enable_shared_from_this and "
+  "inheritance from std::enable_shared_from_this should be public "
+  "inheritance, otherwise the internal weak_ptr won't be "

PiotrZSL wrote:

noneone care/know about "internal weak_ptr, write how it would behave from user 
perspective, start with lower caps.
For me this is too long. it should say: whats wrong (+why it's wrong), how to 
fix (+why fix)


https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {
+VisitCXXBaseSpecifier(Base, RDecl);
+  }
+  for (const auto &Base : RDecl->bases()) {
+const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+if (BaseType && BaseType->getQualifiedNameAsString() ==
+"std::enable_shared_from_this") {
+  EnableSharedClassSet.insert(RDecl->getCanonicalDecl());
+  return true;
+}
+  }
+  return true;
+}
+
+bool VisitCXXBaseSpecifier(const CXXBaseSpecifier &Base,

PiotrZSL wrote:

this entire function is too complicated to what it does, for example you got 
multiple compares to std::enable_shared_from_this, or :enable_shared_from_this, 
that should be eliminated. 
And instead of using getQualifiedNameAsString, 
[isInStdNamespace](https://clang.llvm.org/doxygen/classclang_1_1Decl.html#a066b012f94431b5bba21d19715a274f4)
 and getName should be used.

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {

PiotrZSL wrote:

exclude non-definitions here quickly to avoid processing same class multiple 
times.

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

for me oryginal version that used registerMatchers instead of visitor were way 
better, specially that there are matchers that could be used for this, or could 
be written.
And even for performance reasons it could be implemented in slightly better way 
by simply very quickly exclude all classes that do not derive from 
std::enable_shared_from_this.

If `boost::enable_shared_from_this` got same flaw, then this check should also 
support it. And this mean it maybe should be configurable.

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,120 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  Finder->addMatcher(translationUnitDecl(), this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::MatchResult &Result) {
+
+  class Visitor : public RecursiveASTVisitor {
+IncorrectEnableSharedFromThisCheck &Check;
+llvm::SmallPtrSet EnableSharedClassSet;
+
+  public:
+explicit Visitor(IncorrectEnableSharedFromThisCheck &Check)
+: Check(Check) {}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) {
+  for (const auto &Base : RDecl->bases()) {
+VisitCXXBaseSpecifier(Base, RDecl);
+  }
+  for (const auto &Base : RDecl->bases()) {
+const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+if (BaseType && BaseType->getQualifiedNameAsString() ==
+"std::enable_shared_from_this") {
+  EnableSharedClassSet.insert(RDecl->getCanonicalDecl());
+  return true;
+}
+  }
+  return true;
+}
+
+bool VisitCXXBaseSpecifier(const CXXBaseSpecifier &Base,
+   CXXRecordDecl *RDecl) {
+  const CXXRecordDecl *BaseType = Base.getType()->getAsCXXRecordDecl();
+  const clang::AccessSpecifier AccessSpec = Base.getAccessSpecifier();
+
+  if (BaseType &&
+  BaseType->getQualifiedNameAsString() == "enable_shared_from_this") {
+if (AccessSpec == clang::AS_public) {
+  const SourceLocation InsertLocation = Base.getBaseTypeLoc();
+  const FixItHint Hint = FixItHint::CreateInsertion(InsertLocation, 
"std::");

PiotrZSL wrote:

wrong, check if current class is std::enable_shared_from_this, someone may be 
using "using namespace std", and i don't see an issue with missing "std::", 
that should be separate generic check, and I think that there is being one 
created (or someone were working on it)

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2024-08-15 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

2024-08-15 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/102831
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

2024-08-15 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

Minor nits.

https://github.com/llvm/llvm-project/pull/102831
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -133,3 +133,18 @@ Options
 
When `true`, the check will allow conditional pointer conversions. Default
is `false`.
+
+.. option::  UseUpperCaseLiteralSuffix
+
+   When `true`, the replacements will use an uppercase literal suffix in the
+   provided fixes.

PiotrZSL wrote:

Add info about default value

https://github.com/llvm/llvm-project/pull/102831
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -133,3 +133,18 @@ Options
 
When `true`, the check will allow conditional pointer conversions. Default
is `false`.
+
+.. option::  UseUpperCaseLiteralSuffix
+
+   When `true`, the replacements will use an uppercase literal suffix in the
+   provided fixes.
+
+Example
+^^^
+
+.. code-block:: c++

PiotrZSL wrote:

Put it under an option not outside it, check descriptions for other check.

https://github.com/llvm/llvm-project/pull/102831
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -39,14 +39,22 @@ AST_MATCHER(Stmt, isNULLMacroExpansion) {
 }
 
 StringRef getZeroLiteralToCompareWithForType(CastKind CastExprKind,
- QualType Type,
- ASTContext &Context) {
+ QualType Type, ASTContext 
&Context,
+ bool UseUpperCaseLiteralSuffix) {
   switch (CastExprKind) {
-  case CK_IntegralToBoolean:
-return Type->isUnsignedIntegerType() ? "0u" : "0";
+  case CK_IntegralToBoolean: {
+if (Type->isUnsignedIntegerType())
+  return UseUpperCaseLiteralSuffix ? "0U" : "0u";

PiotrZSL wrote:

Note: You could just use StringRef::upper to avoid using 
UseUpperCaseLiteralSuffix multiple times.

https://github.com/llvm/llvm-project/pull/102831
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

2024-08-15 Thread Piotr Zegar via cfe-commits


@@ -108,6 +108,10 @@ Changes in existing checks
   ` check to
   remove `->`, when reduntant `get()` is removed.
 
+- Added option `UseUpperCaseLiteralSuffix` to 
:doc:`readablility-implicit-bool-conversion

PiotrZSL wrote:

Please follow above conversion, simply because its later easier to find check 
name.
Check release notes from previous release.

https://github.com/llvm/llvm-project/pull/102831
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] use upper case letters for bool conversion suffix (PR #102831)

2024-08-15 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/102831
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix modernize-use-std-format lit test signature (PR #102759)

2024-08-10 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.


https://github.com/llvm/llvm-project/pull/102759
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-08 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Yu could use isDerivedFrom, should do a trick

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)

2024-08-08 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

@martinboehme 
_"I suggested that if we wanted to change the default behavior, we should 
survey users to see what their opinions / preferences are. Have you done this? 
If not, I think the default behavior (when the option is not set) should remain 
unchanged."_

Nope, there is no reliable way to "survey users". Default behavior of checks 
changes every release. Some checks are getting limited, by excluding some use 
cases, some checks are getting extended. In this case situation is easy. Users 
will update Clang-tidy, and if check will report "new issues", they have an 
option, to fix them or look into release notes to find out what changed in 
check and then change configuration to revert back to previous behavior. This 
is how things were handled in past for other checks.

https://github.com/llvm/llvm-project/pull/94869
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)

2024-08-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL updated 
https://github.com/llvm/llvm-project/pull/94869

>From 51e3a4bb1601157416f543ba2a8ba193876ce595 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Tue, 16 Jul 2024 18:34:25 +
Subject: [PATCH 1/2] [clang-tidy] Fix smart pointers handling in
 bugprone-use-after-move

Removed custom handling of smart pointers and
added option IgnoreNonDerefSmartPtrs to restore
previous behavior if needed.
---
 .../clang-tidy/bugprone/UseAfterMoveCheck.cpp | 23 +--
 .../clang-tidy/bugprone/UseAfterMoveCheck.h   |  7 +-
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../checks/bugprone/use-after-move.rst| 14 +++-
 .../bugprone/use-after-move-smart-ptr.cpp | 59 +
 .../checkers/bugprone/use-after-move.cpp  | 65 ++-
 .../modernize/Inputs/smart-ptr/shared_ptr.h   |  2 +
 .../modernize/Inputs/smart-ptr/unique_ptr.h   | 42 
 8 files changed, 150 insertions(+), 67 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move-smart-ptr.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
index 8f4b5e8092ddaa..954b6324e96741 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -48,7 +48,7 @@ struct UseAfterMove {
 /// various internal helper functions).
 class UseAfterMoveFinder {
 public:
-  UseAfterMoveFinder(ASTContext *TheContext);
+  UseAfterMoveFinder(ASTContext *TheContext, bool IgnoreNonDerefSmartPtrs);
 
   // Within the given code block, finds the first use of 'MovedVariable' that
   // occurs after 'MovingCall' (the expression that performs the move). If a
@@ -71,6 +71,7 @@ class UseAfterMoveFinder {
   llvm::SmallPtrSetImpl *DeclRefs);
 
   ASTContext *Context;
+  const bool IgnoreNonDerefSmartPtrs;
   std::unique_ptr Sequence;
   std::unique_ptr BlockMap;
   llvm::SmallPtrSet Visited;
@@ -92,8 +93,9 @@ static StatementMatcher inDecltypeOrTemplateArg() {
hasAncestor(expr(hasUnevaluatedContext(;
 }
 
-UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)
-: Context(TheContext) {}
+UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext,
+   bool IgnoreNonDerefSmartPtrs)
+: Context(TheContext), IgnoreNonDerefSmartPtrs(IgnoreNonDerefSmartPtrs) {}
 
 std::optional
 UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
@@ -275,11 +277,13 @@ void UseAfterMoveFinder::getDeclRefs(
 DeclRefs](const ArrayRef Matches) {
   for (const auto &Match : Matches) {
 const auto *DeclRef = Match.getNodeAs("declref");
-const auto *Operator = 
Match.getNodeAs("operator");
 if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
   // Ignore uses of a standard smart pointer that don't dereference the
   // pointer.
-  if (Operator || !isStandardSmartPointer(DeclRef->getDecl())) {
+  const auto *Operator =
+  Match.getNodeAs("operator");
+  if (Operator || !IgnoreNonDerefSmartPtrs ||
+  !isStandardSmartPointer(DeclRef->getDecl())) {
 DeclRefs->insert(DeclRef);
   }
 }
@@ -429,6 +433,13 @@ static void emitDiagnostic(const Expr *MovingCall, const 
DeclRefExpr *MoveArg,
 << IsMove;
   }
 }
+UseAfterMoveCheck::UseAfterMoveCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IgnoreNonDerefSmartPtrs(Options.get("IgnoreNonDerefSmartPtrs", false)) {}
+
+void UseAfterMoveCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoreNonDerefSmartPtrs", IgnoreNonDerefSmartPtrs);
+}
 
 void UseAfterMoveCheck::registerMatchers(MatchFinder *Finder) {
   // try_emplace is a common maybe-moving function that returns a
@@ -520,7 +531,7 @@ void UseAfterMoveCheck::check(const 
MatchFinder::MatchResult &Result) {
   }
 
   for (Stmt *CodeBlock : CodeBlocks) {
-UseAfterMoveFinder Finder(Result.Context);
+UseAfterMoveFinder Finder(Result.Context, IgnoreNonDerefSmartPtrs);
 if (auto Use = Finder.find(CodeBlock, MovingCall, Arg))
   emitDiagnostic(MovingCall, Arg, *Use, this, Result.Context,
  determineMoveType(MoveDecl));
diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.h
index c14e8028474158..ace97c58c19661 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.h
@@ -20,13 +20,16 @@ namespace clang::tidy::bugprone {
 /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html
 class UseAfterMoveCheck : public ClangTidyCheck {
 public:
-  UseAfterMoveCheck(StringRef Name, ClangTidyContext *Context)
-  : C

[clang] [clang-tools-extra] [clang-tidy] bugprone-implicit-widening ignores unsigned consts (PR #101073)

2024-08-08 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Thats a good question.
@njames93 What do you thing, current tests are sufficient ?

https://github.com/llvm/llvm-project/pull/101073
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] clang-tidy: readability-redundant-smartptr-get does not remove (#97964) (PR #100177)

2024-08-08 Thread Piotr Zegar via cfe-commits


@@ -104,6 +104,10 @@ New check aliases
 Changes in existing checks
 ^^
 
+- Improved :doc:`readability-redundant-smartptr-get
+  ` check to
+  remove '->', when reduntant get() is removed.

PiotrZSL wrote:

```suggestion
  remove `->`, when reduntant `get()` is removed.
```

https://github.com/llvm/llvm-project/pull/100177
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] clang-tidy: readability-redundant-smartptr-get does not remove (#97964) (PR #100177)

2024-08-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.


https://github.com/llvm/llvm-project/pull/100177
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy][cppcoreguidelines-missing-std-forward] Do not warn when the parameter is used in a `static_cast`. (PR #99477)

2024-08-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

storeOptions method is missing, and please rebase.
Except that looks fine.

https://github.com/llvm/llvm-project/pull/99477
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] create new clang-tidy check to add namespaces to symbol references (PR #70621)

2024-08-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

Bump. Please rebase.
And please remove unnecessary diagnostic, its makes harder to understand what 
is part of a check, and what isn't

https://github.com/llvm/llvm-project/pull/70621
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] create new clang-tidy check to add namespaces to symbol references (PR #70621)

2024-08-08 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,220 @@
+// RUN: %check_clang_tidy %s readability-use-explicit-namespaces %t
+
+namespace foo {
+void doSomething() {}
+
+template  void doTemplateThing(T &value) { value = value * 2; }
+
+struct StructTest {
+  int StructIntMember;
+};
+
+class ClassTest {
+public:
+  int ClassIntMember;
+  typedef int ClassTypeDefMember;
+};
+
+enum EnumTest {
+  EnumValueOne,
+  EnumValueTwo,
+  EnumValueThree,
+};
+
+template  class TemplateClassTest {
+public:
+  T TemplatizedData;
+};
+
+typedef int TypeDefTest;
+typedef void (*event_callback)(ClassTest &value);
+
+} // namespace foo
+
+class OutsideNamespace : public foo::ClassTest {
+public:
+  ClassTypeDefMember UseTypeFromParentOk;
+};
+
+OutsideNamespace::ClassTypeDefMember UseTypeFromClassInheritedFromParentOk;
+
+foo::ClassTest AlreadyQualifiedOk() {
+  foo::doSomething();
+  foo::StructTest first;
+  foo::ClassTest second;
+  second.ClassIntMember = 55;
+  foo::EnumTest picked = foo::EnumValueThree;
+  foo::TemplateClassTest data;
+  foo::TemplateClassTest<
+  foo::TemplateClassTest>>
+  dataNested;
+  foo::StructTest many[8];
+  foo::TypeDefTest integer = 22;
+  foo::doTemplateThing(integer);
+  foo::doTemplateThing(integer);
+  struct foo::StructTest fooStruct;
+  auto lambdaReturn = []() -> foo::ClassTest { return foo::ClassTest(); };
+  auto lambdaTypes = [](foo::StructTest &start,
+foo::StructTest *end) -> foo::ClassTest {
+return foo::ClassTest();
+  };
+
+  foo::ClassTest ConstructOnStack;
+  new foo::ClassTest;
+  foo::TemplateClassTest ConstructTemplateOnStack;
+  new foo::TemplateClassTest;
+  foo::ClassTest();
+  new foo::ClassTest();
+  foo::TemplateClassTest();
+  new foo::TemplateClassTest();
+  return foo::ClassTest();
+}
+
+namespace foo {
+ClassTest InsideNamespaceFooOk() {
+  doSomething();
+  StructTest first;
+  ClassTest second;
+  second.ClassIntMember = 55;
+  EnumTest picked = EnumValueThree;
+  TemplateClassTest data;
+  TemplateClassTest>> 
dataNested;
+  StructTest many[8];
+  TypeDefTest integer = 22;
+  doTemplateThing(integer);
+  doTemplateThing(integer);
+  struct StructTest fooStruct;
+  auto lambdaReturn = []() -> ClassTest { return ClassTest(); };
+  auto lambdaTypes = [](StructTest &start, StructTest *end) -> ClassTest {
+return ClassTest();
+  };
+
+  ClassTest ConstructOnStack;
+  new ClassTest;
+  TemplateClassTest ConstructTemplateOnStack;
+  new TemplateClassTest;
+  ClassTest();
+  new ClassTest();
+  TemplateClassTest();
+  new TemplateClassTest();
+  return ClassTest();
+}
+} // namespace foo
+
+using namespace foo;
+
+ClassTest FixAllMissingFoo()
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: Missing namespace qualifiers
+// CHECK-FIXES:  foo::
+{
+  doSomething();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Missing namespace qualifiers 
foo::
+  // CHECK-FIXES:  foo::
+  StructTest first;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Missing namespace qualifiers 
foo::
+  // CHECK-FIXES:  foo::
+  ClassTest second;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Missing namespace qualifiers 
foo::
+  // CHECK-FIXES:  foo::
+  second.ClassIntMember = 55;
+  EnumTest picked = EnumValueThree;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Missing namespace qualifiers 
foo::

PiotrZSL wrote:

warnings should start with lower caps.

https://github.com/llvm/llvm-project/pull/70621
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] create new clang-tidy check to add namespaces to symbol references (PR #70621)

2024-08-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/70621
___
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 bugprone-move-shared-pointer-contents check. (PR #67467)

2024-08-08 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,142 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+namespace {
+
+// Reports whether the QualType matches the inner matcher, which is expected 
to be
+// matchesAnyListedName. The QualType is expected to either point to a 
RecordDecl
+// (for concrete types) or an ElaboratedType (for dependent ones).
+AST_MATCHER_P(QualType, isSharedPointer,
+  clang::ast_matchers::internal::Matcher, InnerMatcher) 
{
+  if (const auto *RD = Node.getTypePtr()->getAsCXXRecordDecl(); RD != nullptr) 
{
+return InnerMatcher.matches(*RD, Finder, Builder);
+  } else if (const auto *ED = Node.getTypePtr()->getAs();
+ ED != nullptr) {
+if (const auto *TS = ED->getNamedType()
+ .getTypePtr()
+ ->getAs();
+TS != nullptr) {
+  return InnerMatcher.matches(*TS->getTemplateName().getAsTemplateDecl(),
+  Finder, Builder);
+}
+  }
+
+  return false;
+}
+
+} // namespace
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", 
"::std::shared_ptr;::boost::shared_pointer"))) {}
+
+void MoveSharedPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  auto isStdMove = callee(functionDecl(hasAnyName("::std::move", 
"::std::forward")));
+
+  auto resolvedType = callExpr(anyOf(
+  // Resolved type, direct move.
+  callExpr(
+  isStdMove,
+  hasArgument(
+  0,
+  cxxOperatorCallExpr(
+  hasOverloadedOperatorName("*"),
+  hasDescendant(declRefExpr(hasType(qualType(isSharedPointer(
+  
matchers::matchesAnyListedName(SharedPointerClasses)),
+  callee(cxxMethodDecl()
+  .bind("call"),
+  // Resolved type, move out of get().
+  callExpr(
+  isStdMove,
+  hasArgument(
+  0, unaryOperator(
+ hasOperatorName("*"),
+ hasUnaryOperand(allOf(
+ hasDescendant(declRefExpr(hasType(qualType(

PiotrZSL wrote:

same issue here as above

https://github.com/llvm/llvm-project/pull/67467
___
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 bugprone-move-shared-pointer-contents check. (PR #67467)

2024-08-08 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,142 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+namespace {
+
+// Reports whether the QualType matches the inner matcher, which is expected 
to be
+// matchesAnyListedName. The QualType is expected to either point to a 
RecordDecl
+// (for concrete types) or an ElaboratedType (for dependent ones).
+AST_MATCHER_P(QualType, isSharedPointer,
+  clang::ast_matchers::internal::Matcher, InnerMatcher) 
{
+  if (const auto *RD = Node.getTypePtr()->getAsCXXRecordDecl(); RD != nullptr) 
{
+return InnerMatcher.matches(*RD, Finder, Builder);
+  } else if (const auto *ED = Node.getTypePtr()->getAs();
+ ED != nullptr) {
+if (const auto *TS = ED->getNamedType()
+ .getTypePtr()
+ ->getAs();
+TS != nullptr) {
+  return InnerMatcher.matches(*TS->getTemplateName().getAsTemplateDecl(),
+  Finder, Builder);
+}
+  }
+
+  return false;
+}
+
+} // namespace
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", 
"::std::shared_ptr;::boost::shared_pointer"))) {}
+
+void MoveSharedPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  auto isStdMove = callee(functionDecl(hasAnyName("::std::move", 
"::std::forward")));
+
+  auto resolvedType = callExpr(anyOf(
+  // Resolved type, direct move.
+  callExpr(
+  isStdMove,
+  hasArgument(
+  0,
+  cxxOperatorCallExpr(
+  hasOverloadedOperatorName("*"),
+  hasDescendant(declRefExpr(hasType(qualType(isSharedPointer(
+  
matchers::matchesAnyListedName(SharedPointerClasses)),
+  callee(cxxMethodDecl()
+  .bind("call"),
+  // Resolved type, move out of get().
+  callExpr(
+  isStdMove,
+  hasArgument(
+  0, unaryOperator(
+ hasOperatorName("*"),
+ hasUnaryOperand(allOf(
+ hasDescendant(declRefExpr(hasType(qualType(
+ isSharedPointer(matchers::matchesAnyListedName(
+ SharedPointerClasses)),
+ cxxMemberCallExpr(
+ callee(cxxMethodDecl(hasName("get")
+  .bind("get_call")));
+
+  Finder->addMatcher(resolvedType, this);
+
+  auto isStdMoveUnresolved = callee(unresolvedLookupExpr(
+  
hasAnyDeclaration(namedDecl(hasUnderlyingDecl(hasName("::std::move"));
+
+  auto unresolvedType = callExpr(anyOf(
+  // Unresolved type, direct move.
+  callExpr(
+  isStdMoveUnresolved,
+  hasArgument(0, unaryOperator(
+ hasOperatorName("*"),
+ hasUnaryOperand(declRefExpr(hasType(qualType(
+ 
isSharedPointer(matchers::matchesAnyListedName(
+ SharedPointerClasses)
+  .bind("unresolved_call"),
+
+  // Annoyingly, the declRefExpr in the unresolved-move-of-get() case
+  // is of  rather than shared_ptr, so we have to
+  // just fetch the variable. This does leave a gap where a temporary
+  // shared_ptr wouldn't be caught, but moving out of a temporary
+  // shared pointer is a truly wild thing to do so it should be okay.
+  callExpr(isStdMoveUnresolved,
+   hasArgument(
+   0, unaryOperator(
+  hasOperatorName("*"),
+  hasDescendant(cxxDependentScopeMemberExpr(
+  hasMemberName("get"))),
+  
hasDescendant(declRefExpr(to(varDecl(hasType(qualType(
+  isSharedPointer(matchers::matchesAnyListedName(
+  SharedPointerClasses)))
+  .bind("unresolved_get_call")));
+
+  Finder->addMatcher(unresolvedType, this);
+}
+
+void MoveSharedPointerContentsCheck::check(
+const MatchFinder::MatchResult &Result) {
+  clang::SourceLocation Loc;
+  if (const auto *UnresolvedCall =
+ 

[clang-tools-extra] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2024-08-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/67467
___
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 bugprone-move-shared-pointer-contents check. (PR #67467)

2024-08-08 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,142 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+namespace {
+
+// Reports whether the QualType matches the inner matcher, which is expected 
to be
+// matchesAnyListedName. The QualType is expected to either point to a 
RecordDecl
+// (for concrete types) or an ElaboratedType (for dependent ones).
+AST_MATCHER_P(QualType, isSharedPointer,
+  clang::ast_matchers::internal::Matcher, InnerMatcher) 
{
+  if (const auto *RD = Node.getTypePtr()->getAsCXXRecordDecl(); RD != nullptr) 
{
+return InnerMatcher.matches(*RD, Finder, Builder);
+  } else if (const auto *ED = Node.getTypePtr()->getAs();
+ ED != nullptr) {
+if (const auto *TS = ED->getNamedType()
+ .getTypePtr()
+ ->getAs();
+TS != nullptr) {
+  return InnerMatcher.matches(*TS->getTemplateName().getAsTemplateDecl(),
+  Finder, Builder);
+}
+  }
+
+  return false;
+}
+
+} // namespace
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", 
"::std::shared_ptr;::boost::shared_pointer"))) {}
+
+void MoveSharedPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  auto isStdMove = callee(functionDecl(hasAnyName("::std::move", 
"::std::forward")));
+
+  auto resolvedType = callExpr(anyOf(
+  // Resolved type, direct move.
+  callExpr(
+  isStdMove,
+  hasArgument(
+  0,
+  cxxOperatorCallExpr(
+  hasOverloadedOperatorName("*"),
+  hasDescendant(declRefExpr(hasType(qualType(isSharedPointer(

PiotrZSL wrote:

this has hasDescendant may not work properly here, as this callExpr would match:
```
std::move(*getSomething(objec1, shared_ptr_obj)
```

Instead you could check type of object used for operator *:

```
cxxOperatorCallExpr(callee(ofClass(matchers::matchesAnyListedName(SharedPointerClasses)))
```

https://github.com/llvm/llvm-project/pull/67467
___
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 bugprone-move-shared-pointer-contents check. (PR #67467)

2024-08-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

Matchers need simplification, mainly that hasDescendant and declRefExpr need to 
go

https://github.com/llvm/llvm-project/pull/67467
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(

PiotrZSL wrote:

`unless(isExpansionInSystemHeader())`

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-public-enable-shared-from-this");

PiotrZSL wrote:

Or just call it bugprone-non-public-enable-shared-from-this

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -98,6 +98,11 @@ Improvements to clang-tidy
 New checks
 ^^
 
+- New :doc:`bugprone-public-enable-shared-from-this
+  ` check.
+
+  Checks if a class deriving from enable_shared_from_this has public access 
specifiers, because otherwise the program will crash when shared_from_this is 
called.

PiotrZSL wrote:

again, wrong. "Check if class publicly derive from std::enable_shared_from_this 
..."
And wrap on 80 column.

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,26 @@
+.. title:: clang-tidy - bugprone-public-enable-shared-from-this
+
+bugprone-public-enable-shared-from-this
+===
+
+Checks that classes/structs inheriting from ``std::enable_shared_from_this`` 
derive it with the ``public`` access specifier. If not, then issue a FixItHint 
that can be applied.
+
+Consider the following code:
+.. code-block:: c++
+#include 
+
+class BadExample : std::enable_shared_from_this {
+// warning: class BadExample is not public even though it's derived 
from std::enable_shared_from_this [bugprone-public-enable-shared-from-this]
+// will insert the public keyword if -fix is applied 
+public:
+BadExample* foo() { return shared_from_this().get(); }
+void bar() { return; }
+};
+
+void using_not_public() {
+auto bad_example = std::make_shared();
+auto* b_ex = bad_example->foo();
+b_ex->bar();
+}
+
+When ``using_not_public()`` is called, this code will crash.

PiotrZSL wrote:

no it won't crash, it will thrown `std::bad_weak_ptr`, if application didin't 
implement proper exception handling then it would crash.

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s bugprone-public-enable-shared-from-this %t -- --
+
+namespace std {
+
+template  class enable_shared_from_this {};
+
+class BadExample : enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class BadExample is not public 
even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public enable_shared_from_this
+
+class Bad2Example : std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class Bad2Example is not 
public even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+
+class GoodExample : public enable_shared_from_this {
+};
+
+struct BaseClass {
+
+void print() {
+(void) State;
+(void) Requester;
+}
+bool State;
+int Requester;
+};
+
+class InheritPrivateBaseClass : BaseClass {
+public:
+void additionalFunction() {
+(void) ID;
+}
+private: 
+int ID;
+};
+
+class InheritPublicBaseClass : public BaseClass {
+public:
+void additionalFunction() {
+(void) ID;
+}
+private: 
+int ID;
+};

PiotrZSL wrote:

Those classes does not add anything, so maybe remove them, or you missing 
something here

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,33 @@
+//===--- PublicEnableSharedFromThisCheck.h - clang-tidy -*- 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PUBLICENABLESHAREDFROMTHISCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_PUBLICENABLESHAREDFROMTHISCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::bugprone {
+
+/// Checks if a class deriving from enable_shared_from_this has public access 
specifiers, because otherwise the program will crash when shared_from_this is 
called.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/bugprone/public-enable-shared-from-this.html
+class PublicEnableSharedFromThisCheck : public ClangTidyCheck {
+public:
+  PublicEnableSharedFromThisCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus;

PiotrZSL wrote:

CPlusPlus11

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s bugprone-public-enable-shared-from-this %t -- --
+
+namespace std {
+
+template  class enable_shared_from_this {};
+
+class BadExample : enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class BadExample is not public 
even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public enable_shared_from_this
+
+class Bad2Example : std::enable_shared_from_this {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class Bad2Example is not 
public even though it's derived from std::enable_shared_from_this 
[bugprone-public-enable-shared-from-this]
+// CHECK-FIXES: public std::enable_shared_from_this
+

PiotrZSL wrote:

add test:
class Bad3Example : private std::enable_shared_from_this {};

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");
+  diag(EnableSharedClassDecl->getLocation(), "class %0 is not 
public even though it's derived from std::enable_shared_from_this", 
DiagnosticIDs::Warning)

PiotrZSL wrote:

this warning message doesn't make sense. there is no such thing like 
public/private class. This public/private inheritance.

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");
+  diag(EnableSharedClassDecl->getLocation(), "class %0 is not 
public even though it's derived from std::enable_shared_from_this", 
DiagnosticIDs::Warning)
+  << EnableSharedClassDecl->getNameAsString()

PiotrZSL wrote:

no need for getNameAsString

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(

PiotrZSL wrote:

consider excluding system headers, to speed things up

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(
+  cxxBaseSpecifier(unless(isPublic()), 
+  hasType(
+  cxxRecordDecl(
+  hasName("::std::enable_shared_from_this"
+  )
+  )
+  .bind("not-public-enable-shared"), this);
+  }
+
+  void PublicEnableSharedFromThisCheck::check(const MatchFinder::MatchResult 
&result) {
+  const auto *EnableSharedClassDecl =
+  result.Nodes.getNodeAs("not-public-enable-shared");
+
+  for (const auto &Base : EnableSharedClassDecl->bases()) {
+  const auto *BaseType = Base.getType()->getAsCXXRecordDecl();
+  if (BaseType && BaseType->getQualifiedNameAsString() == 
"std::enable_shared_from_this") {
+  SourceLocation InsertLoc = Base.getBeginLoc();
+  FixItHint Hint = FixItHint::CreateInsertion(InsertLoc, "public 
");

PiotrZSL wrote:

what if it already got explicit "private", then it will end up with "private 
public" and thats invalid

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s bugprone-public-enable-shared-from-this %t -- --
+
+namespace std {
+
+template  class enable_shared_from_this {};
+

PiotrZSL wrote:

std namespace should end here

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,45 @@
+//===--- PublicEnableSharedFromThisCheck.cpp - clang-tidy 
-===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "PublicEnableSharedFromThisCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+  void PublicEnableSharedFromThisCheck::registerMatchers(MatchFinder 
*match_finder) {
+  match_finder->addMatcher(
+  cxxRecordDecl(
+  hasAnyBase(

PiotrZSL wrote:

`hasAnyBase(cxxBaseSpecifier(...).bind("base"))`, check if this works, maybe 
with that you could avoid having loop in a check method

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

I'm fine with idea behind this check. Just few fixes are needed.

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits


@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-public-enable-shared-from-this");

PiotrZSL wrote:

name should be more a "non-public", as check should tell whats wrong.
i would call this check bugprone-incorrect-enable-shared-from-this, and then 
you could also check other constructions in future like:
```
class Bad2Example : enable_shared_from_this {};
```

https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Create bugprone-public-enable-shared-from-this check (PR #102299)

2024-08-07 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/102299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-08-02 Thread Piotr Zegar via cfe-commits
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,137 @@
+//===--- ProBoundsAvoidUncheckedContainerAccesses.cpp - clang-tidy 
===//
+//
+// 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: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ProBoundsAvoidUncheckedContainerAccesses.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::cppcoreguidelines {
+
+static constexpr std::array SubscriptDefaultExclusions = {
+llvm::StringRef("::std::map"), llvm::StringRef("::std::unordered_map"),
+llvm::StringRef("::std::flat_map")};
+
+ProBoundsAvoidUncheckedContainerAccesses::
+ProBoundsAvoidUncheckedContainerAccesses(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {
+
+  SubscriptExcludedClasses = clang::tidy::utils::options::parseStringList(
+  Options.get("ExcludeClasses", ""));
+  SubscriptExcludedClasses.insert(SubscriptExcludedClasses.end(),
+  SubscriptDefaultExclusions.begin(),
+  SubscriptDefaultExclusions.end());
+}
+
+void ProBoundsAvoidUncheckedContainerAccesses::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+
+  if (SubscriptExcludedClasses.size() == SubscriptDefaultExclusions.size()) {
+Options.store(Opts, "ExcludeClasses", "");
+return;
+  }
+
+  // Sum up the sizes of the defaults ( + semicolons), so we can remove them
+  // from the saved options
+  size_t DefaultsStringLength = std::transform_reduce(
+  SubscriptDefaultExclusions.begin(), SubscriptDefaultExclusions.end(),
+  SubscriptDefaultExclusions.size(), std::plus<>(),
+  [](llvm::StringRef Name) { return Name.size(); });
+
+  std::string Serialized = clang::tidy::utils::options::serializeStringList(
+  SubscriptExcludedClasses);
+
+  Options.store(Opts, "ExcludeClasses",
+Serialized.substr(0, Serialized.size() - 
DefaultsStringLength));
+}
+
+static const CXXMethodDecl *
+findAlternative(const CXXMethodDecl *MatchedOperator) {
+  const CXXRecordDecl *Parent = MatchedOperator->getParent();
+  const QualType SubscriptThisObjType =
+  MatchedOperator->getFunctionObjectParameterReferenceType();
+
+  for (const CXXMethodDecl *Method : Parent->methods()) {
+// Require 'Method' to be as accessible as 'MatchedOperator' or more
+if (MatchedOperator->getAccess() < Method->getAccess())
+  continue;
+
+if (MatchedOperator->isConst() != Method->isConst())
+  continue;
+
+const QualType AtThisObjType =
+Method->getFunctionObjectParameterReferenceType();
+if (SubscriptThisObjType != AtThisObjType)
+  continue;
+
+const bool CorrectName = Method->getNameInfo().getAsString() == "at";
+if (!CorrectName)
+  continue;
+
+const bool SameReturnType =
+Method->getReturnType() == MatchedOperator->getReturnType();
+if (!SameReturnType)
+  continue;
+
+const bool SameNumberOfArguments =
+Method->getNumParams() == MatchedOperator->getNumParams();
+if (!SameNumberOfArguments)
+  continue;
+
+for (unsigned ArgInd = 0; ArgInd < Method->getNumParams(); ArgInd++) {
+  const bool SameArgType =
+  Method->parameters()[ArgInd]->getOriginalType() ==
+  MatchedOperator->parameters()[ArgInd]->getOriginalType();
+  if (!SameArgType)
+continue;
+}
+
+return Method;
+  }
+  return nullptr;
+}
+
+void ProBoundsAvoidUncheckedContainerAccesses::registerMatchers(
+MatchFinder *Finder) {
+  Finder->addMatcher(
+  mapAnyOf(cxx

[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)

2024-08-01 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Rebase, bump

https://github.com/llvm/llvm-project/pull/94869
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)

2024-08-01 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL updated 
https://github.com/llvm/llvm-project/pull/94869

>From 51e3a4bb1601157416f543ba2a8ba193876ce595 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Tue, 16 Jul 2024 18:34:25 +
Subject: [PATCH] [clang-tidy] Fix smart pointers handling in
 bugprone-use-after-move

Removed custom handling of smart pointers and
added option IgnoreNonDerefSmartPtrs to restore
previous behavior if needed.
---
 .../clang-tidy/bugprone/UseAfterMoveCheck.cpp | 23 +--
 .../clang-tidy/bugprone/UseAfterMoveCheck.h   |  7 +-
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../checks/bugprone/use-after-move.rst| 14 +++-
 .../bugprone/use-after-move-smart-ptr.cpp | 59 +
 .../checkers/bugprone/use-after-move.cpp  | 65 ++-
 .../modernize/Inputs/smart-ptr/shared_ptr.h   |  2 +
 .../modernize/Inputs/smart-ptr/unique_ptr.h   | 42 
 8 files changed, 150 insertions(+), 67 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move-smart-ptr.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
index 8f4b5e8092dda..954b6324e9674 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -48,7 +48,7 @@ struct UseAfterMove {
 /// various internal helper functions).
 class UseAfterMoveFinder {
 public:
-  UseAfterMoveFinder(ASTContext *TheContext);
+  UseAfterMoveFinder(ASTContext *TheContext, bool IgnoreNonDerefSmartPtrs);
 
   // Within the given code block, finds the first use of 'MovedVariable' that
   // occurs after 'MovingCall' (the expression that performs the move). If a
@@ -71,6 +71,7 @@ class UseAfterMoveFinder {
   llvm::SmallPtrSetImpl *DeclRefs);
 
   ASTContext *Context;
+  const bool IgnoreNonDerefSmartPtrs;
   std::unique_ptr Sequence;
   std::unique_ptr BlockMap;
   llvm::SmallPtrSet Visited;
@@ -92,8 +93,9 @@ static StatementMatcher inDecltypeOrTemplateArg() {
hasAncestor(expr(hasUnevaluatedContext(;
 }
 
-UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)
-: Context(TheContext) {}
+UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext,
+   bool IgnoreNonDerefSmartPtrs)
+: Context(TheContext), IgnoreNonDerefSmartPtrs(IgnoreNonDerefSmartPtrs) {}
 
 std::optional
 UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
@@ -275,11 +277,13 @@ void UseAfterMoveFinder::getDeclRefs(
 DeclRefs](const ArrayRef Matches) {
   for (const auto &Match : Matches) {
 const auto *DeclRef = Match.getNodeAs("declref");
-const auto *Operator = 
Match.getNodeAs("operator");
 if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
   // Ignore uses of a standard smart pointer that don't dereference the
   // pointer.
-  if (Operator || !isStandardSmartPointer(DeclRef->getDecl())) {
+  const auto *Operator =
+  Match.getNodeAs("operator");
+  if (Operator || !IgnoreNonDerefSmartPtrs ||
+  !isStandardSmartPointer(DeclRef->getDecl())) {
 DeclRefs->insert(DeclRef);
   }
 }
@@ -429,6 +433,13 @@ static void emitDiagnostic(const Expr *MovingCall, const 
DeclRefExpr *MoveArg,
 << IsMove;
   }
 }
+UseAfterMoveCheck::UseAfterMoveCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IgnoreNonDerefSmartPtrs(Options.get("IgnoreNonDerefSmartPtrs", false)) {}
+
+void UseAfterMoveCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoreNonDerefSmartPtrs", IgnoreNonDerefSmartPtrs);
+}
 
 void UseAfterMoveCheck::registerMatchers(MatchFinder *Finder) {
   // try_emplace is a common maybe-moving function that returns a
@@ -520,7 +531,7 @@ void UseAfterMoveCheck::check(const 
MatchFinder::MatchResult &Result) {
   }
 
   for (Stmt *CodeBlock : CodeBlocks) {
-UseAfterMoveFinder Finder(Result.Context);
+UseAfterMoveFinder Finder(Result.Context, IgnoreNonDerefSmartPtrs);
 if (auto Use = Finder.find(CodeBlock, MovingCall, Arg))
   emitDiagnostic(MovingCall, Arg, *Use, this, Result.Context,
  determineMoveType(MoveDecl));
diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.h
index c14e802847415..ace97c58c1966 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.h
@@ -20,13 +20,16 @@ namespace clang::tidy::bugprone {
 /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html
 class UseAfterMoveCheck : public ClangTidyCheck {
 public:
-  UseAfterMoveCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidy

[clang-tools-extra] [clang-tidy] Fix handling --driver-mode= (PR #66553)

2024-08-01 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Rebased, bump

https://github.com/llvm/llvm-project/pull/66553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix handling --driver-mode= (PR #66553)

2024-08-01 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL updated 
https://github.com/llvm/llvm-project/pull/66553

>From 8c9f81796c93d4309eb8711ff35d897b2088dbe4 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Fri, 15 Sep 2023 21:39:17 +
Subject: [PATCH 1/3] [clang-tidy] Fix handling --driver-mode=

Driver mode passed as an extra argument (command line or config)
were not utilized for removing invalid arguments in
stripPositionalArgs function, and even if passed as config
driver mode were not used for dependency file striping
leading to invalid handling of -MD. Additionally driver mode
were needed even if user already added cl.exe after --.
---
 .../clang-tidy/tool/ClangTidyMain.cpp | 96 ++-
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 +
 .../clang-tidy/infrastructure/driver-mode.cpp | 57 +++
 3 files changed, 157 insertions(+), 1 deletion(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/infrastructure/driver-mode.cpp

diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index d42dafa8ffc36..95ee4894a91ca 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -19,6 +19,7 @@
 #include "../ClangTidyForceLinker.h"
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/PluginLoader.h"
@@ -26,7 +27,11 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/WithColor.h"
+#include 
+#include 
 #include 
+#include 
+#include 
 
 using namespace clang::tooling;
 using namespace llvm;
@@ -476,7 +481,7 @@ static StringRef closest(StringRef Value, const StringSet<> 
&Allowed) {
   return Closest;
 }
 
-static constexpr StringLiteral VerifyConfigWarningEnd = " [-verify-config]\n";
+static constexpr StringRef VerifyConfigWarningEnd = " [-verify-config]\n";
 
 static bool verifyChecks(const StringSet<> &AllChecks, StringRef CheckGlob,
  StringRef Source) {
@@ -551,9 +556,91 @@ static llvm::IntrusiveRefCntPtr 
createBaseFS() {
   return BaseFS;
 }
 
+static llvm::Expected
+recreateOptionsParserIfNeeded(llvm::ArrayRef Args,
+  llvm::Expected 
OptionsParser,
+  const ClangTidyOptions &EffectiveOptions) {
+
+  auto DoubleDashIt = std::find(Args.begin(), Args.end(), StringRef("--"));
+
+  // Exit if we don't have any compiler arguments
+  if (DoubleDashIt == Args.end() || Args.empty() ||
+  Args.back() == StringRef("--"))
+return OptionsParser;
+
+  auto IsDriverMode = [](StringRef Argument) {
+return Argument.startswith("--driver-mode=");
+  };
+
+  // Exit if --driver-mode= is explicitly passed in compiler arguments
+  if (Args.end() !=
+  std::find_if(std::next(DoubleDashIt), Args.end(), IsDriverMode))
+return OptionsParser;
+
+  std::vector CommandArguments(std::next(DoubleDashIt),
+Args.end());
+
+  // Add clang-tool as program name if not added
+  if (CommandArguments.empty() ||
+  llvm::StringRef(CommandArguments.front()).startswith("-"))
+CommandArguments.insert(CommandArguments.begin(), "clang-tool");
+
+  // Apply --extra-arg and --extra-arg-before to compiler arguments
+  CommandArguments =
+  OptionsParser->getArgumentsAdjuster()(CommandArguments, "");
+
+  // Apply ExtraArgsBefore from clang-tidy config to compiler arguments
+  if (EffectiveOptions.ExtraArgsBefore)
+CommandArguments = tooling::getInsertArgumentAdjuster(
+*EffectiveOptions.ExtraArgsBefore,
+tooling::ArgumentInsertPosition::BEGIN)(CommandArguments, "");
+
+  // Apply ExtraArgs from clang-tidy config to compiler arguments
+  if (EffectiveOptions.ExtraArgs)
+CommandArguments = tooling::getInsertArgumentAdjuster(
+*EffectiveOptions.ExtraArgs,
+tooling::ArgumentInsertPosition::END)(CommandArguments, "");
+
+  // Check if now we have --driver-mode=
+  auto DriverModeIt = std::find_if(CommandArguments.begin(),
+   CommandArguments.end(), IsDriverMode);
+  if (DriverModeIt == CommandArguments.end()) {
+// Try to detect and add --driver-mode=
+std::string ExeName = CommandArguments.front();
+tooling::addTargetAndModeForProgramName(CommandArguments, ExeName);
+DriverModeIt = std::find_if(CommandArguments.begin(),
+CommandArguments.end(), IsDriverMode);
+  }
+
+  // Exit if there is no --driver-mode= at this stage
+  if (DriverModeIt == CommandArguments.end())
+return OptionsParser;
+
+  std::vector NewArgs(Args.begin(), Args.end());
+
+  // Find place to insert --driver-mode= into new args, best after program 
name.
+  auto InsertIt =
+  NewArgs.begin() + std::distance(Args.begin(), DoubleDashIt) + 1U;
+  if (!StringRef(*Insert

[clang] [clang-tools-extra] [clang-tidy] bugprone-implicit-widening ignores unsigned consts (PR #101073)

2024-08-01 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

Changes made to AST classes should be tested in clang also.
Mainly here clang/test/AST/

https://github.com/llvm/llvm-project/pull/101073
___
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] Add support for bsl::optional (PR #101450)

2024-08-01 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.

I'm fine with change, but at the same time this check should be made 
configurable.
Also please update check documentation before committing.

https://github.com/llvm/llvm-project/pull/101450
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix crash in C language in readability-non-const-parameter (PR #100461)

2024-07-25 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL closed 
https://github.com/llvm/llvm-project/pull/100461
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Fix crash in modernize-use-ranges (PR #100427)

2024-07-25 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL closed 
https://github.com/llvm/llvm-project/pull/100427
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Fix crash in modernize-use-ranges (PR #100427)

2024-07-25 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Fix is reported to work, so lets merge it.

https://github.com/llvm/llvm-project/pull/100427
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix crash in C language in readability-non-const-parameter (PR #100461)

2024-07-24 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL created 
https://github.com/llvm/llvm-project/pull/100461

Fix crash that happen when redeclaration got
different number of parameters than definition.

No release notes, as this will be backported.

Fixes #100340



>From 253e132b022a4f2b454869eed416fd6966f35dd3 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Wed, 24 Jul 2024 20:20:37 +
Subject: [PATCH] [clang-tidy] Fix crash in C language in
 readability-non-const-parameter

Fix crash that happen when redeclaration got
diffrent number of parameters than definition.

Fixes #100340
---
 .../clang-tidy/readability/NonConstParameterCheck.cpp |  5 -
 .../checkers/readability/non-const-parameter.c| 11 +++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/non-const-parameter.c

diff --git 
a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
index 95a3a5165e2e8..43b69a24bdb16 100644
--- a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
@@ -157,9 +157,12 @@ void NonConstParameterCheck::diagnoseNonConstParameters() {
 if (!Function)
   continue;
 unsigned Index = Par->getFunctionScopeIndex();
-for (FunctionDecl *FnDecl : Function->redecls())
+for (FunctionDecl *FnDecl : Function->redecls()) {
+  if (FnDecl->getNumParams() <= Index)
+continue;
   Fixes.push_back(FixItHint::CreateInsertion(
   FnDecl->getParamDecl(Index)->getBeginLoc(), "const "));
+}
 
 diag(Par->getLocation(), "pointer parameter '%0' can be pointer to const")
 << Par->getName() << Fixes;
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/non-const-parameter.c 
b/clang-tools-extra/test/clang-tidy/checkers/readability/non-const-parameter.c
new file mode 100644
index 0..db50467f3dd94
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/non-const-parameter.c
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s readability-non-const-parameter %t
+
+static int f();
+
+int f(p)
+  int *p;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: pointer parameter 'p' can be 
pointer to const [readability-non-const-parameter]
+// CHECK-FIXES: {{^}}  const int *p;{{$}}
+{
+return *p;
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] clang-tidy: readability-redundant-smartptr-get does not remove (#97964) (PR #100177)

2024-07-24 Thread Piotr Zegar via cfe-commits


@@ -104,6 +104,296 @@ New check aliases
 Changes in existing checks
 ^^
 
+- Improved :doc:`bugprone-assert-side-effect
+  ` check by detecting side
+  effect from calling a method with non-const reference parameters.

PiotrZSL wrote:

still incorrectly rebased code, that stuff shoudn't be here
just rebase your changes on top of main branch, and then do force push, or 
cleanup this fill manually

https://github.com/llvm/llvm-project/pull/100177
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Fix crash in modernize-use-ranges (PR #100427)

2024-07-24 Thread Piotr Zegar via cfe-commits


@@ -123,32 +108,34 @@ makeMatcherPair(StringRef State, const 
UseRangesCheck::Indexes &Indexes,
 }
 
 void UseRangesCheck::registerMatchers(MatchFinder *Finder) {
-  Replaces = getReplacerMap();
+  auto Replaces = getReplacerMap();
   ReverseDescriptor = getReverseDescriptor();
   auto BeginEndNames = getFreeBeginEndMethods();
   llvm::SmallVector BeginNames{
   llvm::make_first_range(BeginEndNames)};
   llvm::SmallVector EndNames{
   llvm::make_second_range(BeginEndNames)};
-  llvm::DenseSet> Seen;
+  Replacers.clear();

PiotrZSL wrote:

Note: that Replaces vs Replacers is confusing, consider changing a name of one 
later on main.

https://github.com/llvm/llvm-project/pull/100427
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Fix crash in modernize-use-ranges (PR #100427)

2024-07-24 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.


https://github.com/llvm/llvm-project/pull/100427
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] clang-tidy: readability-redundant-smartptr-get does not remove (#97964) (PR #100177)

2024-07-23 Thread Piotr Zegar via cfe-commits


@@ -498,6 +498,10 @@ Changes in existing checks
   false-positives when type of the member does not match the type of the
   initializer.
 
+- Improved :doc:`readability-redundant-smartptr-get

PiotrZSL wrote:

you may need to rebase, as release notes has been cleared after branch out

https://github.com/llvm/llvm-project/pull/100177
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] clang-tidy: readability-redundant-smartptr-get does not remove (#97964) (PR #100177)

2024-07-23 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/100177
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] clang-tidy: readability-redundant-smartptr-get does not remove (#97964) (PR #100177)

2024-07-23 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL commented:

Except release notes, looks fine.

https://github.com/llvm/llvm-project/pull/100177
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Extend support for specifying languages and version in add_new_check.py (PR #100129)

2024-07-23 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.


https://github.com/llvm/llvm-project/pull/100129
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Extend support for specifying languages and version in add_new_check.py (PR #100129)

2024-07-23 Thread Piotr Zegar via cfe-commits


@@ -53,7 +55,18 @@ def adapt_cmake(module_path, check_name_camel):
 
 
 # Adds a header for the new check.
-def write_header(module_path, module, namespace, check_name, check_name_camel):
+def write_header(
+module_path, module, namespace, check_name, check_name_camel, lang_restrict
+):
+if lang_restrict:
+override_supported = """
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {

PiotrZSL wrote:

would be nice to add also getCheckTraversalKind with a 
TK_IgnoreUnlessSpelledInSource used by default

https://github.com/llvm/llvm-project/pull/100129
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add a description parameter to the add_new_check script (PR #100111)

2024-07-23 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.


https://github.com/llvm/llvm-project/pull/100111
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 26c99c4 - [clang-tidy] fix misc-const-correctness to work with function-try-blocks (#99925)

2024-07-23 Thread Piotr Zegar via cfe-commits

Author: Thomas Schenker
Date: 2024-07-23T07:38:49Z
New Revision: 26c99c421794902b0d929fd9eff81314da55675c

URL: 
https://github.com/llvm/llvm-project/commit/26c99c421794902b0d929fd9eff81314da55675c
DIFF: 
https://github.com/llvm/llvm-project/commit/26c99c421794902b0d929fd9eff81314da55675c.diff

LOG: [clang-tidy] fix misc-const-correctness to work with function-try-blocks 
(#99925)

Make the clang-tidy check misc-const-correctness work with
function-try-blocks.

Fixes #99860.

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
index 8b500de0c028c..e20cf6fbcb55a 100644
--- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
@@ -93,13 +93,12 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder 
*Finder) {
   // shall be run.
   const auto FunctionScope =
   functionDecl(
-  hasBody(
-  compoundStmt(forEachDescendant(
-   declStmt(containsAnyDeclaration(
-LocalValDecl.bind("local-value")),
-unless(has(decompositionDecl(
-   .bind("decl-stmt")))
-  .bind("scope")))
+  hasBody(stmt(forEachDescendant(
+   declStmt(containsAnyDeclaration(
+LocalValDecl.bind("local-value")),
+unless(has(decompositionDecl(
+   .bind("decl-stmt")))
+  .bind("scope")))
   .bind("function-decl");
 
   Finder->addMatcher(FunctionScope, this);
@@ -109,7 +108,7 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder 
*Finder) {
 enum class VariableCategory { Value, Reference, Pointer };
 
 void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
-  const auto *LocalScope = Result.Nodes.getNodeAs("scope");
+  const auto *LocalScope = Result.Nodes.getNodeAs("scope");
   const auto *Variable = Result.Nodes.getNodeAs("local-value");
   const auto *Function = Result.Nodes.getNodeAs("function-decl");
 
@@ -198,7 +197,7 @@ void ConstCorrectnessCheck::check(const 
MatchFinder::MatchResult &Result) {
   }
 }
 
-void ConstCorrectnessCheck::registerScope(const CompoundStmt *LocalScope,
+void ConstCorrectnessCheck::registerScope(const Stmt *LocalScope,
   ASTContext *Context) {
   auto &Analyzer = ScopesCache[LocalScope];
   if (!Analyzer)

diff  --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h 
b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
index 08ffde524522a..bba060e555d00 100644
--- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
@@ -32,10 +32,10 @@ class ConstCorrectnessCheck : public ClangTidyCheck {
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
 private:
-  void registerScope(const CompoundStmt *LocalScope, ASTContext *Context);
+  void registerScope(const Stmt *LocalScope, ASTContext *Context);
 
   using MutationAnalyzer = std::unique_ptr;
-  llvm::DenseMap ScopesCache;
+  llvm::DenseMap ScopesCache;
   llvm::DenseSet TemplateDiagnosticsCache;
 
   const bool AnalyzeValues;

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 0b2c04c23761c..083b098d05d4a 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -381,7 +381,8 @@ Changes in existing checks
 - Improved :doc:`misc-const-correctness
   ` check by avoiding infinite 
recursion
   for recursive functions with forwarding reference parameters and reference
-  variables which refer to themselves.
+  variables which refer to themselves. Also adapted the check to work with
+  function-try-blocks.
 
 - Improved :doc:`misc-definitions-in-headers
   ` check by replacing the local

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
index cb6bfcc1dccba..2af4bfb0bd449 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
@@ -56,6 +56,15 @@ void some_function(double np_arg0, wchar_t np_arg1) {
   np_local6--;
 }
 
+int function_try_block() try {
+  int p_local0 = 0;
+  // CHECK-MES

[clang-tools-extra] 2dd82c5 - [clang-tidy][NFC] Added -fexceptions to const-correctness-values.cp

2024-07-23 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2024-07-23T07:38:49Z
New Revision: 2dd82c5ac56623d38de977ef027b252b4908e4c5

URL: 
https://github.com/llvm/llvm-project/commit/2dd82c5ac56623d38de977ef027b252b4908e4c5
DIFF: 
https://github.com/llvm/llvm-project/commit/2dd82c5ac56623d38de977ef027b252b4908e4c5.diff

LOG: [clang-tidy][NFC] Added -fexceptions to const-correctness-values.cp

Related to #99925.

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
index 2af4bfb0bd449..0d1ff0db58371 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
@@ -3,7 +3,7 @@
 // RUN: misc-const-correctness.TransformValues: true, \
 // RUN: misc-const-correctness.WarnPointersAsValues: false, \
 // RUN: misc-const-correctness.TransformPointersAsValues: false \
-// RUN:   }}" -- -fno-delayed-template-parsing
+// RUN:   }}" -- -fno-delayed-template-parsing -fexceptions
 
 // --- Provide test samples for primitive builtins -
 // - every 'p_*' variable is a 'potential_const_*' variable



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] fix misc-const-correctness to work with function-try-blocks (PR #99925)

2024-07-22 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Looks like missing -fexceptions

https://github.com/llvm/llvm-project/pull/99925
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Revert "[clang-tidy] fix misc-const-correctness to work with function-try-blocks" (PR #100069)

2024-07-22 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL closed 
https://github.com/llvm/llvm-project/pull/100069
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Revert "[clang-tidy] fix misc-const-correctness to work with function-try-blocks" (PR #100069)

2024-07-22 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL created 
https://github.com/llvm/llvm-project/pull/100069

Reverts llvm/llvm-project#99925

>From a96af6c18ea45269c4d2e1fd762a14d763be0358 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Tue, 23 Jul 2024 08:46:14 +0200
Subject: [PATCH] =?UTF-8?q?Revert=20"[clang-tidy]=20fix=20misc-const-corre?=
 =?UTF-8?q?ctness=20to=20work=20with=20function-try-blo=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit cd9e42cb0f2fdf1834e2e6ad2befdba0d7cc84b5.
---
 .../clang-tidy/misc/ConstCorrectnessCheck.cpp   | 17 +
 .../clang-tidy/misc/ConstCorrectnessCheck.h |  4 ++--
 clang-tools-extra/docs/ReleaseNotes.rst |  3 +--
 .../checkers/misc/const-correctness-values.cpp  |  9 -
 4 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
index e20cf6fbcb55a..8b500de0c028c 100644
--- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
@@ -93,12 +93,13 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder 
*Finder) {
   // shall be run.
   const auto FunctionScope =
   functionDecl(
-  hasBody(stmt(forEachDescendant(
-   declStmt(containsAnyDeclaration(
-LocalValDecl.bind("local-value")),
-unless(has(decompositionDecl(
-   .bind("decl-stmt")))
-  .bind("scope")))
+  hasBody(
+  compoundStmt(forEachDescendant(
+   declStmt(containsAnyDeclaration(
+LocalValDecl.bind("local-value")),
+unless(has(decompositionDecl(
+   .bind("decl-stmt")))
+  .bind("scope")))
   .bind("function-decl");
 
   Finder->addMatcher(FunctionScope, this);
@@ -108,7 +109,7 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder 
*Finder) {
 enum class VariableCategory { Value, Reference, Pointer };
 
 void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
-  const auto *LocalScope = Result.Nodes.getNodeAs("scope");
+  const auto *LocalScope = Result.Nodes.getNodeAs("scope");
   const auto *Variable = Result.Nodes.getNodeAs("local-value");
   const auto *Function = Result.Nodes.getNodeAs("function-decl");
 
@@ -197,7 +198,7 @@ void ConstCorrectnessCheck::check(const 
MatchFinder::MatchResult &Result) {
   }
 }
 
-void ConstCorrectnessCheck::registerScope(const Stmt *LocalScope,
+void ConstCorrectnessCheck::registerScope(const CompoundStmt *LocalScope,
   ASTContext *Context) {
   auto &Analyzer = ScopesCache[LocalScope];
   if (!Analyzer)
diff --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h 
b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
index bba060e555d00..08ffde524522a 100644
--- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.h
@@ -32,10 +32,10 @@ class ConstCorrectnessCheck : public ClangTidyCheck {
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
 private:
-  void registerScope(const Stmt *LocalScope, ASTContext *Context);
+  void registerScope(const CompoundStmt *LocalScope, ASTContext *Context);
 
   using MutationAnalyzer = std::unique_ptr;
-  llvm::DenseMap ScopesCache;
+  llvm::DenseMap ScopesCache;
   llvm::DenseSet TemplateDiagnosticsCache;
 
   const bool AnalyzeValues;
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 083b098d05d4a..0b2c04c23761c 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -381,8 +381,7 @@ Changes in existing checks
 - Improved :doc:`misc-const-correctness
   ` check by avoiding infinite 
recursion
   for recursive functions with forwarding reference parameters and reference
-  variables which refer to themselves. Also adapted the check to work with
-  function-try-blocks.
+  variables which refer to themselves.
 
 - Improved :doc:`misc-definitions-in-headers
   ` check by replacing the local
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
index 2af4bfb0bd449..cb6bfcc1dccba 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp
@@ -56,15 +56,6 @@ void some_function(double np_arg0, wchar_t np_arg1) {
   np_local6--;
 }
 
-int function_try_block() try {
-  int p_local0 = 0;
-  // CHECK-MESSAGES:

[clang-tools-extra] [libc] clang-tidy: readability-redundant-smartptr-get does not remove -> (#97964) (PR #98757)

2024-07-22 Thread Piotr Zegar via cfe-commits


@@ -235,3 +276,13 @@ void Negative() {
   if (MACRO(x) == nullptr)
 ;
 }
+
+void test_redundant_get() {
+  std::vector> v;
+  auto f = [](int) {};
+  for (auto i = v.begin(); i != v.end(); ++i) {
+f(*i->get());

PiotrZSL wrote:

Try with:
f((*i).get()->get()->getValue());

https://github.com/llvm/llvm-project/pull/98757
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d48d480 - [clang-tidy][NFC] Fix tiny bug in areStatementsIdentical

2024-07-22 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2024-07-22T20:46:48Z
New Revision: d48d4805f792adbdac58d480f890449def4964ea

URL: 
https://github.com/llvm/llvm-project/commit/d48d4805f792adbdac58d480f890449def4964ea
DIFF: 
https://github.com/llvm/llvm-project/commit/d48d4805f792adbdac58d480f890449def4964ea.diff

LOG: [clang-tidy][NFC] Fix tiny bug in areStatementsIdentical

Function areStatementsIdentical had an early exit
when classes of stmt does not match. That if were
added to speed up checking and do not calculate
hash id of both objects if they are not the same
type. Due to some bug, wrong pointer were used
and this resulted with comparing self to self.

This patch fixes this issue.

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/ASTUtils.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
index fd5dadc9b01db..0cdc7d08abc99 100644
--- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
@@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt 
*SecondStmt,
   if (FirstStmt == SecondStmt)
 return true;
 
-  if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass())
+  if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass())
 return false;
 
   if (isa(FirstStmt) && isa(SecondStmt)) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] fix misc-const-correctness to work with function-try-blocks (PR #99925)

2024-07-22 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/99925
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] fix misc-const-correctness to work with function-try-blocks (PR #99925)

2024-07-22 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

Release notes need small fix, except that looks fine

https://github.com/llvm/llvm-project/pull/99925
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] fix misc-const-correctness to work with function-try-blocks (PR #99925)

2024-07-22 Thread Piotr Zegar via cfe-commits


@@ -120,6 +120,9 @@ Improvements to clang-tidy
 - Improved :program:`check_clang_tidy.py` script. Added argument 
`-export-fixes`
   to aid in clang-tidy and test development.
 
+- Improved :doc:`misc-const-correctness

PiotrZSL wrote:

wrong place, this should be in line 375

https://github.com/llvm/llvm-project/pull/99925
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 04d5003 - [clang-tidy][DOC] Update check documentation

2024-07-22 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2024-07-22T19:31:00Z
New Revision: 04d5003f59c1ef10a036d2158f1aa61de506e707

URL: 
https://github.com/llvm/llvm-project/commit/04d5003f59c1ef10a036d2158f1aa61de506e707
DIFF: 
https://github.com/llvm/llvm-project/commit/04d5003f59c1ef10a036d2158f1aa61de506e707.diff

LOG: [clang-tidy][DOC] Update check documentation

Fix issues in list.rst, addapt add_new_check.py to new
format of that file, and run gen-static-analyzer-docs.py
to generate missing documentation for clang-analyzer.

Added: 

clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/optin.taint.TaintedAlloc.rst

clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.PutenvStackArray.rst

clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/unix.BlockInCriticalSection.rst

Modified: 
clang-tools-extra/clang-tidy/add_new_check.py
clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.Move.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index 3b14d5d158d2d..3a62df1f510ba 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -552,8 +552,8 @@ def format_link_alias(doc_file):
 f.write('   :header: "Name", "Offers fixes"\n\n')
 f.writelines(checks)
 # and the aliases
-f.write("\n\n")
-f.write(".. csv-table:: Aliases..\n")
+f.write("\nCheck aliases\n-\n\n")
+f.write(".. csv-table::\n")
 f.write('   :header: "Name", "Redirect", "Offers fixes"\n\n')
 f.writelines(checks_alias)
 break

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.Move.rst 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.Move.rst
index e723f21f6bc60..f478598bb4e6c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.Move.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/cplusplus.Move.rst
@@ -1,9 +1,13 @@
 .. title:: clang-tidy - clang-analyzer-cplusplus.Move
+.. meta::
+   :http-equiv=refresh: 
5;URL=https://clang.llvm.org/docs/analyzer/checkers.html#cplusplus-move
 
 clang-analyzer-cplusplus.Move
 =
 
 Find use-after-move bugs in C++.
 
-The clang-analyzer-cplusplus.Move check is an alias of
-Clang Static Analyzer cplusplus.Move.
+The `clang-analyzer-cplusplus.Move` check is an alias, please see
+`Clang Static Analyzer Available Checkers
+`_
+for more information.

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/optin.taint.TaintedAlloc.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/optin.taint.TaintedAlloc.rst
new file mode 100644
index 0..9732333c61aa7
--- /dev/null
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/optin.taint.TaintedAlloc.rst
@@ -0,0 +1,14 @@
+.. title:: clang-tidy - clang-analyzer-optin.taint.TaintedAlloc
+.. meta::
+   :http-equiv=refresh: 
5;URL=https://clang.llvm.org/docs/analyzer/checkers.html#optin-taint-taintedalloc
+
+clang-analyzer-optin.taint.TaintedAlloc
+===
+
+Check for memory allocations, where the size parameter might be a tainted
+(attacker controlled) value.
+
+The `clang-analyzer-optin.taint.TaintedAlloc` check is an alias, please see
+`Clang Static Analyzer Available Checkers
+`_
+for more information.

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.PutenvStackArray.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.PutenvStackArray.rst
new file mode 100644
index 0..0a5feff8d3ca8
--- /dev/null
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.PutenvStackArray.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - clang-analyzer-security.PutenvStackArray
+
+clang-analyzer-security.PutenvStackArray
+
+
+Finds calls to the function 'putenv' which pass a pointer to an automatic
+(stack-allocated) array as the argument.
+
+The clang-analyzer-security.PutenvStackArray check is an alias of
+Clang Static Analyzer security.PutenvStackArray.

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/unix.BlockInCriticalSection.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/unix.BlockInCriticalSection.rst
new file mode 100644
index 0..40d2d3d8b8aac
--- /dev/null
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/unix.BlockInCriticalSection.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - clang-analyzer-unix.BlockInCriti

[clang-tools-extra] [libc] clang-tidy: readability-redundant-smartptr-get does not remove -> (#97964) (PR #98757)

2024-07-22 Thread Piotr Zegar via cfe-commits


@@ -235,3 +276,13 @@ void Negative() {
   if (MACRO(x) == nullptr)
 ;
 }
+
+void test_redundant_get() {
+  std::vector> v;
+  auto f = [](int) {};
+  for (auto i = v.begin(); i != v.end(); ++i) {
+f(*i->get());

PiotrZSL wrote:

`f(i->get()->get()->getValue());`


https://github.com/llvm/llvm-project/pull/98757
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [libc] clang-tidy: readability-redundant-smartptr-get does not remove -> (#97964) (PR #98757)

2024-07-22 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/98757
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Draft: Create a new check to look for mis-use in calls that take iterators (PR #99917)

2024-07-22 Thread Piotr Zegar via cfe-commits


@@ -400,15 +401,14 @@ Clang-Tidy Checks
:doc:`readability-use-std-min-max `, "Yes"
:doc:`zircon-temporary-objects `,
 
-Check aliases
--
 
-.. csv-table::
+.. csv-table:: Aliases..
:header: "Name", "Redirect", "Offers fixes"
 
:doc:`bugprone-narrowing-conversions `, 
:doc:`cppcoreguidelines-narrowing-conversions 
`,
:doc:`cert-con36-c `, 
:doc:`bugprone-spuriously-wake-up-functions 
`,
:doc:`cert-con54-cpp `, 
:doc:`bugprone-spuriously-wake-up-functions 
`,
+   :doc:`cert-ctr56-cpp `, 
:doc:`bugprone-pointer-arithmetic-on-polymorphic-object 
`,

PiotrZSL wrote:

thx, for pointing those issues. I will correct them.

https://github.com/llvm/llvm-project/pull/99917
___
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 bugprone-move-shared-pointer-contents check. (PR #67467)

2024-07-22 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Looks like there are still some merge conflicts, duplicated lines and so on.

https://github.com/llvm/llvm-project/pull/67467
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy][performance-unnecessary-value-param] Make `handleMoveFix` virtual (PR #99867)

2024-07-22 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.

Please note that at any time in future those
functions could be changed no non-virtual again,
as there are no tests to guard this.

I'm fine with the change, as it provides tiny refactoring.

https://github.com/llvm/llvm-project/pull/99867
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] `bugprone-exception-escape` didn't detech catching of an exception with pointer type by `void *` exception handler (PR #99773)

2024-07-22 Thread Piotr Zegar via cfe-commits


@@ -245,6 +245,10 @@ Changes in existing checks
   where source is already a ``void``` pointer, making middle ``void`` pointer
   casts bug-free.
 
+- Improved :doc:`exception-escape 
`
+  check to correctly detect exception handler of type ``CV void *`` as 
catching all 
+  ``CV`` compatible pointer types.

PiotrZSL wrote:

```suggestion
- Improved :doc:`bugprone-exception-escape
  `  check to correctly detect 
exception 
  handler of type ``CV void *`` as catching all  ``CV`` compatible pointer 
types.
```

https://github.com/llvm/llvm-project/pull/99773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] `bugprone-exception-escape` didn't detech catching of an exception with pointer type by `void *` exception handler (PR #99773)

2024-07-22 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL edited 
https://github.com/llvm/llvm-project/pull/99773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   9   10   >