//===--- RedundantStrcatCallsCheck.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 "RedundantStrcatCallsCheck.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include <deque> usingnamespaceclang::ast_matchers; namespace clang::tidy::abseil { // TODO: Features to add to the check: // - Make it work if num_args > 26. // - Remove empty literal string arguments. // - Collapse consecutive literal string arguments into one (remove the ,). // - Replace StrCat(a + b) -> StrCat(a, b) if a or b are strings. // - Make it work in macros if the outer and inner StrCats are both in the // argument. void RedundantStrcatCallsCheck::registerMatchers(MatchFinder* Finder) { … } namespace { struct StrCatCheckResult { … }; void removeCallLeaveArgs(const CallExpr *Call, StrCatCheckResult *CheckResult) { … } const clang::CallExpr *processArgument(const Expr *Arg, const MatchFinder::MatchResult &Result, StrCatCheckResult *CheckResult) { … } StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend, const MatchFinder::MatchResult &Result) { … } } // namespace void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) { … } } // namespace clang::tidy::abseil