-
Notifications
You must be signed in to change notification settings - Fork 73
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1c44315
2adeaba
5a07066
752056e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| 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); | ||
|
Comment on lines
+3
to
+13
|
||
|
|
||
| /** | ||
| * 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"] | ||
| ) | ||
| } | ||
| 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())) | ||
| } | ||
| } |