diff --git a/cmake/compilerDefinitions.cmake b/cmake/compilerDefinitions.cmake
index 658385e60..905a9de76 100644
--- a/cmake/compilerDefinitions.cmake
+++ b/cmake/compilerDefinitions.cmake
@@ -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()
diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake
index d1cf61848..00bbf53ec 100644
--- a/cmake/findDependencies.cmake
+++ b/cmake/findDependencies.cmake
@@ -60,3 +60,7 @@ endif()
if (USE_THREADS)
find_package(Threads REQUIRED)
endif()
+
+if (USE_BOOST)
+ find_package(Boost COMPONENTS container QUIET)
+endif()
diff --git a/cmake/options.cmake b/cmake/options.cmake
index 5fe68beaa..709895fd2 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -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")
diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake
index 6d19cd631..e8c9995a8 100644
--- a/cmake/printInfo.cmake
+++ b/cmake/printInfo.cmake
@@ -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} )
@@ -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_LIBRARIES = ${tinyxml2_LIBRARIES}")
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("##########################################################")
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 48c70ec3e..01752bd7a 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -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)
diff --git a/lib/smallvector.h b/lib/smallvector.h
new file mode 100644
index 000000000..acdba2562
--- /dev/null
+++ b/lib/smallvector.h
@@ -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 .
+ */
+
+#ifndef smallvectorH
+#define smallvectorH
+
+#include
+
+static constexpr std::size_t DefaultSmallVectorSize = 0;
+
+#ifdef HAVE_BOOST
+#include
+
+template
+using SmallVector = boost::container::small_vector;
+#else
+#include
+
+template
+struct TaggedAllocator : std::allocator
+{
+ template
+ TaggedAllocator(Ts&&... ts)
+ : std::allocator(std::forward(ts)...)
+ {}
+};
+
+template
+using SmallVector = std::vector>;
+#endif
+
+#endif