Skip to content

added clean C/C++ keyword lists and use them in TokenList#3774

Merged
danmar merged 2 commits intocppcheck-opensource:mainfrom
firewave:keywords
Feb 24, 2023
Merged

added clean C/C++ keyword lists and use them in TokenList#3774
danmar merged 2 commits intocppcheck-opensource:mainfrom
firewave:keywords

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

There are various hard-coded lists of these across the code. Some of them are even incomplete, contain non-keywords or attribute keywords to a standard they do not belong to.

This is in preparation so those instances can be incrementally be replaced with these proper global lists.

@firewave firewave marked this pull request as draft January 29, 2022 18:21
@firewave firewave force-pushed the keywords branch 2 times, most recently from 15291c2 to 0fb6792 Compare May 16, 2022 08:36
@firewave
Copy link
Copy Markdown
Collaborator Author

The interface might not be the best. I will try to replace 1 or 2 of the existing usages locally first to see if it actually makes sense.

@firewave
Copy link
Copy Markdown
Collaborator Author

Using the static lists instead of building them on-demand in TokenList should speed up the tests - especially the scanf/printf ones in TestIO.

before:

Benchmark 1: bin/testrunner TestIO
  Time (mean ± σ):      2.771 s ±  0.053 s    [User: 2.556 s, System: 0.194 s]
  Range (min … max):    2.689 s …  2.821 s    5 runs

after:

Benchmark 1: bin/testrunner TestIO
  Time (mean ± σ):      1.967 s ±  0.072 s    [User: 1.806 s, System: 0.161 s]
  Range (min … max):    1.860 s …  2.036 s    5 runs

@firewave firewave marked this pull request as ready for review February 19, 2023 14:04
Comment thread lib/keywords.cpp Outdated
Comment thread lib/keywords.cpp
@danmar danmar merged commit 674231a into cppcheck-opensource:main Feb 24, 2023
@firewave firewave deleted the keywords branch February 24, 2023 20:54
firewave added a commit that referenced this pull request Jan 13, 2024
…ath::isCPP()`, `Path::isC()` and `Path::isHeader()` (#4681)

None of the `Path::is*()` function is working as expected or consistent
(detailed via additional unit tests and deprecation comments).
I tried to fix them but that would have made made cases with headers
quite awkward to implement so I opted to generate a new function. This
also optimized `Path::acceptFile()` a file.

I am not 100% happy with including `settings.h` but I didn't see a place
to move this to. If #3774 gets merged we might be able to move the
`enum` into `keywords.h` (that could also be renamed).

I kept the old function in case somebody else is using these (they are
in the API after all) and will remove them after the next release.
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.

2 participants