Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
jsinglet merged 5 commits intogithub:mainfromjsinglet:jsinglet/language1
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.vscode/tasks.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -220,6 +220,7 @@
"Invariants",
"Iterators",
"Lambdas",
"Language1",
"Literals",
"Loops",
"Macros",
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff 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."
View file
Open in desktop
Original file line numberDiff line numberDiff 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. |
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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()))
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ import IO1
import IO2
import IO3
import IO4
import Language1
import Misc
import Pointers1
import Pointers2
Expand DownExpand Up@@ -51,6 +52,7 @@ newtype TCQuery =
TIO2PackageQuery(IO2Query q) or
TIO3PackageQuery(IO3Query q) or
TIO4PackageQuery(IO4Query q) or
TLanguage1PackageQuery(Language1Query q) or
TMiscPackageQuery(MiscQuery q) or
TPointers1PackageQuery(Pointers1Query q) or
TPointers2PackageQuery(Pointers2Query q) or
Expand DownExpand Up@@ -84,6 +86,7 @@ predicate isQueryMetadata(Query query, string queryId, string ruleId) {
isIO2QueryMetadata(query, queryId, ruleId) or
isIO3QueryMetadata(query, queryId, ruleId) or
isIO4QueryMetadata(query, queryId, ruleId) or
isLanguage1QueryMetadata(query, queryId, ruleId) or
isMiscQueryMetadata(query, queryId, ruleId) or
isPointers1QueryMetadata(query, queryId, ruleId) or
isPointers2QueryMetadata(query, queryId, ruleId) or
Expand Down
24 changes: 24 additions & 0 deletionsrule_packages/c/Language1.json
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -604,7 +604,7 @@ c,MISRA-C-2012,RULE-2-1,Yes,Required,,,All source files shall compile without an
c,MISRA-C-2012,RULE-3-1,No,Required,,,All code shall be traceable to documented requirements,,,,
c,MISRA-C-2012,RULE-4-1,No,Required,,,Run-time failures shall be minimized,,,,
c,MISRA-C-2012,RULE-4-2,Yes,Advisory,,,All usage of assembly language should be documented,M7-4-1,Language,Import,
c,MISRA-C-2012,RULE-4-3,Yes,Required,,,Assembly language shall be encapsulated and isolated,,Language,Medium,
c,MISRA-C-2012,DIR-4-3,Yes,Required,,,Assembly language shall be encapsulated and isolated,,Language1,Medium,
c,MISRA-C-2012,RULE-4-4,Yes,Advisory,,,Sections of code should not be commented out,A2-7-2,Syntax,Import,
c,MISRA-C-2012,DIR-4-5,Yes,Advisory,,,Identifiers in the same name space with overlapping visibility should be typographically unambiguous,M2-10-1,Syntax,Easy,
c,MISRA-C-2012,RULE-4-6,Yes,Advisory,,,typedefs that indicate size and signedness should be used in place of the basic numerical types,,Types,Hard,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp