2018-06-24 16:41:58 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-04-09 13:55:34 +02:00
|
|
|
#
|
2023-08-16 19:27:31 +02:00
|
|
|
# Copyright (c) 2018-2020 The Bitcoin Core developers
|
2018-04-09 13:55:34 +02:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#
|
|
|
|
# Check for duplicate includes.
|
2018-06-05 16:24:55 +02:00
|
|
|
# Guard against accidental introduction of new Boost dependencies.
|
2018-06-11 20:17:36 +02:00
|
|
|
# Check includes: Check for duplicate includes. Enforce bracket syntax includes.
|
|
|
|
|
2018-06-18 13:12:07 +02:00
|
|
|
export LC_ALL=C
|
2022-11-15 16:38:57 +01:00
|
|
|
IGNORE_REGEXP="/(dashbls|immer|leveldb|secp256k1|univalue|crc32c)/"
|
2018-04-09 13:55:34 +02:00
|
|
|
|
2019-09-05 02:00:39 +02:00
|
|
|
# cd to root folder of git repo for git ls-files to work properly
|
|
|
|
cd "$(dirname $0)/../.." || exit 1
|
|
|
|
|
2018-04-09 13:55:34 +02:00
|
|
|
filter_suffix() {
|
2018-06-11 20:17:36 +02:00
|
|
|
git ls-files | grep -E "^src/.*\.${1}"'$' | grep -Ev "${IGNORE_REGEXP}"
|
2018-04-09 13:55:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
EXIT_CODE=0
|
2018-06-05 16:24:55 +02:00
|
|
|
|
2018-04-09 13:55:34 +02:00
|
|
|
for HEADER_FILE in $(filter_suffix h); do
|
|
|
|
DUPLICATE_INCLUDES_IN_HEADER_FILE=$(grep -E "^#include " < "${HEADER_FILE}" | sort | uniq -d)
|
|
|
|
if [[ ${DUPLICATE_INCLUDES_IN_HEADER_FILE} != "" ]]; then
|
|
|
|
echo "Duplicate include(s) in ${HEADER_FILE}:"
|
|
|
|
echo "${DUPLICATE_INCLUDES_IN_HEADER_FILE}"
|
|
|
|
echo
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
done
|
2018-06-05 16:24:55 +02:00
|
|
|
|
2018-04-09 13:55:34 +02:00
|
|
|
for CPP_FILE in $(filter_suffix cpp); do
|
|
|
|
DUPLICATE_INCLUDES_IN_CPP_FILE=$(grep -E "^#include " < "${CPP_FILE}" | sort | uniq -d)
|
|
|
|
if [[ ${DUPLICATE_INCLUDES_IN_CPP_FILE} != "" ]]; then
|
|
|
|
echo "Duplicate include(s) in ${CPP_FILE}:"
|
|
|
|
echo "${DUPLICATE_INCLUDES_IN_CPP_FILE}"
|
|
|
|
echo
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
done
|
2018-06-05 16:24:55 +02:00
|
|
|
|
2018-06-06 15:17:52 +02:00
|
|
|
INCLUDED_CPP_FILES=$(git grep -E "^#include [<\"][^>\"]+\.cpp[>\"]" -- "*.cpp" "*.h")
|
|
|
|
if [[ ${INCLUDED_CPP_FILES} != "" ]]; then
|
|
|
|
echo "The following files #include .cpp files:"
|
|
|
|
echo "${INCLUDED_CPP_FILES}"
|
|
|
|
echo
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
|
2018-06-05 16:24:55 +02:00
|
|
|
EXPECTED_BOOST_INCLUDES=(
|
|
|
|
boost/date_time/posix_time/posix_time.hpp
|
|
|
|
boost/filesystem.hpp
|
|
|
|
boost/filesystem/fstream.hpp
|
2020-06-17 07:40:08 +02:00
|
|
|
boost/function.hpp
|
|
|
|
boost/lexical_cast.hpp
|
2018-06-05 16:24:55 +02:00
|
|
|
boost/multi_index/hashed_index.hpp
|
|
|
|
boost/multi_index/ordered_index.hpp
|
|
|
|
boost/multi_index/sequenced_index.hpp
|
|
|
|
boost/multi_index_container.hpp
|
2020-06-17 07:40:08 +02:00
|
|
|
boost/pool/pool_alloc.hpp
|
2020-08-05 13:21:24 +02:00
|
|
|
boost/process.hpp
|
2020-08-28 18:35:11 +02:00
|
|
|
boost/signals2/connection.hpp
|
Merge #19256: gui: change combiner for signals to optional_last_value
f1a0314c537791f202dfb7c1209f0e04ba7988c3 gui: change combiner for signals to optional_last_value (Cory Fields)
Pull request description:
[`optional_last_value`](https://www.boost.org/doc/libs/1_73_0/doc/html/boost/signals2/optional_last_value.html), which does not throw, has replaced `last_value` as
Boosts default combiner. Besides being better supported, it also doesn't
trigger gcc's `-Wmaybe-unitialized` warning, presumably because exceptions no
longer bubble-up out of signals:
```bash
In file included from ui_interface.cpp:9:
/bitcoin/depends/x86_64-pc-linux-gnu/share/../include/boost/signals2/last_value.hpp: In member function 'boost::signals2::detail::signal_impl<R(Args ...), Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>::result_type boost::signals2::detail::signal_impl<R(Args ...), Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>::operator()(Args ...) [with Combiner = boost::signals2::last_value<bool>; Group = int; GroupCompare = std::less<int>; SlotFunction = boost::function<bool(const bilingual_str&, const std::__cxx11::basic_string<char>&, unsigned int)>; ExtendedSlotFunction = boost::function<bool(const boost::signals2::connection&, const bilingual_str&, const std::__cxx11::basic_string<char>&, unsigned int)>; Mutex = boost::signals2::mutex; R = bool; Args = {const bilingual_str&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned int}]':
/bitcoin/depends/x86_64-pc-linux-gnu/share/../include/boost/signals2/last_value.hpp:54:36: warning: '*((void*)& value +1)' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(value) return value.get();
^
/bitcoin/depends/x86_64-pc-linux-gnu/share/../include/boost/signals2/last_value.hpp:43:21: note: '*((void*)& value +1)' was declared here
optional<T> value;
^~~~~
/bitcoin/depends/x86_64-pc-linux-gnu/share/../include/boost/signals2/last_value.hpp: In member function 'boost::signals2::detail::signal_impl<R(Args ...), Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>::result_type boost::signals2::detail::signal_impl<R(Args ...), Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>::operator()(Args ...) [with Combiner = boost::signals2::last_value<bool>; Group = int; GroupCompare = std::less<int>; SlotFunction = boost::function<bool(const bilingual_str&, const std::__cxx11::basic_string<char>&, const std::__cxx11::basic_string<char>&, unsigned int)>; ExtendedSlotFunction = boost::function<bool(const boost::signals2::connection&, const bilingual_str&, const std::__cxx11::basic_string<char>&, const std::__cxx11::basic_string<char>&, unsigned int)>; Mutex = boost::signals2::mutex; R = bool; Args = {const bilingual_str&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned int}]':
/bitcoin/depends/x86_64-pc-linux-gnu/share/../include/boost/signals2/last_value.hpp:54:36: warning: '*((void*)& value +1)' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(value) return value.get();
^
/bitcoin/depends/x86_64-pc-linux-gnu/share/../include/boost/signals2/last_value.hpp:43:21: note: '*((void*)& value +1)' was declared here
optional<T> value;
^~~~~
```
The change in default happened in [Boost 1.39.0](https://www.boost.org/users/history/version_1_39_0.html) (along with the introduction of the Signals2 library.
More information is also available here https://www.boost.org/doc/libs/1_73_0/doc/html/signals2/rationale.html#id-1.3.36.9.4:
> The default combiner for Boost.Signals2 has changed from the last_value combiner used by default in the original Boost.Signals library.
> This is because last_value requires that at least 1 slot be connected to the signal when it is invoked (except for the last_value<void> specialization).
> In a multi-threaded environment where signal invocations and slot connections and disconnections may be happening concurrently, it is difficult to fulfill this requirement. When using optional_last_value, there is no requirement for slots to be connected when a signal is invoked, since in that case the combiner may simply return an empty boost::optional.
ACKs for top commit:
laanwj:
ACK f1a0314c537791f202dfb7c1209f0e04ba7988c3
Tree-SHA512: 3600f85019a3591b141dc9207f8a7e66d16d9996cf97fdf08f5133a212d55c591955ab835ffbdca20b5d62711578bc305d5525c75546fa957f180192e2a80c1e
2020-07-01 16:02:50 +02:00
|
|
|
boost/signals2/optional_last_value.hpp
|
2018-06-05 16:24:55 +02:00
|
|
|
boost/signals2/signal.hpp
|
|
|
|
boost/test/unit_test.hpp
|
|
|
|
)
|
|
|
|
|
2022-11-15 16:38:57 +01:00
|
|
|
for BOOST_INCLUDE in $(git grep '^#include <boost/' -- "*.cpp" "*.h" | grep -vE "src/(immer)/" | cut -f2 -d: | cut -f2 -d'<' | cut -f1 -d'>' | sort -u); do
|
2018-06-05 16:24:55 +02:00
|
|
|
IS_EXPECTED_INCLUDE=0
|
|
|
|
for EXPECTED_BOOST_INCLUDE in "${EXPECTED_BOOST_INCLUDES[@]}"; do
|
|
|
|
if [[ "${BOOST_INCLUDE}" == "${EXPECTED_BOOST_INCLUDE}" ]]; then
|
|
|
|
IS_EXPECTED_INCLUDE=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ ${IS_EXPECTED_INCLUDE} == 0 ]]; then
|
|
|
|
EXIT_CODE=1
|
|
|
|
echo "A new Boost dependency in the form of \"${BOOST_INCLUDE}\" appears to have been introduced:"
|
|
|
|
git grep "${BOOST_INCLUDE}" -- "*.cpp" "*.h"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for EXPECTED_BOOST_INCLUDE in "${EXPECTED_BOOST_INCLUDES[@]}"; do
|
|
|
|
if ! git grep -q "^#include <${EXPECTED_BOOST_INCLUDE}>" -- "*.cpp" "*.h"; then
|
|
|
|
echo "Good job! The Boost dependency \"${EXPECTED_BOOST_INCLUDE}\" is no longer used."
|
|
|
|
echo "Please remove it from EXPECTED_BOOST_INCLUDES in $0"
|
|
|
|
echo "to make sure this dependency is not accidentally reintroduced."
|
|
|
|
echo
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-06-11 20:17:36 +02:00
|
|
|
QUOTE_SYNTAX_INCLUDES=$(git grep '^#include "' -- "*.cpp" "*.h" | grep -Ev "${IGNORE_REGEXP}")
|
|
|
|
if [[ ${QUOTE_SYNTAX_INCLUDES} != "" ]]; then
|
|
|
|
echo "Please use bracket syntax includes (\"#include <foo.h>\") instead of quote syntax includes:"
|
|
|
|
echo "${QUOTE_SYNTAX_INCLUDES}"
|
|
|
|
echo
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
|
2018-04-09 13:55:34 +02:00
|
|
|
exit ${EXIT_CODE}
|