Compare commits

..

1 Commits
rawhide ... f29

Author SHA1 Message Date
Steve Grubb a2862be242 add note to patch 3 2019-08-06 14:44:24 -04:00
11 changed files with 485 additions and 240 deletions

14
.gitignore vendored
View File

@ -39,17 +39,3 @@ cppcheck-1.44.tar.bz2
/cppcheck-1.86.tar.gz
/cppcheck-1.87.tar.gz
/cppcheck-1.88.tar.gz
/cppcheck-1.89.tar.gz
/cppcheck-1.90.tar.gz
/cppcheck-2.0.tar.gz
/cppcheck-2.1.tar.gz
/cppcheck-2.2.tar.gz
/cppcheck-2.3.tar.gz
/cppcheck-2.5.tar.gz
/cppcheck-2.6.tar.gz
/cppcheck-2.7.tar.gz
/cppcheck-2.7.3.tar.gz
/cppcheck-2.7.4.tar.gz
/cppcheck-2.8.tar.gz
/cppcheck-2.8.2.tar.gz
/cppcheck-2.9.tar.gz

154
1939.patch Normal file
View File

@ -0,0 +1,154 @@
From 025129663032ab6a2c12e529a0a1a96aeca10db7 Mon Sep 17 00:00:00 2001
From: Robert Reif <reif@FX6840>
Date: Sun, 30 Jun 2019 18:00:28 -0400
Subject: [PATCH] template simplifier: consistently handle templates with no
arguments
this fixes daca boost1.67 crashes
---
lib/templatesimplifier.cpp | 20 ++++++++++----------
test/testsimplifytemplate.cpp | 30 ++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp
index 4a121e642b..0e0423691f 100644
--- a/lib/templatesimplifier.cpp
+++ b/lib/templatesimplifier.cpp
@@ -1048,7 +1048,7 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration)
continue;
}
- if (tok->str() == "<" && templateParameters(tok))
+ if (tok->str() == "<" && (tok->strAt(1) == ">" || templateParameters(tok)))
++templateParmDepth;
// end of template parameters?
@@ -1101,7 +1101,7 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration)
instantiationArgs[index].push_back(tok1);
tok1 = tok1->next();
} while (tok1 && tok1 != endLink);
- } else if (tok1->str() == "<") {
+ } else if (tok1->str() == "<" && (tok1->strAt(1) == ">" || templateParameters(tok1))) {
const Token *endLink = tok1->findClosingBracket();
do {
instantiationArgs[index].push_back(tok1);
@@ -1134,7 +1134,7 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration)
const Token *from = (*it)->next();
std::stack<Token *> links;
while (from && (!links.empty() || indentlevel || !Token::Match(from, ",|>"))) {
- if (from->str() == "<")
+ if (from->str() == "<" && (from->strAt(1) == ">" || templateParameters(from)))
++indentlevel;
else if (from->str() == ">")
--indentlevel;
@@ -1181,7 +1181,7 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration)
}
if (Token::Match(tok2, "(|{|["))
tok2 = tok2->link();
- else if (Token::Match(tok2, "%type% <") && templateParameters(tok2->next())) {
+ else if (Token::Match(tok2, "%type% <") && (tok2->strAt(2) == ">" || templateParameters(tok2->next()))) {
std::list<TokenAndName>::iterator ti = std::find_if(mTemplateInstantiations.begin(),
mTemplateInstantiations.end(),
FindToken(tok2));
@@ -1346,7 +1346,7 @@ bool TemplateSimplifier::instantiateMatch(const Token *instance, const std::size
const Token *tok = instance;
unsigned int indentlevel = 0;
for (tok = instance; tok && (tok->str() != ">" || indentlevel > 0); tok = tok->next()) {
- if (Token::Match(tok, "<|,|(|:: %name% <") && templateParameters(tok->tokAt(2)) > 0)
+ if (Token::Match(tok, "<|,|(|:: %name% <") && (tok->strAt(3) == ">" || templateParameters(tok->tokAt(2))))
++indentlevel;
if (indentlevel > 0 && tok->str() == ">")
--indentlevel;
@@ -1637,7 +1637,7 @@ void TemplateSimplifier::expandTemplate(
typetok = typetok->tokAt(2);
continue;
}
- if (Token::Match(typetok, "%name% <") && templateParameters(typetok->next()) > 0)
+ if (Token::Match(typetok, "%name% <") && (typetok->strAt(2) == ">" || templateParameters(typetok->next())))
++typeindentlevel;
else if (typeindentlevel > 0 && typetok->str() == ">")
--typeindentlevel;
@@ -1859,7 +1859,7 @@ void TemplateSimplifier::expandTemplate(
if (Token::simpleMatch(typetok, ". . .")) {
typetok = typetok->tokAt(2);
} else {
- if (Token::Match(typetok, "%name% <") && templateParameters(typetok->next()) > 0)
+ if (Token::Match(typetok, "%name% <") && (typetok->strAt(2) == ">" || templateParameters(typetok->next())))
++typeindentlevel;
else if (typeindentlevel > 0 && typetok->str() == ">")
--typeindentlevel;
@@ -1939,7 +1939,7 @@ void TemplateSimplifier::expandTemplate(
typetok = typetok->tokAt(2);
continue;
}
- if (Token::Match(typetok, "%name% <") && templateParameters(typetok->next()) > 0)
+ if (Token::Match(typetok, "%name% <") && (typetok->strAt(2) == ">" || templateParameters(typetok->next())))
++typeindentlevel;
else if (typeindentlevel > 0 && typetok->str() == ">")
--typeindentlevel;
@@ -2710,7 +2710,7 @@ std::string TemplateSimplifier::getNewName(
typeForNewName.clear();
break;
}
- if (Token::Match(tok3->tokAt(-2), "<|,|:: %name% <") && templateParameters(tok3) > 0)
+ if (Token::Match(tok3->tokAt(-2), "<|,|:: %name% <") && (tok3->strAt(1) == ">" || templateParameters(tok3)))
++indentlevel;
else if (indentlevel > 0 && Token::Match(tok3, "> [,>]"))
--indentlevel;
@@ -2975,7 +2975,7 @@ void TemplateSimplifier::replaceTemplateUsage(
const Token *typetok = (!mTypesUsedInTemplateInstantiation.empty()) ? mTypesUsedInTemplateInstantiation[0].token : nullptr;
unsigned int indentlevel2 = 0; // indentlevel for tokgt
while (tok2 != endToken && (indentlevel2 > 0 || tok2->str() != ">")) {
- if (tok2->str() == "<" && templateParameters(tok2) > 0)
+ if (tok2->str() == "<" && (tok2->strAt(1) == ">" || templateParameters(tok2)))
++indentlevel2;
else if (indentlevel2 > 0 && Token::Match(tok2, "> [,>]"))
--indentlevel2;
diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp
index c1b3214e2d..bcfcebd03c 100644
--- a/test/testsimplifytemplate.cpp
+++ b/test/testsimplifytemplate.cpp
@@ -157,6 +157,7 @@ class TestSimplifyTemplate : public TestFixture {
TEST_CASE(template117);
TEST_CASE(template118);
TEST_CASE(template119); // #9186
+ TEST_CASE(template120);
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
@@ -2819,6 +2820,35 @@ class TestSimplifyTemplate : public TestFixture {
}
}
+ void template120() {
+ const char code[] = "template<typename Tuple>\n"
+ "struct lambda_context {\n"
+ " template<typename Sig> struct result;\n"
+ " template<typename This, typename I>\n"
+ " struct result<This(terminal, placeholder)> : at<Tuple, I> {};\n"
+ "};\n"
+ "template<typename T>\n"
+ "struct lambda {\n"
+ " template<typename Sig> struct result;\n"
+ " template<typename This>\n"
+ " struct result<This()> : lambda_context<tuple<> > {};\n"
+ "};\n"
+ "lambda<int> l;";
+ const char exp[] = "template < typename Tuple > "
+ "struct lambda_context { "
+ "template < typename Sig > struct result ; "
+ "template < typename This , typename I > "
+ "struct result < This ( terminal , placeholder ) > : at < Tuple , I > { } ; "
+ "} ; "
+ "struct lambda<int> ; "
+ "lambda<int> l ; struct lambda<int> { "
+ "template < typename Sig > struct result ; "
+ "template < typename This > "
+ "struct result < This ( ) > : lambda_context < tuple < > > { } ; "
+ "} ;";
+ ASSERT_EQUALS(exp, tok(code));
+ }
+
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
const char code[] = "template <typename T> struct C {};\n"
"template <typename T> struct S {a};\n"

100
1943.patch Normal file
View File

@ -0,0 +1,100 @@
From e1f980c0e98540cdf0f4210c71dbd7f2d916abe7 Mon Sep 17 00:00:00 2001
From: Robert Reif <reif@FX6840>
Date: Mon, 1 Jul 2019 19:43:23 -0400
Subject: [PATCH] Fixed #9193 (functionStatic false positive (inconclusive))
---
lib/templatesimplifier.cpp | 4 +++-
test/testclass.cpp | 15 +++++++++++++++
test/testsimplifytemplate.cpp | 11 +++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp
index 0e0423691f..893849743a 100644
--- a/lib/templatesimplifier.cpp
+++ b/lib/templatesimplifier.cpp
@@ -1094,19 +1094,21 @@ void TemplateSimplifier::useDefaultArgumentValues(TokenAndName &declaration)
continue;
if (end != instantiation.token->tokAt(2))
instantiationArgs.resize(1);
- for (const Token *tok1 = instantiation.token->tokAt(2); tok1 && tok1!= end; tok1 = tok1->next()) {
+ for (const Token *tok1 = instantiation.token->tokAt(2); tok1 && tok1 != end; tok1 = tok1->next()) {
if (tok1->link() && Token::Match(tok1, "{|(|[")) {
const Token *endLink = tok1->link();
do {
instantiationArgs[index].push_back(tok1);
tok1 = tok1->next();
} while (tok1 && tok1 != endLink);
+ instantiationArgs[index].push_back(tok1);
} else if (tok1->str() == "<" && (tok1->strAt(1) == ">" || templateParameters(tok1))) {
const Token *endLink = tok1->findClosingBracket();
do {
instantiationArgs[index].push_back(tok1);
tok1 = tok1->next();
} while (tok1 && tok1 != endLink);
+ instantiationArgs[index].push_back(tok1);
} else if (tok1->str() == ",") {
++index;
instantiationArgs.resize(index + 1);
diff --git a/test/testclass.cpp b/test/testclass.cpp
index f0ac9cc747..0e0a86d198 100644
--- a/test/testclass.cpp
+++ b/test/testclass.cpp
@@ -174,6 +174,7 @@ class TestClass : public TestFixture {
TEST_CASE(const64); // ticket #6268
TEST_CASE(const65); // ticket #8693
TEST_CASE(const66); // ticket #7714
+ TEST_CASE(const67); // ticket #9193
TEST_CASE(const_handleDefaultParameters);
TEST_CASE(const_passThisToMemberOfOtherClass);
TEST_CASE(assigningPointerToPointerIsNotAConstOperation);
@@ -5661,6 +5662,20 @@ class TestClass : public TestFixture {
ASSERT_EQUALS("", errout.str());
}
+ void const67() { // #9193
+ checkConst("template <class VALUE_T, class LIST_T = std::list<VALUE_T> >\n"
+ "class TestList {\n"
+ "public:\n"
+ " LIST_T m_list;\n"
+ "};\n"
+ "class Test {\n"
+ "public:\n"
+ " const std::list<std::shared_ptr<int>>& get() { return m_test.m_list; }\n"
+ " TestList<std::shared_ptr<int>> m_test;\n"
+ "};\n");
+ ASSERT_EQUALS("[test.cpp:8]: (style, inconclusive) Technically the member function 'Test::get' can be const.\n", errout.str());
+ }
+
void const_handleDefaultParameters() {
checkConst("struct Foo {\n"
" void foo1(int i, int j = 0) {\n"
diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp
index bcfcebd03c..337391571e 100644
--- a/test/testsimplifytemplate.cpp
+++ b/test/testsimplifytemplate.cpp
@@ -158,6 +158,7 @@ class TestSimplifyTemplate : public TestFixture {
TEST_CASE(template118);
TEST_CASE(template119); // #9186
TEST_CASE(template120);
+ TEST_CASE(template121); // #9193
TEST_CASE(template_specialization_1); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_specialization_2); // #7868 - template specialization template <typename T> struct S<C<T>> {..};
TEST_CASE(template_enum); // #6299 Syntax error in complex enum declaration (including template)
@@ -2849,6 +2850,16 @@ class TestSimplifyTemplate : public TestFixture {
ASSERT_EQUALS(exp, tok(code));
}
+ void template121() { // #9193
+ const char code[] = "template <class VALUE_T, class LIST_T = std::list<VALUE_T>>\n"
+ "class TestList { };\n"
+ "TestList<std::shared_ptr<int>> m_test;";
+ const char exp[] = "class TestList<std::shared_ptr<int>,std::list<std::shared_ptr<int>>> ; "
+ "TestList<std::shared_ptr<int>,std::list<std::shared_ptr<int>>> m_test ; "
+ "class TestList<std::shared_ptr<int>,std::list<std::shared_ptr<int>>> { } ;";
+ ASSERT_EQUALS(exp, tok(code));
+ }
+
void template_specialization_1() { // #7868 - template specialization template <typename T> struct S<C<T>> {..};
const char code[] = "template <typename T> struct C {};\n"
"template <typename T> struct S {a};\n"

View File

@ -0,0 +1,27 @@
diff -urp cppcheck-1.85.orig/htmlreport/cppcheck-htmlreport cppcheck-1.85/htmlreport/cppcheck-htmlreport
--- cppcheck-1.85.orig/htmlreport/cppcheck-htmlreport 2018-10-14 14:56:51.000000000 +0200
+++ cppcheck-1.85/htmlreport/cppcheck-htmlreport 2018-11-08 16:26:00.527947956 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
from __future__ import unicode_literals
diff -urp cppcheck-1.85.orig/htmlreport/setup.py cppcheck-1.85/htmlreport/setup.py
--- cppcheck-1.85.orig/htmlreport/setup.py 2018-10-14 14:56:51.000000000 +0200
+++ cppcheck-1.85/htmlreport/setup.py 2018-11-08 16:26:40.266947340 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
from setuptools import setup
diff -urp cppcheck-1.85.orig/htmlreport/test_htmlreport.py cppcheck-1.85/htmlreport/test_htmlreport.py
--- cppcheck-1.85.orig/htmlreport/test_htmlreport.py 2018-10-14 14:56:51.000000000 +0200
+++ cppcheck-1.85/htmlreport/test_htmlreport.py 2018-11-08 16:26:25.963947562 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
"""Test cppcheck-htmlreport."""
import os

View File

@ -0,0 +1,14 @@
diff -urp cppcheck-1.87.orig/cmake/options.cmake cppcheck-1.87/cmake/options.cmake
--- cppcheck-1.87.orig/cmake/options.cmake 2019-02-09 03:31:27.000000000 -0500
+++ cppcheck-1.87/cmake/options.cmake 2019-02-09 13:17:25.237561852 -0500
@@ -22,6 +22,10 @@ option(ANALYZE_UNDEFINED "Clang dynam
option(ANALYZE_DATAFLOW "Clang dynamic analyzer: general dynamic dataflow analysis." OFF)
option(WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF)
option(WARNINGS_ANSI_ISO "Issue all the mandatory diagnostics Listed in C standard" ON)
+option(CFGDIR "Configuration file directory" OFF)
+if(CFGDIR)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCFG=${CFGDIR}")
+endif(CFGDIR)
set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler")
set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify)

View File

@ -1,27 +0,0 @@
diff -up cppcheck-1.88/htmlreport/cppcheck-htmlreport.python3 cppcheck-1.88/htmlreport/cppcheck-htmlreport
--- cppcheck-1.88/htmlreport/cppcheck-htmlreport.python3 2019-06-29 09:51:25.000000000 +0200
+++ cppcheck-1.88/htmlreport/cppcheck-htmlreport 2019-08-14 11:02:23.791627296 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
from __future__ import unicode_literals
diff -up cppcheck-1.88/htmlreport/setup.py.python3 cppcheck-1.88/htmlreport/setup.py
--- cppcheck-1.88/htmlreport/setup.py.python3 2019-06-29 09:51:25.000000000 +0200
+++ cppcheck-1.88/htmlreport/setup.py 2019-08-14 11:02:28.570423533 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
from setuptools import setup
diff -up cppcheck-1.88/htmlreport/test_htmlreport.py.python3 cppcheck-1.88/htmlreport/test_htmlreport.py
--- cppcheck-1.88/htmlreport/test_htmlreport.py.python3 2019-06-29 09:51:25.000000000 +0200
+++ cppcheck-1.88/htmlreport/test_htmlreport.py 2019-08-14 11:02:20.296776345 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
"""Test cppcheck-htmlreport."""
import os

View File

@ -0,0 +1,84 @@
diff -urp cppcheck-1.88.orig/cli/CMakeLists.txt cppcheck-1.88/cli/CMakeLists.txt
--- cppcheck-1.88.orig/cli/CMakeLists.txt 2019-06-29 03:51:25.000000000 -0400
+++ cppcheck-1.88/cli/CMakeLists.txt 2019-07-01 20:38:10.056775258 -0400
@@ -1,5 +1,4 @@
include_directories(${PROJECT_SOURCE_DIR}/lib/)
-include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/)
include_directories(${PROJECT_SOURCE_DIR}/externals/simplecpp/)
file(GLOB hdrs "*.h")
@@ -8,7 +7,7 @@ file(GLOB mainfile "main.cpp")
list(REMOVE_ITEM srcs ${mainfile})
add_library(cli_objs OBJECT ${hdrs} ${srcs})
-add_executable(cppcheck ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:tinyxml_objs> $<TARGET_OBJECTS:simplecpp_objs>)
+add_executable(cppcheck ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
if (HAVE_RULES)
find_library(PCRE_LIBRARY pcre)
target_link_libraries(cppcheck ${PCRE_LIBRARY})
@@ -18,6 +17,7 @@ endif()
if (WIN32 AND NOT BORLAND)
target_link_libraries(cppcheck Shlwapi.lib)
endif()
+target_link_libraries(cppcheck tinyxml2)
install(TARGETS cppcheck
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
diff -urp cppcheck-1.88.orig/CMakeLists.txt cppcheck-1.88/CMakeLists.txt
--- cppcheck-1.88.orig/CMakeLists.txt 2019-06-29 03:51:25.000000000 -0400
+++ cppcheck-1.88/CMakeLists.txt 2019-07-01 20:38:10.078775256 -0400
@@ -19,7 +19,6 @@ if (BUILD_TESTS)
enable_testing()
endif()
-add_subdirectory(externals/tinyxml)
add_subdirectory(externals/simplecpp)
add_subdirectory(lib) # CppCheck Library
add_subdirectory(cli) # Client application
diff -urp cppcheck-1.88.orig/gui/CMakeLists.txt cppcheck-1.88/gui/CMakeLists.txt
--- cppcheck-1.88.orig/gui/CMakeLists.txt 2019-06-29 03:51:25.000000000 -0400
+++ cppcheck-1.88/gui/CMakeLists.txt 2019-07-01 20:41:48.862751778 -0400
@@ -10,7 +10,6 @@ if (BUILD_GUI)
endif()
include_directories(${PROJECT_SOURCE_DIR}/lib/)
- include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml/)
file(GLOB hdrs "*.h")
file(GLOB srcs "*.cpp")
@@ -20,11 +19,11 @@ if (BUILD_GUI)
QT5_ADD_RESOURCES(resources "gui.qrc")
QT5_ADD_TRANSLATION(qms ${tss})
- add_executable(cppcheck-gui ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:tinyxml_objs> $<TARGET_OBJECTS:simplecpp_objs>)
+ add_executable(cppcheck-gui ${hdrs} ${srcs} ${uis_hdrs} ${resources} ${qms} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
if (HAVE_RULES)
target_link_libraries(cppcheck-gui pcre)
endif()
- target_link_libraries(cppcheck-gui Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport)
+ target_link_libraries(cppcheck-gui tinyxml2 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport)
if(WITH_QCHART)
target_compile_definitions (cppcheck-gui PRIVATE HAVE_QCHART )
target_link_libraries(cppcheck-gui Qt5::Charts)
diff -urp cppcheck-1.88.orig/test/CMakeLists.txt cppcheck-1.88/test/CMakeLists.txt
--- cppcheck-1.88.orig/test/CMakeLists.txt 2019-06-29 03:51:25.000000000 -0400
+++ cppcheck-1.88/test/CMakeLists.txt 2019-07-01 20:43:12.299742824 -0400
@@ -1,16 +1,16 @@
if (BUILD_TESTS)
include_directories(${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/cli/)
- include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/externals/tinyxml)
include_directories(${PROJECT_SOURCE_DIR}/externals/simplecpp/)
file(GLOB hdrs "*.h")
file(GLOB srcs "*.cpp")
- add_executable(testrunner ${hdrs} ${srcs} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:tinyxml_objs> $<TARGET_OBJECTS:simplecpp_objs>)
+ add_executable(testrunner ${hdrs} ${srcs} $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:simplecpp_objs>)
if (HAVE_RULES)
target_link_libraries(testrunner pcre)
endif()
+ target_link_libraries(testrunner tinyxml2)
add_custom_target(copy_cfg ALL
COMMENT "Copying cfg files")

View File

@ -0,0 +1,39 @@
Only in cppcheck-1.88: .astylerc
Only in cppcheck-1.88: .codacy.yml
Only in cppcheck-1.88: .gitignore
diff -urp cppcheck-1.88.orig/gui/CMakeLists.txt cppcheck-1.88/gui/CMakeLists.txt
--- cppcheck-1.88.orig/gui/CMakeLists.txt 2019-07-01 20:46:32.662721323 -0400
+++ cppcheck-1.88/gui/CMakeLists.txt 2019-07-01 20:48:29.298708807 -0400
@@ -30,7 +30,7 @@ if (BUILD_GUI)
endif()
install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
- install(FILES ${qms} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
+ install(FILES ${qms} DESTINATION share/${PROJECT_NAME}/lang COMPONENT applications)
install(FILES cppcheck-gui.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
diff -urp cppcheck-1.88.orig/gui/translationhandler.cpp cppcheck-1.88/gui/translationhandler.cpp
--- cppcheck-1.88.orig/gui/translationhandler.cpp 2019-06-29 03:51:25.000000000 -0400
+++ cppcheck-1.88/gui/translationhandler.cpp 2019-07-01 20:49:18.750703500 -0400
@@ -116,15 +116,7 @@ bool TranslationHandler::setLanguage(con
if (datadir.isEmpty())
datadir = appPath;
- QString translationFile;
- if (QFile::exists(datadir + "/lang/" + mTranslations[index].mFilename + ".qm"))
- translationFile = datadir + "/lang/" + mTranslations[index].mFilename + ".qm";
-
- else if (QFile::exists(datadir + "/" + mTranslations[index].mFilename + ".qm"))
- translationFile = datadir + "/" + mTranslations[index].mFilename + ".qm";
-
- else
- translationFile = appPath + "/" + mTranslations[index].mFilename + ".qm";
+ QString translationFile("/usr/share/CppCheck/lang/" + mTranslations[index].mFilename + ".qm");
if (!mTranslator->load(translationFile) && !failure) {
//If it failed, lets check if the default file exists
Only in cppcheck-1.88: .mailmap
Only in cppcheck-1.88: .travis_llvmcheck_suppressions
Only in cppcheck-1.88: .travis_suppressions
Only in cppcheck-1.88: .travis.yml

View File

@ -1,32 +0,0 @@
diff -urp cppcheck-2.2.orig/gui/CMakeLists.txt cppcheck-2.2/gui/CMakeLists.txt
--- cppcheck-2.2.orig/gui/CMakeLists.txt 2020-10-03 11:05:53.000000000 +0200
+++ cppcheck-2.2/gui/CMakeLists.txt 2020-10-04 07:18:23.309796000 +0200
@@ -40,7 +40,7 @@ if (BUILD_GUI)
endif()
install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
- install(FILES ${qms} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
+ install(FILES ${qms} DESTINATION share/${PROJECT_NAME}/lang COMPONENT applications)
install(FILES cppcheck-gui.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
diff -urp cppcheck-2.2.orig/gui/translationhandler.cpp cppcheck-2.2/gui/translationhandler.cpp
--- cppcheck-2.2.orig/gui/translationhandler.cpp 2020-10-03 11:05:53.000000000 +0200
+++ cppcheck-2.2/gui/translationhandler.cpp 2020-10-04 07:19:44.765892500 +0200
@@ -113,15 +113,7 @@ bool TranslationHandler::setLanguage(con
QString datadir = getDataDir();
- QString translationFile;
- if (QFile::exists(datadir + "/lang/" + mTranslations[index].mFilename + ".qm"))
- translationFile = datadir + "/lang/" + mTranslations[index].mFilename + ".qm";
-
- else if (QFile::exists(datadir + "/" + mTranslations[index].mFilename + ".qm"))
- translationFile = datadir + "/" + mTranslations[index].mFilename + ".qm";
-
- else
- translationFile = appPath + "/" + mTranslations[index].mFilename + ".qm";
+ QString translationFile("/usr/share/Cppcheck/lang/" + mTranslations[index].mFilename + ".qm");
if (!mTranslator->load(translationFile) && !failure) {
//If it failed, lets check if the default file exists

View File

@ -1,34 +1,49 @@
%undefine __cmake_in_source_build
# Gui built in all branches
%global gui 1
Name: cppcheck
Version: 2.9
Version: 1.88
Release: 4%{?dist}
Summary: Tool for static C/C++ code analysis
License: GPL-3.0
License: GPLv3+
URL: http://cppcheck.wiki.sourceforge.net/
Source0: https://github.com/danmar/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
# Use system tinyxml2
Patch0: cppcheck-1.88-tinyxml.patch
# Fix location of translations
Patch0: cppcheck-2.2-translations.patch
# Select python3 explicitly
Patch1: cppcheck-1.88-htmlreport-python3.patch
Patch1: cppcheck-1.88-translations.patch
# Set location of config files
Patch2: cppcheck-1.87-cfgdir.patch
# Select python2 explicitly because htmlreport/README.txt says it's
# implemented using Python2.7. Without it the package fails to build on F30.
Patch3: cppcheck-1.85-htmlreport-python2.patch
# BZ #1733663
Patch4: https://github.com/danmar/cppcheck/pull/1939.patch
# BZ #1733663
Patch5: https://github.com/danmar/cppcheck/pull/1943.patch
BuildRequires: gcc-c++
BuildRequires: pcre-devel
BuildRequires: docbook-style-xsl
BuildRequires: libxslt
BuildRequires: pandoc
BuildRequires: cmake
BuildRequires: desktop-file-utils
BuildRequires: tinyxml2-devel >= 2.1.0
BuildRequires: zlib-devel
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-qttools-devel
BuildRequires: qt5-linguist
BuildRequires: make
%if %{gui}
%if 0%{?rhel} == 7
# no qt5-devel metapackage!
BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-linguist
%else
BuildRequires: qt5-devel
%endif
%else
Obsoletes: %{name}-gui < %{version}-%{release}
%endif
%description
Cppcheck is a static analysis tool for C/C++ code. Unlike C/C++
@ -37,17 +52,24 @@ errors in the code. Cppcheck primarily detects the types of bugs that
the compilers normally do not detect. The goal is to detect only real
errors in the code (i.e. have zero false positives).
%if %{gui}
%package gui
Summary: Graphical user interface for cppcheck
Requires: %{name}%{?_isa} = %{version}-%{release}
%description gui
This package contains the graphical user interface for cppcheck.
%endif
%package htmlreport
Summary: HTML reporting for cppcheck
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: python3-pygments
%if 0%{?rhel} > 0 && 0%{?rhel} < 8
# RHEL packages aren't versioned
Requires: python-pygments
%else
Requires: python2-pygments
%endif
%description htmlreport
This package contains the Python utility for generating html reports
@ -55,195 +77,73 @@ from xml files first generated using cppcheck.
%prep
%setup -q
%patch0 -p1 -b .translations
%patch1 -p1 -b .python3
# Make sure bundled tinyxml2 is not used
rm -r externals/tinyxml2
# Generate the Qt online-help file
cd gui/help
qhelpgenerator-qt5 online-help.qhcp -o online-help.qhc
%patch0 -p1 -b .tinyxml
%patch1 -p1 -b .translations
%patch2 -p1 -b .cfgdir
%patch3 -p1 -b .python2
%patch4 -p1 -b .bz1733663a
%patch5 -p1 -b .bz1733663b
# Make sure bundled tinyxml is not used
rm -r externals/tinyxml
%build
# Manuals
make DB2MAN=%{_datadir}/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl man
pandoc man/manual.md -o man/manual.html -s --number-sections --toc
pandoc man/reference-cfg-format.md -o man/reference-cfg-format.html -s --number-sections --toc
make DB2MAN=%{_datadir}/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl man
xsltproc --nonet -o man/manual.html \
%{_datadir}/sgml/docbook/xsl-stylesheets/xhtml/docbook.xsl \
man/manual.docbook
# Binaries
mkdir objdir-%{_target_platform}
cd objdir-%{_target_platform}
# Upstream doesn't support shared libraries (unversioned solib)
%cmake -DCMAKE_BUILD_TYPE=Release -DUSE_MATCHCOMPILER=yes -DHAVE_RULES=yes -DBUILD_GUI=1 -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_TESTS=yes -DFILESDIR=%{_datadir}/Cppcheck -DUSE_BUNDLED_TINYXML2=OFF -DENABLE_OSS_FUZZ=OFF
%cmake_build
%cmake .. -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=1 -DBUILD_GUI=%{gui} -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_TESTS=1 -DCFGDIR=%{_datadir}/Cppcheck
# SMP make doesn't seem to work
make cppcheck
%install
rm -rf %{buildroot}
%cmake_install
make -C objdir-%{_target_platform} DESTDIR=%{buildroot} install
install -D -p -m 644 cppcheck.1 %{buildroot}%{_mandir}/man1/cppcheck.1
%if %{gui}
# Install desktop file
desktop-file-validate %{buildroot}%{_datadir}/applications/cppcheck-gui.desktop
# Install logo
install -D -p -m 644 gui/cppcheck-gui.png %{buildroot}%{_datadir}/pixmaps/cppcheck-gui.png
# Install the Qt online-help file
install -D -p -m 644 gui/help/online-help.qhc %{buildroot}%{_datadir}/Cppcheck/help/online-help.qhc
install -D -p -m 644 gui/help/online-help.qch %{buildroot}%{_datadir}/Cppcheck/help/online-help.qch
%endif
# Install htmlreport
install -D -p -m 755 htmlreport/cppcheck-htmlreport %{buildroot}%{_bindir}/cppcheck-htmlreport
# Restore execute permission of python files
grep -l "#\!/usr/bin/env python3" %{buildroot}%{_datadir}/Cppcheck/addons/*.py | xargs chmod +x
%check
cd %{_vpath_builddir}/bin
cd objdir-%{_target_platform}/bin
./testrunner -g -q
%files
%doc AUTHORS man/manual.html man/reference-cfg-format.html
%license COPYING
%doc AUTHORS COPYING man/manual.html
%{_datadir}/Cppcheck/
%{_bindir}/cppcheck
%{_mandir}/man1/cppcheck.1*
%if %{gui}
%files gui
%{_bindir}/cppcheck-gui
%{_datadir}/applications/cppcheck-gui.desktop
%{_datadir}/pixmaps/cppcheck-gui.png
%{_datadir}/icons/hicolor/64x64/apps/cppcheck-gui.png
%{_datadir}/icons/hicolor/scalable/apps/cppcheck-gui.svg
%endif
%files htmlreport
%{_bindir}/cppcheck-htmlreport
%changelog
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.9-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Fri Jan 13 2023 Steve Grubb <sgrubb@redhat.com> - 2.9-3
- SPDX Migration
* Sun Sep 25 2022 Rich Mattes <richmattes@gmail.com> - 2.9-2
- Rebuild for tinyxml2-9.0.0
* Sun Aug 28 2022 Wolfgang Stöggl <c72578@yahoo.de> - 2.9-1
- Update to 2.9
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.8.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sat Jul 16 2022 Wolfgang Stöggl <c72578@yahoo.de> - 2.8.2-1
- Update to 2.8.2
* Wed May 25 2022 Wolfgang Stöggl <c72578@yahoo.de> - 2.8-1
- Update to 2.8
* Thu May 19 2022 Jerry James <loganjerry@gmail.com> - 2.7.4-2
- Rebuild for z3 4.8.17
* Fri Mar 25 2022 Wolfgang Stöggl <c72578@yahoo.de> - 2.7.4-1
- Update to 2.7.4
* Wed Mar 23 2022 Wolfgang Stöggl <c72578@yahoo.de> - 2.7.3-2
- Update tinyxml2 patch, add upstream link and rebuild
* Sat Mar 19 2022 Wolfgang Stöggl <c72578@yahoo.de> - 2.7.3-1
- Update to 2.7.3.
* Tue Feb 08 2022 Wolfgang Stöggl <c72578@yahoo.de> - 2.7-1
- Update to 2.7.
* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Sat Oct 02 2021 Wolfgang Stöggl <c72578@yahoo.de> - 2.6-1
- Update to 2.6.
* Fri Jul 23 2021 Wolfgang Stöggl <c72578@yahoo.de> - 2.5-3
- Fix Failed to load translation for English (#1983599)
* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Sun Jul 04 2021 Wolfgang Stöggl <c72578@yahoo.de> - 2.5-1
- Update to 2.5.
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jan 05 2021 Timm Bäder <tbaeder@redhat.com> - 2.3-2
- Explicitly disable oss-fuzz
* Sat Dec 05 2020 Wolfgang Stöggl <c72578@yahoo.de> - 2.3-1
- Update to 2.3.
* Sun Nov 08 2020 Wolfgang Stöggl <c72578@yahoo.de> - 2.2-5
- Add cppcheck-2.2-online-help_q_readonly.patch
* Thu Oct 22 2020 Wolfgang Stöggl <c72578@yahoo.de> - 2.2-4
- Fix missing Contents and Index in Qt online-help file
* Tue Oct 13 2020 Jeff Law <law@redhat.com> - 2.2-3
- Fix missing #include for gcc-11
* Sun Oct 11 2020 Wolfgang Stöggl <c72578@yahoo.de> - 2.2-2
- Fix Helpfile 'online-help.qhc' was not found
* Sun Oct 04 2020 Wolfgang Stöggl <c72578@yahoo.de> - 2.2-1
- Update to 2.2.
* Tue Aug 18 2020 Susi Lehtola <jussilehtola@fedoraproject.org> - 2.1-7
- Gui package is always built.
* Tue Aug 04 2020 Wolfgang Stöggl <c72578@yahoo.de> - 2.1-6
- Fix FTBFS #1863368
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.1-5
- Second attempt - Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jun 16 2020 Susi Lehtola <jussilehtola@fedoraproject.org> - 2.1-3
- Drop EPEL specifics since cppcheck is included in RHEL8.
* Tue Jun 16 2020 Wolfgang Stöggl <c72578@yahoo.de> - 2.1-2
- Enable Z3 on Fedora builds.
* Mon Jun 15 2020 Susi Lehtola <jussilehtola@fedoraproject.org> - 2.1-1
- Update to 2.1.
* Mon May 11 2020 Susi Lehtola <jussilehtola@fedoraproject.org> - 2.0-1
- Update to 2.0.
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.90-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Tue Dec 24 2019 Wolfgang Stöggl <c72578@yahoo.de> - 1.90-4
- Use python3 on EPEL7
* Mon Dec 23 2019 Susi Lehtola <jussilehtola@fedoraproject.org> - 1.90-3
- Fix typo in CMake flag (Stöggl's pull request #3).
* Sat Dec 21 2019 Susi Lehtola <jussilehtola@fedoraproject.org> - 1.90-2
- Adaptations to build also on EPEL 7.
* Sat Dec 21 2019 Wolfgang Stöggl <c72578@yahoo.de> - 1.90-1
- New upstream version 1.90
* Thu Dec 12 2019 Steve Grubb <sgrubb@redhat.com> - 1.89-2
- Add "-fsigned-char" to CXXFLAGS, to make tests pass
- https://trac.cppcheck.net/ticket/9359
* Sat Dec 07 2019 Steve Grubb <sgrubb@redhat.com> - 1.89-1
- New upstream release 1.89
* Fri Aug 16 2019 Susi Lehtola <susi.lehtola@iki.fi> - 1.88-5
- rebuilt
* Wed Aug 14 2019 Susi Lehtola <jussilehtola@redhat.com> - 1.88-5
- Switch to python3 in htmlreport (BZ #1737972).
* Mon Jul 29 2019 Susi Lehtola <jussilehtola@redhat.com> - 1.88-4
* Mon Jul 29 2019 Susi Lehtola <jussilehtola@redhat.com> - 1.89-4
- Second patch for another issue in BZ #1733663.
* Sat Jul 27 2019 Susi Lehtola <jussilehtola@redhat.com> - 1.88-3
* Sat Jul 27 2019 Susi Lehtola <jussilehtola@redhat.com> - 1.89-3
- Fix BZ #1733663.
* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.88-2

View File

@ -1 +1 @@
SHA512 (cppcheck-2.9.tar.gz) = 69204a7ceac087470201482894e6422b99d0849f08641e80b2e341c9d164a1d2095e3a08a1fba2e9fa681783d07fe7277b30ea0cc0bf582431b5d13ab2f58c1f
SHA512 (cppcheck-1.88.tar.gz) = fa4ede0665546341af0ba3dae09a00b6efae09ec7838c616c580be01ff6902594d61168a059539779be0c78e1708d2bd9c8e7987dd0bb67dc8fa332a10d1de6a