//===--- SwappedArgumentsCheck.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 "SwappedArgumentsCheck.h" #include "clang/AST/ASTContext.h" #include "clang/Lex/Lexer.h" #include "clang/Tooling/FixIt.h" #include "llvm/ADT/SmallPtrSet.h" usingnamespaceclang::ast_matchers; namespace clang::tidy::bugprone { void SwappedArgumentsCheck::registerMatchers(MatchFinder *Finder) { … } /// Look through lvalue to rvalue and nop casts. This filters out /// implicit conversions that have no effect on the input but block our view for /// other implicit casts. static const Expr *ignoreNoOpCasts(const Expr *E) { … } /// Restrict the warning to implicit casts that are most likely /// accidental. User defined or integral conversions fit in this category, /// lvalue to rvalue or derived to base does not. static bool isImplicitCastCandidate(const CastExpr *Cast) { … } static bool areTypesSemiEqual(const QualType L, const QualType R) { … } static bool areArgumentsPotentiallySwapped(const QualType LTo, const QualType RTo, const QualType LFrom, const QualType RFrom) { … } void SwappedArgumentsCheck::check(const MatchFinder::MatchResult &Result) { … } } // namespace clang::tidy::bugprone