diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java index 415bd437954..550488335f2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/OverloadsWithinCommonHeaderTests.java @@ -75,7 +75,7 @@ public class OverloadsWithinCommonHeaderTests extends PDOMTestBase { public void testOverloadedInCommonHeader_FileScope() throws CoreException { Pattern[] QuuxPath = makePatternArray(new String[] {"quux"}); - IBinding[] Quux = pdom.findBindings(QuuxPath, false, IndexFilter.getFilter(Linkage.CPP_LINKAGE), new NullProgressMonitor()); + IBinding[] Quux = pdom.findBindings(QuuxPath, true, IndexFilter.getFilter(Linkage.CPP_LINKAGE), new NullProgressMonitor()); assertEquals(5,Quux.length); @@ -112,10 +112,31 @@ public class OverloadsWithinCommonHeaderTests extends PDOMTestBase { // corge::grault(ManyOverloaded*) assertFunctionRefCount(new Class[] {IPointerType.class}, Grault, 12); - // (corge::grault(ManyOverloaded) + // corge::grault(ManyOverloaded) assertFunctionRefCount(new Class[] {ICPPClassType.class}, Grault, 14); } + public void testOverloadedInCommonHeader_NamespaceScope_Collides_With_Filescope() throws CoreException { + Pattern[] ns2Path = makePatternArray(new String[] {"ns2","quux"}); + IBinding[] ns2 = pdom.findBindings(ns2Path, true, IndexFilter.getFilter(Linkage.CPP_LINKAGE), new NullProgressMonitor()); + assertEquals(5,ns2.length); + + // ns2::quux() + assertFunctionRefCount(new Class[0], ns2, 16); + + // ns2::quux(int,char) + assertFunctionRefCount(new Class[] {IBasicType.class}, ns2, 20); + + // ns2::quux(int,char) + assertFunctionRefCount(new Class[] {IBasicType.class, IBasicType.class}, ns2, 24); + + // ns2::quux(ManyOverloaded*) + assertFunctionRefCount(new Class[] {IPointerType.class}, ns2, 28); + + // ns2::quux(ManyOverloaded) + assertFunctionRefCount(new Class[] {ICPPClassType.class}, ns2, 32); + } + protected void assertFunctionRefCount(Class[] args, IBinding[] bindingPool, int refCount) throws CoreException { assertFunctionRefCount(pdom, args, bindingPool, refCount); } diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/common.h b/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/common.h new file mode 100644 index 00000000000..c34887690db --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/common.h @@ -0,0 +1,30 @@ +class ManyOverloaded { +public: + void qux(); + void qux(int i); + void qux(int i, char c); + void qux(ManyOverloaded* ptr); + void qux(ManyOverloaded nptr); +}; + +void quux(); +void quux(int i); +void quux(int i, char c); +void quux(ManyOverloaded* ptr); +void quux(ManyOverloaded nptr); + +namespace corge { + void grault(); + void grault(int i); + void grault(int i, char c); + void grault(ManyOverloaded* ptr); + void grault(ManyOverloaded nptr); +} + +namespace ns2 { + void quux(); + void quux(int i); + void quux(int i, char c); + void quux(ManyOverloaded* ptr); + void quux(ManyOverloaded nptr); +} diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/manyOverloadedClientA.cpp b/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/manyOverloadedClientA.cpp index 93af026128f..05a0aeef150 100644 --- a/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/manyOverloadedClientA.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/manyOverloadedClientA.cpp @@ -1,4 +1,19 @@ -#include "class.h" +#include "common.h" + +namespace corge { + void referencesA_inNS() { + ManyOverloaded m; + ns2::quux(); ns2::quux(); ns2::quux(); ns2::quux(); + ns2::quux(5); ns2::quux(5); ns2::quux(5); ns2::quux(5); ns2::quux(5); + ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); + ns2::quux(m); ns2::quux(m); ns2::quux(m); ns2::quux(m); ns2::quux(m); + ns2::quux(m); ns2::quux(m); ns2::quux(m); + } +} void referencesA() { ManyOverloaded m; @@ -24,4 +39,30 @@ void referencesA() { corge::grault(new ManyOverloaded()); corge::grault(new ManyOverloaded()); corge::grault(m); corge::grault(m); corge::grault(m); corge::grault(m); corge::grault(m); corge::grault(m); corge::grault(m); + + ns2::quux(); ns2::quux(); ns2::quux(); ns2::quux(); + ns2::quux(5); ns2::quux(5); ns2::quux(5); ns2::quux(5); ns2::quux(5); + ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); + ns2::quux(m); ns2::quux(m); ns2::quux(m); ns2::quux(m); ns2::quux(m); + ns2::quux(m); ns2::quux(m); ns2::quux(m); + + m.qux(UNRESOLVED_SYMBOL); // indexer should skip without error + m.qux(4, UNRESOLVED_SYMBOL); // indexer should skip without error + quux(UNRESOLVED_SYMBOL); // indexer should skip without error + quux(6, UNRESOLVED_SYMBOL); // indexer should skip without error + corge::grault(UNRESOLVED_SYMBOL); // indexer should skip without error + corge::grault(6, UNRESOLVED_SYMBOL); // indexer should skip without error + ns2::quux(UNRESOLVED_SYMBOL); // indexer should skip without error + ns2::quux(4, UNRESOLVED_SYMBOL); // indexer should skip without error +} + +namespace corge { + void problemRefsA() { + ns2::quux(UNRESOLVED_SYMBOL); // indexer should skip without error + ns2::quux(4, UNRESOLVED_SYMBOL); // indexer should skip without error + } } diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/manyOverloadedClientB.cpp b/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/manyOverloadedClientB.cpp index f1625430c84..dbe9851126c 100644 --- a/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/manyOverloadedClientB.cpp +++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/overloadsWithinCommonHeader/manyOverloadedClientB.cpp @@ -1,4 +1,19 @@ -#include "class.h" +#include "common.h" + +namespace corge { + void referencesB_inNS() { + ManyOverloaded m; + ns2::quux(); ns2::quux(); ns2::quux(); ns2::quux(); + ns2::quux(5); ns2::quux(5); ns2::quux(5); ns2::quux(5); ns2::quux(5); + ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); + ns2::quux(m); ns2::quux(m); ns2::quux(m); ns2::quux(m); ns2::quux(m); + ns2::quux(m); ns2::quux(m); ns2::quux(m); + } +} void referencesB() { ManyOverloaded m; @@ -24,4 +39,30 @@ void referencesB() { corge::grault(new ManyOverloaded()); corge::grault(new ManyOverloaded()); corge::grault(m); corge::grault(m); corge::grault(m); corge::grault(m); corge::grault(m); corge::grault(m); corge::grault(m); + + ns2::quux(); ns2::quux(); ns2::quux(); ns2::quux(); + ns2::quux(5); ns2::quux(5); ns2::quux(5); ns2::quux(5); ns2::quux(5); + ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); ns2::quux(6,'f'); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); ns2::quux(new ManyOverloaded()); + ns2::quux(new ManyOverloaded()); + ns2::quux(m); ns2::quux(m); ns2::quux(m); ns2::quux(m); ns2::quux(m); + ns2::quux(m); ns2::quux(m); ns2::quux(m); + + m.qux(UNRESOLVED_SYMBOL); // indexer should skip without error + m.qux(4, UNRESOLVED_SYMBOL); // indexer should skip without error + quux(UNRESOLVED_SYMBOL); // indexer should skip without error + quux(6, UNRESOLVED_SYMBOL); // indexer should skip without error + corge::grault(UNRESOLVED_SYMBOL); // indexer should skip without error + corge::grault(6, UNRESOLVED_SYMBOL); // indexer should skip without error + ns2::quux(UNRESOLVED_SYMBOL); // indexer should skip without error + ns2::quux(4, UNRESOLVED_SYMBOL); // indexer should skip without error +} + +namespace corge { + void problemRefsB() { + ns2::quux(UNRESOLVED_SYMBOL); // indexer should skip without error + ns2::quux(4, UNRESOLVED_SYMBOL); // indexer should skip without error + } }