Skip to content
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

A13-3-1: Query reports about function overloads at the same location. #796

Open
rak3-sh opened this issue Nov 13, 2024 · 1 comment · May be fixed by #797
Open

A13-3-1: Query reports about function overloads at the same location. #796

rak3-sh opened this issue Nov 13, 2024 · 1 comment · May be fixed by #797
Labels
false positive/false negative An issue related to observed false positives or false negatives. Standard-AUTOSAR

Comments

@rak3-sh
Copy link
Contributor

rak3-sh commented Nov 13, 2024

Affected rules

  • A13-3-1

Description

This query reports two overloaded functions but at the same location in the code base, thereby causing confusion to the user. It may be good to check the location explicitly to avoid such a case. Please note that the implementation already checks if the overloaded function and the candidate function are not the same and also they are not Function Template Instantiation or Specialization. Still, the query results in the same function to be reported as the candidate as well as the overloaded function.

Example

Not able to minimize the problem

@rak3-sh rak3-sh added the false positive/false negative An issue related to observed false positives or false negatives. label Nov 13, 2024
@rak3-sh
Copy link
Contributor Author

rak3-sh commented Nov 13, 2024

Possible Fix

While we can try and understand in greater detail why CodeQL returns two overloaded functions in the same location but at least for this query, it will be pragmatic to check for the difference in location explicitly in the query and removes such unwanted results in FunctionThatContainsForwardingReferenceAsItsArgumentOverloaded.ql,

from
  Candidate c, Function f, Function overload, Function overloaded, string msg,
  string firstMsgSegment
where
  <... snip ...>
  f = c.getAnOverload() and
  <...snip...> 
  // -- Fix start - check location is different
  f.getLocation() != c.getLocation() 
  // -- Fix end 
  <snip> ...
  overloaded = c and
  overload = f
select overload, "Function" + firstMsgSegment + "overloads a $@.", overloaded, msg

rak3-sh added a commit to rak3-sh/codeql-coding-standards that referenced this issue Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false positive/false negative An issue related to observed false positives or false negatives. Standard-AUTOSAR
Projects
None yet
2 participants