Skip to content

Commit 872ea18

Browse files
committed
Declarations5: address review comments
1 parent 654f9fa commit 872ea18

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

c/misra/src/rules/RULE-8-5/ExternalObjectOrFunctionNotDeclaredInOneFile.ql

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ where
3232
kind = "variable"
3333
) and
3434
// Apply an ordering based on location to enforce that (de1, de2) = (de2, de1) and we only report (de1, de2).
35-
(
36-
de.getFile().getAbsolutePath() < otherDeclaration.getFile().getAbsolutePath()
37-
or
38-
de.getFile().getAbsolutePath() = otherDeclaration.getFile().getAbsolutePath() and
39-
de.getLocation().getStartLine() < otherDeclaration.getLocation().getStartLine()
40-
)
35+
de.getFile().getAbsolutePath() < otherDeclaration.getFile().getAbsolutePath()
4136
select de,
4237
"The " + kind + " declaration " + de.getName() +
4338
" is declared in multiple files and has an additional $@.", otherDeclaration, "declaration"

c/misra/src/rules/RULE-8-8/MissingStaticSpecifierObjectRedeclarationC.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ from VariableDeclarationEntry redeclaration, VariableDeclarationEntry de
1818
where
1919
not isExcluded(redeclaration,
2020
Declarations5Package::missingStaticSpecifierObjectRedeclarationCQuery()) and
21+
//following implies de != redeclaration
2122
de.hasSpecifier("static") and
22-
de.getDeclaration().isTopLevel() and
23-
redeclaration.getDeclaration() = de.getDeclaration() and
2423
not redeclaration.hasSpecifier("static") and
25-
de != redeclaration
24+
de.getDeclaration().isTopLevel() and
25+
redeclaration.getDeclaration() = de.getDeclaration()
2626
select redeclaration, "The redeclaration of $@ with internal linkage misses the static specifier.",
2727
de, de.getName()

c/misra/test/rules/RULE-5-2/test.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,25 @@ void f() {
2323
static int
2424
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjy_C; // COMPLIANT length <63
2525
static int
26-
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjy_D; // COMPLIANT length <63
26+
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjy_D; // COMPLIANT length <63
27+
28+
#define iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyA // COMPLIANT
29+
// -
30+
// this
31+
// rule
32+
// does
33+
// not
34+
// consider
35+
// macros
36+
extern int
37+
iltiqzxgfqsgigwfuyntzghvzltueatcxqnqofnnvjyszmcsylyohvqaosjbqyyA; // COMPLIANT
38+
// - this
39+
// rule
40+
// does
41+
// not
42+
// consider
43+
// when
44+
// both
45+
// identifiers
46+
// are
47+
// external

cpp/common/src/codingstandards/cpp/rules/missingstaticspecifierfunctionredeclarationshared/MissingStaticSpecifierFunctionRedeclarationShared.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Provides a library which includes a `problems` predicate for reporting....
2+
* Provides a library which includes a `problems` predicate for reporting missing static specifiers for redeclarations of functions with internal linkage.
33
*/
44

55
import cpp

cpp/common/src/codingstandards/cpp/rules/unnecessaryexposedidentifierdeclarationshared/UnnecessaryExposedIdentifierDeclarationShared.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Provides a library which includes a `problems` predicate for reporting....
2+
* Provides a library which includes a `problems` predicate for reporting unnecessarily exposed identifiers due to too broad of a scope.
33
*/
44

55
import cpp

0 commit comments

Comments
 (0)