From bf5c71bdcad9a590a448686e18e7877bc28289bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= Date: Fri, 17 May 2019 00:31:41 -0700 Subject: [PATCH] sync (#1835) * build: remove -Wabi and add -Wundef gcc >= 8 throws a warning about -Wabi (without a specific ABI version) being ignored, while -Wundef seems more useful (as shown by the change in config.h, which was probably an unfortunate typo) travis.yaml should probably be updated soon, but was left out from this change as the current images don't yet need it * lib: unused function in valueflow refactored out since 8c03be32122ed85af89050eb1ad07ddd7038508e lib/valueflow.cpp:3124:21: warning: unused function 'endTemplateArgument' [-Wunused-function] * readme: include picojson * make: also clean exe --- Makefile | 6 +++--- cmake/compileroptions.cmake | 1 - lib/config.h | 2 +- lib/valueflow.cpp | 13 ------------- readme.md | 4 ++-- readme.txt | 4 ++-- readmeja.md | 4 ++-- tools/dmake.cpp | 2 +- 8 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 0a51d5a79..ea69faa83 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ ifeq (clang++, $(findstring clang++,$(CXX))) CPPCHK_GLIBCXX_DEBUG= endif ifndef CXXFLAGS - CXXFLAGS=-pedantic -Wall -Wextra -Wabi -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar $(CPPCHK_GLIBCXX_DEBUG) -g + CXXFLAGS=-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar $(CPPCHK_GLIBCXX_DEBUG) -g endif ifeq (g++, $(findstring g++,$(CXX))) @@ -277,7 +277,7 @@ run-dmake: dmake generate_cfg_tests: tools/generate_cfg_tests.o $(EXTOBJ) g++ -isystem externals/tinyxml -o generate_cfg_tests tools/generate_cfg_tests.o $(EXTOBJ) clean: - rm -f build/*.o lib/*.o cli/*.o test/*.o tools/*.o externals/*/*.o testrunner dmake cppcheck cppcheck.1 + rm -f build/*.o lib/*.o cli/*.o test/*.o tools/*.o externals/*/*.o testrunner dmake cppcheck cppcheck.exe cppcheck.1 man: man/cppcheck.1 @@ -422,7 +422,7 @@ $(SRCDIR)/checktype.o: lib/checktype.cpp lib/checktype.h lib/check.h lib/config. $(SRCDIR)/checkuninitvar.o: lib/checkuninitvar.cpp lib/checkuninitvar.h lib/check.h lib/config.h lib/errorlogger.h lib/suppressions.h lib/settings.h lib/importproject.h lib/platform.h lib/utils.h lib/library.h lib/mathlib.h lib/standards.h lib/timer.h lib/token.h lib/valueflow.h lib/templatesimplifier.h lib/tokenize.h lib/tokenlist.h lib/ctu.h lib/astutils.h lib/checknullpointer.h lib/symboldatabase.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(SRCDIR)/checkuninitvar.o $(SRCDIR)/checkuninitvar.cpp -$(SRCDIR)/checkunusedfunctions.o: lib/checkunusedfunctions.cpp lib/checkunusedfunctions.h lib/check.h lib/config.h lib/errorlogger.h lib/suppressions.h lib/settings.h lib/importproject.h lib/platform.h lib/utils.h lib/library.h lib/mathlib.h lib/standards.h lib/timer.h lib/token.h lib/valueflow.h lib/templatesimplifier.h lib/tokenize.h lib/tokenlist.h lib/symboldatabase.h +$(SRCDIR)/checkunusedfunctions.o: lib/checkunusedfunctions.cpp lib/checkunusedfunctions.h lib/check.h lib/config.h lib/errorlogger.h lib/suppressions.h lib/settings.h lib/importproject.h lib/platform.h lib/utils.h lib/library.h lib/mathlib.h lib/standards.h lib/timer.h lib/token.h lib/valueflow.h lib/templatesimplifier.h lib/tokenize.h lib/tokenlist.h lib/astutils.h lib/symboldatabase.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(SRCDIR)/checkunusedfunctions.o $(SRCDIR)/checkunusedfunctions.cpp $(SRCDIR)/checkunusedvar.o: lib/checkunusedvar.cpp lib/checkunusedvar.h lib/check.h lib/config.h lib/errorlogger.h lib/suppressions.h lib/settings.h lib/importproject.h lib/platform.h lib/utils.h lib/library.h lib/mathlib.h lib/standards.h lib/timer.h lib/token.h lib/valueflow.h lib/templatesimplifier.h lib/tokenize.h lib/tokenlist.h lib/astutils.h lib/symboldatabase.h diff --git a/cmake/compileroptions.cmake b/cmake/compileroptions.cmake index 545e6beb6..c406c1e84 100644 --- a/cmake/compileroptions.cmake +++ b/cmake/compileroptions.cmake @@ -42,7 +42,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") message(FATAL_ERROR "${PROJECT_NAME} c++11 support requires g++ 4.6 or greater, but it is ${GCC_VERSION}") endif () - set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wabi") set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wcast-qual") # Cast for removing type qualifiers set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wconversion") # Implicit conversions that may alter a value set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wfloat-equal") # Floating values used in equality comparisons diff --git a/lib/config.h b/lib/config.h index 853ad46db..859e3ebb0 100644 --- a/lib/config.h +++ b/lib/config.h @@ -20,7 +20,7 @@ #endif // C++11 override -#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC >= 5)) || defined(__CPPCHECK__) +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__CPPCHECK__) # define OVERRIDE override #else # define OVERRIDE diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 8cd0184ce..2d50e32b6 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3121,19 +3121,6 @@ struct LifetimeStore { } }; -static const Token *endTemplateArgument(const Token *tok) -{ - for (; tok; tok = tok->next()) { - if (Token::Match(tok, ">|,")) - return tok; - else if (tok->link() && Token::Match(tok, "(|{|[|<")) - tok = tok->link(); - else if (Token::simpleMatch(tok, ";")) - return nullptr; - } - return nullptr; -} - static void valueFlowLifetimeFunction(Token *tok, TokenList *tokenlist, ErrorLogger *errorLogger, const Settings *settings) { if (!Token::Match(tok, "%name% (")) diff --git a/readme.md b/readme.md index 01be0f145..eb49f7c57 100644 --- a/readme.md +++ b/readme.md @@ -91,13 +91,13 @@ Flags: If you just want to build Cppcheck without dependencies then you can use this command: ```shell -g++ -o cppcheck -std=c++11 -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp +g++ -o cppcheck -std=c++11 -Iexternals -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp ``` If you want to use `--rule` and `--rule-file` then dependencies are needed: ```shell -g++ -o cppcheck -std=c++11 -lpcre -DHAVE_RULES -Ilib -Iexternals/simplecpp -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp +g++ -o cppcheck -std=c++11 -lpcre -DHAVE_RULES -Ilib -Iexternals -Iexternals/simplecpp -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp ``` ### MinGW diff --git a/readme.txt b/readme.txt index ad7d50a7a..5a2e55c29 100644 --- a/readme.txt +++ b/readme.txt @@ -68,10 +68,10 @@ Compiling g++ (for experts) ================= If you just want to build Cppcheck without dependencies then you can use this command: - g++ -o cppcheck -std=c++11 -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp + g++ -o cppcheck -std=c++11 -Iexternals -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp If you want to use --rule and --rule-file then dependencies are needed: - g++ -o cppcheck -std=c++11 -lpcre -DHAVE_RULES -Ilib -Iexternals/simplecpp -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp + g++ -o cppcheck -std=c++11 -lpcre -DHAVE_RULES -Ilib -Iexternals -Iexternals/simplecpp -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp mingw ===== diff --git a/readmeja.md b/readmeja.md index fa629ef61..0ca694a37 100644 --- a/readmeja.md +++ b/readmeja.md @@ -91,13 +91,13 @@ cppcheckの設定ファイル(.cfg)を置くディレクトリを指定します 依存関係なく Cppcheckをビルドしたい場合、次のコマンドを利用できます。 ```shell -g++ -o cppcheck -std=c++11 -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp +g++ -o cppcheck -std=c++11 -Iexternals -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp ``` `--rule` や `--rule-file` を利用する場合、依存ライブラリが必要です。 ```shell -g++ -o cppcheck -std=c++11 -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp +g++ -o cppcheck -std=c++11 -lpcre -DHAVE_RULES -Iexternals -Iexternals/simplecpp -Iexternals/tinyxml -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml/*.cpp ``` ### MinGW diff --git a/tools/dmake.cpp b/tools/dmake.cpp index f1e68377d..895700e78 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -290,7 +290,6 @@ int main(int argc, char **argv) "-pedantic " "-Wall " "-Wextra " - "-Wabi " "-Wcast-qual " // "-Wconversion " // danmar: gives fp. for instance: unsigned int sizeof_pointer = sizeof(void *); "-Wno-deprecated-declarations " @@ -302,6 +301,7 @@ int main(int argc, char **argv) // "-Woverloaded-virtual " // danmar: we get fp when overloading analyseWholeProgram() "-Wpacked " "-Wredundant-decls " + "-Wundef " "-Wno-shadow " // "-Wsign-conversion " // "-Wsign-promo "