================ @@ -0,0 +1,92 @@ +//===--- 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<Visitor> { + IncorrectEnableSharedFromThisCheck &Check; + llvm::SmallPtrSet<const CXXRecordDecl *, 16> EnableSharedClassSet; + + public: + explicit Visitor(IncorrectEnableSharedFromThisCheck &Check) + : Check(Check) {} + + bool VisitCXXRecordDecl(CXXRecordDecl *RDecl) { + if (!RDecl->hasDefinition()) + return true; + + if (isStdEnableSharedFromThis(RDecl)) + EnableSharedClassSet.insert(RDecl->getCanonicalDecl()); + + for (const auto &Base : RDecl->bases()) { + const auto *BaseRecord = ---------------- EugeneZelenko wrote:
`auto` should not be used - types is not spelled explicitly. 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