feat: clang-query based concept usage checker#568
Open
WhyPenguins wants to merge 2 commits intodoubtfire-lms:10.0.xfrom
Open
feat: clang-query based concept usage checker#568WhyPenguins wants to merge 2 commits intodoubtfire-lms:10.0.xfrom
WhyPenguins wants to merge 2 commits intodoubtfire-lms:10.0.xfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note - this PR isn't necessarily intended to be merged directly :) I'm unfamiliar with this project, and simply tried to guess at the relevant locations for these scripts. They will probably need to be relocated. They are also not in the language of the project - since they are relatively standalone I hope this is alright :)
Description
This PR adds a script
check_concept_usage.pythat usesclang-queryto check if a C++ file matches any rules from a named rule set. It can be called as follows:and it will output a list of one-line descriptions for each rule that was matched.
If it fails to run to completion, it will output errors on stderr, and leave stdout empty.
The rules are defined in
rules.json- here's an example of the layout:Each rule set is named (e.g "chapter_04_control_flow"), and contains a list of rules. Each rule contain a list of queries to try for that rule, and an ID and description/message that can be output when that rule is matched. Each rule set can also include the rules from another rule set.
Type of change
How Has This Been Tested?
A test script has been included (
concept_usage_test.py) that tests a set of representative (but shortened/slightly mangled) pieces of code from the Field Guide. It checks that they pass under the rule sets that are from their own chapter or later, and fail with rule sets from earlier chapters. It also checks the specificids of the rule matches to ensure they are matching correctly.That's not to say this is exhaustive - I found a bunch of edge cases while putting the tests together, so it is possible there are more 😅
Checklist: