Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove simplification in combineOperators() #6900

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checkmemoryleak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable* const vari

else if (tok3->str() == "}") {
if (indentlevel3 == 0) {
memoryLeak(tok3, variable->name() + "." + tok2->strAt(2), allocType);
memoryLeak(tok3, variable->name() + "." + assignToks.first->str(), allocType);
break;
}
--indentlevel3;
Expand Down
13 changes: 2 additions & 11 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3605,17 +3605,8 @@ void Tokenizer::combineOperators()
tok->deleteNext();
}
} else if (tok->str() == "->") {
// If the preceding sequence is "( & %name% )", replace it by "%name%"
Token *t = tok->tokAt(-4);
if (Token::Match(t, "( & %name% )") && !Token::simpleMatch(t->previous(), ">")) {
t->deleteThis();
t->deleteThis();
t->deleteNext();
tok->str(".");
} else {
tok->str(".");
tok->originalName("->");
}
tok->str(".");
tok->originalName("->");
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/cfg/bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ ssize_t nullPointer_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t o
return pwritev(fd,iov,iovcnt,offset);
}

// False negative: #9346
// #9346
void uninitvar_timercmp(struct timeval t)
{
struct timeval uninit;
// cppcheck-suppress uninitvar
(void)timercmp(&t, &uninit, <);
(void)timercmp(&uninit, &t, <=);
(void)timercmp(&uninit, &uninit, ==);
Expand Down
Loading