Skip to content

Commit 2126e62

Browse files
committed
Check if Nested call has no arguments
1 parent 3df9873 commit 2126e62

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,9 @@ generateReplacement(const MatchFinder::MatchResult &Match,
124124
if (ArgType == ResultType)
125125
continue;
126126

127-
const StringRef ArgText =
128-
Lexer::getSourceText(
129-
CharSourceRange::getTokenRange(Arg->getSourceRange()), SourceMngr,
130-
LanguageOpts);
127+
const StringRef ArgText = Lexer::getSourceText(
128+
CharSourceRange::getTokenRange(Arg->getSourceRange()), SourceMngr,
129+
LanguageOpts);
131130

132131
Twine Replacement = llvm::Twine("static_cast<")
133132
.concat(ResultType.getAsString(LanguageOpts))
@@ -146,6 +145,10 @@ generateReplacement(const MatchFinder::MatchResult &Match,
146145
generateReplacement(Match, InnerCall, InnerResult);
147146
const bool IsInnerInitializerList = InnerResult.First == InnerResult.Last;
148147

148+
// if the nested call doesn't have arguments skip it
149+
if (!InnerResult.First || !InnerResult.Last)
150+
continue;
151+
149152
// if the nested call is not the same as the top call
150153
if (InnerCall->getDirectCallee()->getQualifiedNameAsString() !=
151154
TopCall->getDirectCallee()->getQualifiedNameAsString())

0 commit comments

Comments
 (0)