-
Notifications
You must be signed in to change notification settings - Fork 68
Improve identification of reuse of reserved names #951
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
Draft
lcartey
wants to merge
34
commits into
main
Choose a base branch
from
lcartey/standard-library-naming
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
This commit adds a module for representing names from the C/C++ standard libraries. It uses models-as-data to represent the names, and provides modules for accessing names in C99, C11 and C++14.
This adds a python script for taking Appendix B of the C Standard Library and converting it to the StandardLibrayNames models-as-data format.
This repurposes the existing module generator to instead generate a mad file for the C++ standard library. It makes the following changes: * Omits names outside the `std` namespace (as they cannot be distinguished from system headers). * Removes the macro query, and adds member variable and type models instead. * Move to a new generator directory. * Update the script to generate a mad file instead of a .qll file.
Ensure models-as-data are output to the correct location.
Exclude more internal and non `std` models.
The library generator did not correctly parse function prototypes with pointer return types. These are now appropriately parsed.
Appendix B of the spec doesn't include the member variables, but there's only a few of them so we specify by hand.
* Update message * Require appropriate include in the non-external linkage case. * Add extra tests
Library macros are not under user control
Remove unnecessary filter on start locations.
Exclude NDEBUG which is not actually defined by any header, and update the generated files (include the outdated C99 file).
MISRA has slightly different rules to CERT, so unshare the rule.
Determine more accurately which header a declaration belongs to: * Identify "closest" imported header * Use manual mapping to disambiguate
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.
Description
This pull request improves the identification of reserved names across the supported languages. I originally worked on this last year, and putting this up now as a draft PR for visibility. The main contributions are:
.qll
file. This has been adapted to produce data extension files instead. It uses a "real" codebase to identify which APIs are availablestd
. These are now filtered out.ReservedName.qll
has been created which implements reserved name detection/reuse for C, based on the C Standard and the MISRA specific rules. This is adopted by MISRA Rules 21.1 and 21.2, AUTOSAR A17-0-1 and CERT C DCL37-C.ReservedName.qll
is extended to support C++ reserved name detection. This has not yet been adopted by the various C++ reserved name queries - I recall that it was challenging to determine how to handle many of the edge cases due to a lack of clarity in both the language standard and the various Coding Standards.Existing Issue references:
DCL51-CPP
: Only reserve function names when used within the global namespace #148Change request type
.ql
,.qll
,.qls
or unit tests)Rules with added or modified queries
RULE-21-1
RULE-21-2
A17-0-1
DCL37-C
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.