21 Commits

Author SHA1 Message Date
John Bytheway 0a1191638e Remove redundant parentheses
Apply the new check to remove lots of redundant parentheses throughout
the codebase.
2021-11-07 12:57:53 -05:00
John Bytheway ebd549b300 Fix StringMaker ODR violations in tests
Catch2 provides a customization point for converting our types to
strings by specializing the StringMaker template.

We have some specializations in stringmaker.h, but this feature was only
working intermittently.  I finally figured out that was due to an ODR
violation.  The test files that didn't include stringmaker.h were
compiling a different specialization than the ones that did.

Re-jig the test includes so that any file including catch.hpp also
includes stringmaker.h, thereby ensuring that the custom
specializations are used everywhere and there is no ODR violation.

I achieved this by adding a new cata_catch.h header and making all
existing headers include catch.hpp via the new header.
2021-07-03 07:42:06 -07:00
Binrui Dong 9fdb7ef59c Run IWYU
* Change _ctype.h and __locale to cctype and clocale

* Change _wctype.h to cwctype in game.cpp

* Change __functional_base to functional

* Remove libcxx internal headers

* Remove UNIX system headers

* Fix clang-tidy error with -nostdinc++
2021-02-06 00:18:41 -05:00
John Bytheway bf910e50e3 Declare lots of things static
Use the new clang-tidy check to convert a bunch of declarations to
static.

In a few cases, there were 'secret' dependencies being exposed without
headers.  Convert those to work via headers instead.
2020-09-05 23:13:04 -04:00
Kevin Granade c5ccf0c2c7 IWYU for tests (#42806) 2020-08-09 09:46:57 +03:00
Kevin Granade 6d1841ac67 Precompiled Catch2 header (#42453)
* Hoist catch.hpp include to the top of files

* Precompile the catch header in tests
2020-07-29 01:28:26 +03:00
John Bytheway 72571e5b37 More preparatory changes for IWYU. (#39214)
* Define mappings for std::hash

IWYU was including system_error for std::has.  Give it some more
reasonable alternatives in the mapping file.

* More IWYU doc updates

Add the --reorder flag to the example, and mention issue related to
clang-tidy disliking some of its changes.

* Work around IWYU failing

IWYU didn't realise that we were constructing a point here, so it
removed the #include "point.h"; make it more explicit to avoid that
issue.

* Use consistent include style in clang-tidy plugin

The plugin code was mostly using ""-style includes, but IWYU was adding
<>-style includes.  I prefer the latter anyway for external project
includes, so convert them.  That way, IWYU's additions are more
consistent.

Thanks to Qrox for suggesting this in review.
2020-04-04 00:39:59 +03:00
Qrox 94a6d89619 Fix clang-tidy warnings 2019-11-04 21:02:55 +08:00
John Bytheway 4321c025d2 IWYU 20190629 (#31990)
* Add IWYU pragma: keep

* Run IWYU and astyle

* Run IWYU a second time

* Prevent #include <cxxabi.h>

Unclear why IWYU thinks this is needed.  It isn't, and it causes
problems on Visual Studio.
2019-07-01 12:25:53 +03:00
John Bytheway eeb25e8b10 Separate point, tripoint into new point.h
It never made sense that point and tripoint were in enums.h.  Give them
their own header.
2019-06-27 08:30:58 +01:00
John Bytheway 7fb60a561b Remove legacy hash code
This was only present in the tests, contained undefined behaviour, and
was obsolete.
2019-05-22 22:47:01 +01:00
John Bytheway 81309f459a NOLINT undefined shifts in legacy hash code 2019-05-22 22:47:01 +01:00
John Bytheway f3049e5eea Fix missing declarations (#30739)
* Fix missing declarations
Mark functions with no prior declarations as static, and remove the
unused ones.
* Move debug_is_safe_string definition
Put it inside !WIN32 since it's only used there.
2019-05-22 11:00:54 -07:00
John Bytheway e3e7700aef Apply IWYU changes
This is a run of IWYU followed by astyle.
2019-04-22 11:42:51 +01:00
John Bytheway 467926fd85 Guard RELEASE-only header
The <chrono> header here is used only in RELEASE mode, so IWYU run with
debug mode options will want to delete it.  Guard the #include behind
RELEASE as well so that it isn't removed.
2019-01-22 20:19:08 +00:00
ZhilkinSerg c0bce91fa1 Used const where appropriate 2019-01-06 23:00:08 +03:00
John Bytheway b0576393e3 Sort headers according to IWYU conventions
A first step towards IWYU support.  Doing the sorting first because it
makes reviewing any additions or removals of headers much simpler.

The IWYU order is:
- Associated headers
- Misc system headers
- C++ STL headers
- Other project headers

The biggest change is moving system headers before project headers (they
are usually afterwards in Cata at the moment.

The associated header for a cpp file is the header file which declares
the functions defined in that cpp file.  Normally that's the one which
shares the same name (up to extension), and if so IWYU figures it out
automatically.

However, in this project there are many corner cases, so we need to use
IWYU pragma: associated to tell it which header (or, in some cases,
which headers) is the associated header.  We are unusual in having
multiple associated headers for some files, which might lead to
discovering some interesting IWYU bugs later, but in theory it is
supported.
2019-01-05 14:03:31 +00:00
John Bytheway cf75da5f8f Disable hash runtime tests on non-RELEASE builds
These tests take ~20 seconds on a Linux debug build, and serve little
purpose, because these functions are not optimised for debug build
performance.
2018-12-06 21:36:30 +00:00
John Bytheway 1058669ac0 Smaller hash_distribution test on _GLIBCXX_DEBUG
The debug containers make this test much slower.  Scale it down by a
factor of 100 in that case (now ~0.7 seconds, rather than ~50 seconds).
2018-12-06 21:36:22 +00:00
Kevin Granade 7b23ba48fa Replace unordered_set with vector and set operations
At the end of the day this should be more efficient due to memory locality, even though there is an additional O(nlogn + n) processing step at the end of the test.
Increased range of test to 300x300(x21) to take advantage of the increased speed.
2018-11-25 00:40:08 +00:00
Kevin Granade b4e1b9b852 Add some basic health checks for point and tripoint hash distribution. 2018-11-20 04:23:35 +00:00