From ec4e43767e621c295a449d461b97bc407bc012ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= Date: Thu, 27 Jun 2019 21:57:05 -0700 Subject: [PATCH] minor improvements (#1929) * lib: isNonBoolStdType no longer needed lib/checkbool.cpp:50:13: warning: unused function 'isNonBoolStdType' [-Wunused-function] static bool isNonBoolStdType(const Variable* var) * cmake: C++11 is required also change instructions to a more common syntax --- CMakeLists.txt | 3 +++ cmake/cxx11.cmake | 14 ++++++++++++++ lib/checkbool.cpp | 4 ---- readme.md | 9 +++------ readme.txt | 9 +++------ 5 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 cmake/cxx11.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7634e0792..48b9a7b2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ include(cmake/findDependencies.cmake REQUIRED) include(cmake/compileroptions.cmake REQUIRED) include(cmake/compilerDefinitions.cmake REQUIRED) include(cmake/buildFiles.cmake REQUIRED) +include(cmake/cxx11.cmake REQUIRED) + +use_cxx11() file(GLOB cfgs "cfg/*.cfg") diff --git a/cmake/cxx11.cmake b/cmake/cxx11.cmake new file mode 100644 index 000000000..1fa112a16 --- /dev/null +++ b/cmake/cxx11.cmake @@ -0,0 +1,14 @@ +macro(use_cxx11) + if (CMAKE_VERSION VERSION_LESS "3.1") + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif () + else () + set (CMAKE_CXX_STANDARD 11) + if (POLICY CMP0025) + cmake_policy(SET CMP0025 NEW) + endif () + endif () +endmacro(use_cxx11) diff --git a/lib/checkbool.cpp b/lib/checkbool.cpp index 67c3ae924..ddb419f4e 100644 --- a/lib/checkbool.cpp +++ b/lib/checkbool.cpp @@ -47,10 +47,6 @@ static bool isBool(const Variable* var) { return (var && Token::Match(var->typeEndToken(), "bool|_Bool")); } -static bool isNonBoolStdType(const Variable* var) -{ - return (var && var->typeEndToken()->isStandardType() && !Token::Match(var->typeEndToken(), "bool|_Bool")); -} //--------------------------------------------------------------------------- void CheckBool::checkIncrementBoolean() diff --git a/readme.md b/readme.md index 0074c17d4..264ff71b0 100644 --- a/readme.md +++ b/readme.md @@ -36,15 +36,12 @@ There are multiple compilation choices: Example, compiling Cppcheck with cmake: ```shell -mkdir b -cd b +mkdir build +cd build cmake .. -make +cmake --build . ``` -If you need to specify c++ standard you can do it with the option --DCMAKE_CXX_STANDARD=11 - If you want to compile the GUI you can use the flag -DBUILD_GUI=ON diff --git a/readme.txt b/readme.txt index 3f2a5bf96..bb1ff6025 100644 --- a/readme.txt +++ b/readme.txt @@ -34,13 +34,10 @@ Compiling cmake ===== Example, compiling Cppcheck with cmake: - mkdir b - cd b + mkdir build + cd build cmake .. - make - - If you need to specify c++ standard you can do it with the option - -DCMAKE_CXX_STANDARD=11 + cmake --build . If you want to compile the GUI you can use the flag -DBUILD_GUI=ON