- Notifications
You must be signed in to change notification settings - Fork70
Language 1#103
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Language 1#103
Changes fromall commits
Commits
Show all changes
5 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions.vscode/tasks.json
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 |
|---|---|---|
| @@ -220,6 +220,7 @@ | ||
| "Invariants", | ||
| "Iterators", | ||
| "Lambdas", | ||
| "Language1", | ||
| "Literals", | ||
| "Loops", | ||
| "Macros", | ||
28 changes: 28 additions & 0 deletionsc/misra/src/rules/DIR-4-3/LanguageNotEncapsulatedAndIsolated.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 c/misra/language-not-encapsulated-and-isolated | ||
| * @name DIR-4-3: Assembly language shall be encapsulated and isolated | ||
| * @description Failing to encapsulate assembly language limits the portability, reliability, and | ||
| * readability of programs. | ||
| * @kind problem | ||
| * @precision very-high | ||
| * @problem.severity error | ||
| * @tags external/misra/id/dir-4-3 | ||
| * maintainability | ||
| * readability | ||
| * external/misra/obligation/required | ||
| */ | ||
| import cpp | ||
| import codingstandards.c.misra | ||
| from AsmStmt asm | ||
| where | ||
| not isExcluded(asm, Language1Package::languageNotEncapsulatedAndIsolatedQuery()) and | ||
| not exists(asm.getEnclosingFunction()) | ||
| or | ||
| // in concept statements within the body constitute intermingling assembly, | ||
| // rather than expressions and are more general. | ||
| exists(Stmt sp | sp = asm.getEnclosingFunction().getEntryPoint().getASuccessor*() | | ||
| not sp instanceof AsmStmt and not sp instanceof ReturnStmt and not sp instanceof BlockStmt | ||
| ) | ||
| select asm, "Usage of non-isolated and non-encapsulated assembly language." |
5 changes: 5 additions & 0 deletionsc/misra/test/rules/DIR-4-3/LanguageNotEncapsulatedAndIsolated.expected
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,5 @@ | ||
| | test.c:6:3:6:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. | | ||
| | test.c:11:3:11:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. | | ||
| | test.c:32:3:32:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. | | ||
| | test.c:37:3:37:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. | | ||
| | test.c:58:3:58:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. | |
1 change: 1 addition & 0 deletionsc/misra/test/rules/DIR-4-3/LanguageNotEncapsulatedAndIsolated.qlref
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 @@ | ||
| rules/DIR-4-3/LanguageNotEncapsulatedAndIsolated.ql |
80 changes: 80 additions & 0 deletionsc/misra/test/rules/DIR-4-3/test.c
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,80 @@ | ||
| #define N1 asm("HCF") | ||
| #define N2 __asm__("HCF") | ||
| void f1() { | ||
| int a; | ||
| N1; // NON_COMPLIANT | ||
| } | ||
| void f2() { | ||
| int a; | ||
| N2; // NON_COMPLIANT | ||
| } | ||
| void f3() { | ||
| N1; // COMPLIANT | ||
| } | ||
| void f4() { | ||
| N2; // COMPLIANT | ||
| } | ||
| void f5() { | ||
| __asm__("HCF"); // COMPLIANT | ||
| } | ||
| void f6() { | ||
| asm("HCF"); // COMPLIANT | ||
| } | ||
| inline void f7() { | ||
| int a; | ||
| N1; // NON_COMPLIANT | ||
| } | ||
| inline void f8() { | ||
| int a; | ||
| N2; // NON_COMPLIANT | ||
| } | ||
| inline void f9() { | ||
| N1; // COMPLIANT | ||
| } | ||
| inline void f10() { | ||
| N2; // COMPLIANT | ||
| } | ||
| inline void f11() { | ||
| __asm__("HCF"); // COMPLIANT | ||
| } | ||
| inline void f12() { | ||
| asm("HCF"); // COMPLIANT | ||
| } | ||
| inline int f13() { | ||
| int a; | ||
| N2; // NON_COMPLIANT | ||
| return 0; | ||
| } | ||
| inline int f14() { | ||
| N1; // COMPLIANT | ||
| return 0; | ||
| } | ||
| inline int f15() { | ||
| N2; // COMPLIANT | ||
| return 0; | ||
| } | ||
| inline int f16() { | ||
| __asm__("HCF"); // COMPLIANT | ||
| return 0; | ||
| } | ||
| inline int f17() { | ||
| asm("HCF"); // COMPLIANT | ||
| return 0; | ||
| } |
25 changes: 25 additions & 0 deletionscpp/common/src/codingstandards/cpp/exclusions/c/Language1.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/ | ||
| import cpp | ||
| import RuleMetadata | ||
| import codingstandards.cpp.exclusions.RuleMetadata | ||
| newtype Language1Query = TLanguageNotEncapsulatedAndIsolatedQuery() | ||
| predicate isLanguage1QueryMetadata(Query query, string queryId, string ruleId) { | ||
| query = | ||
| // `Query` instance for the `languageNotEncapsulatedAndIsolated` query | ||
| Language1Package::languageNotEncapsulatedAndIsolatedQuery() and | ||
| queryId = | ||
| // `@id` for the `languageNotEncapsulatedAndIsolated` query | ||
| "c/misra/language-not-encapsulated-and-isolated" and | ||
| ruleId = "DIR-4-3" | ||
| } | ||
| module Language1Package { | ||
| Query languageNotEncapsulatedAndIsolatedQuery() { | ||
| //autogenerate `Query` type | ||
| result = | ||
| // `Query` type for `languageNotEncapsulatedAndIsolated` query | ||
| TQueryC(TLanguage1PackageQuery(TLanguageNotEncapsulatedAndIsolatedQuery())) | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletionscpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.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
24 changes: 24 additions & 0 deletionsrule_packages/c/Language1.json
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,24 @@ | ||
| { | ||
| "MISRA-C-2012": { | ||
| "DIR-4-3": { | ||
| "properties": { | ||
| "obligation": "required" | ||
| }, | ||
| "queries": [ | ||
| { | ||
| "description": "Failing to encapsulate assembly language limits the portability, reliability, and readability of programs.", | ||
| "kind": "problem", | ||
| "name": "Assembly language shall be encapsulated and isolated", | ||
| "precision": "very-high", | ||
| "severity": "error", | ||
| "short_name": "LanguageNotEncapsulatedAndIsolated", | ||
| "tags": [ | ||
| "maintainability", | ||
| "readability" | ||
| ] | ||
| } | ||
| ], | ||
| "title": "Assembly language shall be encapsulated and isolated" | ||
| } | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletionrules.csv
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
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.