Title: Add `Template` query library by jeongsoolee09 · Pull Request #932 · github/codeql-coding-standards · GitHub
Open Graph Title: Add `Template` query library by jeongsoolee09 · Pull Request #932 · github/codeql-coding-standards
X Title: Add `Template` query library by jeongsoolee09 · Pull Request #932 · github/codeql-coding-standards
Description: Description
Add a query library titled Template that provides definitions to help reason about templates and human-friendly alert locations.
What is this?
This library started its life as part of a new version of query for M-0-12 in MISRA C++. The rule was mistaken as pertaining to template usages, and thus the types here was conceived of and utilized to report usages that were thought of violating the rule. Although the definitions were pulled off the final version of the query, these are expected to be of some use in providing sensible alert locations when the pattern a query aims to find involves templates.
What does it provide?
Templates, when instantiated, become generated code that is only visible after they are processed. This makes tricky when the way the template is instantiated in a particular case has to be reported, and doubly so when there are some other uses of the same template that don't violate the rule. A quick and dirty way is to alert on a location in the uninstantiated template definition, but in practice this makes it tricky to trace back to the client code that instantiates the template in a way that violates the rule. To circumvent this issue, this library provides TemplateInstantiation.getAUse/0 that finds occurrences of a template call in the client code. TemplateInstantiation is a composition of three cases, class templates, function templates, and variable templates. Therefore, it is natural to explain per case the location this predicate gets us for given template instantiation.
Class templates
Let's assume we're expanding M-0-12, which dictates that explicitly signed or unsigned chars should only be assigned numeric values, to catch template instantiations. We may decide to consider cases like below as below as violating the rule:
template
Open Graph Description: Description Add a query library titled Template that provides definitions to help reason about templates and human-friendly alert locations. What is this? This library started its life as part of a...
X Description: Description Add a query library titled Template that provides definitions to help reason about templates and human-friendly alert locations. What is this? This library started its life as part of a...
Opengraph URL: https://github.com/github/codeql-coding-standards/pull/932
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8c207f52-0249-26b2-863e-78d948e9d1ee |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 96D4:3E9E49:45BC:53B7:6964E653 |
| html-safe-nonce | 5841d9097c074d10e3a8a351ee163f47fc0228a1e7878061266468fa46249ddb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkQ0OjNFOUU0OTo0NUJDOjUzQjc6Njk2NEU2NTMiLCJ2aXNpdG9yX2lkIjoiMjg3NzY4NjU3ODk1Mjg1NzE3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8361696b98c15a9267df2fb233c6d3f25188eb454feddd63d67f3c7569faf5ce |
| hovercard-subject-tag | pull_request:2668790407 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/github/codeql-coding-standards/pull/932/files |
| twitter:image | https://avatars.githubusercontent.com/u/46663033?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/46663033?s=400&v=4 |
| og:image:alt | Description Add a query library titled Template that provides definitions to help reason about templates and human-friendly alert locations. What is this? This library started its life as part of a... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3c30097417ecb9dfdab6b2e8bc7dc38d73e183d6ad48f94cb69e4a5daa2dbb87 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/github/codeql-coding-standards git https://github.com/github/codeql-coding-standards.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 513154248 |
| octolytics-dimension-repository_nwo | github/codeql-coding-standards |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 513154248 |
| octolytics-dimension-repository_network_root_nwo | github/codeql-coding-standards |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 69fc54a84c74307369dba42af5401200531d116e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width