"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/checkvaarg.cpp" between
cppcheck-1.86.tar.gz and cppcheck-1.87.tar.gz

About: Cppcheck is a static analysis tool for C/C++ code. It checks for memory leaks, mismatching allocation-deallocation, buffer overrun, and many more.

checkvaarg.cpp  (cppcheck-1.86):checkvaarg.cpp  (cppcheck-1.87)
/* /*
* Cppcheck - A tool for static C/C++ code analysis * Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2018 Cppcheck team. * Copyright (C) 2007-2019 Cppcheck team.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "checkvaarg.h" #include "checkvaarg.h"
#include "astutils.h"
#include "errorlogger.h" #include "errorlogger.h"
#include "settings.h" #include "settings.h"
#include "symboldatabase.h" #include "symboldatabase.h"
#include "token.h" #include "token.h"
#include "tokenize.h" #include "tokenize.h"
#include <cstddef> #include <cstddef>
#include <list> #include <list>
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
skipping to change at line 109 skipping to change at line 110
if (!var || var->isPointer() || var->isReference() || var->isArray() || !var->scope() || var->typeStartToken()->str() != "va_list") if (!var || var->isPointer() || var->isReference() || var->isArray() || !var->scope() || var->typeStartToken()->str() != "va_list")
continue; continue;
if (!var->isLocal() && !var->isArgument()) // Check only local variables and arguments if (!var->isLocal() && !var->isArgument()) // Check only local variables and arguments
continue; continue;
bool open = var->isArgument(); // va_list passed as argument are opened bool open = var->isArgument(); // va_list passed as argument are opened
bool exitOnEndOfStatement = false; bool exitOnEndOfStatement = false;
const Token* tok = var->nameToken()->next(); const Token* tok = var->nameToken()->next();
for (; tok && tok != var->scope()->bodyEnd; tok = tok->next()) { for (; tok && tok != var->scope()->bodyEnd; tok = tok->next()) {
// Skip lambdas
const Token* tok2 = findLambdaEndToken(tok);
if (tok2)
tok = tok2;
if (Token::Match(tok, "va_start ( %varid%", var->declarationId())) { if (Token::Match(tok, "va_start ( %varid%", var->declarationId())) {
if (open) if (open)
va_start_subsequentCallsError(tok, var->name()); va_start_subsequentCallsError(tok, var->name());
open = true; open = true;
tok = tok->linkAt(1); tok = tok->linkAt(1);
} else if (Token::Match(tok, "va_end ( %varid%", var->declarationId( ))) { } else if (Token::Match(tok, "va_end ( %varid%", var->declarationId( ))) {
if (!open) if (!open)
va_list_usedBeforeStartedError(tok, var->name()); va_list_usedBeforeStartedError(tok, var->name());
open = false; open = false;
tok = tok->linkAt(1); tok = tok->linkAt(1);
 End of changes. 3 change blocks. 
1 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)