Missing update for Makefile. CheckMemoryLeakInFunction::getcode(): skip some C++ token matching in C mode. Minor refactoring

This commit is contained in:
Alexander Mai 2015-06-20 22:49:28 +02:00
parent b3c7a3f798
commit 4172011e78
3 changed files with 6 additions and 6 deletions

View File

@ -385,7 +385,7 @@ $(SRCDIR)/path.o: lib/path.cpp lib/cxx11emu.h lib/path.h lib/config.h
$(SRCDIR)/preprocessor.o: lib/preprocessor.cpp lib/cxx11emu.h lib/preprocessor.h lib/config.h lib/tokenize.h lib/errorlogger.h lib/suppressions.h lib/tokenlist.h lib/token.h lib/valueflow.h lib/mathlib.h lib/path.h lib/settings.h lib/library.h lib/standards.h lib/timer.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -std=c++0x -c -o $(SRCDIR)/preprocessor.o $(SRCDIR)/preprocessor.cpp
$(SRCDIR)/settings.o: lib/settings.cpp lib/cxx11emu.h lib/settings.h lib/config.h lib/library.h lib/mathlib.h lib/token.h lib/valueflow.h lib/suppressions.h lib/standards.h lib/timer.h lib/path.h lib/preprocessor.h
$(SRCDIR)/settings.o: lib/settings.cpp lib/cxx11emu.h lib/settings.h lib/config.h lib/library.h lib/mathlib.h lib/token.h lib/valueflow.h lib/suppressions.h lib/standards.h lib/timer.h lib/path.h lib/preprocessor.h lib/utils.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -std=c++0x -c -o $(SRCDIR)/settings.o $(SRCDIR)/settings.cpp
$(SRCDIR)/suppressions.o: lib/suppressions.cpp lib/cxx11emu.h lib/suppressions.h lib/config.h lib/settings.h lib/library.h lib/mathlib.h lib/token.h lib/valueflow.h lib/standards.h lib/timer.h lib/path.h

View File

@ -1206,7 +1206,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
}
// throw..
else if (Token::Match(tok, "try|throw|catch")) {
else if (tokenizer->isCPP() && Token::Match(tok, "try|throw|catch")) {
addtoken(&rettail, tok, tok->str());
if (tok->strAt(1) == "(")
tok = tok->next()->link();

View File

@ -700,7 +700,7 @@ void CheckOther::checkRedundantAssignment()
else if (memAssignments.find(param1->varId()) == memAssignments.end())
memAssignments[param1->varId()] = tok;
else {
const std::map<unsigned int, const Token*>::iterator it = memAssignments.find(param1->varId());
const std::map<unsigned int, const Token*>::const_iterator it = memAssignments.find(param1->varId());
if (printWarning && scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok))
redundantCopyInSwitchError(it->second, tok, param1->str());
else if (printPerformance)
@ -843,7 +843,7 @@ void CheckOther::checkRedundantAssignmentInSwitch()
else if (Token::Match(tok2->previous(), ";|{|}|: %var% = %name% %or%|& %num% ;") &&
tok2->varId() == tok2->tokAt(2)->varId()) {
std::string bitOp = tok2->strAt(3) + tok2->strAt(4);
std::map<unsigned int, const Token*>::iterator i2 = varsWithBitsSet.find(tok2->varId());
std::map<unsigned int, const Token*>::const_iterator i2 = varsWithBitsSet.find(tok2->varId());
// This variable has not had a bit operation performed on it yet, so just make a note of it
if (i2 == varsWithBitsSet.end()) {
@ -2116,8 +2116,8 @@ void CheckOther::checkInvalidFree()
tok->strAt(3) == "(" ? 4 : 1;
const unsigned int var1 = tok->tokAt(varIndex)->varId();
const unsigned int var2 = tok->tokAt(varIndex + 2)->varId();
const std::map<unsigned int, bool>::iterator alloc1 = allocatedVariables.find(var1);
const std::map<unsigned int, bool>::iterator alloc2 = allocatedVariables.find(var2);
const std::map<unsigned int, bool>::const_iterator alloc1 = allocatedVariables.find(var1);
const std::map<unsigned int, bool>::const_iterator alloc2 = allocatedVariables.find(var2);
if (alloc1 != allocatedVariables.end()) {
invalidFreeError(tok, alloc1->second);
} else if (alloc2 != allocatedVariables.end()) {