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

Commitc3977f2

Browse files
committed
Migrate M17-0-2 to StandardLibraryNames.
1 parent7c94c8c commitc3977f2

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

‎cpp/autosar/src/rules/M17-0-2/NameOfStandardLibraryMacroOrObjectReused.ql‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616

1717
import cpp
1818
import codingstandards.cpp.autosar
19-
import codingstandards.cpp.Naming
19+
import codingstandards.cpp.StandardLibraryNames
2020

21-
fromLocatablel,strings,stringt
21+
module TargetedCLibrary= CStandardLibrary::C99;
22+
23+
module TargetedCppLibrary= CppStandardLibrary::Cpp14;
24+
25+
fromLocatablel,strings,stringt,stringheader,stringstandard
2226
where
2327
notisExcluded(l, NamingPackage::nameOfStandardLibraryMacroOrObjectReusedQuery())and
2428
l.fromSource()and
@@ -28,8 +32,21 @@ where
2832
s=l.(GlobalOrNamespaceVariable).getName()andt="Object"
2933
)and
3034
(
31-
Naming::Cpp14::hasStandardLibraryMacroName(s)
35+
standard= TargetedCppLibrary::getName()and
36+
(
37+
TargetedCppLibrary::hasMacroName(header,s, _)
38+
or
39+
TargetedCppLibrary::hasObjectName(header, _,s, _, _)
40+
)
3241
or
33-
Naming::Cpp14::hasStandardLibraryObjectName(s)
42+
standard= TargetedCLibrary::getName()and
43+
(
44+
header=max(stringcandidateHeader| TargetedCLibrary::hasMacroName(candidateHeader,s, _))
45+
or
46+
header=
47+
max(stringcandidateHeader| TargetedCLibrary::hasObjectName(candidateHeader, _,s, _, _))
48+
)
3449
)
35-
selectl,t+" reuses the name "+s+" from the standard library."
50+
selectl,
51+
t+" reuses the name "+s+" from the "+standard+" standard library header <"+header+
52+
">."
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| test.cpp:1:1:1:14 | #define NULL 0 | Macro reuses the name NULL from the standard library. |
2-
| test.cpp:3:5:3:10 |tzname | Object reuses the nametzname from the standard library. |
1+
| test.cpp:1:1:1:14 | #define NULL 0 | Macro reuses the name NULL from theC99standard library header <wchar.h>. |
2+
| test.cpp:3:5:3:8 |cout | Object reuses the namecout from theC++14standard library header <iostream>. |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#defineNULL0// NON_COMPLIANT
22

3-
inttzname =0;// NON_COMPLIANT
3+
intcout =0;// NON_COMPLIANT

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp