Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inverted the relationship between expanded macros and tokens #305

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

firewave
Copy link
Collaborator

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

@firewave
Copy link
Collaborator Author

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

@firewave
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

The clang-tidy false negative which was unearthed by this was reported upstream as llvm/llvm-project#64955.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant