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

Commit7e9fe0b

Browse files
committed
Add Conversions2 package
1 parent2b1c06b commit7e9fe0b

File tree

3 files changed

+240
-0
lines changed

3 files changed

+240
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
//** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/
2+
import cpp
3+
import RuleMetadata
4+
import codingstandards.cpp.exclusions.RuleMetadata
5+
6+
newtypeConversions2Query=
7+
TVirtualBaseClassCastToDerivedQuery()or
8+
TNoCStyleOrFunctionalCastsQuery()or
9+
TIntToPointerCastProhibitedQuery()or
10+
TNoPointerToIntegralCastQuery()or
11+
TPointerToIntegralCastQuery()or
12+
TNoStandaloneTypeCastExpressionQuery()
13+
14+
predicateisConversions2QueryMetadata(Queryquery,stringqueryId,stringruleId,stringcategory){
15+
query=
16+
// `Query` instance for the `virtualBaseClassCastToDerived` query
17+
Conversions2Package::virtualBaseClassCastToDerivedQuery()and
18+
queryId=
19+
// `@id` for the `virtualBaseClassCastToDerived` query
20+
"cpp/misra/virtual-base-class-cast-to-derived"and
21+
ruleId="RULE-8-2-1"and
22+
category="required"
23+
or
24+
query=
25+
// `Query` instance for the `noCStyleOrFunctionalCasts` query
26+
Conversions2Package::noCStyleOrFunctionalCastsQuery()and
27+
queryId=
28+
// `@id` for the `noCStyleOrFunctionalCasts` query
29+
"cpp/misra/no-c-style-or-functional-casts"and
30+
ruleId="RULE-8-2-2"and
31+
category="required"
32+
or
33+
query=
34+
// `Query` instance for the `intToPointerCastProhibited` query
35+
Conversions2Package::intToPointerCastProhibitedQuery()and
36+
queryId=
37+
// `@id` for the `intToPointerCastProhibited` query
38+
"cpp/misra/int-to-pointer-cast-prohibited"and
39+
ruleId="RULE-8-2-6"and
40+
category="required"
41+
or
42+
query=
43+
// `Query` instance for the `noPointerToIntegralCast` query
44+
Conversions2Package::noPointerToIntegralCastQuery()and
45+
queryId=
46+
// `@id` for the `noPointerToIntegralCast` query
47+
"cpp/misra/no-pointer-to-integral-cast"and
48+
ruleId="RULE-8-2-7"and
49+
category="advisory"
50+
or
51+
query=
52+
// `Query` instance for the `pointerToIntegralCast` query
53+
Conversions2Package::pointerToIntegralCastQuery()and
54+
queryId=
55+
// `@id` for the `pointerToIntegralCast` query
56+
"cpp/misra/pointer-to-integral-cast"and
57+
ruleId="RULE-8-2-8"and
58+
category="required"
59+
or
60+
query=
61+
// `Query` instance for the `noStandaloneTypeCastExpression` query
62+
Conversions2Package::noStandaloneTypeCastExpressionQuery()and
63+
queryId=
64+
// `@id` for the `noStandaloneTypeCastExpression` query
65+
"cpp/misra/no-standalone-type-cast-expression"and
66+
ruleId="RULE-9-2-1"and
67+
category="required"
68+
}
69+
70+
module Conversions2Package{
71+
QueryvirtualBaseClassCastToDerivedQuery(){
72+
//autogenerate `Query` type
73+
result=
74+
// `Query` type for `virtualBaseClassCastToDerived` query
75+
TQueryCPP(TConversions2PackageQuery(TVirtualBaseClassCastToDerivedQuery()))
76+
}
77+
78+
QuerynoCStyleOrFunctionalCastsQuery(){
79+
//autogenerate `Query` type
80+
result=
81+
// `Query` type for `noCStyleOrFunctionalCasts` query
82+
TQueryCPP(TConversions2PackageQuery(TNoCStyleOrFunctionalCastsQuery()))
83+
}
84+
85+
QueryintToPointerCastProhibitedQuery(){
86+
//autogenerate `Query` type
87+
result=
88+
// `Query` type for `intToPointerCastProhibited` query
89+
TQueryCPP(TConversions2PackageQuery(TIntToPointerCastProhibitedQuery()))
90+
}
91+
92+
QuerynoPointerToIntegralCastQuery(){
93+
//autogenerate `Query` type
94+
result=
95+
// `Query` type for `noPointerToIntegralCast` query
96+
TQueryCPP(TConversions2PackageQuery(TNoPointerToIntegralCastQuery()))
97+
}
98+
99+
QuerypointerToIntegralCastQuery(){
100+
//autogenerate `Query` type
101+
result=
102+
// `Query` type for `pointerToIntegralCast` query
103+
TQueryCPP(TConversions2PackageQuery(TPointerToIntegralCastQuery()))
104+
}
105+
106+
QuerynoStandaloneTypeCastExpressionQuery(){
107+
//autogenerate `Query` type
108+
result=
109+
// `Query` type for `noStandaloneTypeCastExpression` query
110+
TQueryCPP(TConversions2PackageQuery(TNoStandaloneTypeCastExpressionQuery()))
111+
}
112+
}

