@@ -23,7 +23,7 @@ namespace clang::tidy::abseil {
23
23
// - Make it work in macros if the outer and inner StrCats are both in the
24
24
// argument.
25
25
26
- void RedundantStrcatCallsCheck::registerMatchers (MatchFinder* Finder) {
26
+ void RedundantStrcatCallsCheck::registerMatchers (MatchFinder * Finder) {
27
27
const auto CallToStrcat =
28
28
callExpr (callee (functionDecl (hasName (" ::absl::StrCat" ))));
29
29
const auto CallToStrappend =
@@ -62,7 +62,7 @@ const clang::CallExpr *processArgument(const Expr *Arg,
62
62
const MatchFinder::MatchResult &Result,
63
63
StrCatCheckResult *CheckResult) {
64
64
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" ));
66
66
const auto IsStrcat = cxxBindTemporaryExpr (
67
67
has (callExpr (callee (functionDecl (*Strcat))).bind (" StrCat" )));
68
68
if (const auto *SubStrcatCall = selectFirst<const CallExpr>(
@@ -81,18 +81,18 @@ const clang::CallExpr *processArgument(const Expr *Arg,
81
81
StrCatCheckResult processCall (const CallExpr *RootCall, bool IsAppend,
82
82
const MatchFinder::MatchResult &Result) {
83
83
StrCatCheckResult CheckResult;
84
- std::deque<const CallExpr*> CallsToProcess = {RootCall};
84
+ std::deque<const CallExpr *> CallsToProcess = {RootCall};
85
85
86
86
while (!CallsToProcess.empty ()) {
87
87
++CheckResult.NumCalls ;
88
88
89
- const CallExpr* CallExpr = CallsToProcess.front ();
89
+ const CallExpr * CallExpr = CallsToProcess.front ();
90
90
CallsToProcess.pop_front ();
91
91
92
92
int StartArg = CallExpr == RootCall && IsAppend;
93
93
for (const auto *Arg : CallExpr->arguments ()) {
94
- if (StartArg-- > 0 )
95
- continue ;
94
+ if (StartArg-- > 0 )
95
+ continue ;
96
96
if (const clang::CallExpr *Sub =
97
97
processArgument (Arg, Result, &CheckResult)) {
98
98
CallsToProcess.push_back (Sub);
@@ -101,18 +101,18 @@ StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
101
101
}
102
102
return CheckResult;
103
103
}
104
- } // namespace
104
+ } // namespace
105
105
106
- void RedundantStrcatCallsCheck::check (const MatchFinder::MatchResult& Result) {
106
+ void RedundantStrcatCallsCheck::check (const MatchFinder::MatchResult & Result) {
107
107
bool IsAppend = false ;
108
108
109
109
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 ;
116
116
117
117
if (RootCall->getBeginLoc ().isMacroID ()) {
118
118
// Ignore calls within macros.
@@ -128,8 +128,8 @@ void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
128
128
return ;
129
129
}
130
130
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" )
133
133
<< CheckResult.Hints ;
134
134
}
135
135
0 commit comments