- Notifications
You must be signed in to change notification settings - Fork70
Implement naming package, new IdentifierIntroduction.qll, unicode funcs.#950
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
MichaelRFairhurst wants to merge3 commits intomainChoose a base branch frommichaelrfairhurst/implement-naming-package
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.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletionschange_notes/2025-08-22-function-like-macro-param-name-bug-fixes.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - "Function-like macros" | ||
| - The parameter list of variadic macros previously included the ellipsis in name of the final parameter, potentially leading to incorrect analysis. This has been corrected. | ||
| - The parameter list of function-like macros with no parameters (i.e. `MACRO()`) was interpreted in a shared library as having a single parameter with an empty name. This does not seem to have had an impact on any existing queries, but has been fixed to correctly show no parameters. |
446 changes: 446 additions & 0 deletionscpp/common/src/codingstandards/cpp/Identifiers.qll
Large diffs are not rendered by default.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
11 changes: 9 additions & 2 deletionscpp/common/src/codingstandards/cpp/Macro.qll
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
65 changes: 65 additions & 0 deletionscpp/common/src/codingstandards/cpp/Unicode.qll
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import codeql.util.Numbers | ||
| /** | ||
| * Provides properties of a Unicode code point, where the property is of 'enumeration', 'catalog', | ||
| * or 'string-valued' type, however, the only supported property is `NFC_QC`. | ||
| * | ||
| * For example, `Block` is an enumeration property, `Line_Break` is a catalog property, and | ||
| * `Uppercase_Mapping` is a string-valued property. | ||
| * | ||
| * For boolean properties, see `unicodeHasBooleanProperty`, and for numeric properties, see | ||
| * `unicodeHasNumericProperty`. | ||
| */ | ||
| extensible predicate unicodeHasProperty(int codePoint, string propertyName, string propertyValue); | ||
| /** | ||
| * Holds when the Unicode code point's boolean property of the given name is true. | ||
| * | ||
| * For example, `Alphabetic` is a boolean property that can be true or false for a code point. | ||
| * | ||
| * For other types of properties, see `unicodeHasProperty`. | ||
| */ | ||
| extensible predicate unicodeHasBooleanProperty(int codePoint, string propertyName); | ||
| bindingset[input] | ||
| int unescapedCodePointAt(string input, int index) { | ||
| exists(string match | | ||
| match = input.regexpFind("(\\\\u[0-9a-fA-F]{4}|.)", index, _) and | ||
| if match.matches("\\u%") | ||
| then result = parseHexInt(match.substring(2, match.length())) | ||
| else result = match.codePointAt(0) | ||
| ) | ||
| } | ||
| bindingset[input] | ||
| string unescapeUnicode(string input) { | ||
| result = | ||
| concat(int code, int idx | | ||
| code = unescapedCodePointAt(input, idx) | ||
| | | ||
| code.toUnicode() order by idx | ||
| ) | ||
| } | ||
| bindingset[id] | ||
| predicate nonUax44IdentifierCodepoint(string id, int index) { | ||
| exists(int codePoint | | ||
| codePoint = id.codePointAt(index) and | ||
| ( | ||
| not unicodeHasBooleanProperty(codePoint, "XID_Start") and | ||
| not unicodeHasBooleanProperty(codePoint, "XID_Continue") | ||
| or | ||
| index = 0 and | ||
| not unicodeHasBooleanProperty(codePoint, "XID_Start") | ||
| ) | ||
| ) | ||
| } | ||
| bindingset[id] | ||
| predicate nonNfcNormalizedCodepoint(string id, int index, string noOrMaybe) { | ||
| exists(int codePoint | | ||
| codePoint = id.codePointAt(index) and | ||
| unicodeHasProperty(codePoint, "NFC_QC", noOrMaybe) and | ||
| noOrMaybe = ["N", "M"] | ||
| ) | ||
| } |
26 changes: 26 additions & 0 deletionscpp/common/src/codingstandards/cpp/exclusions/cpp/Naming2.qll
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ | ||
| import cpp | ||
| import RuleMetadata | ||
| import codingstandards.cpp.exclusions.RuleMetadata | ||
| newtype Naming2Query = TPoorlyFormedIdentifierQuery() | ||
| predicate isNaming2QueryMetadata(Query query, string queryId, string ruleId, string category) { | ||
| query = | ||
| // `Query` instance for the `poorlyFormedIdentifier` query | ||
| Naming2Package::poorlyFormedIdentifierQuery() and | ||
| queryId = | ||
| // `@id` for the `poorlyFormedIdentifier` query | ||
| "cpp/misra/poorly-formed-identifier" and | ||
| ruleId = "RULE-5-10-1" and | ||
| category = "required" | ||
| } | ||
| module Naming2Package { | ||
| Query poorlyFormedIdentifierQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `poorlyFormedIdentifier` query | ||
| TQueryCPP(TNaming2PackageQuery(TPoorlyFormedIdentifierQuery())) | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletionscpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll
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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.