Compare commits

...

3 Commits

Author SHA1 Message Date
Daniel Marjamäki ebeaf98205 1.76.1: set versions 2016-10-12 20:42:32 +02:00
Miika-Petteri Matikainen 1a8d0fd152 Fixes preprocessor regression causing hang
Cppcheck 1.76 introduced a regression in preprocessor which causes
the following code to hang:

    $ cat > test.c << EOF
    #ifndef Y
    #else
    #endif
    EOF
    $ cppcheck -D BAR --force test.c
    Checking test.c ...
    ^C

This used to work with version 1.75. Git bisect reveals that this
regression was caused by commit:
ff036c8742

This commit fixes the regression by avoiding infinite loop in
hasDefine(). If cfg is empty string "", we can skip the whole loop
and exit early.
2016-10-12 20:33:09 +02:00
Daniel Marjamäki 55bfb11692 Makefile: set release mode 2016-10-12 20:31:48 +02:00
6 changed files with 19 additions and 6 deletions

View File

@ -80,7 +80,7 @@ ifeq ($(CXX), clang++)
CPPCHK_GLIBCXX_DEBUG=
endif
ifndef CXXFLAGS
CXXFLAGS=-include lib/cxx11emu.h -pedantic -Wall -Wextra -Wabi -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wshadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar $(CPPCHK_GLIBCXX_DEBUG) -g
CXXFLAGS=-std=c++0x -O2 -include lib/cxx11emu.h -DNDEBUG -Wall -Wno-sign-compare
endif
ifeq ($(CXX), g++)

View File

@ -20,7 +20,7 @@
/**
*
* @mainpage Cppcheck
* @version 1.75
* @version 1.76.1
*
* @section overview_sec Overview
* Cppcheck is a simple tool for static analysis of C/C++ code.

View File

@ -217,6 +217,10 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::set<s
static bool hasDefine(const std::string &userDefines, const std::string &cfg)
{
if (cfg.empty()) {
return false;
}
std::string::size_type pos = 0;
while (pos < userDefines.size()) {
pos = userDefines.find(cfg, pos);

View File

@ -5,8 +5,8 @@
#define STRINGIFY(x) STRING(x)
#define STRING(VER) #VER
#if CPPCHECK_MINOR == CPPCHECK_DEVMINOR
#define CPPCHECK_VERSION_STRING STRINGIFY(CPPCHECK_MAJOR) "." STRINGIFY(CPPCHECK_DEVMINOR)
#define CPPCHECK_VERSION CPPCHECK_MAJOR,CPPCHECK_MINOR,0,0
#define CPPCHECK_VERSION_STRING STRINGIFY(CPPCHECK_MAJOR) "." STRINGIFY(CPPCHECK_DEVMINOR) ".1"
#define CPPCHECK_VERSION CPPCHECK_MAJOR,CPPCHECK_MINOR,1,0
#else
#define CPPCHECK_VERSION_STRING STRINGIFY(CPPCHECK_MAJOR) "." STRINGIFY(CPPCHECK_DEVMINOR) " dev"
#define CPPCHECK_VERSION CPPCHECK_MAJOR,CPPCHECK_MINOR,99,0

View File

@ -224,6 +224,7 @@ private:
TEST_CASE(getConfigsU4);
TEST_CASE(getConfigsU5);
TEST_CASE(getConfigsU6);
TEST_CASE(getConfigsU7);
TEST_CASE(validateCfg);
@ -2121,6 +2122,14 @@ private:
ASSERT_EQUALS("\nX=0\n", getConfigsStr(filedata));
}
void getConfigsU7() {
const char code[] = "#ifndef Y\n"
"#else\n"
"#endif\n";
ASSERT_EQUALS("\nY\n", getConfigsStr(code, "-DX"));
}
void validateCfg() {
Settings settings;
Preprocessor preprocessor(settings, this);

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Include>
<?define ProductName = "Cppcheck $(var.Platform) 1.76" ?>
<?define ProductName = "Cppcheck $(var.Platform) 1.76.1" ?>
<?define ProductNameShort = "Cppcheck" ?>
<?define ProductVersion = "1.76" ?>
<?define ProductVersion = "1.76.1" ?>
<?define ProductManufacturer = "The Cppcheck team" ?>
<?define ProductDescription = "Cppcheck is a tool for static analysis of C/C++ code" ?>