//===--- SuspiciousReallocUsageCheck.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 "SuspiciousReallocUsageCheck.h" #include "../utils/Aliasing.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclVisitor.h" #include "clang/AST/StmtVisitor.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Lex/Lexer.h" usingnamespaceclang::ast_matchers; usingnamespaceclang; namespace { /// Check if two different expression nodes denote the same /// "pointer expression". The "pointer expression" can consist of member /// expressions and declaration references only (like \c a->b->c), otherwise the /// check is always false. class IsSamePtrExpr : public StmtVisitor<IsSamePtrExpr, bool> { … }; /// Check if there is an assignment or initialization that references a variable /// \c Var (at right-hand side) and is before \c VarRef in the source code. /// Only simple assignments like \code a = b \endcode are found. class FindAssignToVarBefore : public ConstStmtVisitor<FindAssignToVarBefore, bool> { … }; } // namespace namespace clang::tidy::bugprone { void SuspiciousReallocUsageCheck::registerMatchers(MatchFinder *Finder) { … } void SuspiciousReallocUsageCheck::check( const MatchFinder::MatchResult &Result) { … } } // namespace clang::tidy::bugprone