- Clean up `check_sexp_syntax` to use `eval_ship` (and incidentally `eval_wing` and `eval_prop`) rather than the old lookups.
- Disable SEXP node caching while FRED is running. Also use smart pointers and fix a cache memory leak.
* avoid undefined behavior from UNREACHABLE on reachable code paths
UNREACHABLE expands to __assume(false) / __builtin_unreachable() in
release builds, which is undefined behavior if the code is ever actually
reached. Many UNREACHABLE sites only guard against unexpected-but-
possible runtime states (values from tables, mission/save files, network
packets, scripting, or user input), so reaching them should degrade
gracefully rather than invoke UB.
Replace UNREACHABLE with Assertion(false, ...) at all such sites. It
still pops an error in debug builds, but in release it is a harmless
no-op that simply falls through to the following code. Sites that are
genuinely unreachable by local invariants (e.g. a switch over a bounded
random number) are left as UNREACHABLE.
A few converted sites had no safe fall-through -- an uninitialized read,
null dereference, or null call would have followed -- so they also get a
minimal recovery: initialize the value, guard the dereference, return
early, or skip the offending item.
Where the converted site was a simple guard of the form
if (x) { Assertion(false, ...); return; }
hoist the check onto the invariant instead:
Assertion(!x, ...);
if (x) { return; }
This states the expectation directly and shows the offending value in
the debug popup, while keeping the same graceful runtime degradation.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* addendum
After consultation with Lafiel, use UNREACHABLE in situations that are effectively impossible even if not provably impossible. UNREACHABLE = "this shouldn't ever happen"; Assertion = "if this ever happens, it's a coding error". Also fix a few other sites and change a couple to Warnings.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Add `UINT64_T_ARG` and `INT64_T_ARG` macros for printf arguments, similar to `SIZE_T_ARG` and `PTRDIFF_T_ARG`.
In the process, fix some issues with the toolchain: in certain CI runs the toolchain headers were being #included multiple times, and certain CI runs produced collisions between clang definitions and gcc definitions. Resolve these issues with `#pragma once` and preprocessor guards in the event of both gcc and clang being active.
Also remove toolchain.h from sexp_container.cpp since it is already #included via pstypes.h.
* add node subtype for container names
* clean up and port changes to qtFRED
* fix parsing when container is the last argument
* fix serializing container name nodes
* fix parsing again
* disallow spaces in container names
* check for spaces and & chars while parsing container names
* early WIP for trying to get list containers of strings working as argument options
* indicate which SEXPs will be supported for now
* clean up
* add FRED/qtFRED support
* remove [in]validate-argument from supported SEXPs
* support map containers with string keys
* update FRED and qtFRED
* clean up
* update FRED help text
* revert some unneeded changes
* fix style
* remove added assertion
* backport useful changes from PR #4263 and then some
* clean up backport
* move condition_node evaluation outside of argument loop
* fix does_blank_of_op_support_container_args()
* fix assertion
* add OPF_DATA_OR_STR_CONTAINER and use restore old behavior of OPF_ANYTHING
* revert some unnecessary changes
* fix CI
* detect attempts to modify container while it is being used as special argument (WIP)
* evaluate conditional for each loop
* update placeholder text for new SEXP arg type
* finish/clean up