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

Nathan James via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 8 09:19:42 PDT 2024


njames93 wrote:

> > How are classes that derive other classes that implement `enable_shared_from_this`
> > 
> > ```c++
> > class A : public std::enable_shared_from_this {};
> > class B : private A{};
> > ```
> 
> Looking at the AST dump that clang-check gives, it seems that B doesn't have any knowledge of A's internals, so the current approach will not work. Correct me if I'm wrong though

I think you'd have to recursively check the inheritance of a class and if you have any private that derives from `std::enable_shared_from_this`

https://github.com/llvm/llvm-project/pull/102299


More information about the cfe-commits mailing list