inverted the relationship between expanded macros and tokens
Instead of duplicating the macro references into each token we should just keep references to the tokens in the macros.
Currently just a hack but tests still pass. And this fixes https://trac.cppcheck.net/ticket/11885.
I am pretty sure the hack is all wrong (too warm to think 🫠). But I think the idea is sound 🤞. Definitely needs way more tests first.
These changes are better. They pass all the tests in simplecpp and Cppcheck. They do not fix that upstream issue as it hits something different now.
Before
Benchmark 1: ./simplecpp -q file.c
Time (mean ± σ): 433.6 ms ± 4.2 ms [User: 333.4 ms, System: 99.9 ms]
Range (min … max): 428.3 ms … 439.6 ms 5 runs
After
Benchmark 1: ./simplecpp -q file.c
Time (mean ± σ): 272.8 ms ± 4.8 ms [User: 223.9 ms, System: 48.5 ms]
Range (min … max): 266.9 ms … 278.7 ms 5 runs
Clang 15 3,048,566,387 -> 1,328,447,289
Unfortunately these changes case a big regression to the example in #96.
Before
Benchmark 1: ./simplecpp -q file2.c
Time (mean ± σ): 1.088 s ± 0.033 s [User: 0.784 s, System: 0.304 s]
Range (min … max): 1.061 s … 1.125 s 5 runs
After
Benchmark 1: ./simplecpp -q file2.c
Time (mean ± σ): 4.029 s ± 0.061 s [User: 3.292 s, System: 0.734 s]
Range (min … max): 3.986 s … 4.134 s 5 runs
The clang-tidy false negative which was unearthed by this was reported upstream as https://github.com/llvm/llvm-project/issues/64955.