-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into michaelrfairhurst/implement-banned2-rule-pac…
…kage-rule-21-24
- Loading branch information
Showing
52 changed files
with
414 additions
and
187 deletions.
There are no files selected for viewing
This file contains 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 file was deleted.
Oops, something went wrong.
This file contains 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 file contains 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 file contains 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 file contains 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 file contains 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 file contains 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 file contains 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 file contains 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 file contains 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 file contains 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 file contains 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 file contains 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
33 changes: 33 additions & 0 deletions
33
c/misra/src/rules/RULE-17-12/FunctionAddressesShouldAddressOperator.ql
This file contains 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,33 @@ | ||
/** | ||
* @id c/misra/function-addresses-should-address-operator | ||
* @name RULE-17-12: A function identifier should only be called with a parenthesized parameter list or used with a & | ||
* @description A function identifier should only be called with a parenthesized parameter list or | ||
* used with a & (address-of). | ||
* @kind problem | ||
* @precision very-high | ||
* @problem.severity error | ||
* @tags external/misra/id/rule-17-12 | ||
* readability | ||
* external/misra/c/2012/amendment3 | ||
* external/misra/obligation/advisory | ||
*/ | ||
|
||
import cpp | ||
import codingstandards.c.misra | ||
|
||
predicate isImplicitlyAddressed(FunctionAccess access) { | ||
not access.getParent() instanceof AddressOfExpr and | ||
// Note: the following *seems* to only exist in c++ codebases, for instance, | ||
// when calling a member. In c, this syntax should always extract as a | ||
// [FunctionCall] rather than a [ExprCall] of a [FunctionAccess]. Still, this | ||
// is a good pattern to be defensive against. | ||
not exists(ExprCall call | call.getExpr() = access) | ||
} | ||
|
||
from FunctionAccess funcAccess | ||
where | ||
not isExcluded(funcAccess, FunctionTypesPackage::functionAddressesShouldAddressOperatorQuery()) and | ||
isImplicitlyAddressed(funcAccess) | ||
select funcAccess, | ||
"The address of function " + funcAccess.getTarget().getName() + | ||
" is taken without the & operator." |
This file contains 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 file contains 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
13 changes: 13 additions & 0 deletions
13
c/misra/test/rules/RULE-17-12/FunctionAddressesShouldAddressOperator.expected
This file contains 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,13 @@ | ||
| test.c:14:25:14:29 | func2 | The address of function func2 is taken without the & operator. | | ||
| test.c:15:25:15:29 | func3 | The address of function func3 is taken without the & operator. | | ||
| test.c:21:12:21:16 | func1 | The address of function func1 is taken without the & operator. | | ||
| test.c:38:3:38:7 | func1 | The address of function func1 is taken without the & operator. | | ||
| test.c:39:3:39:7 | func2 | The address of function func2 is taken without the & operator. | | ||
| test.c:57:13:57:17 | func1 | The address of function func1 is taken without the & operator. | | ||
| test.c:58:21:58:25 | func2 | The address of function func2 is taken without the & operator. | | ||
| test.c:59:13:59:17 | func1 | The address of function func1 is taken without the & operator. | | ||
| test.c:59:20:59:24 | func2 | The address of function func2 is taken without the & operator. | | ||
| test.c:67:11:67:15 | func1 | The address of function func1 is taken without the & operator. | | ||
| test.c:68:12:68:16 | func1 | The address of function func1 is taken without the & operator. | | ||
| test.c:69:12:69:16 | func1 | The address of function func1 is taken without the & operator. | | ||
| test.c:71:18:71:22 | func1 | The address of function func1 is taken without the & operator. | |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-17-12/FunctionAddressesShouldAddressOperator.qlref
This file contains 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 @@ | ||
rules/RULE-17-12/FunctionAddressesShouldAddressOperator.ql |
Oops, something went wrong.