Skip to content

Commit

Permalink
A7-1-3: Avoid producing machine specific locations
Browse files Browse the repository at this point in the history
Modify the alert message to only report a link if the target is
within the source root of the database.
  • Loading branch information
lcartey committed Oct 15, 2024
1 parent 3842b4c commit 917bb45
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ Type unwrapIndirection(Type type) {
// DeclStmts that have a TypedefType name use (ie TypeMention) in them
//AND TypeMention.getStartColumn() - DeclStmt.getStartColumn() > len(const)
//AND the declared thing contains one of these "extra" specifiers in the DeclarationEntry Location
from VariableDeclarationEntry e, TypedefType t, TypeMention tm
from
VariableDeclarationEntry e, TypedefType t, TypeMention tm, string message, Element explainer,
string explainerMessage
where
not isExcluded(e, ConstPackage::cvQualifiersNotPlacedOnTheRightHandSideQuery()) and
// Variable type is specified, and has the typedef type as a base type
Expand All @@ -48,7 +50,20 @@ where
// TypeMention occurs after the start of the StmtDecl, with enough space for const/volatile
tm.getLocation().getStartColumn() - s.getLocation().getStartColumn() > 5
)
) and
if exists(t.getFile().getRelativePath())
then
message =
"There is possibly a const or volatile specifier on the left hand side of typedef name $@." and
explainer = t and
explainerMessage = t.getName()
else (
// Type occurs outside source root, so don't link
message =
"There is possibly a const or volatile specifier on the left hand side of typedef name " +
t.getName() + "." and
// explainer not used in this case
explainer = e and
explainerMessage = ""
)
select e,
"There is possibly a const or volatile specifier on the left hand side of typedef name $@.", t,
t.getName()
select e, message, explainer, explainerMessage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| 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 |
| 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 |
| 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 |
| 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 |
| 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 comments on commit 917bb45

Please sign in to comment.