From 0dbc7c8e1b1db2399eaa3e6ad172597d7a3aa2bd Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:11:27 +0200 Subject: [PATCH] Remove simplification in combineOperators() (#6900) Caused inconsistent results in https://github.com/danmar/cppcheck/pull/6889 --- lib/checkmemoryleak.cpp | 2 +- lib/tokenize.cpp | 13 ++----------- test/cfg/bsd.c | 3 ++- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 8c9b3200e18..397ceb8b7d5 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -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; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ab4956243f7..e20ca901f7d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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("->"); } } } diff --git a/test/cfg/bsd.c b/test/cfg/bsd.c index 33db4c30207..d64746d2a3a 100644 --- a/test/cfg/bsd.c +++ b/test/cfg/bsd.c @@ -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, ==);