@@ -23,7 +23,7 @@ namespace clang::tidy::abseil {
2323// - Make it work in macros if the outer and inner StrCats are both in the
2424// argument.
2525
26- void RedundantStrcatCallsCheck::registerMatchers (MatchFinder* Finder) {
26+ void RedundantStrcatCallsCheck::registerMatchers (MatchFinder * Finder) {
2727 const auto CallToStrcat =
2828 callExpr (callee (functionDecl (hasName (" ::absl::StrCat" ))));
2929 const auto CallToStrappend =
@@ -62,7 +62,7 @@ const clang::CallExpr *processArgument(const Expr *Arg,
6262 const MatchFinder::MatchResult &Result,
6363 StrCatCheckResult *CheckResult) {
6464 const auto IsAlphanum = hasDeclaration (cxxMethodDecl (hasName (" AlphaNum" )));
65- static const auto * const Strcat = new auto (hasName (" ::absl::StrCat" ));
65+ static const auto * const Strcat = new auto (hasName (" ::absl::StrCat" ));
6666 const auto IsStrcat = cxxBindTemporaryExpr (
6767 has (callExpr (callee (functionDecl (*Strcat))).bind (" StrCat" )));
6868 if (const auto *SubStrcatCall = selectFirst<const CallExpr>(
@@ -81,18 +81,18 @@ const clang::CallExpr *processArgument(const Expr *Arg,
8181StrCatCheckResult processCall (const CallExpr *RootCall, bool IsAppend,
8282 const MatchFinder::MatchResult &Result) {
8383 StrCatCheckResult CheckResult;
84- std::deque<const CallExpr*> CallsToProcess = {RootCall};
84+ std::deque<const CallExpr *> CallsToProcess = {RootCall};
8585
8686 while (!CallsToProcess.empty ()) {
8787 ++CheckResult.NumCalls ;
8888
89- const CallExpr* CallExpr = CallsToProcess.front ();
89+ const CallExpr * CallExpr = CallsToProcess.front ();
9090 CallsToProcess.pop_front ();
9191
9292 int StartArg = CallExpr == RootCall && IsAppend;
9393 for (const auto *Arg : CallExpr->arguments ()) {
94- if (StartArg-- > 0 )
95- continue ;
94+ if (StartArg-- > 0 )
95+ continue ;
9696 if (const clang::CallExpr *Sub =
9797 processArgument (Arg, Result, &CheckResult)) {
9898 CallsToProcess.push_back (Sub);
@@ -101,18 +101,18 @@ StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
101101 }
102102 return CheckResult;
103103}
104- } // namespace
104+ } // namespace
105105
106- void RedundantStrcatCallsCheck::check (const MatchFinder::MatchResult& Result) {
106+ void RedundantStrcatCallsCheck::check (const MatchFinder::MatchResult & Result) {
107107 bool IsAppend = false ;
108108
109109 const CallExpr *RootCall = nullptr ;
110- if ((RootCall = Result.Nodes .getNodeAs <CallExpr>(" StrCat" )))
111- IsAppend = false ;
112- else if ((RootCall = Result.Nodes .getNodeAs <CallExpr>(" StrAppend" )))
113- IsAppend = true ;
114- else
115- return ;
110+ if ((RootCall = Result.Nodes .getNodeAs <CallExpr>(" StrCat" )))
111+ IsAppend = false ;
112+ else if ((RootCall = Result.Nodes .getNodeAs <CallExpr>(" StrAppend" )))
113+ IsAppend = true ;
114+ else
115+ return ;
116116
117117 if (RootCall->getBeginLoc ().isMacroID ()) {
118118 // Ignore calls within macros.
@@ -128,8 +128,8 @@ void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
128128 return ;
129129 }
130130
131- diag (RootCall->getBeginLoc (),
132- " multiple calls to 'absl::StrCat' can be flattened into a single call" )
131+ diag (RootCall->getBeginLoc (),
132+ " multiple calls to 'absl::StrCat' can be flattened into a single call" )
133133 << CheckResult.Hints ;
134134}
135135
0 commit comments