From b0849e06bf6e424a398b8e1306b13094aabeb4fd Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 4 May 2008 00:35:11 +0000 Subject: [PATCH] Partial fix for bug 229917. --- .../parser/tests/ast2/AST2TemplateTests.java | 1106 +++++++++-------- .../parser/cpp/semantics/CPPSemantics.java | 10 +- .../parser/cpp/semantics/CPPTemplates.java | 4 +- 3 files changed, 570 insertions(+), 550 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 48b372fac52..3b00dd37ed0 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -82,27 +82,27 @@ public class AST2TemplateTests extends AST2BaseTest { } public void testBasicClassTemplate() throws Exception { - IASTTranslationUnit tu = parse( "template class A{ T t; };", ParserLanguage.CPP ); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("template class A{ T t; };", ParserLanguage.CPP); //$NON-NLS-1$ CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - assertEquals( col.size(), 4 ); + assertEquals(col.size(), 4); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPTemplateScope scope = (ICPPTemplateScope) T.getScope(); IScope s2 = A.getScope(); - assertSame( scope, s2 ); + assertSame(scope, s2); ICPPField t = (ICPPField) col.getName(3).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding(); - assertSame( T, T2 ); + assertSame(T, T2); IType type = t.getType(); - assertSame( type, T ); + assertSame(type, T); - assertNotNull( T ); - assertNotNull( A ); + assertNotNull(T); + assertNotNull(A); } // template < class T > class A { @@ -114,58 +114,58 @@ public class AST2TemplateTests extends AST2BaseTest { // a.t1; a.t2; // } public void testBasicTemplateInstance_1() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - assertEquals( col.size(), 14 ); + assertEquals(col.size(), 14); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPField t1 = (ICPPField) col.getName(3).resolveBinding(); ICPPField t2 = (ICPPField) col.getName(5).resolveBinding(); - assertSame( t1.getType(), T ); - assertSame( ((IPointerType)t2.getType()).getType(), T ); + assertSame(t1.getType(), T); + assertSame(((IPointerType)t2.getType()).getType(), T); ICPPVariable a = (ICPPVariable) col.getName(9).resolveBinding(); ICPPClassType A_int = (ICPPClassType) col.getName(7).resolveBinding(); - assertSame( A_int, a.getType() ); + assertSame(A_int, a.getType()); - assertTrue( A_int instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A_int).getTemplateDefinition(), A ); + assertTrue(A_int instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A_int).getTemplateDefinition(), A); ICPPClassScope A_int_Scope = (ICPPClassScope) A_int.getCompositeScope(); - assertNotSame( A_int_Scope, ((ICompositeType) A).getCompositeScope() ); + assertNotSame(A_int_Scope, ((ICompositeType) A).getCompositeScope()); ICPPField t = (ICPPField) col.getName(11).resolveBinding(); - assertTrue( t instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)t).getSpecializedBinding(), t1 ); - assertSame( t.getScope(), A_int_Scope ); + assertTrue(t instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)t).getSpecializedBinding(), t1); + assertSame(t.getScope(), A_int_Scope); IType type = t.getType(); - assertTrue( type instanceof IBasicType ); - assertEquals( ((IBasicType)type).getType(), IBasicType.t_int ); + assertTrue(type instanceof IBasicType); + assertEquals(((IBasicType)type).getType(), IBasicType.t_int); t = (ICPPField) col.getName(13).resolveBinding(); - assertTrue( t instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)t).getSpecializedBinding(), t2 ); - assertSame( t.getScope(), A_int_Scope ); + assertTrue(t instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)t).getSpecializedBinding(), t2); + assertSame(t.getScope(), A_int_Scope); type = t.getType(); - assertTrue( type instanceof IPointerType ); - assertTrue( ((IPointerType)type).getType() instanceof IBasicType ); - assertEquals( ((IBasicType)((IPointerType)type).getType()).getType(), IBasicType.t_int ); + assertTrue(type instanceof IPointerType); + assertTrue(((IPointerType)type).getType() instanceof IBasicType); + assertEquals(((IBasicType)((IPointerType)type).getType()).getType(), IBasicType.t_int); } // template < class T > class A { - // T f( T *); + // T f(T *); // }; // void g(){ // A a; - // a.f( (int*)0 ); + // a.f((int*)0); // } public void testBasicTemplateInstance_2() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); @@ -174,30 +174,30 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPMethod f = (ICPPMethod) col.getName(3).resolveBinding(); IFunctionType ft = f.getType(); - assertSame( ft.getReturnType(), T ); - assertSame( ((IPointerType)ft.getParameterTypes()[0]).getType(), T ); + assertSame(ft.getReturnType(), T); + assertSame(((IPointerType)ft.getParameterTypes()[0]).getType(), T); ICPPClassType A_int = (ICPPClassType) col.getName(7).resolveBinding(); - assertTrue( A_int instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A_int).getTemplateDefinition(), A ); + assertTrue(A_int instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A_int).getTemplateDefinition(), A); ICPPMethod f_int = (ICPPMethod) col.getName(11).resolveBinding(); - assertTrue( f_int instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)f_int).getSpecializedBinding(), f ); + assertTrue(f_int instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)f_int).getSpecializedBinding(), f); ft = f_int.getType(); - assertTrue( ft.getReturnType() instanceof IBasicType ); - assertTrue( ((IPointerType)ft.getParameterTypes()[0]).getType() instanceof IBasicType ); + assertTrue(ft.getReturnType() instanceof IBasicType); + assertTrue(((IPointerType)ft.getParameterTypes()[0]).getType() instanceof IBasicType); } - // template void f( T ); - // template void f( T ) { + // template void f(T); + // template void f(T) { // T * d; // } // void foo() { - // f( 0 ); + // f(0); // } public void testBasicTemplateFunction() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); @@ -210,46 +210,46 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPFunction f2 = (ICPPFunction) col.getName(5).resolveBinding(); IParameter p2 = (IParameter) col.getName(7).resolveBinding(); - assertSame( T, T2 ); - assertSame( f, f2 ); - assertSame( p1, p2 ); - assertSame( p1.getType(), T ); + assertSame(T, T2); + assertSame(f, f2); + assertSame(p1, p2); + assertSame(p1.getType(), T); ICPPFunction f3 = (ICPPFunction) col.getName(11).resolveBinding(); - assertTrue( f3 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)f3).getTemplateDefinition(), f ); + assertTrue(f3 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)f3).getTemplateDefinition(), f); - assertInstances( col, T, 5 ); + assertInstances(col, T, 5); } // template < class T > class pair { - // template < class U > pair( const pair & ); + // template < class U > pair(const pair &); // }; public void testStackOverflow() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - assertTrue( col.getName(0).resolveBinding() instanceof ICPPTemplateParameter ); + assertTrue(col.getName(0).resolveBinding() instanceof ICPPTemplateParameter); ICPPClassTemplate pair = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter U = (ICPPTemplateParameter) col.getName(2).resolveBinding(); - assertTrue( col.getName(3).resolveBinding() instanceof ICPPFunctionTemplate ); + assertTrue(col.getName(3).resolveBinding() instanceof ICPPFunctionTemplate); ICPPTemplateInstance pi = (ICPPTemplateInstance) col.getName(4).resolveBinding(); ICPPClassTemplate p = (ICPPClassTemplate) col.getName(5).resolveBinding(); ICPPTemplateParameter U2 = (ICPPTemplateParameter) col.getName(6).resolveBinding(); - assertSame( U, U2 ); - assertSame( pair, p ); - assertSame( pi.getTemplateDefinition(), pair ); + assertSame(U, U2); + assertSame(pair, p); + assertSame(pi.getTemplateDefinition(), pair); } // template < class T > class A {}; // template < class T > class A< T* > {}; // template < class T > class A< T** > {}; public void testBasicClassPartialSpecialization() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); @@ -259,34 +259,34 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPClassTemplatePartialSpecialization A3 = (ICPPClassTemplatePartialSpecialization) col.getName(7).resolveBinding(); ICPPTemplateParameter T4 = (ICPPTemplateParameter) col.getName(6).resolveBinding(); - assertSame( A2.getPrimaryClassTemplate(), A1 ); - assertSame( A3.getPrimaryClassTemplate(), A1 ); - assertNotSame( T1, T2 ); - assertNotSame( A1, A2 ); - assertNotSame( A1, A3 ); - assertNotSame( A2, A3 ); - assertSame( T2, T3 ); - assertNotSame( T2, T4 ); + assertSame(A2.getPrimaryClassTemplate(), A1); + assertSame(A3.getPrimaryClassTemplate(), A1); + assertNotSame(T1, T2); + assertNotSame(A1, A2); + assertNotSame(A1, A3); + assertNotSame(A2, A3); + assertSame(T2, T3); + assertNotSame(T2, T4); } // template < class T > class A { typedef int TYPE; }; - // template < class T > A::TYPE foo( T ); - // template < class T > A::TYPE foo( T ); + // template < class T > A::TYPE foo(T); + // template < class T > A::TYPE foo(T); public void testStackOverflow_2() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T0 = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(3).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(12).resolveBinding(); - assertNotSame( T0, T1 ); - assertSame( T1, T2 ); + assertNotSame(T0, T1); + assertSame(T1, T2); ICPPFunctionTemplate foo1 = (ICPPFunctionTemplate) col.getName(9).resolveBinding(); ICPPFunctionTemplate foo2 = (ICPPFunctionTemplate) col.getName(18).resolveBinding(); - assertSame( foo1, foo2 ); + assertSame(foo1, foo2); ITypedef TYPE = (ITypedef) col.getName(2).resolveBinding(); IBinding b0 = col.getName(8).resolveBinding(); @@ -295,7 +295,7 @@ public class AST2TemplateTests extends AST2BaseTest { IBinding b1 = col.getName(17).resolveBinding(); assertSame(TYPE, ((ICPPSpecialization) b1).getSpecializedBinding()); - assertInstances( col, T1, 6 ); + assertInstances(col, T1, 6); } // template < class T > class A { @@ -303,83 +303,83 @@ public class AST2TemplateTests extends AST2BaseTest { // }; // template < class T > void A::f() { } public void testTemplateMemberDef() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPMethod f1 = (ICPPMethod) col.getName(2).resolveBinding(); ICPPMethod f2 = (ICPPMethod) col.getName(8).resolveBinding(); - assertSame( f2, f1 ); + assertSame(f2, f1); } - // template < class T > void f ( T ); + // template < class T > void f (T); // void main() { - // f( 1 ); + // f(1); // } public void testTemplateFunctionImplicitInstantiation() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); IFunction f2 = (IFunction) col.getName(5).resolveBinding(); - assertTrue( f2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)f2).getTemplateDefinition(), f1 ); + assertTrue(f2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f1); } - // template < class T > void f( T ); // #1 - // template < class T > void f( T* ); // #2 - // template < class T > void f( const T* ); // #3 + // template < class T > void f(T); // #1 + // template < class T > void f(T*); // #2 + // template < class T > void f(const T*); // #3 // void main() { // const int *p; - // f( p ); //calls f( const T * ) , 3 is more specialized than 1 or 2 + // f(p); //calls f(const T *) , 3 is more specialized than 1 or 2 // } public void test_14_5_5_2s5_OrderingFunctionTemplates_1() throws Exception{ - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate f2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); ICPPFunctionTemplate f3 = (ICPPFunctionTemplate) col.getName(9).resolveBinding(); - assertNotSame( f1, f2 ); - assertNotSame( f2, f3 ); - assertNotSame( f3, f1 ); + assertNotSame(f1, f2); + assertNotSame(f2, f3); + assertNotSame(f3, f1); IFunction f = (IFunction) col.getName(14).resolveBinding(); - assertTrue( f instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)f).getTemplateDefinition(), f3 ); + assertTrue(f instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)f).getTemplateDefinition(), f3); } - // template < class T > void f( T ); // #1 - // template < class T > void f( T& ); // #2 + // template < class T > void f(T); // #1 + // template < class T > void f(T&); // #2 // void main() { // float x; - // f( x ); //ambiguous 1 or 2 + // f(x); //ambiguous 1 or 2 // } public void test_14_5_5_2s5_OrderingFunctionTemplates_2() throws Exception{ - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate f2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); - assertNotSame( f1, f2 ); + assertNotSame(f1, f2); IProblemBinding f = (IProblemBinding) col.getName(10).resolveBinding(); - assertEquals( f.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP ); + assertEquals(f.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP); } // template < class T, template < class X > class U, T *pT > class A { // }; public void testTemplateParameters() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateTypeParameter T = (ICPPTemplateTypeParameter) col.getName(0).resolveBinding(); ICPPTemplateTemplateParameter U = (ICPPTemplateTemplateParameter) col.getName(2).resolveBinding(); @@ -387,12 +387,12 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPTemplateTypeParameter X = (ICPPTemplateTypeParameter) col.getName(1).resolveBinding(); - ICPPTemplateParameter [] ps = U.getTemplateParameters(); - assertEquals( ps.length, 1 ); - assertSame( ps[0], X ); + ICPPTemplateParameter[] ps = U.getTemplateParameters(); + assertEquals(ps.length, 1); + assertSame(ps[0], X); IPointerType ptype = (IPointerType) pT.getType(); - assertSame( ptype.getType(), T ); + assertSame(ptype.getType(), T); } // template class A { @@ -404,32 +404,32 @@ public class AST2TemplateTests extends AST2BaseTest { // b->a; // } public void testDeferredInstances() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateInstance A_T = (ICPPTemplateInstance) col.getName(2).resolveBinding(); - assertSame( A_T.getTemplateDefinition(), A ); + assertSame(A_T.getTemplateDefinition(), A); ICPPTemplateInstance A_T2 = (ICPPTemplateInstance) col.getName(6).resolveBinding(); - assertSame( A_T, A_T2 ); + assertSame(A_T, A_T2); ICPPVariable a = (ICPPVariable) col.getName(5).resolveBinding(); IPointerType pt = (IPointerType) a.getType(); - assertSame( pt.getType(), A_T ); + assertSame(pt.getType(), A_T); ICPPVariable b = (ICPPVariable) col.getName(13).resolveBinding(); IType bt = b.getType(); - assertTrue( bt instanceof IPointerType ); + assertTrue(bt instanceof IPointerType); ICPPVariable a2 = (ICPPVariable) col.getName(15).resolveBinding(); - assertTrue( a2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)a2).getSpecializedBinding(), a ); + assertTrue(a2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)a2).getSpecializedBinding(), a); IType at = a2.getType(); - assertTrue( at instanceof IPointerType ); + assertTrue(at instanceof IPointerType); - assertSame( ((IPointerType)at).getType(), ((IPointerType)bt).getType() ); + assertSame(((IPointerType)at).getType(), ((IPointerType)bt).getType()); } // template < class T1, class T2, int I > class A {}; //#1 @@ -444,9 +444,9 @@ public class AST2TemplateTests extends AST2BaseTest { // A a4; //uses #5, T is int, T2 is char, I is1 // A a5; //ambiguous, matches #3 & #5. public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{ - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(3).resolveBinding(); ICPPClassTemplate A2 = (ICPPClassTemplate) col.getName(6).resolveBinding(); @@ -454,8 +454,8 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPClassTemplate A4 = (ICPPClassTemplate) col.getName(20).resolveBinding(); ICPPClassTemplate A5 = (ICPPClassTemplate) col.getName(26).resolveBinding(); - assertTrue( A3 instanceof ICPPClassTemplatePartialSpecialization ); - assertSame( ((ICPPClassTemplatePartialSpecialization)A3).getPrimaryClassTemplate(), A1 ); + assertTrue(A3 instanceof ICPPClassTemplatePartialSpecialization); + assertSame(((ICPPClassTemplatePartialSpecialization)A3).getPrimaryClassTemplate(), A1); ICPPTemplateTypeParameter T1 = (ICPPTemplateTypeParameter) col.getName(11).resolveBinding(); ICPPTemplateTypeParameter T2 = (ICPPTemplateTypeParameter) col.getName(12).resolveBinding(); @@ -465,21 +465,21 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPTemplateParameter TR2 = (ICPPTemplateParameter) col.getName(17).resolveBinding(); ICPPTemplateParameter TR3 = (ICPPTemplateParameter) col.getName(18).resolveBinding(); - assertSame( T1, TR1 ); - assertSame( T2, TR2 ); - assertSame( I, TR3 ); + assertSame(T1, TR1); + assertSame(T2, TR2); + assertSame(I, TR3); ICPPTemplateInstance R1 = (ICPPTemplateInstance) col.getName(31).resolveBinding(); ICPPTemplateInstance R2 = (ICPPTemplateInstance) col.getName(34).resolveBinding(); ICPPTemplateInstance R3 = (ICPPTemplateInstance) col.getName(37).resolveBinding(); ICPPTemplateInstance R4 = (ICPPTemplateInstance) col.getName(40).resolveBinding(); IProblemBinding R5 = (IProblemBinding) col.getName(43).resolveBinding(); - assertEquals( R5.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP ); + assertEquals(R5.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP); - assertSame( R1.getTemplateDefinition(), A1 ); - assertSame( R2.getTemplateDefinition(), A2 ); - assertSame( R4.getTemplateDefinition(), A5 ); - assertSame( R3.getTemplateDefinition(), A4 ); + assertSame(R1.getTemplateDefinition(), A1); + assertSame(R2.getTemplateDefinition(), A2); + assertSame(R4.getTemplateDefinition(), A5); + assertSame(R3.getTemplateDefinition(), A4); } // template void f(T); @@ -487,9 +487,9 @@ public class AST2TemplateTests extends AST2BaseTest { // template <> void f(int); //ok // template <> void f(int*); //ok public void test14_7_3_FunctionExplicitSpecialization() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate fT1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate fT2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); @@ -497,36 +497,36 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPSpecialization f1 = (ICPPSpecialization) col.getName(8).resolveBinding(); ICPPSpecialization f2 = (ICPPSpecialization) col.getName(10).resolveBinding(); - assertSame( f1.getSpecializedBinding(), fT1 ); - assertSame( f2.getSpecializedBinding(), fT2 ); + assertSame(f1.getSpecializedBinding(), fT1); + assertSame(f2.getSpecializedBinding(), fT2); } // template void f(T*); // void g(int* p) { f(p); } public void test_14_5_5_1_FunctionTemplates_1() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunction ref = (ICPPFunction) col.getName(6).resolveBinding(); - assertTrue( ref instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)ref).getTemplateDefinition(), f ); + assertTrue(ref instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)ref).getTemplateDefinition(), f); } // template void f(T); // void g(int* p) { f(p); } public void test_14_5_5_1_FunctionTemplates_2() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunction ref = (ICPPFunction) col.getName(6).resolveBinding(); - assertTrue( ref instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)ref).getTemplateDefinition(), f ); + assertTrue(ref instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)ref).getTemplateDefinition(), f); } // template X f(Y); @@ -534,15 +534,15 @@ public class AST2TemplateTests extends AST2BaseTest { // int i = f(5); // Y is int // } public void test_14_8_1s2_FunctionTemplates() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(3).resolveBinding(); ICPPFunction ref1 = (ICPPFunction) col.getName(8).resolveBinding(); - assertTrue( ref1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance) ref1).getTemplateDefinition(), f ); + assertTrue(ref1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance) ref1).getTemplateDefinition(), f); } // template void f(T); @@ -550,14 +550,14 @@ public class AST2TemplateTests extends AST2BaseTest { // f("Annemarie"); // } public void test14_8_3s6_FunctionTemplates() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunction ref = (ICPPFunction) col.getName(5).resolveBinding(); - assertTrue( ref instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)ref).getTemplateDefinition(), f ); + assertTrue(ref instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)ref).getTemplateDefinition(), f); } // template void f(T); // #1 @@ -570,26 +570,26 @@ public class AST2TemplateTests extends AST2BaseTest { // g(ip); //calls #4 // } public void test14_5_5_2s6_FunctionTemplates() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate f2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); - assertNotSame( f1, f2 ); + assertNotSame(f1, f2); ICPPFunctionTemplate g1 = (ICPPFunctionTemplate) col.getName(10).resolveBinding(); ICPPFunctionTemplate g2 = (ICPPFunctionTemplate) col.getName(14).resolveBinding(); - assertNotSame( g1, g2 ); + assertNotSame(g1, g2); ICPPFunction ref1 = (ICPPFunction) col.getName(19).resolveBinding(); ICPPFunction ref2 = (ICPPFunction) col.getName(21).resolveBinding(); - assertTrue( ref1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance) ref1).getTemplateDefinition(), f2 ); + assertTrue(ref1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance) ref1).getTemplateDefinition(), f2); - assertTrue( ref2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance) ref2).getTemplateDefinition(), g2 ); + assertTrue(ref2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance) ref2).getTemplateDefinition(), g2); } // template class X { @@ -597,18 +597,18 @@ public class AST2TemplateTests extends AST2BaseTest { // X* p2; // }; public void test14_6_1s1_LocalNames() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate X = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType x1 = (ICPPClassType) col.getName(2).resolveBinding(); ICPPClassType x2 = (ICPPClassType) col.getName(4).resolveBinding(); - assertTrue( x1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)x1).getTemplateDefinition(), X ); + assertTrue(x1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)x1).getTemplateDefinition(), X); - assertSame( x1, x2 ); + assertSame(x1, x2); } // template T f(T* p){ @@ -618,30 +618,30 @@ public class AST2TemplateTests extends AST2BaseTest { // f(&b); //call f(char**) // } public void test14_8s2_() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(2).resolveBinding(); ICPPFunction f1 = (ICPPFunction) col.getName(8).resolveBinding(); ICPPFunction f2 = (ICPPFunction) col.getName(10).resolveBinding(); - assertNotSame( f1, f2 ); - assertTrue( f1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)f1).getTemplateDefinition(), f ); - assertTrue( f2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)f2).getTemplateDefinition(), f ); + assertNotSame(f1, f2); + assertTrue(f1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)f1).getTemplateDefinition(), f); + assertTrue(f2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f); IType fr1 = f1.getType().getReturnType(); IType fr2 = f2.getType().getReturnType(); - assertTrue( fr1 instanceof IBasicType ); - assertEquals( ((IBasicType)fr1).getType(), IBasicType.t_int ); + assertTrue(fr1 instanceof IBasicType); + assertEquals(((IBasicType)fr1).getType(), IBasicType.t_int); - assertTrue( fr2 instanceof IPointerType ); - assertTrue( ((IPointerType)fr2).getType() instanceof IBasicType ); - assertEquals( ((IBasicType) ((IPointerType)fr2).getType()).getType(), IBasicType.t_char ); + assertTrue(fr2 instanceof IPointerType); + assertTrue(((IPointerType)fr2).getType() instanceof IBasicType); + assertEquals(((IBasicType) ((IPointerType)fr2).getType()).getType(), IBasicType.t_char); } // template void f(T) { } @@ -649,9 +649,9 @@ public class AST2TemplateTests extends AST2BaseTest { // template<> inline void f<>(int) { } //OK: inline // template<> int g<>(int) { } // OK: not inline public void test14_7_3s14() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate g1 = (ICPPFunctionTemplate) col.getName(6).resolveBinding(); @@ -659,13 +659,13 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPSpecialization f2 = (ICPPSpecialization) col.getName(9).resolveBinding(); ICPPSpecialization g2 = (ICPPSpecialization) col.getName(12).resolveBinding(); - assertSame( f2.getSpecializedBinding(), f1 ); - assertSame( g2.getSpecializedBinding(), g1 ); + assertSame(f2.getSpecializedBinding(), f1); + assertSame(g2.getSpecializedBinding(), g1); - assertFalse( ((ICPPFunction)f1).isInline() ); - assertTrue( ((ICPPFunction)g1).isInline() ); - assertTrue( ((ICPPFunction)f2).isInline() ); - assertFalse( ((ICPPFunction)g2).isInline() ); + assertFalse(((ICPPFunction)f1).isInline()); + assertTrue(((ICPPFunction)g1).isInline()); + assertTrue(((ICPPFunction)f2).isInline()); + assertFalse(((ICPPFunction)g2).isInline()); } // template class X { @@ -678,15 +678,15 @@ public class AST2TemplateTests extends AST2BaseTest { // x.a.a.a.a; // } public void test14_7_1s14_InfiniteInstantiation() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate X = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPVariable x = (ICPPVariable) col.getName(9).resolveBinding(); IType t = x.getType(); - assertTrue( t instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance) t).getTemplateDefinition(), X ); + assertTrue(t instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance) t).getTemplateDefinition(), X); ICPPField a = (ICPPField) col.getName(5).resolveBinding(); ICPPField a1 = (ICPPField) col.getName(11).resolveBinding(); @@ -694,14 +694,14 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPField a3 = (ICPPField) col.getName(13).resolveBinding(); ICPPField a4 = (ICPPField) col.getName(14).resolveBinding(); - assertTrue( a1 instanceof ICPPSpecialization ); - assertTrue( a2 instanceof ICPPSpecialization ); - assertTrue( a3 instanceof ICPPSpecialization ); - assertTrue( a4 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)a1).getSpecializedBinding(), a ); - assertSame( ((ICPPSpecialization)a2).getSpecializedBinding(), a ); - assertSame( ((ICPPSpecialization)a3).getSpecializedBinding(), a ); - assertSame( ((ICPPSpecialization)a4).getSpecializedBinding(), a ); + assertTrue(a1 instanceof ICPPSpecialization); + assertTrue(a2 instanceof ICPPSpecialization); + assertTrue(a3 instanceof ICPPSpecialization); + assertTrue(a4 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)a1).getSpecializedBinding(), a); + assertSame(((ICPPSpecialization)a2).getSpecializedBinding(), a); + assertSame(((ICPPSpecialization)a3).getSpecializedBinding(), a); + assertSame(((ICPPSpecialization)a4).getSpecializedBinding(), a); } // template class Y; @@ -710,33 +710,33 @@ public class AST2TemplateTests extends AST2BaseTest { // Y* q; // meaning Y // }; public void test14_6_1s2() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate Y = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPSpecialization Yspec = (ICPPSpecialization) col.getName(2).resolveBinding(); - assertTrue( Yspec instanceof ICPPClassType ); - assertSame( Yspec.getSpecializedBinding(), Y ); + assertTrue(Yspec instanceof ICPPClassType); + assertSame(Yspec.getSpecializedBinding(), Y); ICPPClassType y1 = (ICPPClassType) col.getName(4).resolveBinding(); - assertSame( y1, Yspec ); + assertSame(y1, Yspec); ICPPClassType y2 = (ICPPClassType) col.getName(6).resolveBinding(); - assertTrue( y2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)y2).getTemplateDefinition(), Y ); + assertTrue(y2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)y2).getTemplateDefinition(), Y); } - // template < class T, class U > void f ( T (*) ( T, U ) ); - // int g ( int, char ); + // template < class T, class U > void f (T (*) (T, U)); + // int g (int, char); // void foo () { - // f( g ); + // f(g); // } public void testBug45129() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunction f1 = (ICPPFunction) col.getName(2).resolveBinding(); ICPPFunction g1 = (ICPPFunction) col.getName(9).resolveBinding(); @@ -744,33 +744,33 @@ public class AST2TemplateTests extends AST2BaseTest { IBinding f2 = col.getName(13).resolveBinding(); IBinding g2 = col.getName(14).resolveBinding(); - assertTrue( f2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)f2).getTemplateDefinition(), f1 ); - assertSame( g1, g2 ); + assertTrue(f2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f1); + assertSame(g1, g2); } - // template U f( T ); + // template U f(T); // void g() { - // f( 1 ); + // f(1); // } public void testBug76951_1() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding(); - assertSame( T, T2 ); + assertSame(T, T2); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(4).resolveBinding(); ICPPFunction f2 = (ICPPFunction) col.getName(8).resolveBinding(); - assertTrue( f2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)f2).getTemplateDefinition(), f1 ); + assertTrue(f2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f1); IFunctionType ft = f2.getType(); - assertTrue( ft.getReturnType() instanceof IBasicType ); - assertEquals( ((IBasicType)ft.getReturnType()).getType(), IBasicType.t_int ); + assertTrue(ft.getReturnType() instanceof IBasicType); + assertEquals(((IBasicType)ft.getReturnType()).getType(), IBasicType.t_int); } // template class A { @@ -781,77 +781,77 @@ public class AST2TemplateTests extends AST2BaseTest { // a.u; // } public void testBug76951_2() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPTemplateTypeParameter U = (ICPPTemplateTypeParameter) col.getName(1).resolveBinding(); - assertSame( U.getDefault(), T ); + assertSame(U.getDefault(), T); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(3).resolveBinding(); ICPPField u1 = (ICPPField) col.getName(5).resolveBinding(); - assertSame( u1.getType(), U ); + assertSame(u1.getType(), U); ICPPClassType A1 = (ICPPClassType) col.getName(7).resolveBinding(); - assertTrue( A1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A1).getTemplateDefinition(), A ); + assertTrue(A1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A); ICPPField u2 = (ICPPField) col.getName(11).resolveBinding(); - assertTrue( u2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)u2).getSpecializedBinding(), u1 ); + assertTrue(u2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)u2).getSpecializedBinding(), u1); IType type = u2.getType(); - assertTrue( type instanceof IBasicType ); - assertEquals( ((IBasicType)type).getType(), IBasicType.t_int ); + assertTrue(type instanceof IBasicType); + assertEquals(((IBasicType)type).getType(), IBasicType.t_int); } // template < class T > class A { // A< int > a; // }; - // void f( A p ) { } + // void f(A p) { } public void testInstances() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType A1 = (ICPPClassType) col.getName(2).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(6).resolveBinding(); - assertSame( A1, A2 ); - assertTrue( A1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A1).getTemplateDefinition(), A ); + assertSame(A1, A2); + assertTrue(A1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A); } - // template void f( T ); - // template void f( T ) {} + // template void f(T); + // template void f(T) {} public void testTemplateParameterDeclarations() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(4).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding(); - assertSame( T1, T2 ); + assertSame(T1, T2); - assertInstances( col, T1, 4 ); + assertInstances(col, T1, 4); } // template < class T > class A { - // int f( A * ); + // int f(A *); // A < T > *pA; // }; // void f () { // A< int > *a; - // a->f( a ); + // a->f(a); // a->pA; // }; public void testDeferredInstantiation() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(2).resolveBinding(); @@ -859,27 +859,27 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPClassType A2 = (ICPPClassType) col.getName(5).resolveBinding(); ICPPField pA = (ICPPField) col.getName(8).resolveBinding(); - assertSame( A1, A2 ); - assertTrue( A1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A1).getTemplateDefinition(), A ); + assertSame(A1, A2); + assertTrue(A1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A); ICPPClassType AI = (ICPPClassType) col.getName(10).resolveBinding(); ICPPMethod f2 = (ICPPMethod) col.getName(14).resolveBinding(); ICPPField pA2 = (ICPPField) col.getName(17).resolveBinding(); - assertTrue( f2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)f2).getSpecializedBinding(), f ); - assertTrue( pA2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)pA2).getSpecializedBinding(), pA ); + assertTrue(f2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)f2).getSpecializedBinding(), f); + assertTrue(pA2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)pA2).getSpecializedBinding(), pA); IType paT = pA2.getType(); - assertTrue( paT instanceof IPointerType ); - assertSame( ((IPointerType)paT).getType(), AI ); + assertTrue(paT instanceof IPointerType); + assertSame(((IPointerType)paT).getType(), AI); IParameter p = f2.getParameters()[0]; IType pT = p.getType(); - assertTrue( pT instanceof IPointerType ); - assertSame( ((IPointerType)pT).getType(), AI ); + assertTrue(pT instanceof IPointerType); + assertSame(((IPointerType)pT).getType(), AI); } // template struct A { @@ -895,43 +895,43 @@ public class AST2TemplateTests extends AST2BaseTest { // ac.f<>(1); //template // } public void test14_5_2s2_MemberSpecializations() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPMethod f1 = (ICPPMethod) col.getName(2).resolveBinding(); ICPPMethod f2 = (ICPPMethod) col.getName(5).resolveBinding(); ICPPMethod f1_2 = (ICPPMethod) col.getName(11).resolveBinding(); - assertNotSame( f1, f1_2 ); - assertTrue( f1_2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)f1_2).getSpecializedBinding(), f1 ); + assertNotSame(f1, f1_2); + assertTrue(f1_2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)f1_2).getSpecializedBinding(), f1); ICPPClassType A2 = (ICPPClassType) col.getName(9).resolveBinding(); - assertTrue( A2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A2).getTemplateDefinition(), A ); + assertTrue(A2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A); ICPPMethod f2_2 = (ICPPMethod) col.getName(16).resolveBinding(); - assertTrue( f2_2 instanceof ICPPSpecialization ); + assertTrue(f2_2 instanceof ICPPSpecialization); IBinding speced = ((ICPPSpecialization)f2_2).getSpecializedBinding(); - assertTrue( speced instanceof ICPPFunctionTemplate && speced instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)speced).getSpecializedBinding(), f2 ); + assertTrue(speced instanceof ICPPFunctionTemplate && speced instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)speced).getSpecializedBinding(), f2); ICPPClassType A3 = (ICPPClassType) col.getName(14).resolveBinding(); - assertSame( A2, A3 ); + assertSame(A2, A3); ICPPClassType A4 = (ICPPClassType) col.getName(20).resolveBinding(); - assertSame( A2, A4 ); + assertSame(A2, A4); IFunction r1 = (IFunction) col.getName(24).resolveBinding(); IFunction r2 = (IFunction) col.getName(26).resolveBinding(); IFunction r3 = (IFunction) col.getName(28).resolveBinding(); - assertSame( r1, f1_2 ); - assertTrue( r2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)r2).getTemplateDefinition(), speced ); - assertSame( r3, f2_2 ); + assertSame(r1, f1_2); + assertTrue(r2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)r2).getTemplateDefinition(), speced); + assertSame(r3, f2_2); } // template class A { }; @@ -939,22 +939,22 @@ public class AST2TemplateTests extends AST2BaseTest { // A ac; // A ai; public void testClassSpecializations() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding(); - assertTrue( A2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)A2).getSpecializedBinding(), A1 ); + assertTrue(A2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)A2).getSpecializedBinding(), A1); ICPPClassType r1 = (ICPPClassType) col.getName(4).resolveBinding(); ICPPClassType r2 = (ICPPClassType) col.getName(7).resolveBinding(); - assertTrue( r1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)r1).getTemplateDefinition(), A1 ); - assertSame( r2, A2 ); + assertTrue(r1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)r1).getTemplateDefinition(), A1); + assertSame(r2, A2); } // template struct A { @@ -971,46 +971,46 @@ public class AST2TemplateTests extends AST2BaseTest { // // explicitly specialized class template specialization // void A::f(int) { } public void test14_7_3s5_SpecializationMemberDefinition() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPMethod f1 = (ICPPMethod) col.getName(2).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(5).resolveBinding(); - assertTrue( A2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)A2).getSpecializedBinding(), A1 ); + assertTrue(A2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)A2).getSpecializedBinding(), A1); ICPPMethod f2 = (ICPPMethod) col.getName(7).resolveBinding(); - assertNotSame( f1, f2 ); + assertNotSame(f1, f2); ICPPClassType A3 = (ICPPClassType) col.getName(10).resolveBinding(); - assertSame( A3, A2 ); + assertSame(A3, A2); ICPPMethod f3 = (ICPPMethod) col.getName(14).resolveBinding(); - assertSame( f3, f2 ); + assertSame(f3, f2); ICPPClassType A4 = (ICPPClassType) col.getName(16).resolveBinding(); - assertSame( A4, A2 ); + assertSame(A4, A2); ICPPMethod f4 = (ICPPMethod) col.getName(18).resolveBinding(); - assertSame( f4, f3 ); + assertSame(f4, f3); } // class C{}; // template class A { // template class B { - // T f( T2 ); + // T f(T2); // }; // }; // void g(){ // A::B b; // C c; - // b.f( c ); + // b.f(c); // } public void testNestedSpecializations() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassType C = (ICPPClassType) col.getName(0).resolveBinding(); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(2).resolveBinding(); @@ -1018,27 +1018,27 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPMethod f = (ICPPMethod) col.getName(6).resolveBinding(); ICPPClassType A1 = (ICPPClassType) col.getName(11).resolveBinding(); - assertTrue( A1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A1).getTemplateDefinition(), A ); + assertTrue(A1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A); ICPPClassType B1 = (ICPPClassType) col.getName(13).resolveBinding(); - assertTrue( B1 instanceof ICPPTemplateInstance ); + assertTrue(B1 instanceof ICPPTemplateInstance); ICPPClassType B2 = (ICPPClassType) ((ICPPTemplateInstance)B1).getTemplateDefinition(); - assertTrue( B2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)B2).getSpecializedBinding(), B ); + assertTrue(B2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)B2).getSpecializedBinding(), B); ICPPMethod f1 = (ICPPMethod) col.getName(20).resolveBinding(); - assertTrue( f1 instanceof ICPPSpecialization ); - assertTrue( ((ICPPSpecialization)f1).getSpecializedBinding() instanceof ICPPMethod ); + assertTrue(f1 instanceof ICPPSpecialization); + assertTrue(((ICPPSpecialization)f1).getSpecializedBinding() instanceof ICPPMethod); ICPPMethod f2 = (ICPPMethod) ((ICPPSpecialization)f1).getSpecializedBinding(); - assertTrue( f2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)f2).getSpecializedBinding(), f ); + assertTrue(f2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)f2).getSpecializedBinding(), f); IFunctionType ft = f1.getType(); - assertTrue( ft.getReturnType() instanceof IBasicType ); - assertEquals( ((IBasicType)ft.getReturnType()).getType(), IBasicType.t_int ); + assertTrue(ft.getReturnType() instanceof IBasicType); + assertEquals(((IBasicType)ft.getReturnType()).getType(), IBasicType.t_int); - assertSame( ft.getParameterTypes()[0], C ); + assertSame(ft.getParameterTypes()[0], C); } // namespace N { @@ -1050,19 +1050,19 @@ public class AST2TemplateTests extends AST2BaseTest { // } // A a; public void test14_5_4s7_UsingClassTemplate() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(3).resolveBinding(); ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(9).resolveBinding(); ICPPClassType A3 = (ICPPClassType) col.getName(13).resolveBinding(); - assertTrue( A3 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A3).getTemplateDefinition(), A2 ); + assertTrue(A3 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A2); ICPPClassTemplate A4 = (ICPPClassTemplate) col.getName(14).resolveBinding(); - assertSame( A4, A1 ); + assertSame(A4, A1); } // template class A { @@ -1080,9 +1080,9 @@ public class AST2TemplateTests extends AST2BaseTest { // c.y.x; c.z.x; // } public void testTemplateTemplateParameter() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPField x1 = (ICPPField) col.getName(2).resolveBinding(); @@ -1094,28 +1094,28 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPField z = (ICPPField) col.getName(16).resolveBinding(); ICPPClassType C1 = (ICPPClassType) col.getName(18).resolveBinding(); - assertTrue( C1 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)C1).getTemplateDefinition(), C ); + assertTrue(C1 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)C1).getTemplateDefinition(), C); ICPPField y2 = (ICPPField) col.getName(23).resolveBinding(); - assertTrue( y2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)y2).getSpecializedBinding(), y ); + assertTrue(y2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)y2).getSpecializedBinding(), y); IType t = y2.getType(); - assertTrue( t instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)t).getTemplateDefinition(), A1 ); + assertTrue(t instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)t).getTemplateDefinition(), A1); ICPPField x3 = (ICPPField) col.getName(24).resolveBinding(); - assertTrue( x3 instanceof ICPPSpecialization ); - assertEquals( ((ICPPSpecialization)x3).getSpecializedBinding(), x1 ); + assertTrue(x3 instanceof ICPPSpecialization); + assertEquals(((ICPPSpecialization)x3).getSpecializedBinding(), x1); ICPPField z2 = (ICPPField) col.getName(26).resolveBinding(); - assertTrue( z2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)z2).getSpecializedBinding(), z ); + assertTrue(z2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)z2).getSpecializedBinding(), z); t = z2.getType(); - assertTrue( t instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)t).getTemplateDefinition(), A2 ); + assertTrue(t instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)t).getTemplateDefinition(), A2); ICPPField x4 = (ICPPField) col.getName(27).resolveBinding(); - assertTrue( x4 instanceof ICPPSpecialization ); - assertEquals( ((ICPPSpecialization)x4).getSpecializedBinding(), x2 ); + assertTrue(x4 instanceof ICPPSpecialization); + assertEquals(((ICPPSpecialization)x4).getSpecializedBinding(), x2); } // template class A { @@ -1127,29 +1127,29 @@ public class AST2TemplateTests extends AST2BaseTest { // a.t; // } public void testNestedTypeSpecializations() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ITypedef _T = (ITypedef) col.getName(3).resolveBinding(); - assertSame( _T.getType(), T ); + assertSame(_T.getType(), T); ICPPField t = (ICPPField) col.getName(5).resolveBinding(); - assertSame( t.getType(), _T ); + assertSame(t.getType(), _T); ICPPField t2 = (ICPPField) col.getName(11).resolveBinding(); - assertTrue( t2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)t2).getSpecializedBinding(), t ); + assertTrue(t2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)t2).getSpecializedBinding(), t); IType type = t2.getType(); - assertTrue( type instanceof ITypedef ); - assertTrue( type instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)type).getSpecializedBinding(), _T ); + assertTrue(type instanceof ITypedef); + assertTrue(type instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)type).getSpecializedBinding(), _T); type = ((ITypedef)type).getType(); - assertTrue( type instanceof IBasicType ); - assertEquals( ((IBasicType)type).getType(), IBasicType.t_int ); + assertTrue(type instanceof IBasicType); + assertEquals(((IBasicType)type).getType(), IBasicType.t_int); } // template class A { @@ -1161,31 +1161,31 @@ public class AST2TemplateTests extends AST2BaseTest { // a.b.t; // } public void _testNestedClassTypeSpecializations() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding(); ICPPField t = (ICPPField) col.getName(4).resolveBinding(); - assertSame( t.getType(), T ); + assertSame(t.getType(), T); ICPPField b = (ICPPField) col.getName(6).resolveBinding(); - assertSame( b.getType(), B ); + assertSame(b.getType(), B); ICPPField b2 = (ICPPField) col.getName(12).resolveBinding(); ICPPField t2 = (ICPPField) col.getName(13).resolveBinding(); - assertTrue( b2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)b2).getSpecializedBinding(), b ); + assertTrue(b2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)b2).getSpecializedBinding(), b); IType type = b2.getType(); - assertTrue( type instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)type).getSpecializedBinding(), B ); + assertTrue(type instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)type).getSpecializedBinding(), B); - assertTrue( t2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)t2).getSpecializedBinding(), t ); - assertTrue( t2.getType() instanceof IBasicType ); - assertEquals( ((IBasicType)t2.getType()).getType(), IBasicType.t_int ); + assertTrue(t2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)t2).getSpecializedBinding(), t); + assertTrue(t2.getType() instanceof IBasicType); + assertEquals(((IBasicType)t2.getType()).getType(), IBasicType.t_int); } // template class A { @@ -1200,23 +1200,23 @@ public class AST2TemplateTests extends AST2BaseTest { // A< C > a; a.s; // }; public void testTemplateParameterQualifiedType_1() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateTypeParameter T = (ICPPTemplateTypeParameter) col.getName(0).resolveBinding(); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); IBinding T1 = col.getName(3).resolveBinding(); - assertSame( T1, T ); + assertSame(T1, T); ICPPClassType X = (ICPPClassType) col.getName(4).resolveBinding(); ITypedef _xx = (ITypedef) col.getName(5).resolveBinding(); IBinding _xx2 = col.getName(6).resolveBinding(); - assertSame( _xx, _xx2 ); - assertSame( _xx.getType(), X ); + assertSame(_xx, _xx2); + assertSame(_xx.getType(), X); ICPPField s = (ICPPField) col.getName(7).resolveBinding(); @@ -1224,24 +1224,24 @@ public class AST2TemplateTests extends AST2BaseTest { ITypedef X2 = (ITypedef) col.getName(12).resolveBinding(); ICPPClassType Acb = (ICPPClassType) col.getName(14).resolveBinding(); - assertTrue( Acb instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)Acb).getTemplateDefinition(), A ); + assertTrue(Acb instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)Acb).getTemplateDefinition(), A); ICPPField s2 = (ICPPField) col.getName(21).resolveBinding(); - assertTrue( s2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)s2).getSpecializedBinding(), s ); + assertTrue(s2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)s2).getSpecializedBinding(), s); IType t = s2.getType(); - // assertTrue( t instanceof ITypedef ); - // assertTrue( t instanceof ICPPSpecialization ); - // assertSame( ((ICPPSpecialization)t).getSpecializedBinding(), _xx ); + // assertTrue(t instanceof ITypedef); + // assertTrue(t instanceof ICPPSpecialization); + // assertSame(((ICPPSpecialization)t).getSpecializedBinding(), _xx); t = ((ITypedef)t).getType(); - assertTrue( t instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)t).getSpecializedBinding(), X2 ); + assertTrue(t instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)t).getSpecializedBinding(), X2); t = ((ITypedef)t).getType(); - assertSame( t, B ); + assertSame(t, B); } // template class A { @@ -1252,25 +1252,25 @@ public class AST2TemplateTests extends AST2BaseTest { // U u; // } public void testTemplateScopes() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding(); ICPPTemplateParameter U = (ICPPTemplateParameter) col.getName(7).resolveBinding(); - assertSame( U, T ); + assertSame(U, T); ICPPClassType A3 = (ICPPClassType) col.getName(9).resolveBinding(); - assertTrue( A3 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance) A3).getTemplateDefinition(), A ); - assertSame( A2, A3 ); + assertTrue(A3 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance) A3).getTemplateDefinition(), A); + assertSame(A2, A3); ICPPTemplateParameter U2 = (ICPPTemplateParameter) col.getName(13).resolveBinding(); - assertSame( U, U2 ); - assertSame( T, U ); + assertSame(U, U2); + assertSame(T, U); } // class A { @@ -1278,26 +1278,26 @@ public class AST2TemplateTests extends AST2BaseTest { // }; // template void A::f<>(U){} public void testTemplateScopes_2() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding(); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(1).resolveBinding(); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(2).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(3).resolveBinding(); - assertSame( T, T2 ); + assertSame(T, T2); ICPPTemplateParameter U = (ICPPTemplateParameter) col.getName(5).resolveBinding(); - assertSame( T, U ); + assertSame(T, U); ICPPClassType A2 = (ICPPClassType) col.getName(7).resolveBinding(); - assertSame( A, A2 ); + assertSame(A, A2); ICPPMethod f2 = (ICPPMethod) col.getName(8).resolveBinding(); IBinding U2 = col.getName(10).resolveBinding(); - assertSame( U, U2 ); + assertSame(U, U2); - assertTrue( f2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)f2).getSpecializedBinding(), f1 ); + assertTrue(f2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)f2).getSpecializedBinding(), f1); } // template @@ -1436,58 +1436,58 @@ public class AST2TemplateTests extends AST2BaseTest { // template<> template<> void A::g(int,char); // template<> void A::h(int) { } public void test14_7_3s16() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(2).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(3).resolveBinding(); - assertSame( T, T2 ); + assertSame(T, T2); ICPPTemplateParameter X = (ICPPTemplateParameter) col.getName(5).resolveBinding(); ICPPFunctionTemplate g = (ICPPFunctionTemplate) col.getName(6).resolveBinding(); ICPPTemplateParameter T3 = (ICPPTemplateParameter) col.getName(7).resolveBinding(); - assertSame( T, T3 ); + assertSame(T, T3); ICPPTemplateParameter X2 = (ICPPTemplateParameter) col.getName(9).resolveBinding(); - assertSame( X, X2 ); + assertSame(X, X2); ICPPMethod h = (ICPPMethod) col.getName(11).resolveBinding(); ICPPTemplateParameter T4 = (ICPPTemplateParameter) col.getName(12).resolveBinding(); - assertSame( T, T4 ); + assertSame(T, T4); ICPPClassType A2 = (ICPPClassType) col.getName(15).resolveBinding(); - assertTrue( A2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A2).getTemplateDefinition(), A ); + assertTrue(A2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A); ICPPMethod f2 = (ICPPMethod) col.getName(17).resolveBinding(); - assertTrue( f2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)f2).getSpecializedBinding(), f ); + assertTrue(f2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)f2).getSpecializedBinding(), f); ICPPTemplateParameter TR = (ICPPTemplateParameter) col.getName(19).resolveBinding(); - assertSame( T, TR ); + assertSame(T, TR); ICPPTemplateParameter XR = (ICPPTemplateParameter) col.getName(20).resolveBinding(); - assertSame( X, XR ); + assertSame(X, XR); ICPPClassType A3 = (ICPPClassType) col.getName(22).resolveBinding(); - assertTrue( A3 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A3).getTemplateDefinition(), A ); - assertNotSame( A2, A3 ); + assertTrue(A3 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A); + assertNotSame(A2, A3); ICPPMethod g2 = (ICPPMethod) col.getName(25).resolveBinding(); - assertSame( g2, g ); + assertSame(g2, g); TR = (ICPPTemplateParameter) col.getName(26).resolveBinding(); - assertSame( T, TR ); + assertSame(T, TR); XR = (ICPPTemplateParameter) col.getName(28).resolveBinding(); - assertSame( X, XR ); + assertSame(X, XR); - assertSame( col.getName(32).resolveBinding(), A2 ); - assertSame( col.getName(39).resolveBinding(), A2 ); - assertSame( col.getName(45).resolveBinding(), A2 ); - assertSame( col.getName(52).resolveBinding(), A2 ); + assertSame(col.getName(32).resolveBinding(), A2); + assertSame(col.getName(39).resolveBinding(), A2); + assertSame(col.getName(45).resolveBinding(), A2); + assertSame(col.getName(52).resolveBinding(), A2); ICPPMethod h2 = (ICPPMethod) col.getName(54).resolveBinding(); - assertTrue( h2 instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)h2).getSpecializedBinding(), h ); + assertTrue(h2 instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)h2).getSpecializedBinding(), h); } // namespace N { @@ -1500,56 +1500,56 @@ public class AST2TemplateTests extends AST2BaseTest { // C b; // C is the template parameter, not N::C // } public void test14_6_1s6() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(2).resolveBinding(); ICPPClassTemplate B = (ICPPClassTemplate) col.getName(3).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(4).resolveBinding(); ICPPTemplateParameter TR = (ICPPTemplateParameter) col.getName(5).resolveBinding(); - assertSame( T, TR ); + assertSame(T, TR); ICPPTemplateParameter C = (ICPPTemplateParameter) col.getName(7).resolveBinding(); - assertSame( C, T ); + assertSame(C, T); ICPPClassType B2 = (ICPPClassType) col.getName(10).resolveBinding(); - assertTrue( B2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)B2).getTemplateDefinition(), B ); + assertTrue(B2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)B2).getTemplateDefinition(), B); ICPPTemplateParameter CR = (ICPPTemplateParameter) col.getName(12).resolveBinding(); - assertSame( CR, T ); + assertSame(CR, T); ICPPMethod f2 = (ICPPMethod) col.getName(13).resolveBinding(); - assertSame( f2, f ); + assertSame(f2, f); CR = (ICPPTemplateParameter) col.getName(14).resolveBinding(); - assertSame( CR, T ); + assertSame(CR, T); } // template class Array {}; - // template void sort( Array & ); - // template void sort<>( Array & ); + // template void sort(Array &); + // template void sort<>(Array &); public void testBug90689_ExplicitInstantiation() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate s = (ICPPFunctionTemplate) col.getName(3).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(4).resolveBinding(); - assertTrue( A2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A2).getTemplateDefinition(), A ); + assertTrue(A2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A); ICPPFunction s2 = (ICPPFunction) col.getName(8).resolveBinding(); - assertTrue( s2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)s2).getTemplateDefinition(), s ); + assertTrue(s2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)s2).getTemplateDefinition(), s); ICPPClassType A3 = (ICPPClassType) col.getName(10).resolveBinding(); - assertTrue( A3 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A3).getTemplateDefinition(), A ); - assertNotSame( A2, A3 ); + assertTrue(A3 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A); + assertNotSame(A2, A3); } // template class Array { }; @@ -1557,22 +1557,22 @@ public class AST2TemplateTests extends AST2BaseTest { // template void sort(Array& v) { } // template void sort(Array&); // argument is deduced here public void test14_7_2s2_ExplicitInstantiation() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding(); - assertTrue( A2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A2).getTemplateDefinition(), A1 ); + assertTrue(A2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A1); ICPPFunctionTemplate s1 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); ICPPFunction s2 = (ICPPFunction) col.getName(10).resolveBinding(); - assertTrue( s2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)s2).getTemplateDefinition(), s1 ); + assertTrue(s2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)s2).getTemplateDefinition(), s1); ICPPClassType A3 = (ICPPClassType) col.getName(11).resolveBinding(); - assertSame( A2, A3 ); + assertSame(A2, A3); } // template class A { @@ -1580,48 +1580,48 @@ public class AST2TemplateTests extends AST2BaseTest { // void f() { this; } // }; public void testBug74204() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); IField p = (IField) col.getName(5).resolveBinding(); IASTName f = col.getName(6); IASTFunctionDefinition fdef = (IASTFunctionDefinition) f.getParent().getParent(); IASTExpressionStatement statement = (IASTExpressionStatement) ((IASTCompoundStatement)fdef.getBody()).getStatements()[0]; - IType type = CPPVisitor.getExpressionType( statement.getExpression() ); + IType type = CPPVisitor.getExpressionType(statement.getExpression()); - assertTrue( type.isSameType( p.getType() ) ); + assertTrue(type.isSameType(p.getType())); } - // template void f( T ); - // template void g( T t ){ - // f( t ); + // template void f(T); + // template void g(T t){ + // f(t); // } public void testDeferredFunctionTemplates() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunction f2 = (ICPPFunction) col.getName(8).resolveBinding(); - assertTrue( f2 instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)f2).getTemplateDefinition(), f ); + assertTrue(f2 instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f); } // template < class T > class A {}; // template < class T > class B { - // void init( A * ); + // void init(A *); // }; // template < class T > class C : public B { - // C( A * a ) { - // init( a ); + // C(A * a) { + // init(a); // } // }; public void testRelaxationForTemplateInheritance() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPMethod init = (ICPPMethod) col.getName(4).resolveBinding(); ICPPSpecialization b0 = (ICPPSpecialization) col.getName(19).resolveBinding(); @@ -1640,14 +1640,14 @@ public class AST2TemplateTests extends AST2BaseTest { // class Bar { public: int foo; }; // void f() { // list bar; - // for( list::iterator i = bar.begin(); i != bar.end(); ++i ){ + // for(list::iterator i = bar.begin(); i != bar.end(); ++i){ // i->foo; i[0].foo; // } // } public void testBug91707() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPMethod begin = (ICPPMethod) col.getName(16).resolveBinding(); ICPPMethod end = (ICPPMethod) col.getName(18).resolveBinding(); @@ -1655,15 +1655,15 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPField foo = (ICPPField) col.getName(20).resolveBinding(); IBinding r = col.getName(33).resolveBinding(); - assertTrue( r instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)r).getSpecializedBinding(), begin ); + assertTrue(r instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)r).getSpecializedBinding(), begin); r = col.getName(36).resolveBinding(); - assertTrue( r instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)r).getSpecializedBinding(), end ); + assertTrue(r instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)r).getSpecializedBinding(), end); - assertSame( foo, col.getName(39).resolveBinding() ); - assertSame( foo, col.getName(41).resolveBinding() ); + assertSame(foo, col.getName(39).resolveBinding()); + assertSame(foo, col.getName(41).resolveBinding()); } // class B { int i; }; @@ -1675,9 +1675,9 @@ public class AST2TemplateTests extends AST2BaseTest { // (*t).i; // } public void testBug98961() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassType B = (ICPPClassType) col.getName(0).resolveBinding(); ICPPField i = (ICPPField) col.getName(1).resolveBinding(); @@ -1685,103 +1685,103 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPVariable t = (ICPPVariable) col.getName(12).resolveBinding(); IType type = t.getType(); - assertTrue( type instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)type).getSpecializedBinding(), _T ); - assertSame( ((IPointerType)((ITypedef)type).getType()).getType(), B ); - assertSame( i, col.getName(14).resolveBinding() ); + assertTrue(type instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)type).getSpecializedBinding(), _T); + assertSame(((IPointerType)((ITypedef)type).getType()).getType(), B); + assertSame(i, col.getName(14).resolveBinding()); } // class A { - // template void f( T ) { + // template void f(T) { // begin(); // } // void begin(); // }; public void testBug98784() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); - assertSame( col.getName(5).resolveBinding(), col.getName(6).resolveBinding() ); + assertSame(col.getName(5).resolveBinding(), col.getName(6).resolveBinding()); } // template class A { - // A( T t ); + // A(T t); // }; - // void f( A a ); + // void f(A a); // void m(){ - // f( A(1) ); + // f(A(1)); // } public void testBug99254() throws Exception{ - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPConstructor ctor = (ICPPConstructor) col.getName(2).resolveBinding(); ICPPFunction f = (ICPPFunction) col.getName(5).resolveBinding(); ICPPSpecialization spec = (ICPPSpecialization) col.getName(11).resolveBinding(); - assertSame( spec.getSpecializedBinding(), ctor ); + assertSame(spec.getSpecializedBinding(), ctor); - assertSame( f, col.getName(10).resolveBinding() ); + assertSame(f, col.getName(10).resolveBinding()); } // namespace core { // template class A { - // A( T x, T y ); + // A(T x, T y); // }; // } // class B { - // int add(const core::A &rect ); + // int add(const core::A &rect); // }; - // void f( B* b ){ - // b->add( core::A(10, 2) ); + // void f(B* b){ + // b->add(core::A(10, 2)); // } public void testBug99254_2() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPConstructor ctor = (ICPPConstructor) col.getName(3).resolveBinding(); ICPPMethod add = (ICPPMethod) col.getName(9).resolveBinding(); ICPPSpecialization spec = (ICPPSpecialization) col.getName(20).resolveBinding(); - assertSame( spec.getSpecializedBinding(), ctor ); + assertSame(spec.getSpecializedBinding(), ctor); - assertSame( add, col.getName(19).resolveBinding() ); + assertSame(add, col.getName(19).resolveBinding()); } - // template class A { A( T ); }; + // template class A { A(T); }; // typedef signed int s32; // class B { - // int add(const A &rect ); + // int add(const A &rect); // }; - // void f( B* b ){ - // b->add( A(10) ); + // void f(B* b){ + // b->add(A(10)); // } public void testBug99254_3() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPConstructor ctor = (ICPPConstructor) col.getName(2).resolveBinding(); ICPPMethod add = (ICPPMethod) col.getName(7).resolveBinding(); ICPPSpecialization spec = (ICPPSpecialization) col.getName(17).resolveBinding(); - assertSame( spec.getSpecializedBinding(), ctor ); + assertSame(spec.getSpecializedBinding(), ctor); - assertSame( add, col.getName(16).resolveBinding() ); + assertSame(add, col.getName(16).resolveBinding()); } public void testBug98666() throws Exception { - IASTTranslationUnit tu = parse( "A::template B b;", ParserLanguage.CPP ); //$NON-NLS-1$ + IASTTranslationUnit tu = parse("A::template B b;", ParserLanguage.CPP); //$NON-NLS-1$ CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0); - IASTName [] ns = qn.getNames(); - assertTrue( ns[1] instanceof ICPPASTTemplateId ); - assertEquals( ((ICPPASTTemplateId)ns[1]).toString(), "B" ); //$NON-NLS-1$ + IASTName[] ns = qn.getNames(); + assertTrue(ns[1] instanceof ICPPASTTemplateId); + assertEquals(((ICPPASTTemplateId)ns[1]).toString(), "B"); //$NON-NLS-1$ } // template struct A{ @@ -1793,26 +1793,26 @@ public class AST2TemplateTests extends AST2BaseTest { // struct A::C::B{}; // A::C::B ab; public void testBug90678() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(3).resolveBinding(); ICPPClassTemplate B = (ICPPClassTemplate) col.getName(4).resolveBinding(); - assertSame( T, col.getName(5).resolveBinding() ); - assertSame( T2, col.getName(6).resolveBinding() ); - assertSame( T, col.getName(10).resolveBinding() ); - assertSame( T2, col.getName(14).resolveBinding() ); + assertSame(T, col.getName(5).resolveBinding()); + assertSame(T2, col.getName(6).resolveBinding()); + assertSame(T, col.getName(10).resolveBinding()); + assertSame(T2, col.getName(14).resolveBinding()); ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) col.getName(12).resolveBinding(); - assertSame( spec.getPrimaryClassTemplate(), B ); + assertSame(spec.getPrimaryClassTemplate(), B); ICPPClassType BI = (ICPPClassType) col.getName(19).resolveBinding(); - assertTrue( BI instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)BI).getSpecializedBinding(), spec ); + assertTrue(BI instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)BI).getSpecializedBinding(), spec); } // template int f(T); // #1 @@ -1821,27 +1821,27 @@ public class AST2TemplateTests extends AST2BaseTest { // int l = f<>(1); // uses #1 public void testBug95208() throws Exception { String content= getAboveComment(); - IASTTranslationUnit tu = parse(content, ParserLanguage.CPP ); + IASTTranslationUnit tu = parse(content, ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunction f2 = (ICPPFunction) col.getName(4).resolveBinding(); - assertSame( f2, col.getName(7).resolveBinding() ); + assertSame(f2, col.getName(7).resolveBinding()); IBinding b = col.getName(9).resolveBinding(); // resolve the binding of the ICPPASTTemplateId first - assertTrue( b instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)b).getSpecializedBinding(), f1 ); - assertSame( f1, col.getName(10).resolveBinding() ); + assertTrue(b instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)b).getSpecializedBinding(), f1); + assertSame(f1, col.getName(10).resolveBinding()); - tu = parse(content,ParserLanguage.CPP ); + tu = parse(content,ParserLanguage.CPP); col = new CPPNameCollector(); tu.accept(col); f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); - assertSame( f1, col.getName(10).resolveBinding() ); + assertSame(f1, col.getName(10).resolveBinding()); } // template class A {}; @@ -1850,17 +1850,17 @@ public class AST2TemplateTests extends AST2BaseTest { // A broken; // }; public void testBug103578() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(2).resolveBinding(); IVariable local = (IVariable) col.getName(4).resolveBinding(); ICPPClassType a = (ICPPClassType) col.getName(5).resolveBinding(); - assertTrue( a instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)a).getTemplateDefinition(), A ); - assertSame( local, col.getName(7).resolveBinding() ); + assertTrue(a instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)a).getTemplateDefinition(), A); + assertSame(local, col.getName(7).resolveBinding()); } // template class A : public T {}; @@ -1870,19 +1870,19 @@ public class AST2TemplateTests extends AST2BaseTest { // a.base; // } public void testBug103715() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPField base = (ICPPField) col.getName(4).resolveBinding(); - assertSame( base, col.getName(11).resolveBinding() ); + assertSame(base, col.getName(11).resolveBinding()); ICPPClassType B = (ICPPClassType) col.getName(3).resolveBinding(); ICPPClassType A = (ICPPClassType) col.getName(6).resolveBinding(); - ICPPBase [] bases = A.getBases(); - assertEquals( bases.length, 1 ); - assertSame( bases[0].getBaseClass(), B ); + ICPPBase[] bases = A.getBases(); + assertEquals(bases.length, 1); + assertSame(bases[0].getBaseClass(), B); } // template < class T > class complex; @@ -1890,25 +1890,25 @@ public class AST2TemplateTests extends AST2BaseTest { // template < class T > class complex{ // }; // template <> class complex< float > { - // void f( float ); + // void f(float); // }; // void complex::f(float){ // } public void testBug74276() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPClassTemplate complex = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType cspec = (ICPPClassType) col.getName(2).resolveBinding(); - assertTrue( cspec instanceof ICPPSpecialization ); - assertSame( ((ICPPSpecialization)cspec).getSpecializedBinding(), complex ); + assertTrue(cspec instanceof ICPPSpecialization); + assertSame(((ICPPSpecialization)cspec).getSpecializedBinding(), complex); - assertSame( complex, col.getName(5).resolveBinding() ); - assertSame( cspec, col.getName(6).resolveBinding() ); + assertSame(complex, col.getName(5).resolveBinding()); + assertSame(cspec, col.getName(6).resolveBinding()); ICPPMethod f = (ICPPMethod) col.getName(8).resolveBinding(); - assertSame( f, col.getName(10).resolveBinding() ); + assertSame(f, col.getName(10).resolveBinding()); } // template< class T1, int q > class C {}; @@ -1921,17 +1921,17 @@ public class AST2TemplateTests extends AST2BaseTest { // myType t; // } public void testBug105852() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ITypedef myType = (ITypedef) col.getName(31).resolveBinding(); ICPPClassType A = (ICPPClassType) myType.getType(); ICPPSpecialization Aspec = (ICPPSpecialization) col.getName(10).resolveBinding(); - assertTrue( A instanceof ICPPTemplateInstance ); - assertSame( ((ICPPTemplateInstance)A).getTemplateDefinition(), Aspec); + assertTrue(A instanceof ICPPTemplateInstance); + assertSame(((ICPPTemplateInstance)A).getTemplateDefinition(), Aspec); } // template< class T > class A : public T {}; @@ -1942,12 +1942,12 @@ public class AST2TemplateTests extends AST2BaseTest { // k.c; // } public void testBug105769() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPVariable c = (ICPPVariable) col.getName(13).resolveBinding(); - assertSame( c, col.getName(4).resolveBinding() ); + assertSame(c, col.getName(4).resolveBinding()); } // template< class T > class C { @@ -1957,9 +1957,9 @@ public class AST2TemplateTests extends AST2BaseTest { // template <> C(wchar_t * c) : blah(c) {} // }; public void testBug162230() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassTemplate C = (ICPPClassTemplate) col.getName(1).resolveBinding(); @@ -1994,11 +1994,11 @@ public class AST2TemplateTests extends AST2BaseTest { // template< class T > class C {}; // typedef struct C CInt; public void testBug169628() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); - assertTrue( col.getName(2).resolveBinding() instanceof ICPPSpecialization ); + assertTrue(col.getName(2).resolveBinding() instanceof ICPPSpecialization); } // template @@ -2038,12 +2038,28 @@ public class AST2TemplateTests extends AST2BaseTest { // int main(map x) { // GetPair(x, 1); // } - public void _testBug229917() throws Exception { + public void testBug229917_1() throws Exception { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); - IBinding b0 = bh.assertNonProblem("_C::value_type GetPair", 2, IBinding.class); ICPPFunction fn = bh.assertNonProblem("GetPair(x", 7, ICPPFunction.class); } + // template + // struct pair { + // typedef _T1 first_type; + // }; + // + // template + // struct map { + // typedef pair<_Key, _Tp> value_type; + // }; + // + // template + // typename _C::value_type GetPair(_C& collection, typename _C::value_type::first_type key); + public void _testBug229917_2() throws Exception { + BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); + IBinding b0 = bh.assertNonProblem("value_type GetPair", 10, IBinding.class); + } + // class A {}; // // template class C { @@ -2124,10 +2140,10 @@ public class AST2TemplateTests extends AST2BaseTest { // // foo -> CPPMethodInstance // } public void testCPPConstructorTemplateSpecialization() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); ICPPASTTemplateId tid= (ICPPASTTemplateId) col.getName(20); IASTName cn= col.getName(21); @@ -2146,10 +2162,10 @@ public class AST2TemplateTests extends AST2BaseTest { // return (lhs < rhs ? rhs : lhs); // } public void testNestedFuncTemplatedDeclarator_bug190241() throws Exception { - IASTTranslationUnit tu = parse( getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); - tu.accept( col ); + tu.accept(col); IASTName name; for (Iterator i = col.nameList.iterator(); i.hasNext();) { @@ -2436,7 +2452,7 @@ public class AST2TemplateTests extends AST2BaseTest { // const int i= 1; // A a1; public void _testNonTypeArgumentIsIDExpression_229942() throws Exception { - IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 95153ff4797..eb5b0169a4e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -649,7 +649,7 @@ public class CPPSemantics { // store using-directives found in this block or namespace for later use. if ((!data.hasResults() || !data.qualified() || data.contentAssist) && scope instanceof ICPPNamespaceScope) { final ICPPNamespaceScope blockScope= (ICPPNamespaceScope) scope; - if (! (blockScope instanceof ICPPBlockScope)) { + if (!(blockScope instanceof ICPPBlockScope)) { data.visited.put(blockScope); // namespace has been searched. if (data.tu != null) { data.tu.handleAdditionalDirectives(blockScope); @@ -776,7 +776,7 @@ public class CPPSemantics { //if the inheritanceChain already contains the parent, then that //is circular inheritance - if (! data.inheritanceChain.containsKey(parent)) { + if (!data.inheritanceChain.containsKey(parent)) { //is this name define in this scope? if (ASTInternal.isFullyCached(parent)) { if (data.astName != null && !data.contentAssist) { @@ -1395,7 +1395,7 @@ public class CPPSemantics { return alias; } else if (declaration instanceof IASTFunctionDefinition) { IASTFunctionDefinition functionDef = (IASTFunctionDefinition) declaration; - if (! ((ICPPASTDeclSpecifier) functionDef.getDeclSpecifier()).isFriend()) { + if (!((ICPPASTDeclSpecifier) functionDef.getDeclSpecifier()).isFriend()) { IASTFunctionDeclarator declarator = functionDef.getDeclarator(); //check the function itself @@ -1562,7 +1562,9 @@ public class CPPSemantics { final boolean indexBased= data.tu != null && data.tu.getIndex() != null; @SuppressWarnings("unchecked") - ObjectSet fns= ObjectSet.EMPTY_SET, templateFns= ObjectSet.EMPTY_SET; + ObjectSet fns= ObjectSet.EMPTY_SET; + @SuppressWarnings("unchecked") + ObjectSet templateFns= ObjectSet.EMPTY_SET; IBinding type = null; IBinding obj = null; IBinding temp = null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 79b72050afe..941adc82ed0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -1223,6 +1223,7 @@ public class CPPTemplates { } return false; } + static public boolean deduceTemplateArgument(ObjectMap map, IType p, IType a) throws DOMException { boolean pIsAReferenceType = (p instanceof ICPPReferenceType); p = getParameterTypeForDeduction(p); @@ -1308,6 +1309,8 @@ public class CPPTemplates { } } return true; + } else if (p instanceof ICPPInternalUnknown) { + return true; // An unknown type may match anything. } else { return p.isSameType(a); } @@ -1330,7 +1333,6 @@ public class CPPTemplates { * for each occurrence of that parameter in the function parameter list * @throws DOMException */ - static private IType[] createArgsForFunctionTemplateOrdering(ICPPFunctionTemplate template) throws DOMException{ ICPPTemplateParameter[] paramList = template.getTemplateParameters(); int size = paramList.length;