-
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 lcartey/dead-code-improvements
- Loading branch information
Showing
34 changed files
with
425 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
language,standard,amendment,rule_id,queryable,implementation_category,implemented,difficulty | ||
c,misra-c-2012,Amendment3,DIR-4-6,Yes,Expand,No,Easy | ||
c,misra-c-2012,Amendment3,DIR-4-9,Yes,Refine,No,Easy | ||
c,misra-c-2012,Amendment3,DIR-4-11,Yes,Refine,No,Import | ||
c,misra-c-2012,Amendment3,RULE-1-4,Yes,Replace,No,Easy | ||
c,misra-c-2012,Amendment3,RULE-10-1,Yes,Replace,No,Easy | ||
c,misra-c-2012,Amendment3,RULE-10-3,Yes,Refine,No,Easy | ||
c,misra-c-2012,Amendment3,RULE-10-4,Yes,Refine,No,Import | ||
c,misra-c-2012,Amendment3,RULE-10-5,Yes,Expand,No,Easy | ||
c,misra-c-2012,Amendment3,RULE-10-7,Yes,Refine,No,Import | ||
c,misra-c-2012,Amendment3,RULE-10-8,Yes,Refine,No,Import | ||
c,misra-c-2012,Amendment3,RULE-21-11,Yes,Clarification,No,Import | ||
c,misra-c-2012,Amendment3,RULE-21-12,Yes,Replace,No,Easy | ||
c,misra-c-2012,Amendment4,RULE-11-3,Yes,Expand,No,Easy | ||
c,misra-c-2012,Amendment4,RULE-11-8,Yes,Expand,No,Easy | ||
c,misra-c-2012,Amendment4,RULE-13-2,Yes,Expand,No,Very Hard | ||
c,misra-c-2012,Amendment4,RULE-18-6,Yes,Expand,No,Medium | ||
c,misra-c-2012,Amendment4,RULE-18-8,Yes,Split,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-2-2,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-2-7,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-3-1,Yes,Refine,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-8-6,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-8-9,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-9-4,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-10-1,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-18-3,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-1-4,Yes,Replace,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-9-1,Yes,Refine,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-9-2,Yes,Refine,No,Import | ||
c,misra-c-2012,Corrigendum2,DIR-4-10,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-7-4,Yes,Refine,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-8-2,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-8-3,Yes,Refine,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-8-7,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-10-1,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-10-2,Yes,Refine,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-10-3,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-11-3,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-11-6,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-13-2,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-13-6,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-14-3,Yes,Refine,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-15-7,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-17-4,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-17-5,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-18-1,Yes,Refine,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-20-14,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-21-19,Yes,Clarification,No,Import | ||
c,misra-c-2012,Corrigendum2,RULE-21-20,Yes,Refine,No,Easy | ||
c,misra-c-2012,Corrigendum2,RULE-22-9,Yes,Clarification,No,Import |
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
23 changes: 23 additions & 0 deletions
23
c/misra/src/rules/RULE-6-3/BitFieldDeclaredAsMemberOfAUnion.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,23 @@ | ||
/** | ||
* @id c/misra/bit-field-declared-as-member-of-a-union | ||
* @name RULE-6-3: A bit field shall not be declared as a member of a union | ||
* @description Type punning on a union with bit fields relies on implementation-specific alignment | ||
* behavior. | ||
* @kind problem | ||
* @precision very-high | ||
* @problem.severity warning | ||
* @tags external/misra/id/rule-6-3 | ||
* correctness | ||
* external/misra/obligation/required | ||
*/ | ||
|
||
import cpp | ||
import codingstandards.c.misra | ||
|
||
from BitField field, Union u | ||
where | ||
not isExcluded(field, BitfieldTypes2Package::bitFieldDeclaredAsMemberOfAUnionQuery()) and | ||
u.getAField() = field | ||
select field, | ||
"Union member " + field.getName() + | ||
" is declared as a bit field which relies on implementation-specific behavior." |
1 change: 0 additions & 1 deletion
1
c/misra/test/rules/RULE-11-1/ConversionBetweenFunctionPointerAndOtherType.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
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
12 changes: 6 additions & 6 deletions
12
c/misra/test/rules/RULE-11-4/ConversionBetweenPointerToObjectAndIntegerType.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
| test.c:5:21:5:42 | (unsigned int)... | Cast performed between a pointer to object type and a pointer to an integer type. | | ||
| test.c:5:35:5:42 | (int *)... | Cast performed between a pointer to object type and a pointer to an integer type. | | ||
| test.c:6:21:6:37 | (unsigned int)... | Cast performed between a pointer to object type and a pointer to an integer type. | | ||
| test.c:8:8:8:24 | (unsigned int)... | Cast performed between a pointer to object type and a pointer to an integer type. | | ||
| test.c:10:22:10:22 | (unsigned int *)... | Cast performed between a pointer to object type and a pointer to an integer type. | | ||
| test.c:12:22:12:39 | (unsigned int *)... | Cast performed between a pointer to object type and a pointer to an integer type. | | ||
| test.c:6:21:6:37 | (unsigned int)... | Cast from pointer to object type 'unsigned int *' to integer type 'unsigned int'. | test.c:6:21:6:37 | (unsigned int)... | | | ||
| test.c:8:8:8:24 | (unsigned int)... | Cast from pointer to object type 'unsigned int *' to integer type 'unsigned int'. | test.c:8:8:8:24 | (unsigned int)... | | | ||
| test.c:12:22:12:39 | (unsigned int *)... | Cast from integer type 'unsigned int' to pointer to object type 'unsigned int *'. | test.c:12:22:12:39 | (unsigned int *)... | | | ||
| test.c:15:1:15:24 | #define FOO (int *)0x200 | Cast from integer type 'int' to pointer to object type 'int *'. | test.c:15:1:15:24 | #define FOO (int *)0x200 | | | ||
| test.c:23:3:23:22 | (int *)... | Cast from integer type 'int' to pointer to object type 'int *' from expansion of macro $@. | test.c:17:1:17:34 | #define FOO_FUNCTIONAL(x) (int *)x | FOO_FUNCTIONAL | | ||
| test.c:24:14:24:25 | (int *)... | Cast from integer type 'int' to pointer to object type 'int *' from expansion of macro $@. | test.c:18:1:18:23 | #define FOO_INSERT(x) x | FOO_INSERT | |
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
5 changes: 3 additions & 2 deletions
5
c/misra/test/rules/RULE-11-9/MacroNullNotUsedAsIntegerNullPointerConstant.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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
| test.c:15:13:15:13 | 0 | $@ uses zero-value integer constant expression as null pointer constant. | test.c:15:7:15:13 | ... == ... | Equality operator | | ||
| test.c:17:8:17:8 | 0 | $@ uses zero-value integer constant expression as null pointer constant. | test.c:17:3:17:8 | ... = ... | Assignment to pointer | | ||
| test.c:25:20:25:20 | 0 | $@ uses zero-value integer constant expression as null pointer constant. | test.c:25:3:25:35 | ... ? ... : ... | Ternary operator | | ||
| test.c:25:20:25:20 | 0 | $@ uses zero-value integer constant expression as null pointer constant. | test.c:25:15:25:20 | ... = ... | Assignment to pointer | | ||
| test.c:23:13:23:13 | 0 | $@ uses zero-value integer constant expression as null pointer constant. | test.c:23:3:23:13 | ... ? ... : ... | Ternary operator | | ||
| test.c:24:8:24:8 | 0 | $@ uses zero-value integer constant expression as null pointer constant. | test.c:24:3:24:13 | ... ? ... : ... | Ternary operator | | ||
| test.c:31:14:31:14 | 0 | $@ uses zero-value integer constant expression as null pointer constant. | test.c:31:9:31:14 | ... = ... | Assignment to pointer | |
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
2 changes: 2 additions & 0 deletions
2
c/misra/test/rules/RULE-6-3/BitFieldDeclaredAsMemberOfAUnion.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,2 @@ | ||
| test.c:7:7:7:7 | x | Union member x is declared as a bit field which relies on implementation-specific behavior. | | ||
| test.c:20:7:20:7 | (unnamed bitfield) | Union member (unnamed bitfield) is declared as a bit field which relies on implementation-specific behavior. | |
1 change: 1 addition & 0 deletions
1
c/misra/test/rules/RULE-6-3/BitFieldDeclaredAsMemberOfAUnion.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-6-3/BitFieldDeclaredAsMemberOfAUnion.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,21 @@ | ||
union U1 { | ||
int x; // COMPLIANT | ||
char y; // COMPLIANT | ||
}; | ||
|
||
union U2 { | ||
int x : 2; // NON-COMPLIANT | ||
char y; // COMPLIANT | ||
}; | ||
|
||
union U3 { | ||
struct str { | ||
int x : 4; // COMPLIANT | ||
int y : 2; // COMPLIANT | ||
}; | ||
}; | ||
|
||
union U4 { | ||
char x; | ||
int : 0; // NON-COMPLIANT | ||
}; |
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,12 @@ | ||
- `RULE-11-1` - `ConversionBetweenFunctionPointerAndOtherType.ql`: | ||
- Fixed issue #331 - consider `0` a null pointer constant. | ||
- `RULE-11-4` - `ConversionBetweenPointerToObjectAndIntegerType.ql`: | ||
- Fixed issue #331 - consider `0` a null pointer constant. | ||
- Improve reporting of the order of the cast and the actual types involved. | ||
- Improve reporting where the result is expanded from a macro by either reporting the macro itself (if it is not dependent on the context) or by including a link to the macro in the alert message. | ||
- `RULE-11-5` - `ConversionFromPointerToVoidIntoPointerToObject.ql`: | ||
- Fixed issue #331 - consider `0` a null pointer constant. | ||
- `RULE-11-6` - `CastBetweenPointerToVoidAndArithmeticType.ql`: | ||
- Fixed issue #331 - accept integer constant expressions with value `0` instead of null pointer constants. | ||
- `RULE-11-9` - `MacroNullNotUsedAsIntegerNullPointerConstant.ql`: | ||
- Remove false positives in branches of ternary expressions, where `0` was used correctly. |
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,2 @@ | ||
- `M3-4-1` - `UnnecessaryExposedIdentifierDeclarationShared.qll`: | ||
- Fixes #665. Exclude variables that are constexpr and coming from template instantiations. |
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,2 @@ | ||
- `A1-1-2` - `CompilerWarningLevelNotInCompliance.ql`: | ||
- Report non-compliance for compilations that use the error-suppressing `-w` flag. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
| Wcast-function-type.cpp:0:0:0:0 | Wcast-function-type.cpp | No warning-level options were used in the compilation of 'Wcast-function-type.cpp'. | |
Empty file.
Empty file.
Empty file.
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 |
---|---|---|
@@ -1,2 +1,14 @@ | ||
// semmle-extractor-options: --clang -std=c++14 -Wcast-function-type | ||
// COMPLIANT | ||
// COMPLIANT | ||
|
||
// NOTE: When tested with `codeql test run`, the test extractor provides `-w` | ||
// which overrides `-Wcast-function-type` and causes this test case to be | ||
// non-compliant. | ||
// | ||
// However, when tested with our compiler matrix tests, this test db is built | ||
// via `codeql database create --command="..."`, and the `-w` flag will NOT be | ||
// used. This means the `-Wcast-function-type` flag is active and the test case | ||
// is compliant. | ||
// | ||
// Therefore, the .expected file for this test expects non-compliance, and the | ||
// .expected.gcc and .expected.clang files expect this test to be compliant. |
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 @@ | ||
| Wall.cpp:0:0:0:0 | Wall.cpp | No warning-level options were used in the compilation of 'Wall.cpp'. | |
Empty file.
Empty file.
Empty file.
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 |
---|---|---|
@@ -1,2 +1,12 @@ | ||
// semmle-extractor-options: --clang -std=c++14 -Wall | ||
// COMPLIANT | ||
// COMPLIANT | ||
|
||
// NOTE: When tested with `codeql test run`, the test extractor provides `-w` | ||
// which overrides `-Wall` and causes this test case to be non-compliant. | ||
// | ||
// However, when tested with our compiler matrix tests, this test db is built | ||
// via `codeql database create --command="..."`, and the `-w` flag will NOT be | ||
// used. This means the `-Wall` flag is active and the test case is compliant. | ||
// | ||
// Therefore, the .expected file for this test expects non-compliance, and the | ||
// .expected.gcc and .expected.clang files expect this test to be compliant. |
Oops, something went wrong.