Skip to content

Commit 9259f1e

Browse files
committed
Helper function
1 parent 4d57075 commit 9259f1e

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

lib/checkstl.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,23 @@ static bool isc_strConcat(const Token* tok)
19891989
return false;
19901990
}
19911991

1992+
static bool isc_strInPlusChain(const Token* tok, const Library::Container* container)
1993+
{
1994+
if (!tok || !tok->valueType() || !tok->valueType()->pointer)
1995+
return false;
1996+
bool result = false;
1997+
visitAstNodes(tok, [&](const Token* tok2) {
1998+
if (Token::simpleMatch(tok2, "+"))
1999+
return ChildrenToVisit::op1_and_op2;
2000+
if (isc_strCall(tok2, container)) {
2001+
result = true;
2002+
return ChildrenToVisit::done;
2003+
}
2004+
return ChildrenToVisit::none;
2005+
});
2006+
return result;
2007+
}
2008+
19922009
static bool isc_strAssignment(const Token* tok)
19932010
{
19942011
if (!Token::simpleMatch(tok, "="))
@@ -2003,17 +2020,7 @@ static bool isc_strConstructor(const Token* tok)
20032020
{
20042021
if (!tok->valueType() || !Token::Match(tok, "%var% (|{"))
20052022
return false;
2006-
bool result = false;
2007-
visitAstNodes(tok->tokAt(1)->astOperand2(), [&](const Token* tok2) {
2008-
if (Token::simpleMatch(tok2, "+"))
2009-
return ChildrenToVisit::op1_and_op2;
2010-
if (isc_strCall(tok2, tok->valueType()->container)) {
2011-
result = true;
2012-
return ChildrenToVisit::done;
2013-
}
2014-
return ChildrenToVisit::none;
2015-
});
2016-
return result;
2023+
return isc_strInPlusChain(tok->tokAt(1)->astOperand2(), tok->valueType()->container);
20172024
}
20182025

20192026
namespace {

0 commit comments

Comments
 (0)