Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ if (USE_Z3)
add_definitions(-DUSE_Z3)
endif()

if (Boost_FOUND)
add_definitions(-DHAVE_BOOST)
endif()

if (ENABLE_CHECK_INTERNAL)
add_definitions(-DCHECK_INTERNAL)
endif()
Expand Down
4 changes: 4 additions & 0 deletions cmake/findDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ endif()
if (USE_THREADS)
find_package(Threads REQUIRED)
endif()

if (USE_BOOST)
find_package(Boost COMPONENTS container QUIET)
endif()
1 change: 1 addition & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ option(USE_Z3 "Usage of z3 library"
option(USE_BUNDLED_TINYXML2 "Usage of bundled tinyxml2 library" ON)
option(CPPCHK_GLIBCXX_DEBUG "Usage of _GLIBCXX_DEBUG in Debug build" ON)
option(USE_THREADS "Usage of threads instead of fork() for -j" OFF)
option(USE_BOOST "Usage of Boost" OFF)

if (CMAKE_VERSION VERSION_EQUAL "3.16" OR CMAKE_VERSION VERSION_GREATER "3.16")
set(CMAKE_DISABLE_PRECOMPILE_HEADERS Off CACHE BOOL "Disable precompiled headers")
Expand Down
9 changes: 9 additions & 0 deletions cmake/printInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ message( STATUS "C++ flags (General) = ${CMAKE_CXX_FLAGS}")
message( STATUS "C++ flags (Release) = ${CMAKE_CXX_FLAGS_RELEASE}")
message( STATUS "C++ flags (RelWithDebInfo) = ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
message( STATUS "C++ flags (Debug) = ${CMAKE_CXX_FLAGS_DEBUG}")
message( STATUS "CPPCHK_GLIBCXX_DEBUG = ${CPPCHK_GLIBCXX_DEBUG}" )
get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
foreach( d ${DirDefs} )
message( STATUS "Found Define: " ${d} )
Expand Down Expand Up @@ -62,11 +63,19 @@ if (USE_Z3)
message( STATUS "Z3_LIBRARIES = ${Z3_LIBRARIES}" )
message( STATUS "Z3_CXX_INCLUDE_DIRS = ${Z3_CXX_INCLUDE_DIRS}" )
endif()
message( STATUS )
message( STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}" )
if (NOT USE_BUNDLED_TINYXML2)
message(STATUS "tinyxml2_LIBRARY = ${tinyxml2_LIBRARY}")
endif()
message( STATUS )
message( STATUS "USE_BOOST = ${USE_BOOST}" )
if (USE_BOOST)
message( STATUS "Boost_FOUND = ${Boost_FOUND}")
message( STATUS "Boost_VERSION_STRING = ${Boost_VERSION_STRING}")
message( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
endif()
message( STATUS )

if(${ANALYZE_ADDRESS})
message("##########################################################")
Expand Down
3 changes: 3 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ endif()
if (USE_Z3)
target_include_directories(lib_objs SYSTEM PRIVATE ${Z3_CXX_INCLUDE_DIRS})
endif()
if (Boost_FOUND)
target_include_directories(lib_objs SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
endif()

if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
target_precompile_headers(lib_objs PRIVATE precompiled.h)
Expand Down
47 changes: 47 additions & 0 deletions lib/smallvector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2022 Cppcheck team.
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef smallvectorH
#define smallvectorH

#include <cstddef>

static constexpr std::size_t DefaultSmallVectorSize = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldnt we want to default to be something like 4?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be adjusted when the actual usage is added. Seems we will end up with 5 for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you going to set this to 5?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said I will do this in the follow-up(s) (one will drop shortly after this is in, the other in the following days). Currently nobody is using it and I want those changes tied together.


#ifdef HAVE_BOOST
#include <boost/container/small_vector.hpp>

template<typename T, std::size_t N = DefaultSmallVectorSize>
using SmallVector = boost::container::small_vector<T, N>;
#else
#include <vector>

template<class T, std::size_t N>
struct TaggedAllocator : std::allocator<T>
{
template<class ... Ts>
TaggedAllocator(Ts&&... ts)
: std::allocator<T>(std::forward<Ts>(ts)...)
{}
};

template<typename T, std::size_t N = DefaultSmallVectorSize>
using SmallVector = std::vector<T, TaggedAllocator<T, N>>;
#endif

#endif