simplecpp icon indicating copy to clipboard operation
simplecpp copied to clipboard

inverted the relationship between expanded macros and tokens

Open firewave opened this issue 2 years ago • 5 comments

Instead of duplicating the macro references into each token we should just keep references to the tokens in the macros.

firewave avatar Aug 21 '23 13:08 firewave

Currently just a hack but tests still pass. And this fixes https://trac.cppcheck.net/ticket/11885.

firewave avatar Aug 21 '23 13:08 firewave

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.

firewave avatar Aug 21 '23 16:08 firewave

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

firewave avatar Aug 24 '23 09:08 firewave

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

firewave avatar Aug 24 '23 10:08 firewave

The clang-tidy false negative which was unearthed by this was reported upstream as https://github.com/llvm/llvm-project/issues/64955.

firewave avatar Aug 24 '23 16:08 firewave