1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-21 15:23:59 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-11-30 14:45:01 -08:00
parent 0f13c1b8f1
commit 372f3ef066
34 changed files with 498 additions and 536 deletions

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.model.tests; package org.eclipse.cdt.core.model.tests;
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
/** /**
* @author bnicolle * @author bnicolle
*
*/ */
public class IStructureTests extends IntegratedCModelTest { public class IStructureTests extends IntegratedCModelTest {
/** /**
@ -56,29 +55,29 @@ public class IStructureTests extends IntegratedCModelTest {
* containing all its public members named "test*" * containing all its public members named "test*"
*/ */
public static Test suite() { public static Test suite() {
TestSuite suite= new TestSuite( IStructureTests.class.getName() ); TestSuite suite= new TestSuite(IStructureTests.class.getName());
// TODO check C-only behaviour using C_NATURE vs CC_NATURE // TODO check C-only behaviour using C_NATURE vs CC_NATURE
// Interface tests: // Interface tests:
suite.addTest( new IStructureTests("testGetChildrenOfTypeStruct")); suite.addTest(new IStructureTests("testGetChildrenOfTypeStruct"));
suite.addTest( new IStructureTests("testGetChildrenOfTypeClass")); // C++ only suite.addTest(new IStructureTests("testGetChildrenOfTypeClass")); // C++ only
suite.addTest( new IStructureTests("testGetFields")); suite.addTest(new IStructureTests("testGetFields"));
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetFieldsHack")); //Bug# 38985: solved. suite.addTest(new IStructureTests("testGetFieldsHack"));
suite.addTest( new IStructureTests("testGetField")); suite.addTest(new IStructureTests("testGetField"));
suite.addTest( new IStructureTests("testGetMethods")); // C++ only suite.addTest(new IStructureTests("testGetMethods")); // C++ only
//Bug# 38985: solved. suite.addTest( new IStructureTests("testGetMethodsHack")); // C++ only //Bug# 38985: solved. suite.addTest(new IStructureTests("testGetMethodsHack")); // C++ only
suite.addTest( new IStructureTests("testGetMethod")); // C++ only suite.addTest(new IStructureTests("testGetMethod")); // C++ only
suite.addTest( new IStructureTests("testIsStruct")); suite.addTest(new IStructureTests("testIsStruct"));
suite.addTest( new IStructureTests("testIsClass")); // C++ only suite.addTest(new IStructureTests("testIsClass")); // C++ only
suite.addTest( new IStructureTests("testIsUnion")); suite.addTest(new IStructureTests("testIsUnion"));
suite.addTest( new IStructureTests("testIsAbstract")); // C++ only suite.addTest(new IStructureTests("testIsAbstract")); // C++ only
suite.addTest( new IStructureTests("testGetBaseTypes")); // C++ only suite.addTest(new IStructureTests("testGetBaseTypes")); // C++ only
suite.addTest( new IStructureTests("testGetAccessControl")); // C++ only suite.addTest(new IStructureTests("testGetAccessControl")); // C++ only
// Language Specification tests: // Language Specification tests:
suite.addTest( new IStructureTests("testAnonymousStructObject")); suite.addTest(new IStructureTests("testAnonymousStructObject"));
suite.addTest( new IStructureTests("testInnerStruct")); suite.addTest(new IStructureTests("testInnerStruct"));
return suite; return suite;
} }
@ -92,9 +91,9 @@ public class IStructureTests extends IntegratedCModelTest {
"testStruct8" "testStruct8"
}; };
assertEquals(myExpectedStructs.length,arrayStructs.size()); assertEquals(myExpectedStructs.length,arrayStructs.size());
for(int i=0; i<myExpectedStructs.length; i++) { for (int i= 0; i < myExpectedStructs.length; i++) {
IStructure myIStruct = (IStructure) arrayStructs.get(i); IStructure myIStruct = (IStructure) arrayStructs.get(i);
assertNotNull( "Failed on "+i, myIStruct); assertNotNull("Failed on " + i, myIStruct);
assertEquals(myExpectedStructs[i], myIStruct.getElementName()); assertEquals(myExpectedStructs[i], myIStruct.getElementName());
} }
} }
@ -103,11 +102,11 @@ public class IStructureTests extends IntegratedCModelTest {
List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS); List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS);
String[] myExpectedClasses = { String[] myExpectedClasses = {
"testClass1", "testClass2NoSemicolon", "testClass3", "testClass4Abstract", "testClass1", "testClass2NoSemicolon", "testClass3", "testClass4Abstract",
"testClass5", "testClass6"}; "testClass5", "testClass6" };
assertEquals(myExpectedClasses.length,arrayClasses.size()); assertEquals(myExpectedClasses.length,arrayClasses.size());
for(int i=0; i<myExpectedClasses.length; i++) { for (int i= 0; i < myExpectedClasses.length; i++) {
IStructure myIStruct = (IStructure) arrayClasses.get(i); IStructure myIStruct = (IStructure) arrayClasses.get(i);
assertNotNull( "Failed on "+i, myIStruct); assertNotNull("Failed on " + i, myIStruct);
assertEquals(myExpectedClasses[i], myIStruct.getElementName()); assertEquals(myExpectedClasses[i], myIStruct.getElementName());
} }
} }
@ -122,9 +121,9 @@ public class IStructureTests extends IntegratedCModelTest {
"m_field4","m_field5","m_field6", "m_field4","m_field5","m_field6",
}; };
assertEquals(myExpectedFields.length, myArrayIField.length); assertEquals(myExpectedFields.length, myArrayIField.length);
for(int i=0; i<myArrayIField.length; i++) { for (int i= 0; i < myArrayIField.length; i++) {
assertNotNull( "Failed on "+i, myArrayIField[i]); assertNotNull("Failed on " + i, myArrayIField[i]);
assertEquals("Failed on "+i, assertEquals("Failed on " + i,
myExpectedFields[i], myArrayIField[i].getElementName()); myExpectedFields[i], myArrayIField[i].getElementName());
} }
} }
@ -140,10 +139,10 @@ public class IStructureTests extends IntegratedCModelTest {
}; };
List myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD); List myArrayIField = myIStruct.getChildrenOfType(ICElement.C_FIELD);
assertEquals(myExpectedFields.length, myArrayIField.size()); assertEquals(myExpectedFields.length, myArrayIField.size());
for(int i=0; i<myArrayIField.size(); i++) { for (int i= 0; i < myArrayIField.size(); i++) {
IField myIField = (IField) myArrayIField.get(i); IField myIField = (IField) myArrayIField.get(i);
assertNotNull( "Failed on "+i, myIField ); assertNotNull("Failed on " + i, myIField);
assertEquals("Failed on "+i, assertEquals("Failed on " + i,
myExpectedFields[i], myIField.getElementName()); myExpectedFields[i], myIField.getElementName());
} }
} }
@ -155,17 +154,17 @@ public class IStructureTests extends IntegratedCModelTest {
"m_field1","m_field2","m_field3", "m_field1","m_field2","m_field3",
"m_field4","m_field5","m_field6", "m_field4","m_field5","m_field6",
}; };
for(int i=0; i<myExpectedFields.length; i++) { for (int i= 0; i < myExpectedFields.length; i++) {
IField myIField = myIStruct.getField( myExpectedFields[i] ); IField myIField = myIStruct.getField(myExpectedFields[i]);
assertNotNull( "Failed on "+i, myIField); assertNotNull("Failed on " + i, myIField);
} }
String[] myUnexpectedFields = { String[] myUnexpectedFields = {
"m_field7","m_field8","m_field9", "m_field7","m_field8","m_field9",
}; };
for(int i=0; i<myUnexpectedFields.length; i++) { for (int i= 0; i < myUnexpectedFields.length; i++) {
IField myIField = myIStruct.getField( myUnexpectedFields[i] ); IField myIField = myIStruct.getField(myUnexpectedFields[i]);
assertNull( "Failed on "+i, myIField); assertNull("Failed on " + i, myIField);
} }
} }
public void testGetMethods() throws CModelException { public void testGetMethods() throws CModelException {
@ -177,9 +176,9 @@ public class IStructureTests extends IntegratedCModelTest {
"method1","method2","testStruct1","~testStruct1" "method1","method2","testStruct1","~testStruct1"
}; };
assertEquals(myExpectedMethods.length, myArrayIMethod.length); assertEquals(myExpectedMethods.length, myArrayIMethod.length);
for(int i=0; i<myArrayIMethod.length; i++) { for (int i= 0; i < myArrayIMethod.length; i++) {
assertNotNull( "Failed on "+i, myArrayIMethod[i]); assertNotNull("Failed on " + i, myArrayIMethod[i]);
assertEquals("Failed on "+i, assertEquals("Failed on " + i,
myExpectedMethods[i], myArrayIMethod[i].getElementName()); myExpectedMethods[i], myArrayIMethod[i].getElementName());
} }
} }
@ -189,15 +188,15 @@ public class IStructureTests extends IntegratedCModelTest {
List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT); List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT);
IStructure myIStruct = (IStructure) myArrayStructs.get(0); IStructure myIStruct = (IStructure) myArrayStructs.get(0);
List myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION); List myArrayIMethod = myIStruct.getChildrenOfType(ICElement.C_METHOD_DECLARATION);
myArrayIMethod.addAll( myIStruct.getChildrenOfType(ICElement.C_METHOD) ); myArrayIMethod.addAll(myIStruct.getChildrenOfType(ICElement.C_METHOD));
String[] myExpectedMethods = { String[] myExpectedMethods = {
"method1","method2","testStruct1","~testStruct1" "method1","method2","testStruct1","~testStruct1"
}; };
assertEquals(myExpectedMethods.length, myArrayIMethod.size()); assertEquals(myExpectedMethods.length, myArrayIMethod.size());
for(int i=0; i<myArrayIMethod.size(); i++) { for (int i= 0; i < myArrayIMethod.size(); i++) {
IMethodDeclaration myIMethod = (IMethodDeclaration) myArrayIMethod.get(i); IMethodDeclaration myIMethod = (IMethodDeclaration) myArrayIMethod.get(i);
assertNotNull( "Failed on "+i, myIMethod); assertNotNull("Failed on " + i, myIMethod);
assertEquals("Failed on "+i, assertEquals("Failed on " + i,
myExpectedMethods[i], myIMethod.getElementName()); myExpectedMethods[i], myIMethod.getElementName());
} }
} }
@ -208,17 +207,17 @@ public class IStructureTests extends IntegratedCModelTest {
String[] myExpectedMethods = { String[] myExpectedMethods = {
"method1","method2","testStruct1","~testStruct1" "method1","method2","testStruct1","~testStruct1"
}; };
for(int i=0; i<myExpectedMethods.length; i++) { for (int i= 0; i < myExpectedMethods.length; i++) {
IMethodDeclaration myIMethod = myIStruct.getMethod( myExpectedMethods[i] ); IMethodDeclaration myIMethod = myIStruct.getMethod(myExpectedMethods[i]);
assertNotNull( "Failed on "+i, myIMethod); assertNotNull("Failed on " + i, myIMethod);
} }
String[] myUnexpectedMethods = { String[] myUnexpectedMethods = {
"method7","method8","method9", "method7","method8","method9",
}; };
for(int i=0; i<myUnexpectedMethods.length; i++) { for (int i= 0; i < myUnexpectedMethods.length; i++) {
IMethodDeclaration myIMethod = myIStruct.getMethod( myUnexpectedMethods[i] ); IMethodDeclaration myIMethod = myIStruct.getMethod(myUnexpectedMethods[i]);
assertNull( "Failed on "+i, myIMethod); assertNull("Failed on " + i, myIMethod);
} }
} }
@ -229,23 +228,22 @@ public class IStructureTests extends IntegratedCModelTest {
try { try {
myElementUnion = tu.getElement("testUnion1"); myElementUnion = tu.getElement("testUnion1");
myElementNonUnion = tu.getElement("testStruct1"); myElementNonUnion = tu.getElement("testStruct1");
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
} }
catch( CModelException c ) assertNotNull(myElementUnion);
{ assertTrue(myElementUnion.getElementType() == ICElement.C_UNION);
assertNotNull("CModelException thrown",c);
}
assertNotNull( myElementUnion );
assertTrue( myElementUnion.getElementType()==ICElement.C_UNION );
IStructure myStructUnion = (IStructure) myElementUnion; IStructure myStructUnion = (IStructure) myElementUnion;
assertNotNull( myStructUnion ); assertNotNull(myStructUnion);
assertTrue( myStructUnion.isUnion() ); assertTrue(myStructUnion.isUnion());
assertNotNull( myElementNonUnion ); assertNotNull(myElementNonUnion);
assertTrue( myElementNonUnion.getElementType()!=ICElement.C_UNION ); assertTrue(myElementNonUnion.getElementType() != ICElement.C_UNION);
IStructure myStructNonUnion = (IStructure) myElementNonUnion; IStructure myStructNonUnion = (IStructure) myElementNonUnion;
assertNotNull( myStructNonUnion ); assertNotNull(myStructNonUnion);
assertFalse( myStructNonUnion.isUnion() ); assertFalse(myStructNonUnion.isUnion());
} }
public void testIsStruct() throws CModelException { public void testIsStruct() throws CModelException {
ITranslationUnit tu = getTU(); ITranslationUnit tu = getTU();
ICElement myElementStruct = null; ICElement myElementStruct = null;
@ -253,22 +251,20 @@ public class IStructureTests extends IntegratedCModelTest {
try { try {
myElementStruct = tu.getElement("testStruct1"); myElementStruct = tu.getElement("testStruct1");
myElementNonStruct = tu.getElement("testClass1"); myElementNonStruct = tu.getElement("testClass1");
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
} }
catch( CModelException c ) assertNotNull(myElementStruct);
{ assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT);
assertNotNull("CModelException thrown",c);
}
assertNotNull( myElementStruct );
assertTrue( myElementStruct.getElementType()==ICElement.C_STRUCT );
IStructure myStructStruct = (IStructure) myElementStruct; IStructure myStructStruct = (IStructure) myElementStruct;
assertNotNull( myStructStruct ); assertNotNull(myStructStruct);
assertTrue( myStructStruct.isStruct() ); assertTrue(myStructStruct.isStruct());
assertNotNull( myElementNonStruct ); assertNotNull(myElementNonStruct);
assertTrue( myElementNonStruct.getElementType()!=ICElement.C_STRUCT ); assertTrue(myElementNonStruct.getElementType() != ICElement.C_STRUCT);
IStructure myStructNonStruct = (IStructure) myElementNonStruct; IStructure myStructNonStruct = (IStructure) myElementNonStruct;
assertNotNull( myStructNonStruct ); assertNotNull(myStructNonStruct);
assertFalse( myStructNonStruct.isStruct() ); assertFalse(myStructNonStruct.isStruct());
} }
public void testIsClass() throws CModelException { public void testIsClass() throws CModelException {
@ -278,22 +274,20 @@ public class IStructureTests extends IntegratedCModelTest {
try { try {
myElementClass = tu.getElement("testClass1"); myElementClass = tu.getElement("testClass1");
myElementNonClass = tu.getElement("testStruct1"); myElementNonClass = tu.getElement("testStruct1");
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
} }
catch( CModelException c ) assertNotNull(myElementClass);
{ assertTrue(myElementClass.getElementType() == ICElement.C_CLASS);
assertNotNull("CModelException thrown",c);
}
assertNotNull( myElementClass );
assertTrue( myElementClass.getElementType()==ICElement.C_CLASS );
IStructure myStructClass = (IStructure) myElementClass; IStructure myStructClass = (IStructure) myElementClass;
assertNotNull( myStructClass ); assertNotNull(myStructClass);
assertTrue( myStructClass.isClass() ); assertTrue(myStructClass.isClass());
assertNotNull( myElementNonClass ); assertNotNull(myElementNonClass);
assertTrue( myElementNonClass.getElementType()!=ICElement.C_CLASS ); assertTrue(myElementNonClass.getElementType() != ICElement.C_CLASS);
IStructure myStructNonClass = (IStructure) myElementNonClass; IStructure myStructNonClass = (IStructure) myElementNonClass;
assertNotNull( myStructNonClass ); assertNotNull(myStructNonClass);
assertFalse( myStructNonClass.isClass() ); assertFalse(myStructNonClass.isClass());
} }
public void testIsAbstract() throws CModelException { public void testIsAbstract() throws CModelException {
@ -303,22 +297,20 @@ public class IStructureTests extends IntegratedCModelTest {
try { try {
myElementAbstract = tu.getElement("testClass4Abstract"); myElementAbstract = tu.getElement("testClass4Abstract");
myElementNonAbstract = tu.getElement("testClass1"); myElementNonAbstract = tu.getElement("testClass1");
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
} }
catch( CModelException c ) assertNotNull(myElementAbstract);
{ assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS);
assertNotNull("CModelException thrown",c);
}
assertNotNull( myElementAbstract );
assertTrue( myElementAbstract.getElementType()==ICElement.C_CLASS );
IStructure myStructAbstract = (IStructure) myElementAbstract; IStructure myStructAbstract = (IStructure) myElementAbstract;
assertNotNull( myStructAbstract ); assertNotNull(myStructAbstract);
assertTrue( myStructAbstract.isAbstract() ); assertTrue(myStructAbstract.isAbstract());
assertNotNull( myElementNonAbstract ); assertNotNull(myElementNonAbstract);
assertTrue( myElementNonAbstract.getElementType() == ICElement.C_CLASS ); assertTrue(myElementNonAbstract.getElementType() == ICElement.C_CLASS);
IStructure myStructNonAbstract = (IStructure) myElementNonAbstract; IStructure myStructNonAbstract = (IStructure) myElementNonAbstract;
assertNotNull( myStructNonAbstract ); assertNotNull(myStructNonAbstract);
assertFalse( myStructNonAbstract.isAbstract() ); assertFalse(myStructNonAbstract.isAbstract());
} }
// IInheritance // IInheritance
@ -328,23 +320,21 @@ public class IStructureTests extends IntegratedCModelTest {
String[] myBaseTypes = null; String[] myBaseTypes = null;
try { try {
myElementDerived = tu.getElement("testClass5"); // throws myElementDerived = tu.getElement("testClass5"); // throws
assertNotNull( myElementDerived ); assertNotNull(myElementDerived);
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS ); assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
IStructure myStructDerived = (IStructure) myElementDerived; IStructure myStructDerived = (IStructure) myElementDerived;
assertNotNull( myStructDerived ); assertNotNull(myStructDerived);
myBaseTypes = myStructDerived.getSuperClassesNames(); myBaseTypes = myStructDerived.getSuperClassesNames();
} } catch (CModelException e) {
catch( CModelException c ) assertNotNull("CModelException thrown", e);
{
assertNotNull("CModelException thrown",c);
} }
String[] myExpectedBaseTypes = { String[] myExpectedBaseTypes = {
"testClass1","testClass3","testClass4Abstract" "testClass1", "testClass3","testClass4Abstract"
}; };
assertEquals( myExpectedBaseTypes.length, myBaseTypes.length ); assertEquals(myExpectedBaseTypes.length, myBaseTypes.length);
for(int i=0; i<myBaseTypes.length; i++) { for (int i= 0; i < myBaseTypes.length; i++) {
assertEquals( "Failed on "+i, myExpectedBaseTypes[i], myBaseTypes[i] ); assertEquals("Failed on " + i, myExpectedBaseTypes[i], myBaseTypes[i]);
} }
} }
@ -355,10 +345,10 @@ public class IStructureTests extends IntegratedCModelTest {
String[] myBaseTypes = null; String[] myBaseTypes = null;
try { try {
myElementDerived = tu.getElement("testClass5"); // throws myElementDerived = tu.getElement("testClass5"); // throws
assertNotNull( myElementDerived ); assertNotNull(myElementDerived);
assertTrue( myElementDerived.getElementType()==ICElement.C_CLASS ); assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS);
IStructure myStructDerived = (IStructure) myElementDerived; IStructure myStructDerived = (IStructure) myElementDerived;
assertNotNull( myStructDerived ); assertNotNull(myStructDerived);
myBaseTypes = myStructDerived.getSuperClassesNames(); myBaseTypes = myStructDerived.getSuperClassesNames();
ASTAccessVisibility[] myExpectedAccessControl = { ASTAccessVisibility[] myExpectedAccessControl = {
@ -367,15 +357,13 @@ public class IStructureTests extends IntegratedCModelTest {
ASTAccessVisibility.PROTECTED, ASTAccessVisibility.PROTECTED,
ASTAccessVisibility.PRIVATE ASTAccessVisibility.PRIVATE
}; };
assertEquals( myExpectedAccessControl.length, myBaseTypes.length ); assertEquals(myExpectedAccessControl.length, myBaseTypes.length);
for(int i=0; i<myBaseTypes.length; i++) { for (int i= 0; i < myBaseTypes.length; i++) {
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]); ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
assertEquals( "Failed on "+i, myExpectedAccessControl[i], myAccessControl ); assertEquals("Failed on " + i, myExpectedAccessControl[i], myAccessControl);
} }
} } catch (CModelException e) {
catch( CModelException c ) assertNotNull("CModelException thrown", e);
{
assertNotNull("CModelException thrown",c);
} }
} }
@ -399,13 +387,11 @@ public class IStructureTests extends IntegratedCModelTest {
ICElement myElement = null; ICElement myElement = null;
try { try {
myElement = tu.getElement("testAnonymousStructObject1"); myElement = tu.getElement("testAnonymousStructObject1");
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
} }
catch( CModelException c ) assertNotNull(myElement);
{ assertEquals(ICElement.C_VARIABLE, myElement.getElementType());
assertNotNull("CModelException thrown",c);
}
assertNotNull( myElement );
assertEquals( ICElement.C_VARIABLE, myElement.getElementType() );
} }
public void testInnerStruct() throws CModelException { public void testInnerStruct() throws CModelException {
@ -413,24 +399,22 @@ public class IStructureTests extends IntegratedCModelTest {
ICElement myElement = null; ICElement myElement = null;
try { try {
myElement = tu.getElement("testStruct8"); myElement = tu.getElement("testStruct8");
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
} }
catch( CModelException c ) assertNotNull(myElement);
{
assertNotNull("CModelException thrown",c);
}
assertNotNull( myElement );
IStructure myIStruct = (IStructure) myElement; IStructure myIStruct = (IStructure) myElement;
assertNotNull( myIStruct ); assertNotNull(myIStruct);
String[] myExpectedInnerStructs = { String[] myExpectedInnerStructs = {
"testStruct9Inner", "testStruct10Inner" "testStruct9Inner", "testStruct10Inner"
}; };
List myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT); List myInnerStructs = myIStruct.getChildrenOfType(ICElement.C_STRUCT);
assertEquals( myExpectedInnerStructs.length, myInnerStructs.size() ); assertEquals(myExpectedInnerStructs.length, myInnerStructs.size());
for(int i=0; i<myExpectedInnerStructs.length; i++) { for (int i= 0; i < myExpectedInnerStructs.length; i++) {
IStructure myInnerStruct = (IStructure) myInnerStructs.get(i); IStructure myInnerStruct = (IStructure) myInnerStructs.get(i);
assertNotNull( "Failed on "+i, myInnerStruct ); assertNotNull("Failed on " + i, myInnerStruct);
assertEquals( "Failed on "+i, myExpectedInnerStructs[i], myInnerStruct.getElementName() ); assertEquals("Failed on " + i, myExpectedInnerStructs[i], myInnerStruct.getElementName());
} }
} }
} }

