-
Notifications
You must be signed in to change notification settings - Fork 60
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
Comments
Possible FixWhile 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 |
Thanks @rak3-sh! I believe the problem of multiple overloads at the same location can happen when a single file is compiled multiple times in an introspected build under different contexts (for example, different target platforms). Fortunately, we already have a library that helps deduplicate in this case - ...
not f = getAnEquivalentFunction(c) and
... The reason I would suggest against the |
Thanks for your insightful comment! It makes sense and it has been changed appropriately in the PR #797 |
Fix #796 (A13-3-1) - Consider reporting overloaded functions that are at different locations.
Affected rules
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
The text was updated successfully, but these errors were encountered: