- use_amount_stack template in map.cpp is only used inside the TU
- npc_pickup_from_stack template in npcmove.cpp is only used inside the TU
- silences misc-use-internal-linkage
Update string formatter code in a few ways, taking advantage of C++17:
- Allow string_view as the format string.
- Allow string_view to be a formatted argument (via %s).
- Simplify the metaprogramming using alias templates and variable
templates.
astyle really struggles to style this code reasonably. I had to add
some extra newlines to avoid some situations where astyle got into an
infinite loop of going back and forth between options.
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.
* Omit tests that are failing on Mingw
These string_formatter tests fail on Mingw and it looks like it's simply
a bug in the standard library there. I don't know that we can
reasonably fix them (short of implementing printf ourselves) and they're
showing up in the GitHub UI for every PR, which is potentially confusing
for contributors.
* Remove !mayfail marking on string_formatter test
This should no longer be expected to fail, with the troublesome tests
excised.
* 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++
This is failing on Visual Studio with no sign of a fix coming soon. The
failure isn't super critical, and the code under test is not likely to
change, so marking this test mayfail should be pretty low risk.
The existing string_formatter test has a weird behaviour where a bunch
of unrelated things that were CAPTUREd get printed out when any of the
tests fail. This can be seen in the current Appveyor test failures. I
think this is actually a Catch2 bug, or possibly a limitation of how
Catch2 implements required-throw tests, but I'm too lazy to investigate
that so I'm just working around it.
Basically, the tests that throw an error are not removing their strings
from Catch2's output state, so they are still printed out for later test
failures even though they are unrelated.
Fix by separating out the throw-based tests into a separate test case.
* Disable space check after unicode ellipses
* Fix spacing
* Suppress false positives
* Do not remove spaces before ellipses and colons to suppress false positives
* Fix spacing of raw strings
* Update text style check test
* Enable cata-text-style
* Enable bugprone-use-after-move
Enable this clang-tidy check and deal with associated warnings.
Mostly these were suppressions for things in the tests that are
specifically testing move constructor semantics, but one case was a
genuine latent bug.
* Fix mismatched declaration name
This error seems to have crept into master.
* 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.
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.
That was the only place that actually called it anyway.
Now there is only one function: `raw_string_format` (which is now public in `string_formatter` so the test code can call it).
- Rename `string_format` to `raw_string_format`.
- Removed the overload of `string_format` that takes a `std::string`. The other overload (taking a `const char*`) will be used instead.
Add `string_formatter` class and helper function `string_format` (which takes the place of the previously removed / renamed version).
As the implementation of it is in another header, include the new header "string_formatter.h" where it is used.
Add tests for the new code.