View file

@ -8,10 +8,6 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
/*
* Created on Jun 3, 2003
* by bnicolle
*/
package org.eclipse.cdt.core.model.tests; package org.eclipse.cdt.core.model.tests;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -33,18 +29,13 @@ import org.eclipse.core.runtime.Path;
/** /**
* @author bnicolle * @author bnicolle
*
*/ */
public abstract class IntegratedCModelTest extends BaseTestCase { public abstract class IntegratedCModelTest extends BaseTestCase {
private ICProject fCProject; private ICProject fCProject;
private IFile sourceFile; private IFile sourceFile;
private NullProgressMonitor monitor; private NullProgressMonitor monitor;
private boolean structuralParse = false; private boolean structuralParse = false;
/**
*
*/
public IntegratedCModelTest() { public IntegratedCModelTest() {
super(); super();
} }
@ -113,5 +104,4 @@ public abstract class IntegratedCModelTest extends BaseTestCase {
public void setStructuralParse(boolean structuralParse) { public void setStructuralParse(boolean structuralParse) {
this.structuralParse = structuralParse; this.structuralParse = structuralParse;
} }
} }

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.index.tests; package org.eclipse.cdt.internal.index.tests;
@ -78,7 +78,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public static class ProjectWithDepProj extends IndexCPPTemplateResolutionTest { public static class ProjectWithDepProj extends IndexCPPTemplateResolutionTest {
public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));} public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
public static TestSuite suite() {return suite(ProjectWithDepProj.class);} public static TestSuite suite() {return suite(ProjectWithDepProj.class);}
@Override @Override
public void testDefaultTemplateArgInHeader_264988() throws Exception { public void testDefaultTemplateArgInHeader_264988() throws Exception {
// Not supported across projects (the composite index does not merge // Not supported across projects (the composite index does not merge
@ -86,7 +86,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
} }
} }
public static void addTests(TestSuite suite) { public static void addTests(TestSuite suite) {
suite.addTest(SingleProject.suite()); suite.addTest(SingleProject.suite());
suite.addTest(ProjectWithDepProj.suite()); suite.addTest(ProjectWithDepProj.suite());
} }
@ -253,7 +253,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
IBinding b0= getBindingFromASTName("C1<char> c1", 8); IBinding b0= getBindingFromASTName("C1<char> c1", 8);
IBinding b1= getBindingFromASTName("m1(\"aaa\")", 2); IBinding b1= getBindingFromASTName("m1(\"aaa\")", 2);
IBinding b2= getBindingFromASTName("m2(\"aaa\")", 2); IBinding b2= getBindingFromASTName("m2(\"aaa\")", 2);
assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length); assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length);
assertEquals(1, getIndex().findNames(b2, IIndex.FIND_REFERENCES).length); assertEquals(1, getIndex().findNames(b2, IIndex.FIND_REFERENCES).length);
} }
@ -368,7 +368,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testUnindexedConstructorInstanceImplicitReference() throws Exception { public void testUnindexedConstructorInstanceImplicitReference() throws Exception {
IBinding b0= getBindingFromASTName("m1(\"aaa\")", 2); IBinding b0= getBindingFromASTName("m1(\"aaa\")", 2);
IBinding b1= getBindingFromASTName("m2(\"aaa\")", 2); IBinding b1= getBindingFromASTName("m2(\"aaa\")", 2);
assertEquals(1, getIndex().findNames(b0, IIndex.FIND_REFERENCES).length); assertEquals(1, getIndex().findNames(b0, IIndex.FIND_REFERENCES).length);
assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length); assertEquals(1, getIndex().findNames(b1, IIndex.FIND_REFERENCES).length);
} }
@ -397,29 +397,29 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testCPPConstructorTemplateSpecialization() throws Exception { public void testCPPConstructorTemplateSpecialization() throws Exception {
IBinding b0= getBindingFromASTName("D<int> *var", 1); IBinding b0= getBindingFromASTName("D<int> *var", 1);
IBinding b1= getBindingFromASTName("D<int> *var", 6); IBinding b1= getBindingFromASTName("D<int> *var", 6);
assertInstance(b0, ICPPClassTemplate.class); assertInstance(b0, ICPPClassTemplate.class);
assertInstance(b0, ICPPClassType.class); assertInstance(b0, ICPPClassType.class);
assertInstance(b1, ICPPTemplateInstance.class); assertInstance(b1, ICPPTemplateInstance.class);
assertInstance(b1, ICPPClassType.class); assertInstance(b1, ICPPClassType.class);
// ICPPClassType _ct= (ICPPClassType) b1; // ICPPClassType _ct= (ICPPClassType) b1;
// ICPPConstructor[] _ctcs= _ct.getConstructors(); // ICPPConstructor[] _ctcs= _ct.getConstructors();
// assertEquals(3, _ctcs.length); // two implicit plus the constructor template // assertEquals(3, _ctcs.length); // two implicit plus the constructor template
IBinding b2= getBindingFromASTName("D<int>(", 1); IBinding b2= getBindingFromASTName("D<int>(", 1);
IBinding b3= getBindingFromASTName("D<int>(", 6); IBinding b3= getBindingFromASTName("D<int>(", 6);
assertInstance(b2, ICPPClassTemplate.class); // *D*<int>(5, 6) assertInstance(b2, ICPPClassTemplate.class); // *D*<int>(5, 6)
assertInstance(b2, ICPPClassType.class); // *D*<int>(5, 6) assertInstance(b2, ICPPClassType.class); // *D*<int>(5, 6)
assertInstance(b3, ICPPTemplateInstance.class); // *D<int>*(5, 6) assertInstance(b3, ICPPTemplateInstance.class); // *D<int>*(5, 6)
assertInstance(b3, ICPPConstructor.class); // *D<int>*(5, 6) assertInstance(b3, ICPPConstructor.class); // *D<int>*(5, 6)
// //
// ICPPClassType ct= (ICPPClassType) b2; // ICPPClassType ct= (ICPPClassType) b2;
// ICPPConstructor[] ctcs= ct.getConstructors(); // ICPPConstructor[] ctcs= ct.getConstructors();
// assertEquals(3, ctcs.length); // two implicit plus the constructor template // assertEquals(3, ctcs.length); // two implicit plus the constructor template
IBinding tidSpc= ((ICPPTemplateInstance)b3).getSpecializedBinding(); IBinding tidSpc= ((ICPPTemplateInstance)b3).getSpecializedBinding();
assertInstance(tidSpc, ICPPConstructor.class); assertInstance(tidSpc, ICPPConstructor.class);
assertInstance(tidSpc, ICPPSpecialization.class); assertInstance(tidSpc, ICPPSpecialization.class);
@ -470,22 +470,22 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
IBinding b2= getBindingFromASTName("f.s.foo", 1); IBinding b2= getBindingFromASTName("f.s.foo", 1);
IBinding b3= getBindingFromASTName("s.foo", 1); IBinding b3= getBindingFromASTName("s.foo", 1);
IBinding b4= getBindingFromASTName("foo(*", 3); IBinding b4= getBindingFromASTName("foo(*", 3);
assertInstance(b0, ICPPClassTemplate.class); assertInstance(b0, ICPPClassTemplate.class);
assertInstance(b0, ICPPClassType.class); assertInstance(b0, ICPPClassType.class);
ICPPTemplateParameter[] ps= ((ICPPClassTemplate)b0).getTemplateParameters(); ICPPTemplateParameter[] ps= ((ICPPClassTemplate)b0).getTemplateParameters();
assertEquals(2, ps.length); assertEquals(2, ps.length);
assertInstance(ps[0], ICPPTemplateTypeParameter.class); assertInstance(ps[0], ICPPTemplateTypeParameter.class);
assertInstance(ps[1], ICPPTemplateTemplateParameter.class); assertInstance(ps[1], ICPPTemplateTemplateParameter.class);
assertInstance(b1, ICPPTemplateInstance.class); assertInstance(b1, ICPPTemplateInstance.class);
assertInstance(b1, ICPPClassType.class); assertInstance(b1, ICPPClassType.class);
IType[] type= ((ICPPTemplateInstance)b1).getArguments(); IType[] type= ((ICPPTemplateInstance)b1).getArguments();
assertInstance(type[0], ICPPClassType.class); assertInstance(type[0], ICPPClassType.class);
assertInstance(type[1], ICPPClassTemplate.class); assertInstance(type[1], ICPPClassTemplate.class);
assertInstance(type[1], ICPPClassType.class); assertInstance(type[1], ICPPClassType.class);
ObjectMap om= ((ICPPTemplateInstance)b1).getArgumentMap(); ObjectMap om= ((ICPPTemplateInstance)b1).getArgumentMap();
assertEquals(2, om.size()); assertEquals(2, om.size());
assertInstance(om.keyAt(0), ICPPTemplateTypeParameter.class); assertInstance(om.keyAt(0), ICPPTemplateTypeParameter.class);
@ -493,7 +493,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(om.keyAt(1), ICPPTemplateTemplateParameter.class); assertInstance(om.keyAt(1), ICPPTemplateTemplateParameter.class);
assertInstance(om.getAt(1), ICPPClassType.class); assertInstance(om.getAt(1), ICPPClassType.class);
assertInstance(om.getAt(1), ICPPClassTemplate.class); assertInstance(om.getAt(1), ICPPClassTemplate.class);
IBinding b1_spcd= ((ICPPTemplateInstance)b1).getSpecializedBinding(); IBinding b1_spcd= ((ICPPTemplateInstance)b1).getSpecializedBinding();
assertInstance(b1_spcd, ICPPClassTemplate.class); assertInstance(b1_spcd, ICPPClassTemplate.class);
assertInstance(b1_spcd, ICPPClassType.class); assertInstance(b1_spcd, ICPPClassType.class);
@ -580,20 +580,20 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
IBinding b1= getBindingFromASTName("D<B, T3>", 8); IBinding b1= getBindingFromASTName("D<B, T3>", 8);
IBinding b2= getBindingFromASTName("D<C, T3>", 8); IBinding b2= getBindingFromASTName("D<C, T3>", 8);
IBinding b3= getBindingFromASTName("D<B", 1); IBinding b3= getBindingFromASTName("D<B", 1);
List spBindings= new ArrayList(); List spBindings= new ArrayList();
assertInstance(b0, ICPPSpecialization.class); assertInstance(b0, ICPPSpecialization.class);
assertInstance(b0, ICPPClassTemplate.class); assertInstance(b0, ICPPClassTemplate.class);
spBindings.add(((ICPPSpecialization)b0).getSpecializedBinding()); spBindings.add(((ICPPSpecialization)b0).getSpecializedBinding());
assertInstance(b1, ICPPSpecialization.class); assertInstance(b1, ICPPSpecialization.class);
assertInstance(b1, ICPPClassTemplate.class); assertInstance(b1, ICPPClassTemplate.class);
spBindings.add(((ICPPSpecialization)b1).getSpecializedBinding()); spBindings.add(((ICPPSpecialization)b1).getSpecializedBinding());
assertInstance(b2, ICPPSpecialization.class); assertInstance(b2, ICPPSpecialization.class);
assertInstance(b2, ICPPClassTemplate.class); assertInstance(b2, ICPPClassTemplate.class);
spBindings.add(((ICPPSpecialization)b2).getSpecializedBinding()); spBindings.add(((ICPPSpecialization)b2).getSpecializedBinding());
for(int i=0; i<spBindings.size(); i++) { for(int i=0; i<spBindings.size(); i++) {
for(int j=0; j<spBindings.size(); j++) { for(int j=0; j<spBindings.size(); j++) {
IType ty1= (IType) spBindings.get(i); IType ty1= (IType) spBindings.get(i);
@ -601,7 +601,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertTrue(ty1.isSameType(ty2)); assertTrue(ty1.isSameType(ty2));
} }
} }
assertInstance(b3, ICPPClassTemplate.class); assertInstance(b3, ICPPClassTemplate.class);
ICPPClassTemplate ct= (ICPPClassTemplate) b3; ICPPClassTemplate ct= (ICPPClassTemplate) b3;
assertEquals(3, ct.getPartialSpecializations().length); assertEquals(3, ct.getPartialSpecializations().length);
@ -668,7 +668,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// B foo(B t) { B x= *new B(); return x; } // B foo(B t) { B x= *new B(); return x; }
// void bar(B t, int& x) { x++; } // void bar(B t, int& x) { x++; }
// }; // };
// A<B> ab; // A<B> ab;
public void testClassSpecializationMethods() throws Exception { public void testClassSpecializationMethods() throws Exception {
IBinding b0= getBindingFromASTName("A<B> ab", 4); IBinding b0= getBindingFromASTName("A<B> ab", 4);
@ -685,20 +685,20 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPMethod foo= dms[0].getName().equals("foo") ? dms[0] : dms[1]; ICPPMethod foo= dms[0].getName().equals("foo") ? dms[0] : dms[1];
ICPPMethod bar= dms[0].getName().equals("bar") ? dms[0] : dms[1]; ICPPMethod bar= dms[0].getName().equals("bar") ? dms[0] : dms[1];
assertEquals(foo.getName(), "foo"); assertEquals(foo.getName(), "foo");
assertEquals(bar.getName(), "bar"); assertEquals(bar.getName(), "bar");
assertInstance(foo.getType().getReturnType(), ICPPClassType.class); assertInstance(foo.getType().getReturnType(), ICPPClassType.class);
assertEquals(((ICPPClassType)foo.getType().getReturnType()).getName(), "B"); assertEquals(((ICPPClassType)foo.getType().getReturnType()).getName(), "B");
assertEquals(foo.getType().getParameterTypes().length, 1); assertEquals(foo.getType().getParameterTypes().length, 1);
assertInstance(foo.getType().getParameterTypes()[0], ICPPClassType.class); assertInstance(foo.getType().getParameterTypes()[0], ICPPClassType.class);
assertEquals(((ICPPClassType)foo.getType().getParameterTypes()[0]).getName(), "B"); assertEquals(((ICPPClassType)foo.getType().getParameterTypes()[0]).getName(), "B");
assertInstance(bar.getType().getReturnType(), ICPPBasicType.class); assertInstance(bar.getType().getReturnType(), ICPPBasicType.class);
assertEquals(((ICPPBasicType)bar.getType().getReturnType()).getType(), IBasicType.t_void); assertEquals(((ICPPBasicType)bar.getType().getReturnType()).getType(), IBasicType.t_void);
} }
// template<typename T> class A { // template<typename T> class A {
// public: // public:
// typedef T TD; // typedef T TD;
@ -807,25 +807,25 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b0_ptypes[1], ICPPClassType.class); assertInstance(b0_ptypes[1], ICPPClassType.class);
assertEquals("A", ((ICPPClassType)b0_ptypes[0]).getName()); assertEquals("A", ((ICPPClassType)b0_ptypes[0]).getName());
assertEquals("B", ((ICPPClassType)b0_ptypes[1]).getName()); assertEquals("B", ((ICPPClassType)b0_ptypes[1]).getName());
IParameter[] b0_pms= ((ICPPFunction)b0).getParameters(); IParameter[] b0_pms= ((ICPPFunction)b0).getParameters();
assertEquals(2, b0_pms.length); assertEquals(2, b0_pms.length);
assertInstance(b0_pms[0].getType(), ICPPClassType.class); assertInstance(b0_pms[0].getType(), ICPPClassType.class);
assertInstance(b0_pms[1].getType(), ICPPClassType.class); assertInstance(b0_pms[1].getType(), ICPPClassType.class);
assertEquals("A", ((ICPPClassType)b0_pms[0].getType()).getName()); assertEquals("A", ((ICPPClassType)b0_pms[0].getType()).getName());
assertEquals("B", ((ICPPClassType)b0_pms[1].getType()).getName()); assertEquals("B", ((ICPPClassType)b0_pms[1].getType()).getName());
IBinding b0_spcd= ((ICPPTemplateInstance)b0).getSpecializedBinding(); IBinding b0_spcd= ((ICPPTemplateInstance)b0).getSpecializedBinding();
assertInstance(b0_spcd, ICPPFunction.class); assertInstance(b0_spcd, ICPPFunction.class);
assertInstance(b0_spcd, ICPPTemplateDefinition.class); assertInstance(b0_spcd, ICPPTemplateDefinition.class);
IParameter[] b0_spcd_pms= ((ICPPFunction)b0_spcd).getParameters(); IParameter[] b0_spcd_pms= ((ICPPFunction)b0_spcd).getParameters();
assertEquals(2, b0_spcd_pms.length); assertEquals(2, b0_spcd_pms.length);
assertInstance(b0_spcd_pms[0].getType(), ICPPTemplateTypeParameter.class); assertInstance(b0_spcd_pms[0].getType(), ICPPTemplateTypeParameter.class);
assertInstance(b0_spcd_pms[1].getType(), ICPPTemplateTypeParameter.class); assertInstance(b0_spcd_pms[1].getType(), ICPPTemplateTypeParameter.class);
assertEquals("T1", ((ICPPTemplateTypeParameter)b0_spcd_pms[0].getType()).getName()); assertEquals("T1", ((ICPPTemplateTypeParameter)b0_spcd_pms[0].getType()).getName());
assertEquals("T2", ((ICPPTemplateTypeParameter)b0_spcd_pms[1].getType()).getName()); assertEquals("T2", ((ICPPTemplateTypeParameter)b0_spcd_pms[1].getType()).getName());
ObjectMap b0_am= ((ICPPSpecialization)b0).getArgumentMap(); ObjectMap b0_am= ((ICPPSpecialization)b0).getArgumentMap();
assertEquals(2, b0_am.size()); assertEquals(2, b0_am.size());
assertInstance(b0_am.getAt(0), ICPPClassType.class); assertInstance(b0_am.getAt(0), ICPPClassType.class);
@ -836,7 +836,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertEquals("T2", ((ICPPTemplateTypeParameter)b0_am.keyAt(1)).getName()); assertEquals("T2", ((ICPPTemplateTypeParameter)b0_am.keyAt(1)).getName());
assertEquals("A", ((ICPPClassType)b0_am.getAt(0)).getName()); assertEquals("A", ((ICPPClassType)b0_am.getAt(0)).getName());
assertEquals("B", ((ICPPClassType)b0_am.getAt(1)).getName()); assertEquals("B", ((ICPPClassType)b0_am.getAt(1)).getName());
ICPPFunctionType b0_spcd_type= ((ICPPFunction)b0_spcd).getType(); ICPPFunctionType b0_spcd_type= ((ICPPFunction)b0_spcd).getType();
assertInstance(b0_spcd_type.getReturnType(), ICPPBasicType.class); assertInstance(b0_spcd_type.getReturnType(), ICPPBasicType.class);
IType[] b0_spcd_ptypes= b0_spcd_type.getParameterTypes(); IType[] b0_spcd_ptypes= b0_spcd_type.getParameterTypes();
@ -845,7 +845,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b0_spcd_ptypes[1], ICPPTemplateTypeParameter.class); assertInstance(b0_spcd_ptypes[1], ICPPTemplateTypeParameter.class);
assertEquals("T1", ((ICPPTemplateTypeParameter)b0_spcd_ptypes[0]).getName()); assertEquals("T1", ((ICPPTemplateTypeParameter)b0_spcd_ptypes[0]).getName());
assertEquals("T2", ((ICPPTemplateTypeParameter)b0_spcd_ptypes[1]).getName()); assertEquals("T2", ((ICPPTemplateTypeParameter)b0_spcd_ptypes[1]).getName());
IBinding b1= getBindingFromASTName("foo(c,a)", 3); IBinding b1= getBindingFromASTName("foo(c,a)", 3);
assertInstance(b1, ICPPFunction.class); assertInstance(b1, ICPPFunction.class);
ICPPFunctionType b1type= ((ICPPFunction)b1).getType(); ICPPFunctionType b1type= ((ICPPFunction)b1).getType();
@ -856,20 +856,20 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b1_ptypes[1], ICPPClassType.class); assertInstance(b1_ptypes[1], ICPPClassType.class);
assertEquals("C", ((ICPPClassType)b1_ptypes[0]).getName()); assertEquals("C", ((ICPPClassType)b1_ptypes[0]).getName());
assertEquals("A", ((ICPPClassType)b1_ptypes[1]).getName()); assertEquals("A", ((ICPPClassType)b1_ptypes[1]).getName());
IParameter[] b1_pms= ((ICPPFunction)b1).getParameters(); IParameter[] b1_pms= ((ICPPFunction)b1).getParameters();
assertEquals(2, b1_pms.length); assertEquals(2, b1_pms.length);
assertInstance(b1_pms[0].getType(), ICPPClassType.class); assertInstance(b1_pms[0].getType(), ICPPClassType.class);
assertInstance(b1_pms[1].getType(), ICPPClassType.class); assertInstance(b1_pms[1].getType(), ICPPClassType.class);
assertEquals("C", ((ICPPClassType)b1_pms[0].getType()).getName()); assertEquals("C", ((ICPPClassType)b1_pms[0].getType()).getName());
assertEquals("A", ((ICPPClassType)b1_pms[1].getType()).getName()); assertEquals("A", ((ICPPClassType)b1_pms[1].getType()).getName());
assertInstance(b1, ICPPSpecialization.class); assertInstance(b1, ICPPSpecialization.class);
ICPPSpecialization b1s= (ICPPSpecialization) b1; ICPPSpecialization b1s= (ICPPSpecialization) b1;
IBinding b1_spcd= b1s.getSpecializedBinding(); IBinding b1_spcd= b1s.getSpecializedBinding();
assertInstance(b1_spcd, ICPPFunction.class); assertInstance(b1_spcd, ICPPFunction.class);
assertInstance(b1_spcd, ICPPTemplateDefinition.class); assertInstance(b1_spcd, ICPPTemplateDefinition.class);
ICPPFunctionType b1_spcd_type= ((ICPPFunction)b1_spcd).getType(); ICPPFunctionType b1_spcd_type= ((ICPPFunction)b1_spcd).getType();
assertInstance(b1_spcd_type.getReturnType(), ICPPBasicType.class); assertInstance(b1_spcd_type.getReturnType(), ICPPBasicType.class);
IType[] b1_spcd_ptypes= b1_spcd_type.getParameterTypes(); IType[] b1_spcd_ptypes= b1_spcd_type.getParameterTypes();
@ -878,14 +878,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b1_spcd_ptypes[1], ICPPTemplateTypeParameter.class); assertInstance(b1_spcd_ptypes[1], ICPPTemplateTypeParameter.class);
assertEquals("T1", ((ICPPTemplateTypeParameter)b1_spcd_ptypes[0]).getName()); assertEquals("T1", ((ICPPTemplateTypeParameter)b1_spcd_ptypes[0]).getName());
assertEquals("T2", ((ICPPTemplateTypeParameter)b1_spcd_ptypes[1]).getName()); assertEquals("T2", ((ICPPTemplateTypeParameter)b1_spcd_ptypes[1]).getName());
IParameter[] b1_spcd_pms= ((ICPPFunction)b1_spcd).getParameters(); IParameter[] b1_spcd_pms= ((ICPPFunction)b1_spcd).getParameters();
assertEquals(2, b1_spcd_pms.length); assertEquals(2, b1_spcd_pms.length);
assertInstance(b1_spcd_pms[0].getType(), ICPPTemplateTypeParameter.class); assertInstance(b1_spcd_pms[0].getType(), ICPPTemplateTypeParameter.class);
assertInstance(b1_spcd_pms[1].getType(), ICPPTemplateTypeParameter.class); assertInstance(b1_spcd_pms[1].getType(), ICPPTemplateTypeParameter.class);
assertEquals("T1", ((ICPPTemplateTypeParameter)b1_spcd_pms[0].getType()).getName()); assertEquals("T1", ((ICPPTemplateTypeParameter)b1_spcd_pms[0].getType()).getName());
assertEquals("T2", ((ICPPTemplateTypeParameter)b1_spcd_pms[1].getType()).getName()); assertEquals("T2", ((ICPPTemplateTypeParameter)b1_spcd_pms[1].getType()).getName());
ObjectMap b1_am= b1s.getArgumentMap(); ObjectMap b1_am= b1s.getArgumentMap();
assertEquals(2, b1_am.size()); assertEquals(2, b1_am.size());
assertInstance(b1_am.keyAt(0), ICPPTemplateTypeParameter.class); assertInstance(b1_am.keyAt(0), ICPPTemplateTypeParameter.class);
@ -911,17 +911,17 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
IBinding b0= getBindingFromASTName("foo(a)", 3); IBinding b0= getBindingFromASTName("foo(a)", 3);
assertInstance(b0, ICPPTemplateInstance.class); assertInstance(b0, ICPPTemplateInstance.class);
assertInstance(b0, ICPPFunction.class); assertInstance(b0, ICPPFunction.class);
ICPPFunction f= (ICPPFunction) b0; ICPPFunction f= (ICPPFunction) b0;
ICPPFunctionType type= f.getType(); ICPPFunctionType type= f.getType();
IType rt= type.getReturnType(); IType rt= type.getReturnType();
IType[] pts= type.getParameterTypes(); IType[] pts= type.getParameterTypes();
IParameter[] ps= f.getParameters(); IParameter[] ps= f.getParameters();
assertEquals(1, ps.length); assertEquals(1, ps.length);
ICPPParameter param= (ICPPParameter) ps[0]; ICPPParameter param= (ICPPParameter) ps[0];
assertInstance(param, ICPPSpecialization.class); assertInstance(param, ICPPSpecialization.class);
IType paramType= param.getType(); IType paramType= param.getType();
assertInstance(paramType, ICPPClassType.class); assertInstance(paramType, ICPPClassType.class);
ICPPParameter paramSpec= (ICPPParameter) ((ICPPSpecialization) param).getSpecializedBinding(); ICPPParameter paramSpec= (ICPPParameter) ((ICPPSpecialization) param).getSpecializedBinding();
@ -929,7 +929,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPTemplateTypeParameter ttp= (ICPPTemplateTypeParameter) paramSpec.getType(); ICPPTemplateTypeParameter ttp= (ICPPTemplateTypeParameter) paramSpec.getType();
assertEquals("T", ttp.getName()); assertEquals("T", ttp.getName());
assertNull(ttp.getDefault()); assertNull(ttp.getDefault());
ICPPTemplateInstance inst= (ICPPTemplateInstance) b0; ICPPTemplateInstance inst= (ICPPTemplateInstance) b0;
IBinding sp= inst.getSpecializedBinding(); IBinding sp= inst.getSpecializedBinding();
assertInstance(sp, ICPPFunction.class); assertInstance(sp, ICPPFunction.class);
@ -994,10 +994,10 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testClassSpecializations_180738() { public void testClassSpecializations_180738() {
IBinding b1a = getBindingFromASTName("Foo<B> b1;", 3); IBinding b1a = getBindingFromASTName("Foo<B> b1;", 3);
IBinding b1b = getBindingFromASTName("Foo<B> b1;", 6); IBinding b1b = getBindingFromASTName("Foo<B> b1;", 6);
assertInstance(b1a, ICPPClassType.class); assertInstance(b1a, ICPPClassType.class);
assertInstance(b1a, ICPPClassTemplate.class); assertInstance(b1a, ICPPClassTemplate.class);
assertInstance(b1b, ICPPClassType.class); assertInstance(b1b, ICPPClassType.class);
assertInstance(b1b, ICPPSpecialization.class); assertInstance(b1b, ICPPSpecialization.class);
ICPPSpecialization b1spc= (ICPPSpecialization) b1b; ICPPSpecialization b1spc= (ICPPSpecialization) b1b;
@ -1006,13 +1006,13 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(b1om.getAt(0), ICPPClassType.class); assertInstance(b1om.getAt(0), ICPPClassType.class);
ICPPClassType b1pct= (ICPPClassType) b1om.getAt(0); ICPPClassType b1pct= (ICPPClassType) b1om.getAt(0);
assertEquals("B", b1pct.getName()); assertEquals("B", b1pct.getName());
IBinding b2a = getBindingFromASTName("Foo<B> b2;", 3); IBinding b2a = getBindingFromASTName("Foo<B> b2;", 3);
IBinding b2b = getBindingFromASTName("Foo<B> b2;", 6); IBinding b2b = getBindingFromASTName("Foo<B> b2;", 6);
assertInstance(b2a, ICPPClassType.class); assertInstance(b2a, ICPPClassType.class);
assertInstance(b2a, ICPPClassTemplate.class); assertInstance(b2a, ICPPClassTemplate.class);
assertInstance(b2b, ICPPClassType.class); assertInstance(b2b, ICPPClassType.class);
assertInstance(b2b, ICPPSpecialization.class); assertInstance(b2b, ICPPSpecialization.class);
ICPPSpecialization b2spc= (ICPPSpecialization) b2b; ICPPSpecialization b2spc= (ICPPSpecialization) b2b;
@ -1122,21 +1122,21 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
IBinding ca= getBindingFromASTName("C<A>", 4); IBinding ca= getBindingFromASTName("C<A>", 4);
assertInstance(ca, ICPPClassType.class); assertInstance(ca, ICPPClassType.class);
assertInstance(ca, ICPPTemplateInstance.class); assertInstance(ca, ICPPTemplateInstance.class);
IBinding foo1= getBindingFromASTName("foo(c)", 3); IBinding foo1= getBindingFromASTName("foo(c)", 3);
IBinding da= getBindingFromASTName("D<A>", 4); IBinding da= getBindingFromASTName("D<A>", 4);
assertInstance(da, ICPPClassType.class); assertInstance(da, ICPPClassType.class);
assertInstance(da, ICPPTemplateInstance.class); assertInstance(da, ICPPTemplateInstance.class);
IBinding foo2= getBindingFromASTName("foo(d)", 3); IBinding foo2= getBindingFromASTName("foo(d)", 3);
IBinding foo3= getBindingFromASTName("foo(e)", 3); IBinding foo3= getBindingFromASTName("foo(e)", 3);
IBinding foo4= getBindingFromASTName("foo(cx)", 3); IBinding foo4= getBindingFromASTName("foo(cx)", 3);
assertEquals(foo1, foo2); assertEquals(foo2, foo3); assertEquals(foo1, foo2); assertEquals(foo2, foo3);
assertEquals(foo3, foo4); assertEquals(foo3, foo4);
} }
// template<typename T> // template<typename T>
// class A {}; // class A {};
// //
@ -1144,7 +1144,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// //
// template<> // template<>
// class A<B> {}; // class A<B> {};
// class C {}; // class C {};
// //
// A<B> ab; // A<B> ab;
@ -1152,15 +1152,15 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testEnclosingScopes_a() throws Exception { public void testEnclosingScopes_a() throws Exception {
ICPPSpecialization b0= getBindingFromASTName("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class); ICPPSpecialization b0= getBindingFromASTName("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class);
ICPPTemplateInstance b1= getBindingFromASTName("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class); ICPPTemplateInstance b1= getBindingFromASTName("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
ICPPClassType sc0= assertInstance(b0.getSpecializedBinding(), ICPPClassType.class); ICPPClassType sc0= assertInstance(b0.getSpecializedBinding(), ICPPClassType.class);
ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class); ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class);
assertTrue(sc0.isSameType(sc1)); assertTrue(sc0.isSameType(sc1));
assertNull(sc0.getScope()); assertNull(sc0.getScope());
assertNull(b0.getScope()); assertNull(b0.getScope());
} }
// template<typename T> // template<typename T>
// class A { // class A {
// public: // public:
@ -1174,7 +1174,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// public: // public:
// class B {}; // class B {};
// }; // };
// #include "header.h" // #include "header.h"
// void refs() { // void refs() {
// A<C>::B acb; // A<C>::B acb;
@ -1184,7 +1184,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPClassType b0= getBindingFromASTName("B acb", 1, ICPPClassType.class); ICPPClassType b0= getBindingFromASTName("B acb", 1, ICPPClassType.class);
ICPPClassType b1= getBindingFromASTName("B adb", 1, ICPPClassType.class, ICPPSpecialization.class); ICPPClassType b1= getBindingFromASTName("B adb", 1, ICPPClassType.class, ICPPSpecialization.class);
ICPPClassType b2= getBindingFromASTName("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class); ICPPClassType b2= getBindingFromASTName("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class);
IIndexBinding[] sr = getIndex().findBindings("A".toCharArray(), new IndexFilter() { IIndexBinding[] sr = getIndex().findBindings("A".toCharArray(), new IndexFilter() {
@Override @Override
public boolean acceptBinding(IBinding binding) throws CoreException { public boolean acceptBinding(IBinding binding) throws CoreException {
@ -1193,7 +1193,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
}, npm()); }, npm());
assertTrue(sr.length == 1); assertTrue(sr.length == 1);
ICPPClassType b3= (ICPPClassType) sr[0]; ICPPClassType b3= (ICPPClassType) sr[0];
sr = getIndex().findBindings(new char[][] {"A".toCharArray(), "B".toCharArray()}, new IndexFilter() { sr = getIndex().findBindings(new char[][] {"A".toCharArray(), "B".toCharArray()}, new IndexFilter() {
@Override @Override
public boolean acceptBinding(IBinding binding) throws CoreException { public boolean acceptBinding(IBinding binding) throws CoreException {
@ -1202,19 +1202,19 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
}, npm()); }, npm());
assertTrue(sr.length == 1); assertTrue(sr.length == 1);
ICPPClassType b4= (ICPPClassType) sr[0]; ICPPClassType b4= (ICPPClassType) sr[0];
assertFalse(b0 instanceof ICPPSpecialization); assertFalse(b0 instanceof ICPPSpecialization);
IIndexScope s0= (IIndexScope) b0.getScope(), s4= (IIndexScope) b4.getScope(); IIndexScope s0= (IIndexScope) b0.getScope(), s4= (IIndexScope) b4.getScope();
IScope s1= b1.getScope(); IScope s1= b1.getScope();
assertTrue(((IType)s0.getScopeBinding()).isSameType((IType)((IIndexScope)b2.getCompositeScope()).getScopeBinding())); assertTrue(((IType)s0.getScopeBinding()).isSameType((IType)((IIndexScope)b2.getCompositeScope()).getScopeBinding()));
ICPPClassScope cs1= assertInstance(s1, ICPPClassScope.class); ICPPClassScope cs1= assertInstance(s1, ICPPClassScope.class);
assertInstance(cs1.getClassType(), ICPPClassType.class); assertInstance(cs1.getClassType(), ICPPClassType.class);
assertInstance(cs1.getClassType(), ICPPTemplateInstance.class); assertInstance(cs1.getClassType(), ICPPTemplateInstance.class);
assertTrue(((IType)((ICPPClassSpecialization) s4.getScopeBinding()).getSpecializedBinding()).isSameType( (IType) ((IIndexScope)b3.getCompositeScope()).getScopeBinding() )); assertTrue(((IType)((ICPPClassSpecialization) s4.getScopeBinding()).getSpecializedBinding()).isSameType( (IType) ((IIndexScope)b3.getCompositeScope()).getScopeBinding() ));
} }
// class A {}; // class A {};
// //
// template<typename T> // template<typename T>
@ -1230,18 +1230,18 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testEnclosingScopes_c() throws Exception { public void testEnclosingScopes_c() throws Exception {
ICPPClassType b0= getBindingFromASTName("Y::Z x", 1, ICPPClassType.class); ICPPClassType b0= getBindingFromASTName("Y::Z x", 1, ICPPClassType.class);
ICPPClassType b1= getBindingFromASTName("Z xayz", 1, ICPPClassType.class); ICPPClassType b1= getBindingFromASTName("Z xayz", 1, ICPPClassType.class);
IScope s0= b0.getScope(), s1= b1.getScope(); IScope s0= b0.getScope(), s1= b1.getScope();
ICPPClassScope cs0= assertInstance(s0, ICPPClassScope.class); ICPPClassScope cs0= assertInstance(s0, ICPPClassScope.class);
assertInstance(cs0.getClassType(), ICPPClassType.class); assertInstance(cs0.getClassType(), ICPPClassType.class);
assertInstance(cs0.getClassType(), ICPPSpecialization.class); assertInstance(cs0.getClassType(), ICPPSpecialization.class);
ICPPClassScope cs1= assertInstance(s1, ICPPClassScope.class); ICPPClassScope cs1= assertInstance(s1, ICPPClassScope.class);
assertInstance(cs1.getClassType(), ICPPClassType.class); assertInstance(cs1.getClassType(), ICPPClassType.class);
assertInstance(cs1.getClassType(), ICPPSpecialization.class); assertInstance(cs1.getClassType(), ICPPSpecialization.class);
} }
// class A {}; class B {}; // class A {}; class B {};
// //
// template<typename T1, typename T2> // template<typename T1, typename T2>
@ -1252,21 +1252,21 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// public: // public:
// class N {}; // class N {};
// }; // };
// X<B,A>::N n; // X<B,A>::N n;
public void testEnclosingScopes_d() throws Exception { public void testEnclosingScopes_d() throws Exception {
ICPPClassType b0= getBindingFromASTName("N n", 1, ICPPClassType.class, ICPPSpecialization.class); ICPPClassType b0= getBindingFromASTName("N n", 1, ICPPClassType.class, ICPPSpecialization.class);
ICPPClassType b1= assertInstance(((ICPPSpecialization) b0).getSpecializedBinding(), ICPPClassType.class); ICPPClassType b1= assertInstance(((ICPPSpecialization) b0).getSpecializedBinding(), ICPPClassType.class);
ICPPClassScope s0= assertInstance(b0.getScope(), ICPPClassScope.class); ICPPClassScope s0= assertInstance(b0.getScope(), ICPPClassScope.class);
assertInstance(s0.getClassType(), ICPPTemplateInstance.class); assertInstance(s0.getClassType(), ICPPTemplateInstance.class);
ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class); ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class);
assertInstance(s1.getClassType(), ICPPTemplateDefinition.class); assertInstance(s1.getClassType(), ICPPTemplateDefinition.class);
assertNull(s1.getClassType().getScope()); assertNull(s1.getClassType().getScope());
} }
// typedef signed int SI; // typedef signed int SI;
// //
// template <SI x> // template <SI x>
@ -1282,16 +1282,16 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertInstance(args.keyAt(0), ICPPTemplateNonTypeParameter.class); assertInstance(args.keyAt(0), ICPPTemplateNonTypeParameter.class);
assertEquals(1, args.size()); assertEquals(1, args.size());
} }
// template <class T> class A { // template <class T> class A {
// class B { T t; }; // class B { T t; };
// B b; // B b;
// }; // };
// void f() { // void f() {
// A<int> a; // A<int> a;
// a.b.t; // a.b.t;
// } // }
public void testNestedClassTypeSpecializations() throws Exception { public void testNestedClassTypeSpecializations() throws Exception {
ICPPField t2 = getBindingFromASTName("t;", 1, ICPPField.class); ICPPField t2 = getBindingFromASTName("t;", 1, ICPPField.class);
@ -1312,7 +1312,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// template<typename _Iterator, typename _Container> class normal_iterator { // template<typename _Iterator, typename _Container> class normal_iterator {
// protected: // protected:
// _Iterator _M_current; // _Iterator _M_current;
// //
// public: // public:
// typedef typename iterator_traits<_Iterator>::pointer pointer; // typedef typename iterator_traits<_Iterator>::pointer pointer;
// normal_iterator() : _M_current(_Iterator()) { } // normal_iterator() : _M_current(_Iterator()) { }
@ -1349,7 +1349,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPField t2 = getBindingFromASTName("member; // it->member", 6, ICPPField.class); ICPPField t2 = getBindingFromASTName("member; // it->member", 6, ICPPField.class);
ICPPClassType ct= t2.getClassOwner(); ICPPClassType ct= t2.getClassOwner();
assertEquals("MyStruct", ct.getName()); assertEquals("MyStruct", ct.getName());
final IType type = t2.getType(); final IType type = t2.getType();
assertTrue(type instanceof IBasicType); assertTrue(type instanceof IBasicType);
assertEquals(((IBasicType)type).getType(), IBasicType.t_int); assertEquals(((IBasicType)type).getType(), IBasicType.t_int);
@ -1382,7 +1382,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPTemplateArgument arg = paramMap.getArgument(0); ICPPTemplateArgument arg = paramMap.getArgument(0);
assertEquals(Long.valueOf(256), arg.getNonTypeValue().numericalValue()); assertEquals(Long.valueOf(256), arg.getNonTypeValue().numericalValue());
assertInstance(arg.getTypeOfNonTypeValue(), ICPPBasicType.class); assertInstance(arg.getTypeOfNonTypeValue(), ICPPBasicType.class);
ICPPFunction foo = getBindingFromASTName("foo(t)", 3, ICPPFunction.class); ICPPFunction foo = getBindingFromASTName("foo(t)", 3, ICPPFunction.class);
ICPPFunction bar = getBindingFromASTName("bar(t)", 3, ICPPFunction.class); ICPPFunction bar = getBindingFromASTName("bar(t)", 3, ICPPFunction.class);
} }
@ -1400,15 +1400,15 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPClassType b2= getBindingFromASTName("A<B, 'x'>", 9, ICPPClassType.class, ICPPTemplateInstance.class); ICPPClassType b2= getBindingFromASTName("A<B, 'x'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
ICPPClassType b3= getBindingFromASTName("A<B, 'y'>", 9, ICPPClassType.class, ICPPTemplateInstance.class); ICPPClassType b3= getBindingFromASTName("A<B, 'y'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
ICPPClassType b4= getBindingFromASTName("A<B, 'z'>", 9, ICPPClassType.class, ICPPTemplateInstance.class); ICPPClassType b4= getBindingFromASTName("A<B, 'z'>", 9, ICPPClassType.class, ICPPTemplateInstance.class);
assertTrue(!b2.isSameType(b3)); assertTrue(!b2.isSameType(b3));
assertTrue(!b3.isSameType(b4)); assertTrue(!b3.isSameType(b4));
assertTrue(!b4.isSameType(b2)); assertTrue(!b4.isSameType(b2));
ICPPClassType X= getBindingFromASTName("X x", 1, ICPPClassType.class); ICPPClassType X= getBindingFromASTName("X x", 1, ICPPClassType.class);
ICPPClassType Y= getBindingFromASTName("Y y", 1, ICPPClassType.class); ICPPClassType Y= getBindingFromASTName("Y y", 1, ICPPClassType.class);
ICPPClassType Z= getBindingFromASTName("Z z", 1, ICPPClassType.class); ICPPClassType Z= getBindingFromASTName("Z z", 1, ICPPClassType.class);
assertTrue(!X.isSameType(Y)); assertTrue(!X.isSameType(Y));
assertTrue(!Y.isSameType(Z)); assertTrue(!Y.isSameType(Z));
assertTrue(!Z.isSameType(X)); assertTrue(!Z.isSameType(X));
@ -1429,7 +1429,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPClassType Y= getBindingFromASTName("Y y; //2", 1, ICPPClassType.class); ICPPClassType Y= getBindingFromASTName("Y y; //2", 1, ICPPClassType.class);
getProblemFromASTName("X x; //3", 1); getProblemFromASTName("X x; //3", 1);
getProblemFromASTName("Y y; //4", 1); getProblemFromASTName("Y y; //4", 1);
assertTrue(!X.isSameType(Y)); assertTrue(!X.isSameType(Y));
} }
@ -1453,12 +1453,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPClassType a5c= getBindingFromASTName("A<FUNF>", 7, ICPPClassType.class, ICPPSpecialization.class); ICPPClassType a5c= getBindingFromASTName("A<FUNF>", 7, ICPPClassType.class, ICPPSpecialization.class);
ICPPClassType a5d= getBindingFromASTName("A<5>", 4, ICPPClassType.class, ICPPSpecialization.class); ICPPClassType a5d= getBindingFromASTName("A<5>", 4, ICPPClassType.class, ICPPSpecialization.class);
ICPPClassType a1= getBindingFromASTName("A<1>", 4, ICPPClassType.class, ICPPTemplateInstance.class); ICPPClassType a1= getBindingFromASTName("A<1>", 4, ICPPClassType.class, ICPPTemplateInstance.class);
assertTrue(a5a.isSameType(a5b)); assertTrue(a5a.isSameType(a5b));
assertTrue(a5b.isSameType(a5c)); assertTrue(a5b.isSameType(a5c));
assertTrue(a5c.isSameType(a5d)); assertTrue(a5c.isSameType(a5d));
assertTrue(a5d.isSameType(a5a)); assertTrue(a5d.isSameType(a5a));
assertTrue(!a1.isSameType(a5a)); assertTrue(!a1.isSameType(a5a));
assertTrue(!a1.isSameType(a5b)); assertTrue(!a1.isSameType(a5b));
assertTrue(!a1.isSameType(a5c)); assertTrue(!a1.isSameType(a5c));
@ -1489,7 +1489,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class); ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class);
assertFalse(th1sCtor instanceof ICPPSpecialization);ICPPTemplateNonTypeParameter np= ba.assertNonProblem("I)", 1, ICPPTemplateNonTypeParameter.class); assertFalse(th1sCtor instanceof ICPPSpecialization);ICPPTemplateNonTypeParameter np= ba.assertNonProblem("I)", 1, ICPPTemplateNonTypeParameter.class);
*/ */
ICPPTemplateNonTypeParameter np= getBindingFromASTName("I>(I)", 1, ICPPTemplateNonTypeParameter.class); ICPPTemplateNonTypeParameter np= getBindingFromASTName("I>(I)", 1, ICPPTemplateNonTypeParameter.class);
ICPPConstructor clazz= getBindingFromASTName("That<I>(I)", 4, ICPPConstructor.class); ICPPConstructor clazz= getBindingFromASTName("That<I>(I)", 4, ICPPConstructor.class);
ICPPConstructor ctor= getBindingFromASTName("That<I>(I)", 7, ICPPConstructor.class); ICPPConstructor ctor= getBindingFromASTName("That<I>(I)", 7, ICPPConstructor.class);
@ -1515,7 +1515,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertFalse(tid instanceof ICPPSpecialization); assertFalse(tid instanceof ICPPSpecialization);
ICPPConstructor th1sCtor= getBindingFromASTName("This() :", 4, ICPPConstructor.class); ICPPConstructor th1sCtor= getBindingFromASTName("This() :", 4, ICPPConstructor.class);
assertFalse(th1sCtor instanceof ICPPSpecialization); assertFalse(th1sCtor instanceof ICPPSpecialization);
ICPPTemplateTypeParameter np= getBindingFromASTName("I>()", 1, ICPPTemplateTypeParameter.class); ICPPTemplateTypeParameter np= getBindingFromASTName("I>()", 1, ICPPTemplateTypeParameter.class);
ICPPConstructor clazz= getBindingFromASTName("That<I>()", 4, ICPPConstructor.class); ICPPConstructor clazz= getBindingFromASTName("That<I>()", 4, ICPPConstructor.class);
ICPPConstructor ctor= getBindingFromASTName("That<I>()", 7, ICPPConstructor.class); ICPPConstructor ctor= getBindingFromASTName("That<I>()", 7, ICPPConstructor.class);
@ -1530,14 +1530,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testUniqueSpecializations_Bug241641() throws Exception { public void testUniqueSpecializations_Bug241641() throws Exception {
ICPPVariable v1= getBindingFromASTName("v1", 2, ICPPVariable.class); ICPPVariable v1= getBindingFromASTName("v1", 2, ICPPVariable.class);
ICPPVariable v2= getBindingFromASTName("v1", 2, ICPPVariable.class); ICPPVariable v2= getBindingFromASTName("v1", 2, ICPPVariable.class);
IType t1= v1.getType(); IType t1= v1.getType();
assertInstance(t1, ICPPClassType.class); assertInstance(t1, ICPPClassType.class);
ICPPClassType ct= (ICPPClassType) t1; ICPPClassType ct= (ICPPClassType) t1;
IBinding f1= ct.getCompositeScope().find("field")[0]; IBinding f1= ct.getCompositeScope().find("field")[0];
IBinding f2= ct.getCompositeScope().find("field")[0]; IBinding f2= ct.getCompositeScope().find("field")[0];
assertSame(f1, f2); assertSame(f1, f2);
} }
@ -1549,15 +1549,15 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testUniqueInstance_Bug241641() throws Exception { public void testUniqueInstance_Bug241641() throws Exception {
IASTName name= findName("v1", 2); IASTName name= findName("v1", 2);
ICPPVariable v1= getBindingFromASTName("v1", 2, ICPPVariable.class); ICPPVariable v1= getBindingFromASTName("v1", 2, ICPPVariable.class);
IType t1= v1.getType(); IType t1= v1.getType();
assertInstance(t1, ICPPTemplateInstance.class); assertInstance(t1, ICPPTemplateInstance.class);
ICPPTemplateInstance inst= (ICPPTemplateInstance) t1; ICPPTemplateInstance inst= (ICPPTemplateInstance) t1;
final ICPPClassTemplate tmplDef = (ICPPClassTemplate) inst.getTemplateDefinition(); final ICPPClassTemplate tmplDef = (ICPPClassTemplate) inst.getTemplateDefinition();
IBinding inst2= CPPTemplates.instantiate(tmplDef, inst.getTemplateArguments(), name); IBinding inst2= CPPTemplates.instantiate(tmplDef, inst.getTemplateArguments(), name);
assertSame(inst, inst2); assertSame(inst, inst2);
IBinding charInst1= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0))}, name); IBinding charInst1= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0))}, name);
IBinding charInst2= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0))}, name); IBinding charInst2= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateTypeArgument(new CPPBasicType(Kind.eChar, 0))}, name);
assertSame(charInst1, charInst2); assertSame(charInst1, charInst2);
@ -1582,9 +1582,9 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
} }
// template<class T, class U> class A {}; // template<class T, class U> class A {};
// template<class T> class A<T, int> { // template<class T> class A<T, int> {
// void foo(T t); // void foo(T t);
// }; // };
// template<class T> void A<T, int>::foo(T t) {} // template<class T> void A<T, int>::foo(T t) {}
public void testBug177418() throws Exception { public void testBug177418() throws Exception {
@ -1592,8 +1592,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPClassType owner= m.getClassOwner(); ICPPClassType owner= m.getClassOwner();
assertInstance(owner, ICPPClassTemplatePartialSpecialization.class); assertInstance(owner, ICPPClassTemplatePartialSpecialization.class);
} }
// template<typename T> class XT { // template<typename T> class XT {
// int f; // int f;
// void m(); // void m();
@ -1610,13 +1610,13 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertFalse(m instanceof ICPPUnknownBinding); assertFalse(m instanceof ICPPUnknownBinding);
m= getBindingFromASTName("m(); // 2", 1, ICPPMethod.class); m= getBindingFromASTName("m(); // 2", 1, ICPPMethod.class);
assertFalse(m instanceof ICPPUnknownBinding); assertFalse(m instanceof ICPPUnknownBinding);
ICPPField f= getBindingFromASTName("f; // 1", 1, ICPPField.class); ICPPField f= getBindingFromASTName("f; // 1", 1, ICPPField.class);
assertFalse(f instanceof ICPPUnknownBinding); assertFalse(f instanceof ICPPUnknownBinding);
f= getBindingFromASTName("f; // 2", 1, ICPPField.class); f= getBindingFromASTName("f; // 2", 1, ICPPField.class);
assertFalse(f instanceof ICPPUnknownBinding); assertFalse(f instanceof ICPPUnknownBinding);
} }
// template <typename T= int> class XT; // template <typename T= int> class XT;
// #include "header.h" // #include "header.h"
@ -1769,7 +1769,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertFalse(inst.isExplicitSpecialization()); assertFalse(inst.isExplicitSpecialization());
inst = getBindingFromASTName("Y<int>", 0); inst = getBindingFromASTName("Y<int>", 0);
assertTrue(inst.isExplicitSpecialization()); assertTrue(inst.isExplicitSpecialization());
inst = getBindingFromASTName("f(1)", 1); inst = getBindingFromASTName("f(1)", 1);
assertFalse(inst.isExplicitSpecialization()); assertFalse(inst.isExplicitSpecialization());
inst = getBindingFromASTName("g(1)", 1); inst = getBindingFromASTName("g(1)", 1);
@ -1819,7 +1819,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// }; // };
// int main() { // int main() {
// A<float, int> a; // A<float, int> a;
// a.f(0); // a.f(0);
// return 0; // return 0;
// } // }
public void testPartialSpecializationsOfClassTemplateSpecializations_332884() throws Exception { public void testPartialSpecializationsOfClassTemplateSpecializations_332884() throws Exception {
@ -1844,16 +1844,16 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
ICPPClassType ct= getBindingFromASTName("TXT", 0, ICPPClassType.class); ICPPClassType ct= getBindingFromASTName("TXT", 0, ICPPClassType.class);
ICPPMethod[] methods = ct.getAllDeclaredMethods(); ICPPMethod[] methods = ct.getAllDeclaredMethods();
assertEquals(2, methods.length); assertEquals(2, methods.length);
methods= ct.getConstructors(); methods= ct.getConstructors();
assertEquals(2, methods.length); assertEquals(2, methods.length);
methods= ct.getMethods(); methods= ct.getMethods();
assertEquals(14, methods.length); assertEquals(14, methods.length);
ICPPBase[] bases = ClassTypeHelper.getBases(ct, null); ICPPBase[] bases = ClassTypeHelper.getBases(ct, null);
assertEquals(1, bases.length); assertEquals(1, bases.length);
IField field = ct.findField("bfield"); IField field = ct.findField("bfield");
assertNotNull(field); assertNotNull(field);
@ -2034,12 +2034,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testSFINAE_b() throws Exception { public void testSFINAE_b() throws Exception {
checkBindings(); checkBindings();
} }
// struct CString { // struct CString {
// template<template<class,class> class ListT, class UType, class Alloc, typename StringT> // template<template<class,class> class ListT, class UType, class Alloc, typename StringT>
// void split(ListT<UType,Alloc>& out, const StringT& sep, bool keepEmptyElements = false, bool trimElements = true, bool emptyBefore = true) const; // void split(ListT<UType,Alloc>& out, const StringT& sep, bool keepEmptyElements = false, bool trimElements = true, bool emptyBefore = true) const;
// }; // };
// template<template<class,class> class ListT, class UType, class Alloc, class StringT> // template<template<class,class> class ListT, class UType, class Alloc, class StringT>
// void CString::split(ListT<UType,Alloc>& out, const StringT& sep, bool keepEmptyElements, bool trimElements, bool emptyBefore) const { // void CString::split(ListT<UType,Alloc>& out, const StringT& sep, bool keepEmptyElements, bool trimElements, bool emptyBefore) const {
// } // }

View file

@ -160,7 +160,7 @@ public class BaseTestCase extends TestCase {
try { try {
super.runBare(); super.runBare();
} catch (Throwable e) { } catch (Throwable e) {
testThrowable=e; testThrowable= e;
} }
if (statusLog.size() != fExpectedLoggedNonOK) { if (statusLog.size() != fExpectedLoggedNonOK) {
@ -168,7 +168,7 @@ public class BaseTestCase extends TestCase {
msg.append("non-OK status objects in log differs from actual (" + statusLog.size() + ").\n"); msg.append("non-OK status objects in log differs from actual (" + statusLog.size() + ").\n");
Throwable cause= null; Throwable cause= null;
if (!statusLog.isEmpty()) { if (!statusLog.isEmpty()) {
synchronized(statusLog) { synchronized (statusLog) {
for (IStatus status : statusLog) { for (IStatus status : statusLog) {
IStatus[] ss= {status}; IStatus[] ss= {status};
ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss; ss= status instanceof MultiStatus ? ((MultiStatus) status).getChildren() : ss;

View file

@ -20,7 +20,7 @@ public interface IASTBinaryTypeIdExpression extends IASTExpression {
public static final ASTNodeProperty OPERAND2 = new ASTNodeProperty("IASTBinaryTypeIdExpression.OPERAND2 [IASTTypeId]"); //$NON-NLS-1$ public static final ASTNodeProperty OPERAND2 = new ASTNodeProperty("IASTBinaryTypeIdExpression.OPERAND2 [IASTTypeId]"); //$NON-NLS-1$
/** /**
* Built-in type trait of g++. * Built-in type trait of g++.
*/ */
public static enum Operator {__is_base_of} public static enum Operator {__is_base_of}

View file

@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
@ -16,57 +16,57 @@ import org.eclipse.cdt.core.dom.ast.IType;
/** /**
* Binding for c++ functions. * Binding for c++ functions.
* *
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
*/ */
public interface ICPPFunction extends IFunction, ICPPBinding { public interface ICPPFunction extends IFunction, ICPPBinding {
/** /**
* Does this function have the mutable storage class specifier * Does this function have the mutable storage class specifier
*/ */
public boolean isMutable(); public boolean isMutable();
/** /**
* Is this an inline function * Is this an inline function
*/ */
@Override @Override
public boolean isInline(); public boolean isInline();
/** /**
* Returns whether this function is declared as extern "C". * Returns whether this function is declared as extern "C".
* @since 5.0 * @since 5.0
*/ */
public boolean isExternC(); public boolean isExternC();
/** /**
* Returns the exception specification for this function or <code>null</code> if there * Returns the exception specification for this function or <code>null</code> if there
* is no exception specification. * is no exception specification.
* @since 5.1
*/
public IType[] getExceptionSpecification();
/**
* {@inheritDoc}
* @since 5.1 * @since 5.1
*/ */
@Override public IType[] getExceptionSpecification();
/**
* {@inheritDoc}
* @since 5.1
*/
@Override
public ICPPFunctionType getType(); public ICPPFunctionType getType();
/** /**
* @since 5.2 * @since 5.2
*/ */
@Override @Override
public ICPPParameter[] getParameters(); public ICPPParameter[] getParameters();
/** /**
* @since 5.2
*/
public int getRequiredArgumentCount();
/**
* @since 5.2 * @since 5.2
*/ */
public boolean hasParameterPack(); public int getRequiredArgumentCount();
/**
* @since 5.2
*/
public boolean hasParameterPack();
/** /**
* Returns whether this is a function with a deleted function definition. * Returns whether this is a function with a deleted function definition.

View file

@ -6,10 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Niefer (IBM Corporation) - Initial API and implementation * Andrew Niefer (IBM Corporation) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.util; package org.eclipse.cdt.core.parser.util;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -42,9 +43,7 @@ public class ObjectMap extends ObjectTable<Object> {
@Override @Override
final public void clear() { final public void clear() {
super.clear(); super.clear();
for(int i = 0; i < valueTable.length; i++) { Arrays.fill(valueTable, null);
valueTable[i] = null;
}
} }
@Override @Override

View file

@ -417,8 +417,9 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
copy.fForContentAssist = fForContentAssist; copy.fForContentAssist = fForContentAssist;
copy.fOriginatingTranslationUnit = fOriginatingTranslationUnit; copy.fOriginatingTranslationUnit = fOriginatingTranslationUnit;
for (IASTDeclaration declaration : getDeclarations()) for (IASTDeclaration declaration : getDeclarations()) {
copy.addDeclaration(declaration == null ? null : declaration.copy(style)); copy.addDeclaration(declaration == null ? null : declaration.copy(style));
}
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
} }

View file

@ -227,7 +227,7 @@ public class Value implements IValue {
} }
/** /**
* Creates a value object representing the given boolean value. * Creates a value object representing the given boolean value.
*/ */
public static IValue create(boolean value) { public static IValue create(boolean value) {
return create(value ? 1 : 0); return create(value ? 1 : 0);
@ -357,7 +357,7 @@ public class Value implements IValue {
} }
/** /**
* Tests whether the value is a template parameter (or a parameter pack). * Tests whether the value is a template parameter (or a parameter pack).
* *
* @return the parameter id of the parameter, or <code>-1</code> if it is not a template * @return the parameter id of the parameter, or <code>-1</code> if it is not a template
* parameter. * parameter.
*/ */

View file

@ -263,7 +263,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
if (image.length > 1 && image[0] == 'L') if (image.length > 1 && image[0] == 'L')
return Value.create(ExpressionEvaluator.getChar(image, 2)); return Value.create(ExpressionEvaluator.getChar(image, 2));
return Value.create(ExpressionEvaluator.getChar(image, 1)); return Value.create(ExpressionEvaluator.getChar(image, 1));
} catch (EvalException e1) { } catch (EvalException e) {
return Value.UNKNOWN; return Value.UNKNOWN;
} }
} }
@ -271,7 +271,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
private IValue createIntValue() { private IValue createIntValue() {
try { try {
return Value.create(ExpressionEvaluator.getNumber(getValue())); return Value.create(ExpressionEvaluator.getNumber(getValue()));
} catch (EvalException e1) { } catch (EvalException e) {
return Value.UNKNOWN; return Value.UNKNOWN;
} }
} }

View file

@ -19,5 +19,4 @@ public class CPPConstructor extends CPPMethod implements ICPPConstructor {
public CPPConstructor(ICPPASTFunctionDeclarator declarator) { public CPPConstructor(ICPPASTFunctionDeclarator declarator) {
super(declarator); super(declarator);
} }
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Bryan Wilkinson (QNX) - Initial API and implementation * Bryan Wilkinson (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Niefer (IBM) - Initial API and implementation * Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -28,7 +28,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance { public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
private final ICPPTemplateArgument[] fArguments; private final ICPPTemplateArgument[] fArguments;
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) { public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap,
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
super(orig, owner, argMap, type, exceptionSpecs); super(orig, owner, argMap, type, exceptionSpecs);
fArguments = args; fArguments = args;
} }
@ -73,11 +74,11 @@ public class CPPFunctionInstance extends CPPFunctionSpecialization implements IC
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if( (obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)){ if ((obj instanceof ICPPTemplateInstance) && (obj instanceof ICPPFunction)) {
final ICPPTemplateInstance inst = (ICPPTemplateInstance)obj; final ICPPTemplateInstance inst = (ICPPTemplateInstance) obj;
ICPPFunctionType ct1= ((ICPPFunction)getSpecializedBinding()).getType(); ICPPFunctionType ct1= ((ICPPFunction) getSpecializedBinding()).getType();
ICPPFunctionType ct2= ((ICPPFunction)inst.getTemplateDefinition()).getType(); ICPPFunctionType ct2= ((ICPPFunction) inst.getTemplateDefinition()).getType();
if(!ct1.isSameType(ct2)) if (!ct1.isSameType(ct2))
return false; return false;
return CPPTemplates.haveSameArguments(this, inst); return CPPTemplates.haveSameArguments(this, inst);

View file

@ -183,10 +183,10 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
protected ICPPASTDeclSpecifier getDeclSpecifier(IASTDeclaration decl) { protected ICPPASTDeclSpecifier getDeclSpecifier(IASTDeclaration decl) {
if (decl instanceof IASTSimpleDeclaration) { if (decl instanceof IASTSimpleDeclaration) {
return (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier(); return (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
} }
if (decl instanceof IASTFunctionDefinition) { if (decl instanceof IASTFunctionDefinition) {
return (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier(); return (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) decl).getDeclSpecifier();
} }
return null; return null;
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Niefer (IBM) - Initial API and implementation * Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -29,8 +29,7 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
*/ */
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
implements ICPPFunctionTemplate, ICPPInternalTemplate { implements ICPPFunctionTemplate, ICPPInternalTemplate {
private ObjectMap instances;
private ObjectMap instances = null;
public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap, ICPPFunctionType type, IType[] exceptionSpecs) { public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap, ICPPFunctionType type, IType[] exceptionSpecs) {
super(original, owner, argumentMap, type, exceptionSpecs); super(original, owner, argumentMap, type, exceptionSpecs);

View file

@ -23,16 +23,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
*/ */
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod { public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) { public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap,
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
super(orig, owner, tpmap, args, type, exceptionSpecs); super(orig, owner, tpmap, args, type, exceptionSpecs);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
*/
@Override @Override
public int getVisibility() { public int getVisibility() {
return ((ICPPMethod)getTemplateDefinition()).getVisibility(); return ((ICPPMethod) getTemplateDefinition()).getVisibility();
} }
@Override @Override
@ -40,20 +38,14 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
return (ICPPClassType) getOwner(); return (ICPPClassType) getOwner();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
*/
@Override @Override
public boolean isVirtual() { public boolean isVirtual() {
return ((ICPPMethod)getTemplateDefinition()).isVirtual(); return ((ICPPMethod) getTemplateDefinition()).isVirtual();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual()
*/
@Override @Override
public boolean isPureVirtual() { public boolean isPureVirtual() {
return ((ICPPMethod)getTemplateDefinition()).isPureVirtual(); return ((ICPPMethod) getTemplateDefinition()).isPureVirtual();
} }
@Override @Override
@ -61,9 +53,6 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
return ((ICPPMethod) getTemplateDefinition()).isExplicit(); return ((ICPPMethod) getTemplateDefinition()).isExplicit();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
*/
@Override @Override
public boolean isDestructor() { public boolean isDestructor() {
char[] name = getNameCharArray(); char[] name = getNameCharArray();
@ -80,11 +69,11 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
@Override @Override
public boolean isOverride() { public boolean isOverride() {
return ((ICPPMethod)getTemplateDefinition()).isOverride(); return ((ICPPMethod) getTemplateDefinition()).isOverride();
} }
@Override @Override
public boolean isFinal() { public boolean isFinal() {
return ((ICPPMethod)getTemplateDefinition()).isFinal(); return ((ICPPMethod) getTemplateDefinition()).isFinal();
} }
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;

View file

@ -3041,8 +3041,10 @@ public class CPPSemantics {
if (type == null) if (type == null)
return null; return null;
ICPPEvaluation[] args = {new EvalFixed(type, LVALUE, Value.UNKNOWN), ICPPEvaluation[] args = {
((ICPPASTExpression) expr.getOperand()).getEvaluation()}; new EvalFixed(type, LVALUE, Value.UNKNOWN),
((ICPPASTExpression) expr.getOperand()).getEvaluation()
};
return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS); return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
} }

View file

@ -96,7 +96,7 @@ public class EvalFunctionCall extends CPPEvaluation {
if (isTypeDependent()) if (isTypeDependent())
return null; return null;
IType t= SemanticUtil.getNestedType(fArguments[0].getTypeOrFunctionSet(point), TDEF|REF|CVTYPE); IType t= SemanticUtil.getNestedType(fArguments[0].getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
if (t instanceof ICPPClassType) { if (t instanceof ICPPClassType) {
return CPPSemantics.findOverloadedOperator(point, fArguments, t, OverloadableOperator.PAREN, LookupMode.NO_GLOBALS); return CPPSemantics.findOverloadedOperator(point, fArguments, t, OverloadableOperator.PAREN, LookupMode.NO_GLOBALS);
} }
@ -118,9 +118,8 @@ public class EvalFunctionCall extends CPPEvaluation {
if (overload != null) if (overload != null)
return ExpressionTypes.typeFromFunctionCall(overload); return ExpressionTypes.typeFromFunctionCall(overload);
final ICPPEvaluation arg0 = fArguments[0]; final ICPPEvaluation arg0 = fArguments[0];
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF|REF|CVTYPE); IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
if (t instanceof ICPPClassType) { if (t instanceof ICPPClassType) {
return ProblemType.UNKNOWN_FOR_EXPRESSION; return ProblemType.UNKNOWN_FOR_EXPRESSION;
} }

View file

@ -175,8 +175,9 @@ public class EvalMemberAccess extends CPPEvaluation {
* examine for type information. * examine for type information.
*/ */
ICPPEvaluation[] args= {new EvalFixed(type, LVALUE, Value.UNKNOWN)}; ICPPEvaluation[] args= { new EvalFixed(type, LVALUE, Value.UNKNOWN) };
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType, OverloadableOperator.ARROW, LookupMode.NO_GLOBALS); ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType,
OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
if (op == null) if (op == null)
break; break;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c; package org.eclipse.cdt.internal.core.index.composite.c;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c; package org.eclipse.cdt.internal.core.index.composite.c;
@ -24,28 +24,28 @@ class CompositeCParameter extends CompositeCBinding implements IParameter {
@Override @Override
public IType getType() { public IType getType() {
IType rtype = ((IParameter)rbinding).getType(); IType rtype = ((IParameter) rbinding).getType();
return cf.getCompositeType(rtype); return cf.getCompositeType(rtype);
} }
@Override @Override
public boolean isAuto() { public boolean isAuto() {
return ((IParameter)rbinding).isAuto(); return ((IParameter) rbinding).isAuto();
} }
@Override @Override
public boolean isExtern() { public boolean isExtern() {
return ((IParameter)rbinding).isExtern(); return ((IParameter) rbinding).isExtern();
} }
@Override @Override
public boolean isRegister() { public boolean isRegister() {
return ((IParameter)rbinding).isRegister(); return ((IParameter) rbinding).isRegister();
} }
@Override @Override
public boolean isStatic() { public boolean isStatic() {
return ((IParameter)rbinding).isStatic(); return ((IParameter) rbinding).isStatic();
} }
@Override @Override

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c; package org.eclipse.cdt.internal.core.index.composite.c;
@ -24,18 +24,18 @@ class CompositeCVariable extends CompositeCBinding implements IVariable {
@Override @Override
public IType getType() { public IType getType() {
IType rtype = ((IVariable)rbinding).getType(); IType rtype = ((IVariable) rbinding).getType();
return cf.getCompositeType(rtype); return cf.getCompositeType(rtype);
} }
@Override @Override
public boolean isAuto() { public boolean isAuto() {
return ((IVariable)rbinding).isAuto(); return ((IVariable) rbinding).isAuto();
} }
@Override @Override
public boolean isExtern() { public boolean isExtern() {
return ((IVariable)rbinding).isExtern(); return ((IVariable) rbinding).isExtern();
} }
@Override @Override
@ -45,11 +45,11 @@ class CompositeCVariable extends CompositeCBinding implements IVariable {
@Override @Override
public boolean isStatic() { public boolean isStatic() {
return ((IVariable)rbinding).isStatic(); return ((IVariable) rbinding).isStatic();
} }
@Override @Override
public IValue getInitialValue() { public IValue getInitialValue() {
return ((IVariable)rbinding).getInitialValue(); return ((IVariable) rbinding).getInitialValue();
} }
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Ferguson (Symbian) - Initial implementation * Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp; package org.eclipse.cdt.internal.core.index.composite.cpp;
@ -25,42 +25,42 @@ class CompositeCPPVariable extends CompositeCPPBinding implements ICPPVariable {
@Override @Override
public boolean isMutable() { public boolean isMutable() {
return ((ICPPVariable)rbinding).isMutable(); return ((ICPPVariable) rbinding).isMutable();
} }
@Override @Override
public boolean isExternC() { public boolean isExternC() {
return ((ICPPVariable)rbinding).isExternC(); return ((ICPPVariable) rbinding).isExternC();
} }
@Override @Override
public IType getType() { public IType getType() {
IType rtype = ((ICPPVariable)rbinding).getType(); IType rtype = ((ICPPVariable) rbinding).getType();
return cf.getCompositeType(rtype); return cf.getCompositeType(rtype);
} }
@Override @Override
public boolean isAuto() { public boolean isAuto() {
return ((ICPPVariable)rbinding).isAuto(); return ((ICPPVariable) rbinding).isAuto();
} }
@Override @Override
public boolean isExtern() { public boolean isExtern() {
return ((ICPPVariable)rbinding).isExtern(); return ((ICPPVariable) rbinding).isExtern();
} }
@Override @Override
public boolean isRegister() { public boolean isRegister() {
return ((ICPPVariable)rbinding).isRegister(); return ((ICPPVariable) rbinding).isRegister();
} }
@Override @Override
public boolean isStatic() { public boolean isStatic() {
return ((ICPPVariable)rbinding).isStatic(); return ((ICPPVariable) rbinding).isStatic();
} }
@Override @Override
public IValue getInitialValue() { public IValue getInitialValue() {
return ((ICPPVariable)rbinding).getInitialValue(); return ((ICPPVariable) rbinding).getInitialValue();
} }
} }

View file

@ -1,11 +1,11 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Corporation - initial implementation * IBM Corporation - initial implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207 * Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
@ -73,9 +73,9 @@ public class ExpressionEvaluator {
if (LA() == IToken.tQUESTION) { if (LA() == IToken.tQUESTION) {
consume(); consume();
long r2 = expression(); long r2 = expression();
if (LA() == IToken.tCOLON) if (LA() == IToken.tCOLON) {
consume(); consume();
else { } else {
throw new EvalException(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, null); throw new EvalException(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, null);
} }
long r3 = conditionalExpression(); long r3 = conditionalExpression();
@ -139,11 +139,12 @@ public class ExpressionEvaluator {
for (int t = LA(); t == IToken.tEQUAL || t == IToken.tNOTEQUAL; t = LA()) { for (int t = LA(); t == IToken.tEQUAL || t == IToken.tNOTEQUAL; t = LA()) {
consume(); consume();
long r2 = relationalExpression(); long r2 = relationalExpression();
if (t == IToken.tEQUAL) if (t == IToken.tEQUAL) {
r1 = (r1 == r2) ? 1 : 0; r1 = (r1 == r2) ? 1 : 0;
else } else {
// t == tNOTEQUAL // t == tNOTEQUAL
r1 = (r1 != r2) ? 1 : 0; r1 = (r1 != r2) ? 1 : 0;
}
} }
return r1; return r1;
} }
@ -179,11 +180,12 @@ public class ExpressionEvaluator {
for (int t = LA(); t == IToken.tSHIFTL || t == IToken.tSHIFTR; t = LA()) { for (int t = LA(); t == IToken.tSHIFTL || t == IToken.tSHIFTR; t = LA()) {
consume(); consume();
long r2 = additiveExpression(); long r2 = additiveExpression();
if (t == IToken.tSHIFTL) if (t == IToken.tSHIFTL) {
r1 = r1 << r2; r1 = r1 << r2;
else } else {
// t == tSHIFTR // t == tSHIFTR
r1 = r1 >> r2; r1 = r1 >> r2;
}
} }
return r1; return r1;
} }
@ -193,11 +195,12 @@ public class ExpressionEvaluator {
for (int t = LA(); t == IToken.tPLUS || t == IToken.tMINUS; t = LA()) { for (int t = LA(); t == IToken.tPLUS || t == IToken.tMINUS; t = LA()) {
consume(); consume();
long r2 = multiplicativeExpression(); long r2 = multiplicativeExpression();
if (t == IToken.tPLUS) if (t == IToken.tPLUS) {
r1 = r1 + r2; r1 = r1 + r2;
else } else {
// t == tMINUS // t == tMINUS
r1 = r1 - r2; r1 = r1 - r2;
}
} }
return r1; return r1;
} }
@ -207,13 +210,14 @@ public class ExpressionEvaluator {
for (int t = LA(); t == IToken.tSTAR || t == IToken.tDIV || t == IToken.tMOD; t = LA()) { for (int t = LA(); t == IToken.tSTAR || t == IToken.tDIV || t == IToken.tMOD; t = LA()) {
consume(); consume();
long r2 = unaryExpression(); long r2 = unaryExpression();
if (t == IToken.tSTAR) if (t == IToken.tSTAR) {
r1 = r1 * r2; r1 = r1 * r2;
else if (r2 != 0) { } else if (r2 != 0) {
if (t == IToken.tDIV) if (t == IToken.tDIV) {
r1 = r1 / r2; r1 = r1 / r2;
else } else {
r1 = r1 % r2; //tMOD r1 = r1 % r2; //tMOD
}
} else { } else {
throw new EvalException(IProblem.SCANNER_DIVIDE_BY_ZERO, null); throw new EvalException(IProblem.SCANNER_DIVIDE_BY_ZERO, null);
} }
@ -328,7 +332,7 @@ public class ExpressionEvaluator {
} }
long getValue(Token t) throws EvalException { long getValue(Token t) throws EvalException {
switch(t.getType()) { switch (t.getType()) {
case IToken.tCHAR: case IToken.tCHAR:
return getChar(t.getCharImage(), 1); return getChar(t.getCharImage(), 1);
case IToken.tLCHAR: case IToken.tLCHAR:
@ -386,7 +390,7 @@ public class ExpressionEvaluator {
} }
public static long getChar(char[] tokenImage, int i) throws EvalException { public static long getChar(char[] tokenImage, int i) throws EvalException {
if (i>=tokenImage.length) { if (i >= tokenImage.length) {
throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage); throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage);
} }
final char c= tokenImage[i]; final char c= tokenImage[i];
@ -398,7 +402,7 @@ public class ExpressionEvaluator {
throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage); throw new EvalException(IProblem.SCANNER_BAD_CHARACTER, tokenImage);
} }
final char d= tokenImage[i]; final char d= tokenImage[i];
switch(d) { switch (d) {
case '\\': case '"': case '\'': case '\\': case '"': case '\'':
return d; return d;
case 'a': return 7; case 'a': return 7;
@ -433,7 +437,7 @@ public class ExpressionEvaluator {
result= result*base + digit; result= result*base + digit;
} }
for (; i < to; i++) { for (; i < to; i++) {
switch(tokenImage[i]) { switch (tokenImage[i]) {
case 'u' : case 'l': case 'U': case 'L': case 'u' : case 'l': case 'U': case 'L':
break; break;
default: default:
@ -444,13 +448,13 @@ public class ExpressionEvaluator {
} }
private static int getDigit(char c) { private static int getDigit(char c) {
switch(c) { switch (c) {
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
return c-'0'; return c - '0';
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
return c-'a' + 10; return c - 'a' + 10;
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
return c-'A'+10; return c - 'A' + 10;
} }
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }

View file

@ -14,7 +14,7 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex;
/** /**
* Write lock on the index that can be yielded temporarily to unblock threads that need * Write lock on the index that can be yielded temporarily to unblock threads that need
* read access to the index. * read access to the index.
* @since 5.2 * @since 5.2
*/ */
public class YieldableIndexLock { public class YieldableIndexLock {
@ -30,7 +30,7 @@ public class YieldableIndexLock {
/** /**
* Acquires the lock. * Acquires the lock.
* *
* @throws InterruptedException * @throws InterruptedException
*/ */
public void acquire() throws InterruptedException { public void acquire() throws InterruptedException {
@ -51,7 +51,7 @@ public class YieldableIndexLock {
/** /**
* Yields the lock temporarily if it was held for YIELD_INTERVAL or more, and somebody is waiting * Yields the lock temporarily if it was held for YIELD_INTERVAL or more, and somebody is waiting
* for a read lock. * for a read lock.
* @throws InterruptedException * @throws InterruptedException
*/ */
public void yield() throws InterruptedException { public void yield() throws InterruptedException {
@ -64,7 +64,7 @@ public class YieldableIndexLock {
} }
/** /**
* @return Total time the lock was held in milliseconds. * @return Total time the lock was held in milliseconds.
*/ */
public long getCumulativeLockTime() { public long getCumulativeLockTime() {
return cumulativeLockTime; return cumulativeLockTime;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (QNX) - Initial API and implementation * Doug Schaefer (QNX) - Initial API and implementation
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c; package org.eclipse.cdt.internal.core.pdom.dom.c;
@ -31,15 +31,14 @@ import org.eclipse.core.runtime.CoreException;
* Binding for a function parameter in the index. * Binding for a function parameter in the index.
*/ */
final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding { final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE; private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
private static final int FLAG_OFFSET = NEXT_PARAM + Database.PTR_SIZE; private static final int FLAG_OFFSET = NEXT_PARAM + Database.PTR_SIZE;
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
public static final int RECORD_SIZE = FLAG_OFFSET + 1; public static final int RECORD_SIZE = FLAG_OFFSET + 1;
static { static {
assert RECORD_SIZE <= 22; // 23 would yield a 32-byte block assert RECORD_SIZE <= 22; // 23 would yield a 32-byte block
} }
private final IType fType; private final IType fType;
public PDOMCParameter(PDOMLinkage linkage, long record, IType type) { public PDOMCParameter(PDOMLinkage linkage, long record, IType type) {
super(linkage, record); super(linkage, record);
@ -50,7 +49,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
throws CoreException { throws CoreException {
super(linkage, parent, param.getNameCharArray()); super(linkage, parent, param.getNameCharArray());
fType= null; // this constructor is used for adding parameters to the database, only. fType= null; // this constructor is used for adding parameters to the database, only.
Database db = getDB(); Database db = getDB();
db.putRecPtr(record + NEXT_PARAM, 0); db.putRecPtr(record + NEXT_PARAM, 0);
@ -67,7 +66,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
public int getNodeType() { public int getNodeType() {
return IIndexCBindingConstants.CPARAMETER; return IIndexCBindingConstants.CPARAMETER;
} }
@Override @Override
public IType getType() { public IType getType() {
return fType; return fType;
@ -75,13 +74,13 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
@Override @Override
public boolean isAuto() { public boolean isAuto() {
byte flag = 1<<PDOMCAnnotation.AUTO_OFFSET; byte flag = 1 << PDOMCAnnotation.AUTO_OFFSET;
return hasFlag(flag, true); return hasFlag(flag, true);
} }
@Override @Override
public boolean isRegister() { public boolean isRegister() {
byte flag = 1<<PDOMCAnnotation.REGISTER_OFFSET; byte flag = 1 << PDOMCAnnotation.REGISTER_OFFSET;
return hasFlag(flag, false); return hasFlag(flag, false);
} }
@ -137,15 +136,14 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
public int getBindingConstant() { public int getBindingConstant() {
return getNodeType(); return getNodeType();
} }
@Override @Override
public void delete(PDOMLinkage linkage) throws CoreException { public void delete(PDOMLinkage linkage) throws CoreException {
PDOMCParameter p= this; PDOMCParameter p= this;
for (;;) { for (;;) {
long rec = p.getNextPtr(); long rec = p.getNextPtr();
p.flatDelete(linkage); p.flatDelete(linkage);
if (rec == 0) if (rec == 0)
return; return;
p= new PDOMCParameter(linkage, rec, null); p= new PDOMCParameter(linkage, rec, null);
} }
@ -153,8 +151,8 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
private void flatDelete(PDOMLinkage linkage) throws CoreException { private void flatDelete(PDOMLinkage linkage) throws CoreException {
super.delete(linkage); super.delete(linkage);
} }
public long getNextPtr() throws CoreException { public long getNextPtr() throws CoreException {
long rec = getDB().getRecPtr(record + NEXT_PARAM); long rec = getDB().getRecPtr(record + NEXT_PARAM);
return rec; return rec;
@ -164,7 +162,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
public boolean isFileLocal() throws CoreException { public boolean isFileLocal() throws CoreException {
return false; return false;
} }
@Override @Override
public IIndexFile getLocalToFile() throws CoreException { public IIndexFile getLocalToFile() throws CoreException {
return null; return null;
@ -192,8 +190,7 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
} }
return defValue; return defValue;
} }
@Override @Override
public boolean isExtern() { public boolean isExtern() {
return false; return false;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Bryan Wilkinson (QNX) - Initial API and implementation * Bryan Wilkinson (QNX) - Initial API and implementation
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
* Result of instantiating a class template. * Result of instantiating a class template.
*/ */
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance { class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0; private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
/** /**

View file

@ -42,38 +42,36 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
private static final short ANNOT_IS_DELETED = 9; private static final short ANNOT_IS_DELETED = 9;
/** /**
* Offset of total number of function parameters (relative to the * Offset of total number of function parameters (relative to the beginning of the record).
* beginning of the record).
*/ */
private static final int NUM_PARAMS = PDOMCPPBinding.RECORD_SIZE; private static final int NUM_PARAMS = PDOMCPPBinding.RECORD_SIZE;
/** /**
* Offset of pointer to the first parameter of this function (relative to * Offset of pointer to the first parameter of this function (relative to the beginning of the record).
* the beginning of the record).
*/ */
private static final int FIRST_PARAM = NUM_PARAMS + 4; private static final int FIRST_PARAM = NUM_PARAMS + 4;
/** /**
* Offset of pointer to the function type record of this function (relative to * Offset of pointer to the function type record of this function (relative to the beginning of the
* the beginning of the record). * record).
*/ */
protected static final int FUNCTION_TYPE= FIRST_PARAM + Database.PTR_SIZE; protected static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE;
/** /**
* Offset of hash of parameter information to allow fast comparison * Offset of hash of parameter information to allow fast comparison
*/ */
private static final int SIGNATURE_HASH = FUNCTION_TYPE + Database.TYPE_SIZE; private static final int SIGNATURE_HASH = FUNCTION_TYPE + Database.TYPE_SIZE;
/** /**
* Offset of start of exception specifications * Offset of start of exception specifications
*/ */
protected static final int EXCEPTION_SPEC = SIGNATURE_HASH + 4; // int protected static final int EXCEPTION_SPEC = SIGNATURE_HASH + 4; // int
/** /**
* Offset of annotation information (relative to the beginning of the record). * Offset of annotation information (relative to the beginning of the record).
*/ */
private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short
private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2; private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2;
/** /**
@ -82,13 +80,14 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT + 4; protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT + 4;
private short fAnnotation= -1; private short fAnnotation = -1;
private int fRequiredArgCount= -1; private int fRequiredArgCount = -1;
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final. private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, boolean setTypes) throws CoreException, DOMException { public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function,
boolean setTypes) throws CoreException, DOMException {
super(linkage, parent, function.getNameCharArray()); super(linkage, parent, function.getNameCharArray());
Database db = getDB(); Database db = getDB();
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function); Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0); getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
db.putShort(record + ANNOTATION, getAnnotation(function)); db.putShort(record + ANNOTATION, getAnnotation(function));
@ -99,7 +98,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
} }
private short getAnnotation(ICPPFunction function) { private short getAnnotation(ICPPFunction function) {
int annot= PDOMCPPAnnotation.encodeAnnotation(function) & 0xff; int annot = PDOMCPPAnnotation.encodeAnnotation(function) & 0xff;
if (function.hasParameterPack()) { if (function.hasParameterPack()) {
annot |= (1 << ANNOT_PARAMETER_PACK); annot |= (1 << ANNOT_PARAMETER_PACK);
} }
@ -122,39 +121,39 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@Override @Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException { public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof ICPPFunction) { if (newBinding instanceof ICPPFunction) {
ICPPFunction func= (ICPPFunction) newBinding; ICPPFunction func = (ICPPFunction) newBinding;
ICPPFunctionType newType; ICPPFunctionType newType;
ICPPParameter[] newParams; ICPPParameter[] newParams;
short newAnnotation; short newAnnotation;
int newBindingRequiredArgCount; int newBindingRequiredArgCount;
newType= func.getType(); newType = func.getType();
newParams = func.getParameters(); newParams = func.getParameters();
newAnnotation = getAnnotation(func); newAnnotation = getAnnotation(func);
newBindingRequiredArgCount= func.getRequiredArgumentCount(); newBindingRequiredArgCount = func.getRequiredArgumentCount();
fType= null; fType = null;
linkage.storeType(record + FUNCTION_TYPE, newType); linkage.storeType(record + FUNCTION_TYPE, newType);
PDOMCPPParameter oldParams= getFirstParameter(null); PDOMCPPParameter oldParams = getFirstParameter(null);
int requiredCount; int requiredCount;
if (oldParams != null && hasDeclaration()) { if (oldParams != null && hasDeclaration()) {
int parCount= 0; int parCount = 0;
requiredCount= 0; requiredCount = 0;
for (ICPPParameter newPar : newParams) { for (ICPPParameter newPar : newParams) {
parCount++; parCount++;
if (parCount <= newBindingRequiredArgCount && !oldParams.hasDefaultValue()) if (parCount <= newBindingRequiredArgCount && !oldParams.hasDefaultValue())
requiredCount= parCount; requiredCount = parCount;
oldParams.update(newPar); oldParams.update(newPar);
long next= oldParams.getNextPtr(); long next = oldParams.getNextPtr();
if (next == 0) if (next == 0)
break; break;
oldParams= new PDOMCPPParameter(linkage, next, null); oldParams = new PDOMCPPParameter(linkage, next, null);
} }
if (parCount < newBindingRequiredArgCount) { if (parCount < newBindingRequiredArgCount) {
requiredCount= newBindingRequiredArgCount; requiredCount = newBindingRequiredArgCount;
} }
} else { } else {
requiredCount= newBindingRequiredArgCount; requiredCount = newBindingRequiredArgCount;
setParameters(newParams); setParameters(newParams);
if (oldParams != null) { if (oldParams != null) {
oldParams.delete(linkage); oldParams.delete(linkage);
@ -162,10 +161,10 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
} }
final Database db = getDB(); final Database db = getDB();
db.putShort(record + ANNOTATION, newAnnotation); db.putShort(record + ANNOTATION, newAnnotation);
fAnnotation= newAnnotation; fAnnotation = newAnnotation;
db.putInt(record + REQUIRED_ARG_COUNT, requiredCount); db.putInt(record + REQUIRED_ARG_COUNT, requiredCount);
fRequiredArgCount= requiredCount; fRequiredArgCount = requiredCount;
long oldRec = db.getRecPtr(record + EXCEPTION_SPEC); long oldRec = db.getRecPtr(record + EXCEPTION_SPEC);
storeExceptionSpec(extractExceptionSpec(func)); storeExceptionSpec(extractExceptionSpec(func));
if (oldRec != 0) { if (oldRec != 0) {
@ -175,7 +174,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
} }
private void storeExceptionSpec(IType[] exceptionSpec) throws CoreException { private void storeExceptionSpec(IType[] exceptionSpec) throws CoreException {
long typelist= PDOMCPPTypeList.putTypes(this, exceptionSpec); long typelist = PDOMCPPTypeList.putTypes(this, exceptionSpec);
getDB().putRecPtr(record + EXCEPTION_SPEC, typelist); getDB().putRecPtr(record + EXCEPTION_SPEC, typelist);
} }
@ -183,43 +182,43 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
IType[] exceptionSpec; IType[] exceptionSpec;
if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isImplicit()) { if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isImplicit()) {
// Don't store the exception specification, compute it on demand. // Don't store the exception specification, compute it on demand.
exceptionSpec= null; exceptionSpec = null;
} else { } else {
exceptionSpec= binding.getExceptionSpecification(); exceptionSpec = binding.getExceptionSpecification();
} }
return exceptionSpec; return exceptionSpec;
} }
private void setParameters(ICPPParameter[] params) throws CoreException { private void setParameters(ICPPParameter[] params) throws CoreException {
final PDOMLinkage linkage = getLinkage(); final PDOMLinkage linkage = getLinkage();
final Database db= getDB(); final Database db = getDB();
db.putInt(record + NUM_PARAMS, params.length); db.putInt(record + NUM_PARAMS, params.length);
db.putRecPtr(record + FIRST_PARAM, 0); db.putRecPtr(record + FIRST_PARAM, 0);
PDOMCPPParameter next= null; PDOMCPPParameter next = null;
for (int i= params.length; --i >= 0;) { for (int i = params.length; --i >= 0;) {
next= new PDOMCPPParameter(linkage, this, params[i], next); next = new PDOMCPPParameter(linkage, this, params[i], next);
} }
db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord()); db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord());
} }
private void setType(ICPPFunctionType ft) throws CoreException { private void setType(ICPPFunctionType ft) throws CoreException {
fType= null; fType = null;
getLinkage().storeType(record + FUNCTION_TYPE, ft); getLinkage().storeType(record + FUNCTION_TYPE, ft);
} }
@Override @Override
public int getSignatureHash() throws CoreException { public int getSignatureHash() throws CoreException {
return getDB().getInt(record + SIGNATURE_HASH); return getDB().getInt(record + SIGNATURE_HASH);
} }
public static int getSignatureHash(PDOMLinkage linkage, long record) throws CoreException { public static int getSignatureHash(PDOMLinkage linkage, long record) throws CoreException {
return linkage.getDB().getInt(record + SIGNATURE_HASH); return linkage.getDB().getInt(record + SIGNATURE_HASH);
} }
public PDOMCPPFunction(PDOMLinkage linkage, long bindingRecord) { public PDOMCPPFunction(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord); super(linkage, bindingRecord);
} }
@Override @Override
protected int getRecordSize() { protected int getRecordSize() {
return RECORD_SIZE; return RECORD_SIZE;
@ -229,12 +228,12 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
public int getNodeType() { public int getNodeType() {
return IIndexCPPBindingConstants.CPPFUNCTION; return IIndexCPPBindingConstants.CPPFUNCTION;
} }
private PDOMCPPParameter getFirstParameter(IType type) throws CoreException { private PDOMCPPParameter getFirstParameter(IType type) throws CoreException {
long rec = getDB().getRecPtr(record + FIRST_PARAM); long rec = getDB().getRecPtr(record + FIRST_PARAM);
return rec != 0 ? new PDOMCPPParameter(getLinkage(), rec, type) : null; return rec != 0 ? new PDOMCPPParameter(getLinkage(), rec, type) : null;
} }
@Override @Override
public boolean isInline() { public boolean isInline() {
return getBit(getAnnotation(), PDOMCAnnotation.INLINE_OFFSET); return getBit(getAnnotation(), PDOMCAnnotation.INLINE_OFFSET);
@ -244,9 +243,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
public int getRequiredArgumentCount() { public int getRequiredArgumentCount() {
if (fRequiredArgCount == -1) { if (fRequiredArgCount == -1) {
try { try {
fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT); fRequiredArgCount = getDB().getInt(record + REQUIRED_ARG_COUNT);
} catch (CoreException e) { } catch (CoreException e) {
fRequiredArgCount= 0; fRequiredArgCount = 0;
} }
} }
return fRequiredArgCount; return fRequiredArgCount;
@ -255,9 +254,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
final protected short getAnnotation() { final protected short getAnnotation() {
if (fAnnotation == -1) { if (fAnnotation == -1) {
try { try {
fAnnotation= getDB().getShort(record + ANNOTATION); fAnnotation = getDB().getShort(record + ANNOTATION);
} catch (CoreException e) { } catch (CoreException e) {
fAnnotation= 0; fAnnotation = 0;
} }
} }
return fAnnotation; return fAnnotation;
@ -281,20 +280,20 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@Override @Override
public ICPPParameter[] getParameters() { public ICPPParameter[] getParameters() {
try { try {
PDOMLinkage linkage= getLinkage(); PDOMLinkage linkage = getLinkage();
Database db= getDB(); Database db = getDB();
ICPPFunctionType ft = getType(); ICPPFunctionType ft = getType();
IType[] ptypes= ft == null ? IType.EMPTY_TYPE_ARRAY : ft.getParameterTypes(); IType[] ptypes = ft == null ? IType.EMPTY_TYPE_ARRAY : ft.getParameterTypes();
int n = db.getInt(record + NUM_PARAMS); int n = db.getInt(record + NUM_PARAMS);
ICPPParameter[] result = new ICPPParameter[n]; ICPPParameter[] result = new ICPPParameter[n];
long next = db.getRecPtr(record + FIRST_PARAM); long next = db.getRecPtr(record + FIRST_PARAM);
for (int i = 0; i < n && next != 0; i++) { for (int i = 0; i < n && next != 0; i++) {
IType type= i<ptypes.length ? ptypes[i] : null; IType type = i < ptypes.length ? ptypes[i] : null;
final PDOMCPPParameter par = new PDOMCPPParameter(linkage, next, type); final PDOMCPPParameter par = new PDOMCPPParameter(linkage, next, type);
next= par.getNextPtr(); next = par.getNextPtr();
result[i]= par; result[i] = par;
} }
return result; return result;
} catch (CoreException e) { } catch (CoreException e) {
@ -304,29 +303,29 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
} }
@Override @Override
public final ICPPFunctionType getType() { public final ICPPFunctionType getType() {
if (fType == null) { if (fType == null) {
try { try {
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE); fType = (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED); fType = new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
} }
} }
return fType; return fType;
} }
@Override @Override
public boolean isAuto() { public boolean isAuto() {
// ISO/IEC 14882:2003 7.1.1.2 // ISO/IEC 14882:2003 7.1.1.2
return false; return false;
} }
@Override @Override
public boolean isDeleted() { public boolean isDeleted() {
return getBit(getAnnotation(), ANNOT_IS_DELETED); return getBit(getAnnotation(), ANNOT_IS_DELETED);
} }
@Override @Override
public boolean isExtern() { public boolean isExtern() {
return getBit(getAnnotation(), PDOMCAnnotation.EXTERN_OFFSET); return getBit(getAnnotation(), PDOMCAnnotation.EXTERN_OFFSET);
@ -335,7 +334,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@Override @Override
public boolean isRegister() { public boolean isRegister() {
// ISO/IEC 14882:2003 7.1.1.2 // ISO/IEC 14882:2003 7.1.1.2
return false; return false;
} }
@Override @Override
@ -360,24 +359,24 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@Override @Override
public Object clone() { public Object clone() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public int pdomCompareTo(PDOMBinding other) { public int pdomCompareTo(PDOMBinding other) {
int cmp = super.pdomCompareTo(other); int cmp = super.pdomCompareTo(other);
return cmp == 0 ? compareSignatures(this, other) : cmp; return cmp == 0 ? compareSignatures(this, other) : cmp;
} }
protected static int compareSignatures(IPDOMOverloader a, Object b) { protected static int compareSignatures(IPDOMOverloader a, Object b) {
if (b instanceof IPDOMOverloader) { if (b instanceof IPDOMOverloader) {
IPDOMOverloader bb= (IPDOMOverloader) b; IPDOMOverloader bb = (IPDOMOverloader) b;
try { try {
int mySM = a.getSignatureHash(); int mySM = a.getSignatureHash();
int otherSM = bb.getSignatureHash(); int otherSM = bb.getSignatureHash();
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1; return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
} catch(CoreException ce) { } catch (CoreException e) {
CCorePlugin.log(ce); CCorePlugin.log(e);
} }
} else { } else {
assert false; assert false;

View file

@ -86,7 +86,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
getLinkage().storeType(record + FUNCTION_TYPE, astFt); getLinkage().storeType(record + FUNCTION_TYPE, astFt);
} }
ICPPFunction origAstFunc= (ICPPFunction) ((ICPPSpecialization)astFunction).getSpecializedBinding(); ICPPFunction origAstFunc= (ICPPFunction) ((ICPPSpecialization) astFunction).getSpecializedBinding();
ICPPParameter[] origAstParams= origAstFunc.getParameters(); ICPPParameter[] origAstParams= origAstFunc.getParameters();
if (origAstParams.length == 0) { if (origAstParams.length == 0) {
db.putInt(record + NUM_PARAMS, 0); db.putInt(record + NUM_PARAMS, 0);
@ -98,14 +98,14 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
db.putRecPtr(record + FIRST_PARAM, 0); db.putRecPtr(record + FIRST_PARAM, 0);
PDOMCPPParameter origPar= null; PDOMCPPParameter origPar= null;
PDOMCPPParameterSpecialization next= null; PDOMCPPParameterSpecialization next= null;
for (int i= length-1; i >= 0; --i) { for (int i= length; --i >= 0;) {
// There may be fewer or less original parameters, because of parameter packs. // There may be fewer or less original parameters, because of parameter packs.
if (i < origAstParams.length - 1) { if (i < origAstParams.length - 1) {
// Normal case // Normal case
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null); origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[i], null);
} else if (origPar == null) { } else if (origPar == null) {
// Use last parameter // Use last parameter
origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length-1], null); origPar= new PDOMCPPParameter(linkage, specialized, origAstParams[origAstParams.length - 1], null);
} }
next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next); next= new PDOMCPPParameterSpecialization(linkage, this, astParams[i], origPar, next);
} }
@ -205,8 +205,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
if (fType == null) { if (fType == null) {
try { try {
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE); fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
} catch(CoreException ce) { } catch (CoreException e) {
CCorePlugin.log(ce); CCorePlugin.log(e);
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED); fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
} }
} }
@ -287,7 +287,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
@Override @Override
public int pdomCompareTo(PDOMBinding other) { public int pdomCompareTo(PDOMBinding other) {
int cmp= super.pdomCompareTo(other); int cmp= super.pdomCompareTo(other);
return cmp==0 ? PDOMCPPFunction.compareSignatures(this, other) : cmp; return cmp == 0 ? PDOMCPPFunction.compareSignatures(this, other) : cmp;
} }
@Override @Override

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (QNX) - Initial API and implementation * Doug Schaefer (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* IBM Corporation * IBM Corporation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -35,7 +35,6 @@ import org.eclipse.core.runtime.CoreException;
* Binding for a parameter of a c++ function in the index. * Binding for a parameter of a c++ function in the index.
*/ */
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBinding { class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBinding {
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE; private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
private static final int ANNOTATIONS = NEXT_PARAM + Database.PTR_SIZE; private static final int ANNOTATIONS = NEXT_PARAM + Database.PTR_SIZE;
private static final int FLAGS = ANNOTATIONS + 1; private static final int FLAGS = ANNOTATIONS + 1;
@ -44,10 +43,11 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
static { static {
assert RECORD_SIZE <= 22; // 23 would yield a 32-byte block assert RECORD_SIZE <= 22; // 23 would yield a 32-byte block
} }
private static final byte FLAG_DEFAULT_VALUE = 0x1; private static final byte FLAG_DEFAULT_VALUE = 0x1;
private final IType fType; private final IType fType;
public PDOMCPPParameter(PDOMLinkage linkage, long record, IType type) { public PDOMCPPParameter(PDOMLinkage linkage, long record, IType type) {
super(linkage, record); super(linkage, record);
fType= type; fType= type;
@ -57,7 +57,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
throws CoreException { throws CoreException {
super(linkage, parent, param.getNameCharArray()); super(linkage, parent, param.getNameCharArray());
fType= null; // this constructor is used for adding parameters to the database, only. fType= null; // this constructor is used for adding parameters to the database, only.
Database db = getDB(); Database db = getDB();
db.putByte(record + FLAGS, param.hasDefaultValue() ? FLAG_DEFAULT_VALUE : 0); db.putByte(record + FLAGS, param.hasDefaultValue() ? FLAG_DEFAULT_VALUE : 0);
db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord()); db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord());
@ -77,9 +77,9 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
db.putByte(record + FLAGS, FLAG_DEFAULT_VALUE); db.putByte(record + FLAGS, FLAG_DEFAULT_VALUE);
} else if (newPar.isParameterPack()) { } else if (newPar.isParameterPack()) {
db.putByte(record + FLAGS, (byte) 0); db.putByte(record + FLAGS, (byte) 0);
} }
storeAnnotations(db, newPar); storeAnnotations(db, newPar);
final char[] newName = newPar.getNameCharArray(); final char[] newName = newPar.getNameCharArray();
if (!CharArrayUtils.equals(newName, getNameCharArray())) { if (!CharArrayUtils.equals(newName, getNameCharArray())) {
updateName(newName); updateName(newName);
@ -95,7 +95,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
public int getNodeType() { public int getNodeType() {
return IIndexCPPBindingConstants.CPPPARAMETER; return IIndexCPPBindingConstants.CPPPARAMETER;
} }
@Override @Override
public String[] getQualifiedName() { public String[] getQualifiedName() {
return new String[] {getName()}; return new String[] {getName()};
@ -114,7 +114,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
@Override @Override
public boolean isMutable() { public boolean isMutable() {
// ISO/IEC 14882:2003 7.1.1.8 // ISO/IEC 14882:2003 7.1.1.8
return false; return false;
} }
@Override @Override
@ -125,14 +125,14 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
@Override @Override
public boolean isAuto() { public boolean isAuto() {
// ISO/IEC 14882:2003 7.1.1.2 // ISO/IEC 14882:2003 7.1.1.2
byte flag = 1<<PDOMCAnnotation.AUTO_OFFSET; byte flag = 1 << PDOMCAnnotation.AUTO_OFFSET;
return hasFlag(flag, true, ANNOTATIONS); return hasFlag(flag, true, ANNOTATIONS);
} }
@Override @Override
public boolean isExtern() { public boolean isExtern() {
// ISO/IEC 14882:2003 7.1.1.5 // ISO/IEC 14882:2003 7.1.1.5
return false; return false;
} }
@Override @Override
@ -143,14 +143,14 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
@Override @Override
public boolean isRegister() { public boolean isRegister() {
// ISO/IEC 14882:2003 7.1.1.2 // ISO/IEC 14882:2003 7.1.1.2
byte flag = 1<<PDOMCAnnotation.REGISTER_OFFSET; byte flag = 1 << PDOMCAnnotation.REGISTER_OFFSET;
return hasFlag(flag, true, ANNOTATIONS); return hasFlag(flag, true, ANNOTATIONS);
} }
@Override @Override
public boolean isStatic() { public boolean isStatic() {
// ISO/IEC 14882:2003 7.1.1.4 // ISO/IEC 14882:2003 7.1.1.4
return false; return false;
} }
@Override @Override
@ -198,12 +198,12 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
} }
return defValue; return defValue;
} }
@Override @Override
public IIndexFragment getFragment() { public IIndexFragment getFragment() {
return getPDOM(); return getPDOM();
} }
@Override @Override
public boolean hasDefinition() throws CoreException { public boolean hasDefinition() throws CoreException {
// parameter bindings do not span index fragments // parameter bindings do not span index fragments
@ -215,7 +215,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
// parameter bindings do not span index fragments // parameter bindings do not span index fragments
return true; return true;
} }
@Override @Override
public int getBindingConstant() { public int getBindingConstant() {
return getNodeType(); return getNodeType();
@ -227,7 +227,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
for (;;) { for (;;) {
long rec = p.getNextPtr(); long rec = p.getNextPtr();
p.flatDelete(linkage); p.flatDelete(linkage);
if (rec == 0) if (rec == 0)
return; return;
p= new PDOMCPPParameter(linkage, rec, null); p= new PDOMCPPParameter(linkage, rec, null);
} }
@ -246,7 +246,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
public boolean isFileLocal() throws CoreException { public boolean isFileLocal() throws CoreException {
return false; return false;
} }
@Override @Override
public IIndexFile getLocalToFile() throws CoreException { public IIndexFile getLocalToFile() throws CoreException {
return null; return null;

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Bryan Wilkinson (QNX) - Initial API and implementation * Bryan Wilkinson (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -44,7 +44,7 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam, public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam,
PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException { PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException {
super(linkage, parent, (ICPPSpecialization) astParam, original); super(linkage, parent, (ICPPSpecialization) astParam, original);
fType= null; // this constructor is used for adding parameters to the database, only. fType= null; // This constructor is used for adding parameters to the database, only.
Database db = getDB(); Database db = getDB();
db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord()); db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord());
@ -79,7 +79,7 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
if (parent instanceof ICPPSpecialization && parent instanceof ICPPFunction) { if (parent instanceof ICPPSpecialization && parent instanceof ICPPFunction) {
IParameter[] pars= ((ICPPFunction) parent).getParameters(); IParameter[] pars= ((ICPPFunction) parent).getParameters();
int parPos= -1; int parPos= -1;
for (parPos= 0; parPos<pars.length; parPos++) { for (parPos= 0; parPos < pars.length; parPos++) {
IParameter par= pars[parPos]; IParameter par= pars[parPos];
if (equals(par)) { if (equals(par)) {
break; break;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (QNX) - Initial API and implementation * Doug Schaefer (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* IBM Corporation * IBM Corporation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
* Binding for a c++ variable in the index, serves as a base class for fields. * Binding for a c++ variable in the index, serves as a base class for fields.
*/ */
class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable { class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
private static final int TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE; private static final int TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE;
private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE; private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE;
protected static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE; // byte protected static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE; // byte