-
Notifications
You must be signed in to change notification settings - Fork 77
Add Banned8, Banned5, and Banned6 #1094
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
Open
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
6fda6fa
Add Banned8
jeongsoolee09 cd095be
Add Banned5
jeongsoolee09 e4b4e4b
Add Banned6 and improve `@description` metadata of A9-5-1
jeongsoolee09 25c9df8
Fix an editing mistake on rules.csv
jeongsoolee09 e682b81
Fix query formatting
jeongsoolee09 cfaccb3
Re-generate package files with new names and add shared test that was…
jeongsoolee09 52b590b
Fill in shared query file for BannedSyntax and Banned6
jeongsoolee09 895ffbb
Populate shared query for Banned5 / Representation and make shared te…
jeongsoolee09 a54f56d
Minor formatting
jeongsoolee09 e76a2d2
Fix query formatting
jeongsoolee09 5f0ad4d
Remove UnionKeywordUsed query and test
mbaluda a23f7a5
Merge branch 'main' into jeongsoolee09/MISRA-C++-2023-Banned856
mbaluda 97b5fa5
remove bitFieldsShouldNotBeDeclaredQuery.ql
mbaluda 6b86b72
Remove duplicate tests
mbaluda 33e536d
Merge branch 'main' into jeongsoolee09/MISRA-C++-2023-Banned856
jeongsoolee09 67d06e9
Surround code bits with single-quotes
jeongsoolee09 b73fab8
Un-share `UnionKeywordUsed`
jeongsoolee09 5740aaa
Add `"readability"` tag to Banned8.json
jeongsoolee09 bf7a636
Shorten shared query name
jeongsoolee09 085033d
Update shared test query
jeongsoolee09 d4233c5
Fix formatting
jeongsoolee09 750cb2c
Add clickable links to the alert message
jeongsoolee09 a2d3c0e
Add change note for the breaking change
jeongsoolee09 febb828
Make the @tags property consistent
jeongsoolee09 97637a4
Merge branch 'main' into jeongsoolee09/MISRA-C++-2023-Banned856
jeongsoolee09 be70ae7
Update expected files of RULE-8-3-2
jeongsoolee09 1c5b8cc
Don't make the primary location show up twice
jeongsoolee09 da1e77d
Mention the fact that the union name is now surrounded with single qu…
jeongsoolee09 6035f80
Merge branch 'main' into jeongsoolee09/MISRA-C++-2023-Banned856
jeongsoolee09 5ef3a9d
Add expected results for AuditPossible[..]Definition
jeongsoolee09 a8dda3d
Merge branch 'jeongsoolee09/MISRA-C++-2023-Banned856' of github.com:g…
jeongsoolee09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,4 @@ | ||
| - `A9-6-2` - `BitFieldsShallBeUsedOnlyWhenInterfacingToHardwareOrConformingToCommunicationProtocols.ql`: | ||
| - Shorten the name to `BitFieldsShouldNotBeDeclaredAutosarCpp`, where the name shared query it imports is `BitFieldsShouldNotBeDeclared`. | ||
| - Tag `"portability"` is added. | ||
| - Alert message now includes single quotes around union name. | ||
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
35 changes: 0 additions & 35 deletions
35
.../BitFieldsShallBeUsedOnlyWhenInterfacingToHardwareOrConformingToCommunicationProtocols.ql
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
cpp/autosar/src/rules/A9-6-2/BitFieldsShouldNotBeDeclaredAutosarCpp.ql
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,28 @@ | ||
| /** | ||
| * @id cpp/autosar/bit-fields-should-not-be-declared-autosar-cpp | ||
| * @name A9-6-2: Bit-fields shall be used only when interfacing to hardware or conforming to communication protocols | ||
| * @description The usage of bit-fields increases code complexity and certain aspects of bit-field | ||
| * manipulation can be error prone and implementation defined. Hence a bit-field usage | ||
| * is reserved only when interfacing to hardware or conformance to communication | ||
| * protocols. | ||
| * @kind problem | ||
| * @precision very-high | ||
| * @problem.severity recommendation | ||
| * @tags external/autosar/id/a9-6-2 | ||
| * maintainability | ||
| * portability | ||
| * external/autosar/allocated-target/design | ||
| * external/autosar/enforcement/partially-automated | ||
| * external/autosar/obligation/required | ||
| */ | ||
|
|
||
| import cpp | ||
| import codingstandards.cpp.autosar | ||
| import codingstandards.cpp.rules.bitfieldsshouldnotbedeclared.BitFieldsShouldNotBeDeclared | ||
|
|
||
| module BitFieldsShouldNotBeDeclaredAutosarCppConfig implements BitFieldsShouldNotBeDeclaredConfigSig | ||
| { | ||
| Query getQuery() { result = RepresentationPackage::bitFieldsShouldNotBeDeclaredAutosarCppQuery() } | ||
| } | ||
|
|
||
| import BitFieldsShouldNotBeDeclared<BitFieldsShouldNotBeDeclaredAutosarCppConfig> |
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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| | test.cpp:14:9:14:9 | u | u is not a tagged union. | | ||
| | test.cpp:21:7:21:7 | u | u is not a tagged union. | | ||
| | test.cpp:14:9:14:9 | u | 'u' is not a tagged union. | | ||
| | test.cpp:21:7:21:7 | u | 'u' is not a tagged union. | |
1 change: 0 additions & 1 deletion
1
...eldsShallBeUsedOnlyWhenInterfacingToHardwareOrConformingToCommunicationProtocols.expected
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...tFieldsShallBeUsedOnlyWhenInterfacingToHardwareOrConformingToCommunicationProtocols.qlref
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
cpp/autosar/test/rules/A9-6-2/BitFieldsShouldNotBeDeclaredAutosarCpp.testref
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 @@ | ||
| cpp/common/test/rules/bitfieldsshouldnotbedeclared/BitFieldsShouldNotBeDeclared.ql |
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,287 @@ | ||
| import cpp as default | ||
|
|
||
| /* | ||
| * Implementations of the C/C++ Fixed Width Types from cstdint. | ||
| * | ||
| * TODO: Deprecate once this is available in the CodeQL standard library. | ||
| */ | ||
|
|
||
| /** | ||
| * A parent class representing C/C++ a typedef'd `UserType` such as `int8_t`. | ||
| */ | ||
| abstract private class IntegralUnderlyingUserType extends default::UserType { | ||
| IntegralUnderlyingUserType() { this.getUnderlyingType() instanceof default::IntegralType } | ||
| } | ||
|
|
||
| abstract private class TFixedWidthIntegralType extends IntegralUnderlyingUserType { } | ||
|
|
||
| /** | ||
| * A C/C++ fixed-width numeric type, such as `int8_t`. | ||
| */ | ||
| class FixedWidthIntegralType extends TFixedWidthIntegralType { | ||
| FixedWidthIntegralType() { this instanceof TFixedWidthIntegralType } | ||
| } | ||
|
|
||
| abstract private class TMinimumWidthIntegralType extends IntegralUnderlyingUserType { } | ||
|
|
||
| /** | ||
| * A C/C++ minimum-width numeric type, such as `int_least8_t`. | ||
| */ | ||
| class MinimumWidthIntegralType extends TMinimumWidthIntegralType { | ||
| MinimumWidthIntegralType() { this instanceof TMinimumWidthIntegralType } | ||
| } | ||
|
|
||
| abstract private class TFastestMinimumWidthIntegralType extends IntegralUnderlyingUserType { } | ||
|
|
||
| /** | ||
| * A C/C++ minimum-width numeric type, representing the fastest integer type with a | ||
| * width of at least `N` such as `int_fast8_t`. | ||
| */ | ||
| class FastestMinimumWidthIntegralType extends TFastestMinimumWidthIntegralType { | ||
| FastestMinimumWidthIntegralType() { this instanceof TFastestMinimumWidthIntegralType } | ||
| } | ||
|
|
||
| /** | ||
| * An enum type based on a fixed-width integer type. For instance, `enum e: uint8_t = { a, b };` | ||
| */ | ||
| class FixedWidthEnumType extends default::UserType { | ||
| FixedWidthEnumType() { | ||
| this.(default::Enum).getExplicitUnderlyingType() instanceof FixedWidthIntegralType | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int8_t` type. | ||
| */ | ||
| class Int8_t extends TFixedWidthIntegralType { | ||
| Int8_t() { this.hasGlobalOrStdName("int8_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int8_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int16_t` type. | ||
| */ | ||
| class Int16_t extends TFixedWidthIntegralType { | ||
| Int16_t() { this.hasGlobalOrStdName("int16_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int16_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int32_t` type. | ||
| */ | ||
| class Int32_t extends TFixedWidthIntegralType { | ||
| Int32_t() { this.hasGlobalOrStdName("int32_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int32_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int64_t` type. | ||
| */ | ||
| class Int64_t extends TFixedWidthIntegralType { | ||
| Int64_t() { this.hasGlobalOrStdName("int64_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int64_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint8_t` type. | ||
| */ | ||
| class UInt8_t extends TFixedWidthIntegralType { | ||
| UInt8_t() { this.hasGlobalOrStdName("uint8_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt8_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint16_t` type. | ||
| */ | ||
| class UInt16_t extends TFixedWidthIntegralType { | ||
| UInt16_t() { this.hasGlobalOrStdName("uint16_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt16_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint32_t` type. | ||
| */ | ||
| class UInt32_t extends TFixedWidthIntegralType { | ||
| UInt32_t() { this.hasGlobalOrStdName("uint32_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt32_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint64_t` type. | ||
| */ | ||
| class UInt64_t extends TFixedWidthIntegralType { | ||
| UInt64_t() { this.hasGlobalOrStdName("uint64_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt64_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int_least8_t` type. | ||
| */ | ||
| class Int_least8_t extends TMinimumWidthIntegralType { | ||
| Int_least8_t() { this.hasGlobalOrStdName("int_least8_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int_least8_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int_least16_t` type. | ||
| */ | ||
| class Int_least16_t extends TMinimumWidthIntegralType { | ||
| Int_least16_t() { this.hasGlobalOrStdName("int_least16_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int_least16_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int_least32_t` type. | ||
| */ | ||
| class Int_least32_t extends TMinimumWidthIntegralType { | ||
| Int_least32_t() { this.hasGlobalOrStdName("int_least32_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int_least32_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int_least64_t` type. | ||
| */ | ||
| class Int_least64_t extends TMinimumWidthIntegralType { | ||
| Int_least64_t() { this.hasGlobalOrStdName("int_least64_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int_least64_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint_least8_t` type. | ||
| */ | ||
| class UInt_least8_t extends TMinimumWidthIntegralType { | ||
| UInt_least8_t() { this.hasGlobalOrStdName("uint_least8_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt_least8_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint_least16_t` type. | ||
| */ | ||
| class UInt_least16_t extends TMinimumWidthIntegralType { | ||
| UInt_least16_t() { this.hasGlobalOrStdName("uint_least16_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt_least16_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint_least32_t` type. | ||
| */ | ||
| class UInt_least32_t extends TMinimumWidthIntegralType { | ||
| UInt_least32_t() { this.hasGlobalOrStdName("uint_least32_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt_least32_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint_least64_t` type. | ||
| */ | ||
| class UInt_least64_t extends TMinimumWidthIntegralType { | ||
| UInt_least64_t() { this.hasGlobalOrStdName("uint_least64_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt_least64_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int_fast8_t` type. | ||
| */ | ||
| class Int_fast8_t extends TFastestMinimumWidthIntegralType { | ||
| Int_fast8_t() { this.hasGlobalOrStdName("int_fast8_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int_fast8_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int_fast16_t` type. | ||
| */ | ||
| class Int_fast16_t extends TFastestMinimumWidthIntegralType { | ||
| Int_fast16_t() { this.hasGlobalOrStdName("int_fast16_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int_fast16_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int_fast32_t` type. | ||
| */ | ||
| class Int_fast32_t extends TFastestMinimumWidthIntegralType { | ||
| Int_fast32_t() { this.hasGlobalOrStdName("int_fast32_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int_fast32_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `int_fast64_t` type. | ||
| */ | ||
| class Int_fast64_t extends TFastestMinimumWidthIntegralType { | ||
| Int_fast64_t() { this.hasGlobalOrStdName("int_fast64_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "Int_fast64_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint_fast8_t` type. | ||
| */ | ||
| class UInt_fast8_t extends TFastestMinimumWidthIntegralType { | ||
| UInt_fast8_t() { this.hasGlobalOrStdName("uint_fast8_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt_fast8_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint_fast16_t` type. | ||
| */ | ||
| class UInt_fast16_t extends TFastestMinimumWidthIntegralType { | ||
| UInt_fast16_t() { this.hasGlobalOrStdName("uint_fast16_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt_fast16_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint_fast32_t` type. | ||
| */ | ||
| class UInt_fast32_t extends TFastestMinimumWidthIntegralType { | ||
| UInt_fast32_t() { this.hasGlobalOrStdName("uint_fast32_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt_fast32_t" } | ||
| } | ||
|
|
||
| /** | ||
| * The C/C++ `uint_fast64_t` type. | ||
| */ | ||
| class UInt_fast64_t extends TFastestMinimumWidthIntegralType { | ||
| UInt_fast64_t() { this.hasGlobalOrStdName("uint_fast64_t") } | ||
|
|
||
| override string getAPrimaryQlClass() { result = "UInt_fast64_t" } | ||
| } | ||
|
|
||
| /** | ||
| * Type that models a type that is either a pointer or a reference type. | ||
| */ | ||
| class PointerOrReferenceType extends default::DerivedType { | ||
| PointerOrReferenceType() { | ||
| this instanceof default::PointerType or | ||
| this instanceof default::ReferenceType | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Type that models a char type that is explicitly signed or unsigned. | ||
| */ | ||
| class ExplictlySignedOrUnsignedCharType extends default::CharType { | ||
| ExplictlySignedOrUnsignedCharType() { | ||
| isExplicitlySigned() or | ||
| isExplicitlyUnsigned() | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
...dards/cpp/HardwareOrProtocolInterface.qll → ...dards/cpp/HardwareOrProtocolInterface.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.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.