‎cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Concurrency
1313
import Conditionals
1414
import Const
1515
import Conversions
16+
import Conversions2
1617
import DeadCode
1718
import Declarations
1819
import ExceptionSafety
@@ -69,6 +70,7 @@ newtype TCPPQuery =
6970
TConditionalsPackageQuery(ConditionalsQueryq)or
7071
TConstPackageQuery(ConstQueryq)or
7172
TConversionsPackageQuery(ConversionsQueryq)or
73+
TConversions2PackageQuery(Conversions2Queryq)or
7274
TDeadCodePackageQuery(DeadCodeQueryq)or
7375
TDeclarationsPackageQuery(DeclarationsQueryq)or
7476
TExceptionSafetyPackageQuery(ExceptionSafetyQueryq)or
@@ -125,6 +127,7 @@ predicate isQueryMetadata(Query query, string queryId, string ruleId, string cat
125127
isConditionalsQueryMetadata(query,queryId,ruleId,category)or
126128
isConstQueryMetadata(query,queryId,ruleId,category)or
127129
isConversionsQueryMetadata(query,queryId,ruleId,category)or
130+
isConversions2QueryMetadata(query,queryId,ruleId,category)or
128131
isDeadCodeQueryMetadata(query,queryId,ruleId,category)or
129132
isDeclarationsQueryMetadata(query,queryId,ruleId,category)or
130133
isExceptionSafetyQueryMetadata(query,queryId,ruleId,category)or
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"MISRA-C++-2023": {
3+
"RULE-8-2-1": {
4+
"properties": {
5+
"enforcement":"decidable",
6+
"obligation":"required"
7+
},
8+
"queries": [
9+
{
10+
"description":"Casting from a virtual base class to a derived class using anything other than dynamic_cast causes undefined behavior.",
11+
"kind":"problem",
12+
"name":"A virtual base class shall only be cast to a derived class by means of dynamic_cast",
13+
"precision":"very-high",
14+
"severity":"error",
15+
"short_name":"VirtualBaseClassCastToDerived",
16+
"tags": [
17+
"scope/single-translation-unit"
18+
],
19+
"shared_implementation_short_name":"PointerToAVirtualBaseClassCastToAPointer"
20+
}
21+
],
22+
"title":"A virtual base class shall only be cast to a derived class by means of dynamic_cast"
23+
},
24+
"RULE-8-2-2": {
25+
"properties": {
26+
"enforcement":"decidable",
27+
"obligation":"required"
28+
},
29+
"queries": [
30+
{
31+
"description":"Using C-style casts or functional notation casts allows unsafe type conversions and makes code harder to maintain compared to using named casts like const_cast, dynamic_cast, static_cast and reinterpret_cast.",
32+
"kind":"problem",
33+
"name":"C-style casts and functional notation casts shall not be used",
34+
"precision":"very-high",
35+
"severity":"error",
36+
"short_name":"NoCStyleOrFunctionalCasts",
37+
"tags": [
38+
"scope/single-translation-unit"
39+
]
40+
}
41+
],
42+
"title":"C-style casts and functional notation casts shall not be used"
43+
},
44+
"RULE-8-2-6": {
45+
"properties": {
46+
"enforcement":"decidable",
47+
"obligation":"required"
48+
},
49+
"queries": [
50+
{
51+
"description":"Casting from an integral type, enumerated type, or pointer to void type to a pointer type leads to unspecified behavior and is error prone.",
52+
"kind":"problem",
53+
"name":"An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type",
54+
"precision":"very-high",
55+
"severity":"error",
56+
"short_name":"IntToPointerCastProhibited",
57+
"tags": [
58+
"scope/single-translation-unit"
59+
]
60+
}
61+
],
62+
"title":"An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type"
63+
},
64+
"RULE-8-2-7": {
65+
"properties": {
66+
"enforcement":"decidable",
67+
"obligation":"advisory"
68+
},
69+
"queries": [
70+
{
71+
"description":"Casting between pointer types and integral types makes code behavior harder to understand and may cause pointer tracking tools to become unreliable.",
72+
"kind":"problem",
73+
"name":"A cast should not convert a pointer type to an integral type",
74+
"precision":"very-high",
75+
"severity":"error",
76+
"short_name":"NoPointerToIntegralCast",
77+
"tags": [
78+
"scope/single-translation-unit"
79+
]
80+
}
81+
],
82+
"title":"A cast should not convert a pointer type to an integral type"
83+
},
84+
"RULE-8-2-8": {
85+
"properties": {
86+
"enforcement":"decidable",
87+
"obligation":"required"
88+
},
89+
"queries": [
90+
{
91+
"description":"Casting object pointers to integral types other than std::uintptr_t or std::intptr_t can lead to implementation-defined behavior and potential loss of pointer information.",
92+
"kind":"problem",
93+
"name":"An object pointer type shall not be cast to an integral type other than std::uintptr_t or",
94+
"precision":"very-high",
95+
"severity":"error",
96+
"short_name":"PointerToIntegralCast",
97+
"tags": [
98+
"scope/single-translation-unit"
99+
]
100+
}
101+
],
102+
"title":"An object pointer type shall not be cast to an integral type other than std::uintptr_t or std::intptr_t"
103+
},
104+
"RULE-9-2-1": {
105+
"properties": {
106+
"enforcement":"decidable",
107+
"obligation":"required"
108+
},
109+
"queries": [
110+
{
111+
"description":"Using an explicit type conversion as an expression statement creates a temporary object that is immediately discarded, which can lead to unintended premature resource cleanup.",
112+
"kind":"problem",
113+
"name":"An explicit type conversion shall not be an expression statement",
114+
"precision":"very-high",
115+
"severity":"error",
116+
"short_name":"NoStandaloneTypeCastExpression",
117+
"tags": [
118+
"scope/single-translation-unit"
119+
]
120+
}
121+
],
122+
"title":"An explicit type conversion shall not be an expression statement"
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp