mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 16:55:38 +02:00
Bug 415914 - Organize Includes doesn't add include for a constructor
call
This commit is contained in:
parent
ecdbe69720
commit
50c5677fcf
2 changed files with 42 additions and 8 deletions
|
@ -258,6 +258,37 @@ public class BindingClassifierTest extends OneSourceMultipleHeadersTestCase {
|
||||||
assertDeclared("f");
|
assertDeclared("f");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct A {
|
||||||
|
// A(void* p);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// void test() {
|
||||||
|
// A(nullptr);
|
||||||
|
// }
|
||||||
|
public void testConstructorCall() throws Exception {
|
||||||
|
getPreferenceStore().setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
|
||||||
|
// A header declaring the function is not responsible for defining the parameter type since
|
||||||
|
// the implicit conversion from B to A is provided externally to parameter type.
|
||||||
|
assertDefined("A");
|
||||||
|
assertDeclared();
|
||||||
|
}
|
||||||
|
|
||||||
|
// struct A {
|
||||||
|
// A(void* p);
|
||||||
|
// };
|
||||||
|
// typedef A B;
|
||||||
|
|
||||||
|
// void test() {
|
||||||
|
// B(nullptr);
|
||||||
|
// }
|
||||||
|
public void testConstructorCallWithTypedef() throws Exception {
|
||||||
|
getPreferenceStore().setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
|
||||||
|
// A header declaring the function is not responsible for defining the parameter type since
|
||||||
|
// the implicit conversion from B to A is provided externally to parameter type.
|
||||||
|
assertDefined("B");
|
||||||
|
assertDeclared();
|
||||||
|
}
|
||||||
|
|
||||||
// struct A {
|
// struct A {
|
||||||
// A(const B& b);
|
// A(const B& b);
|
||||||
// };
|
// };
|
||||||
|
|
|
@ -1030,12 +1030,15 @@ public class BindingClassifier {
|
||||||
IBinding binding = ((IASTIdExpression) functionNameExpression).getName().resolveBinding();
|
IBinding binding = ((IASTIdExpression) functionNameExpression).getName().resolveBinding();
|
||||||
if (binding instanceof IFunction) {
|
if (binding instanceof IFunction) {
|
||||||
declareFunction((IFunction) binding, functionCallExpression);
|
declareFunction((IFunction) binding, functionCallExpression);
|
||||||
} else if (functionCallExpression instanceof IASTImplicitNameOwner) {
|
} else if (binding instanceof IType) {
|
||||||
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) functionCallExpression).getImplicitNames();
|
defineBinding(binding);
|
||||||
for (IASTName name : implicitNames) {
|
if (functionCallExpression instanceof IASTImplicitNameOwner) {
|
||||||
binding = name.resolveBinding();
|
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) functionCallExpression).getImplicitNames();
|
||||||
if (binding instanceof IFunction) {
|
for (IASTName name : implicitNames) {
|
||||||
declareFunction((IFunction) binding, functionCallExpression);
|
binding = name.resolveBinding();
|
||||||
|
if (binding instanceof IFunction) {
|
||||||
|
declareFunction((IFunction) binding, functionCallExpression);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1123,11 +1126,11 @@ public class BindingClassifier {
|
||||||
} else {
|
} else {
|
||||||
IBinding owner = binding.getOwner();
|
IBinding owner = binding.getOwner();
|
||||||
if (owner instanceof IType) {
|
if (owner instanceof IType) {
|
||||||
defineBinding(owner); // Member access requires definition of the containing type.
|
defineBinding(owner); // Member access requires definition of the containing type.
|
||||||
if (binding instanceof IProblemBinding)
|
if (binding instanceof IProblemBinding)
|
||||||
declareBinding(binding);
|
declareBinding(binding);
|
||||||
} else {
|
} else {
|
||||||
declareBinding(binding); // Declare the binding of this name.
|
declareBinding(binding); // Declare the binding of this name.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue