-
Notifications
You must be signed in to change notification settings - Fork 88
Description
It might be, that we are a little bit to strict with the current call resolving.
We always check the parameter types, also for languages where no function overloading exists.
This will not map function calls, where one of the parameters have an UNKNOWN type.
This is the relevant code part:
cpg/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt
Lines 719 to 731 in fdc642b
| if (call.language !is HasFunctionOverloading) { | |
| // If the function does not allow function overloading, and we have multiple candidate | |
| // symbols, the | |
| // result is "problematic" | |
| if (result.candidateFunctions.size > 1) { | |
| result.success = CallResolutionResult.SuccessKind.PROBLEMATIC | |
| } | |
| } | |
| // Filter functions that match the signature of our call, either directly or with casts; | |
| // those functions are "viable". Take default arguments into account if the language has | |
| // them. | |
| result.signatureResults = |
Theoretically, for the "not HasFunctionOverloading" case, we could finish here with an ==1:
cpg/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/ScopeManager.kt
Lines 723 to 725 in fdc642b
| if (result.candidateFunctions.size > 1) { | |
| result.success = CallResolutionResult.SuccessKind.PROBLEMATIC | |
| } |
Or we only take the shortcut, when one of the types is unknown.
Update: Of course, the number of arguments must match, otherwise something is going wrong.
What do you think?
Example where current call resolving fails:
//#define MY_CONST_INT 1
void foo(int i) {
}
int main() {
foo(MY_CONST_INT);
return 0;
}