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

Appearance settings

Commit 917bb45

Browse filesBrowse files
committed
A7-1-3: Avoid producing machine specific locations
Modify the alert message to only report a link if the target is within the source root of the database.
1 parent 3842b4c commit 917bb45
Copy full SHA for 917bb45

File tree

Expand file treeCollapse file tree

2 files changed

+20
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-5
lines changed

‎cpp/autosar/src/rules/A7-1-3/CvQualifiersNotPlacedOnTheRightHandSide.ql

Copy file name to clipboardExpand all lines: cpp/autosar/src/rules/A7-1-3/CvQualifiersNotPlacedOnTheRightHandSide.ql
+19-4Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ Type unwrapIndirection(Type type) {
3131
// DeclStmts that have a TypedefType name use (ie TypeMention) in them
3232
//AND TypeMention.getStartColumn() - DeclStmt.getStartColumn() > len(const)
3333
//AND the declared thing contains one of these "extra" specifiers in the DeclarationEntry Location
34-
from VariableDeclarationEntry e, TypedefType t, TypeMention tm
34+
from
35+
VariableDeclarationEntry e, TypedefType t, TypeMention tm, string message, Element explainer,
36+
string explainerMessage
3537
where
3638
not isExcluded(e, ConstPackage::cvQualifiersNotPlacedOnTheRightHandSideQuery()) and
3739
// Variable type is specified, and has the typedef type as a base type
@@ -48,7 +50,20 @@ where
4850
// TypeMention occurs after the start of the StmtDecl, with enough space for const/volatile
4951
tm.getLocation().getStartColumn() - s.getLocation().getStartColumn() > 5
5052
)
53+
) and
54+
if exists(t.getFile().getRelativePath())
55+
then
56+
message =
57+
"There is possibly a const or volatile specifier on the left hand side of typedef name $@." and
58+
explainer = t and
59+
explainerMessage = t.getName()
60+
else (
61+
// Type occurs outside source root, so don't link
62+
message =
63+
"There is possibly a const or volatile specifier on the left hand side of typedef name " +
64+
t.getName() + "." and
65+
// explainer not used in this case
66+
explainer = e and
67+
explainerMessage = ""
5168
)
52-
select e,
53-
"There is possibly a const or volatile specifier on the left hand side of typedef name $@.", t,
54-
t.getName()
69+
select e, message, explainer, explainerMessage
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
| test.cpp:9:16:9:19 | definition of ptr1 | There is possibly a const or volatile specifier on the left hand side of typedef name $@. | test.cpp:1:7:1:12 | intptr | intptr |
22
| test.cpp:10:19:10:22 | definition of ptr2 | There is possibly a const or volatile specifier on the left hand side of typedef name $@. | test.cpp:1:7:1:12 | intptr | intptr |
33
| test.cpp:19:21:19:24 | definition of ptr8 | There is possibly a const or volatile specifier on the left hand side of typedef name $@. | test.cpp:3:7:3:17 | constintptr | constintptr |
4-
| test.cpp:32:23:32:26 | definition of u32d | There is possibly a const or volatile specifier on the left hand side of typedef name $@. | file:///Users/luke/git/codeql-coding-standards/cpp/common/test/includes/standard-library/cstdint.h:9:22:9:29 | uint32_t | uint32_t |
4+
| test.cpp:32:23:32:26 | definition of u32d | There is possibly a const or volatile specifier on the left hand side of typedef name uint32_t. | test.cpp:32:23:32:26 | definition of u32d | |

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.