parent
0d35a96594
commit
d471c27502
|
@ -354,11 +354,11 @@ static const Variable *getContainer(const Token *argtok)
|
||||||
|
|
||||||
static const Token * getIteratorExpression(const Token * tok, const Token * end)
|
static const Token * getIteratorExpression(const Token * tok, const Token * end)
|
||||||
{
|
{
|
||||||
for(;tok != end;tok = tok->next()) {
|
for (; tok != end; tok = tok->next()) {
|
||||||
if(Token::Match(tok, iteratorFuncPattern.c_str())) {
|
if (Token::Match(tok, iteratorFuncPattern.c_str())) {
|
||||||
if(Token::Match(tok->previous(), ". %name% ( )")) {
|
if (Token::Match(tok->previous(), ". %name% ( )")) {
|
||||||
return tok->previous()->astOperand1();
|
return tok->previous()->astOperand1();
|
||||||
} else if(Token::Match(tok, "%name% ( !!)")) {
|
} else if (Token::Match(tok, "%name% ( !!)")) {
|
||||||
return tok->next()->astOperand2();
|
return tok->next()->astOperand2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ void CheckStl::mismatchingContainers()
|
||||||
if (!i)
|
if (!i)
|
||||||
continue;
|
continue;
|
||||||
const Variable *c = getContainer(argTok);
|
const Variable *c = getContainer(argTok);
|
||||||
if(c) {
|
if (c) {
|
||||||
std::map<const Variable *, unsigned int>::const_iterator it = containerNr.find(c);
|
std::map<const Variable *, unsigned int>::const_iterator it = containerNr.find(c);
|
||||||
if (it == containerNr.end()) {
|
if (it == containerNr.end()) {
|
||||||
for (it = containerNr.begin(); it != containerNr.end(); ++it) {
|
for (it = containerNr.begin(); it != containerNr.end(); ++it) {
|
||||||
|
@ -399,14 +399,14 @@ void CheckStl::mismatchingContainers()
|
||||||
mismatchingContainersError(argTok);
|
mismatchingContainersError(argTok);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(i->first) {
|
if (i->first) {
|
||||||
firstArg = argTok;
|
firstArg = argTok;
|
||||||
} else if(i->last && firstArg && argTok) {
|
} else if (i->last && firstArg && argTok) {
|
||||||
const Token * firstArgNext = firstArg->nextArgument() ? firstArg->nextArgument() : tok->linkAt(1);
|
const Token * firstArgNext = firstArg->nextArgument() ? firstArg->nextArgument() : tok->linkAt(1);
|
||||||
const Token * iter1 = getIteratorExpression(firstArg, firstArgNext);
|
const Token * iter1 = getIteratorExpression(firstArg, firstArgNext);
|
||||||
const Token * argTokNext = argTok->nextArgument() ? argTok->nextArgument() : tok->linkAt(1);
|
const Token * argTokNext = argTok->nextArgument() ? argTok->nextArgument() : tok->linkAt(1);
|
||||||
const Token * iter2 = getIteratorExpression(argTok, argTokNext);
|
const Token * iter2 = getIteratorExpression(argTok, argTokNext);
|
||||||
if(iter1 && iter2 && !isSameExpression(true, false, iter1, iter2, mSettings->library, false)) {
|
if (iter1 && iter2 && !isSameExpression(true, false, iter1, iter2, mSettings->library, false)) {
|
||||||
mismatchingContainerExpressionError(iter1, iter2);
|
mismatchingContainerExpressionError(iter1, iter2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue