Skip to content

RULE-5-8: Only consider declarations conflicting if they occur in the same link target #686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,25 @@ class NotUniqueExternalIdentifier extends ExternalIdentifiers {

Declaration getAConflictingDeclaration() {
not result = this and
isConflictingDeclaration(result, getName())
isConflictingDeclaration(result, getName()) and
// We only consider a declaration to be conflicting if it shares a link target with the external
// identifier. This avoids reporting false positives where multiple binaries or libraries are
// built in the same CodeQL database, but are not intended to be linked together.
exists(LinkTarget lt |
// External declaration can only be a function or global variable
lt = this.(Function).getALinkTarget() or
lt = this.(GlobalVariable).getALinkTarget()
|
lt = result.(Function).getALinkTarget()
or
lt = result.(GlobalVariable).getALinkTarget()
or
exists(Class c | c.getAMember() = result and c.getALinkTarget() = lt)
or
result.(LocalVariable).getFunction().getALinkTarget() = lt
or
result.(Class).getALinkTarget() = lt
)
}
}

Expand Down
2 changes: 2 additions & 0 deletions change_notes/2024-09-16-rule-5-8-consider-linkage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `RULE-5-8` - `IdentifiersWithExternalLinkageNotUnique.ql`
- Remove false positives where conflicting declarations do not appear in the same link target.
Loading