Apply some IWYU suggestions

This is not nearly all of them, because IWYU does not support the
way Catch2 manages includes -- it expects that non-system includes
are done using `#include "foo/bar/baz.hpp"`, while Catch2 uses
`<foo/bar/baz.hpp>`. This causes trouble, because IWYU suggests
removing every single internal header, and then adding them again,
but using `""` in the include directive... the resulting suggestions
cannot be used without a lot of manual work, as they are largely
bogus.

For bonus points, IWYU also _loves_ to suggest kinda-random stdlib
headers for `size_t` and similar. Still, the resulting inclusion
graph is somewhat better than it was before.
This commit is contained in:
Martin Hořeňovský 2020-07-29 16:29:41 +02:00
parent 35098a62d8
commit ed0ea30149
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
31 changed files with 35 additions and 45 deletions

View File

@ -11,17 +11,15 @@
#ifndef TWOBLUECUBES_CATCH_DETAIL_ANALYSIS_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_DETAIL_ANALYSIS_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_DETAIL_ANALYSIS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_DETAIL_ANALYSIS_HPP_INCLUDED
#include <catch2/benchmark/catch_clock.hpp>
#include <catch2/benchmark/catch_estimate.hpp> #include <catch2/benchmark/catch_estimate.hpp>
#include <catch2/benchmark/catch_outlier_classification.hpp> #include <catch2/benchmark/catch_outlier_classification.hpp>
#include <algorithm> #include <algorithm>
#include <functional>
#include <vector> #include <vector>
#include <numeric> #include <numeric>
#include <tuple>
#include <cmath> #include <cmath>
#include <utility> #include <utility>
#include <cstddef>
namespace Catch { namespace Catch {
namespace Benchmark { namespace Benchmark {
@ -64,7 +62,8 @@ namespace Catch {
template <typename Estimator, typename Iterator> template <typename Estimator, typename Iterator>
sample jackknife(Estimator&& estimator, Iterator first, Iterator last) { sample jackknife(Estimator&& estimator, Iterator first, Iterator last) {
auto n = last - first; auto n = last - first;
auto second = std::next(first); auto second = first;
++second;
sample results; sample results;
results.reserve(n); results.reserve(n);

View File

@ -11,6 +11,8 @@
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/internal/catch_test_spec_parser.hpp> #include <catch2/internal/catch_test_spec_parser.hpp>
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
namespace Catch { namespace Catch {

View File

@ -18,14 +18,11 @@
#include <catch2/internal/catch_random_number_generator.hpp> #include <catch2/internal/catch_random_number_generator.hpp>
#include <catch2/internal/catch_startup_exception_registry.hpp> #include <catch2/internal/catch_startup_exception_registry.hpp>
#include <catch2/internal/catch_text.hpp> #include <catch2/internal/catch_text.hpp>
#include <catch2/internal/catch_stream.hpp>
#include <catch2/internal/catch_windows_h_proxy.hpp> #include <catch2/internal/catch_windows_h_proxy.hpp>
#include <catch2/reporters/catch_reporter_listening.hpp> #include <catch2/reporters/catch_reporter_listening.hpp>
#include <cstdlib>
#include <iomanip> #include <iomanip>
#include <set> #include <set>
#include <iterator>
namespace Catch { namespace Catch {

View File

@ -10,7 +10,6 @@
#include <catch2/internal/catch_commandline.hpp> #include <catch2/internal/catch_commandline.hpp>
#include <catch2/catch_config.hpp> #include <catch2/catch_config.hpp>
#include <catch2/internal/catch_text.hpp>
#include <catch2/internal/catch_unique_ptr.hpp> #include <catch2/internal/catch_unique_ptr.hpp>
namespace Catch { namespace Catch {

View File

@ -12,10 +12,9 @@
#include <catch2/interfaces/catch_interfaces_testcase.hpp> #include <catch2/interfaces/catch_interfaces_testcase.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <cassert>
#include <cctype> #include <cctype>
#include <exception>
#include <algorithm> #include <algorithm>
#include <sstream>
namespace Catch { namespace Catch {

View File

@ -7,7 +7,6 @@
#include <catch2/catch_test_spec.hpp> #include <catch2/catch_test_spec.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <algorithm> #include <algorithm>

View File

@ -7,8 +7,6 @@
*/ */
#include <catch2/internal/catch_assertion_handler.hpp> #include <catch2/internal/catch_assertion_handler.hpp>
#include <catch2/catch_assertion_result.hpp>
#include <catch2/interfaces/catch_interfaces_runner.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp> #include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/internal/catch_context.hpp> #include <catch2/internal/catch_context.hpp>
#include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_enforce.hpp>

View File

@ -9,6 +9,9 @@
#ifndef TWOBLUECUBES_CATCH_CLARA_H_INCLUDED #ifndef TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED #define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
// For CATCH_CONFIG_CONSOLE_WIDTH. We should refactor this out somewhere else.
#include <catch2/catch_config.hpp>
// Use Catch's value for console width (store Clara's off to the side, if present) // Use Catch's value for console width (store Clara's off to the side, if present)
#ifdef CLARA_CONFIG_CONSOLE_WIDTH #ifdef CLARA_CONFIG_CONSOLE_WIDTH
#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH #define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH

View File

@ -8,11 +8,12 @@
#include <catch2/internal/catch_commandline.hpp> #include <catch2/internal/catch_commandline.hpp>
#include <catch2/catch_config.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp> #include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/interfaces/catch_interfaces_reporter.hpp> #include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <algorithm>
#include <fstream> #include <fstream>
#include <ctime> #include <ctime>

View File

@ -8,11 +8,12 @@
#ifndef TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED #define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
#include <catch2/catch_config.hpp>
#include <catch2/internal/catch_clara.hpp> #include <catch2/internal/catch_clara.hpp>
namespace Catch { namespace Catch {
struct ConfigData;
clara::Parser makeCommandLineParser( ConfigData& config ); clara::Parser makeCommandLineParser( ConfigData& config );
} // end namespace Catch } // end namespace Catch

View File

@ -7,8 +7,6 @@
*/ */
#include <catch2/internal/catch_common.hpp> #include <catch2/internal/catch_common.hpp>
#include <catch2/internal/catch_context.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <cstring> #include <cstring>
#include <ostream> #include <ostream>

View File

@ -20,8 +20,6 @@
#endif #endif
#include <iosfwd> #include <iosfwd>
#include <string>
#include <cstdint>
// We need a dummy global operator<< so we can bring it into Catch namespace later // We need a dummy global operator<< so we can bring it into Catch namespace later
struct Catch_global_namespace_dummy {}; struct Catch_global_namespace_dummy {};

View File

@ -23,7 +23,7 @@
#include <catch2/internal/catch_debugger.hpp> #include <catch2/internal/catch_debugger.hpp>
#include <catch2/internal/catch_windows_h_proxy.hpp> #include <catch2/internal/catch_windows_h_proxy.hpp>
#include <sstream> #include <ostream>
namespace Catch { namespace Catch {
namespace { namespace {

View File

@ -13,7 +13,6 @@ namespace Catch {
struct IResultCapture; struct IResultCapture;
struct IRunner; struct IRunner;
struct IConfig; struct IConfig;
struct IMutableContext;
struct IContext struct IContext
{ {

View File

@ -9,7 +9,6 @@
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/internal/catch_stream.hpp> #include <catch2/internal/catch_stream.hpp>
#include <map>
#include <cassert> #include <cassert>
namespace Catch { namespace Catch {

View File

@ -10,6 +10,7 @@
#include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp> #include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
#include <catch2/internal/catch_unique_ptr.hpp> #include <catch2/internal/catch_unique_ptr.hpp>
#include <catch2/internal/catch_stringref.hpp>
#include <vector> #include <vector>

View File

@ -13,18 +13,12 @@
#include <catch2/interfaces/catch_interfaces_testcase.hpp> #include <catch2/interfaces/catch_interfaces_testcase.hpp>
#include <catch2/internal/catch_context.hpp> #include <catch2/internal/catch_context.hpp>
#include <catch2/catch_config.hpp>
#include <catch2/internal/catch_stream.hpp> #include <catch2/internal/catch_stream.hpp>
#include <catch2/internal/catch_console_colour.hpp>
#include <catch2/internal/catch_test_spec_parser.hpp> #include <catch2/internal/catch_test_spec_parser.hpp>
#include <catch2/catch_tostring.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <limits>
#include <algorithm>
#include <set>
namespace Catch { namespace Catch {
namespace { namespace {

View File

@ -8,7 +8,6 @@
#ifndef TWOBLUECUBES_CATCH_LIST_H_INCLUDED #ifndef TWOBLUECUBES_CATCH_LIST_H_INCLUDED
#define TWOBLUECUBES_CATCH_LIST_H_INCLUDED #define TWOBLUECUBES_CATCH_LIST_H_INCLUDED
#include <catch2/catch_config.hpp>
#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_stringref.hpp>
#include <set> #include <set>
@ -18,6 +17,8 @@
namespace Catch { namespace Catch {
struct IStreamingReporter; struct IStreamingReporter;
class Config;
struct ReporterDescription { struct ReporterDescription {
std::string name, description; std::string name, description;

View File

@ -1,4 +1,5 @@
#include <catch2/interfaces/catch_interfaces_generatortracker.hpp> #include <catch2/interfaces/catch_interfaces_generatortracker.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/internal/catch_run_context.hpp> #include <catch2/internal/catch_run_context.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp> #include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_context.hpp> #include <catch2/internal/catch_context.hpp>
@ -8,6 +9,7 @@
#include <catch2/internal/catch_stream.hpp> #include <catch2/internal/catch_stream.hpp>
#include <catch2/catch_timer.hpp> #include <catch2/catch_timer.hpp>
#include <catch2/internal/catch_output_redirect.hpp> #include <catch2/internal/catch_output_redirect.hpp>
#include <catch2/internal/catch_assertion_handler.hpp>
#include <cassert> #include <cassert>
#include <algorithm> #include <algorithm>

View File

@ -10,14 +10,13 @@
#include <catch2/interfaces/catch_interfaces_runner.hpp> #include <catch2/interfaces/catch_interfaces_runner.hpp>
#include <catch2/interfaces/catch_interfaces_reporter.hpp> #include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <catch2/catch_config.hpp>
#include <catch2/internal/catch_test_registry.hpp> #include <catch2/internal/catch_test_registry.hpp>
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <catch2/internal/catch_test_macro_impl.hpp>
#include <catch2/catch_message.hpp> #include <catch2/catch_message.hpp>
#include <catch2/catch_totals.hpp> #include <catch2/catch_totals.hpp>
#include <catch2/internal/catch_test_case_tracker.hpp> #include <catch2/internal/catch_test_case_tracker.hpp>
#include <catch2/internal/catch_assertion_handler.hpp> #include <catch2/catch_assertion_info.hpp>
#include <catch2/catch_assertion_result.hpp>
#include <string> #include <string>
@ -25,6 +24,7 @@ namespace Catch {
struct IMutableContext; struct IMutableContext;
struct IGeneratorTracker; struct IGeneratorTracker;
struct IConfig;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@ -12,8 +12,6 @@
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp> #include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <sstream>
namespace Catch { namespace Catch {
TagAliasRegistry::~TagAliasRegistry() {} TagAliasRegistry::~TagAliasRegistry() {}

View File

@ -12,6 +12,7 @@
#include <catch2/catch_tag_alias.hpp> #include <catch2/catch_tag_alias.hpp>
#include <map> #include <map>
#include <string>
namespace Catch { namespace Catch {

View File

@ -17,9 +17,7 @@
#include <catch2/catch_test_spec.hpp> #include <catch2/catch_test_spec.hpp>
#include <algorithm> #include <algorithm>
#include <iterator> #include <set>
#include <random>
#include <sstream>
namespace Catch { namespace Catch {

View File

@ -12,8 +12,6 @@
#include <catch2/interfaces/catch_interfaces_config.hpp> #include <catch2/interfaces/catch_interfaces_config.hpp>
#include <vector> #include <vector>
#include <set>
#include <algorithm>
namespace Catch { namespace Catch {

View File

@ -13,7 +13,6 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <memory> #include <memory>
#include <sstream>
#if defined(__clang__) #if defined(__clang__)
# pragma clang diagnostic push # pragma clang diagnostic push

View File

@ -8,6 +8,7 @@
#include <catch2/internal/catch_test_spec_parser.hpp> #include <catch2/internal/catch_test_spec_parser.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
namespace Catch { namespace Catch {

View File

@ -14,10 +14,14 @@
#endif #endif
#include <catch2/catch_test_spec.hpp> #include <catch2/catch_test_spec.hpp>
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
#include <vector>
#include <string>
namespace Catch { namespace Catch {
struct ITagAliasRegistry;
class TestSpecParser { class TestSpecParser {
enum Mode{ None, Name, QuotedName, Tag, EscapedName }; enum Mode{ None, Name, QuotedName, Tag, EscapedName };
Mode m_mode = None; Mode m_mode = None;

View File

@ -17,7 +17,6 @@
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <sstream> #include <sstream>
#include <type_traits>
#include <iomanip> #include <iomanip>
#include <limits> #include <limits>

View File

@ -10,7 +10,6 @@
#include <array> #include <array>
#include <algorithm> #include <algorithm>
#include <memory>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>

View File

@ -7,6 +7,7 @@
*/ */
#include <catch2/reporters/catch_reporter_listening.hpp> #include <catch2/reporters/catch_reporter_listening.hpp>
#include <cassert> #include <cassert>
namespace Catch { namespace Catch {

View File

@ -10,6 +10,8 @@
#include <catch2/internal/catch_text.hpp> #include <catch2/internal/catch_text.hpp>
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <cassert>
namespace Catch { namespace Catch {
namespace { namespace {