Skip to content

Commit a271422

Browse files
committed
Restrict to STL types
1 parent ed47749 commit a271422

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

lib/checkstl.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,8 @@ static bool isc_strCall(const Token* tok)
19671967
if (!Token::simpleMatch(dot, "."))
19681968
return false;
19691969
const Token* obj = dot->astOperand1();
1970-
if (!obj || !obj->valueType() || !obj->valueType()->container || !obj->valueType()->container->stdStringLike)
1970+
if (!obj || !obj->valueType() || !obj->valueType()->container ||
1971+
!obj->valueType()->container->stdStringLike || !obj->valueType()->container->startPatternHasStd)
19711972
return false;
19721973
return Token::Match(dot->astOperand2(), "c_str|data ( )");
19731974
}
@@ -1986,7 +1987,8 @@ static bool isc_strConcat(const Token* tok)
19861987
if (!cstr)
19871988
return false;
19881989
const Token* strTok = (cstr == tok->astOperand1()) ? tok->astOperand2() : tok->astOperand1();
1989-
return strTok->valueType() && strTok->valueType()->container && strTok->valueType()->container->stdStringLike;
1990+
return strTok->valueType() && strTok->valueType()->container &&
1991+
strTok->valueType()->container->stdStringLike && strTok->valueType()->container->startPatternHasStd;
19901992
}
19911993

19921994
static bool isc_strAssignment(const Token* tok)
@@ -1996,7 +1998,8 @@ static bool isc_strAssignment(const Token* tok)
19961998
if (!isc_strCall(tok->astOperand2()))
19971999
return false;
19982000
const Token* strTok = tok->astOperand1();
1999-
return strTok && strTok->valueType() && strTok->valueType()->container && strTok->valueType()->container->stdStringLike;
2001+
return strTok && strTok->valueType() && strTok->valueType()->container &&
2002+
strTok->valueType()->container->stdStringLike && strTok->valueType()->container->startPatternHasStd;
20002003
}
20012004

20022005
static bool isc_strConstructor(const Token* tok)
@@ -2005,7 +2008,8 @@ static bool isc_strConstructor(const Token* tok)
20052008
return false;
20062009
if (!isc_strCall(tok->tokAt(1)->astOperand2()))
20072010
return false;
2008-
return tok->valueType() && tok->valueType()->container && tok->valueType()->container->stdStringLike;
2011+
return tok->valueType() && tok->valueType()->container &&
2012+
tok->valueType()->container->stdStringLike && tok->valueType()->container->startPatternHasStd;
20092013
}
20102014

20112015
namespace {

0 commit comments

Comments
 (0)